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

Alex Eftimiades alexeftimiades at gmail.com
Mon Jun 9 15:33:44 CDT 2014


Thanks.

For anyone who reads this, the correct code looks like this:

     E.solve()

     vals = []
     vecs = []
     for i in range(E.getConverged()):
         val = E.getEigenpair(i, xr, xi)
         vals.append(val)
         vecs = [complex(xr0, xi0) for xr0, xi0 in zip(xr.getArray(), 
xi.getArray())]

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


On 06/09/2014 02:58 PM, Jose E. Roman wrote:
> 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