diff --git a/base/array.jl b/base/array.jl index 213698c754bb33..93335153954f66 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1930,6 +1930,9 @@ function hcat(V::Vector{T}...) where T end return [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ] end +hcat(A::Union{Number,Vector,Matrix}...) = cat(A...; dims=Val(2)) # more special than LinAlg/special.jl +hcat(A::VecOrMat{T}...) where {T} = typed_hcat(T, A...) # more special than LinAlg/special.jl +hcat(A::Vector...) = cat(A...; dims=Val(2)) # more special than SparseArrays's vcat function vcat(arrays::Vector{T}...) where T n = 0 @@ -1946,6 +1949,13 @@ function vcat(arrays::Vector{T}...) where T end return arr end +vcat(A::Vector...) = cat(A...; dims=Val(1)) # more special than SparseArrays's vcat +vcat(A::Union{Number,Vector,Matrix}...) = cat(A...; dims=Val(1)) # more special than LinAlg/special.jl +vcat(A::VecOrMat{T}...) where {T} = typed_vcat(T, A...) # more special than LinAlg/special.jl + +# disambiguation with LinAlg/special.jl +hvcat(rows::Tuple{Vararg{Int}}, xs::Union{Number,Vector,Matrix}...) = typed_hvcat(promote_eltypeof(xs...), rows, xs...) +hvcat(rows::Tuple{Vararg{Int}}, xs::VecOrMat{T}...) where {T} = typed_hvcat(T, rows, xs...) _cat(n::Integer, x::Integer...) = reshape([x...], (ntuple(Returns(1), n-1)..., length(x))) diff --git a/stdlib/LinearAlgebra/src/special.jl b/stdlib/LinearAlgebra/src/special.jl index 19b1057f9d6b84..06227c782002a9 100644 --- a/stdlib/LinearAlgebra/src/special.jl +++ b/stdlib/LinearAlgebra/src/special.jl @@ -335,9 +335,7 @@ const _TypedDenseConcatGroup{T} = Union{Vector{T}, Adjoint{T,Vector{T}}, Transpo promote_to_array_type(::Tuple{Vararg{Union{_DenseConcatGroup,UniformScaling}}}) = Matrix Base._cat(dims, xs::_DenseConcatGroup...) = Base._cat_t(dims, promote_eltype(xs...), xs...) -vcat(A::Vector...) = Base.typed_vcat(promote_eltype(A...), A...) vcat(A::_DenseConcatGroup...) = Base.typed_vcat(promote_eltype(A...), A...) -hcat(A::Vector...) = Base.typed_hcat(promote_eltype(A...), A...) hcat(A::_DenseConcatGroup...) = Base.typed_hcat(promote_eltype(A...), A...) hvcat(rows::Tuple{Vararg{Int}}, xs::_DenseConcatGroup...) = Base.typed_hvcat(promote_eltype(xs...), rows, xs...) # For performance, specially handle the case where the matrices/vectors have homogeneous eltype