Matrix Addition
Hello
How do I add two matrices together using the C++ interface, i.e, A = M + K ?
The Matrix class has no function for this and axpy doesn't seem like the right one to use.
Best wishes
Pietro
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- 2010-01-02
- Last query:
- 2010-01-02
- Last reply:
- 2010-01-01
|
#1 |
On Friday 01 January 2010 12:57:47 Pietro Maximoff wrote:
> New question #95871 on DOLFIN:
> https:/
>
> 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
>
Pietro Maximoff (segment-x) said : | #2 |
Thanks Johan Hake, that solved my question.