![]() |
Stan Math Library
5.3.0
Automatic Differentiation
|
|
inline |
Build the reverse-mode result of a one-dimensional adaptive quadrature.
The quadrature routine is supplied as a callable integrator so the three integrate_1d* variants (plain, double-exponential, Gauss-Kronrod) can share this body, differing only in which Boost routine and tolerances they bind. integrator is invoked as integrator(g) where g is an integrand with signature g(x, xc); it returns the scalar integral of g over [a, b].
The integral value is computed with an all-double integrand. Adjoints are then accumulated into the original var inputs:
-f(a) and f(b) (skipped when infinite),var argument component contributes the integral of d f / d arg, obtained with nested reverse-mode autodiff.Gradients of f that come back NaN at a point where f == 0 are set to zero. Any other NaN propagates into the component integral and is reported as a domain_error naming the (flattened) parameter index.
| F | Type of f |
| T_a | type of first limit |
| T_b | type of second limit |
| Integrator | callable (integrand) -> double |
| Args | types of parameter pack arguments |
| function | name of the calling function, used in error messages | |
| f | the functor to integrate | |
| a | lower limit of integration | |
| b | upper limit of integration | |
| integrator | binds the quadrature routine and its tolerances | |
| [in,out] | msgs | the print stream for warning messages |
| args | additional arguments to pass to f |
Definition at line 57 of file integrate_1d_adjoint.hpp.