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
|
<!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/MatGetSubMatrix.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>MatGetSubMatrix</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.4.2 2013-07-02</b></div>
<A NAME="MatGetSubMatrix"><H1>MatGetSubMatrix</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"
PetscErrorCode MatGetSubMatrix(Mat mat,IS isrow,IS iscol,MatReuse cll,Mat *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 MAT_INITIAL_MATRIX or MAT_REUSE_MATRIX
</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>
The rows in isrow will be sorted into the same order as the original matrix on each process.
<P>
The first time this is called you should use a cll of MAT_INITIAL_MATRIX,
the <A HREF="../Mat/MatGetSubMatrix.html#MatGetSubMatrix">MatGetSubMatrix</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 MAT_REUSE_MATRIX
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/MatGetSubMatrices.html#MatGetSubMatrices">MatGetSubMatrices</A>()
<BR><P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>advanced
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/mat/interface/matrix.c.html#MatGetSubMatrix">src/mat/interface/matrix.c</A>
<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>
<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/snes/examples/tutorials/ex54.c.html">src/snes/examples/tutorials/ex54.c.html</A><BR>
<A HREF="../../../src/ts/examples/tutorials/ex23.c.html">src/ts/examples/tutorials/ex23.c.html</A><BR>
</BODY></HTML>
|