Skip to content

Commit 6f08d24

Browse files
rfourquetthofma
authored andcommitted
remove vcat(A::Vector{<: MatrixElem}) (#409)
1 parent 7bec6c0 commit 6f08d24

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/generic/Matrix.jl

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,14 +4765,10 @@ function vcat(a::AbstractAlgebra.MatElem, b::AbstractAlgebra.MatElem)
47654765
end
47664766

47674767
@doc Markdown.doc"""
4768-
vcat(A::Vector{<: MatrixElem}) -> MatrixElem
4769-
> Return the horizontal concatenation of the matrices in $A$.
4768+
vcat(A::MatrixElem...) -> MatrixElem
4769+
> Return the horizontal concatenation of the matrices $A$.
47704770
> All component matrices need to have the same base ring and number of columns.
47714771
"""
4772-
function vcat(A::Vector{<: MatrixElem})
4773-
return _vcat(A)
4774-
end
4775-
47764772
function Base.vcat(A::MatrixElem...)
47774773
return _vcat(A)
47784774
end
@@ -4785,7 +4781,7 @@ function _vcat(A)
47854781
if any(x -> ncols(x) != ncols(A[1]), A)
47864782
error("Matrices must have the same number of columns")
47874783
end
4788-
4784+
47894785
if any(x -> base_ring(x) != base_ring(A[1]), A)
47904786
error("Matrices must have the same base ring")
47914787
end
@@ -4804,23 +4800,23 @@ function _vcat(A)
48044800
end
48054801

48064802
@doc Markdown.doc"""
4807-
hcat(A::Vector{<: MatrixElem}) -> MatrixElem
4808-
> Return the horizontal concatenating of the matrices in $A$.
4803+
hcat(A::MatrixElem...) -> MatrixElem
4804+
> Return the horizontal concatenating of the matrices $A$.
48094805
> All component matrices need to have the same base ring and number of rows.
48104806
"""
4811-
function hcat(A::Vector{<: MatrixElem})
4807+
function Base.hcat(A::MatrixElem...)
48124808
return _hcat(A)
48134809
end
48144810

48154811
function _hcat(A)
48164812
if length(A) == 0
48174813
error("Number of matrices to concatenate must be positive")
48184814
end
4819-
4815+
48204816
if any(x -> nrows(x) != nrows(A[1]), A)
48214817
error("Matrices must have the same number of rows")
48224818
end
4823-
4819+
48244820
if any(x -> base_ring(x) != base_ring(A[1]), A)
48254821
error("Matrices must have the same base ring")
48264822
end
@@ -4838,14 +4834,10 @@ function _hcat(A)
48384834
return M
48394835
end
48404836

4841-
function Base.hcat(A::MatrixElem...)
4842-
return _hcat(A)
4843-
end
4844-
4845-
function Base.cat(A::MatrixElem...;dims)
4837+
function Base.cat(A::MatrixElem...;dims)
48464838
@assert dims == (1,2) || isa(dims, Int)
48474839

4848-
if isa(dims, Int)
4840+
if isa(dims, Int)
48494841
if dims == 1
48504842
return hcat(A...)
48514843
elseif dims == 2

test/generic/Matrix-test.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,11 @@ function test_gen_mat_concat()
16511651
0 1 0;
16521652
0 1 2;])
16531653
@test hcat(B, C) == [B C]
1654-
@test hcat([B, C]) == [B C]
1654+
let BC = hcat([B, C])
1655+
@test size(BC) == (2, 1)
1656+
@test BC[1] == B
1657+
@test BC[2] == C
1658+
end
16551659

16561660
@test vcat(A, B) == matrix(R, [1 2;
16571661
3 4;
@@ -1661,7 +1665,12 @@ function test_gen_mat_concat()
16611665
0 1;])
16621666

16631667
@test vcat(A, B) == [A; B]
1664-
@test vcat(A, B) == vcat([A, B])
1668+
let AB = vcat([A, B])
1669+
@test size(AB) == (2,)
1670+
@test AB[1] == A
1671+
@test AB[2] == B
1672+
end
1673+
16651674

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

0 commit comments

Comments
 (0)