Created
June 2, 2016 13:31
-
-
Save pkofod/5536ae52c23db5f34ba35cedbf0b74e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Base.Test | |
Base.hcat(Xin::Union{SparseVector, SparseMatrixCSC}...) = hcat(map(SparseMatrixCSC, Xin)...) | |
Base.vcat(Xin::Union{SparseVector, SparseMatrixCSC}...) = vcat(map(SparseMatrixCSC, Xin)...) | |
Base.hcat(Xin::Union{Vector, AbstractSparseVector}...) = hcat(map(sparse, Xin)...) | |
Base.vcat(Xin::Union{Vector, AbstractSparseVector}...) = vcat(map(sparse, Xin)...) | |
function Base.hcat(Xin::Union{Matrix, Vector, SparseMatrixCSC}...) | |
X = SparseMatrixCSC[issparse(x) ? x : sparse(x) for x in Xin] | |
hcat(X...) | |
end | |
function Base.vcat(Xin::Union{Matrix, Vector, SparseMatrixCSC}...) | |
X = SparseMatrixCSC[issparse(x) ? x : sparse(x) for x in Xin] | |
vcat(X...) | |
end | |
Base.hcat(A::Union{Matrix, Vector}...) = Base.typed_hcat(Base.promote_eltype(A...), A...) | |
Base.vcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_vcat(T, A...) | |
Base.vcat(A::Union{Matrix, Vector}...) = Base.typed_vcat(Base.promote_eltype(A...), A...) | |
Base.hcat{T}(A::Union{Matrix{T}, Vector{T}}...) = typed_hcat(T, A...) | |
# Matrix vector cat not supported for sparse #13130 and #16661 | |
@test issparse([sprand(10,10,.1) sprand(10,.1)]) | |
@test issparse([sprand(10,1,.1); sprand(10,.1)]) | |
@test issparse([sprand(10,10,.1) rand(10)]) | |
@test issparse([sprand(10,1,.1) rand(10)]) | |
@test issparse([sprand(10,2,.1) sprand(10,1,.1) rand(10)]) | |
@test issparse([sprand(10,1,.1); rand(10)]) | |
@test issparse([sprand(10,.1) rand(10)]) | |
@test issparse([sprand(10,.1); rand(10)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm, it's the
SparseVector
, right? It's more specific, so it won't fall back to the abstractsparsevector method...