16.1. Extracting Submatrices

Up: Contents Next: Matrix Factorization Previous: Advanced Features of Matrices and Solvers

One can extract a (parallel) submatrix from a given (parallel) using

   ierr = MatGetSubMatrix(Mat A,IS rows,IS cols,int csize,MatReuse call,Mat *B); 
This extracts the rows and columns of the matrix A into B. If call is MAT_INITIAL_MATRIX it will create the matrix B. If call is MAT_REUSE_MATRIX it will reuse the B created with a previous call. The argument csize is ignored on sequential matrices, for parallel matrices it determines the ``local columns'' if the matrix format supports this concept. Often one can use the default by passing in PETSC_DECIDE. To create a B matrix that may be multiplied with a vector x one can use
   ierr = VecGetLocalSize(x,&csize); 
   ierr = MatGetSubMatrix(Mat A,IS rows,IS cols,int csize,MatReuse call,Mat *B); 


Up: Contents Next: Matrix Factorization Previous: Advanced Features of Matrices and Solvers