Open baggepinnen opened 10 months ago
($f)(x::Real) = ($f)(float(x))
They have this, and assume float
will always return a float which it should, but @YingboMa added this:
which will make it go into an infinite loop.
Makes me think #536 is not really working...
@baggepinnen just curious why is the sparsity detection implemented like this? Is it beneficial to do this over just calling jacobian_sparsity
before you generate the code? (I need legit examples where we trace generated code symbolically again.)
I my use case, I have dynamics functions generated by MTK, those are then used to compute a Lagrangian for an optimal control problem, the Hessian of which I need for the optimization. It's this Hessian, and other similar functions, I am "re tracing". I could keep everything symbolic without generating the intermediate dynamics function, but then I'd need separate logic to handle MTK models and manually written models, so I opted for always going through a function.
Awesome! Thanks that's a great example of code reuse.
A recent change (maybe PR #536 @YingboMa ?) causes functions produced by
build_function
to fail when called with symbolic variables:This is a problem when generated functions are used to build, e.g., cost functions for optimization problems, after which symbolic tracing is used to find sparsity patterns or generate jacobian functions etc.