1 #ifndef STAN_MATH_PRIM_MAT_FUN_ACCUMULATOR_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_ACCUMULATOR_HPP 49 typename std::enable_if<std::is_arithmetic<S>::value,
void>::type
add(S x) {
50 buf_.push_back(static_cast<T>(x));
66 typename std::enable_if<
67 !std::is_arithmetic<S>::value,
68 typename std::enable_if<std::is_same<S, T>::value,
void>::type>::type
82 template <
typename S,
int R,
int C>
83 void add(
const Eigen::Matrix<S, R, C>& m) {
84 for (
int i = 0; i < m.size(); ++i)
98 void add(
const std::vector<S>& xs) {
99 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.
std::enable_if< !std::is_arithmetic< S >::value, typename std::enable_if< std::is_same< S, T >::value, 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.
std::enable_if< std::is_arithmetic< S >::value, void >::type add(S x)
Add the specified arithmetic type value to the buffer after static casting it to the class type T...
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.