Skip to content

Commit

Permalink
Add support for BitVector and BitArray in operate
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Oct 11, 2023
1 parent 37bb9bf commit 1c70967
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/implementations/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ end

similar_array_type(::Type{Array{T,N}}, ::Type{S}) where {S,T,N} = Array{S,N}

similar_array_type(::Type{BitArray{N}}, ::Type{S}) where {S,N} = Array{S,N}

function promote_operation(
op::typeof(*),
A::Type{<:AbstractArray{T}},
Expand Down
13 changes: 13 additions & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,16 @@ end
end
end
end

@testset "add_mul for BitArray" begin
x = BigInt[0, 0]
MA.operate!!(MA.add_mul, x, big(2), trues(2))
@test x == BigInt[2, 2]
MA.operate!!(MA.add_mul, x, big(3), BitVector([true, false]))
@test x == BigInt[5, 2]
x = BigInt[0 0; 0 0]
MA.operate!!(MA.add_mul, x, big(2), trues(2, 2))
@test x == BigInt[2 2; 2 2]
MA.operate!!(MA.add_mul, x, big(3), BitArray([true false; true true]))
@test x == BigInt[5 2; 5 5]
end

0 comments on commit 1c70967

Please sign in to comment.