Skip to content

Commit 17608cb

Browse files
authored
Update to MutableArithmetics v0.3 (#1640)
* Update to MutableArithmetics v0.3 * MA released
1 parent bfc0add commit 17608cb

4 files changed

Lines changed: 25 additions & 25 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CodecBzip2 = "~0.6, 0.7"
2121
CodecZlib = "~0.6, 0.7"
2222
JSON = "~0.21"
2323
JSONSchema = "1"
24-
MutableArithmetics = "0.2"
24+
MutableArithmetics = "0.3"
2525
OrderedCollections = "1"
2626
julia = "1"
2727

src/Utilities/functions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ function operate!(
15951595
::Type{T},
15961596
f::Union{MOI.ScalarAffineFunction{T},MOI.ScalarQuadraticFunction{T}},
15971597
) where {T}
1598-
return MA.mutable_operate!(-, f)
1598+
return MA.operate!(-, f)
15991599
end
16001600

16011601
# Scalar Affine +/-! ...
@@ -1605,7 +1605,7 @@ function operate!(
16051605
f::MOI.ScalarAffineFunction{T},
16061606
g::Union{T,MOI.VariableIndex,MOI.ScalarAffineFunction{T}},
16071607
) where {T}
1608-
return MA.mutable_operate!(op, f, g)
1608+
return MA.operate!(op, f, g)
16091609
end
16101610

16111611
function operate!(
@@ -1638,7 +1638,7 @@ function operate!(
16381638
MOI.ScalarQuadraticFunction{T},
16391639
},
16401640
) where {T}
1641-
return MA.mutable_operate!(op, f, g)
1641+
return MA.operate!(op, f, g)
16421642
end
16431643

16441644
## operate

src/Utilities/mutable_arithmetics.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function MA.isequal_canonical(
4646
)
4747
end
4848

49-
function MA.iszero!(f::TypedScalarLike)
49+
function MA.iszero!!(f::TypedScalarLike)
5050
return iszero(MOI.constant(f)) && _is_constant(canonicalize!(f))
5151
end
5252

@@ -103,15 +103,15 @@ function MA.promote_operation(
103103
return promote_operation(op, G, F, G)
104104
end
105105

106-
function MA.mutable_operate!(
106+
function MA.operate!(
107107
op::Union{typeof(zero),typeof(one)},
108108
f::MOI.ScalarAffineFunction,
109109
)
110110
empty!(f.terms)
111111
f.constant = op(f.constant)
112112
return f
113113
end
114-
function MA.mutable_operate!(
114+
function MA.operate!(
115115
op::Union{typeof(zero),typeof(one)},
116116
f::MOI.ScalarQuadraticFunction,
117117
)
@@ -121,34 +121,34 @@ function MA.mutable_operate!(
121121
return f
122122
end
123123

124-
function MA.mutable_operate!(::typeof(-), f::MOI.ScalarQuadraticFunction)
124+
function MA.operate!(::typeof(-), f::MOI.ScalarQuadraticFunction)
125125
operate_terms!(-, f.quadratic_terms)
126126
operate_terms!(-, f.affine_terms)
127127
f.constant = -f.constant
128128
return f
129129
end
130-
function MA.mutable_operate!(::typeof(-), f::MOI.ScalarAffineFunction)
130+
function MA.operate!(::typeof(-), f::MOI.ScalarAffineFunction)
131131
operate_terms!(-, f.terms)
132132
f.constant = -f.constant
133133
return f
134134
end
135-
function MA.mutable_operate!(
135+
function MA.operate!(
136136
op::Union{typeof(+),typeof(-)},
137137
f::MOI.ScalarAffineFunction{T},
138138
g::T,
139139
) where {T}
140140
f.constant = op(f.constant, g)
141141
return f
142142
end
143-
function MA.mutable_operate!(
143+
function MA.operate!(
144144
op::Union{typeof(+),typeof(-)},
145145
f::MOI.ScalarAffineFunction{T},
146146
g::MOI.VariableIndex,
147147
) where {T}
148148
push!(f.terms, MOI.ScalarAffineTerm(op(one(T)), g))
149149
return f
150150
end
151-
function MA.mutable_operate_to!(
151+
function MA.operate_to!(
152152
output::MOI.ScalarAffineFunction{T},
153153
op::Union{typeof(+),typeof(-)},
154154
f::MOI.ScalarAffineFunction{T},
@@ -160,7 +160,7 @@ function MA.mutable_operate_to!(
160160
output.constant = op(f.constant, g.constant)
161161
return output
162162
end
163-
function MA.mutable_operate_to!(
163+
function MA.operate_to!(
164164
output::MOI.ScalarQuadraticFunction{T},
165165
op::Union{typeof(+),typeof(-)},
166166
f::MOI.ScalarQuadraticFunction{T},
@@ -175,7 +175,7 @@ function MA.mutable_operate_to!(
175175
output.constant = op(f.constant, g.constant)
176176
return output
177177
end
178-
function MA.mutable_operate!(
178+
function MA.operate!(
179179
op::Union{typeof(+),typeof(-)},
180180
f::MOI.ScalarAffineFunction{T},
181181
g::MOI.ScalarAffineFunction{T},
@@ -184,23 +184,23 @@ function MA.mutable_operate!(
184184
f.constant = op(f.constant, g.constant)
185185
return f
186186
end
187-
function MA.mutable_operate!(
187+
function MA.operate!(
188188
op::Union{typeof(+),typeof(-)},
189189
f::MOI.ScalarQuadraticFunction{T},
190190
g::T,
191191
) where {T}
192192
f.constant = op(f.constant, g)
193193
return f
194194
end
195-
function MA.mutable_operate!(
195+
function MA.operate!(
196196
op::Union{typeof(+),typeof(-)},
197197
f::MOI.ScalarQuadraticFunction{T},
198198
g::MOI.VariableIndex,
199199
) where {T}
200200
push!(f.affine_terms, MOI.ScalarAffineTerm(op(one(T)), g))
201201
return f
202202
end
203-
function MA.mutable_operate!(
203+
function MA.operate!(
204204
op::Union{typeof(+),typeof(-)},
205205
f::MOI.ScalarQuadraticFunction{T},
206206
g::MOI.ScalarAffineFunction{T},
@@ -209,7 +209,7 @@ function MA.mutable_operate!(
209209
f.constant = op(f.constant, g.constant)
210210
return f
211211
end
212-
function MA.mutable_operate!(
212+
function MA.operate!(
213213
op::Union{typeof(+),typeof(-)},
214214
f::MOI.ScalarQuadraticFunction{T},
215215
g::MOI.ScalarQuadraticFunction{T},
@@ -320,7 +320,7 @@ function _add_sub_affine_terms(
320320
return _add_sub_affine_terms(op, terms, α * β, args...)
321321
end
322322

323-
function MA.mutable_operate!(
323+
function MA.operate!(
324324
op::MA.AddSubMul,
325325
f::MOI.ScalarAffineFunction{T},
326326
args::Vararg{ScalarAffineLike{T},N},
@@ -409,7 +409,7 @@ function _num_function_with_terms(
409409
) where {T,N}
410410
return _num_function_with_terms(T, f) + _num_function_with_terms(T, args...)
411411
end
412-
function MA.mutable_operate!(
412+
function MA.operate!(
413413
op::MA.AddSubMul,
414414
f::MOI.ScalarQuadraticFunction{T},
415415
args::Vararg{ScalarQuadraticLike{T},N},
@@ -420,15 +420,15 @@ function MA.mutable_operate!(
420420
_add_quadratic_terms(MA.add_sub_op(op), f.quadratic_terms, args...)
421421
return f
422422
else
423-
return MA.mutable_operate!(MA.add_sub_op(op), f, *(args...))
423+
return MA.operate!(MA.add_sub_op(op), f, *(args...))
424424
end
425425
end
426426
# `args` could be `(x', a)` where `a` is a vector of constants and `x` a vector
427427
# of affine functions for instance.
428-
function MA.mutable_operate!(
428+
function MA.operate!(
429429
op::MA.AddSubMul,
430430
f::TypedScalarLike,
431431
args::Vararg{Any,N},
432432
) where {N}
433-
return MA.mutable_operate!(MA.add_sub_op(op), f, *(args...))
433+
return MA.operate!(MA.add_sub_op(op), f, *(args...))
434434
end

src/Utilities/results.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ function triangle_dot(
512512
for j in 1:i
513513
k += 1
514514
if i == j
515-
result = MA.add_mul!(result, x[k], y[k])
515+
result = MA.add_mul!!(result, x[k], y[k])
516516
else
517-
result = MA.add_mul!(result, 2, x[k], y[k])
517+
result = MA.add_mul!!(result, 2, x[k], y[k])
518518
end
519519
end
520520
end

0 commit comments

Comments
 (0)