Skip to content

LU instability for non-float matrices due to lack of pivoting #605

Closed
JuliaLang/julia
#32989
@stevengj

Description

@stevengj

As was pointed out recently on discourse, the lu function suffers from numerical instability for non-floating-point matrices, where it tries to do the factorization without pivoting first.

(The example on the mailing list was det([1 1 0 0 1 0 0 0; 1 0 1 0 0 1 0 0; 1 0 0 1 0 0 1 0; 0 1 1 1 0 0 0 0; 0 1 0 0 0 0 1 1; 0 0 1 0 1 0 0 1; 0 0 0 1 1 1 0 0; 0 0 0 0 1 1 0 1]).)

The problem seems to stem from PR JuliaLang/julia#10215 by @andreasnoack, and indeed the abovementioned determinant started being wrong in Julia 0.4.

As @tpapp suggested, we should default to pivoting at least whenever lutype(T) <: AbstractFloat, but we also want to handle cases like lutype(Complex{Int}) == Complex{Float64}. Perhaps the right criterion is to pivot whenever abs(zero(lutype(T))) isa AbstractFloat since pivoting is based on the abs function.

(Not sure whether we should try to support types that don't have abs via try-catch?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions