Is it correct to say that a reinterpreted array belongs to the same place in the type hierarchy of the original array?
Meaning:
julia> x = rand(3,3)
3×3 Matrix{Float64}:
0.147486 0.663168 0.631236
0.133914 0.63211 0.162756
0.20874 0.726117 0.959137
julia> y = reinterpret(SVector{3,Float64},x);
julia> y isa AbstractMatrix
true
julia> y isa AbstractVector
false
julia> x = rand(9)
9-element Vector{Float64}:
0.44525765951197704
0.9449254480621896
0.0295372702108041
0.6995113601801652
0.2283303239869987
0.13192687662938263
0.3828075496261596
0.5295738484396664
0.919470209658066
julia> y = reinterpret(SVector{3,Float64},x);
julia> y isa AbstractVector
true
Or, if I may ask something more specific: how is the recommended way to make a function that is typed to receive AbstractVector{<:AbstractVector}
to work also on matrices? That is:
julia> f(x::AbstractVector{<:AbstractVector}) = "this is a vector of vectors"
f (generic function with 1 method)
julia> x = rand(3,3)
3×3 Matrix{Float64}:
0.752403 0.068355 0.318391
0.966343 0.7082 0.870195
0.57566 0.995996 0.374196
julia> y = reinterpret(reshape, SVector{3,Float64}, x);
julia> f(y)
"this is a vector of vectors"
julia> y = vec(reinterpret(SVector{3,Float64}, x));
julia> f(y)
"this is a vector of vectors"
Both options above work. Is there any preferred, or recommended way?