Skip to content

Commit 9c7f88d

Browse files
committed
Merge branch 'feature/parameter-pack-odes' of https://github.com/stan-dev/math into feature/parameter-pack-odes
2 parents 2e83467 + 49bfc45 commit 9c7f88d

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

stan/math/prim/fun/eval.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ namespace math {
1616
* @param[in] arg Input argument
1717
* @return Forwarded input argument
1818
**/
19-
template <typename T,
20-
require_not_eigen_t<T>* = nullptr>
19+
template <typename T, require_not_eigen_t<T>* = nullptr>
2120
inline decltype(auto) eval(T&& arg) {
2221
return std::forward<T>(arg);
2322
}
@@ -29,8 +28,7 @@ inline decltype(auto) eval(T&& arg) {
2928
* @param[in] arg Input argument
3029
* @return Eval'd argument
3130
**/
32-
template <typename T,
33-
require_eigen_t<T>* = nullptr>
31+
template <typename T, require_eigen_t<T>* = nullptr>
3432
inline decltype(auto) eval(T arg) {
3533
return arg.eval();
3634
}

stan/math/rev/functor/ode_store_sensitivities.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Eigen::Matrix<var, Eigen::Dynamic, 1> ode_store_sensitivities(
5555

5656
Eigen::VectorXd f_y0_t0;
5757
if (is_var<T_t0>::value)
58-
f_y0_t0 = f(value_of(t0), eval(value_of(y0)), msgs, eval(value_of(args))...);
58+
f_y0_t0
59+
= f(value_of(t0), eval(value_of(y0)), msgs, eval(value_of(args))...);
5960

6061
const size_t total_vars
6162
= num_y0_vars + num_args_vars + num_t0_vars + num_t_vars;

test/unit/math/prim/fun/eval_test.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ TEST(MathMatrixPrimArr, eval) {
3232
TEST(MathFunctions, eval_int_return_type_short_circuit) {
3333
std::vector<int> a(5, 0);
3434
const std::vector<int> b(5, 0);
35-
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(a)),
36-
std::vector<int>&>::value));
35+
EXPECT_TRUE(
36+
(std::is_same<decltype(stan::math::eval(a)), std::vector<int>&>::value));
3737
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(b)),
3838
const std::vector<int>&>::value));
3939
}
@@ -150,8 +150,9 @@ TEST(MathFunctions, eval_return_type_short_circuit_vector_xd) {
150150
Eigen::Matrix<double, Eigen::Dynamic, 1> a(5);
151151
const Eigen::Matrix<double, Eigen::Dynamic, 1> b(5);
152152
stan::math::eval(a);
153-
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(a)),
154-
const Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value));
153+
EXPECT_TRUE(
154+
(std::is_same<decltype(stan::math::eval(a)),
155+
const Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value));
155156
EXPECT_TRUE(
156157
(std::is_same<decltype(stan::math::eval(b)),
157158
const Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value));
@@ -160,8 +161,9 @@ TEST(MathFunctions, eval_return_type_short_circuit_vector_xd) {
160161
TEST(MathFunctions, eval_return_type_short_circuit_row_vector_xd) {
161162
Eigen::Matrix<double, 1, Eigen::Dynamic> a(5);
162163
const Eigen::Matrix<double, 1, Eigen::Dynamic> b(5);
163-
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(a)),
164-
const Eigen::Matrix<double, 1, Eigen::Dynamic>&>::value));
164+
EXPECT_TRUE(
165+
(std::is_same<decltype(stan::math::eval(a)),
166+
const Eigen::Matrix<double, 1, Eigen::Dynamic>&>::value));
165167
EXPECT_TRUE(
166168
(std::is_same<decltype(stan::math::eval(b)),
167169
const Eigen::Matrix<double, 1, Eigen::Dynamic>&>::value));
@@ -170,9 +172,9 @@ TEST(MathFunctions, eval_return_type_short_circuit_row_vector_xd) {
170172
TEST(MathFunctions, eval_return_type_short_circuit_matrix_xd) {
171173
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> a(5, 4);
172174
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> b(5, 4);
173-
EXPECT_TRUE((std::is_same<
174-
decltype(stan::math::eval(a)),
175-
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>&>::value));
175+
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(a)),
176+
const Eigen::Matrix<double, Eigen::Dynamic,
177+
Eigen::Dynamic>&>::value));
176178
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(b)),
177179
const Eigen::Matrix<double, Eigen::Dynamic,
178180
Eigen::Dynamic>&>::value));
@@ -185,18 +187,21 @@ TEST(MathFunctions, eval_return_type_expression) {
185187
const auto& expr_a = 3 * a;
186188
auto expr_b = b * b;
187189

188-
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(expr_a)),
189-
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>::value));
190-
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(expr_b)),
191-
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>::value));
190+
EXPECT_TRUE(
191+
(std::is_same<
192+
decltype(stan::math::eval(expr_a)),
193+
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>::value));
194+
EXPECT_TRUE(
195+
(std::is_same<
196+
decltype(stan::math::eval(expr_b)),
197+
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>::value));
192198
}
193199

194200
TEST(MathFunctions, eval_return_type_short_circuit_static_sized_matrix) {
195201
Eigen::Matrix<double, 5, 4> a;
196202
const Eigen::Matrix<double, 5, 4> b;
197203
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(a)),
198-
const Eigen::Matrix<double, 5, 4>&>::value));
204+
const Eigen::Matrix<double, 5, 4>&>::value));
199205
EXPECT_TRUE((std::is_same<decltype(stan::math::eval(b)),
200-
const Eigen::Matrix<double, 5, 4>&>::value));
206+
const Eigen::Matrix<double, 5, 4>&>::value));
201207
}
202-

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ struct aytm {
4141
template <typename T0, typename T_y, typename T_Arg, int R, int C>
4242
inline auto operator()(const T0& t, const T_y& y, std::ostream* msgs,
4343
const Eigen::Matrix<T_Arg, R, C>& args) const {
44-
std::vector<typename stan::return_type<T_Arg>::type> vec
45-
= {sum_(args)};
46-
Eigen::Matrix<stan::return_type_t<T0, T_y, T_Arg>, Eigen::Dynamic, 1>
47-
out(2);
44+
std::vector<typename stan::return_type<T_Arg>::type> vec = {sum_(args)};
45+
Eigen::Matrix<stan::return_type_t<T0, T_y, T_Arg>, Eigen::Dynamic, 1> out(
46+
2);
4847
out(0) = -sum_(vec) * y(0) * t;
4948
out(1) = -1.7 * sum_(vec) * y(1) * t;
5049
return out;

0 commit comments

Comments
 (0)