[Trilinos-Users] Resend: Problem with Multiply()

Williams, Alan B william at sandia.gov
Fri Jul 18 10:13:23 MDT 2008


Hi,

One thing about epetra that newer users often struggle with is the definition of the 4 maps that a matrix has: row-map, column-map, range-map and domain-map.

I've had success using rectangular matrices from file by doing this:

  Epetra_Comm ecomm = ...
  Epetra_Map* rowmap = NULL;
  Epetra_Map* colmap = NULL;
  Epetra_Map* domainmap = NULL;
  Epetra_Map* rangemap = NULL;
  Epetra_CrsMatrix* A = NULL;

  EpetraExt::MatrixMarketFileToBlockMaps(filename, ecomm, rowmap, colmap, rangemap, domainmap);

  EpetraExt::MatrixMarketFileToCrsMatrix(filename, *rowmap, *colmap, *rangemap, *domainmap, A);

The key is to not try to define all the maps yourself. The relationships between the different maps is often tricky to get correct.

The test program for the EpetraExt::MatrixMatrix::Multiply function performs these operations, and the test involves rectangular matrices in parallel. You can browse through that program here: packages/epetraext/test/MatrixMatrix/cxx_main.cpp

Note that this program performs matrix-matrix multiply, I'm not sure I've specifically exercised the matrix-vector multiply with rectangular matrices. So there is a possibility that there is a bug in there. But try the above method of letting the maps be defined and populated by Trilinos, and see if that helps.

Alan



> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov
> [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf
> Of Tudor Buican
> Sent: Friday, July 18, 2008 7:53 AM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] Resend: Problem with Multiply()
>
> I'm resending this message which may have not reached the list.
>
> ==============================================================
> Hi, everybody.
>
> I am trying to multiply a rectangular Epetra_CrsMatrix, which I
> construct from an MM file, by an Epetra_Vector, using the
> Multiply(...)
> method. It all works fine if I read in an MM file for a square matrix,
> but I run into problems with files for rectangular matrices.
>
> 1. Here is my MM file for a simple 12X10 matrix:
>
> %%MatrixMarket matrix coordinate real general
> % Generated 02-Jul-2008
> 12 10 10
> 1 1 1
> 2 2 1
> 5 3 1
> 6 4 1
> 7 5 1
> 9 6 1
> 9 7 1
> 10 8 1
> 11 9 1
> 12 10 1
>
> 2. I read in the file with
>
> Epetra_CrsMatrix* pNull;
> EpetraExt::MatrixMarketFileToCrsMatrix(argv[2], mMap, mMap, nMap,
> pNull);
>
> where mMap and nMap are constructed as
>
> Epetra_Map mMap(M, 0, Comm);
> Epetra_Map nMap(N, 0, Comm);
>
> with M=12 (No. of rows) and N=10 (No. of columns). The
> resulting matrix,
> pointed to by pNull, prints out as
>
> Number of Global Rows        = 12
> Number of Global Cols        = 10
> Number of Global Diagonals   = 2
> Number of Global Nonzeros    = 10
> Global Maximum Num Entries   = 2
>  ** Matrix is Lower Triangular **
>
> Number of My Rows        = 12
> Number of My Cols        = 10
> Number of My Diagonals   = 2
> Number of My Nonzeros    = 10
> My Maximum Num Entries   = 2
>
>    Processor    Row Index    Col Index           Value
>        0             0             0                       1
>        0             1             1                       1
>        0             4             2                       1
>        0             5             3                       1
>        0             6             4                       1
>        0             8             5                       1
>        0             8             6                       1
>        0             9             7                       1
>        0            10             8                       1
>        0            11             9                       1
>
> So far, so good.
>
> 3. However, the domain map for this matrix, as returned by pNull-
> >DomainMap(), is not nMap with its 10 global elements, but a
> map with 12
> global elements, just like the row and range maps. Moreover,
> the result
> is the same if I use nMap and mMap for range and domain maps,
> respectively!
>
> 4. If I try to multiply the above matrix by q, a 10-element
> Epetra_Vector constructed with nMap, with the result in p, a
> 12-element
> vector constructed with mMap,
>
>    pNull->Multiply(false, q, p);
>
> I get the following error messages:
>
> Epetra ERROR -3,
> ../../../../packages/epetra/src/Epetra_DistObject.cpp,
> line 110
> Epetra ERROR -3, ../../../../packages/epetra/src/Epetra_CrsMatrix.cpp,
> line 2353
>
> (I'm using Trilinos v. 8.0.4.)
>
> 5. However,
>
>    pNull->Multiply(true, q, p);
>
> works and q is multiplied by the transposed matrix, but as if
> this was a
> 12X12 problem, with q and the matrix being padded with 0s.
>
> ========================
>
> Can anybody figure out what it is that I'm doing wrong?
>
> Thanks in advance,
> -Tudor
>
> --
> Tudor N. Buican, PhD
> Managing Member
> SEA LLC
> phone: 505-271-9925, 505-818-7303
> fax: 505-271-9925
> email: tudor at timb.com
>
>
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users
>



More information about the Trilinos-Users mailing list