# VecStrideSubSetGather
Gathers a subset of components from a multi-component vector into another vector. 
## Synopsis
```
#include "petscvec.h" 
PetscErrorCode VecStrideSubSetGather(Vec v, PetscInt nidx, const PetscInt idxv[], const PetscInt idxs[], Vec s, InsertMode addv)
```
Collective


## Input Parameters

- ***v -*** the vector
- ***nidx -*** the number of indices
- ***idxv -*** the indices of the components 0 <= idxv[0] ...idxv[nidx-1] < bs(v), they need not be sorted
- ***idxs -*** the indices of the components 0 <= idxs[0] ...idxs[nidx-1] < bs(s), they need not be sorted, may be null if nidx == bs(s) or is PETSC_DETERMINE
- ***addv -*** one of ADD_VALUES,INSERT_VALUES,MAX_VALUES



## Output Parameter

- ***s -*** the location where the subvector is stored



## Notes
One must call VecSetBlockSize() on both vectors before this routine to set the stride
information, or use a vector created from a multicomponent DMDA.

The parallel layout of the vector and the subvector must be the same;

Not optimized; could be easily




## See Also
 `VecStrideNorm()`, `VecStrideScatter()`, `VecStrideGather()`, `VecStrideSubSetScatter()`, `VecStrideMin()`, `VecStrideMax()`, `VecStrideGatherAll()`,
`VecStrideScatterAll()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/utils/vinv.c.html#VecStrideSubSetGather">src/vec/vec/utils/vinv.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/utils/vinv.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)  
