Skip to content

Commit

Permalink
test cases and NEWS for #30372 (sparse matmul) (#30433)
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausC authored and ViralBShah committed Dec 20, 2018
1 parent 258e08a commit e7e33cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Standard library changes

* Added keyword arguments `rtol`, `atol` to `pinv` and `nullspace` ([#29998]).

#### SparseArrays

* performance improvements for sparse matrix-matrix multiplication ([#30372]).

#### Dates

* Fixed `repr` such that it displays `DateTime` as it would be entered in Julia ([#30200]).
Expand Down
22 changes: 16 additions & 6 deletions stdlib/SparseArrays/test/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,22 @@ end
end

@testset "matrix multiplication" begin
for i = 1:5
a = sprand(10, 5, 0.7)
b = sprand(5, 15, 0.3)
@test maximum(abs.(a*b - Array(a)*Array(b))) < 100*eps()
@test maximum(abs.(SparseArrays.spmatmul(a,b) - Array(a)*Array(b))) < 100*eps()
f = Diagonal(rand(5))
for (m, p, n, q, k) in (
(10, 0.7, 5, 0.3, 15),
(100, 0.01, 100, 0.01, 20),
(100, 0.1, 100, 0.2, 100),
)
a = sprand(m, n, p)
b = sprand(n, k, q)
as = sparse(a')
bs = sparse(b')
ab = a * b
aab = Array(a) * Array(b)
@test maximum(abs.(ab - aab)) < 100*eps()
@test a*bs' == ab
@test as'*b == ab
@test as'*bs' == ab
f = Diagonal(rand(n))
@test Array(a*f) == Array(a)*f
@test Array(f*b) == f*Array(b)
end
Expand Down

0 comments on commit e7e33cc

Please sign in to comment.