MatSetPreallocationCOO#

set preallocation for matrices using a coordinate format of the entries with global indices

Synopsis#

#include "petscmat.h"  
PetscErrorCode MatSetPreallocationCOO(Mat A, PetscCount ncoo, PetscInt coo_i[], PetscInt coo_j[])

Collective

Input Parameters#

  • A - matrix being preallocated

  • ncoo - number of entries

  • coo_i - row indices

  • coo_j - column indices

Notes#

The indices coo_i and coo_j may be modified within this function. The caller should not rely on them having any specific value after this function returns. The arrays can be freed or reused immediately after this function returns.

Entries can be repeated, see MatSetValuesCOO(). Entries with negative row or column indices are allowed but will be ignored. The corresponding entries in MatSetValuesCOO() will be ignored too. Remote entries are allowed and will be properly added or inserted to the matrix, unless the matrix option MAT_IGNORE_OFF_PROC_ENTRIES is set, in which case remote entries are ignored, or MAT_NO_OFF_PROC_ENTRIES is set, in which case an error will be generated.

If you just want to create a sequential AIJ matrix (MATSEQAIJ), and your matrix entries in COO format are unique, you can also use MatCreateSeqAIJFromTriple(). But that is not recommended for iterative applications.

See Also#

Matrices, Mat, MatSetValuesCOO(), MatSeqAIJSetPreallocation(), MatMPIAIJSetPreallocation(), MatSeqBAIJSetPreallocation(), MatMPIBAIJSetPreallocation(), MatSeqSBAIJSetPreallocation(), MatMPISBAIJSetPreallocation(), MatSetPreallocationCOOLocal(), DMSetMatrixPreallocateSkip(), MatCreateSeqAIJFromTriple()

Level#

beginner

Location#

src/mat/utils/gcreate.c

Examples#

src/ksp/ksp/tutorials/bench_kspsolve.c
src/ksp/ksp/tutorials/ex83f.F90
src/mat/tutorials/ex18.c
src/snes/tutorials/ex55k.kokkos.cxx

Implementations#

MatSetPreallocationCOO_MPIAIJKokkos in src/mat/impls/aij/mpi/kokkos/mpiaijkok.kokkos.cxx
MatSetPreallocationCOO_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatSetPreallocationCOO_MPIAIJCUSPARSE in src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu
MatSetPreallocationCOO_MPIAIJHIPSPARSE in src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.c
MatSetPreallocationCOO_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatSetPreallocationCOO_SeqAIJKokkos in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx
MatSetPreallocationCOO_SeqAIJCUSPARSE in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatSetPreallocationCOO_SeqAIJHIPSPARSE in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c
MatSetPreallocationCOO_HYPRE in src/mat/impls/hypre/mhypre.c
MatSetPreallocationCOO_IS in src/mat/impls/is/matis.c


Edit on GitLab

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