Skip to content
Snippets Groups Projects
Commit 4c1a2ac5 authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

getdp: pretty print

parent 8b077ef0
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ import numpy.matlib
def simple(operator, radius, origin,
nodes=100, maxIt=10, lStart=1, lStep=1, rankTol=1e-4):
"""Solve an eigenvalue problem using Beyn's algorithm (simple version)
"""Solves an eigenvalue problem using Beyn's algorithm (simple version)
Keyword arguments:
operator -- the solver defining the operator to use
......@@ -14,6 +14,8 @@ def simple(operator, radius, origin,
lStart -- the number of columns used for A0 when algorithm starts (optional)
lStep -- the step used for increasing the number of columns of A0 (optional)
rankTol -- the tolerance for the rank test
Returns the computed eigenvalues
"""
# Initialise A0 search
......@@ -67,11 +69,8 @@ def simple(operator, radius, origin,
print "Solving linear EVP..."
myLambda, QHat = numpy.linalg.eig(B)
# Display
display(myLambda)
# Done
return
return myLambda
## Import only simple (other functions are just helpers)
......@@ -162,19 +161,6 @@ def randomMatrix(n, m):
return np.matlib.rand(n, m) + np.matlib.rand(n, m) * 1j
def display(v):
"""Displays the eigenvalues given in the array v"""
size = v.shape[0]
print "Eigenvalues:"
print "----------- "
for i in range(size):
print "(" + format(np.real(v[i]).tolist(), '+e') + ")",
print "+",
print "(" + format(np.imag(v[i]).tolist(), '+e') + ")*j"
print "----------- "
print "Found: " + str(size)
def zeroRankErrorStr():
"""Returns a string explaining the probable reason of a zero rank"""
return ("Found a rank of zero: " +
......
......@@ -11,4 +11,13 @@ resolution = "Maxwell"
operator = Solver.GetDPWave(pro, mesh, resolution)
# Compute
Beyn.simple(operator, 1e8, complex(9e8, 0))
v = Beyn.simple(operator, 1e8, complex(9e8, 0))
print "Eigenvalues:"
print "----------- "
for i in range(v.shape[0]):
print "(" + format(np.real(v[i]).tolist(), '+e') + ")",
print "+",
print "(" + format(np.imag(v[i]).tolist(), '+e') + ")*j"
print "----------- "
print "Found: " + str(v.shape[0])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment