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

Alicia Klinvex aklinvex at purdue.edu
Tue Nov 24 12:37:57 EST 2015


I don't know that much about AztecOO, but I can tell you what I know about
Belos/Ifpack (your other preconditioned Krylov solvers option).  Krylov
solvers don't need to know about the structure of your matrix; they just
need to be able to apply the matrix to a vector.  To construct a
preconditioner, you need more information.  Ifpack still doesn't require
you to explicitly form the matrix, but it does require you to be able to
provide a single row of the matrix at a time; it needs a RowMatrix, whereas
Krylov solvers only require an Operator with an Apply method.  I wonder if
you can construct a decent preconditioner out of your original CrsMatrix,
ignoring the rank 1 update?

These are your options, as far as I see it:
1.  Explicitly form the matrix so you can use our preconditioners
2.  Create a preconditioner from your original CrsMatrix (which already has
getRow implemented) and hope for the best
3.  Define a RowMatrix instead of an Operator, which will require you to
implement getRow, so that you can use our preconditioners
4.  Write your own preconditioner (as an Operator)
5.  Don't use preconditioning

On Tue, Nov 24, 2015 at 10:18 AM, Danielle Catherine Maddix <
dcmaddix at stanford.edu> wrote:

> Actually, yes when I explicitly added the
> line solver.SetAztecOption(AZ_precond, AZ_none); there was no error.
>
> We do need to use preconditioning for our problem though.  Will
> preconditioning not be compatible with this method?
>
>
> Thanks,
>
> DAnielle
>
>
>
>
>
> ------------------------------
> *From:* Alicia Klinvex <aklinvex at purdue.edu>
> *Sent:* Tuesday, November 24, 2015 7:15 AM
> *To:* Danielle Catherine Maddix
> *Cc:* trilinos-users at trilinos.org; Mark Hoemmen
> *Subject:* Re: [Trilinos-Users] Add dense rank 1 matrix to sparse matrix
>
> The only reason I can think of that would make AztecOO want to call
> getrow() is that it's trying to use a preconditioner.  (Krylov solvers
> should only care about the Apply method.)  Are you using a preconditioner?
>
> I don't know how much you want to change your code, but our other Krylov
> solver package Belos won't try to call getrow() for sure.
>
> On Tue, Nov 24, 2015 at 1:25 AM, Danielle Catherine Maddix <
> dcmaddix at stanford.edu> wrote:
>
>> 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> 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>
>>> *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> 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
>>>> https://trilinos.org/mailman/listinfo/trilinos-users
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20151124/5ef3328f/attachment-0001.html>


More information about the Trilinos-Users mailing list