@@ -82,8 +82,8 @@ struct laplace_options<true> : public laplace_options_base {
8282 Eigen::VectorXd theta_0{0 }; // 6
8383
8484 template <typename ThetaVec>
85- laplace_options (ThetaVec&& theta_0_,
86- double tolerance_, int max_num_steps_, int hessian_block_size_, int solver_,
85+ laplace_options (ThetaVec&& theta_0_, double tolerance_, int max_num_steps_,
86+ int hessian_block_size_, int solver_,
8787 int max_steps_line_search_, bool allow_fallthrough_)
8888 : laplace_options_base(hessian_block_size_, solver_, tolerance_,
8989 max_num_steps_, allow_fallthrough_,
@@ -130,7 +130,8 @@ inline constexpr auto tuple_to_laplace_options(Options&& ops) {
130130 static_assert (
131131 sizeof (std::decay_t <Ops>*) == 0 ,
132132 " ERROR:(laplace_marginal_lpdf) The third laplace argument is "
133- " expected to be an int representing the maximum number of steps for the laplace approximation." );
133+ " expected to be an int representing the maximum number of steps for "
134+ " the laplace approximation." );
134135 }
135136 if constexpr (!stan::is_inner_tuple_type_v<3 , Ops, int >) {
136137 static_assert (
@@ -148,7 +149,8 @@ inline constexpr auto tuple_to_laplace_options(Options&& ops) {
148149 static_assert (
149150 sizeof (std::decay_t <Ops>*) == 0 ,
150151 " ERROR:(laplace_marginal_lpdf) The sixth laplace argument is "
151- " expected to be an int representing the max steps for the laplace approximaton's wolfe line search." );
152+ " expected to be an int representing the max steps for the laplace "
153+ " approximaton's wolfe line search." );
152154 }
153155 constexpr bool is_fallthrough
154156 = stan::is_inner_tuple_type_v<
@@ -923,22 +925,23 @@ template <typename SolverPolicy, typename NewtonStateT, typename OptionsT,
923925inline auto run_newton_loop (SolverPolicy& solver, NewtonStateT& state,
924926 const OptionsT& options, Eigen::Index& step_iter,
925927 const LLFunT& ll_fun, const LLTupleArgsT& ll_args,
926- const CovarMatT& covariance,
927- UpdateFun&& update_fun,
928+ const CovarMatT& covariance, UpdateFun&& update_fun,
928929 std::ostream* msgs) {
929930 bool finish_update = false ;
930931 for (; step_iter <= options.max_num_steps ; step_iter++) {
931932 solver.solve_step (state, ll_fun, ll_args, covariance,
932933 options.hessian_block_size , msgs);
933934 if (!state.final_loop ) {
934935 state.wolfe_info .p_ = state.curr ().a () - state.prev ().a ();
935- state.prev_g .noalias () = -covariance * state.prev ().a () + covariance * state.prev ().theta_grad ();
936+ state.prev_g .noalias () = -covariance * state.prev ().a ()
937+ + covariance * state.prev ().theta_grad ();
936938 state.wolfe_info .init_dir_ = state.prev_g .dot (state.wolfe_info .p_ );
937939 // Flip direction if not ascending
938940 state.wolfe_info .flip_direction ();
939941 auto && scratch = state.wolfe_info .scratch_ ;
940942 scratch.alpha () = 1.0 ;
941- update_fun (scratch, state.curr (), state.prev (), scratch.eval_ , state.wolfe_info .p_ );
943+ update_fun (scratch, state.curr (), state.prev (), scratch.eval_ ,
944+ state.wolfe_info .p_ );
942945 bool run_convergence_check = true ;
943946 if (scratch.alpha () <= options.line_search .min_alpha ) {
944947 state.wolfe_status .accept_ = false ;
@@ -951,7 +954,9 @@ inline auto run_newton_loop(SolverPolicy& solver, NewtonStateT& state,
951954 run_convergence_check = false ;
952955 } else {
953956 Eigen::VectorXd s = scratch.a () - state.prev ().a ();
954- auto full_step_grad = (-covariance * scratch.a () + covariance * scratch.theta_grad ()).eval ();
957+ auto full_step_grad
958+ = (-covariance * scratch.a () + covariance * scratch.theta_grad ())
959+ .eval ();
955960 state.curr ().alpha () = barzilai_borwein_step_size (
956961 s, full_step_grad, state.prev_g , state.prev ().alpha (),
957962 state.wolfe_status .num_backtracks_ , options.line_search .min_alpha ,
@@ -964,8 +969,10 @@ inline auto run_newton_loop(SolverPolicy& solver, NewtonStateT& state,
964969 * Stop when objective change is small, or when a rejected Wolfe step
965970 * fails to improve; finish_update then exits the Newton loop.
966971 */
967- finish_update = std::abs (state.curr ().obj () - state.prev ().obj ()) < options.tolerance
968- || (!state.wolfe_status .accept_ && state.curr ().obj () <= state.prev ().obj ());
972+ finish_update = std::abs (state.curr ().obj () - state.prev ().obj ())
973+ < options.tolerance
974+ || (!state.wolfe_status .accept_
975+ && state.curr ().obj () <= state.prev ().obj ());
969976 }
970977 }
971978 if (finish_update) {
@@ -1116,7 +1123,9 @@ inline auto laplace_marginal_density_est(
11161123 proposal.theta ().noalias () = covariance * proposal.a ();
11171124 proposal.theta_grad () = theta_grad_f (proposal.theta ());
11181125 eval_in.obj () = obj_fun (proposal.a (), proposal.theta ());
1119- eval_in.dir () = (-covariance * proposal.a () + covariance * proposal.theta_grad ()).dot (p);
1126+ eval_in.dir ()
1127+ = (-covariance * proposal.a () + covariance * proposal.theta_grad ())
1128+ .dot (p);
11201129 return std::isfinite (eval_in.obj ()) && std::isfinite (eval_in.dir ());
11211130 } catch (const std::exception&) {
11221131 return false ;
0 commit comments