# Type hierarchy of reinterpreted arrays

**URL:** <https://discourse.julialang.org/t/type-hierarchy-of-reinterpreted-arrays/68066>\
**Category:** General Usage\
**Created:** [September 12, 2021, 11:42pm UTC](https://discourse.julialang.org/t/type-hierarchy-of-reinterpreted-arrays/68066 "2021-09-12T23:42:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 12, 2021, 11:42pm UTC](https://discourse.julialang.org/t/type-hierarchy-of-reinterpreted-arrays/68066/1 "2021-09-12T23:42:22Z")

</div>

Is it correct to say that a reinterpreted array belongs to the same place in the type hierarchy of the original array?

Meaning:

```julia
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
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?
