<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Also if you know that the rows/cols are contiguous <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">(next to each other) </span>in your sparse matrix then it is recommended to use MatSetValuesBlocked as it is more efficient.<div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391</div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2020, at 10:32 AM, Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" class="">junchao.zhang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Add two rows 2 ,4, and each row has three nonzeros at column 3, 7, 9</div><div class=""><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><font face="monospace" class="">m=2;</font></div><div class=""><font face="monospace" class="">n=3;</font></div><div class=""><font face="monospace" class="">idxm[] = {2, 4};</font></div><div class=""><font face="monospace" class="">idxn[] = {3, 7, 9};</font></div><div class=""><font face="monospace" class="">v[6] = {0.1, 0.2, ....};</font></div><div class=""><font face="monospace" class="">MatSetValues(mat, m, idxm, n, idxn,v, INSERT_VALUES);</font></div></blockquote></div><br clear="all" class=""><div class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">--Junchao Zhang</div></div></div><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 13, 2020 at 9:59 AM Bin Liu <<a href="mailto:lbllm2018@hotmail.com" class="">lbllm2018@hotmail.com</a>> wrote:<br class=""></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" class="">
<div class=""><p class="MsoNormal"><span lang="EN-US" class="">Hi all,<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span lang="EN-US" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span lang="EN-US" class="">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?<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span lang="EN-US" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span lang="EN-US" class="">Regards<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span lang="EN-US" class="">B. <u class=""></u><u class=""></u></span></p>
</div>
</div>
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>