Skip to content

Commit ecc0c43

Browse files
authored
Use norm instead of abs in generic lu factorization (#34575)
* Use norm instead of abs in generic lu factorization * Add norm for ModInt in tests
1 parent 4c7ae77 commit ecc0c43

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stdlib/LinearAlgebra/src/lu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ function generic_lufact!(A::StridedMatrix{T}, ::Val{Pivot} = Val(true);
140140
# find index max
141141
kp = k
142142
if Pivot
143-
amax = abs(zero(T))
143+
amax = norm(zero(T))
144144
for i = k:m
145-
absi = abs(A[i,k])
145+
absi = norm(A[i,k])
146146
if absi > amax
147147
kp = i
148148
amax = absi

stdlib/LinearAlgebra/test/generic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ LinearAlgebra.Transpose(a::ModInt{n}) where {n} = transpose(a)
365365

366366
# Needed for pivoting:
367367
Base.abs(a::ModInt{n}) where {n} = a
368+
LinearAlgebra.norm(a::ModInt{n}) where {n} = a
369+
368370
Base.:<(a::ModInt{n}, b::ModInt{n}) where {n} = a.k < b.k
369371

370372
@test A*(lu(A, Val(true))\b) == b

0 commit comments

Comments
 (0)