@@ -10,18 +10,30 @@ tc(r1,r2) = false
10
10
bitcheck (b:: BitArray ) = length (b. chunks) == 0 || (b. chunks[end ] == b. chunks[end ] & Base. _msk_end (b))
11
11
bitcheck (x) = true
12
12
13
- function check_bitop (ret_type, func, args... )
13
+ function check_bitop_call (ret_type, func, args... )
14
14
r1 = func (args... )
15
15
r2 = func (map (x-> (isa (x, BitArray) ? Array (x) : x), args)... )
16
+ check_bitop_tests (ret_type, r1, r2)
17
+ end
18
+ function check_bitop_dotcall (ret_type, func, args... )
19
+ r1 = func .(args... )
20
+ r2 = func .(map (x-> (isa (x, BitArray) ? Array (x) : x), args)... )
21
+ check_bitop_tests (ret_type, r1, r2)
22
+ end
23
+ function check_bitop_tests (ret_type, r1, r2)
16
24
@test isa (r1, ret_type)
17
25
@test tc (r1, r2)
18
26
@test isequal (r1, convert (ret_type, r2))
19
27
@test bitcheck (r1)
20
28
end
21
-
22
29
macro check_bit_operation (ex, ret_type)
23
- @assert Meta. isexpr (ex, :call )
24
- Expr (:call , :check_bitop , esc (ret_type), map (esc,ex. args)... )
30
+ if Meta. isexpr (ex, :call )
31
+ Expr (:call , :check_bitop_call , esc (ret_type), map (esc, ex. args)... )
32
+ elseif Meta. isexpr (ex, :.)
33
+ Expr (:call , :check_bitop_dotcall , esc (ret_type), esc (ex. args[1 ]), map (esc, ex. args[2 ]. args)... )
34
+ else
35
+ throw (ArgumentError (" first argument to @check_bit_operation must be an expression with head either :call or :. !" ))
36
+ end
25
37
end
26
38
27
39
let t0 = time ()
@@ -612,11 +624,11 @@ b2 = bitrand(n1, n2)
612
624
613
625
b2 = trues (n1, n2)
614
626
@check_bit_operation div (b1, b2) BitMatrix
615
- @check_bit_operation mod (b1, b2) BitMatrix
627
+ @check_bit_operation mod . (b1, b2) BitMatrix
616
628
@check_bit_operation div (b1,Array (b2)) BitMatrix
617
- @check_bit_operation mod (b1,Array (b2)) BitMatrix
629
+ @check_bit_operation mod . (b1,Array (b2)) BitMatrix
618
630
@check_bit_operation div (Array (b1),b2) BitMatrix
619
- @check_bit_operation mod (Array (b1),b2) BitMatrix
631
+ @check_bit_operation mod . (Array (b1),b2) BitMatrix
620
632
621
633
while true
622
634
global b1
@@ -650,7 +662,7 @@ i2 = rand(1:10, n1, n2)
650
662
@check_bit_operation (./ )(b1, i2) Matrix{Float64}
651
663
@check_bit_operation (.^ )(b1, i2) BitMatrix
652
664
@check_bit_operation div (b1, i2) Matrix{Int}
653
- @check_bit_operation mod (b1, i2) Matrix{Int}
665
+ @check_bit_operation mod . (b1, i2) Matrix{Int}
654
666
655
667
# Matrix{Bool}/Matrix{Float64}
656
668
b1 = bitrand (n1, n2)
@@ -659,7 +671,7 @@ f2 = 1.0 .+ rand(n1, n2)
659
671
@check_bit_operation (./ )(b1, f2) Matrix{Float64}
660
672
@check_bit_operation (.^ )(b1, f2) Matrix{Float64}
661
673
@check_bit_operation div (b1, f2) Matrix{Float64}
662
- @check_bit_operation mod (b1, f2) Matrix{Float64}
674
+ @check_bit_operation mod . (b1, f2) Matrix{Float64}
663
675
664
676
# Number/Matrix
665
677
b2 = bitrand (n1, n2)
@@ -696,22 +708,22 @@ end
696
708
b2 = trues (n1, n2)
697
709
@check_bit_operation (./ )(true , b2) Matrix{Float64}
698
710
@check_bit_operation div (true , b2) BitMatrix
699
- @check_bit_operation mod (true , b2) BitMatrix
711
+ @check_bit_operation mod . (true , b2) BitMatrix
700
712
@check_bit_operation (./ )(false , b2) Matrix{Float64}
701
713
@check_bit_operation div (false , b2) BitMatrix
702
- @check_bit_operation mod (false , b2) BitMatrix
714
+ @check_bit_operation mod . (false , b2) BitMatrix
703
715
704
716
@check_bit_operation (./ )(i1, b2) Matrix{Float64}
705
717
@check_bit_operation div (i1, b2) Matrix{Int}
706
- @check_bit_operation mod (i1, b2) Matrix{Int}
718
+ @check_bit_operation mod . (i1, b2) Matrix{Int}
707
719
708
720
@check_bit_operation (./ )(u1, b2) Matrix{Float64}
709
721
@check_bit_operation div (u1, b2) Matrix{UInt8}
710
- @check_bit_operation mod (u1, b2) Matrix{UInt8}
722
+ @check_bit_operation mod . (u1, b2) Matrix{UInt8}
711
723
712
724
@check_bit_operation (./ )(f1, b2) Matrix{Float64}
713
725
@check_bit_operation div (f1, b2) Matrix{Float64}
714
- @check_bit_operation mod (f1, b2) Matrix{Float64}
726
+ @check_bit_operation mod . (f1, b2) Matrix{Float64}
715
727
716
728
@check_bit_operation (./ )(ci1, b2) Matrix{Complex128}
717
729
@check_bit_operation (./ )(cu1, b2) Matrix{Complex128}
@@ -767,7 +779,7 @@ b2 = Array(bitrand(n1,n2))
767
779
@check_bit_operation (./ )(b1, true ) Matrix{Float64}
768
780
@check_bit_operation (./ )(b1, false ) Matrix{Float64}
769
781
@check_bit_operation div (b1, true ) BitMatrix
770
- @check_bit_operation mod (b1, true ) BitMatrix
782
+ @check_bit_operation mod . (b1, true ) BitMatrix
771
783
772
784
@check_bit_operation (& )(b1, b2) BitMatrix
773
785
@check_bit_operation (| )(b1, b2) BitMatrix
@@ -783,7 +795,7 @@ b2 = Array(bitrand(n1,n2))
783
795
@check_bit_operation (.* )(b1, i2) Matrix{Int}
784
796
@check_bit_operation (./ )(b1, i2) Matrix{Float64}
785
797
@check_bit_operation div (b1, i2) Matrix{Int}
786
- @check_bit_operation mod (b1, i2) Matrix{Int}
798
+ @check_bit_operation mod . (b1, i2) Matrix{Int}
787
799
788
800
@check_bit_operation (& )(b1, u2) Matrix{UInt8}
789
801
@check_bit_operation (| )(b1, u2) Matrix{UInt8}
@@ -793,14 +805,14 @@ b2 = Array(bitrand(n1,n2))
793
805
@check_bit_operation (.* )(b1, u2) Matrix{UInt8}
794
806
@check_bit_operation (./ )(b1, u2) Matrix{Float64}
795
807
@check_bit_operation div (b1, u2) Matrix{UInt8}
796
- @check_bit_operation mod (b1, u2) Matrix{UInt8}
808
+ @check_bit_operation mod . (b1, u2) Matrix{UInt8}
797
809
798
810
@check_bit_operation (.+ )(b1, f2) Matrix{Float64}
799
811
@check_bit_operation (.- )(b1, f2) Matrix{Float64}
800
812
@check_bit_operation (.* )(b1, f2) Matrix{Float64}
801
813
@check_bit_operation (./ )(b1, f2) Matrix{Float64}
802
814
@check_bit_operation div (b1, f2) Matrix{Float64}
803
- @check_bit_operation mod (b1, f2) Matrix{Float64}
815
+ @check_bit_operation mod . (b1, f2) Matrix{Float64}
804
816
805
817
@check_bit_operation (.+ )(b1, ci2) Matrix{Complex{Int}}
806
818
@check_bit_operation (.- )(b1, ci2) Matrix{Complex{Int}}
0 commit comments