Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def eigenvalues(self):
import slepc4py
slepc4py.init()
from slepc4py import SLEPc
E = SLEPc.EPS(); E.create()
E.setOperators(self.A)
E.setProblemType(SLEPc.EPS.ProblemType.NHEP)
E.setDimensions(1)
E.setWhichEigenpairs(SLEPc.EPS.Which.SMALLEST_REAL)
E.setFromOptions()
E.solve()
n = E.getConverged()
for i in range(0, n):
print(E.getEigenvalue(0))
return
elif key == "spectral_shift":
st = self.eps.getST()
st.setShift(value)
elif key == "spectral_transform":
assert value == "shift-and-invert"
st = self.eps.getST()
st.setType(SLEPc.ST.Type.SINVERT)
elif key == "spectrum":
if value == "largest magnitude":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.LARGEST_MAGNITUDE)
elif value == "smallest magnitude":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.SMALLEST_MAGNITUDE)
elif value == "largest real":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.LARGEST_REAL)
elif value == "smallest real":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.SMALLEST_REAL)
elif value == "largest imaginary":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.LARGEST_IMAGINARY)
elif value == "smallest imaginary":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.SMALLEST_IMAGINARY)
elif value == "target magnitude":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_MAGNITUDE)
if "spectral_shift" in parameters:
self.eps.setTarget(parameters["spectral_shift"])
elif value == "target real":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_REAL)
if "spectral_shift" in parameters:
self.eps.setTarget(parameters["spectral_shift"])
elif value == "target imaginary":
self.eps.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_IMAGINARY)
if "spectral_shift" in parameters:
self.eps.setTarget(parameters["spectral_shift"])