File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,12 @@ _float(J::UniformScaling) = _float(J.λ)
30
30
# _Constant--_Constant obviously already taken care of!
31
31
# _Constant--VariableRef
32
32
function Base.:+ (lhs:: _Constant , rhs:: AbstractVariableRef )
33
- return _build_aff_expr (_float (lhs), 1.0 , rhs)
33
+ constant = _float (lhs)
34
+ return _build_aff_expr (constant, one (constant), rhs)
34
35
end
35
36
function Base.:- (lhs:: _Constant , rhs:: AbstractVariableRef )
36
- return _build_aff_expr (_float (lhs), - 1.0 , rhs)
37
+ constant = _float (lhs)
38
+ return _build_aff_expr (constant, - one (constant), rhs)
37
39
end
38
40
function Base.:* (lhs:: _Constant , rhs:: AbstractVariableRef )
39
41
if iszero (lhs)
Original file line number Diff line number Diff line change @@ -22,6 +22,24 @@ function test_complex_aff_expr()
22
22
return
23
23
end
24
24
25
+ function test_complex_plus_variable ()
26
+ model = Model ()
27
+ @variable (model, x)
28
+ y = x + im
29
+ @test typeof (y) == GenericAffExpr{Complex{Float64},VariableRef}
30
+ @test y == im + x
31
+ return
32
+ end
33
+
34
+ function test_complex_minus_variable ()
35
+ model = Model ()
36
+ @variable (model, x)
37
+ y = im - x
38
+ @test typeof (y) == GenericAffExpr{Complex{Float64},VariableRef}
39
+ @test - y == x - im
40
+ return
41
+ end
42
+
25
43
function test_complex_aff_expr_convert ()
26
44
model = Model ()
27
45
@variable (model, x)
You can’t perform that action at this time.
0 commit comments