1 #ifndef STAN_MATH_FWD_MAT_META_OPERANDS_AND_PARTIALS_HPP 2 #define STAN_MATH_FWD_MAT_META_OPERANDS_AND_PARTIALS_HPP 14 template <
typename Dx>
17 typedef std::vector<fvar<Dx> >
Op;
22 : partials_(partials_t::Zero(ops.size())),
23 partials_vec_(partials_),
27 template <
typename,
typename,
typename,
typename,
typename,
typename>
33 for (
size_t i = 0; i < this->operands_.size(); ++i) {
34 derivative += this->partials_[i] * this->operands_[i].d_;
40 template <
typename Dx,
int R,
int C>
44 typedef Eigen::Matrix<fvar<Dx>, R, C>
Op;
48 : partials_(partials_t::Zero(ops.
rows(), ops.
cols())),
49 partials_vec_(partials_),
53 template <
typename,
typename,
typename,
typename,
typename,
typename>
59 for (
int i = 0; i < this->operands_.size(); ++i) {
67 template <
typename Dx,
int R,
int C>
70 typedef std::vector<Eigen::Matrix<fvar<Dx>, R, C> >
Op;
74 : partials_vec_(ops.
size()), operands_(ops) {
75 for (
size_t i = 0; i < ops.size(); ++i) {
76 partials_vec_[i] = partial_t::Zero(ops[i].
rows(), ops[i].
cols());
81 template <
typename,
typename,
typename,
typename,
typename,
typename>
87 for (
size_t i = 0; i < this->operands_.size(); ++i) {
88 for (
int j = 0; j < this->operands_[i].size(); ++j) {
89 derivative += this->partials_vec_[i](j) * this->operands_[i](j).d_;
96 template <
typename Dx>
99 typedef std::vector<std::vector<fvar<Dx> > >
Op;
103 : partials_vec_(
length(ops)), operands_(ops) {
104 for (
size_t i = 0; i <
length(ops); ++i) {
105 partials_vec_[i] = partial_t(
length(ops[i]), 0.0);
110 template <
typename,
typename,
typename,
typename,
typename,
typename>
116 for (
size_t i = 0; i < this->operands_.size(); ++i) {
117 for (
size_t j = 0; j < this->operands_[i].size(); ++j) {
118 derivative += this->partials_vec_[i][j] * this->operands_[i][j].d_;
int rows(const Eigen::Matrix< T, R, C > &m)
Return the number of rows in the specified matrix, vector, or row vector.
An edge holds both the operands and its associated partial derivatives.
std::vector< fvar< Dx > > Op
This template builds partial derivatives with respect to a set of operands.
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
(Expert) Numerical traits for algorithmic differentiation variables.
std::vector< partial_t > partials_vec_
Eigen::Matrix< Dx, -1, 1 > partials_t
broadcast_array< partials_t > partials_vec_
ops_partials_edge(const Op &ops)
broadcast_array< partials_t > partials_vec_
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.
empty_broadcast_array< ViewElt, Op > partials_
std::vector< Dx > partial_t
int cols(const Eigen::Matrix< T, R, C > &m)
Return the number of columns in the specified matrix, vector, or row vector.
Eigen::Matrix< Dx, -1, -1 > partial_t
Eigen::Matrix< Dx, R, C > partials_t
std::vector< Eigen::Matrix< fvar< Dx >, R, C > > Op
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
ops_partials_edge(const Op &ops)
ops_partials_edge(const Op &ops)
std::vector< std::vector< fvar< Dx > > > Op
ops_partials_edge(const Op &ops)
std::vector< partial_t > partials_vec_
Eigen::Matrix< fvar< Dx >, R, C > Op