Skip to main content
`Ctrl`+`K`

# VecSetValuesCOO

set values at once in a vector preallocated using `VecSetPreallocationCOO()`

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecSetValuesCOO(Vec x, const PetscScalar coo_v[], InsertMode imode)

Collective

## Input Parameters

- x - vector being set

- coo_v - the value array

- imode - the insert mode

## Note

This and `VecSetPreallocationCOO() or ``VecSetPreallocationCOOLocal()` provide an alternative API to using `VecSetValues()` to provide vector values.

This API is particularly efficient for use on GPUs.

The values must follow the order of the indices prescribed with `VecSetPreallocationCOO()` or `VecSetPreallocationCOOLocal()`. When repeated entries are specified in the COO indices the `coo_v` values are first properly summed, regardless of the value of `imode`. The imode flag indicates if `coo_v` must be added to the current values of the vector (`ADD_VALUES`) or overwritten (`INSERT_VALUES`). `VecAssemblyBegin()` and `VecAssemblyEnd()` do not need to be called after this routine. It automatically handles the assembly process.

## See Also

Vectors and Parallel Data, `Vec`, `VecSetPreallocationCOO()`, `VecSetPreallocationCOOLocal()`, `VecSetValues()`

## Level

beginner

## Location

src/vec/vec/interface/vector.c

## Implementations

VecSetValuesCOO_MPIKokkos() in src/vec/vec/impls/mpi/kokkos/mpikok.kokkos.cxx
VecSetValuesCOO_MPI() in src/vec/vec/impls/mpi/pdvec.c
VecSetValuesCOO_Seq() in src/vec/vec/impls/seq/bvec2.c
VecSetValuesCOO_SeqKokkos() in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx

Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages