<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Dear PETSc developers,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Since I am learning how to use MatCreateNest, I was looking at example
<a href="https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex73f90t.F90.html">
ex73f90t.F90</a> (I am using Fortran).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">At line 297, the array of matrices to be passed to MatCreateNest is initialized with code lines as “matArray(1) = Amat”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I was surprised to find such a simple command, I thought a matrix copy should be done by a sequence like<o:p></o:p></p>
<p class="MsoNormal">“ call MatDuplicate(Amat, MAT_SHARE_NONZERO_PATTERN,matArray(1),ierr); CHKERRA(ierr)<o:p></o:p></p>
<p class="MsoNormal"> call MatCopy(Amat,matArray(1), SAME_NONZERO_PATTERN,ierr); CHKERRA(ierr) “<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, I was wondering: are the two ways completely equivalent, and therefore the second unnecessarily more complex? or is the latter more robust and therefore preferable?<o:p></o:p></p>
<p class="MsoNormal">Is there any difference in terms of performance?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks a lot for the clarification.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best regards,<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:4.0pt"><span style="mso-fareast-language:NL">Marco Tiberga<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:NL">PhD candidate<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#00B0F0;mso-fareast-language:NL">Delft University of Technology<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:NL">Faculty of Applied Sciences<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:NL">Radiation Science & Technology Department</span><span style="mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:NL">Mekelweg 15, 2629 JB Delft, The Netherlands</span><span style="mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:2.0pt"><span style="mso-fareast-language:NL">E-Mail:<span style="color:gray"> </span><u><span style="color:blue"><a href="mailto:m.tiberga@tudelft.nl"><span style="color:blue">m.tiberga@tudelft.nl</span></a></span></u></span><span style="font-family:"Segoe UI","sans-serif";color:black;mso-fareast-language:NL"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="mso-fareast-language:NL">Website: </span>
<span style="mso-fareast-language:NL"><a href="http://www.nera.rst.tudelft.nl/"><span lang="NL" style="color:blue">http://www.nera.rst.tudelft.nl/</span></a></span><span lang="NL" style="mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="NL"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="NL"><o:p> </o:p></span></p>
</div>
</body>
</html>