Skip to content

Commit 68e1dd4

Browse files
authored
Merge pull request #17089 from pkofod/densecat
Make concatenation of vectors of matrices return dense matrix.
2 parents f129484 + 2d23bac commit 68e1dd4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

base/array.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ hcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_hcat(T, A...)
731731
vcat(A::Union{Matrix, Vector}...) = typed_vcat(promote_eltype(A...), A...)
732732
vcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_vcat(T, A...)
733733

734+
hvcat(rows::Tuple{Vararg{Int}}, xs::Vector...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
735+
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Vector{T}...) = typed_hvcat(T, rows, xs...)
734736

735737
hvcat(rows::Tuple{Vararg{Int}}, xs::Matrix...) = typed_hvcat(promote_eltype(xs...), rows, xs...)
736738
hvcat{T}(rows::Tuple{Vararg{Int}}, xs::Matrix{T}...) = typed_hvcat(T, rows, xs...)

test/abstractarray.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,20 @@ A = TSlowNIndexes(rand(2,2))
612612
@test @inferred(indices(rand(3,2), 1)) == 1:3
613613
@test @inferred(indices(rand(3,2), 2)) == 1:2
614614
@test @inferred(indices(rand(3,2), 3)) == 1:1
615+
616+
#17088
617+
let
618+
n = 10
619+
M = rand(n, n)
620+
# vector of vectors
621+
v = [[M]; [M]] # using vcat
622+
@test size(v) == (2,)
623+
@test !issparse(v)
624+
# matrix of vectors
625+
m1 = [[M] [M]] # using hcat
626+
m2 = [[M] [M];] # using hvcat
627+
@test m1 == m2
628+
@test size(m1) == (1,2)
629+
@test !issparse(m1)
630+
@test !issparse(m2)
631+
end

0 commit comments

Comments
 (0)