[petsc-users] MatMPIAIJSetPreallocationCSR and complex scalars

Heikki Virtanen heikki.a.virtanen at hotmail.com
Sun Jul 21 15:53:35 CDT 2013


Hi, I have tried to solve generalized complex eigenvalue problem using SLEPc and PETSc. Both matrices are also sparse and I know with very good accuracy where I have non-zero entries. So, it sounds that function MatMPIAIJSetPreallocationCSR() is very good in my case. I have a test problem and my code works well with real scalars, but when I change real scalars to complex I get errors like

Floating point exception!
[0]PETSC ERROR: Inserting -nan+iG at matrix entry (0,-524288)!
[0]PETSC ERROR: MatSetValues() line 1092 in /opt/petsc-3.4.2/src/mat/interface/matrix.c
[0]PETSC ERROR: MatAXPY_BasicWithPreallocation() line 122 in /opt/petsc-3.4.2/src/mat/utils/axpy.c
[0]PETSC ERROR: MatAXPY_MPIAIJ() line 2343 in /opt/petsc-3.4.2/src/mat/impls/aij/mpi/mpiaij.c
[0]PETSC ERROR: MatAXPY() line 39 in /opt/petsc-3.4.2/src/mat/utils/axpy.c
[0]PETSC ERROR: STMatGAXPY_Private() line 366 in /opt/slepc-3.4.0/src/st/interface/stsolve.c
[0]PETSC ERROR: STSetUp_Shift() line 113 in /opt/slepc-3.4.0/src/st/impls/shift/shift.c
[0]PETSC ERROR: STSetUp() line 285 in /opt/slepc-3.4.0/src/st/interface/stsolve.c
[0]PETSC ERROR: EPSSetUp() line 215 in /opt/slepc-3.4.0/src/eps/interface/setup.c
[0]PETSC ERROR: EPSSolve() line 90 in /opt/slepc-3.4.0/src/eps/interface/solve.c

I have also printed out the matrices, after these are assembled using MatSetValues(), in complex and real case and both are ok. ( there is nothing suspicious and PETSc does not try to access entries which are not initialized.) Also MatZeroRowsColumns() works when I apply boundary conditions. I don't know but I would guess that something is wrong when I initialize matrices. Basically, I do it in this way.

ierr = MatMPIAIJSetPreallocationCSR (matrix,i,j,0); CHKERRQ(ierr);
ierr = MatAssemblyBegin (matrix,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
ierr = MatAssemblyEnd (matrix,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE); CHKERRQ(ierr);
ierr = MatSetOption (matrix, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);CHKERRQ(ierr);

i and j arrays work fine with real case so they should be ok. Is there any examples where MatMPIAIJSetPreallocationCSR() is used to initialize matrices of eigenvalue problem.

-Heikki

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130721/6713e223/attachment.html>


More information about the petsc-users mailing list