StaticArrays.jl
StaticArrays.jl copied to clipboard
`*` and `UniformScaling`
I'm seeing some strange typing when multiplying StaticArrays and UniformScaling. Is all of this expected?
N = 2
typeof(rand(SMatrix{N,N}) * I) # SMatrix{N, N}
typeof(rand(SMatrix{N,N}) * I(N)) # Matrix
typeof(rand(SVector{N}) * I) # Matrix
typeof(I * rand(SVector{N})) # SVector{N}
typeof(rand(SVector{N}) * I(1)) # Matrix
typeof(I(N) * rand(SVector{N})) # SizedVector{N}
Should all these be outputs <: StaticArray?
If not, what is the rule for expected output type of these operations?
To me it looks like all of them should be static, so it's just a matter of adding more methods to *.
julia> I
UniformScaling{Bool}
true*I
julia> I*3
UniformScaling{Int64}
3*I
julia> I(3)
3×3 Diagonal{Bool, Vector{Bool}}:
1 ⋅ ⋅
⋅ 1 ⋅
⋅ ⋅ 1
Note that the I(N) case is not a UniformScaling example because it produces a Diagonal wrapping a Vector. But Diagonal matrices are all square so there's still room to improve the output type.