Value_of vs value_of_rec in stan/dev/math

Anyone know offhand what’s the difference in values_of vs values_of_rec?

1 Like

The value_of_rec version is recursive, so that for fvar<var<double>>, it returns double, while value_of would return var<double>. As to when one should use one rather than the other, I’m not clear either.

Ooooh, got it, thanks. Did I just miss the docs somewhere? If not I can make an issue.

I don’t know, I think I looked at tests to see what the difference was.

The doc is in:


We need value_of inside operands_and_partials in order to get higher-order derivatives right. We can use value_of_rec in most other places. If you implement a function for all types, then you can recurse with value_of or go all the way at once with value_of_rec if you know you’ll eventually need a primitive value.