Hi, I'd like to create a matrix with an array comprehension. Specifically,
I have a function that returns a 2-length array, like
function f()
[3.0, 5.0]
end
And I'd like an Nx2 (or 2xN) matrix from its output. Unfortunately, an
obvious way of calling it results in:
[f() for i=1:3]
3-element Array{Array{Float64,1},1}:
[3.0,5.0]
[3.0,5.0]
[3.0,5.0]
Is there a general way to convert Array{Array{float, 1}, 1} into an
Array{float, 2} ? reshape() and convert() both don't seem to do it. I
guess hcat() (or vcat()) could do it if it was called with each element in
the original array as one of its arguments.
I read through the docs page but didn't see anything
obvious: http://docs.julialang.org/en/release-0.3/manual/arrays/
This is also no better:
[f()' for i=1:3]
3-element Array{Array{Float64,2},1}:
1x2 Array{Float64,2}:
3.0 5.0
1x2 Array{Float64,2}:
3.0 5.0
1x2 Array{Float64,2}:
3.0 5.0