mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 18:38:39 +00:00
further improvements using array slicing
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
parent
c9871e71b6
commit
244ec4049f
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user