<div dir="ltr"><div dir="ltr">On Wed, Apr 15, 2020 at 1:24 AM Bin Liu <<a href="mailto:lbllm2018@hotmail.com">lbllm2018@hotmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-SG">
<div class="gmail-m_280034125930444214WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thanks for your example. My problem is resolved. Meanwhile I am wondering, if it is possible to make this example more flexible. I mean what if the columns in
each row are different? Is there any way to insert them all together?</span></p></div></div></blockquote><div><br></div><div>No. If the columns are different, you make a separate calls to MatSetValues().</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-SG"><div class="gmail-m_280034125930444214WordSection1"><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Bin<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_280034125930444214__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> Junchao Zhang [mailto:<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a>]
<br>
<b>Sent:</b> Monday, 13 April 2020 11:33 PM<br>
<b>To:</b> Bin Liu <<a href="mailto:lbllm2018@hotmail.com" target="_blank">lbllm2018@hotmail.com</a>><br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] inserting multiple rows together into a matrix<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Add two rows 2 ,4, and each row has three nonzeros at column 3, 7, 9<u></u><u></u></p>
</div>
<div>
<blockquote style="margin-left:30pt;margin-right:0cm">
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">m=2;</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">n=3;</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">idxm[] = {2, 4};</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">idxn[] = {3, 7, 9};</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">v[6] = {0.1, 0.2, ....};</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">MatSetValues(mat, m, idxm, n, idxn,v, INSERT_VALUES);</span><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">--Junchao Zhang<u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Apr 13, 2020 at 9:59 AM Bin Liu <<a href="mailto:lbllm2018@hotmail.com" target="_blank">lbllm2018@hotmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Hi all,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">I know how to insert values in one row into the matrix via routine “MatSetValues”. I understand I logically should be able to insert multiple rows into the matrix
with one call of “MatSetValues”. However, I am not sure how to do it. I searched in the PETSc mail list and did not find a relevant question answered before. Could anyone help me and give me a simple example code?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Regards</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">B.
</span><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>