<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>I see, thanks.</p>
<p><br>
</p>
<p>Is there some clever way to have PETSc decide for me which column goes where?</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Fra:</b> Mark Adams <mfadams@lbl.gov><br>
<b>Sendt:</b> 14. november 2021 19:17:07<br>
<b>Til:</b> Peder Jørgensgaard Olesen<br>
<b>Cc:</b> petsc-users@mcs.anl.gov<br>
<b>Emne:</b> Re: [petsc-users] Creating rectangular submatrix</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Nov 14, 2021 at 12:39 PM Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_9222570883430151966divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hello</p>
<p><br>
</p>
<p>I need to extract a submatrix consisting of a number columns from a rectangular matrix. The
<a href="https://petsc.org/release/docs/manualpages/Mat/MatCreateSubMatrix.html" target="_blank">
documentation </a>for MatCreateSubMatrix states that "each process should list the columns that will be in its "diagonal part" in the new matrix".</p>
<p><br>
</p>
<p>However, is it not the case that not all columns are necessarily in some process's diagonal part? <span style="font-size:12pt">Consider
</span><span style="font-size:12pt">the </span><span style="font-size:12pt">example of a 2x5 matrix stored on two processes. Each process then stores one row. Suppose we wish to
</span><span style="font-size:12pt">create a submatrix </span><span style="font-size:12pt">with rows 0 and 1, and columns 2, 3, and 4 from the original matrix. The diagonal parts
</span><span style="font-size:12pt">of</span><span style="font-size:12pt"> the matrix created then each hold one element, namely (0,2) and (1,3), respectively (using source matrix indices). But how would the ISs for creating this submatrix look? Taking the
syntax described in the documentation at face value tthe ISs would be row_is = [0 | 1] and col_is = [2 | 3]. Thus, t</span><span style="font-size:12pt">here doesn't seem to be a way to tell
</span><span style="font-size:12pt">MatCreateSubMatrix that we also want column 4 (unless we may simply let col_is = [2 | 3 4], and the new matrix' "diagonal part" becomes non-square - which might also explain the scare quotes around the term in the documentation?)</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">I'd be surprised if the syntax does not allow
certain submatrices to be formed; more likely I'm misunderstanding the documentation. Could someone shed some light on this?</span></span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>You are on the right track. You have to decide what processor is going to have each column. This is the partitioning of the left hand side vector will need when applying this new matrix.</div>
<div>So [2 | 3 4] is valid. This would give you<br>
</div>
<div>[01]* [03 04] </div>
<div>[11] [13 14]*</div>
<div>* diagonal part</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_9222570883430151966divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px"><br>
</span></span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">Thanks in advance.</span></span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px"><br>
</span></span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">Best regards</span></span></p>
<p><span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">Peder</span></span></p>
<p><br>
</p>
<div id="gmail-m_9222570883430151966Signature">
<div id="gmail-m_9222570883430151966divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><br>
</p>
<p></p>
<table border="0" cellspacing="0" cellpadding="0" style="font-family:"Times New Roman";padding:0px;width:400px">
<tbody>
<tr>
<td style="width:400px">
<table border="0" cellspacing="0" cellpadding="0" style="width:400px;font-family:Arial;font-size:11.5px;border-collapse:collapse">
<tbody>
<tr>
<td valign="top" style="width:50px;vertical-align:top">
<table cellspacing="0" cellpadding="0" style="width:50px;padding-top:4px">
<tbody>
<tr>
<td align="left" style="width:50px;vertical-align:top"><img width="36" height="53" src="http://www.dtu.dk/-/media/DTU_Generelt/Andet/mail-signature-logo.png"></td>
</tr>
</tbody>
</table>
</td>
<td valign="top" style="width:350px;vertical-align:top">
<table border="0" cellspacing="0" cellpadding="0" style="width:350px;border-collapse:collapse">
<tbody>
<tr>
<td style="width:350px;font-size:16px;margin:0px;font-weight:bold;line-height:19.2px">
Peder Jørgensgaard Olesen</td>
</tr>
<tr>
<td style="width:350px;margin:0px;line-height:17px">PhD student<br>
Department of Mechanical Engineering</td>
</tr>
<tr>
<td style="width:350px;margin:0px;line-height:17px"> </td>
</tr>
<tr>
<td style="width:350px;line-height:17px"><a href="mailto:pjool@mek.dtu.dk" style="margin:0px;line-height:17px;color:black" id="gmail-m_9222570883430151966LPNoLP" target="_blank">pjool@mek.dtu.dk</a></td>
</tr>
<tr>
<td style="width:350px;margin:0px;line-height:17px">Koppels Allé</td>
</tr>
<tr>
<td style="width:350px;margin:0px;line-height:17px">Building 403, room 105</td>
</tr>
<tr>
<td style="width:350px;margin:0px;line-height:17px">2800 Kgs. Lyngby</td>
</tr>
<tr>
<td style="width:350px;line-height:17px"><a href="https://www.dtu.dk/english" style="margin:0px;line-height:17px;color:black" id="gmail-m_9222570883430151966LPNoLP" target="_blank">www.dtu.dk/english</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:10pt;color:rgb(117,123,128)"></span></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>