14
14
Compute the return type of the call `operate(op, T, args...)`, where the types
15
15
of the arguments `args` are `ArgsTypes`.
16
16
17
+ One assumption is that the element type `T` is invariant under each operation.
18
+ That is, `op(::T, ::T)::T` where `op` is a `+`, `-`, `*`, and `/`.
19
+
17
20
There are five methods for which we implement `Utilities.promote_operation`:
18
21
19
22
1. `+`
20
23
a. `promote_operation(::typeof(+), ::Type{T}, ::Type{F1}, ::Type{F2})`
21
24
2. `-`
22
25
a. `promote_operation(::typeof(-), ::Type{T}, ::Type{F})`
23
26
b. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{F2})`
24
- c. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{Vector{T}})`
25
27
3. `*`
26
28
a. `promote_operation(::typeof(*), ::Type{T}, ::Type{T}, ::Type{F})`
27
29
b. `promote_operation(::typeof(*), ::Type{T}, ::Type{F}, ::Type{T})`
@@ -33,10 +35,13 @@ There are five methods for which we implement `Utilities.promote_operation`:
33
35
5. `vcat`
34
36
a. `promote_operation(::typeof(vcat), ::Type{T}, ::Type{F}...)`
35
37
6. `imag`
36
- a. `promote_operation(::typeof(imag), ::Type{T}, ::Type{F}`
38
+ a. `promote_operation(::typeof(imag), ::Type{T}, ::Type{F}) `
37
39
where `F` is `VariableIndex` or `VectorOfVariables`
38
40
39
- There are nine types:
41
+ In each case, `F` (or `F1` and `F2`) is one of the nine supported types, with
42
+ a restriction that the mathematical operation makes sense, for example, we don't
43
+ define `promote_operation(-, T, F1, F2)` where `F1` is a scalar-valued function
44
+ and `F2` is a vector-valued function. The nine supported types are:
40
45
41
46
1. ::T
42
47
2. ::VariableIndex
@@ -166,33 +171,6 @@ function promote_operation(
166
171
return MOI. VectorAffineFunction{T}
167
172
end
168
173
169
- # ## Method 2c
170
-
171
- function promote_operation (
172
- :: typeof (- ),
173
- :: Type{T} ,
174
- :: Type{F} ,
175
- :: Type{<:AbstractVector{T}} ,
176
- ) where {
177
- T,
178
- F<: Union {
179
- AbstractVector{T},
180
- MOI. VectorAffineFunction{T},
181
- MOI. VectorQuadraticFunction{T},
182
- },
183
- }
184
- return F
185
- end
186
-
187
- function promote_operation (
188
- :: typeof (- ),
189
- :: Type{T} ,
190
- :: Type{MOI.VectorOfVariables} ,
191
- :: Type{<:AbstractVector{T}} ,
192
- ) where {T}
193
- return MOI. VectorAffineFunction{T}
194
- end
195
-
196
174
# ## Method 3a
197
175
198
176
function promote_operation (
0 commit comments