[petsc-users] Getting Eigenvectors from a SLEPc run (in python)
Jose E. Roman
jroman at dsic.upv.es
Mon Jun 9 13:58:32 CDT 2014
El 09/06/2014, a las 20:45, Alex Eftimiades escribió:
> Hi
>
> I am trying solve a sparse generalized Hermitian matrix eigenvalue problem. I am trying to use slepc4py to get both the eigenvalues and eigenvectors, but I am unable to get the eigenvectors. Instead, I keep getting None. Do you have any example code that can do this? I copied the code I have tried below.
>
> Thanks,
> Alex Eftimiades
>
> xr, tmp = A.getVecs()
> xi, tmp = A.getVecs()
>
> # Setup the eigensolver
> E = SLEPc.EPS().create()
> E.setOperators(A,M)
> E.setDimensions(50, PETSc.DECIDE)
>
> E.setWhichEigenpairs("SM")
>
> E.solve()
>
> vals = []
> vecs = []
> for i in range(E.getConverged()):
> val = E.getEigenpair(i, xr, xi)
> vecr, veci = E.getEigenvector(i, xr, xi)
> vals.append(val)
> vecs.append(complex(vecr, veci))
>
> vals = asarray(vals)
> vecs = asarray(vecs).T
Eigenvectors are not obtained as return values. Instead, the arguments of getEigenvector() are mutable, so after the call they contain the eigenvector.
Jose
More information about the petsc-users
mailing list