mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Update jacobi_iteration_method.py
left the old algorithm commented out, as it clearly shows what is being done.
This commit is contained in:
parent
cc545c5b49
commit
d288cbd864
@ -114,6 +114,24 @@ def jacobi_iteration_method(
|
||||
rows, cols = table.shape
|
||||
|
||||
strictly_diagonally_dominant(table)
|
||||
|
||||
"""
|
||||
# Iterates the whole matrix for given number of times
|
||||
for _ in range(iterations):
|
||||
new_val = []
|
||||
for row in range(rows):
|
||||
temp = 0
|
||||
for col in range(cols):
|
||||
if col == row:
|
||||
denom = table[row][col]
|
||||
elif col == cols - 1:
|
||||
val = table[row][col]
|
||||
else:
|
||||
temp += (-1) * table[row][col] * init_val[col]
|
||||
temp = (temp + val) / denom
|
||||
new_val.append(temp)
|
||||
init_val = new_val
|
||||
"""
|
||||
|
||||
"""
|
||||
denom - a list of values along the diagonal
|
||||
|
Loading…
x
Reference in New Issue
Block a user