1

I got a "Inserting -nan+iG error" at function MatSetValues.

My code goes 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's the problem:

I compile my PETSc code into a .so lib and 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. So I copy the matrix from screen into a file and compile it with options:

g++ test.cpp -L. -leigen_slepc -lstdc++ -I/home/altria/software/slepc-3.4.4/include -I/home/altria/software/slepc-3.4.4/arch-linux2-c-debug/include -I/home/altria/software/petsc-3.4.4/include -I/home/altria/software/petsc-3.4.4/arch-linux2-c-debug/include

This time it passed. So I guess maybe the difference of compiling processing caused the problem. Do anyone have any idea about my problem?

Praetorian
  • 106,671
  • 19
  • 240
  • 328
altria
  • 53
  • 5

0 Answers0