diff --git a/test/runtests.jl b/test/runtests.jl index fce4aad..af3a211 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -46,9 +46,38 @@ using SafeTestsets, Test y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) y_dense = copy(y_butterfly) - @assert isapprox(x_butterfly * y_butterfly, x_dense * y_dense) + @test isapprox(x_butterfly * y_butterfly, x_dense * y_dense) end - + @safetestset "Division" begin + using SparseBandedMatrices, Random + dim = 5000 + x = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, x) + diag_locs = randperm(dim * 2 - 1)[1:x] + for j in 1:x + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + x_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + x_dense = copy(x_butterfly) + + y = rand(dim, dim) + z = zeros(dim, dim) + + @test isapprox(x_dense / y, x_butterfly / y) + @test isapprox(y / x_dense, y / x_butterfly) + y = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, y) + diag_locs = randperm(dim * 2 - 1)[1:y] + for j in 1:y + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + y_dense = copy(y_butterfly) + + @test isapprox(x_butterfly / y_butterfly, x_dense / y_dense) + end end \ No newline at end of file