@@ -13,24 +13,41 @@ tc(r1,r2) = false
13
13
bitcheck (b:: BitArray ) = Base. _check_bitarray_consistency (b)
14
14
bitcheck (x) = true
15
15
16
- function check_bitop (ret_type, func, args... )
16
+ function check_bitop_call (ret_type, func, args... )
17
17
r1 = func (args... )
18
18
r2 = func (map (x-> (isa (x, BitArray) ? Array (x) : x), args)... )
19
+ check_bitop_tests (ret_type, r1, r2)
20
+ end
21
+ function check_bitop_dotcall (ret_type, func, args... )
22
+ r1 = func .(args... )
23
+ r2 = func .(map (x-> (isa (x, BitArray) ? Array (x) : x), args)... )
24
+ check_bitop_tests (ret_type, r1, r2)
25
+ end
26
+ function check_bitop_tests (ret_type, r1, r2)
19
27
ret_type ≢ nothing && ! isa (r1, ret_type) && @show ret_type, r1
20
28
ret_type ≢ nothing && @test isa (r1, ret_type)
21
29
@test tc (r1, r2)
22
30
@test isequal (r1, ret_type ≡ nothing ? r2 : convert (ret_type, r2))
23
31
@test bitcheck (r1)
24
32
end
25
-
26
33
macro check_bit_operation (ex, ret_type)
27
- @assert Meta. isexpr (ex, :call )
28
- Expr (:call , :check_bitop , esc (ret_type), map (esc,ex. args)... )
34
+ if Meta. isexpr (ex, :call )
35
+ Expr (:call , :check_bitop_call , esc (ret_type), map (esc, ex. args)... )
36
+ elseif Meta. isexpr (ex, :.)
37
+ Expr (:call , :check_bitop_dotcall , esc (ret_type), esc (ex. args[1 ]), map (esc, ex. args[2 ]. args)... )
38
+ else
39
+ throw (ArgumentError (" first argument to @check_bit_operation must be an expression with head either :call or :. !" ))
40
+ end
29
41
end
30
42
31
43
macro check_bit_operation (ex)
32
- @assert Meta. isexpr (ex, :call )
33
- Expr (:call , :check_bitop , nothing , map (esc,ex. args)... )
44
+ if Meta. isexpr (ex, :call )
45
+ Expr (:call , :check_bitop_call , nothing , map (esc, ex. args)... )
46
+ elseif Meta. isexpr (ex, :.)
47
+ Expr (:call , :check_bitop_dotcall , nothing , esc (ex. args[1 ]), map (esc, ex. args[2 ]. args)... )
48
+ else
49
+ throw (ArgumentError (" first argument to @check_bit_operation must be an expression with head either :call or :. !" ))
50
+ end
34
51
end
35
52
36
53
let t0 = time ()
@@ -793,11 +810,11 @@ let b1 = bitrand(n1, n2)
793
810
@check_bit_operation (/ )(b1,1 ) Matrix{Float64}
794
811
795
812
b2 = trues (n1, n2)
796
- @check_bit_operation div ( b1, b2) BitMatrix
813
+ @check_bit_operation broadcast (div, b1, b2) BitMatrix
797
814
@check_bit_operation mod (b1, b2) BitMatrix
798
- @check_bit_operation div ( b1,Array (b2)) BitMatrix
815
+ @check_bit_operation broadcast (div, b1, Array (b2)) BitMatrix
799
816
@check_bit_operation mod (b1,Array (b2)) BitMatrix
800
- @check_bit_operation div ( Array (b1),b2) BitMatrix
817
+ @check_bit_operation broadcast (div, Array (b1), b2) BitMatrix
801
818
@check_bit_operation mod (Array (b1),b2) BitMatrix
802
819
end
803
820
@@ -832,7 +849,7 @@ let b1 = bitrand(n1, n2)
832
849
@check_bit_operation broadcast (* , b1, i2) Matrix{Int}
833
850
@check_bit_operation broadcast (/ , b1, i2) Matrix{Float64}
834
851
@check_bit_operation broadcast (^ , b1, i2) BitMatrix
835
- @check_bit_operation div ( b1, i2) Matrix{Int}
852
+ @check_bit_operation broadcast (div, b1, i2) Matrix{Int}
836
853
@check_bit_operation mod (b1, i2) Matrix{Int}
837
854
end
838
855
@@ -843,7 +860,7 @@ let b1 = bitrand(n1, n2)
843
860
@check_bit_operation broadcast (* , b1, f2) Matrix{Float64}
844
861
@check_bit_operation broadcast (/ , b1, f2) Matrix{Float64}
845
862
@check_bit_operation broadcast (^ , b1, f2) Matrix{Float64}
846
- @check_bit_operation div ( b1, f2) Matrix{Float64}
863
+ @check_bit_operation broadcast (div, b1, f2) Matrix{Float64}
847
864
@check_bit_operation mod (b1, f2) Matrix{Float64}
848
865
end
849
866
@@ -882,22 +899,22 @@ let b2 = bitrand(n1, n2)
882
899
883
900
b2 = trues (n1, n2)
884
901
@check_bit_operation broadcast (/ , true , b2) Matrix{Float64}
885
- @check_bit_operation div ( true , b2) BitMatrix
902
+ @check_bit_operation broadcast (div, true , b2) BitMatrix
886
903
@check_bit_operation mod (true , b2) BitMatrix
887
904
@check_bit_operation broadcast (/ , false , b2) Matrix{Float64}
888
- @check_bit_operation div ( false , b2) BitMatrix
905
+ @check_bit_operation broadcast (div, false , b2) BitMatrix
889
906
@check_bit_operation mod (false , b2) BitMatrix
890
907
891
908
@check_bit_operation broadcast (/ , i1, b2) Matrix{Float64}
892
- @check_bit_operation div ( i1, b2) Matrix{Int}
909
+ @check_bit_operation broadcast (div, i1, b2) Matrix{Int}
893
910
@check_bit_operation mod (i1, b2) Matrix{Int}
894
911
895
912
@check_bit_operation broadcast (/ , u1, b2) Matrix{Float64}
896
- @check_bit_operation div ( u1, b2) Matrix{UInt8}
913
+ @check_bit_operation broadcast (div, u1, b2) Matrix{UInt8}
897
914
@check_bit_operation mod (u1, b2) Matrix{UInt8}
898
915
899
916
@check_bit_operation broadcast (/ , f1, b2) Matrix{Float64}
900
- @check_bit_operation div ( f1, b2) Matrix{Float64}
917
+ @check_bit_operation broadcast (div, f1, b2) Matrix{Float64}
901
918
@check_bit_operation mod (f1, b2) Matrix{Float64}
902
919
903
920
@check_bit_operation broadcast (/ , ci1, b2) Matrix{Complex128}
@@ -955,7 +972,7 @@ let b1 = bitrand(n1, n2)
955
972
@check_bit_operation broadcast (* , false , b1) BitMatrix
956
973
@check_bit_operation broadcast (/ , b1, true ) Matrix{Float64}
957
974
@check_bit_operation broadcast (/ , b1, false ) Matrix{Float64}
958
- @check_bit_operation div ( b1, true ) BitMatrix
975
+ @check_bit_operation broadcast (div, b1, true ) BitMatrix
959
976
@check_bit_operation mod (b1, true ) BitMatrix
960
977
961
978
@check_bit_operation (& )(b1, b2) BitMatrix
@@ -971,7 +988,7 @@ let b1 = bitrand(n1, n2)
971
988
@check_bit_operation broadcast (- , b1, i2) Matrix{Int}
972
989
@check_bit_operation broadcast (* , b1, i2) Matrix{Int}
973
990
@check_bit_operation broadcast (/ , b1, i2) Matrix{Float64}
974
- @check_bit_operation div ( b1, i2) Matrix{Int}
991
+ @check_bit_operation broadcast (div, b1, i2) Matrix{Int}
975
992
@check_bit_operation mod (b1, i2) Matrix{Int}
976
993
977
994
@check_bit_operation (& )(b1, u2) Matrix{UInt8}
@@ -981,14 +998,14 @@ let b1 = bitrand(n1, n2)
981
998
@check_bit_operation broadcast (- , b1, u2) Matrix{UInt8}
982
999
@check_bit_operation broadcast (* , b1, u2) Matrix{UInt8}
983
1000
@check_bit_operation broadcast (/ , b1, u2) Matrix{Float64}
984
- @check_bit_operation div ( b1, u2) Matrix{UInt8}
1001
+ @check_bit_operation broadcast (div, b1, u2) Matrix{UInt8}
985
1002
@check_bit_operation mod (b1, u2) Matrix{UInt8}
986
1003
987
1004
@check_bit_operation broadcast (+ , b1, f2) Matrix{Float64}
988
1005
@check_bit_operation broadcast (- , b1, f2) Matrix{Float64}
989
1006
@check_bit_operation broadcast (* , b1, f2) Matrix{Float64}
990
1007
@check_bit_operation broadcast (/ , b1, f2) Matrix{Float64}
991
- @check_bit_operation div ( b1, f2) Matrix{Float64}
1008
+ @check_bit_operation broadcast (div, b1, f2) Matrix{Float64}
992
1009
@check_bit_operation mod (b1, f2) Matrix{Float64}
993
1010
994
1011
@check_bit_operation broadcast (+ , b1, ci2) Matrix{Complex{Int}}
0 commit comments