hvcat

hvcat(rows::Tuple{Vararg{Int}}, values...)

Horizontal and vertical concatenation in one call. This function is called for block matrix syntax. The first argument specifies the number of arguments to concatenate in each block row.

julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1,2,3,4,5,6)

julia> [a b c; d e f]
2x3 Array{Int64,2}:
 1  2  3
 4  5  6

julia> hvcat((3,3), a,b,c,d,e,f)
2x3 Array{Int64,2}:
 1  2  3
 4  5  6

julia> [a b;c d; e f]
3x2 Array{Int64,2}:
 1  2
 3  4
 5  6

julia> hvcat((2,2,2), a,b,c,d,e,f)
3x2 Array{Int64,2}:
 1  2
 3  4
 5  6

If the first argument is a single integer n, then all block rows are assumed to have n block columns.

Examples

julia> foo = Array(Int8,2,2)
2x2 Array{Int8,2}:
 -4     -1
 -1     -1
julia> bar = Array(Int8,2,2)
2x2 Array{Int8,2}:
 -8     124
 -117   8
julia> baz = Array(Int8,2,4)
2x4 Array{Int8,2}:
 0  0   0   0
 0  0   0   0
julia> hvcat((2,1), foo, bar, baz)        # equivalent to [foo bar; baz]
4x4 Array{Int8,2}:
 -4     -1      -8      124 
 -1     -1    -117      8
 0      0       0       0
 0      0       0       0

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: