Skip to content

Commit

Permalink
Fix bug in matrix add_mul (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 2, 2020
1 parent 7057356 commit 464faa0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 464faa0

Please sign in to comment.