Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/generic/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4757,6 +4757,8 @@ function Base.vcat(A::MatrixElem...)
return _vcat(A)
end

Base.reduce(::typeof(vcat), A::AbstractVector{<:MatrixElem}) = _vcat(A)

function _vcat(A)
if length(A) == 0
error("Number of matrices to concatenate must be positive")
Expand Down Expand Up @@ -4792,6 +4794,8 @@ function Base.hcat(A::MatrixElem...)
return _hcat(A)
end

Base.reduce(::typeof(hcat), A::AbstractVector{<:MatrixElem}) = _hcat(A)

function _hcat(A)
if length(A) == 0
error("Number of matrices to concatenate must be positive")
Expand Down Expand Up @@ -5232,4 +5236,3 @@ function MatrixSpace(R::AbstractAlgebra.Ring, r::Int, c::Int, cached::Bool = tru
T = elem_type(R)
return MatSpace{T}(R, r, c, cached)
end

3 changes: 2 additions & 1 deletion test/generic/Matrix-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ end
0 1 0;
0 1 2;])
@test hcat(B, C) == [B C]
@test hcat(B, C, C, B) == reduce(hcat, [B, C, C, B])
let BC = hcat([B, C])
@test size(BC) == (2, 1)
@test BC[1] == B
Expand All @@ -1614,13 +1615,13 @@ end
0 1;])

@test vcat(A, B) == [A; B]
@test vcat(A, B, B, A) == reduce(vcat, [A, B, B, A])
let AB = vcat([A, B])
@test size(AB) == (2,)
@test AB[1] == A
@test AB[2] == B
end


@test [A D; B B C] == matrix(R, [1 2 1 2 3;
3 4 4 5 6;
1 2 1 2 0;
Expand Down