[petsc-users] Inserting -nan+iG at matrix entry problem

Karl Rupp rupp at iue.tuwien.ac.at
Wed May 7 05:08:00 CDT 2014


Hi,

from your description it sounds like this might be a memory corruption 
issue. Please run your code through valgrind first. If this doesn't show 
any errors, please send more context (sources, Makefile, etc.). We can 
only guess what e.g. the type of 'temp' is or whether the correct header 
files get picked up.

Best regards,
Karli


On 05/07/2014 11:01 AM, 张国熙 wrote:
> Hi,all
>
> I got a "Inserting -nan+iG error" at function MatSetValues.
>
> My code like this:
>
> I first use code below to change a double into PETScScalar (I am using
> Complex version).
> *for(i=0;i<nz;i++)temp[i] = Ax[i] + Az[i] * PETSC_i;*
> Then I use code below to insert values into matrix.
> *ierr = MatSetValues(A,n,Conlumn_ptr,n,Ai,temp,INSERT_VALUES);*
>
> Here is how problem happens:
>
> I compile my PETSc code into a .so lib and test it with a simple matrix
> and*it passed*. So I link it with the other part of my program.
>
> However, it keeps telling me
> *
> Inserting -nan+iG at matrix entry (2,3)!*
>
> 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.)
>
> 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?
>
>
> Guoxi



More information about the petsc-users mailing list