:orphan:
# VecGetValues
Gets values from certain locations of a vector. Currently can only get values on the same processor on which they are owned 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecGetValues(Vec x, PetscInt ni, const PetscInt ix[], PetscScalar y[])
```
Not Collective


## Input Parameters

- ***x -*** vector to get values from
- ***ni -*** number of elements to get
- ***ix -*** indices where to get them from (in global 1d numbering)



## Output Parameter

- ***y -*** array of values





## Notes
The user provides the allocated array y; it is NOT allocated in this routine

`VecGetValues()` gets y[i] = x[ix[i]], for i=0,...,ni-1.

`VecAssemblyBegin()` and `VecAssemblyEnd()`  MUST be called before calling this if `VecSetValues()` or related routine has been called

VecGetValues() uses 0-based indices in Fortran as well as in C.

If you call `VecSetOption`(x, `VEC_IGNORE_NEGATIVE_INDICES`,`PETSC_TRUE`),
negative indices may be passed in ix. These rows are
simply ignored.


## See Also
 [](ch_vectors), `Vec`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValues()`

## Level
beginner

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex2f.F90.html">src/vec/vec/tutorials/ex2f.F90</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/pdvec.c.html#VecGetValues_MPI">VecGetValues_MPI in src/vec/vec/impls/mpi/pdvec.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/bvec2.c.html#VecGetValues_Seq">VecGetValues_Seq in src/vec/vec/impls/seq/bvec2.c</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](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
