Skip to content

Commit

Permalink
Use norm instead of abs in generic lu factorization (JuliaLang#34575)
Browse files Browse the repository at this point in the history
* Use norm instead of abs in generic lu factorization

* Add norm for ModInt in tests
  • Loading branch information
mschauer authored Apr 24, 2020
1 parent 4c7ae77 commit ecc0c43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ function generic_lufact!(A::StridedMatrix{T}, ::Val{Pivot} = Val(true);
# find index max
kp = k
if Pivot
amax = abs(zero(T))
amax = norm(zero(T))
for i = k:m
absi = abs(A[i,k])
absi = norm(A[i,k])
if absi > amax
kp = i
amax = absi
Expand Down
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/test/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ LinearAlgebra.Transpose(a::ModInt{n}) where {n} = transpose(a)

# Needed for pivoting:
Base.abs(a::ModInt{n}) where {n} = a
LinearAlgebra.norm(a::ModInt{n}) where {n} = a

Base.:<(a::ModInt{n}, b::ModInt{n}) where {n} = a.k < b.k

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

0 comments on commit ecc0c43

Please sign in to comment.