:orphan: # MatProductCreate create a matrix to hold the result of a matrix-matrix product operation ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatProductCreate(Mat A, Mat B, Mat C, Mat *D) ``` Collective ## Input Parameters - ***A -*** the first matrix - ***B -*** the second matrix - ***C -*** the third matrix (or `NULL`) ## Output Parameter - ***D -*** the matrix whose values are to be computed via a matrix-matrix product operation ## Example ```none MatProductCreate(A,B,C,&D); or MatProductCreateWithMat(A,B,C,D) MatProductSetType(D, MATPRODUCT_AB or MATPRODUCT_AtB or MATPRODUCT_ABt or MATPRODUCT_PtAP or MATPRODUCT_RARt or MATPRODUCT_ABC) MatProductSetAlgorithm(D, alg) MatProductSetFill(D,fill) MatProductSetFromOptions(D) MatProductSymbolic(D) MatProductNumeric(D) Change numerical values in some of the matrices MatProductNumeric(D) ``` ## Notes Use `MatProductCreateWithMat()` if the matrix you wish computed, the `D` matrix, already exists. The information computed during the symbolic stage can be reused for new numerical computations with the same non-zero structure ## Developer Note It is undocumented what happens if the nonzero structure of the input matrices changes. Is the symbolic stage automatically redone? Does it crash? Is there error checking for it? ## See Also [](ch_matrices), `MatProduct`, `Mat`, `MatProductCreateWithMat()`, `MatProductSetType()`, `MatProductSetAlgorithm()`, `MatProductClear()` ## Level intermediate ## Location src/mat/interface/matproduct.c ## Examples src/tao/pde_constrained/tutorials/parabolic.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matproduct.c) [Index of all Mat routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)