Thanks for the pointer for reshape. Sorry that I failed to make my question clear enough. In fact, I wonder if there is a function which can _automatically_ recast a single-column Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple rows.
On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote: > > See reshape and vec. > > Best, > --Tim > > On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com <javascript:> > wrote: > > Here is rookie question, which I have tried to find a similar question > and > > answer in the history of this group, but failed. Please bear me. > > > > Since Julia distinguishes between Array{Float64,1} and Array{Float64,2}, > > even there is only one column in an Array{Float64,2}. Therefore, the > type > > of rand(5) and rand(5,1) are not same. > > > > julia> x = rand(5) > > 5-element Array{Float64,1}: > > 0.183247 > > 0.480208 > > 0.623144 > > 0.342792 > > 0.0400695 > > > > julia> y = rand(5, 1) > > 5x1 Array{Float64,2}: > > 0.553224 > > 0.0061835 > > 0.762059 > > 0.643796 > > 0.655135 > > > > > > Is there any way that I can upgrade x about to become an > Array{Float64,2}? > > And is there a way to downgrade y to become an Array{Float64,1}, when it > > has only one column? > > > > In case that there is a similar discussion before, a link to the > previous > > thread is good enough and appreciated! > > > > Thanks! > >