From fc10b363b3c35313ac2f1bf14f83daec2bf22c41 Mon Sep 17 00:00:00 2001 From: Thomas Albers Raviola Date: Tue, 4 Jun 2024 11:26:32 +0200 Subject: Throw exception on linear dependence --- solvers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'solvers.py') diff --git a/solvers.py b/solvers.py index 72f1b1d..38ac247 100644 --- a/solvers.py +++ b/solvers.py @@ -92,7 +92,7 @@ def gaussian_eliminate( aa: NDArray[np.float_], bb: NDArray[np.float_], tolerance: float = 1e-6 -) -> NDArray[np.float_] | None: +) -> NDArray[np.float_]: '''Solves a linear system of equations (A x = b) by LUP factorization. Args: @@ -108,7 +108,7 @@ def gaussian_eliminate( nn = uu.shape[0] # Check if rank of matrix is lower than nn if np.abs(uu[nn - 1, nn - 1]) < tolerance: - return None + raise ValueError # L y = P @ b y = forward_substitution(ll, pp @ bb) -- cgit v1.2.3