In the example in Figure , the vector data structure
( Vec) is used to store the solution and gradient for TAO
unconstrained minimization solvers. A new parallel or sequential
vector x of global dimension M is created with the
command
info = VecCreate(MPI_Comm comm,int m,int M,Vec *x);
where comm denotes the MPI communicator. The type of storage
for the vector may be set with either calls to VecSetType()
or VecSetFromOptions(). Additional vectors of the same type
can be formed with
info = VecDuplicate(Vec old,Vec *new);
The commands
info = VecSet(Vec X,PetscScalar value);
info = VecSetValues(Vec x,int n,int *indices,
Scalar *values,INSERT_VALUES);
respectively set all the components of a vector to a particular scalar
value and assign a different value to each component. More detailed
information about PETSc vectors, including their basic operations,
scattering/gathering, index sets, and distributed arrays, may be found
in the PETSc users manual.