[petsc-users] Getting Eigenvectors from a SLEPc run (in python)

Alex Eftimiades alexeftimiades at gmail.com
Mon Jun 9 13:45:45 CDT 2014


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.

Alex Eftimiades

     xr, tmp = A.getVecs()
     xi, tmp = A.getVecs()

     # Setup the eigensolver
     E = SLEPc.EPS().create()
     E.setDimensions(50, PETSc.DECIDE)



     vals = []
     vecs = []
     for i in range(E.getConverged()):
         val = E.getEigenpair(i, xr, xi)
         vecr, veci = E.getEigenvector(i, xr, xi)
         vecs.append(complex(vecr, veci))

     vals = asarray(vals)
     vecs = asarray(vecs).T

More information about the petsc-users mailing list