JuliaArrays / JuliaArrays/StaticArrays.jl

inv(Inf*I) returns Nan for dims between (2,2) and (4,4)

Open
#897 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When calculating the inverse of a matrix with inf-entries, StaticArrays returns NaNs:

julia> inv(SMatrix{3,3}(Inf*I))
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 NaN  NaN  NaN
 NaN  NaN  NaN
 NaN  NaN  NaN

Using normal matrices results in zero:

julia> inv(Inf*I(3))       # Diagonal
3×3 Diagonal{Float64, Vector{Float64}}:
 0.0   ⋅    ⋅ 
  ⋅   0.0   ⋅ 
  ⋅    ⋅   0.0
julia> inv(Inf*Matrix(I(3)))  # Also for full matrix
3×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0

This is true for the Dims (2,2) (3,3) and (4,4) and probably due to the specialized methods for these sizes in inv.jl.

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

Reproduce the issue in Julia for the 2×2, 3×3, and 4×4 cases, then inspect the specialized inverse methods in inv.jl. Compare their behavior with inv(Inf*I(N)) for normal matrices; done means the StaticArrays results no longer produce NaNs for these diagonal infinity inputs.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.