Skip to content

Commit

Permalink
Revert "Replacing the generator with numpy vector operations from lu_…
Browse files Browse the repository at this point in the history
…decomposition."

This reverts commit ad217c6.
  • Loading branch information
quant12345 committed Oct 7, 2023
1 parent eccea26 commit 4e34723
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions arithmetic_analysis/lu_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,15 @@ def lower_upper_decomposition(table: np.ndarray) -> tuple[np.ndarray, np.ndarray

lower = np.zeros((rows, columns))
upper = np.zeros((rows, columns))

# in 'total', the necessary data is extracted through slices
# and the sum of the products is obtained.

for i in range(columns):
for j in range(i):
total = np.sum(lower[i, :i] * upper[:i, j])
total = sum(lower[i][k] * upper[k][j] for k in range(j))
if upper[j][j] == 0:
raise ArithmeticError("No LU decomposition exists")
lower[i][j] = (table[i][j] - total) / upper[j][j]
lower[i][i] = 1
for j in range(i, columns):
total = np.sum(lower[i, :i] * upper[:i, j])
total = sum(lower[i][k] * upper[k][j] for k in range(j))
upper[i][j] = table[i][j] - total
return lower, upper

Expand Down

0 comments on commit 4e34723

Please sign in to comment.