# 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 Parameters

- ***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
 [](chapter_vectors), `Vec`, `VecDestroy()`, `VecDuplicateVecs()`, `VecCreate()`, `VecCopy()`

## Level
beginner

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1.c.html">src/vec/vec/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex14f.F90.html">src/vec/vec/tutorials/ex14f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex16.c.html">src/vec/vec/tutorials/ex16.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex16f.F90.html">src/vec/vec/tutorials/ex16f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex18.c.html">src/vec/vec/tutorials/ex18.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex18f.F90.html">src/vec/vec/tutorials/ex18f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex19.c.html">src/vec/vec/tutorials/ex19.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1f.F90.html">src/vec/vec/tutorials/ex1f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1f90.F90.html">src/vec/vec/tutorials/ex1f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex20f90.F90.html">src/vec/vec/tutorials/ex20f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex21f90.F90.html">src/vec/vec/tutorials/ex21f90.F90.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/kokkos/mpikok.kokkos.cxx.html#VecDuplicate_MPIKokkos">VecDuplicate_MPIKokkos in src/vec/vec/impls/mpi/kokkos/mpikok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/mpicuda/mpicuda.cu.html#VecDuplicate_MPICUDA">VecDuplicate_MPICUDA in src/vec/vec/impls/mpi/mpicuda/mpicuda.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/mpihip/mpihip.hip.c.html#VecDuplicate_MPIHIP">VecDuplicate_MPIHIP in src/vec/vec/impls/mpi/mpihip/mpihip.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/mpiviennacl/mpiviennacl.cxx.html#VecDuplicate_MPIViennaCL">VecDuplicate_MPIViennaCL in src/vec/vec/impls/mpi/mpiviennacl/mpiviennacl.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/pbvec.c.html#VecDuplicate_MPI">VecDuplicate_MPI in src/vec/vec/impls/mpi/pbvec.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/nest/vecnest.c.html#VecDuplicate_Nest">VecDuplicate_Nest in src/vec/vec/impls/nest/vecnest.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/bvec2.c.html#VecDuplicate_Seq">VecDuplicate_Seq in src/vec/vec/impls/seq/bvec2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx.html#VecDuplicate_SeqKokkos">VecDuplicate_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#VecDuplicate_SeqCUDA">VecDuplicate_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#VecDuplicate_SeqHIP">VecDuplicate_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#VecDuplicate_SeqViennaCL">VecDuplicate_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/shared/shvec.c.html#VecDuplicate_Shared">VecDuplicate_Shared in src/vec/vec/impls/shared/shvec.c</A><BR>


---
[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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
