[petsc-users] find eigenvalues in serial for small matrix

Oleksandr Koshkarov olk548 at mail.usask.ca
Mon Jul 23 20:27:59 CDT 2018


Dear All,

In my large parallel simulation, I need to precompute eigenvalues (or at 
least the largest one) of smallish simple matrix (from 4x4 up to maybe 
50x50, tridiagonal and symmetric). Computation time here is not 
important and I thought to do it for each processor independently in 
serial. I thought to use petsc for this as I already use petsc for 
everything else. However, simple solution seems not to work:

   Mat M;
   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&M);

... insering some values

   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

   KSP ksp;
   KSPCreate(PETSC_COMM_WORLD,&ksp);
   KSPSetOperators(ksp,M,M);

   PetscReal r[n], c[n];
   KSPComputeEigenvaluesExplicitly(ksp,n,r,c);

which produces the error:
[0]PETSC ERROR: --------------------- Error Message 
--------------------------------------------------------------
[0]PETSC ERROR: Null argument, when expecting valid pointer
[0]PETSC ERROR: Null Object: Parameter # 1
[0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html 
for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.9.2, May, 20, 2018
[0]PETSC ERROR: ./eigtest on a arch-linux2-c-debug named koshlaptop by 
kosh Mon Jul 23 19:25:29 2018
[0]PETSC ERROR: Configure options --with-hdf5-dir=/home/kosh/.local/hdf5
[0]PETSC ERROR: #1 VecDuplicate() line 372 in 
/home/kosh/.local/petsc-3.9.2/src/vec/vec/interface/vector.c
[0]PETSC ERROR: #2 KSPComputeExplicitOperator() line 47 in 
/home/kosh/.local/petsc-3.9.2/src/ksp/ksp/interface/eige.c
[0]PETSC ERROR: #3 KSPComputeEigenvaluesExplicitly() line 140 in 
/home/kosh/.local/petsc-3.9.2/src/ksp/ksp/interface/eige.c

Is it possible to use petsc for this simple task? or KSP will not work 
with dense serial matrix?

Thank you in advance and best regards,
Alex.


More information about the petsc-users mailing list