@@ -7,7 +7,7 @@ subtypes, as we know the full set that might be encountered.
7
7
Thus we can avoid any ambiguities.
8
8
9
9
Notice:
10
- The precidence goes: (:Wirtinger, :Casted, :Zero, :DNE, :One, :Thunk, :InplaceableThunk , :Any)
10
+ The precidence goes: (:Wirtinger, :Casted, :Zero, :DNE, :One, :AbstractThunk , :Any)
11
11
Thus each of the @eval loops creating definitions of + and *
12
12
defines the combination this type with all types of lower precidence.
13
13
This means each eval loops is 1 item smaller than the previous.
@@ -36,7 +36,7 @@ function Base.:+(a::Wirtinger, b::Wirtinger)
36
36
return Wirtinger (+ (a. primal, b. primal), a. conjugate + b. conjugate)
37
37
end
38
38
39
- for T in (:Casted , :Zero , :DNE , :One , :Thunk , :InplaceableThunk , :Any )
39
+ for T in (:Casted , :Zero , :DNE , :One , :AbstractThunk , :Any )
40
40
@eval Base.:+ (a:: Wirtinger , b:: $T ) = a + Wirtinger (b, Zero ())
41
41
@eval Base.:+ (a:: $T , b:: Wirtinger ) = Wirtinger (a, Zero ()) + b
42
42
47
47
48
48
Base.:+ (a:: Casted , b:: Casted ) = Casted (broadcasted (+ , a. value, b. value))
49
49
Base.:* (a:: Casted , b:: Casted ) = Casted (broadcasted (* , a. value, b. value))
50
- for T in (:Zero , :DNE , :One , :Thunk , :InplaceableThunk , :Any )
50
+ for T in (:Zero , :DNE , :One , :AbstractThunk , :Any )
51
51
@eval Base.:+ (a:: Casted , b:: $T ) = Casted (broadcasted (+ , a. value, b))
52
52
@eval Base.:+ (a:: $T , b:: Casted ) = Casted (broadcasted (+ , a, b. value))
53
53
58
58
59
59
Base.:+ (:: Zero , b:: Zero ) = Zero ()
60
60
Base.:* (:: Zero , :: Zero ) = Zero ()
61
- for T in (:DNE , :One , :Thunk , :InplaceableThunk , :Any )
61
+ for T in (:DNE , :One , :AbstractThunk , :Any )
62
62
@eval Base.:+ (:: Zero , b:: $T ) = b
63
63
@eval Base.:+ (a:: $T , :: Zero ) = a
64
64
69
69
70
70
Base.:+ (:: DNE , :: DNE ) = DNE ()
71
71
Base.:* (:: DNE , :: DNE ) = DNE ()
72
- for T in (:One , :Thunk , :InplaceableThunk , :Any )
72
+ for T in (:One , :AbstractThunk , :Any )
73
73
@eval Base.:+ (:: DNE , b:: $T ) = b
74
74
@eval Base.:+ (a:: $T , :: DNE ) = a
75
75
80
80
81
81
Base.:+ (a:: One , b:: One ) = extern (a) + extern (b)
82
82
Base.:* (:: One , :: One ) = One ()
83
- for T in (:Thunk , :InplaceableThunk , :Any )
83
+ for T in (:AbstractThunk , :Any )
84
84
@eval Base.:+ (a:: One , b:: $T ) = extern (a) + b
85
85
@eval Base.:+ (a:: $T , b:: One ) = a + extern (b)
86
86
@@ -89,23 +89,12 @@ for T in (:Thunk, :InplaceableThunk, :Any)
89
89
end
90
90
91
91
92
- Base.:+ (a:: Thunk , b:: Thunk ) = extern (a) + extern (b)
93
- Base.:* (a:: Thunk , b:: Thunk ) = extern (a) * extern (b)
94
- for T in (:InplaceableThunk , : Any )
95
- @eval Base.:+ (a:: Thunk , b:: $T ) = extern (a) + b
96
- @eval Base.:+ (a:: $T , b:: Thunk ) = a + extern (b)
92
+ Base.:+ (a:: AbstractThunk , b:: AbstractThunk ) = extern (a) + extern (b)
93
+ Base.:* (a:: AbstractThunk , b:: AbstractThunk ) = extern (a) * extern (b)
94
+ for T in (:Any , )
95
+ @eval Base.:+ (a:: AbstractThunk , b:: $T ) = extern (a) + b
96
+ @eval Base.:+ (a:: $T , b:: AbstractThunk ) = a + extern (b)
97
97
98
- @eval Base.:* (a:: Thunk , b:: $T ) = extern (a) * b
99
- @eval Base.:* (a:: $T , b:: Thunk ) = a * extern (b)
100
- end
101
-
102
- # InplaceableThunk acts just like Thunk
103
- Base.:+ (a:: InplaceableThunk , b:: InplaceableThunk ) = extern (a) + extern (b)
104
- Base.:* (a:: InplaceableThunk , b:: InplaceableThunk ) = extern (a) * extern (b)
105
- for T in (:Any , )
106
- @eval Base.:+ (a:: InplaceableThunk , b:: $T ) = extern (a) + b
107
- @eval Base.:+ (a:: $T , b:: InplaceableThunk ) = a + extern (b)
108
-
109
- @eval Base.:* (a:: InplaceableThunk , b:: $T ) = extern (a) * b
110
- @eval Base.:* (a:: $T , b:: InplaceableThunk ) = a * extern (b)
98
+ @eval Base.:* (a:: AbstractThunk , b:: $T ) = extern (a) * b
99
+ @eval Base.:* (a:: $T , b:: AbstractThunk ) = a * extern (b)
111
100
end
0 commit comments