VecDuplicateVecs#

Creates several vectors of the same type as an existing vector.

Synopsis#

#include "petscvec.h"   
PetscErrorCode VecDuplicateVecs(Vec v, PetscInt m, Vec *V[])

Collective

Input Parameters#

  • m - the number of vectors to obtain

  • v - a vector to mimic

Output Parameter#

  • V - location to put pointer to array of vectors

Notes#

Use VecDestroyVecs() to free the space. Use VecDuplicate() to form a single vector.

PETSc Vec always have all zero entries when created with VecDuplicateVecs() until routines such as VecSet() or VecSetValues() are used to change the values. There is no reason to call VecZeroEntries() after creation.

Some implementations ensure that the arrays accessed by each vector are contiguous in memory. Certain VecMDot() and VecMAXPY() implementations utilize this property to use BLAS 2 operations for higher efficiency. This is especially useful in KSPGMRES, see KSPGMRESSetPreAllocateVectors().

Fortran Note#

  Vec, pointer :: V(:)

See Also#

Vectors and Parallel Data, Vec, PETSc for Fortran Users, VecDestroyVecs(), VecDuplicate(), VecCreate(), VecMDot(), VecMAXPY(), KSPGMRES, KSPGMRESSetPreAllocateVectors()

Level#

intermediate

Location#

src/vec/vec/interface/vector.c

Examples#

src/vec/vec/tutorials/ex1.c
src/vec/vec/tutorials/ex19.c
src/vec/vec/tutorials/ex20f90.F90
src/ksp/ksp/tutorials/ex49.c
src/vec/vec/tutorials/ex1f90.F90
src/tao/pde_constrained/tutorials/parabolic.c
src/tao/pde_constrained/tutorials/hyperbolic.c


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