@@ -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 ()
@@ -611,11 +623,11 @@ b2 = bitrand(n1, n2)
611
623
@check_bit_operation (/ )(b1,1 ) Matrix{Float64}
612
624
613
625
b2 = trues (n1, n2)
614
- @check_bit_operation div (b1, b2) BitMatrix
626
+ @check_bit_operation div . (b1, b2) BitMatrix
615
627
@check_bit_operation mod (b1, b2) BitMatrix
616
- @check_bit_operation div (b1,Array (b2)) BitMatrix
628
+ @check_bit_operation div . (b1,Array (b2)) BitMatrix
617
629
@check_bit_operation mod (b1,Array (b2)) BitMatrix
618
- @check_bit_operation div (Array (b1),b2) BitMatrix
630
+ @check_bit_operation div . (Array (b1),b2) BitMatrix
619
631
@check_bit_operation mod (Array (b1),b2) BitMatrix
620
632
621
633
while true
@@ -649,7 +661,7 @@ i2 = rand(1:10, n1, n2)
649
661
@check_bit_operation (.* )(b1, i2) Matrix{Int}
650
662
@check_bit_operation (./ )(b1, i2) Matrix{Float64}
651
663
@check_bit_operation (.^ )(b1, i2) BitMatrix
652
- @check_bit_operation div (b1, i2) Matrix{Int}
664
+ @check_bit_operation div . (b1, i2) Matrix{Int}
653
665
@check_bit_operation mod (b1, i2) Matrix{Int}
654
666
655
667
# Matrix{Bool}/Matrix{Float64}
@@ -658,7 +670,7 @@ f2 = 1.0 .+ rand(n1, n2)
658
670
@check_bit_operation (.* )(b1, f2) Matrix{Float64}
659
671
@check_bit_operation (./ )(b1, f2) Matrix{Float64}
660
672
@check_bit_operation (.^ )(b1, f2) Matrix{Float64}
661
- @check_bit_operation div (b1, f2) Matrix{Float64}
673
+ @check_bit_operation div . (b1, f2) Matrix{Float64}
662
674
@check_bit_operation mod (b1, f2) Matrix{Float64}
663
675
664
676
# Number/Matrix
@@ -695,22 +707,22 @@ end
695
707
696
708
b2 = trues (n1, n2)
697
709
@check_bit_operation (./ )(true , b2) Matrix{Float64}
698
- @check_bit_operation div (true , b2) BitMatrix
710
+ @check_bit_operation div . (true , b2) BitMatrix
699
711
@check_bit_operation mod (true , b2) BitMatrix
700
712
@check_bit_operation (./ )(false , b2) Matrix{Float64}
701
- @check_bit_operation div (false , b2) BitMatrix
713
+ @check_bit_operation div . (false , b2) BitMatrix
702
714
@check_bit_operation mod (false , b2) BitMatrix
703
715
704
716
@check_bit_operation (./ )(i1, b2) Matrix{Float64}
705
- @check_bit_operation div (i1, b2) Matrix{Int}
717
+ @check_bit_operation div . (i1, b2) Matrix{Int}
706
718
@check_bit_operation mod (i1, b2) Matrix{Int}
707
719
708
720
@check_bit_operation (./ )(u1, b2) Matrix{Float64}
709
- @check_bit_operation div (u1, b2) Matrix{UInt8}
721
+ @check_bit_operation div . (u1, b2) Matrix{UInt8}
710
722
@check_bit_operation mod (u1, b2) Matrix{UInt8}
711
723
712
724
@check_bit_operation (./ )(f1, b2) Matrix{Float64}
713
- @check_bit_operation div (f1, b2) Matrix{Float64}
725
+ @check_bit_operation div . (f1, b2) Matrix{Float64}
714
726
@check_bit_operation mod (f1, b2) Matrix{Float64}
715
727
716
728
@check_bit_operation (./ )(ci1, b2) Matrix{Complex128}
@@ -766,7 +778,7 @@ b2 = Array(bitrand(n1,n2))
766
778
@check_bit_operation (.* )(false , b1) BitMatrix
767
779
@check_bit_operation (./ )(b1, true ) Matrix{Float64}
768
780
@check_bit_operation (./ )(b1, false ) Matrix{Float64}
769
- @check_bit_operation div (b1, true ) BitMatrix
781
+ @check_bit_operation div . (b1, true ) BitMatrix
770
782
@check_bit_operation mod (b1, true ) BitMatrix
771
783
772
784
@check_bit_operation (& )(b1, b2) BitMatrix
@@ -782,7 +794,7 @@ b2 = Array(bitrand(n1,n2))
782
794
@check_bit_operation (.- )(b1, i2) Matrix{Int}
783
795
@check_bit_operation (.* )(b1, i2) Matrix{Int}
784
796
@check_bit_operation (./ )(b1, i2) Matrix{Float64}
785
- @check_bit_operation div (b1, i2) Matrix{Int}
797
+ @check_bit_operation div . (b1, i2) Matrix{Int}
786
798
@check_bit_operation mod (b1, i2) Matrix{Int}
787
799
788
800
@check_bit_operation (& )(b1, u2) Matrix{UInt8}
@@ -792,14 +804,14 @@ b2 = Array(bitrand(n1,n2))
792
804
@check_bit_operation (.- )(b1, u2) Matrix{UInt8}
793
805
@check_bit_operation (.* )(b1, u2) Matrix{UInt8}
794
806
@check_bit_operation (./ )(b1, u2) Matrix{Float64}
795
- @check_bit_operation div (b1, u2) Matrix{UInt8}
807
+ @check_bit_operation div . (b1, u2) Matrix{UInt8}
796
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
- @check_bit_operation div (b1, f2) Matrix{Float64}
814
+ @check_bit_operation div . (b1, f2) Matrix{Float64}
803
815
@check_bit_operation mod (b1, f2) Matrix{Float64}
804
816
805
817
@check_bit_operation (.+ )(b1, ci2) Matrix{Complex{Int}}
0 commit comments