[Trilinos-Users] Add dense rank 1 matrix to sparse matrix
Danielle Catherine Maddix
dcmaddix at stanford.edu
Mon Nov 23 13:30:21 EST 2015
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>
Sent: Wednesday, November 18, 2015 1:11 PM
To: Danielle Catherine Maddix
Cc: 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/20151123/8cd997bc/attachment.html>
More information about the Trilinos-Users
mailing list