MatSetValuesCOO#

set values at once in a matrix preallocated using MatSetPreallocationCOO()

Synopsis#

#include "petscmat.h"  
PetscErrorCode MatSetValuesCOO(Mat A, const PetscScalar coo_v[], InsertMode imode)

Collective

Input Parameters#

  • A - matrix being preallocated

  • coo_v - the matrix values (can be NULL)

  • imode - the insert mode

Notes#

The values must follow the order of the indices prescribed with MatSetPreallocationCOO() or MatSetPreallocationCOOLocal().

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 matrix (ADD_VALUES) or overwritten (INSERT_VALUES).

MatAssemblyBegin() and MatAssemblyEnd() do not need to be called after this routine. It automatically handles the assembly process.

If the MAT_STRUCTURE_ONLY option is set to true, the values are ignored and only the assembly process is performed.

MatSetValues() and other operations may modify existing entries of the matrix between calls to this routine. If they change the nonzero pattern built by MatSetPreallocationCOO(), for example by inserting a new nonzero, this routine generates an error for MATAIJ and its device subtypes; call MatSetPreallocationCOO() again before calling MatSetValuesCOO().

See Also#

Matrices, Mat, MatSetPreallocationCOO(), MatSetPreallocationCOOLocal(), InsertMode, INSERT_VALUES, ADD_VALUES

Level#

beginner

Location#

src/mat/utils/gcreate.c

Examples#

src/mat/tutorials/ex18.c
src/mat/tutorials/ex18k.kokkos.cxx
src/mat/tests/ex123.c
src/mat/tests/ex254.c
src/mat/tests/ex270.c
src/ksp/ksp/tutorials/bench_kspsolve.c
src/ksp/ksp/tutorials/ex83f.F90
src/ksp/ksp/tutorials/ex88f.F90
src/snes/tutorials/ex55k.kokkos.cxx

Implementations#

MatSetValuesCOO_MPIAIJKokkos() in src/mat/impls/aij/mpi/kokkos/mpiaijkok.kokkos.cxx
MatSetValuesCOO_MPIAIJ() in src/mat/impls/aij/mpi/mpiaij.c
MatSetValuesCOO_MPIAIJCUSPARSE() in src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu
MatSetValuesCOO_MPIAIJHIPSPARSE() in src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.cxx
MatSetValuesCOO_SeqAIJ() in src/mat/impls/aij/seq/aij.c
MatSetValuesCOO_SeqAIJKokkos() in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx
MatSetValuesCOO_SeqAIJCUSPARSE() in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatSetValuesCOO_SeqAIJHIPSPARSE() in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.cxx
MatSetValuesCOO_HYPRE() in src/mat/impls/hypre/mhypre.c
MatSetValuesCOO_IS() in src/mat/impls/is/matis.c


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