From 28f008ff550f1cd80c5e3fdd9cccab0af835310c Mon Sep 17 00:00:00 2001 From: mschauer Date: Wed, 29 Jan 2020 15:00:32 +0100 Subject: [PATCH 1/2] Use norm instead of abs in generic lu factorization --- stdlib/LinearAlgebra/src/lu.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/LinearAlgebra/src/lu.jl b/stdlib/LinearAlgebra/src/lu.jl index 5a240478a1123..eb86e54b082ff 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 From 08e4c24c6602e3aab17b5b37a72df1b89a469dfc Mon Sep 17 00:00:00 2001 From: mschauer Date: Thu, 30 Jan 2020 11:48:07 +0100 Subject: [PATCH 2/2] Add norm for ModInt in tests --- stdlib/LinearAlgebra/test/generic.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/LinearAlgebra/test/generic.jl b/stdlib/LinearAlgebra/test/generic.jl index eb747b185afa3..cc5c1a0f2d88d 100644 --- a/stdlib/LinearAlgebra/test/generic.jl +++ b/stdlib/LinearAlgebra/test/generic.jl @@ -346,6 +346,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