Skip to content

Commit a88e494

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 20b6f5e commit a88e494

5 files changed

Lines changed: 36 additions & 45 deletions

File tree

stan/math/rev/functor/solve_newton.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ template <typename F, typename T, typename... Args,
5757
require_eigen_vector_t<T>* = nullptr,
5858
require_all_st_arithmetic<Args...>* = nullptr>
5959
Eigen::VectorXd solve_newton_tol(const F& f, const T& x,
60-
const double scaling_step_size,
61-
const double function_tolerance,
62-
const int64_t max_num_steps,
63-
std::ostream* const msgs,
64-
const Args&... args) {
60+
const double scaling_step_size,
61+
const double function_tolerance,
62+
const int64_t max_num_steps,
63+
std::ostream* const msgs,
64+
const Args&... args) {
6565
const auto& x_ref = to_ref(value_of(x));
6666

6767
check_nonzero_size("solve_newton", "initial guess", x_ref);
@@ -298,9 +298,9 @@ Eigen::Matrix<scalar_type_t<T2>, Eigen::Dynamic, 1> algebra_solver_newton(
298298
const double scaling_step_size = 1e-3,
299299
const double function_tolerance = 1e-6,
300300
const long int max_num_steps = 200) { // NOLINT(runtime/int)
301-
return solve_newton_tol(algebra_solver_adapter<F>(f), x,
302-
scaling_step_size, function_tolerance, max_num_steps,
303-
msgs, y, dat, dat_int);
301+
return solve_newton_tol(algebra_solver_adapter<F>(f), x, scaling_step_size,
302+
function_tolerance, max_num_steps, msgs, y, dat,
303+
dat_int);
304304
}
305305

306306
} // namespace math

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ TEST_F(FP_direct_prod_func_test, algebra_solver_fp) {
495495
Eigen::Matrix<var, -1, 1> xv_fp = algebra_solver_fp(
496496
f, x, yp, x_r, x_i, u_scale, f_scale, 0, f_tol, max_num_steps); // NOLINT
497497
Eigen::Matrix<var, -1, 1> xv_newton = algebra_solver_newton(
498-
f_newton, x, yp, x_r, x_i, 0, 1.e-3, f_tol, max_num_steps); // NOLINT
498+
f_newton, x, yp, x_r, x_i, 0, 1.e-3, f_tol, max_num_steps); // NOLINT
499499
for (int i = 0; i < n; ++i) {
500500
EXPECT_FLOAT_EQ(value_of(xv_fp(i)), value_of(xv_newton(i)));
501501
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
TEST_F(algebra_solver_simple_eq_test, newton_dbl) {
1616
bool is_newton = true;
17-
Eigen::VectorXd theta
18-
= simple_eq_test(simple_eq_functor(), y_dbl, is_newton);
17+
Eigen::VectorXd theta = simple_eq_test(simple_eq_functor(), y_dbl, is_newton);
1918
}
2019

2120
TEST_F(algebra_solver_simple_eq_test, newton_tuned_dbl) {
2221
bool is_newton = true;
23-
Eigen::VectorXd theta
24-
= simple_eq_test(simple_eq_functor(), y_dbl, is_newton, true,
25-
scale_step, xtol, ftol, maxfev);
22+
Eigen::VectorXd theta = simple_eq_test(simple_eq_functor(), y_dbl, is_newton,
23+
true, scale_step, xtol, ftol, maxfev);
2624
}
2725

2826
TEST_F(algebra_solver_simple_eq_nopara_test, newton_dbl) {
@@ -266,8 +264,7 @@ TEST_F(algebra_solver_simple_eq_test, newton_deprecated) {
266264
Eigen::Matrix<var, Eigen::Dynamic, 1> y = y_dbl;
267265

268266
Eigen::Matrix<var, Eigen::Dynamic, 1> theta
269-
= simple_eq_non_varia_test(simple_eq_non_varia_functor(), y,
270-
is_newton);
267+
= simple_eq_non_varia_test(simple_eq_non_varia_functor(), y, is_newton);
271268

272269
std::vector<stan::math::var> y_vec{y(0), y(1), y(2)};
273270
std::vector<double> g;
@@ -285,9 +282,8 @@ TEST_F(algebra_solver_simple_eq_test, newton_tuned_deprecated) {
285282
Eigen::Matrix<var, Eigen::Dynamic, 1> y = y_dbl;
286283

287284
Eigen::Matrix<var, Eigen::Dynamic, 1> theta
288-
= simple_eq_non_varia_test(simple_eq_non_varia_functor(), y,
289-
is_newton, true,
290-
scale_step, xtol, ftol, maxfev);
285+
= simple_eq_non_varia_test(simple_eq_non_varia_functor(), y, is_newton,
286+
true, scale_step, xtol, ftol, maxfev);
291287

292288
std::vector<stan::math::var> y_vec{y(0), y(1), y(2)};
293289
std::vector<double> g;

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
TEST_F(algebra_solver_simple_eq_test, powell_dbl) {
1616
bool is_newton = false;
17-
Eigen::VectorXd theta
18-
= simple_eq_test(simple_eq_functor(), y_dbl, is_newton);
17+
Eigen::VectorXd theta = simple_eq_test(simple_eq_functor(), y_dbl, is_newton);
1918
}
2019

2120
TEST_F(algebra_solver_simple_eq_test, powell_tuned_dbl) {
2221
bool is_newton = false;
23-
Eigen::VectorXd theta
24-
= simple_eq_test(simple_eq_functor(), y_dbl, is_newton, true,
25-
scale_step, xtol, ftol, maxfev);
22+
Eigen::VectorXd theta = simple_eq_test(simple_eq_functor(), y_dbl, is_newton,
23+
true, scale_step, xtol, ftol, maxfev);
2624
}
2725

2826
TEST_F(algebra_solver_simple_eq_nopara_test, powell) {
@@ -139,8 +137,8 @@ TEST_F(algebra_solver_simple_eq_test, powell_tuned) {
139137
Eigen::Matrix<var, Eigen::Dynamic, 1> y = y_dbl;
140138

141139
Eigen::Matrix<var, Eigen::Dynamic, 1> theta
142-
= simple_eq_test(simple_eq_functor(), y, is_newton, use_tol,
143-
scale_step, xtol, ftol, maxfev);
140+
= simple_eq_test(simple_eq_functor(), y, is_newton, use_tol, scale_step,
141+
xtol, ftol, maxfev);
144142

145143
std::vector<stan::math::var> y_vec{y(0), y(1), y(2)};
146144
std::vector<double> g;

test/unit/math/rev/functor/util_algebra_solver.hpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,11 @@ Eigen::Matrix<T2, Eigen::Dynamic, 1> general_algebra_solver_non_varia(
226226

227227
Eigen::Matrix<T2, Eigen::Dynamic, 1> theta;
228228
if (!is_newton) {
229-
theta = algebra_solver(f, x, y, dat,
230-
dat_int, msgs, relative_tolerance,
229+
theta = algebra_solver(f, x, y, dat, dat_int, msgs, relative_tolerance,
231230
function_tolerance, max_num_steps);
232231
} else {
233232
theta
234-
= algebra_solver_newton(f, x, y,
235-
dat, dat_int, msgs, scaling_step_size,
233+
= algebra_solver_newton(f, x, y, dat, dat_int, msgs, scaling_step_size,
236234
function_tolerance, max_num_steps);
237235
}
238236
return theta;
@@ -280,8 +278,8 @@ struct simple_eq_functor_nopara {
280278
struct non_linear_eq_functor {
281279
template <typename T1, typename T2, typename T3, typename T4>
282280
inline Eigen::Matrix<stan::return_type_t<T1, T2>, Eigen::Dynamic, 1>
283-
operator()(const T1& x, std::ostream* pstream__,
284-
const T2& y, const T3& dat, const T4& dat_int) const {
281+
operator()(const T1& x, std::ostream* pstream__, const T2& y, const T3& dat,
282+
const T4& dat_int) const {
285283
Eigen::Matrix<stan::return_type_t<T1, T2>, Eigen::Dynamic, 1> z(3);
286284
z(0) = x(2) - y(2);
287285
z(1) = x(0) * x(1) - y(0) * y(1);
@@ -519,7 +517,6 @@ inline void max_num_steps_test(Eigen::Matrix<T, Eigen::Dynamic, 1>& y,
519517
std::domain_error);
520518
}
521519

522-
523520
Eigen::Matrix<stan::math::var, Eigen::Dynamic, 1> variadic_eq_impl_test(
524521
const Eigen::Matrix<stan::math::var, Eigen::Dynamic, Eigen::Dynamic> A,
525522
const stan::math::var& y_1, const stan::math::var& y_2,
@@ -539,18 +536,18 @@ Eigen::Matrix<stan::math::var, Eigen::Dynamic, 1> variadic_eq_impl_test(
539536
Eigen::Matrix<var, Eigen::Dynamic, 1> theta;
540537

541538
theta = is_newton
542-
? use_tol ? solve_newton_tol(variadic_eq_functor(), x,
543-
relative_tolerance,
544-
function_tolerance, max_num_steps,
545-
&std::cout, A, y_1, y_2, y_3, i)
546-
: solve_newton(variadic_eq_functor(), x, &std::cout,
547-
A, y_1, y_2, y_3, i)
548-
: use_tol ? solve_powell_tol(variadic_eq_functor(), x,
549-
relative_tolerance,
550-
function_tolerance, max_num_steps,
551-
&std::cout, A, y_1, y_2, y_3, i)
552-
: solve_powell(variadic_eq_functor(), x, &std::cout,
553-
A, y_1, y_2, y_3, i);
539+
? use_tol ? solve_newton_tol(variadic_eq_functor(), x,
540+
relative_tolerance,
541+
function_tolerance, max_num_steps,
542+
&std::cout, A, y_1, y_2, y_3, i)
543+
: solve_newton(variadic_eq_functor(), x, &std::cout, A,
544+
y_1, y_2, y_3, i)
545+
: use_tol ? solve_powell_tol(variadic_eq_functor(), x,
546+
relative_tolerance,
547+
function_tolerance, max_num_steps,
548+
&std::cout, A, y_1, y_2, y_3, i)
549+
: solve_powell(variadic_eq_functor(), x, &std::cout, A,
550+
y_1, y_2, y_3, i);
554551

555552
EXPECT_NEAR(20, value_of(theta(0)), 1e-6);
556553
EXPECT_NEAR(2, value_of(theta(1)), 1e-6);

0 commit comments

Comments
 (0)