I was wondering if it would make sense (or is possible) to reuse the AD tree of a function when I change the argument values?
As I understand from the arXiv paper it is much more efficient to reuse the AD tree for a function when I want to get the Jacobian and as such do AD for different outputs while I always have the same inputs.
But shouldn’t it be possible to extend this recycling principle to the case when I want to get the Jacobian of the same function (hence same tree), but for different inputs?
I was looking through the code and found that val_ has the type const double. So is my thought wrong here?
If this could work, then we could potentially get some ODE speedups since we evaluate the Jacobian of the very same function very often. I guess, this could benefit others parts of Stan as well…
PS: Do such posts belong here? This is more of a stan-math users question…