It is not only for A./B. If one wants to do A.*B, it is not necessary to guarantee the nonzeros of B. Generally, I think MatGetValues() will be good choice although you need to judge whether the entries are zero when doing A./B. <br>
<br>Yujie<br><br><div class="gmail_quote">On Sun, Feb 21, 2010 at 2:17 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Sun, 21 Feb 2010 13:48:09 -0600, Yujie <<a href="mailto:recrusader@gmail.com">recrusader@gmail.com</a>> wrote:<br>
> Hi, Jeb<br>
><br>
> It looks MatGetRow() only can get the nonzero row values for sparse matrix.<br>
> It is not suitable for A./B if there are different formats between A and B.<br>
<br>
</div>Of course, but note that B must have at least all the nonzeros of A,<br>
otherwise you divide by 0. If you really need to do A./B where A was<br>
not preallocated to match B (it is a strict subset), then MatDuplicate B<br>
(call it C), loop over rows inserting rows of A into C, then perform the<br>
division with MatGetArray B and C (you'll have to work with the<br>
off-diagonal blocks separately in parallel).<br>
<br>
But you would be *much* better off to find a way to assemble the matrix<br>
you want rather than these other matrices with inequivalent nonzero<br>
patterns.<br>
<font color="#888888"><br>
Jed<br>
</font></blockquote></div><br>