I don’t understand why I can’t reinterpret a 3D array of float as an array of static matrices. i’m trying to do this:
A = rand(2,3,5)
# can do
julia> reinterpret(SVector{3,Float64},A[1,:,:],(5,))
5-element Array{SVector{3,Float64},1}:
[0.23546, 0.907289, 0.740175]
[0.61008, 0.734986, 0.629369]
[0.996311, 0.0236219, 0.452736]
[0.926702, 0.754213, 0.0497403]
[0.00632655, 0.469851, 0.832494]
# but not
julia> reinterpret(SMatrix{2,3,Float64},A,(5,))
ERROR: ArgumentError: cannot reinterpret Array{Float64} to ::Type{Array{SMatrix{2,3,Float64}}}, type SMatrix{2,3,Float64} is not a bits type
I don’t understand. I want a 5-element Array{SMatrix{2,3,Float64},1}
, analog to the first example. I’m coming from FixedSizeArrays
(julia v0.5) where this work like
# julia v0.5
julia> using FixedSizeArrays
julia> reinterpret(Mat{2,3,Float64},A,(5,))
5-element Array{FixedSizeArrays.Mat{2,3,Float64},1}:
FixedSizeArrays.Mat{2,3,Float64}(
0.5574181712074888 0.9644487115785165 0.6704697319255919
0.9975096208909706 0.2222225851632973 0.14946990105711122
)
FixedSizeArrays.Mat{2,3,Float64}(
0.28001812808230175 0.44931736683789114 0.322378156341002
0.46665857950152345 0.14451919484905318 0.22147629055395557
)
FixedSizeArrays.Mat{2,3,Float64}(
0.0002579687549821852 0.8900462296197154 0.5851686490075749
0.6029813419932457 0.7732024531312345 0.12115694131802379
)
FixedSizeArrays.Mat{2,3,Float64}(
0.41651532906948185 0.44625111837501996 0.09088448384005732
0.8730213366071933 0.7085121876088183 0.2729717970821717
)
FixedSizeArrays.Mat{2,3,Float64}(
0.3853576197872626 0.13637018253558097 0.04404747821364219
0.9183888520473955 0.6311436084278026 0.9758791739746058
)