Skip to content

Commit 5a45d3c

Browse files
committed
more header fixes
1 parent 08cf193 commit 5a45d3c

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

stan/math/prim/functor/partials_propagator.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class partials_propagator<ReturnType, require_arithmetic_t<ReturnType>,
6767
* @param value the return value of the function we are compressing
6868
* @return the value with its derivative
6969
*/
70-
inline static double build(double value) noexcept { return value; }
71-
std::tuple<internal::ops_partials_edge<double, std::decay_t<Ops>>...> edges_;
70+
inline static constexpr double build(double value) noexcept { return value; }
7271
};
7372

7473
} // namespace internal

test/unit/math/prim/functor/partials_propagator_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ TEST(MathMetaPrim, PartialsPropagator) {
77
auto o1 = stan::math::make_partials_propagator(1.0);
88
auto o2 = stan::math::make_partials_propagator(2.0, 3.0, 4.0, 5.0);
99

10-
// This is size 8 because it just hold an tuple with 4 elements of size 8
11-
EXPECT_EQ(8, sizeof(o2));
10+
// This is size 1 because of empty base class optimization
11+
EXPECT_EQ(1, sizeof(o2));
1212

1313
EXPECT_FLOAT_EQ(27.1, o1.build(27.1));
1414
}

test/unit/math/rev/functor/partials_propagator_test.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorScal) {
1010

1111
double d1;
1212
auto o3 = stan::math::make_partials_propagator(d1);
13-
EXPECT_EQ(2, sizeof(o3));
13+
EXPECT_EQ(1, sizeof(o3));
1414

1515
var v1 = var(0.0);
1616

@@ -35,7 +35,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorVec) {
3535

3636
vector_d d_vec(4);
3737
auto o3 = stan::math::make_partials_propagator(d_vec);
38-
EXPECT_EQ(2, sizeof(o3));
38+
EXPECT_EQ(1, sizeof(o3));
3939

4040
vector_v v_vec(4);
4141
var v1 = var(0.0);
@@ -72,7 +72,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorStdVec) {
7272

7373
std::vector<double> d_vec(4);
7474
auto o3 = stan::math::make_partials_propagator(d_vec);
75-
EXPECT_EQ(2, sizeof(o3));
75+
EXPECT_EQ(1, sizeof(o3));
7676

7777
std::vector<var> v_vec;
7878
var v1 = var(0.0);
@@ -110,7 +110,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMat) {
110110
d_mat << 10.0, 20.0, 30.0, 40.0;
111111
auto o3 = stan::math::make_partials_propagator(d_mat);
112112

113-
EXPECT_EQ(2, sizeof(o3));
113+
EXPECT_EQ(1, sizeof(o3));
114114

115115
matrix_v v_mat(2, 2);
116116
var v1 = var(0.0);
@@ -153,7 +153,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMatMultivar) {
153153
d_mat_vec.push_back(d_mat);
154154
auto o3 = stan::math::make_partials_propagator(d_mat_vec);
155155

156-
EXPECT_EQ(2, sizeof(o3));
156+
EXPECT_EQ(1, sizeof(o3));
157157

158158
matrix_v v_mat1(2, 2);
159159
var v1 = var(0.0);
@@ -218,7 +218,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivar) {
218218
d_vec_vec.push_back(d_vec2);
219219
auto o3 = stan::math::make_partials_propagator(d_vec_vec);
220220

221-
EXPECT_EQ(2, sizeof(o3));
221+
EXPECT_EQ(1, sizeof(o3));
222222

223223
vector_v v_vec1(2);
224224
var v1 = var(0.0);
@@ -292,7 +292,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivarMixed) {
292292

293293
// 2 partials stdvecs, 4 pointers to edges, 2 pointers to operands
294294
// vecs
295-
EXPECT_EQ(112, sizeof(o4));
295+
EXPECT_EQ(104, sizeof(o4));
296296

297297
std::vector<double> grad;
298298
var v = o4.build(10.0);
@@ -307,21 +307,9 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivarMixed) {
307307
// still compile
308308
auto o5 = make_partials_propagator(v_vec, d_vec_vec, d_vec2);
309309
stan::math::edge<0>(o5).partials_vec_[0] += d_vec1;
310-
if (false) {
311-
// the test here is to make things compile as this pattern to
312-
// if-out things when terms are const is used in our functions
313-
stan::math::edge<2>(o5).partials_vec_[0] += vector_d();
314-
stan::math::edge<2>(o5).partials_vec_[0] -= vector_d();
315-
stan::math::edge<2>(o5).partials_vec_[0](0) = 0;
316-
}
317310

318311
// the same needs to work for the nested case
319312
auto o6 = make_partials_propagator(d_vec_vec, d_vec_vec, v_vec2);
320-
if (false) {
321-
// the test here is to make things compile as this pattern to
322-
// if-out things when terms are const is used in our functions
323-
stan::math::edge<0>(o6).partials_vec_[0] += d_vec1;
324-
}
325313
stan::math::edge<2>(o6).partials_vec_[0] += d_vec2;
326314
}
327315

0 commit comments

Comments
 (0)