mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Refactorings (#8987)
* use np.dot * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * further improvements using array slicing Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
parent
672e7bde2e
commit
1984d97171
|
@ -33,10 +33,7 @@ def retroactive_resolution(
|
|||
|
||||
x: NDArray[float64] = np.zeros((rows, 1), dtype=float)
|
||||
for row in reversed(range(rows)):
|
||||
total = 0
|
||||
for col in range(row + 1, columns):
|
||||
total += coefficients[row, col] * x[col]
|
||||
|
||||
total = np.dot(coefficients[row, row + 1 :], x[row + 1 :])
|
||||
x[row, 0] = (vector[row] - total) / coefficients[row, row]
|
||||
|
||||
return x
|
||||
|
|
Loading…
Reference in New Issue
Block a user