From 45aaf49cb3fe07b006316bacac1318f07a08cc19 Mon Sep 17 00:00:00 2001 From: Thomas Albers Raviola Date: Tue, 14 May 2024 11:13:31 +0200 Subject: * Initial commit --- solvers.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solvers.py (limited to 'solvers.py') diff --git a/solvers.py b/solvers.py new file mode 100644 index 0000000..7aa9568 --- /dev/null +++ b/solvers.py @@ -0,0 +1,20 @@ +"""Routines for solving a linear system of equations.""" + +import numpy as np +from numpy.typing import NDArray + + +def gaussian_eliminate(aa: NDArray[np.float_], bb: NDArray[np.float_]) -> NDArray[np.float_] | None: + """Solves a linear system of equations (Ax = b) by Gauss-elimination + + Args: + aa: Matrix with the coefficients. Shape: (n, n). + bb: Right hand side of the equation. Shape: (n,) + + Returns: + Vector xx with the solution of the linear equation or None + if the equations are linearly dependent. + """ + nn = aa.shape[0] + xx = np.zeros((nn,), dtype=np.float_) + return xx -- cgit v1.2.3