diff --git a/stan/math/prim/arr/functor/integrate_1d.hpp b/stan/math/prim/arr/functor/integrate_1d.hpp index ed6f3788c4f..97a416572d8 100644 --- a/stan/math/prim/arr/functor/integrate_1d.hpp +++ b/stan/math/prim/arr/functor/integrate_1d.hpp @@ -195,7 +195,7 @@ template inline double integrate_1d( const F& f, const double a, const double b, const std::vector& theta, const std::vector& x_r, - const std::vector& x_i, std::ostream& msgs, + const std::vector& x_i, std::ostream* msgs, const double relative_tolerance = std::sqrt(std::numeric_limits::epsilon())) { static const char* function = "integrate_1d"; @@ -209,7 +209,7 @@ inline double integrate_1d( } else { return integrate( std::bind(f, std::placeholders::_1, std::placeholders::_2, - theta, x_r, x_i, &msgs), + theta, x_r, x_i, msgs), a, b, relative_tolerance); } } diff --git a/stan/math/rev/arr/functor/integrate_1d.hpp b/stan/math/rev/arr/functor/integrate_1d.hpp index 1426e73f5fc..1356c40f799 100644 --- a/stan/math/rev/arr/functor/integrate_1d.hpp +++ b/stan/math/rev/arr/functor/integrate_1d.hpp @@ -32,7 +32,7 @@ inline double gradient_of_f(const F &f, const double &x, const double &xc, const std::vector &theta_vals, const std::vector &x_r, const std::vector &x_i, size_t n, - std::ostream &msgs) { + std::ostream *msgs) { double gradient = 0.0; start_nested(); std::vector theta_var(theta_vals.size()); @@ -40,7 +40,7 @@ inline double gradient_of_f(const F &f, const double &x, const double &xc, for (size_t i = 0; i < theta_vals.size(); i++) { theta_var[i] = theta_vals[i]; } - var fx = f(x, xc, theta_var, x_r, x_i, &msgs); + var fx = f(x, xc, theta_var, x_r, x_i, msgs); fx.grad(); gradient = theta_var[n].adj(); if (is_nan(gradient)) { @@ -119,7 +119,7 @@ template integrate_1d( const F &f, const T_a &a, const T_b &b, const std::vector &theta, const std::vector &x_r, const std::vector &x_i, - std::ostream &msgs, + std::ostream *msgs, const double relative_tolerance = std::sqrt(std::numeric_limits::epsilon())) { static const char *function = "integrate_1d"; @@ -134,7 +134,7 @@ inline return_type_t integrate_1d( } else { double integral = integrate( std::bind(f, std::placeholders::_1, std::placeholders::_2, - value_of(theta), x_r, x_i, &msgs), + value_of(theta), x_r, x_i, msgs), value_of(a), value_of(b), relative_tolerance); size_t N_theta_vars = is_var::value ? theta.size() : 0; @@ -148,7 +148,7 @@ inline return_type_t integrate_1d( dintegral_dtheta[n] = integrate( std::bind(gradient_of_f, f, std::placeholders::_1, std::placeholders::_2, theta_vals, x_r, x_i, n, - std::ref(msgs)), + msgs), value_of(a), value_of(b), relative_tolerance); theta_concat[n] = theta[n]; } @@ -157,13 +157,13 @@ inline return_type_t integrate_1d( if (!is_inf(a) && is_var::value) { theta_concat.push_back(a); dintegral_dtheta.push_back( - -value_of(f(value_of(a), 0.0, theta, x_r, x_i, &msgs))); + -value_of(f(value_of(a), 0.0, theta, x_r, x_i, msgs))); } if (!is_inf(b) && is_var::value) { theta_concat.push_back(b); dintegral_dtheta.push_back( - value_of(f(value_of(b), 0.0, theta, x_r, x_i, &msgs))); + value_of(f(value_of(b), 0.0, theta, x_r, x_i, msgs))); } return precomputed_gradients(integral, theta_concat, dintegral_dtheta); diff --git a/test/unit/math/prim/arr/functor/integrate_1d_test.cpp b/test/unit/math/prim/arr/functor/integrate_1d_test.cpp index 5eedf20e313..bd1f0986def 100644 --- a/test/unit/math/prim/arr/functor/integrate_1d_test.cpp +++ b/test/unit/math/prim/arr/functor/integrate_1d_test.cpp @@ -6,7 +6,7 @@ #include #include -std::ostringstream msgs; +std::ostringstream *msgs = nullptr; struct f1 { template diff --git a/test/unit/math/rev/arr/functor/integrate_1d_test.cpp b/test/unit/math/rev/arr/functor/integrate_1d_test.cpp index 9cc5710d980..ed50b98093e 100644 --- a/test/unit/math/rev/arr/functor/integrate_1d_test.cpp +++ b/test/unit/math/rev/arr/functor/integrate_1d_test.cpp @@ -8,7 +8,7 @@ #include #include -std::ostringstream msgs; +std::ostringstream *msgs = nullptr; struct f1 { template