You can use MatCreateMAIJ(A,2,&M) and a single MatMult(A,xy) where xy contains the vectors x and y interlaced [x_0, y_0, x_1, y_1, ...].
There is also MatMatMult(A,X,...,&Y) where X is a MATDENSE with two columns, but I would prefer the MAIJ variant above in most cases. Tyler Chen via petsc-users <petsc-users@mcs.anl.gov> writes: > Hello, > > I am looking for a way to compute two matrix vector products > simultaneously, where the matrix is the same for both products (i.e. Ax and > Ay). I know some numerical libraries have the concept of "block vectors" or > "basis vectors" and was wondering if there is anything similar in PETSc. > Right now I am just using two MatMults sequentially, but I'm hoping there > are probably better ways to do this. My matrices are MPIAIJ if that makes > any difference. > > Best, > Tyler