petsc-3.14.6 2021-03-30
MatSetValues
Inserts or adds a block of values into a matrix. These values may be cached, so MatAssemblyBegin() and MatAssemblyEnd() MUST be called after all calls to MatSetValues() have been completed.
Synopsis
#include "petscmat.h"
PetscErrorCode MatSetValues(Mat mat,PetscInt m,const PetscInt idxm[],PetscInt n,const PetscInt idxn[],const PetscScalar v[],InsertMode addv)
Not Collective
Input Parameters
| mat | - the matrix
|
| v | - a logically two-dimensional array of values
|
| m, idxm | - the number of rows and their global indices
|
| n, idxn | - the number of columns and their global indices
|
| addv | - either ADD_VALUES or INSERT_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
|
Notes
If you create the matrix yourself (that is not with a call to DMCreateMatrix()) then you MUST call MatXXXXSetPreallocation() or
MatSetUp() before using this routine
By default the values, v, are row-oriented. See MatSetOption() for other options.
Calls to MatSetValues() with the INSERT_VALUES and ADD_VALUES
options cannot be mixed without intervening calls to the assembly
routines.
MatSetValues() uses 0-based row and column numbers in Fortran
as well as in C.
Negative indices may be passed in idxm and idxn, these rows and columns are
simply ignored. This allows easily inserting element stiffness matrices
with homogeneous Dirchlet boundary conditions that you don't want represented
in the matrix.
Efficiency Alert
The routine MatSetValuesBlocked() may offer much better efficiency
for users of block sparse formats (MATSEQBAIJ and MATMPIBAIJ).
Developer Notes
This is labeled with C so does not automatically generate Fortran stubs and interfaces
because it requires multiple Fortran interfaces depending on which arguments are scalar or arrays.
See Also
MatSetOption(), MatAssemblyBegin(), MatAssemblyEnd(), MatSetValuesBlocked(), MatSetValuesLocal(),
InsertMode, INSERT_VALUES, ADD_VALUES
Level
beginner
Location
src/mat/interface/matrix.c
Examples
src/mat/tutorials/ex2.c.html
src/mat/tutorials/ex8.c.html
src/mat/tutorials/ex12.c.html
src/mat/tutorials/ex15.c.html
src/mat/tutorials/ex16.c.html
src/mat/tutorials/ex17.c.html
src/mat/tutorials/ex15f.F90.html
src/mat/tutorials/ex17f.F90.html
src/ksp/pc/tutorials/ex1.c.html
src/ksp/pc/tutorials/ex2.c.html
src/ksp/pc/tutorials/ex3.c.html
Implementations
MatSetValues_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatSetValues_MPIAIJ_CopyFromCSRFormat_Symbolic in src/mat/impls/aij/mpi/mpiaij.c
MatSetValues_MPIAIJ_CopyFromCSRFormat in src/mat/impls/aij/mpi/mpiaij.c
MatSetValues_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatSetValues_SeqAIJ_SortedFullNoPreallocation in src/mat/impls/aij/seq/aij.c
MatSetValues_SeqAIJ_SortedFull in src/mat/impls/aij/seq/aij.c
MatSetValues_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c
MatSetValues_MPIBAIJ_HT in src/mat/impls/baij/mpi/mpibaij.c
MatSetValues_SeqBAIJ in src/mat/impls/baij/seq/baij.c
MatSetValues_BlockMat in src/mat/impls/blockmat/seq/blockmat.c
MatSetValues_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatSetValues_SeqDense in src/mat/impls/dense/seq/dense.c
MatSetValues_Elemental in src/mat/impls/elemental/matelem.cxx
MatSetValues_HYPRE in src/mat/impls/hypre/mhypre.c
MatSetValues_IS in src/mat/impls/is/matis.c
MatSetValues_Preallocator in src/mat/impls/preallocator/matpreallocator.c
MatSetValues_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c
MatSetValues_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij.c
MatSetValues_ScaLAPACK in src/mat/impls/scalapack/matscalapack.c
MatSetValues_MPISELL in src/mat/impls/sell/mpi/mpisell.c
MatSetValues_SeqSELL in src/mat/impls/sell/seq/sell.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages