Skip to content

reinterpret of Arrays of static arrays failed #501

Closed
@Hong-Xiang

Description

@Hong-Xiang

reinterpret Arrays of static arrays failed.

steps to reproduce:

using StaticArrays
function svectors(x::Matrix{Float64})
    @assert size(x,1) == 3
    reinterpret(SVector{3,Float64}, x, (size(x,2),))
end
m = zeros(3, 10)
svectors(m)

outputs:

ERROR: MethodError: no method matching reinterpret(::Type{SArray{Tuple{3},Float64,1,3}}, ::Array{Float64,2}, ::Tuple{Int64})
Closest candidates are:
  reinterpret(::Type{T}, ::Base.ReshapedArray, ::Tuple{Vararg{Int64,N}} where N) where T at reshapedarray.jl:191
  reinterpret(::Type{T}, ::A<:AbstractArray{S,N}) where {T, N, S, A<:AbstractArray{S,N}} at reinterpretarray.jl:14
  reinterpret(::Type{T}, ::Any) where T at essentials.jl:370
  ...
Stacktrace:
 [1] svectors(::Array{Float64,2}) at ./REPL[2]:3
 [2] top-level scope at none:0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions