File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #ifndef STAN_MATH_FWD_META_BROADCAST_ARRAY_HPP
2- #define STAN_MATH_FWD_META_BROADCAST_ARRAY_HPP
1+ #ifndef STAN_MATH_FWD_FUNCTOR_BROADCAST_ARRAY_HPP
2+ #define STAN_MATH_FWD_FUNCTOR_BROADCAST_ARRAY_HPP
33
44#include < stan/math/prim/fun/Eigen.hpp>
55#include < stan/math/fwd/fun/sum.hpp>
6- #include < stan/math/prim/functor/broadcast_array_fwd .hpp>
6+ #include < stan/math/prim/functor/broadcast_array .hpp>
77#include < stan/math/prim/meta.hpp>
88
99namespace stan {
Original file line number Diff line number Diff line change 1- #ifndef STAN_MATH_PRIM_META_BROADCAST_ARRAY_HPP
2- #define STAN_MATH_PRIM_META_BROADCAST_ARRAY_HPP
1+ #ifndef STAN_MATH_PRIM_FUNCTOR_BROADCAST_ARRAY_HPP
2+ #define STAN_MATH_PRIM_FUNCTOR_BROADCAST_ARRAY_HPP
33
44#include < stan/math/prim/functor/broadcast_array_fwd.hpp>
55#include < stan/math/prim/meta/is_eigen.hpp>
@@ -16,7 +16,7 @@ namespace math {
1616namespace internal {
1717
1818template <typename T>
19- class broadcast_array <T, require_t <is_var_or_arithmetic<T> >> {
19+ class broadcast_array <T, require_st_arithmetic<T >> {
2020 private:
2121 std::reference_wrapper<T> prim_;
2222
Original file line number Diff line number Diff line change 88#include < stan/math/rev/functor/apply_scalar_unary.hpp>
99#include < stan/math/rev/functor/apply_scalar_binary.hpp>
1010#include < stan/math/rev/functor/apply_vector_unary.hpp>
11+ #include < stan/math/rev/functor/broadcast_array.hpp>
1112#include < stan/math/rev/functor/coupled_ode_system.hpp>
1213#include < stan/math/rev/functor/cvodes_integrator.hpp>
1314#include < stan/math/rev/functor/cvodes_utils.hpp>
Original file line number Diff line number Diff line change 1+ #ifndef STAN_MATH_REV_FUNCTOR_BROADCAST_ARRAY_HPP
2+ #define STAN_MATH_REV_FUNCTOR_BROADCAST_ARRAY_HPP
3+
4+ #include < stan/math/prim/fun/Eigen.hpp>
5+ #include < stan/math/rev/fun/sum.hpp>
6+ #include < stan/math/prim/functor/broadcast_array.hpp>
7+ #include < stan/math/prim/meta.hpp>
8+
9+ namespace stan {
10+ namespace math {
11+ namespace internal {
12+
13+ template <typename T>
14+ class broadcast_array <T, require_st_var<T>> {
15+ private:
16+ std::reference_wrapper<T> prim_;
17+
18+ public:
19+ template <typename TT >
20+ explicit broadcast_array (TT && prim) : prim_(std::forward<TT >(prim)) {}
21+
22+ T& operator [](int /* i*/ ) { return prim_.get (); }
23+
24+ /* * \ingroup type_trait
25+ * Broadcast array can be assigned a scalar or a vector. If assigned a scalar,
26+ * it will be used directly. If assigned a vector, the argument will be summed
27+ * first.
28+ */
29+ template <typename Y>
30+ void operator =(const Y& m) {
31+ prim_.get () = sum (m);
32+ }
33+ };
34+
35+ } // namespace internal
36+ } // namespace math
37+ } // namespace stan
38+ #endif
Original file line number Diff line number Diff line change 77#include < stan/math/rev/core/var.hpp>
88#include < stan/math/rev/core/vari.hpp>
99#include < stan/math/rev/core/typedefs.hpp>
10+ #include < stan/math/rev/functor/broadcast_array.hpp>
1011#include < stan/math/prim/meta/is_eigen.hpp>
1112#include < stan/math/prim/meta/is_vector_like.hpp>
1213#include < stan/math/prim/meta/compiler_attributes.hpp>
1314#include < stan/math/prim/meta/promote_scalar_type.hpp>
1415#include < stan/math/prim/fun/size.hpp>
15- #include < stan/math/prim/functor/broadcast_array.hpp>
1616#include < stan/math/prim/functor/operands_and_partials.hpp>
17+ #include < stan/math/prim/functor/broadcast_array.hpp>
1718#include < stan/math/prim/functor/apply.hpp>
1819#include < stan/math/prim/functor/for_each.hpp>
1920#include < vector>
Original file line number Diff line number Diff line change 55#include < stan/math/rev/core/var.hpp>
66#include < stan/math/rev/core/typedefs.hpp>
77#include < stan/math/rev/functor/operands_and_partials.hpp>
8+ #include < stan/math/rev/functor/broadcast_array.hpp>
89#include < stan/math/prim/functor/for_each.hpp>
910#include < vector>
1011#include < tuple>
You can’t perform that action at this time.
0 commit comments