Skip to content

Commit d6a9f43

Browse files
committed
Remove seemingly redundant dense array concatenation methods and clean up the associated code.
1 parent 0e9da4f commit d6a9f43

File tree

1 file changed

+20
-33
lines changed

1 file changed

+20
-33
lines changed

base/array.jl

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,26 @@ function reverse!(v::AbstractVector, s=1, n=length(v))
643643
return v
644644
end
645645

646+
647+
# concatenations of combinations (homogeneous, heterogeneous) of dense matrices/vectors #
648+
vcat{T}(A::Union{Vector{T},Matrix{T}}...) = typed_vcat(T, A...)
649+
vcat(A::Union{Vector,Matrix}...) = typed_vcat(promote_eltype(A...), A...)
650+
hcat{T}(A::Union{Vector{T},Matrix{T}}...) = typed_hcat(T, A...)
651+
hcat(A::Union{Vector,Matrix}...) = typed_hcat(promote_eltype(A...), A...)
652+
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Union{Vector{T},Matrix{T}}...) = typed_hvcat(T, rows, xs...)
653+
hvcat(rows::Tuple{Vararg{Int}}, xs::Union{Vector,Matrix}...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
654+
cat{T}(catdims, xs::Union{Vector{T},Matrix{T}}...) = Base.cat_t(catdims, T, xs...)
655+
cat(catdims, xs::Union{Vector,Matrix}...) = Base.cat_t(catdims, promote_eltype(xs...), xs...)
656+
# concatenations of homogeneous combinations of vectors, horizontal and vertical
657+
function hcat{T}(V::Vector{T}...)
658+
height = length(V[1])
659+
for j = 2:length(V)
660+
if length(V[j]) != height
661+
throw(DimensionMismatch("vectors must have same lengths"))
662+
end
663+
end
664+
return [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
665+
end
646666
function vcat{T}(arrays::Vector{T}...)
647667
n = 0
648668
for a in arrays
@@ -670,39 +690,6 @@ function vcat{T}(arrays::Vector{T}...)
670690
return arr
671691
end
672692

673-
function hcat{T}(V::Vector{T}...)
674-
height = length(V[1])
675-
for j = 2:length(V)
676-
if length(V[j]) != height
677-
throw(DimensionMismatch("vectors must have same lengths"))
678-
end
679-
end
680-
return [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
681-
end
682-
683-
hcat(A::Matrix...) = typed_hcat(promote_eltype(A...), A...)
684-
hcat{T}(A::Matrix{T}...) = typed_hcat(T, A...)
685-
686-
vcat(A::Matrix...) = typed_vcat(promote_eltype(A...), A...)
687-
vcat{T}(A::Matrix{T}...) = typed_vcat(T, A...)
688-
689-
hcat(A::Union{Matrix, Vector}...) = typed_hcat(promote_eltype(A...), A...)
690-
hcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_hcat(T, A...)
691-
692-
vcat(A::Union{Matrix, Vector}...) = typed_vcat(promote_eltype(A...), A...)
693-
vcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_vcat(T, A...)
694-
695-
hvcat(rows::Tuple{Vararg{Int}}, xs::Vector...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
696-
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Vector{T}...) = typed_hvcat(T, rows, xs...)
697-
698-
hvcat(rows::Tuple{Vararg{Int}}, xs::Matrix...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
699-
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Matrix{T}...) = typed_hvcat(T, rows, xs...)
700-
701-
hvcat(rows::Tuple{Vararg{Int}}, xs::Union{Vector,Matrix}...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
702-
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Union{Vector{T},Matrix{T}}...) = typed_hvcat(T, rows, xs...)
703-
704-
cat(catdims, xs::Union{Vector,Matrix}...) = Base.cat_t(catdims, promote_eltype(xs...), xs...)
705-
cat{T}(catdims, xs::Union{Vector{T},Matrix{T}}...) = Base.cat_t(catdims, T, xs...)
706693

707694
## find ##
708695

0 commit comments

Comments
 (0)