From 464faa083e5744cd9a92d89079226adad3ec16a4 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 3 Nov 2020 02:26:25 +1300 Subject: [PATCH] Fix bug in matrix add_mul (#55) --- src/linear_algebra.jl | 2 +- test/matmul.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/linear_algebra.jl b/src/linear_algebra.jl index f3a54e6..99ec584 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra.jl @@ -180,7 +180,7 @@ function _add_mul_array(C::Matrix, A::AbstractMatrix, B::AbstractMatrix) @inbounds begin for i = 1:size(A, 1), j = 1:size(B, 2) - Ctmp = zero!(C[i, j]) + Ctmp = C[i, j] for k = 1:size(A, 2) Ctmp = buffered_operate!(mul_buffer, add_mul, Ctmp, A[i, k], B[k, j]) end diff --git a/test/matmul.jl b/test/matmul.jl index 0b16ea6..bf69c73 100644 --- a/test/matmul.jl +++ b/test/matmul.jl @@ -147,3 +147,11 @@ end alloc_test(() -> MA.mutable_operate!(MA.add_mul, C, A, B), 48) end end + +@testset "matrix multiplication" begin + X = ones(BigInt, 1, 1) + M = ones(1, 1); + C = X * M + D = MA.operate!(MA.add_mul, C, X, M) + @test D == X * M + X * M +end