Skip to content

Commit 2ddb152

Browse files
committed
fix fwd includes by making a separate in
1 parent 998ad00 commit 2ddb152

6 files changed

Lines changed: 51 additions & 7 deletions

File tree

stan/math/fwd/fun/fft.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#define STAN_MATH_FWD_FUN_FFT_HPP
33

44
#include <stan/math/prim/fun/Eigen.hpp>
5-
#include <stan/math/prim/fun/fft.hpp>
6-
#include <stan/math/prim/fun/to_ref.hpp>
7-
#include <stan/math/prim/meta.hpp>
85
#include <stan/math/fwd/core.hpp>
9-
#include <stan/math/fwd/fun/value_of.hpp>
106
#include <stan/math/fwd/meta.hpp>
7+
#include <stan/math/fwd/fun/value_of.hpp>
8+
#include <stan/math/prim/meta.hpp>
9+
#include <stan/math/prim/fun/fft.hpp>
10+
#include <stan/math/prim/fun/to_ref.hpp>
1111
#include <complex>
1212

1313
namespace stan {

stan/math/fwd/functor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define STAN_MATH_FWD_FUNCTOR_HPP
33

44
#include <stan/math/fwd/functor/apply_scalar_unary.hpp>
5+
#include <stan/math/fwd/functor/broadcast_array.hpp>
56
#include <stan/math/fwd/functor/gradient.hpp>
67
#include <stan/math/fwd/functor/finite_diff.hpp>
78
#include <stan/math/fwd/functor/hessian.hpp>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef STAN_MATH_FWD_META_BROADCAST_ARRAY_HPP
2+
#define STAN_MATH_FWD_META_BROADCAST_ARRAY_HPP
3+
4+
#include <stan/math/prim/fun/Eigen.hpp>
5+
#include <stan/math/fwd/fun/sum.hpp>
6+
#include <stan/math/prim/meta.hpp>
7+
8+
namespace stan {
9+
namespace math {
10+
namespace internal {
11+
12+
template <typename T>
13+
class broadcast_array<T, require_st_fvar<T>> {
14+
private:
15+
std::reference_wrapper<T> prim_;
16+
17+
public:
18+
template <typename TT>
19+
explicit broadcast_array(TT&& prim) : prim_(std::forward<TT>(prim)) {}
20+
21+
T& operator[](int /*i*/) { return prim_.get(); }
22+
23+
/** \ingroup type_trait
24+
* Broadcast array can be assigned a scalar or a vector. If assigned a scalar,
25+
* it will be used directly. If assigned a vector, the argument will be summed
26+
* first.
27+
*/
28+
template <typename Y>
29+
void operator=(const Y& m) {
30+
prim_.get() = sum(m);
31+
}
32+
};
33+
34+
}
35+
}
36+
}
37+
#endif

stan/math/fwd/functor/operands_and_partials.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#include <stan/math/prim/fun/Eigen.hpp>
55
#include <stan/math/prim/meta.hpp>
66
#include <stan/math/prim/fun/size.hpp>
7+
#include <stan/math/fwd/functor/broadcast_array.hpp>
78
#include <stan/math/fwd/core/fvar.hpp>
89
#include <stan/math/fwd/meta.hpp>
910
#include <stan/math/fwd/fun/sum.hpp>
1011
#include <stan/math/prim/fun/as_column_vector_or_scalar.hpp>
1112
#include <stan/math/prim/fun/elt_multiply.hpp>
1213
#include <stan/math/prim/functor/apply.hpp>
1314
#include <stan/math/prim/functor/for_each.hpp>
14-
#include <stan/math/prim/functor/broadcast_array.hpp>
1515
#include <stan/math/prim/functor/operands_and_partials.hpp>
1616
#include <vector>
1717

stan/math/prim/functor/broadcast_array.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define STAN_MATH_PRIM_META_BROADCAST_ARRAY_HPP
33

44
#include <stan/math/prim/meta/is_eigen.hpp>
5+
#include <stan/math/prim/meta/is_var_or_arithmetic.hpp>
56
#include <stan/math/prim/meta/promote_scalar_type.hpp>
67
#include <stan/math/prim/meta/ref_type.hpp>
78
#include <stan/math/prim/fun/Eigen.hpp>
@@ -13,8 +14,11 @@ namespace stan {
1314
namespace math {
1415
namespace internal {
1516

17+
template <typename T, typename Enable = void>
18+
class broadcast_array;
19+
1620
template <typename T>
17-
class broadcast_array {
21+
class broadcast_array<T, require_t<is_var_or_arithmetic<T>>> {
1822
private:
1923
std::reference_wrapper<T> prim_;
2024

stan/math/rev/functor/partials_propagator.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
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/prim/functor/partials_propagator.hpp>
98
#include <stan/math/prim/functor/for_each.hpp>
109
#include <vector>
1110
#include <tuple>
@@ -15,6 +14,9 @@ namespace math {
1514

1615
namespace internal {
1716

17+
template <typename ReturnType, typename Enable, typename... Ops>
18+
class partials_propagator;
19+
1820
/** \ingroup type_trait
1921
* \callergraph
2022
* This class builds partial derivatives with respect to a set of

0 commit comments

Comments
 (0)