<div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks for the quick reply. The reason why I want to do this is because I would like to build A and B separately first. Then do something with B by itself. Then scale B by a constant. Then append B to A to make C and continue some other matrix operations. I took a look at MatGetLocalSubMatrix() and there is this line:</div><div dir="ltr"><br></div><div dir="ltr"><span><span><span style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;float:none;display:inline;white-space:normal;background-color:rgb(255,255,255)">Depending on the format of mat, the returned submat may not implement<span> </span></span><a style="text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)" href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMult.html#MatMult"><font color="#0066cc">MatMult</font></a><span style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;float:none;display:inline;white-space:normal;background-color:rgb(255,255,255)">(). Its communicator may be the same as mat, it may be<span> </span></span><a style="text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255)" href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PETSC_COMM_SELF.html#PETSC_COMM_SELF"><font color="#0066cc">PETSC_COMM_SELF</font></a><span style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;float:none;display:inline;white-space:normal;background-color:rgb(255,255,255)">, or some other subcomm of mat's.</span></span></span></div><span><span><span style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;float:none;display:inline;white-space:normal;background-color:rgb(255,255,255)"></span></span></span></div><div dir="ltr"><span><span><span style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:"Times New Roman";font-size:medium;font-style:normal;font-weight:400;word-spacing:0px;float:none;display:inline;white-space:normal;background-color:rgb(255,255,255)"><span><div dir="ltr"><br></div><div>what is the format that will make submat not being able to do MatMult()? Thank you very much.<br></div></span></span></span></span></div></div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Mon, Aug 31, 2020 at 10:29 PM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Karl Lin <<a href="mailto:karl.linkui@gmail.com" target="_blank">karl.linkui@gmail.com</a>> writes:<br>
<br>
> If I have two matrix A and B with the same number of columns, same<br>
> distribution pattern (column ownership pattern) among processes but<br>
> different number of rows, is there a function to append B to A to make a<br>
> new matrix C = [A; B]? Thanks.<br>
<br>
Sort of; you can create a MatNest with the two matrices and (optionally) convert to AIJ format.<br>
<br>
Better, you can take the code that builds A and B, but call it on "local" submatrices; see MatGetLocalSubMatrix() or an example like src/snes/tutorials/ex28.c.<br>
</blockquote></div>