:orphan: # 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 ## 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` (pass `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 [](ch_vectors), `Vec`, `VECNEST`, `VECSCATTER`, `VecScatterCreate()` ## Level advanced ## Location src/vec/vec/interface/rvector.c ## Examples src/vec/vec/tutorials/ex44.c
## Implementations VecConcatenate_Nest in src/vec/vec/impls/nest/vecnest.c
--- [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)