# [Trilinos-Users] Epetra_FEVector multiplication

Cristiano Malossi cristiano.malossi at epfl.ch
Mon Jan 10 09:09:55 MST 2011

```Dear Michael,

thank you for the support! Actually, I am implementing a Broyden method
to solve a nonlinear problem. In particular I have a matrix J that is a
distributed (and sparse) Epetra_FECrsMatrix which approximate the
Jacobian of my problem. Following the Broyden scheme, the full
computation that I need to perform (at each subiteration) is:

J = J + A * B^T,

where A and B are two distributed Epetra_FEVector. Therefore, I don't
need matrix C (with C = A * B^T) if it is possible to update directly J.
Otherwise, creating matrix C I can later use the Multiply method of
EpetraExt for the final sum.

The result of A * B^T is not a sparse matrix however, for the type of
applications I am working on, the size of the two vectors is never
bigger than about 200 elements. Therefore, if in Trilinos there is a
single function call to do the job I would really like to use it, even
if it is not the most efficient approach. I can use it to perform some
preliminary test to understand how Broyden behaves for my applications
and later decide to optimize the code if necessary.

Thank you!
Best regards,
Cristiano Malossi

On 01/10/2011 04:25 PM, Heroux, Michael A wrote:
> Cristiano,
>
> Do A and B have special properties that would make C sparse?  Might it be
> better for you to instead use A and B as-is?
>
> Specifically, suppose you want to compute y = Cx.  You could do it in two
> steps: z = B^Tx, y = Az.  There are kernels in the Epetra_Vector class to do
> these operations.
>
> Just checking to make sure.
>
> If indeed you need to form C, there is specific functionality to do so in
> one function call, but it would be very straight forward to build the matrix
> row-by-row.
>
> Mike
>
>
> On 1/10/11 3:32 AM, "Cristiano Malossi"<cristiano.malossi at epfl.ch>  wrote:
>
>> Hello,
>>
>> I need some help to perform a vector by vector multiplication in Trilinos.
>>
>> I have two distributed Epetra_FEVector, with the same map (and size),
>> say A and B.
>> I need to perform the following operation: C = A * B^T, where C is a
>> square Epetra_FECrsMatrix. The resulting matrix will then be used for
>> other matrix by matrix operations.
>>
>> Unfortunately I was not able to find an easy way to do that with Epetra
>> and/or EpetraExt packages. Therefore, I suppose that I should somehow
>> convert the vectors A and B to two Epetra_FECrsMatrix objects (of size
>> Nx1, with N the length of the vectors), and then use the
>> EpetraExt::MatrixMatrix::Multiply method for the computation of matrix
>> C. However I do not know if there is a smart way to do the conversion
>> from an Epetra_FEVector to an Epetra_FECrsMatrix (using a view for
>> instance?). Any suggestion is welcome!
>>
>> Thank you for your help.
>> Best regards,
>>
>>      Cristiano Malossi
>

```