I believe if all your type fields are concrete (which they are in the case
of Float64), the performance should be the same as using Vector{Float64}.
This is really nice since you get to use code that is much more
understandable like state.x instead of state[1] for no penalty.
And if your state vector happens to require different types, you would have
to switch to a Vector{Real} or Vector{Any} in the non-type case, which
would imply a substantial performance hit.
On Tuesday, March 3, 2015 at 10:00:21 AM UTC-5, Chris wrote:
>
> Hello,
>
> Most of my Julia code basically involves dynamics simulations, and thus
> state vectors. So far, I have simply been using ::Vector{Float64} as the
> type for my state vectors, but I have seen other Julia code that defines a
> composite type for this, something like:
>
> type StateVec
> x::Float64
> y::Float64
> z::Float64
> end
>
> My question is (hopefully) simple: what benefit, if any, does this give
> over simply using Vector{Float64}? If it is not quite obvious by now, I
> am a Matlab transplant, and this is one of those things I haven't quite
> been able to wrap my head around yet.
>
> Thanks,
> Chris
>