In-place normalization during eigensolve
This commit is contained in:
parent
7342c8efd7
commit
17fa2aa3d3
@ -67,8 +67,8 @@ def solve_waveguide_mode_2d(mode_number: int,
|
|||||||
eigval = v.conj() @ A @ v
|
eigval = v.conj() @ A @ v
|
||||||
if numpy.linalg.norm(A @ v - eigval * v) < 1e-13:
|
if numpy.linalg.norm(A @ v - eigval * v) < 1e-13:
|
||||||
break
|
break
|
||||||
w = spalg.spsolve(A - eigval * sparse.eye(A.shape[0]), v)
|
v = spalg.spsolve(A - eigval * sparse.eye(A.shape[0]), v)
|
||||||
v = w / numpy.linalg.norm(w)
|
v /= numpy.linalg.norm(v)
|
||||||
|
|
||||||
# Calculate the wave-vector (force the real part to be positive)
|
# Calculate the wave-vector (force the real part to be positive)
|
||||||
wavenumber = numpy.sqrt(eigval)
|
wavenumber = numpy.sqrt(eigval)
|
||||||
|
Loading…
Reference in New Issue
Block a user