Skip to content

Commit

Permalink
Merge pull request #15251 from martinholters/sparsesqueeze
Browse files Browse the repository at this point in the history
squeeze for sparse matrices
  • Loading branch information
tkelman committed Feb 26, 2016
2 parents 026fa10 + 7c54abd commit 009cede
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 0 additions & 2 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2910,8 +2910,6 @@ function blkdiag(X::SparseMatrixCSC...)
SparseMatrixCSC(m, n, colptr, rowval, nzval)
end

squeeze(S::SparseMatrixCSC, dims::Dims) = throw(ArgumentError("squeeze is not available for sparse matrices"))

## Structure query functions
issym(A::SparseMatrixCSC) = is_hermsym(A, IdFun())

Expand Down
12 changes: 12 additions & 0 deletions test/sparsedir/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ a116[p, p] = reshape(1:9, 3, 3)
s116[p, p] = reshape(1:9, 3, 3)
@test a116 == s116

# squeeze
for i = 1:5
am = sprand(20, 1, 0.2)
av = squeeze(am, 2)
@test ndims(av) == 1
@test all(av.==am)
am = sprand(1, 20, 0.2)
av = squeeze(am, 1)
@test ndims(av) == 1
@test all(av.'.==am)
end

# matrix-vector multiplication (non-square)
for i = 1:5
a = sprand(10, 5, 0.5)
Expand Down

0 comments on commit 009cede

Please sign in to comment.