I do not understand the difference between :
# applying hcat to a vector
hcat( [hcat(Gray.(Float64.(rand(10)))) for _ in 1:10] )
and
# applying hcat to a list of arguments, using the splat operator
begin
vecs = [hcat(Gray.(Float64.(rand(10)))) for _ in 1:10]
hcat(vecs…)
end
Hcat takes its arguments and concatenates them horizontally. When you pass multiple vectors to hcat it will create a matrix with each vector as its columns. It does exactly this when you only pass a single vector, creating a Nx1 Matrix.
When you use the splat operator it separates the vector into its components and concatenates them creating I.e a row vector.
julia> hcat(rand(10))
10×1 Matrix{Float64}
julia> hcat(rand(10)...)
1×10 Matrix{Float64}
Since your vector is made of 10x1 matrices it creates a 10x10 matrix.
1 Like