<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:10px;"><div><font size="3">For a symmetric matrix:</font></div><div><font size="3"><br></font></div><div><font size="3">I assume, I should compute the number of nonzeros per row just for the upper triangle?</font><br></div>
<div><br></div><div><br></div>
<div id="yahoo_quoted_4886841497" class="yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
Am Montag, 16. April 2018, 14:23:19 MESZ hat Jed Brown <jed@jedbrown.org> Folgendes geschrieben:
</div>
<div><br></div>
<div><br></div>
<div><div dir="ltr">Klaus Burkart <<a shape="rect" ymailto="mailto:k_burkart@yahoo.com" href="mailto:k_burkart@yahoo.com">k_burkart@yahoo.com</a>> writes:<br clear="none"><br clear="none">> Hi, <br clear="none">> How can I preallocate space for matrices (some symmetric, others<br clear="none">> asymmetric) if I have the global number of nonzeros (NNZ) but not the<br clear="none">> number of nonzeros per row? <br clear="none"><br clear="none">Unfortunately, this is not enough for efficient assembly. It is more<br clear="none">efficient to over-estimate.<div class="yqt1457308952" id="yqtfd34097"><br clear="none"><br clear="none">> I could compute the NNZ for the upper or lower part separately if this<br clear="none">> would be useful for symmetric matrices.<br clear="none">><br clear="none">> I create the matrix this way:<br clear="none">> MatCreate(PETSC_COMM_WORLD, &M);<br clear="none">> MatSetSizes(M, PETSC_DECIDE, PETSC_DECIDE, N, N);<br clear="none">> MatSetFromOptions(M);<br clear="none">> Klaus</div></div></div>
</div>
</div></div></body></html>