partial_derivative.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_MIX_MAT_FUNCTOR_PARTIAL_DERIVATIVE_HPP
#define STAN_MATH_MIX_MAT_FUNCTOR_PARTIAL_DERIVATIVE_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <vector>
namespace stan {
namespace math {
template <typename T, typename F>
void
partial_derivative(const F& f,
const Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
int n,
T& fx,
T& dfx_dxn) {
Eigen::Matrix<fvar<T>, Eigen::Dynamic, 1> x_fvar(x.size());
for (int i = 0; i < x.size(); ++i)
x_fvar(i) = fvar<T>(x(i), i == n);
fvar<T> fx_fvar = f(x_fvar);
fx = fx_fvar.val_;
dfx_dxn = fx_fvar.d_;
}
}
}
#endif
core.hpp
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:16
stan
Definition: log_sum_exp.hpp:8
stan::math::fvar::val_
T val_
Definition: fvar.hpp:15
Eigen.hpp
stan::math::fvar
Definition: fvar.hpp:14
stan::math::partial_derivative
void partial_derivative(const F &f, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, int n, T &fx, T &dfx_dxn)
Return the partial derivative of the specified multiivariate function at the specified argument...
Definition: partial_derivative.hpp:26

[ Stan Home Page ] © 2011–2016, Stan Development Team.