-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Here matrix-matrix-scalar multiplication seems to make incorrect assumptions about what number type scalar multiplication will return:
julia> import Unitful
julia> a = 2.0Unitful.cm
2.0 cm
julia> b = 0.1Unitful.cm
0.1 cm
julia> a * [a b; -b a] * [a b; -b a] # avoids the fast path, as Number not assumed to commute
2×2 Matrix{Unitful.Quantity{Float64, 𝐋³, Unitful.FreeUnits{(cm³,), 𝐋³, nothing}}}:
7.98 cm³ 0.8 cm³
-0.8 cm³ 7.98 cm³
julia> [a b; -b a] * [a b; -b a] * a # uses fast path mat_mat_scalar
ERROR: DimensionError: 8.0 cm³ and 0.0 cm are not dimensionally compatible.
Stacktrace:
[1] _muladd
@ ~/.julia/packages/Unitful/nwwOk/src/quantities.jl:197 [inlined]
[2] muladd
@ ~/.julia/packages/Unitful/nwwOk/src/quantities.jl:192 [inlined]
[3] macro expansion
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:897 [inlined]
[4] macro expansion
@ ./simdloop.jl:77 [inlined]
[5] _generic_matmatmul!(C::Matrix{…}, A::Matrix{…}, B::Matrix{…}, _add::LinearAlgebra.MulAddMul{…})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:896
[6] generic_matmatmul!
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:868 [inlined]
[7] _mul!
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:287 [inlined]
[8] mul!
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:285 [inlined]
[9] _mat_mat_scalar
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:1167 [inlined]
[10] mat_mat_scalar
@ ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:1161 [inlined]
[11] *(A::Matrix{Unitful.Quantity{…}}, B::Matrix{Unitful.Quantity{…}}, γ::Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{…}})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:1122
[12] top-level scope
@ REPL[419]:1
Some type information was truncated. Use `show(err)` to see complete types.
Metadata
Metadata
Assignees
Labels
No labels