further improvements using array slicing

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
Dom 2023-08-20 13:11:53 -07:00 committed by GitHub
parent c9871e71b6
commit 244ec4049f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,10 +33,7 @@ def retroactive_resolution(
x: NDArray[float64] = np.zeros((rows, 1), dtype=float) x: NDArray[float64] = np.zeros((rows, 1), dtype=float)
for row in reversed(range(rows)): for row in reversed(range(rows)):
total = np.dot( total = np.dot(coefficients[row, row + 1 :], x[row + 1 :])
[coefficients[row, col] for col in range(row + 1, columns)],
[x[col] for col in range(row + 1, columns)],
)
x[row, 0] = (vector[row] - total) / coefficients[row, row] x[row, 0] = (vector[row] - total) / coefficients[row, row]
return x return x