Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 23, 2019
1 parent 9bc143f commit a072d8c
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -251,7 +251,7 @@ function operate(::typeof(*), x::LinearAlgebra.Transpose{<:Any, <:AbstractVector
throw(DimensionMismatch("first array has length $(lx) which does not match the length of the second, $(length(y))."))
end
if iszero(lx)
return promote_operation(add_mul, eltype(x), eltype(y))
return zero(promote_operation(add_mul, eltype(x), eltype(y)))
end

# We need a buffer to hold the intermediate multiplication.
Expand Down
11 changes: 11 additions & 0 deletions test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ end
B = zeros(2, 2)
err = DimensionMismatch("Cannot sum matrices of size `(1, 1)` and size `(2, 2)`, the size of the two matrices must be equal.")
@test_throws err MA.@rewrite A + B
x = ones(1)
y = ones(2)
err = DimensionMismatch("first array has length 1 which does not match the length of the second, 2.")
@test_throws err MA.operate(*, x', y)
@test_throws err MA.operate(*, LinearAlgebra.transpose(x), y)
err = DimensionMismatch("matrix A has dimensions (2,2), vector B has length 1")
@test_throws err MA.operate(*, x', B)
a = zeros(0)
@test iszero(@inferred MA.operate(LinearAlgebra.dot, a, a))
@test iszero(@inferred MA.operate(*, a', a))
@test iszero(@inferred MA.operate(*, LinearAlgebra.transpose(a), a))
end
end

Expand Down

0 comments on commit a072d8c

Please sign in to comment.