If they’re the same lengths, you could do vcat-then-reshape to get the same 
result as for hcat, but without splatting :)

reshape(fast_vcat(arr_of_arrs), length(arr_of_arrs[1]), length(arr_of_arrs))

// T

On Monday, November 30, 2015 at 3:42:35 PM UTC+1, Cedric St-Jean wrote:

Oh, right, the input vectors are all the same size. It's for a machine 
> learning training set.
>
> I've yet to hit the `hcat(v...)` limit in this particular case. I was just 
> curious to see what the alternatives were, since it seems to be common 
> wisdom that splatting arbitrarily-sized vectors is bad. Thank you for the 
> answers everyone.
>
> Cédric
>
> On Monday, November 30, 2015 at 1:32:42 AM UTC-5, Tomas Lycken wrote:
>>
>> For hcat, what shape would you want the output to have?
>>
>> With your example input, the result of vcat is straightforward:
>>
>> v = [[1],[2,3],[4,5]]
>> vcat(v...)
>> # -> [1, 2, 3, 4, 5]
>>
>> But for hcat, what output would you want? hcat(v...) throws a 
>> DimensionMismatch error stating that vectors must have the same length.
>> //T
>>
>> On Friday, November 27, 2015 at 1:39:34 PM UTC+1, Cedric St-Jean wrote:
>>
>> foldl would work, but it's going to create a ton of temporary arrays.
>>>
>>> None of the proposed efficient solutions work with hcat... I suppose if 
>>> splatting is a problem I should allocate and fill in the array myself.
>>>
>>> On Friday, November 27, 2015 at 6:39:07 AM UTC-5, Glen O wrote:
>>>>
>>>> Any chance that foldl(vcat,arr_of_arr) will do the job?
>>>>
>>>> On Sunday, 22 November 2015 23:04:26 UTC+10, Cedric St-Jean wrote:
>>>>>
>>>>> I have a big vector of vectors. Is there any way to vcat/hcat them 
>>>>> without splatting?
>>>>>
>>>>> arr_of_arr = Vector[[1],[2,3],[4,5]]
>>>>> vcat(arr_of_arr...)
>>>>>
>>>>> I'm asking because splatting big arrays is a performance issue (and 
>>>>> IIRC it blows the stack at some point).
>>>>>
>>>> ​
>>
> ​

Reply via email to