JuliaArrays / JuliaArrays/StaticArrays.jl
Numerical issues with exp(::SMatrix{3, 3, Float32})
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
MWE:
julia> using StaticArrays
julia> F = Float32[0.0 1.0 0.0; 0.0 0.0 1.0; -11.18034 -15.0 -6.708204]
# Works fine with `Matrix{Float32}`
julia> exp(F)
3×3 Array{Float32,2}:
0.613059 0.345864 0.053439
-0.597466 -0.188525 -0.0126152
0.141042 -0.408237 -0.1039
julia> F_static = SMatrix{3, 3, Float32}(F);
# Breaks for `SMatrix{3, 3, Float32}`
julia> exp(F_static)
3×3 SArray{Tuple{3,3},Float32,2,9} with indices SOneTo(3)×SOneTo(3):
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
Note that this matrix is a little weird (might be defective, I'm not actually sure).
It still happens if you pick a matrix that is diagonalisable:
julia> A = SMatrix{3, 3, Float32}(randn(3, 3));
julia> exp(A)
3×3 SArray{Tuple{3,3},Float32,2,9} with indices SOneTo(3)×SOneTo(3):
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
Same thing if the matrix in question is symmetric.
Tested on version 0.12.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MWE at the exp(::SMatrix{3, 3, Float32}) entry point, comparing it with exp on the equivalent Matrix{Float32}. Check the Float32 SMatrix path using the provided defective, random, and symmetric examples. Done means these cases produce finite results consistent with the corresponding matrix computation rather than NaN values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100