All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
sum.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_FWD_MAT_FUN_SUM_HPP
#define STAN_MATH_FWD_MAT_FUN_SUM_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/fun/sum.hpp>
namespace stan {
namespace math {
template <typename T, int R, int C>
inline fvar<T> sum(const Eigen::Matrix<fvar<T>, R, C>& m) {
using stan::math::sum;
if (m.size() == 0)
return 0.0;
Eigen::Matrix<T, Eigen::Dynamic, 1> vals(m.size());
Eigen::Matrix<T, Eigen::Dynamic, 1> tans(m.size());
for (int i = 0; i < m.size(); ++i) {
vals(i) = m(i).val();
tans(i) = m(i).tangent();
}
return fvar<T>(sum(vals), sum(tans));
}
}
}
#endif
stan::math::sum
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition: sum.hpp:20
core.hpp
Eigen.hpp
sum.hpp
stan::math::fvar
Definition: fvar.hpp:13

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