<div dir="ltr"><div><div><div><div><div><div>Hi,all<br><br></div>I got a "Inserting -nan+iG error" at function MatSetValues.<br><br>My code like this:<br><br>I first use code below to change a double into PETScScalar (I am using Complex version).<br>
<b>for(i=0;i<nz;i++)temp[i] = Ax[i] + Az[i] * PETSC_i;</b><br></div>Then I use code below to insert values into matrix.<br><b>ierr = MatSetValues(A,n,Conlumn_ptr,n,Ai,temp,INSERT_VALUES);</b><br><br></div><div>Here is how problem happens:<br>
<br></div>I compile my PETSc code into a .so lib and test it with a simple matrix and<b> it passed</b>. So I link it with the other part of my program.<br><br></div>However, it keeps telling me <br><b><br>Inserting -nan+iG at matrix entry (2,3)!</b><br>
<br></div>The
 (2,3) is zero actually, and I could print it with std::cerr which tells
 me it is zero. The other part of my program,with which generates actual
 matrix I will deal, is correct.(I could use ARPACK with it.) <br><br></div>I
 was confused about why PETSc recognize a zero into -nan. In my simple 
test, there is also zero entry, at (0,0) however. For the other part is 
compiled itself, I guess there might be some problem with compiling 
options. But I have no idea about it. Could anybody help me?<br><div><br><br></div>Guoxi </div>