# VecConcatenate
Creates a new vector that is a vertical concatenation of all the given array of vectors in the order they appear in the array. The concatenated vector resides on the same communicator and is the same type as the source vectors. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecConcatenate(PetscInt nx, const Vec X[], Vec *Y, IS *x_is[])
```
Collective on X


## Input Parameters

- ***nx   -*** number of vectors to be concatenated
- ***X    -*** array containing the vectors to be concatenated in the order of concatenation



## Output Parameters

- ***Y    -*** concatenated vector
- ***x_is -*** array of index sets corresponding to the concatenated components of Y (NULL if not needed)



## Notes
Concatenation is similar to the functionality of a VecNest object; they both represent combination of
different vector spaces. However, concatenated vectors do not store any information about their
sub-vectors and own their own data. Consequently, this function provides index sets to enable the
manipulation of data in the concatenated vector that corresponds to the original components at creation.

This is a useful tool for outer loop algorithms, particularly constrained optimizers, where the solver
has to operate on combined vector spaces and cannot utilize VecNest objects due to incompatibility with
bound projections.




## See Also
 `VECNEST`, `VECSCATTER`, `VecScatterCreate()`

## Level
advanced

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

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

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/nest/vecnest.c.html#VecConcatenate_Nest">VecConcatenate_Nest in src/vec/vec/impls/nest/vecnest.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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
