Which way is BEST depends on the size of the array and if performance or 
maintainability/simplicity is most important. If performance is important 
you have to do testing on your specific use case to see which solution does 
the right trade of.

I think the most readable way is to collect the columns in an 
Array{Array{Float64,1},1} and then do hcat(a...) to get the array. Maybe we 
could define full{T<:Number}(a::Array{Array{T,1},1}) to julia Base to do 
that concatenation in a more efficient way. 

The best performance is to know or calculate the array size beforehand, and 
write all numbers directly into that. If the calculation of the number of 
columns is expensive you can append every column to the end of a 1d array, 
and then use reshape to get the right shape.

Ivar



kl. 02:45:15 UTC+1 lørdag 28. desember 2013 skrev Sheehan Olver følgende:
>
> What's the "best" way of constructing an array that can grow adaptively? 
>  For example, it has fixed m rows but the number of columns grows as an 
> algorithm proceeds.  Unfortunately,
>
> resize!
>
> doesn't work for 2d arrays.  It does work for Array{Array{Float64,1},1}, 
> but not sure that's optimal.
>
>
>
>
>
>

Reply via email to