Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIT #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

SIT #93

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions python/ad-hoc/SIT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numpy as np
def SIT(A, b):
# if the matrix is not lower triangular, we cannot solve the system
if not np.allclose(A, np.tril(A)):
print("The matrix A is not lower triangular!")
return np.nan

n = len(b)
x = np.zeros((n, 1))

# calculate x1
x[0, 0] = b[0, 0] / A[0, 0]

# calculate x(i) forwards
for i in range (1, n):
sum_of_xs = np.dot(A[i, 0 : i], x[0 : i, 0])
x[i, 0] = (b[i, 0] - sum_of_xs) / A[i, i]

return x