From 62563b8116c8eaed89721fe7d205b2095a3f06c0 Mon Sep 17 00:00:00 2001 From: garrettthomaskth Date: Mon, 29 Aug 2016 14:23:47 +0200 Subject: [PATCH] lufact for sparse matrix pivot option error (#18246) * lufact for sparse matrix pivot option error base/sparse/umfpack.jl includes the following method definition for lufact `lufact(A::SparseMatrixCSC, pivot::Type{Val{false}}) = lufact(A)` This should likely be `lufact(A::SparseMatrixCSC, pivot::Type{Val{true}}) = lufact(A)` because in lufact pivoting is on by default. The error is shown in the following example ``` A = speye(4) A[1:2,1:2] = [-.01 -200; 200 .001] F = lufact(A,Val{false}) F[:p] ``` which returns ``` julia> F[:q] 4-element Array{Int64,1}: 3 4 1 2 ``` However it should return ``` julia> F[:q] 4-element Array{Int64,1}: 1 2 3 4 ``` because pivoting was turned off. * Added test for #18246 and #18244 * 4 space indent oops my bad * remove unnecessary lufact method * update test for removed lufact method definition (cherry picked from commit 68d3d329ce369830433364d275c308a4dbc1bd46) --- base/sparse/umfpack.jl | 1 - test/sparsedir/umfpack.jl | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/base/sparse/umfpack.jl b/base/sparse/umfpack.jl index 3b426bb9f234d..25f4b9935a7d1 100644 --- a/base/sparse/umfpack.jl +++ b/base/sparse/umfpack.jl @@ -157,7 +157,6 @@ lufact{T<:AbstractFloat}(A::Union{SparseMatrixCSC{T},SparseMatrixCSC{Complex{T}} "sparse floating point LU using UMFPACK or lufact(full(A)) for generic ", "dense LU."))) lufact(A::SparseMatrixCSC) = lufact(float(A)) -lufact(A::SparseMatrixCSC, pivot::Type{Val{false}}) = lufact(A) size(F::UmfpackLU) = (F.m, F.n) diff --git a/test/sparsedir/umfpack.jl b/test/sparsedir/umfpack.jl index 6db636a20353e..6ce7877e58011 100644 --- a/test/sparsedir/umfpack.jl +++ b/test/sparsedir/umfpack.jl @@ -136,4 +136,12 @@ let @test_throws ArgumentError Base.SparseArrays.UMFPACK.solve!(a, lufact(speye(5,5)), a, Base.SparseArrays.UMFPACK.UMFPACK_A) aa = complex(a) @test_throws ArgumentError Base.SparseArrays.UMFPACK.solve!(aa, lufact(complex(speye(5,5))), aa, Base.SparseArrays.UMFPACK.UMFPACK_A) -end \ No newline at end of file +end + +#18246,18244-lufact sparse pivot +let + A = speye(4) + A[1:2,1:2] = [-.01 -200; 200 .001] + F = lufact(A) + @test F[:p] == [3 ; 4 ; 2 ; 1] +end