@@ -106,9 +106,8 @@ inline auto shallow_copy_vargs(Args&&... args) {
106106 */
107107template <typename F, typename Theta, typename Stream, typename ... Args,
108108 require_eigen_vector_vt<std::is_arithmetic, Theta>* = nullptr >
109- inline auto diff (F&& f, Theta&& theta,
110- const Eigen::Index hessian_block_size, Stream* msgs,
111- Args&&... args) {
109+ inline auto diff (F&& f, Theta&& theta, const Eigen::Index hessian_block_size,
110+ Stream* msgs, Args&&... args) {
112111 using Eigen::Dynamic;
113112 using Eigen::Matrix;
114113 const Eigen::Index theta_size = theta.size ();
@@ -122,18 +121,20 @@ inline auto diff(F&& f, Theta&& theta,
122121 if (hessian_block_size == 1 ) {
123122 auto v = Eigen::VectorXd::Ones (theta_size);
124123 Eigen::VectorXd hessian_v = Eigen::VectorXd::Zero (theta_size);
125- hessian_times_vector (f, hessian_v, theta, std::move (v), value_of (args)..., msgs);
124+ hessian_times_vector (f, hessian_v, theta, std::move (v), value_of (args)...,
125+ msgs);
126126 Eigen::SparseMatrix<double > hessian_theta (theta_size, theta_size);
127127 hessian_theta.reserve (Eigen::VectorXi::Constant (theta_size, 1 ));
128128 for (Eigen::Index i = 0 ; i < theta_size; i++) {
129129 hessian_theta.insert (i, i) = hessian_v (i);
130130 }
131131 return std::make_pair (std::move (theta_gradient), (-hessian_theta).eval ());
132132 } else {
133- return std::make_pair (std::move (theta_gradient),
134- (-hessian_block_diag (f, std::forward<Theta>(theta), hessian_block_size,
135- value_of (args)..., msgs))
136- .eval ());
133+ return std::make_pair (
134+ std::move (theta_gradient),
135+ (-hessian_block_diag (f, std::forward<Theta>(theta), hessian_block_size,
136+ value_of (args)..., msgs))
137+ .eval ());
137138 }
138139}
139140
@@ -237,8 +238,8 @@ inline auto compute_s2(F&& f, Theta&& theta, AMat&& A,
237238 */
238239template <typename F, typename V_t, typename Theta, typename Stream,
239240 typename ... Args, require_eigen_vector_t <Theta>* = nullptr >
240- inline auto diff_eta_implicit (F&& f, V_t&& v, Theta&& theta,
241- Stream* msgs, Args&&... args) {
241+ inline auto diff_eta_implicit (F&& f, V_t&& v, Theta&& theta, Stream* msgs,
242+ Args&&... args) {
242243 using Eigen::Dynamic;
243244 using Eigen::Matrix;
244245 using Eigen::VectorXd;
@@ -285,11 +286,12 @@ inline auto log_likelihood(F&& f, Theta&& theta, TupleArgs&& ll_tup,
285286 Stream* msgs) {
286287 return apply (
287288 [](auto && f, auto && theta, auto && msgs, auto &&... args) {
288- return internal::log_likelihood (std::forward< decltype (f)>(f),
289- std::forward<decltype (theta)>(theta),
290- msgs, std::forward<decltype (args)>(args)...);
289+ return internal::log_likelihood (
290+ std::forward< decltype (f)>(f), std::forward<decltype (theta)>(theta),
291+ msgs, std::forward<decltype (args)>(args)...);
291292 },
292- std::forward<TupleArgs>(ll_tup), std::forward<F>(f), std::forward<Theta>(theta), msgs);
293+ std::forward<TupleArgs>(ll_tup), std::forward<F>(f),
294+ std::forward<Theta>(theta), msgs);
293295}
294296
295297/* *
@@ -307,18 +309,17 @@ inline auto log_likelihood(F&& f, Theta&& theta, TupleArgs&& ll_tup,
307309template <typename F, typename Theta, typename TupleArgs, typename Stream,
308310 require_eigen_vector_t <Theta>* = nullptr ,
309311 require_tuple_t <TupleArgs>* = nullptr >
310- inline auto diff (F&& f, Theta&& theta,
311- const Eigen::Index hessian_block_size, TupleArgs&& ll_tuple,
312- Stream* msgs) {
312+ inline auto diff (F&& f, Theta&& theta, const Eigen::Index hessian_block_size,
313+ TupleArgs&& ll_tuple, Stream* msgs) {
313314 return apply (
314315 [](auto && f, auto && theta, auto hessian_block_size, auto * msgs,
315316 auto &&... args) {
316- return internal::diff (std::forward< decltype (f)>(f), std::forward< decltype (theta)>(theta),
317- hessian_block_size, msgs ,
318- std::forward<decltype (args)>(args)...);
317+ return internal::diff (
318+ std::forward< decltype (f)>(f), std::forward< decltype (theta)>(theta) ,
319+ hessian_block_size, msgs, std::forward<decltype (args)>(args)...);
319320 },
320- std::forward<TupleArgs>(ll_tuple), std::forward<F>(f), std::forward<Theta>(theta),
321- hessian_block_size, msgs);
321+ std::forward<TupleArgs>(ll_tuple), std::forward<F>(f),
322+ std::forward<Theta>(theta), hessian_block_size, msgs);
322323}
323324
324325/* *
@@ -334,12 +335,16 @@ inline auto diff(F&& f, Theta&& theta,
334335template <typename F, typename Theta, typename TupleArgs, typename Stream,
335336 require_eigen_vector_t <Theta>* = nullptr ,
336337 require_tuple_t <TupleArgs>* = nullptr >
337- inline Eigen::VectorXd third_diff (F&& f, Theta&& theta,
338- TupleArgs&& ll_args, Stream* msgs) {
338+ inline Eigen::VectorXd third_diff (F&& f, Theta&& theta, TupleArgs&& ll_args,
339+ Stream* msgs) {
339340 return apply (
340341 [](auto && f, auto && theta, auto && msgs, auto &&... args) {
341- return internal::third_diff (std::forward<decltype (f)>(f), std::forward<decltype (theta)>(theta), msgs, std::forward<decltype (args)>(args)...);
342- }, std::forward<TupleArgs>(ll_args), std::forward<F>(f), std::forward<Theta>(theta), msgs);
342+ return internal::third_diff (std::forward<decltype (f)>(f),
343+ std::forward<decltype (theta)>(theta), msgs,
344+ std::forward<decltype (args)>(args)...);
345+ },
346+ std::forward<TupleArgs>(ll_args), std::forward<F>(f),
347+ std::forward<Theta>(theta), msgs);
343348}
344349
345350/* *
@@ -356,22 +361,22 @@ inline Eigen::VectorXd third_diff(F&& f, Theta&& theta,
356361 * @param ll_args Variadic arguments for likelihood function.
357362 * @param msgs Streaming messages.
358363 */
359- template <typename F, typename Theta, typename AMat, typename TupleArgs, typename Stream,
360- require_eigen_vector_t <Theta>* = nullptr ,
364+ template <typename F, typename Theta, typename AMat, typename TupleArgs,
365+ typename Stream, require_eigen_vector_t <Theta>* = nullptr ,
361366 require_tuple_t <TupleArgs>* = nullptr >
362- inline auto compute_s2 (F&& f, Theta&& theta, AMat&& A,
363- int hessian_block_size, TupleArgs&& ll_args,
364- Stream* msgs) {
367+ inline auto compute_s2 (F&& f, Theta&& theta, AMat&& A, int hessian_block_size,
368+ TupleArgs&& ll_args, Stream* msgs) {
365369 return apply (
366370 [](auto && f, auto && theta, auto && A, auto hessian_block_size, auto * msgs,
367371 auto &&... args) {
368- return internal::compute_s2 (std::forward<decltype (f)>(f),
369- std::forward<decltype (theta)>(theta),
370- std::forward<decltype (A)>(A),
371- hessian_block_size, msgs,
372- std::forward<decltype (args)>(args)...);
373- }, std::forward<TupleArgs>(ll_args), std::forward<F>(f), std::forward<Theta>(theta), std::forward<AMat>(A),
374- hessian_block_size, msgs);
372+ return internal::compute_s2 (
373+ std::forward<decltype (f)>(f), std::forward<decltype (theta)>(theta),
374+ std::forward<decltype (A)>(A), hessian_block_size, msgs,
375+ std::forward<decltype (args)>(args)...);
376+ },
377+ std::forward<TupleArgs>(ll_args), std::forward<F>(f),
378+ std::forward<Theta>(theta), std::forward<AMat>(A), hessian_block_size,
379+ msgs);
375380}
376381
377382/* *
@@ -393,8 +398,13 @@ inline auto diff_eta_implicit(F&& f, V_t&& v, Theta&& theta,
393398 TupleArgs&& ll_args, Stream* msgs) {
394399 return apply (
395400 [](auto && f, auto && v, auto && theta, auto && msgs, auto &&... args) {
396- return internal::diff_eta_implicit (std::forward<decltype (f)>(f), std::forward<decltype (v)>(v), std::forward<decltype (theta)>(theta), msgs, std::forward<decltype (args)>(args)...);
397- }, std::forward<TupleArgs>(ll_args), std::forward<F>(f), std::forward<V_t>(v), std::forward<Theta>(theta), msgs);
401+ return internal::diff_eta_implicit (
402+ std::forward<decltype (f)>(f), std::forward<decltype (v)>(v),
403+ std::forward<decltype (theta)>(theta), msgs,
404+ std::forward<decltype (args)>(args)...);
405+ },
406+ std::forward<TupleArgs>(ll_args), std::forward<F>(f),
407+ std::forward<V_t>(v), std::forward<Theta>(theta), msgs);
398408}
399409
400410} // namespace laplace_likelihood
0 commit comments