At the risk of asking the obvious: is reinterpret
what you’re looking for?
Array of deserialized data:
julia> d = [(data = (var"1" = -0.04, var"2" = -0.04, var"3" = 0.0),)
(data = (var"1" = -0.04, var"2" = -0.02, var"3" = 0.0),)
(data = (var"1" = -0.02, var"2" = -0.04, var"3" = 0.0),)
(data = (var"1" = -0.02, var"2" = -0.02, var"3" = 0.0),)]
4-element Vector{@NamedTuple{data::@NamedTuple{1::Float64, 2::Float64, 3::Float64}}}:
(data = (var"1" = -0.04, var"2" = -0.04, var"3" = 0.0),)
(data = (var"1" = -0.04, var"2" = -0.02, var"3" = 0.0),)
(data = (var"1" = -0.02, var"2" = -0.04, var"3" = 0.0),)
(data = (var"1" = -0.02, var"2" = -0.02, var"3" = 0.0),)
Reinterpreted as an array of SVector{3, Float64}
:
julia> using StaticArrays
julia> reinterpret(SVector{3, Float64}, d)
4-element reinterpret(SVector{3, Float64}, ::Vector{@NamedTuple{data::@NamedTuple{1::Float64, 2::Float64, 3::Float64}}}):
[-0.04, -0.04, 0.0]
[-0.04, -0.02, 0.0]
[-0.02, -0.04, 0.0]
[-0.02, -0.02, 0.0]
Reinterpreted as a 3xN array of Float64
:
julia> reinterpret(reshape, Float64, d)
3×4 reinterpret(reshape, Float64, ::Vector{@NamedTuple{data::@NamedTuple{1::Float64, 2::Float64, 3::Float64}}}) with eltype Float64:
-0.04 -0.04 -0.02 -0.02
-0.04 -0.02 -0.04 -0.02
0.0 0.0 0.0 0.0