From d9fddede0840ca18907db7b703639dd74af88e65 Mon Sep 17 00:00:00 2001 From: AndreaBaldanza Date: Fri, 10 Apr 2026 14:23:30 +0200 Subject: [PATCH] Fix save_abc dropping the last a coefficient in biconjugate Lanczos In run_FT, a_coeffs is appended at every iteration while b_coeffs and c_coeffs are appended only when the algorithm has not converged, so len(a) = N and len(b) = len(c) = N-1. save_abc used len(c_coeffs) as the array size, silently truncating the last diagonal element of the continued fraction. Use len(a_coeffs) as the leading dimension and fill b/c only for the rows that exist. The last row gets b = c = 0, consistent with the termination of the continued fraction. Co-Authored-By: Claude Opus 4.6 --- Modules/DynamicalLanczos.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/DynamicalLanczos.py b/Modules/DynamicalLanczos.py index c80718d1..b4b71db8 100644 --- a/Modules/DynamicalLanczos.py +++ b/Modules/DynamicalLanczos.py @@ -3658,12 +3658,12 @@ def save_abc(self, file): In this way the calculation cannot be restarted. """ - total_len = len(self.c_coeffs) + total_len = len(self.a_coeffs) abc = np.zeros( (total_len, 3), dtype = np.double) - abc[:,0] = self.a_coeffs[:total_len] - abc[:,1] = self.b_coeffs - abc[:,2] = self.c_coeffs + abc[:,0] = self.a_coeffs + abc[:len(self.b_coeffs),1] = self.b_coeffs + abc[:len(self.c_coeffs),2] = self.c_coeffs np.savetxt(file, abc, header = "a; b; c")