Skip to content

Commit

Permalink
Add getLeftEigenvector()
Browse files Browse the repository at this point in the history
  • Loading branch information
joseeroman committed Mar 29, 2019
1 parent 61625ce commit 90a874a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/SLEPc/EPS.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,33 @@ cdef class EPS(Object):
cdef PetscVec veci = Vi.vec if Vi is not None else <PetscVec>NULL
CHKERR( EPSGetEigenvector(self.eps, i, vecr, veci) )

def getLeftEigenvector(self, int i, Vec Wr, Vec Wi=None):
"""
Gets the i-th left eigenvector as computed by `solve()`.
Parameters
----------
i: int
Index of the solution to be obtained.
Wr: Vec
Placeholder for the returned eigenvector (real part).
Wi: Vec, optional
Placeholder for the returned eigenvector (imaginary part).
Notes
-----
The index ``i`` should be a value between ``0`` and
``nconv-1`` (see `getConverged()`). Eigensolutions are indexed
according to the ordering criterion established with
`setWhichEigenpairs()`.
Left eigenvectors are available only if the twosided flag was set
with `setTwoSided()`.
"""
cdef PetscVec vecr = Wr.vec
cdef PetscVec veci = Wi.vec if Wi is not None else <PetscVec>NULL
CHKERR( EPSGetLeftEigenvector(self.eps, i, vecr, veci) )

def getEigenpair(self, int i, Vec Vr=None, Vec Vi=None):
"""
Gets the i-th solution of the eigenproblem as computed by
Expand Down
27 changes: 27 additions & 0 deletions src/SLEPc/NEP.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,33 @@ cdef class NEP(Object):
CHKERR( NEPGetEigenpair(self.nep, i, &sval1, &sval2, vecr, veci) )
return toComplex(sval1, sval2)

def getLeftEigenvector(self, int i, Vec Wr, Vec Wi=None):
"""
Gets the i-th left eigenvector as computed by `solve()`.
Parameters
----------
i: int
Index of the solution to be obtained.
Wr: Vec
Placeholder for the returned eigenvector (real part).
Wi: Vec, optional
Placeholder for the returned eigenvector (imaginary part).
Notes
-----
The index ``i`` should be a value between ``0`` and
``nconv-1`` (see `getConverged()`). Eigensolutions are indexed
according to the ordering criterion established with
`setWhichEigenpairs()`.
Left eigenvectors are available only if the twosided flag was set
with `setTwoSided()`.
"""
cdef PetscVec vecr = Wr.vec
cdef PetscVec veci = Wi.vec if Wi is not None else <PetscVec>NULL
CHKERR( NEPGetLeftEigenvector(self.nep, i, vecr, veci) )

def getErrorEstimate(self, int i):
"""
Returns the error estimate associated to the i-th computed
Expand Down
1 change: 1 addition & 0 deletions src/SLEPc/slepceps.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ cdef extern from * nogil:
int EPSGetConverged(SlepcEPS,PetscInt*)
int EPSGetEigenvalue(SlepcEPS,PetscInt,PetscScalar*,PetscScalar*)
int EPSGetEigenvector(SlepcEPS,PetscInt,PetscVec,PetscVec)
int EPSGetLeftEigenvector(SlepcEPS,PetscInt,PetscVec,PetscVec)
int EPSGetEigenpair(SlepcEPS,PetscInt,PetscScalar*,PetscScalar*,PetscVec,PetscVec)
int EPSGetInvariantSubspace(SlepcEPS,PetscVec*)

Expand Down
1 change: 1 addition & 0 deletions src/SLEPc/slepcnep.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ cdef extern from * nogil:

int NEPGetConverged(SlepcNEP,PetscInt*)
int NEPGetEigenpair(SlepcNEP,PetscInt,PetscScalar*,PetscScalar*,PetscVec,PetscVec)
int NEPGetLeftEigenvector(SlepcNEP,PetscInt,PetscVec,PetscVec)
int NEPComputeError(SlepcNEP,PetscInt,SlepcNEPErrorType,PetscReal*)
int NEPErrorView(SlepcNEP,SlepcNEPErrorType,PetscViewer)
int NEPGetErrorEstimate(SlepcNEP,PetscInt,PetscReal*)
Expand Down

0 comments on commit 90a874a

Please sign in to comment.