JuliaArrays / JuliaArrays/StaticArrays.jl

Singular matrix inversion doesn't produce an Exception as it does for Matrix

Open
#434 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

numerical-robustness
Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

julia> A = [0 1; 0 0]
2×2 Array{Int64,2}:
 0  1
 0  0

julia> inv(A)
ERROR: Base.LinAlg.LAPACKException(1)
Stacktrace:
 [1] chklapackerror(::Int64) at ./linalg/lapack.jl:34
 [2] trtrs!(::Char, ::Char, ::Char, ::Array{Float64,2}, ::Array{Float64,2}) at ./linalg/lapack.jl:3291
 [3] inv at ./linalg/triangular.jl:536 [inlined]
 [4] inv(::Array{Int64,2}) at ./linalg/dense.jl:655

julia> A = @SMatrix [0 1; 0 0]
2×2 StaticArrays.SArray{Tuple{2,2},Int64,2,4}:
 0  1
 0  0

julia> inv(A)
2×2 StaticArrays.SArray{Tuple{2,2},Float64,2,4}:
 NaN  -Inf
 NaN   NaN

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue's inv(A) examples for a singular regular matrix and a StaticArrays @SMatrix. Compare the resulting behavior with Matrix inversion and trace the StaticArrays entry point used by inv. Done means singular static matrices produce the expected exception rather than NaN or Inf values.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.