SymbolicUtils.jl
SymbolicUtils.jl copied to clipboard
Generated functions no longer re-tracable with Symbolics
A recent change (maybe PR #536 @YingboMa ?) causes functions produced by build_function
to fail when called with symbolic variables:
julia> @variables x
1-element Vector{Num}:
x
julia> f = build_function([sin(x)], [x], expression=Val{false});
julia> f[1]([1])
1-element Vector{Float64}:
0.8414709848078965
julia> f[1]([x])
ERROR: StackOverflowError:
Stacktrace:
[1] sin(x::Num) (repeats 79984 times)
@ NaNMath ~/.julia/packages/NaNMath/ceWIc/src/NaNMath.jl:11
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.