<div dir="ltr"><div dir="ltr">On Mon, Mar 11, 2019 at 8:27 AM Eda Oktay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</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 dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>I have a following part of a code which tries to change the nonzero values of matrix L with -1. However in MatSetValues line, something happens and some of the values in matrix turns into 1.99665e-314 instead of -1. Type of arr is defined as PetscScalar and arr is produced correctly. What can be the problem, is there a mistake about types?</div><div><br></div><div>Thanks,</div><div><br></div><div>Eda</div><div><br></div><div><br></div><div>for(rw = mm; rw<nn; ++rw){ </div><div> ierr = MatGetRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr); </div><div> s = sizeof(vals);</div></div></div></div></blockquote><div><br></div><div>This is wrong. sizeof(vals) gives bytes, not entries. Why don't you just use ncols here?</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 dir="ltr"><div dir="ltr"><div dir="ltr"><div> ierr = PetscMalloc1(s,&arr);CHKERRQ(ierr); </div><div> for(j=0;j<s;++j){ </div><div> arr[j]=-1.0;</div><div> }</div><div> ierr = MatSetValues(NSymmA,1,&rw,ncols,cols,arr,INSERT_VALUES);CHKERRQ(ierr); </div><div> ierr = MatRestoreRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr);</div><div> }</div></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>