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

Alicia Klinvex aklinvex at purdue.edu
Wed Nov 18 16:11:40 EST 2015

```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 <

> 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,
>
>
> _______________________________________________
> Trilinos-Users mailing list
> 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/20151118/6b371704/attachment.html>
```