diff --git a/stdlib/LinearAlgebra/src/lu.jl b/stdlib/LinearAlgebra/src/lu.jl index c770f478d4f4a..18ba0bbe11e6a 100644 --- a/stdlib/LinearAlgebra/src/lu.jl +++ b/stdlib/LinearAlgebra/src/lu.jl @@ -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 diff --git a/stdlib/LinearAlgebra/test/generic.jl b/stdlib/LinearAlgebra/test/generic.jl index 9ca508d9a9908..de7eade6030b3 100644 --- a/stdlib/LinearAlgebra/test/generic.jl +++ b/stdlib/LinearAlgebra/test/generic.jl @@ -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