I would like to preallocate memory of an array of arrays and pass it to a function to be filled in. I have created an example below that illustrates my question(s).
Based on my (probably incorrect) understanding that it would be desirable to fix the type in my function, I would like to be able to pass my array of arrays, X, in a type stable way. However, I can't seem to pass Array{Array{Float64,N},1}. If, however, i do not attempt to impose the type on the function, it works. Is there a way to pass Array{Array{Float64,N},1 to my function? Do I even need to fix the type in the function to get good performance? # version of Julia: 0.4.0-rc3 @generated function testfun1!{N}(X::Array{Array{Float64,1},1},Y::NTuple{N,Float64}) quote for j in 1:$N, i in eachindex(X) X[i][j] = Y[j] end return X end end @generated function testfun2!{N}(X,Y::NTuple{N,Float64}) quote for j in 1:$N, i in eachindex(X) X[i][j] = Y[j] end return X end end # Setup for function call InnerArrayPts = 3 OuterArrayPts = 10 Xinput = [Array{Float64}(InnerArrayPts) for r in 1:OuterArrayPts] Yinput = rand(InnerArrayPts) # Method Error Problem testfun1!(Xinput,tuple(Yinput...)) # This works testfun2!(Xinput,tuple(Yinput...)) I also tried with the following version of testfun1!() and again got a method error. @generated function testfun1!{N}(X::Array{Array{Float64,N},1},Y::NTuple{N,Float64}) quote for j in 1:$N, i in eachindex(X) X[i][j] = Y[j] end return X end end I am sure i am misunderstanding something quite fundamental and/or missing something straightforward... Thanks, Alan