1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateSubMatrix.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>MatCreateSubMatrix</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.10.3 2018-12-18</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.10.3 v3.10.3 docs/manualpages/Mat/MatCreateSubMatrix.html "><small>Report Typos and Errors</small></a></div>
<A NAME="MatCreateSubMatrix"><H1>MatCreateSubMatrix</H1></A>
Gets a single submatrix on the same number of processors as the original matrix.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscmat.h"
<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> <A HREF="../Mat/MatCreateSubMatrix.html#MatCreateSubMatrix">MatCreateSubMatrix</A>(<A HREF="../Mat/Mat.html#Mat">Mat</A> mat,<A HREF="../IS/IS.html#IS">IS</A> isrow,<A HREF="../IS/IS.html#IS">IS</A> iscol,<A HREF="../Mat/MatReuse.html#MatReuse">MatReuse</A> cll,<A HREF="../Mat/Mat.html#Mat">Mat</A> *newmat)
</PRE>
Collective on <A HREF="../Mat/Mat.html#Mat">Mat</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>mat </B></TD><TD>- the original matrix
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>isrow </B></TD><TD>- parallel <A HREF="../IS/IS.html#IS">IS</A> containing the rows this processor should obtain
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>iscol </B></TD><TD>- parallel <A HREF="../IS/IS.html#IS">IS</A> containing all columns you wish to keep. Each process should list the columns that will be in IT's "diagonal part" in the new matrix.
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>cll </B></TD><TD>- either <A HREF="../Mat/MatReuse.html#MatReuse">MAT_INITIAL_MATRIX</A> or <A HREF="../Mat/MatReuse.html#MatReuse">MAT_REUSE_MATRIX</A>
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Output Parameter</FONT></H3>
<DT><B>newmat </B> -the new submatrix, of the same type as the old
<br>
<P>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
The submatrix will be able to be multiplied with vectors using the same layout as iscol.
<P>
Some matrix types place restrictions on the row and column indices, such
as that they be sorted or that they be equal to each other.
<P>
The index sets may not have duplicate entries.
<P>
The first time this is called you should use a cll of <A HREF="../Mat/MatReuse.html#MatReuse">MAT_INITIAL_MATRIX</A>,
the <A HREF="../Mat/MatCreateSubMatrix.html#MatCreateSubMatrix">MatCreateSubMatrix</A>() 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 <A HREF="../Mat/MatReuse.html#MatReuse">MAT_REUSE_MATRIX</A>
will reuse the matrix generated the first time. You should call <A HREF="../Mat/MatDestroy.html#MatDestroy">MatDestroy</A>() on newmat when
you are finished using it.
<P>
The communicator of the newly obtained matrix is ALWAYS the same as the communicator of
the input matrix.
<P>
If iscol is NULL then all columns are obtained (not supported in Fortran).
<P>
<H3><FONT COLOR="#CC3333">Example usage</FONT></H3>
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
<H3><FONT COLOR="#CC3333">as follows</FONT></H3>
<P>
<PRE>
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
</PRE>
<P>
Suppose isrow = [0 1 | 4 | 6 7] and iscol = [1 2 | 3 4 5 | 6]. The resulting submatrix is
<P>
<PRE>
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
</PRE>
<P>
<P>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../Mat/MatCreateSubMatrices.html#MatCreateSubMatrices">MatCreateSubMatrices</A>()
<BR><P><B></B><H3><FONT COLOR="#CC3333">Level</FONT></H3>advanced<BR>
<H3><FONT COLOR="#CC3333">Location</FONT></H3>
</B><A HREF="../../../src/mat/interface/matrix.c.html#MatCreateSubMatrix">src/mat/interface/matrix.c</A>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex49.c.html">src/ksp/ksp/examples/tutorials/ex49.c.html</A><BR>
<A HREF="../../../src/ksp/ksp/examples/tutorials/ex64.c.html">src/ksp/ksp/examples/tutorials/ex64.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex73f90t.F90.html">src/snes/examples/tutorials/ex73f90t.F90.html</A><BR>
<P><H3><FONT COLOR="CC3333">Implementations</FONT></H3><A HREF="../../../src/mat/impls/adj/mpi/mpiadj.c.html#MatCreateSubMatrix_MPIAdj_data">MatCreateSubMatrix_MPIAdj_data in src/mat/impls/adj/mpi/mpiadj.c</A><BR>
<A HREF="../../../src/mat/impls/aij/mpi/mpiaij.c.html#MatCreateSubMatrix_MPIAIJ_SameRowColDist">MatCreateSubMatrix_MPIAIJ_SameRowColDist in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="../../../src/mat/impls/aij/mpi/mpiaij.c.html#MatCreateSubMatrix_MPIAIJ">MatCreateSubMatrix_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="../../../src/mat/impls/aij/mpi/mpiaij.c.html#MatCreateSubMatrix_MPIAIJ_SameRowDist">MatCreateSubMatrix_MPIAIJ_SameRowDist in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="../../../src/mat/impls/aij/mpi/mpiaij.c.html#MatCreateSubMatrix_MPIAIJ_nonscalable">MatCreateSubMatrix_MPIAIJ_nonscalable in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="../../../src/mat/impls/aij/mpi/mpiov.c.html#MatCreateSubMatrix_MPIAIJ_All">MatCreateSubMatrix_MPIAIJ_All in src/mat/impls/aij/mpi/mpiov.c</A><BR>
<A HREF="../../../src/mat/impls/aij/seq/aij.c.html#MatCreateSubMatrix_SeqAIJ">MatCreateSubMatrix_SeqAIJ in src/mat/impls/aij/seq/aij.c</A><BR>
<A HREF="../../../src/mat/impls/baij/mpi/mpibaij.c.html#MatCreateSubMatrix_MPIBAIJ">MatCreateSubMatrix_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="../../../src/mat/impls/baij/mpi/mpibaij.c.html#MatCreateSubMatrix_MPIBAIJ_Private">MatCreateSubMatrix_MPIBAIJ_Private in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="../../../src/mat/impls/baij/seq/baij2.c.html#MatCreateSubMatrix_SeqBAIJ_Private">MatCreateSubMatrix_SeqBAIJ_Private in src/mat/impls/baij/seq/baij2.c</A><BR>
<A HREF="../../../src/mat/impls/baij/seq/baij2.c.html#MatCreateSubMatrix_SeqBAIJ">MatCreateSubMatrix_SeqBAIJ in src/mat/impls/baij/seq/baij2.c</A><BR>
<A HREF="../../../src/mat/impls/blockmat/seq/blockmat.c.html#MatCreateSubMatrix_BlockMat">MatCreateSubMatrix_BlockMat in src/mat/impls/blockmat/seq/blockmat.c</A><BR>
<A HREF="../../../src/mat/impls/dense/mpi/mpidense.c.html#MatCreateSubMatrix_MPIDense">MatCreateSubMatrix_MPIDense in src/mat/impls/dense/mpi/mpidense.c</A><BR>
<A HREF="../../../src/mat/impls/dense/seq/dense.c.html#MatCreateSubMatrix_SeqDense">MatCreateSubMatrix_SeqDense in src/mat/impls/dense/seq/dense.c</A><BR>
<A HREF="../../../src/mat/impls/is/matis.c.html#MatCreateSubMatrix_IS">MatCreateSubMatrix_IS in src/mat/impls/is/matis.c</A><BR>
<A HREF="../../../src/mat/impls/maij/maij.c.html#MatCreateSubMatrix_MAIJ">MatCreateSubMatrix_MAIJ in src/mat/impls/maij/maij.c</A><BR>
<A HREF="../../../src/mat/impls/nest/matnest.c.html#MatCreateSubMatrix_Nest">MatCreateSubMatrix_Nest in src/mat/impls/nest/matnest.c</A><BR>
<A HREF="../../../src/mat/impls/sbaij/mpi/mpisbaij.c.html#MatCreateSubMatrix_MPISBAIJ">MatCreateSubMatrix_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c</A><BR>
<A HREF="../../../src/mat/impls/sbaij/seq/sbaij2.c.html#MatCreateSubMatrix_SeqSBAIJ_Private">MatCreateSubMatrix_SeqSBAIJ_Private in src/mat/impls/sbaij/seq/sbaij2.c</A><BR>
<A HREF="../../../src/mat/impls/sbaij/seq/sbaij2.c.html#MatCreateSubMatrix_SeqSBAIJ">MatCreateSubMatrix_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij2.c</A><BR>
<BR><A HREF="./index.html">Index of all Mat routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
</BODY></HTML>
|