**newmat ** -the new submatrix, of the same type as the old

### Notes

The submatrix will be able to be multiplied with vectors using the same layout as iscol.
The rows in isrow will be sorted into the same order as the original matrix on each process.

The first time this is called you should use a cll of MAT_INITIAL_MATRIX,
the MatGetSubMatrix() routine will create the newmat for you. Any additional calls
to this routine with a mat of the same nonzero structure and with a call of MAT_REUSE_MATRIX
will reuse the matrix generated the first time. You should call MatDestroy() on newmat when
you are finished using it.

The communicator of the newly obtained matrix is ALWAYS the same as the communicator of
the input matrix.

If iscol is PETSC_NULL then all columns are obtained (not supported in Fortran).

### Example usage

Consider the following 8x8 matrix with 34 non-zero values, that is
assembled across 3 processors. Let's assume that proc0 owns 3 rows,
proc1 owns 3 rows, proc2 owns 2 rows. This division can be shown
### as follows

1 2 0 | 0 3 0 | 0 4
Proc0 0 5 6 | 7 0 0 | 8 0
9 0 10 | 11 0 0 | 12 0
-------------------------------------
13 0 14 | 15 16 17 | 0 0
Proc1 0 18 0 | 19 20 21 | 0 0
0 0 0 | 22 23 0 | 24 0
-------------------------------------
Proc2 25 26 27 | 0 0 28 | 29 0
30 0 0 | 31 32 33 | 0 34

Suppose isrow = [0 1 | 4 | 6 7] and iscol = [1 2 | 3 4 5 | 6]. The resulting submatrix is

2 0 | 0 3 0 | 0
Proc0 5 6 | 7 0 0 | 8
-------------------------------
Proc1 18 0 | 19 20 21 | 0
-------------------------------
Proc2 26 27 | 0 0 28 | 29
0 0 | 31 32 33 | 0

### See Also

MatGetSubMatrices()

**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

### Examples

src/ksp/ksp/examples/tutorials/ex49.c.html

src/snes/examples/tutorials/ex54.c.html

src/ts/examples/tutorials/ex23.c.html