similar when called with a FieldVector should output an array type equal to the input type (with possibly different eltype if specified). However the current behavior does not do this. For immutableeltypes, it converts to an MVector:
julia> using StaticArrays
julia> mutable struct Quaternion{T <: Number} <: FieldVector{4, T}
q0::T
q1::T
q2::T
q3::T
end
julia> q = Quaternion(1,2,3,4)
4-element Quaternion{Int64} with indices SOneTo(4):
1
2
3
4
julia> similar(q) # This should be a `Quaternion{Int64}`
4-element MVector{4, Int64} with indices SOneTo(4):
4472459824
1
563205
1
And for mutableeltypes, a SizedVector:
julia> mutable struct MyNum{T} <: Number
num::T
end
julia> q = Quaternion{MyNum{Int64}}(MyNum(1),MyNum(2),MyNum(3),MyNum(4))
4-element Quaternion{MyNum{Int64}} with indices SOneTo(4):
MyNum{Int64}(1)
MyNum{Int64}(2)
MyNum{Int64}(3)
MyNum{Int64}(4)
julia> similar(q)
4-element SizedVector{4, MyNum{Int64}, Vector{MyNum{Int64}}} with indices SOneTo(4):
#undef
#undef
#undef
#undef
similar
when called with aFieldVector
should output an array type equal to the input type (with possibly differenteltype
if specified). However the current behavior does not do this. Forimmutable
eltype
s, it converts to anMVector
:And for
mutable
eltype
s, aSizedVector
: