1 #ifndef STAN_MATH_PRIM_MAT_FUN_ACCUMULATOR_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_ACCUMULATOR_HPP 6 #include <boost/utility/enable_if.hpp> 7 #include <boost/type_traits/is_arithmetic.hpp> 8 #include <boost/type_traits/is_same.hpp> 53 typename boost::enable_if<boost::is_arithmetic<S>,
void>::type
55 buf_.push_back(static_cast<T>(x));
71 typename boost::disable_if<boost::is_arithmetic<S>,
72 typename boost::enable_if<boost::is_same<S, T>,
87 template <
typename S,
int R,
int C>
88 void add(
const Eigen::Matrix<S, R, C>& m) {
89 for (
int i = 0; i < m.size(); ++i)
102 template <
typename S>
103 void add(
const std::vector<S>& xs) {
104 for (
size_t i = 0; i < xs.size(); ++i)
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
accumulator()
Construct an accumulator.
boost::disable_if< boost::is_arithmetic< S >, typename boost::enable_if< boost::is_same< S, T >, void >::type >::type add(const S &x)
Add the specified non-arithmetic value to the buffer.
T sum() const
Return the sum of the accumulated values.
Class to accumulate values and eventually return their sum.
void add(const std::vector< S > &xs)
Recursively add each entry in the specified standard vector to the buffer.
void add(const Eigen::Matrix< S, R, C > &m)
Add each entry in the specified matrix, vector, or row vector of values to the buffer.
~accumulator()
Destroy an accumulator.
boost::enable_if< boost::is_arithmetic< S >, void >::type add(S x)
Add the specified arithmetic type value to the buffer after static casting it to the class type T...