I wrote this, but I’ll get into a little more detail:
Different Math devs have written different versions over the years (I’m listing what I can find quickly down below), but what I consider to be the current API is written here: Quick Start · stan-dev/math Wiki · GitHub.
To break it down a bit:
- 13 header includes. C++ clients can expect these to exist.
stan/math.hpp
- these 12 header files:
stan/math/{prim, rev, fwd, mix}/{scal, arr, mat}.hpp
(but we’re trying to knock that down to 4 with the “flattening” refactor)
- Math functions (almost everything in the
stan::math
namespace):- every function in
err
,fun
,functor
,prob
, andvectorize
folders, e.g.stan/math/prim/scal/fun/*.hpp
. - a lot of the
meta
folder, but not all; some of this is considered “internal,” but clients should have access to templated functions likevalue_of(...)
oris_var
- every function in
That covers almost everything in the Math library. I can’t think of a single function signature I’d be willing to change at will, but I’m sure there are a handful of functions that we could. In practice, we’ve acted as though this is our API because we’ve deprecated functions like normal_log()
when we could easily have removed it and had Stan’s generator handle the name change.
So, that’s what I consider to be the C++ API. I know there are users (that have posted on Discourse) that have stated they use the Math library for higher order autodiff without the Stan language. I don’t know if the number of clients that use it for that purpose are in the single digits or if it’s much higher.
Different places where Math devs and users have discussed it:
- Quick Start · stan-dev/math Wiki · GitHub
- Motivation for the headers: Home · stan-dev/math Wiki · GitHub
- Guidelines for contributing new functions: Contributing New Functions to Stan · stan-dev/stan Wiki · GitHub
- Mentioned here: Home · stan-dev/math Wiki · GitHub
- First inclusion of
fvar
in the source: Stan’s67de79e1
commit (pre v1.1.0 when Math and Stan were in the same repo) - The actual Math PR where the 12 headers were introduced: math#245
- This Stan PR is where we generalized operands and partials, which allowed all of the lpdfs to be higher-order autodiff enabled: stan#706
- We’ve helped users with higher order autodiff since that was introduced: 12/2014 thread on stan-users “2nd order derivatives, working yet?”
- that said, we’ve haven’t really backed all the higher-order derivatives… this goes back to v2.5 (09/2014) “2.5 and beyond — punting on higher-order autodiff again” – this was before the other thread on stan-users
- Discussion on these forums about “Higher-Order Autodiff, testing framework & RHMC” (last activity was a couple weeks ago)
- We don’t really have new bugs pertaining to higher order autodiff. But… this is the issue that documents some of our problems: math#403
- @rgiordan has used the higher order stuff write different packages. This is a thread from stan-users “Sub-Hessians with STAN math autodiff library”