Skip to content

Commit

Permalink
lufact for sparse matrix pivot option error (#18246)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
garrettthomaskth authored and andreasnoack committed Aug 29, 2016
1 parent 77176cd commit 68d3d32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion base/sparse/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion test/sparsedir/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit 68d3d32

Please sign in to comment.