@@ -21,22 +21,26 @@ function _create_binary_switch(ids, exprs)
2121 )
2222end
2323
24- # We use a let block here for `expr` to create a local variable that does not
25- # persist in the scope of the module. All we care about is the _eval_univariate
26- # function that is eval'd as a result.
27- let
24+ function _generate_eval_univariate ()
2825 exprs = map (SYMBOLIC_UNIVARIATE_EXPRESSIONS) do arg
2926 return :(return $ (arg[1 ])(x), $ (arg[2 ]))
3027 end
31- @eval @inline function _eval_univariate (id, x:: T ) where {T}
32- $ (_create_binary_switch (1 : length (exprs), exprs))
33- return error (" Invalid id for univariate operator: $id " )
34- end
35- ∇²f_exprs = map (arg -> :(return $ (arg[3 ])), SYMBOLIC_UNIVARIATE_EXPRESSIONS)
36- @eval @inline function _eval_univariate_2nd_deriv (id, x:: T ) where {T}
37- $ (_create_binary_switch (1 : length (∇²f_exprs), ∇²f_exprs))
38- return error (" Invalid id for univariate operator: $id " )
39- end
28+ return _create_binary_switch (1 : length (exprs), exprs)
29+ end
30+
31+ @eval @inline function _eval_univariate (id, x:: T ) where {T}
32+ $ (_generate_eval_univariate ())
33+ return error (" Invalid id for univariate operator: $id " )
34+ end
35+
36+ function _generate_eval_univariate_2nd_deriv ()
37+ exprs = map (arg -> :(return $ (arg[3 ])), SYMBOLIC_UNIVARIATE_EXPRESSIONS)
38+ return _create_binary_switch (1 : length (exprs), exprs)
39+ end
40+
41+ @eval @inline function _eval_univariate_2nd_deriv (id, x:: T ) where {T}
42+ $ (_generate_eval_univariate_2nd_deriv ())
43+ return error (" Invalid id for univariate operator: $id " )
4044end
4145
4246struct _UnivariateOperator{F,F′,F′′}
0 commit comments