MatCreateVecs — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# MatCreateVecs

Get vector(s) compatible with the matrix, i.e. with the same parallel layout, `PetscLayout` for rows and columns

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatCreateVecs(Mat mat, Vec *right, Vec *left)

Collective

## Input Parameter

- mat - the matrix

## Output Parameters

- right - (optional) vector that the matrix can be multiplied against

- left - (optional) vector that the matrix vector product can be stored in

## Notes

The blocksize of the returned vectors is determined by the row and column block sizes set with `MatSetBlockSizes()` or the single blocksize (same for both) set by `MatSetBlockSize()`.

These are new vectors which are not owned by the mat, they should be destroyed in `VecDestroy()` when no longer needed

## See Also

Matrices, `Mat`, `Vec`, `VecCreate()`, `VecDestroy()`, `DMCreateGlobalVector()`

## Level

advanced

## Location

src/mat/interface/matrix.c

## Examples

src/ksp/ksp/tutorials/ex100.c
src/ksp/ksp/tutorials/ex54.c
src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex59.c
src/ksp/ksp/tutorials/ex100f.F90
src/ksp/ksp/tutorials/ex4.c
src/ksp/ksp/tutorials/ex52.c
src/ksp/ksp/tutorials/ex55.c
src/ksp/ksp/tutorials/ex27.c
src/ksp/ksp/tutorials/ex49.c

## Implementations

MatCreateVecs_Nest() in src/mat/impls/nest/matnest.c

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