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
ksp = self.eps.getST().getKSP()
ksp.setType("preonly")
ksp.getPC().setType("lu")
if value == "default":
value = wrapping.get_default_linear_solver()
if hasattr(ksp.getPC(), "setFactorSolverType"): # PETSc >= 3.9
ksp.getPC().setFactorSolverType(value)
else:
ksp.getPC().setFactorSolverPackage(value)
elif key == "maximum_iterations":
eps_tolerances[1] = value
elif key == "problem_type":
if value == "hermitian":
self.eps.setProblemType(SLEPc.EPS.ProblemType.HEP)
elif value == "non_hermitian":
self.eps.setProblemType(SLEPc.EPS.ProblemType.NHEP)
elif value == "gen_hermitian":
self.eps.setProblemType(SLEPc.EPS.ProblemType.GHEP)
elif value == "gen_non_hermitian":
self.eps.setProblemType(SLEPc.EPS.ProblemType.GNHEP)
elif value == "pos_gen_non_hermitian":
self.eps.setProblemType(SLEPc.EPS.ProblemType.PGNHEP)
else:
raise RuntimeError("Invalid problem type")
elif key == "solver":
if value == "power":
self.eps.setType(SLEPc.EPS.Type.POWER)
elif value == "subspace":
self.eps.setType(SLEPc.EPS.Type.SUBSPACE)
elif value == "arnoldi":
self.eps.setType(SLEPc.EPS.Type.ARNOLDI)
elif value == "lanczos":