diff --git a/src/implementations/LinearAlgebra.jl b/src/implementations/LinearAlgebra.jl index 00b301f3..3553c662 100644 --- a/src/implementations/LinearAlgebra.jl +++ b/src/implementations/LinearAlgebra.jl @@ -157,6 +157,9 @@ 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} +similar_array_type(::Type{BitArray{N}}, ::Type{Bool}) where {N} = BitArray{N} + function promote_operation( op::typeof(*), A::Type{<:AbstractArray{T}}, diff --git a/test/interface.jl b/test/interface.jl index 787ca4ae..bfbfc8e9 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -108,3 +108,21 @@ 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 + +@testset "similar_array_type" begin + @test MA.similar_array_type(BitArray{2}, Int) == Array{Int,2} + @test MA.similar_array_type(BitArray{2}, Bool) == BitArray{2} +end