# Re: [deal.II] A*diag(V) with mmult?

```Franck,

> How to perform the matrix multiplication
>
> A*diag(V)```
```
There is no function inside the library to do this, but you can write
it yourself by scaling the entry a_ij by v_i. Code should be something
like this (not tested):

for (SparseMatrix<double>::iterator it=A.begin();it!=A.end(); ++it)
it->value() = it->value * v[it->column()];

Best,
Timo

On Sun, Sep 18, 2016 at 12:01 PM, 'Franck Kalala' via deal.II User
> I am having a SparseMatrix A which has a certain sparsity pattern and a
> vector V.
>
> How to perform the matrix multiplication
>
> A*diag(V)
>
> where diag(V) is a diagonal matrix with the vector V in the main diagonal.
>
> is there any such function in dealii?
>
> how to create the SparseMatrix diag(V) for a given vector V?
>
> to my knowledge dealii on provided
>
> A.mmult(C,B,V)  for   C= A*diag(V)*B or
>
> A.mmult(C,B)  for   C= A*B
>
> Cheers
>
> --
> The deal.II project is located at
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.dealii.org_&d=CwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=nutqCiVLmVstYWjGLzjVBnkpm9fqmaOfCj5dSBZ-TZM&s=AzRYY0doLxrkmdpDhGlH6HDbgqaABDuNDwbbd0aM2GY&e=
>
> For mailing list/forum options, see
>
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> For more options, visit
>  .

--
Timo Heister
http://www.math.clemson.edu/~heister/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see