From fa225fd37c3972c98bf8bb97bb328595dc669d22 Mon Sep 17 00:00:00 2001 From: John Long Date: Fri, 13 Jan 2023 10:53:31 -0500 Subject: [PATCH 1/2] added unit tests for \beta = 0 and \beta = 1 --- test/mul!.jl | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/mul!.jl b/test/mul!.jl index b29129a..c56f28e 100644 --- a/test/mul!.jl +++ b/test/mul!.jl @@ -177,4 +177,40 @@ end end -end \ No newline at end of file +end + +# When β = 0, `mul!` just fills the given output vector with zeros before adding the solution to it +# when β = 1, the contents of the output vector are not touched (skip multiplying by β altogether) before +# adding the solution to it +@testset "β special cases" begin + + @testset "β = 0" begin + A = transpose(sparse(zeros(10,10))) + B = rand(10) + + α = 1.29 + + C = rand(10) + C_copy = deepcopy(C) + β = 0 + + ParallelMergeCSR.mul!(C, A, B, α, β) + SparseArrays.mul!(C_copy, A, B, α, β) + @test C == C_copy + end + + @testset "β = 1" begin + A = transpose(sparse(zeros(10,10))) + B = rand(1:20, size(A, 2)) + + α = 6.2 + + C = rand(1:20, size(A, 2)) + C_copy = deepcopy(C) + β = 1 + + ParallelMergeCSR.mul!(C, A, B, α, β) + SparseArrays.mul!(C_copy, A, B, α, β) + @test C == C_copy + end +begin \ No newline at end of file From 41e7baff6650c4e3d5a2727aceada659b01cad61 Mon Sep 17 00:00:00 2001 From: John Long Date: Fri, 13 Jan 2023 10:56:51 -0500 Subject: [PATCH 2/2] Fix spacing --- test/mul!.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/mul!.jl b/test/mul!.jl index c56f28e..2537300 100644 --- a/test/mul!.jl +++ b/test/mul!.jl @@ -213,4 +213,5 @@ end SparseArrays.mul!(C_copy, A, B, α, β) @test C == C_copy end -begin \ No newline at end of file + +end \ No newline at end of file