Hi,
Say I create a multidimensional array "a" and I have defined the type
immutable Dual{T1,T2} # immutable: fields are read only, except by constructor
x ::T1 # think of this as a Float for this discussion
dx::T2 # Vector{Float}
end
(yes, I am playing with automatic differentiation) Then I want to do the
following allocation:
b = Array(Dual{Float64, Array{Float64,ndims(a)}} ,size(a)...)
So I want an array of "structures", each having as field a Float, and an Array.
This would be accessed as b[i].x and b[i].dx[j]
Now my intention is that all these dx array *have the same size*, which opens
for packed storage, without any use of pointers by the compiler. This, I
understand is what "immutable" is for, and is exploited, implicitly, in
Complex.jl. However, in my declaration above, I do not spec the size of the
dx's, and sothis will compile, I believe, into an array of x's and pointer to
dx's, and I expect suboptimal performance.
1. Am I right that this would compile into an array of pointers?
2. If yes, am I right that this would cause poor performance? (think of
Complex,jl, you really want things to go fast, there)
3. If yes, is there a way to allocate b that ensures "packed storage"?
Thank you beforehand for your answer, but most of all, thank you for Julia!
Philippe