<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
1) the asserts<br>
PetscValidScalarPointer(r,3);<br>
PetscValidScalarPointer(c,4);<br>
<br>
are over zealous. They should actually be if (n) PetscValidScalarPointer(r,3);<br>
<br></blockquote><div><br></div><div>That fixed the problem.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BTW: we should have an additional assert that n >=0<br></blockquote><div><br></div><div>I guess I should have done a if (n<0) SETERRQ(...</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
ierr = PetscMemzero(c,nmax*sizeof(PetscReal));CHKERRQ(ierr);<br>
if (!n) {<br>
*r = 0.0;<br>
^^^^ assumes there is space in r for something even if the array dimension is zero which is not good.<br>
<br></blockquote><div> </div><div> I'm not sure how to test this so I just protected this line.</div></div></div></div>