Skip to content

Commit 8c330a7

Browse files
committed
fix bernoulli_cdf_log sum header include error
1 parent 095a58b commit 8c330a7

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

stan/math/prim/functor/broadcast_array.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <stan/math/prim/meta/ref_type.hpp>
77
#include <stan/math/prim/fun/Eigen.hpp>
88
#include <stan/math/prim/fun/sum.hpp>
9+
#include <functional>
910
#include <stdexcept>
1011

1112
namespace stan {
@@ -15,12 +16,13 @@ namespace internal {
1516
template <typename T>
1617
class broadcast_array {
1718
private:
18-
T& prim_;
19+
std::reference_wrapper<T> prim_;
1920

2021
public:
21-
explicit broadcast_array(T& prim) : prim_(prim) {}
22+
template <typename TT>
23+
explicit broadcast_array(TT&& prim) : prim_(std::forward<TT>(prim)) {}
2224

23-
T& operator[](int /*i*/) { return prim_; }
25+
T& operator[](int /*i*/) { return prim_.get(); }
2426

2527
/** \ingroup type_trait
2628
* Broadcast array can be assigned a scalar or a vector. If assigned a scalar,
@@ -29,7 +31,7 @@ class broadcast_array {
2931
*/
3032
template <typename Y>
3133
void operator=(const Y& m) {
32-
prim_ = sum(m);
34+
prim_.get() = sum(m);
3335
}
3436
};
3537

@@ -40,15 +42,15 @@ class empty_broadcast_array {
4042
/** \ingroup type_trait
4143
* Not implemented so cannot be called.
4244
*/
43-
T& operator[](int /*i*/);
45+
constexpr T& operator[](int /*i*/);
4446

4547
/** \ingroup type_trait
4648
* Not implemented so cannot be called.
4749
*/
4850
template <typename Y>
49-
void operator=(const Y& /*A*/);
51+
constexpr void operator=(const Y& /*A*/);
5052
template <typename Y>
51-
void add_write_event(Y&& /* event */);
53+
constexpr void add_write_event(Y&& /* event */);
5254
};
5355

5456
template <typename ViewElt, typename T>

stan/math/prim/prob/bernoulli_cdf_log.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace math {
1313
template <typename T_n, typename T_prob>
1414
inline return_type_t<T_prob> bernoulli_cdf_log(const T_n& n,
1515
const T_prob& theta) {
16-
return bernoulli_lcdf<T_n, T_prob>(n, theta);
16+
return bernoulli_lcdf<T_n>(n, theta);
1717
}
1818

1919
} // namespace math

test/prob/test_fixture_cdf_log.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TEST_PROB_TEST_FIXTURE_CDF_LOG_HPP
22
#define TEST_PROB_TEST_FIXTURE_CDF_LOG_HPP
33

4-
#include <stan/math/rev.hpp>
4+
#include <stan/math/mix.hpp>
55
#include <test/prob/utility.hpp>
66
#include <type_traits>
77

0 commit comments

Comments
 (0)