-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of sum of products with nonlinear expressions #3470
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,16 +368,20 @@ for f in (:+, :-, :*, :^, :/, :atan) | |
end | ||
|
||
function _MA.operate!!( | ||
::typeof(_MA.add_mul), | ||
op::_MA.AddSubMul, | ||
x::GenericNonlinearExpr, | ||
y::AbstractJuMPScalar, | ||
) | ||
args::Vararg{Any,N}, | ||
) where {N} | ||
_throw_if_not_real(x) | ||
if x.head == :+ | ||
push!(x.args, y) | ||
arg = *(args...) | ||
if _MA.add_sub_op(op) != + | ||
arg = _MA.add_sub_op(op)(arg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really think we should avoid this. If the user writes Julia has a parsing precedence order. Let's follow that where possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought |
||
end | ||
push!(x.args, arg) | ||
return x | ||
end | ||
return +(x, y) | ||
return _MA.add_sub_op(op)(x, *(args...)) | ||
end | ||
|
||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why I only wrote the binary case 😆