Skip to content

Commit db233e7

Browse files
committed
Update
1 parent 54cd866 commit db233e7

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/functions.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,20 +1196,12 @@ function Base.convert(
11961196
f::ScalarNonlinearFunction,
11971197
) where {T}
11981198
if f.head == :*
1199-
if length(f.args) == 2
1200-
quad_terms = ScalarQuadraticTerm{T}[]
1201-
affine_terms = ScalarAffineTerm{T}[]
1202-
if _order_quad(f.args[1], f.args[2]) === nothing
1203-
push!(affine_terms, convert(ScalarAffineTerm{T}, f))
1204-
else
1205-
push!(quadratic_terms, convert(ScalarQuadraticTerm{T}, f))
1206-
end
1207-
return ScalarQuadraticFunction{T}(quad_terms, affine_terms, zero(T))
1208-
elseif length(f.args) == 3
1209-
quad_terms = [convert(ScalarQuadraticTerm{T}, f)]
1210-
affine_terms = ScalarAffineTerm{T}[]
1211-
return ScalarQuadraticFunction{T}(quad_terms, affine_terms, zero(T))
1212-
end
1199+
g = ScalarQuadraticFunction{T}(
1200+
ScalarQuadraticTerm{T}[],
1201+
ScalarAffineTerm{T}[],
1202+
zero(T),
1203+
)
1204+
return _add_to_function(g, f)
12131205
elseif f.head == :^ && length(f.args) == 2 && f.args[2] == 2
12141206
return convert(
12151207
ScalarQuadraticFunction{T},

0 commit comments

Comments
 (0)