Inserts or adds a block of values into a matrix.


#include "petscmat.h" 
PetscErrorCode  MatSetValuesBlocked(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 block rows and their global block indices
n, idxn - the number of block columns and their global block 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


The m and n count the NUMBER of blocks in the row direction and column direction, NOT the total number of rows/columns; for example, if the block size is 2 and you are passing in values for rows 2,3,4,5 then m would be 2 (not 4).

By default the values, v, are row-oriented and unsorted. So the layout of v is the same as for MatSetValues(). See MatSetOption() for other options.

Calls to MatSetValuesBlocked() with the INSERT_VALUES and ADD_VALUES options cannot be mixed without intervening calls to the assembly routines.

MatSetValuesBlocked() 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.

Each time an entry is set within a sparse matrix via MatSetValues(), internal searching must be done to determine where to place the the data in the matrix storage space. By instead inserting blocks of entries via MatSetValuesBlocked(), the overhead of matrix assembly is reduced.


MatSetValuesBlocked() is currently supported only for the BAIJ and SBAIJ formats

See Also

MatSetOption(), MatAssemblyBegin(), MatAssemblyEnd(), MatSetValues(), MatSetValuesBlockedLocal()

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