# VecPlaceArray
Allows one to replace the array in a vector with an array provided by the user. This is useful to avoid copying an array into a vector. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecPlaceArray(Vec vec, const PetscScalar array[])
```
Not Collective


## Input Parameters

- ***vec -*** the vector
- ***array -*** the array



## Notes
You can return to the original array with a call to `VecResetArray()`. `vec` does not take
ownership of `array` in any way. The user must free `array` themselves but be careful not to
do so before the vector has either been destroyed, had its original array restored with
`VecResetArray()` or permanently replaced with `VecReplaceArray()`.




## See Also
 `VecGetArray()`, `VecRestoreArray()`, `VecReplaceArray()`, `VecResetArray()`


## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/rvector.c.html#VecPlaceArray">src/vec/vec/interface/rvector.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex13.c.html">src/ksp/ksp/tutorials/ex13.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex13f90.F90.html">src/ksp/ksp/tutorials/ex13f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex61f.F90.html">src/ksp/ksp/tutorials/ex61f.F90.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/pbvec.c.html#VecPlaceArray_MPI">VecPlaceArray_MPI in src/vec/vec/impls/mpi/pbvec.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/dvec2.c.html#VecPlaceArray_Seq">VecPlaceArray_Seq in src/vec/vec/impls/seq/dvec2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx.html#VecPlaceArray_SeqKokkos">VecPlaceArray_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqcuda/veccuda.c.html#VecPlaceArray_SeqCUDA">VecPlaceArray_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqhip/vechip.hip.c.html#VecPlaceArray_SeqHIP">VecPlaceArray_SeqHIP in src/vec/vec/impls/seq/seqhip/vechip.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx.html#VecPlaceArray_SeqViennaCL">VecPlaceArray_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.c)


[Index of all Vec routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
