[petsc-dev] How to check that MatMatMult is available

Pierre Jolivet pierre.jolivet at enseeiht.fr
Fri Sep 20 00:23:18 CDT 2019


Hello,
Given a Mat A, I’d like to know if there is an implementation available for doing C=A*B
I was previously using MatHasOperation(A, MATOP_MATMAT_MULT, &hasMatMatMult) but the result is not correct in at least two cases:
1) A is a MATTRANSPOSE and the underlying Mat B=A^T has a MatTransposeMatMult implementation (there is currently no MATOP_MATTRANSPOSEMAT_MULT)
2) A is a MATNEST. This could be fixed in MatHasOperation_Nest, by checking MATOP_MATMAT_MULT of all matrices in the MATNEST, but this would be incorrect again if there is a single MATTRANPOSE in there
What is then the proper way to check that I can indeed call MatMatMult(A,…)?
Do I need to copy/paste all this https://www.mcs.anl.gov/petsc/petsc-current/src/mat/interface/matrix.c.html#line9801 <https://www.mcs.anl.gov/petsc/petsc-current/src/mat/interface/matrix.c.html#line9801> in user code?

Thanks,
Pierre

PS: in my case, C and B are always of type MATDENSE. Should we handle this in MatMatMult and never error out for such a simple case. Indeed, one can just loop on the columns of B and C by doing multiple MatMult. This is what I’m currently doing in user code when hasMatMatMult == PETSC_FALSE.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190920/0ea76c64/attachment-0001.html>


More information about the petsc-dev mailing list