Skip to content

Commit

Permalink
Merge branch 'feature/reduce_sum' of github.com:stan-dev/math into fe…
Browse files Browse the repository at this point in the history
…ature/reduce_sum
  • Loading branch information
SteveBronder committed Apr 7, 2020
2 parents 2ea9a7b + dcfffc5 commit 8d8ebd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions stan/math/fwd/functor/reduce_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace stan {
namespace math {

namespace internal {
template <typename ReduceFunction, typename Enable, typename ReturnType,
typename Vec, typename... Args>
struct reduce_sum_impl;
template <typename ReduceFunction, typename Enable, typename ReturnType,
typename Vec, typename... Args>
struct reduce_sum_impl;

/**
* reduce_sum_impl implementation for any autodiff type.
Expand Down Expand Up @@ -63,9 +63,11 @@ struct reduce_sum_impl {
* @param args Shared arguments used in every sum term
* @return Summation of all terms
*/
inline return_type_t<Vec, Args...> operator()(Vec&& vmapped, bool auto_partitioning,
int grainsize, std::ostream* msgs,
Args&&... args) const {
inline return_type_t<Vec, Args...> operator()(Vec&& vmapped,
bool auto_partitioning,
int grainsize,
std::ostream* msgs,
Args&&... args) const {
if (vmapped.empty()) {
return 0.0;
}
Expand Down
7 changes: 4 additions & 3 deletions stan/math/prim/functor/reduce_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ struct reduce_sum_impl<ReduceFunction, require_arithmetic_t<ReturnType>,
* @param args Shared arguments used in every sum term
* @return Summation of all terms
*/
inline ReturnType operator()(Vec&& vmapped, bool auto_partitioning, int grainsize,
std::ostream* msgs, Args&&... args) const {
inline ReturnType operator()(Vec&& vmapped, bool auto_partitioning,
int grainsize, std::ostream* msgs,
Args&&... args) const {
const std::size_t num_terms = vmapped.size();
if (vmapped.empty()) {
return 0.0;
Expand Down Expand Up @@ -193,7 +194,7 @@ struct reduce_sum_impl<ReduceFunction, require_arithmetic_t<ReturnType>,
template <typename ReduceFunction, typename Vec,
typename = require_vector_like_t<Vec>, typename... Args>
inline auto reduce_sum(Vec&& vmapped, int grainsize, std::ostream* msgs,
Args&&... args) {
Args&&... args) {
using return_type = return_type_t<Vec, Args...>;

check_positive("reduce_sum", "grainsize", grainsize);
Expand Down

0 comments on commit 8d8ebd1

Please sign in to comment.