petsc-3.15.0 2021-03-30
Report Typos and Errors

# MatGetValues

Gets a block of values from a matrix.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode MatGetValues(Mat mat,PetscInt m,const PetscInt idxm[],PetscInt n,const PetscInt idxn[],PetscScalar v[])

Not Collective; can only return values that are owned by the give process

### Input Parameters

| mat | - the matrix
| v | - a logically two-dimensional array for storing the values
| m, idxm | - the number of rows and their global indices
| n, idxn | - the number of columns and their global indices

### Notes

The user must allocate space (m*n PetscScalars) for the values, v. The values, v, are then returned in a row-oriented format, analogous to that used by default in MatSetValues().

MatGetValues() uses 0-based row and column numbers in Fortran as well as in C.

MatGetValues() requires that the matrix has been assembled with MatAssemblyBegin()/MatAssemblyEnd(). Thus, calls to MatSetValues() and MatGetValues() CANNOT be made in succession without intermediate matrix assembly.

Negative row or column indices will be ignored and those locations in v[] will be left unchanged.

For the standard row-based matrix formats, idxm[] can only contain rows owned by the requesting MPI rank. That is, rows with global index greater than or equal to restart and less than rend where restart and rend are obtainable from MatGetOwnershipRange(mat,&rstart,&rend).

### See Also

MatGetRow(), MatCreateSubMatrices(), MatSetValues(), MatGetOwnershipRange(), MatGetValuesLocal()

### Level

advanced

### Location

src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages