Open bob-carpenter opened 4 years ago
BTW, the no chain stack is used in the ODE integrators, for example. The other use case is when we instantiate constants which themselves are used as roots for the AD tree (like in the gradient functional). There we need the no chain stack in order to avoid unnecessary chain
calls being made.
Description
For initialization in the language and for general use, we need functions that will initialize constant containers without allocating new
vari
and without placing thosevari
on the stack to have theirchain()
methods called. What we need is something like this with an explicit template parameter,that would be implemented someting like this:
That creates a
std::vector<var>
with only a singlevari
that's not on the autodiff stack.We want to do the same thing for
Eigen::Matrix<T, R, C>
.I'm not sure how this will interact with the existing functions that have recently been added. Those do not have template parameters and default to primitive types (
double
andint
).I also think we can get rid of the no-chain stack as I don't think it's being used for anything, but that's a different PR.
This came up in an issue in stanc3
Example
Current Version:
v3.1.0