Automatic Differentiation
 
Loading...
Searching...
No Matches
derivative.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_MIX_FUNCTOR_DERIVATIVE_HPP
2#define STAN_MATH_MIX_FUNCTOR_DERIVATIVE_HPP
3
7#include <vector>
8
9namespace stan {
10namespace math {
11
23template <typename T, typename F>
24void derivative(const F& f, const T& x, T& fx, T& dfx_dx) {
25 fvar<T> x_fvar = fvar<T>(x, 1.0);
26 fvar<T> fx_fvar = f(x_fvar);
27 fx = fx_fvar.val_;
28 dfx_dx = fx_fvar.d_;
29}
30
31} // namespace math
32} // namespace stan
33#endif
void derivative(const F &f, const T &x, T &fx, T &dfx_dx)
Return the derivative of the specified univariate function at the specified argument.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Scalar val_
The value of this variable.
Definition fvar.hpp:49
Scalar d_
The tangent (derivative) of this variable.
Definition fvar.hpp:61
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40