PETSc version 3.17.4
Fix/Edit manual page

# MatCreateVecs

Get vector(s) compatible with the matrix, i.e. with the same parallel layout

### Synopsis

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

Collective on Mat

### 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().

### Notes

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

### See Also

MatCreate(), VecDestroy()

### Level

advanced

### Location

src/mat/interface/matrix.c

### Examples

src/mat/tutorials/ex9.c.html
src/mat/tutorials/ex5cu.cu.html
src/ksp/ksp/tutorials/ex4.c.html
src/ksp/ksp/tutorials/ex6.c.html
src/ksp/ksp/tutorials/ex7.c.html
src/ksp/ksp/tutorials/ex8.c.html
src/ksp/ksp/tutorials/ex10.c.html
src/ksp/ksp/tutorials/ex21.c.html
src/ksp/ksp/tutorials/ex27.c.html
src/ksp/ksp/tutorials/ex42.c.html
src/ksp/ksp/tutorials/ex49.c.html

### Implementations

MatCreateVecs_Nest in src/mat/impls/nest/matnest.c
MatCreateVecs_HT in src/mat/impls/transpose/htransm.c
MatCreateVecs_Transpose in src/mat/impls/transpose/transm.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages