Holding columns in separate entries is a great way. However, if you need to do
linear algebra on the matrix at intermediate stages during its growth, then
you'll have a lot of needless copying occurring while you convert the column-
storage into a matrix.
In such circumstances, there's a sneaky workaround:
reshape1(a::Vector, dims::Dims) = pointer_to_array(pointer(a), dims)
a = zeros(3)
c = ones(3)
append!(a, c)
A = reshape1(a, (3, div(length(a),3)))
c += 1
append!(a, c)
A = reshape1(a, (3, div(length(a),3)))
Using pointer_to_array circumvents the ordinary protections built into resize!
There's still allocation occurring (it has to build a new Array "wrapper" on
each iteration), but it avoids copying any data, and for large amounts of data
this is a big win.
Even better would be to generalize resize! to support the final dimension of
any array. I seem to remember Stefan had a reason why this might be
problematic, but I confess I forget what it is.
--Tim