← Back to team overview

dolfin team mailing list archive

Re: [Question #95871]: Matrix Addition

 

On Friday 01 January 2010 12:57:47 Pietro Maximoff wrote:
> New question #95871 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/95871
> 
> Hello
> 
> How do I add two matrices together using the C++ interface, i.e,  A = M + K
>  ?

The operator+ is not implemented in the C++ interface. You can do something 
like:

  Matrix A(M);
  A += K;

or

  Matrix A(M);
  A.axpy(1.0, K, true);

if you know they have the same sparsity pattern.

Johan

> The Matrix class has no function for this and axpy doesn't seem like the
>  right one to use.
> 
> Best wishes
> 
> Pietro
> 



Follow ups

References