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
Options Database Key#
-mat_vec_type type - set the
VecTypeof the created vectors duringMatSetFromOptions()
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().
The VecType of the created vectors is determined by the MatType of mat. This can be overridden by using MatSetVecType() or the option -mat_vec_type.
These are new vectors which are not owned by the mat, they should be destroyed with VecDestroy() when no longer needed.
PETSc Vec always have all zero entries when created with MatCreateVecs() until routines such as VecSet() or VecSetValues()
are used to change the values. There is no reason to call VecZeroEntries() after creation.
See Also#
Matrices, Mat, Vec, VecCreate(), VecDestroy(), DMCreateGlobalVector(), MatSetVecType()
Level#
advanced
Location#
Examples#
src/mat/tutorials/ex3.c
src/ksp/pc/tutorials/ex4.c
src/ksp/ksp/tutorials/ex75f.F90
src/ksp/ksp/tutorials/ex76f.F90
src/snes/tutorials/ex13.c
src/ksp/ksp/tutorials/ex100f.F90
src/ksp/ksp/tutorials/ex82.c
src/mat/tutorials/ex9.c
src/snes/tutorials/ex73f90t.F90
src/ksp/ksp/tutorials/ex72.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