How to optimize struct for speed?

It is likely due to the missing type parameter of MVector. It actually has two type parameters: MVector{S, T}, where S is the size and T is the element type.

This should help:

struct Foo{N, T}
    dev::MVector{N, T}
    Foo(v::A) where A <: Union{Vector, SVector, MVector} = 
        new{length(v), eltype(A)}(MVector{length(v)}(v))
end
3 Likes