Skip to main content
`Ctrl`+`K`

# 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

        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 Notes

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

Matrices, `MatProduct`, `Mat`, `MatProductCreateWithMat()`, `MatProductSetType()`, `MatProductSetAlgorithm()`, `MatProductClear()`

## Level

intermediate

## Location

src/mat/interface/matproduct.c

## Examples

src/tao/pde_constrained/tutorials/parabolic.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages