diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-06-04 11:11:20 +0200 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-06-04 11:11:20 +0200 |
commit | fe852453c0cb80e05a0adc4a95ceb52873461851 (patch) | |
tree | 313beb43b025917264da93048c1f1f8d63d15c84 /solvers.py | |
parent | 68870236395435606a767c4c8c1a6b45f5c1ff64 (diff) |
Modify substitution routines to return vectors
Diffstat (limited to 'solvers.py')
-rw-r--r-- | solvers.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -64,7 +64,7 @@ def forward_substitution( x: solution of the system of equations ''' nn = aa.shape[0] - xx = np.zeros((nn, 1), dtype=np.float_) + xx = np.zeros(nn, dtype=np.float_) for i in range(nn): xx[i] = (bb[i] - np.dot(aa[i, 0:i], xx[0:i])) / aa[i, i] return xx @@ -83,7 +83,7 @@ def back_substitution( x: solution of the system of equations ''' nn = aa.shape[0] - xx = np.zeros((nn, 1), dtype=np.float_) + xx = np.zeros(nn, dtype=np.float_) for i in range(nn - 1, -1, -1): xx[i] = (bb[i] - np.dot(aa[i, i:], xx[i:nn])) / aa[i, i] return xx @@ -114,4 +114,4 @@ def gaussian_eliminate( y = forward_substitution(ll, pp @ bb) # U @ x = y x = back_substitution(uu, y) - return x[:, 0] + return x |