[Trilinos-Users] Add dense rank 1 matrix to sparse matrix

Danielle Catherine Maddix dcmaddix at stanford.edu
Tue Nov 24 03:25:05 EST 2015


To be more clear, it seems that the problem is that I have defined my x and b using my blockMap. I am using my finite element block matrix as Epetra_FEVbrMatrix and have defined my vectors using this block map as well. It seems that the vectors must be defined with A.OperatorDomainMap() and A.OperatorRangeMap(), respectively. I was unclear when writing OperatorDomainMap() and OperatorRangeMap(), since they only return an Epetra_Map rather than Epetra_BlockMap.  Is there not support for a BlockMap version?


Thanks,

Danielle


________________________________
From: Alicia Klinvex <aklinvex at purdue.edu>
Sent: Monday, November 23, 2015 12:31 PM
To: Danielle Catherine Maddix
Cc: trilinos-users at trilinos.org; Mark Hoemmen
Subject: Re: [Trilinos-Users] Add dense rank 1 matrix to sparse matrix

Hello Danielle,

As far as I know, Trilinos does not have a sparse vector class.  If you wanted to store your vector as a sparse matrix, you definitely could; I just don't know that it would be a great idea.  Hopefully somebody else on the list can help you with that :-)

  The sparse matrix multiplication and addition functions are in a separate package called EpetraExt: https://trilinos.org/docs/dev/packages/epetraext/doc/html/classEpetraExt_1_1MatrixMatrix.html.  I would definitely wait to hear back regarding the efficiency of such operations before making any changes to the current way you handle vectors though.

Hope that helps!
Alicia

On Mon, Nov 23, 2015 at 11:30 AM, Danielle Catherine Maddix <dcmaddix at stanford.edu<mailto:dcmaddix at stanford.edu>> wrote:

Hi Alicia,


Thank you for the clear and quick response. This was the exact functionality I was looking for.  The example was clear as well.


I just have one remaining question.  In our current code, this vector v in C = v*v^T, is compressed down to only storing its nonzero entries as a sparse vector.  I wanted to do the same here, but I do not see a vector constructor which will take in a graph with the nonzero indices, such as in the crsmatrix class.


I then thought about constructing v as crsmatrix with 1 row and then calling v.apply on x for the dot product.  Then, scaling v by this scalar.  There doesn't seem to be an available operation to add this to the vector from the first multiplication, since the update routine

Y = 1.0*Y + (v^Tx)*v, requires v to be a vector.


I was wondering if there was a better solution.  Also, would we be losing efficiency by storing the zeros and those entries being used in the dot product and addition or does Trilinos have a remove zeros routine?


Thank you!

Danielle


________________________________
From: Alicia Klinvex <aklinvex at purdue.edu<mailto:aklinvex at purdue.edu>>
Sent: Wednesday, November 18, 2015 1:11 PM
To: Danielle Catherine Maddix
Cc: trilinos-users at trilinos.org<mailto:trilinos-users at trilinos.org>
Subject: Re: [Trilinos-Users] Add dense rank 1 matrix to sparse matrix

Hello Danielle,

Is this what you're trying to do: Solve a linear system A x = b, where A = [some sparse matrix B] + [some rank 1 dense matrix C (which is never formed explicitly)].

If so, we do have a matrix-free interface you could use to avoid having to explicitly form A.  There's an example that uses this interface in Trilinos/packages/aztecoo/example/AztecOO_UserOpUserMat.  Essentially, you could define your own custom subclass of Epetra_Operator with an apply method that does the following:
* compute sparse matrix vector multiplication using B's apply method
* compute C*x by using Epetra_Vector operations such as dot-product
* add the two together using an Epetra_Vector operation

Does that make sense?  Please feel free to ask if this is unclear.

Thank you,
Alicia

On Wed, Nov 18, 2015 at 11:36 AM, Danielle Catherine Maddix <dcmaddix at stanford.edu<mailto:dcmaddix at stanford.edu>> wrote:

Hello,


I have been transferring my lab's finite element code to a trilinos framework for the linear solver. I have assembled the values into the global stiffness matrix of type Epetra_FEVbrMatrix.  However, in our current code at each time step for the linear solvers, such as GMRES, we compute the matrix vector products on this current values and then a matrix vector product by adding in the coupled boundary condition.  These are stored in a separate array.  Is there a way to interface with the AZTECOO solver to add in this matrix vector product at each iteration?

This coupled boundary matrix consists of an outer product.  Another option would be to add this rank 1 matrix to our sparse trilinos matrix. Can the Epetra_Operator be used for this? Is there an efficient built in method to add a sparse matrix to a dense rank 1 matrix? Perhaps using the wrapped blas routines? Forming the rank1 matrix will reduce the efficiency.

Let me know if you have any advice on how to proceed.


Thank you,

Danielle Maddix

_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at trilinos.org<mailto:Trilinos-Users at trilinos.org>
https://trilinos.org/mailman/listinfo/trilinos-users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20151124/01298e4a/attachment.html>


More information about the Trilinos-Users mailing list