@@ -643,6 +643,26 @@ function reverse!(v::AbstractVector, s=1, n=length(v))
643
643
return v
644
644
end
645
645
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
646
666
function vcat {T} (arrays:: Vector{T} ...)
647
667
n = 0
648
668
for a in arrays
@@ -670,39 +690,6 @@ function vcat{T}(arrays::Vector{T}...)
670
690
return arr
671
691
end
672
692
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... )
706
693
707
694
# # find ##
708
695
0 commit comments