Skip to content

Commit e4ab155

Browse files
convert uppercase variable to lowercase
1 parent 3e54f33 commit e4ab155

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

linear_algebra/determinant.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def determinant_lu(matrix: NDArray[float64]) -> float:
7777
n = matrix.shape[0]
7878

7979
# Create a copy to avoid modifying the original matrix
80-
A = matrix.astype(float64, copy=True)
80+
copy = matrix.astype(float64, copy=True)
8181

8282
# Keep track of row swaps for sign adjustment
8383
swap_count = 0
@@ -87,28 +87,28 @@ def determinant_lu(matrix: NDArray[float64]) -> float:
8787
# Find pivot
8888
max_row = i
8989
for k in range(i + 1, n):
90-
if abs(A[k, i]) > abs(A[max_row, i]):
90+
if abs(copy[k, i]) > abs(copy[max_row, i]):
9191
max_row = k
9292

9393
# Swap rows if needed
9494
if max_row != i:
95-
A[[i, max_row]] = A[[max_row, i]]
95+
copy[[i, max_row]] = copy[[max_row, i]]
9696
swap_count += 1
9797

9898
# Check for singular matrix
99-
if abs(A[i, i]) < 1e-14:
99+
if abs(copy[i, i]) < 1e-14:
100100
return 0.0
101101

102102
# Eliminate below pivot
103103
for k in range(i + 1, n):
104-
factor = A[k, i] / A[i, i]
104+
factor = copy[k, i] / copy[i, i]
105105
for j in range(i, n):
106-
A[k, j] -= factor * A[i, j]
106+
copy[k, j] -= factor * copy[i, j]
107107

108108
# Calculate determinant as product of diagonal elements
109109
det = 1.0
110110
for i in range(n):
111-
det *= A[i, i]
111+
det *= copy[i, i]
112112

113113
# Adjust sign based on number of row swaps
114114
if swap_count % 2 == 1:

0 commit comments

Comments
 (0)