# VecCreateSeqWithArray

Creates a standard,sequential array-style vector, where the user provides the array space to store the vector values.

### Synopsis

    #include "petscvec.h"
    PetscErrorCode  VecCreateSeqWithArray(MPI_Comm comm,PetscInt n,const PetscScalar array[],Vec *V)

Collective on MPI_Comm

### Input Parameter

| comm | - the communicator, should be PETSC_COMM_SELF
| n | - the vector length
| array | - memory where the vector elements are to be stored.

### Output Parameter

V -the vector

### C++ variants

| VecCreateSeqWithArray(PetscInt n,PetscScalar s[],Vec *x) |  | -> |  | VecCreateSeqWithArray(PETSC_COMM_SELF,n,s,x)

### Notes

Use VecDuplicate() or VecDuplicateVecs() to form additional vectors of the same type as an existing vector.

If the user-provided array is PETSC_NULL, then VecPlaceArray() can be used at a later stage to SET the array for storing the vector values.

PETSc does NOT free the array when the vector is destroyed via VecDestroy(). The user should not free the array until the vector is destroyed.

### See Also

VecCreateMPIWithArray(), VecCreate(), VecDuplicate(), VecDuplicateVecs(),
VecCreateGhost(), VecCreateSeq(), VecPlaceArray()

Level:intermediate
Location:src/vec/vec/impls/seq/bvec2.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/mat/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex13.c.html
src/ksp/ksp/examples/tutorials/ex33.c.html
src/ksp/ksp/examples/tutorials/ex13f90.F.html