:orphan:
# VecDuplicate
Creates a new vector of the same type as an existing vector.
## Synopsis
```
#include "petscvec.h"
PetscErrorCode VecDuplicate(Vec v, Vec *newv)
```
Collective
## Input Parameter
- ***v -*** a vector to mimic
## Output Parameter
- ***newv -*** location to put new vector
## Notes
`VecDuplicate()` DOES NOT COPY the vector entries, but rather allocates storage
for the new vector. Use `VecCopy()` to copy a vector.
Use `VecDestroy()` to free the space. Use `VecDuplicateVecs()` to get several
vectors.
## See Also
[](ch_vectors), `Vec`, `VecDestroy()`, `VecDuplicateVecs()`, `VecCreate()`, `VecCopy()`
## Level
beginner
## Location
src/vec/vec/interface/vector.c
## Examples
src/dm/impls/stag/tutorials/ex1.c
src/dm/impls/stag/tutorials/ex2.c
src/dm/impls/stag/tutorials/ex3.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/impls/stag/tutorials/ex8.c
src/dm/tutorials/ex10.c
src/dm/tutorials/ex15.c
src/dm/tutorials/ex9.c
src/ksp/ksp/tutorials/bench_kspsolve.c
src/ksp/ksp/tutorials/ex1.c
src/ksp/ksp/tutorials/ex10.c
## Implementations
VecDuplicate_MPIKokkos in src/vec/vec/impls/mpi/kokkos/mpikok.kokkos.cxx
VecDuplicate_MPIViennaCL in src/vec/vec/impls/mpi/mpiviennacl/mpiviennacl.cxx
VecDuplicate_MPI in src/vec/vec/impls/mpi/pbvec.c
VecDuplicate_Nest in src/vec/vec/impls/nest/vecnest.c
VecDuplicate_Seq in src/vec/vec/impls/seq/bvec2.c
VecDuplicate_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
VecDuplicate_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx
VecDuplicate_Shared in src/vec/vec/impls/shared/shvec.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/vector.c)
[Index of all Vec routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)