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

Matthew Knepley knepley at gmail.com
Mon Jul 23 20:32:46 CDT 2018


On Mon, Jul 23, 2018 at 9:28 PM Oleksandr Koshkarov <olk548 at mail.usask.ca>
wrote:

> 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?
>

What that does is compute the eigenvalues of the Krylov matrix. If you want
the eigenvalues of an explicit dense matrix, just call the LAPACK function
directly (dgeev).

   Matt


> Thank you in advance and best regards,
> Alex.
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180723/3876a513/attachment.html>


More information about the petsc-users mailing list