On Fri, Mar 26, 2010 at 9:18 AM, John-Michael Fischer <span dir="ltr">&lt;<a href="mailto:fischej@umich.edu">fischej@umich.edu</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I have a vector of values I want to insert into a sparse matrix as a row.  My vector contains non-zero values at their proper positions in the row and zero&#39;s elsewhere.  If I MatSetValues into a Mat setup in a sparse form, will PETSC automatically see the zero&#39;s and not insert them while working out the proper indecies of the non-zero elements?<br>

<br>
Is there another calling sequence that lets me do this without calling MatSetValue for each non-zero entry since the non-zero entries are not contiguous in the row?<br>
<br>
Alternatively, I was thinking I could assemble a vector with the indecies of the non-zero elements, then use that in the call to MatSetValues with a row vector of non-zero values only - but I wanted to ask first since this seems like a common usage pattern for PETSC sparse mat&#39;s.<br>
</blockquote><div><br></div><div>This is not very common, since Mats are usually very sparse, looking at every value would be</div><div>incredibly time consuming. I recommend compressing the row down to the nonzeros, and then</div>
<div>calling MatSetValues(). There is a flag you can set, <span class="Apple-style-span" style="font-family: Times; font-size: medium; ">MAT_IGNORE_ZERO_ENTRIES,</span></div><div>that will ignore zeros, but this would not be my first choice.</div>
<div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks,<br>
<font color="#888888">John-Michael</font></blockquote></div><br><br clear="all"><br>-- <br>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<br>