From 17fa2aa3d370635a1bb8b9c713b7b93979c46ba3 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 24 Sep 2017 19:13:37 -0700 Subject: [PATCH] In-place normalization during eigensolve --- fdfd_tools/waveguide_mode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdfd_tools/waveguide_mode.py b/fdfd_tools/waveguide_mode.py index 51a6266..fac43e2 100644 --- a/fdfd_tools/waveguide_mode.py +++ b/fdfd_tools/waveguide_mode.py @@ -67,8 +67,8 @@ def solve_waveguide_mode_2d(mode_number: int, eigval = v.conj() @ A @ v if numpy.linalg.norm(A @ v - eigval * v) < 1e-13: break - w = spalg.spsolve(A - eigval * sparse.eye(A.shape[0]), v) - v = w / numpy.linalg.norm(w) + v = spalg.spsolve(A - eigval * sparse.eye(A.shape[0]), v) + v /= numpy.linalg.norm(v) # Calculate the wave-vector (force the real part to be positive) wavenumber = numpy.sqrt(eigval)