# [Trilinos-Users] Epetra_FEVector multiplication

Heroux, Michael A maherou at sandia.gov
Mon Jan 10 08:25:56 MST 2011

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

```