X+a*Y with PETSc matrix (Mat)

Hi,
As said in the title, I am trying to compute X=X+a*Y where X and Y are Mat PETSc matrices and a is a scalar. Is there a way to do this ? Here a stupid example :

load "PETSc"
mesh Th = square(10,10);
fespace Vh(Th,P1);

varf vX(u,v) = int2d(Th)(u*v) + on(1,u=0);

matrix X = vX(Vh,Vh);
matrix Y = vX(Vh,Vh);

Mat Xp(X);
Mat Yp(Y);
Mat Zp;
real a=2.0;

Yp = a*Xp + Yp;

I see something called MatAXPY in PETSc doc but I don’t know if it is available in FreeFem ? (I see it in PETSc-code.hpp)
I can do it with matrix format and then import the results in Mat but I loose the advantage of distributed matrices in large problem ?
Thanks for your help

You are in luck, this feature has been very recently added to FreeFEM develop branch, and it is available in FreeFEM 4.9 (released earlier this week).
You can simply do:

Yp += a*Xp;

Let me know if you need something else.

Thank you, I’ve install the 4.9 and now it works.