[Trilinos-Users] Inserting values into an Epetra_CrsMatrix on 2x2-diagonal blocks
Nico Schlömer
nico.schloemer at gmail.com
Wed Aug 22 04:58:10 MDT 2012
I implemented it now using one call to SumIntoMyValues per matrix row
for (int k=0; k<n; k++)
{
idx[0] = 2*k;
idx[1] = 2*k + 1;
vals[0] = alpha + gamma;
vals[1] = beta;
TEUCHOS_ASSERT_EQUALITY(0, A.SumIntoMyValues(2*k, 2, vals, idx));
vals[0] = beta;
vals[1] = alpha - gamma;
TEUCHOS_ASSERT_EQUALITY(0, A.SumIntoMyValues(2*k+1, 2, vals, idx));
}
This works, but also generates a noticeable overhead with that many
calls to Epetra_CrsMatrix::SumIntoGlobalValues() and, implicitly,
Epetra_Util_binary_search().
If someone has a better idea, let me know.
--Nico
On Tue, Aug 21, 2012 at 6:56 PM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
> Hi,
>
> I have an Epetra_CrsMatrix here, constructed and filled, of which I used to
> update the diagonal by something like
>
> TEUCHOS_ASSERT_EQUALITY(0, A.ExtractDiagonalCopy(diag));
> TEUCHOS_ASSERT_EQUALITY(0, A.Update(1.0, v, 1.0));
> TEUCHOS_ASSERT_EQUALITY(0, A.ReplaceDiagonalValues(diag));
>
> Now I not only need to update the diagonal, but the 2x2 blocks on the
> diagonal (the matrix is effectively a 2x2-block matrix, but implemented with
> a regular map, not a block map).
> There doesn't seem to be a matching helper function, but maybe there's a
> recommended procedure?
>
> Cheers,
> Nico
More information about the Trilinos-Users
mailing list