Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve throws on small SMatrix with Measurements.jl entries #939

Closed
mapclyps opened this issue Jul 22, 2021 · 2 comments · Fixed by #1196
Closed

solve throws on small SMatrix with Measurements.jl entries #939

mapclyps opened this issue Jul 22, 2021 · 2 comments · Fixed by #1196

Comments

@mapclyps
Copy link

I was using using backslash on some SMatrices with Measurements.jl entries and when I used smaller matrices with sizes 2x2 and 3x3 it started to throw an error.

Measurements v2.6.0
StaticArrays v1.2.7

MWE

julia> using Measurements

julia> using StaticArrays

julia> n=5;a=SMatrix{n,n}(rand(n,n)0.1);

julia> a\a; #works

julia> n=3;a=SMatrix{n,n}(rand(n,n)0.1);

julia> a\a
ERROR: setindex!() with non-isbitstype eltype is not supported by StaticArrays. Consider using SizedArray.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] setindex!
    @ ~/.julia/packages/StaticArrays/AHT47/src/MArray.jl:99 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:66 [inlined]
  [4] _setindex!_scalar
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:46 [inlined]
  [5] setindex!
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:42 [inlined]
  [6] macro expansion
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:357 [inlined]
  [7] _setindex!
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:320 [inlined]
  [8] setindex!
    @ ~/.julia/packages/StaticArrays/AHT47/src/indexing.jl:274 [inlined]
  [9] _solve
    @ ~/.julia/packages/StaticArrays/AHT47/src/solve.jl:36 [inlined]
 [10] \(a::SMatrix{3, 3, Measurement{Float64}, 9}, b::SMatrix{3, 3, Measurement{Float64}, 9})
    @ StaticArrays ~/.julia/packages/StaticArrays/AHT47/src/solve.jl:1
 [11] top-level scope
    @ REPL[6]:1
    ```
@mateuszbaran
Copy link
Collaborator

It looks like MArray doesn't work well with non-isbits types, and actually the implementation of \ for 3x3 matrices makes a temporary MArray. I think similar should return SizedArray instead for non-isbits SArray.

@mapclyps
Copy link
Author

This was also discussed in #799 and then later fixed in #1196. It works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants