Skip to content

Commit b02a08a

Browse files
committed
update wiener_full code to move reverse mode tests to reverse mode folder
1 parent 33e262b commit b02a08a

7 files changed

Lines changed: 158 additions & 157 deletions

File tree

stan/math/prim/prob/wiener4_lccdf_unnorm.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
253253
return ret_t(0.0);
254254
}
255255

256-
if (!include_summand<propto, T_y, T_a, T_t0, T_w, T_v>::value) {
256+
if constexpr (!include_summand<propto, T_y, T_a, T_t0, T_w, T_v>::value) {
257257
return ret_t(0.0);
258258
}
259259

@@ -324,21 +324,21 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
324324
const auto new_est_err
325325
= log_ccdf_single_value + log_error_derivative - LOG_FOUR;
326326

327-
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
327+
if constexpr (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
328328
const auto deriv_y = internal::estimate_with_err_check<5, 0>(
329329
[](auto&&... args) {
330330
return internal::wiener5_density<GradientCalc::ON>(args...);
331331
},
332332
new_est_err, y_value - t0_value, a_value, v_value, w_value, 0.0,
333333
log_error_absolute);
334-
if (!is_constant_all<T_y>::value) {
334+
if constexpr (!is_constant_all<T_y>::value) {
335335
partials<0>(ops_partials)[i] = -deriv_y / ccdf;
336336
}
337-
if (!is_constant_all<T_t0>::value) {
337+
if constexpr (!is_constant_all<T_t0>::value) {
338338
partials<2>(ops_partials)[i] = deriv_y / ccdf;
339339
}
340340
}
341-
if (!is_constant_all<T_a>::value) {
341+
if constexpr (!is_constant_all<T_a>::value) {
342342
partials<1>(ops_partials)[i]
343343
= internal::estimate_with_err_check<5, 0>(
344344
[](auto&&... args) {
@@ -348,7 +348,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
348348
log_error_absolute)
349349
/ ccdf;
350350
}
351-
if (!is_constant_all<T_w>::value) {
351+
if constexpr (!is_constant_all<T_w>::value) {
352352
partials<3>(ops_partials)[i]
353353
= internal::estimate_with_err_check<5, 0>(
354354
[](auto&&... args) {
@@ -358,7 +358,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
358358
log_error_absolute)
359359
/ ccdf;
360360
}
361-
if (!is_constant_all<T_v>::value) {
361+
if constexpr (!is_constant_all<T_v>::value) {
362362
partials<4>(ops_partials)[i]
363363
= internal::wiener4_ccdf_grad_v(y_value - t0_value, a_value, v_value,
364364
w_value, cdf, log_error_absolute)

stan/math/prim/prob/wiener4_lcdf_unnorm.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
610610
auto w_val = to_ref(as_value_column_array_or_scalar(w_ref));
611611
auto t0_val = to_ref(as_value_column_array_or_scalar(t0_ref));
612612

613-
if (!include_summand<propto, T_y, T_a, T_t0, T_w, T_v>::value) {
613+
if constexpr (!include_summand<propto, T_y, T_a, T_t0, T_w, T_v>::value) {
614614
return ret_t(0.0);
615615
}
616616

@@ -682,7 +682,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
682682

683683
const auto new_est_err = log_cdf + log_error_derivative - LOG_FOUR;
684684

685-
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
685+
if constexpr (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
686686
const auto deriv_y
687687
= internal::estimate_with_err_check<5, 0, GradientCalc::OFF,
688688
GradientCalc::ON>(
@@ -692,14 +692,14 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
692692
new_est_err, y_value - t0_value, a_value, v_value, w_value, 0,
693693
log_error_absolute);
694694

695-
if (!is_constant_all<T_y>::value) {
695+
if constexpr (!is_constant_all<T_y>::value) {
696696
partials<0>(ops_partials)[i] = deriv_y / cdf;
697697
}
698-
if (!is_constant_all<T_t0>::value) {
698+
if constexpr (!is_constant_all<T_t0>::value) {
699699
partials<2>(ops_partials)[i] = -deriv_y / cdf;
700700
}
701701
}
702-
if (!is_constant_all<T_a>::value) {
702+
if constexpr (!is_constant_all<T_a>::value) {
703703
partials<1>(ops_partials)[i]
704704
= internal::estimate_with_err_check<5, 0, GradientCalc::OFF,
705705
GradientCalc::ON>(
@@ -710,7 +710,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
710710
log_error_absolute)
711711
/ cdf;
712712
}
713-
if (!is_constant_all<T_w>::value) {
713+
if constexpr (!is_constant_all<T_w>::value) {
714714
partials<3>(ops_partials)[i]
715715
= internal::estimate_with_err_check<5, 0, GradientCalc::OFF,
716716
GradientCalc::ON>(
@@ -721,7 +721,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
721721
log_error_absolute)
722722
/ cdf;
723723
}
724-
if (!is_constant_all<T_v>::value) {
724+
if constexpr (!is_constant_all<T_v>::value) {
725725
partials<4>(ops_partials)[i]
726726
= internal::wiener4_cdf_grad_v(y_value - t0_value, a_value, v_value,
727727
w_value, cdf, log_error_absolute)

stan/math/prim/prob/wiener_full_lccdf_unnorm.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
119119
auto sw_val = to_ref(as_value_column_array_or_scalar(sw_ref));
120120
auto st0_val = to_ref(as_value_column_array_or_scalar(st0_ref));
121121

122-
if (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
122+
if constexpr (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
123123
T_st0>::value) {
124124
return ret_t(0.0);
125125
}
@@ -269,7 +269,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
269269
// the value as deriv_t to edge1 and as -deriv_t to edge5
270270

271271
// computation of derivatives and precision checks
272-
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
272+
if constexpr (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
273273
const T_partials_return deriv_t_7
274274
= -internal::wiener7_integrate_cdf<
275275
GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF,
@@ -281,15 +281,15 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
281281
maximal_evaluations_hcubature, absolute_error_hcubature,
282282
relative_error_hcubature / 2)
283283
/ ccdf;
284-
if (!is_constant_all<T_y>::value) {
284+
if constexpr (!is_constant_all<T_y>::value) {
285285
partials<0>(ops_partials)[i] = deriv_t_7;
286286
}
287-
if (!is_constant_all<T_t0>::value) {
287+
if constexpr (!is_constant_all<T_t0>::value) {
288288
partials<2>(ops_partials)[i] = -deriv_t_7;
289289
}
290290
}
291291
T_partials_return deriv;
292-
if (!is_constant_all<T_a>::value) {
292+
if constexpr (!is_constant_all<T_a>::value) {
293293
partials<1>(ops_partials)[i]
294294
= internal::wiener7_integrate_cdf(
295295
[&](auto&&... args) {
@@ -300,7 +300,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
300300
relative_error_hcubature / 2)
301301
/ ccdf;
302302
}
303-
if (!is_constant_all<T_w>::value) {
303+
if constexpr (!is_constant_all<T_w>::value) {
304304
partials<3>(ops_partials)[i]
305305
= internal::wiener7_integrate_cdf<GradientCalc::OFF,
306306
GradientCalc::ON>(
@@ -312,7 +312,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
312312
relative_error_hcubature / 2)
313313
/ ccdf;
314314
}
315-
if (!is_constant_all<T_v>::value) {
315+
if constexpr (!is_constant_all<T_v>::value) {
316316
partials<4>(ops_partials)[i]
317317
= internal::wiener7_integrate_cdf(
318318
[&](auto&&... args) {
@@ -323,7 +323,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
323323
relative_error_hcubature / 2)
324324
/ ccdf;
325325
}
326-
if (!is_constant_all<T_sv>::value) {
326+
if constexpr (!is_constant_all<T_sv>::value) {
327327
if (sv_value == 0) {
328328
partials<5>(ops_partials)[i] = 0.0;
329329
} else {
@@ -339,7 +339,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
339339
/ ccdf;
340340
}
341341
}
342-
if (!is_constant_all<T_sw>::value) {
342+
if constexpr (!is_constant_all<T_sw>::value) {
343343
if (sw_value == 0) {
344344
partials<6>(ops_partials)[i] = 0.0;
345345
} else {
@@ -367,7 +367,7 @@ inline auto wiener_lccdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
367367
partials<6>(ops_partials)[i] = deriv;
368368
}
369369
}
370-
if (!is_constant_all<T_st0>::value) {
370+
if constexpr (!is_constant_all<T_st0>::value) {
371371
if (st0_value == 0) {
372372
partials<7>(ops_partials)[i] = 0.0;
373373
} else if (y_value - (t0_value + st0_value) <= 0) {

stan/math/prim/prob/wiener_full_lcdf_unnorm.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
295295
auto sw_val = to_ref(as_value_column_array_or_scalar(sw_ref));
296296
auto st0_val = to_ref(as_value_column_array_or_scalar(st0_ref));
297297

298-
if (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
298+
if constexpr (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
299299
T_st0>::value) {
300300
return ret_t(0);
301301
}
@@ -446,7 +446,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
446446
// computation of derivative for t and precision check in order to give
447447
// the value as deriv_t to edge1 and as -deriv_t to edge5
448448

449-
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
449+
if constexpr (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
450450
T_partials_return deriv_t_7
451451
= internal::wiener7_integrate_cdf<
452452
GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF,
@@ -458,15 +458,15 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
458458
maximal_evaluations_hcubature, absolute_error_hcubature,
459459
relative_error_hcubature / 2)
460460
/ cdf;
461-
if (!is_constant_all<T_y>::value) {
461+
if constexpr (!is_constant_all<T_y>::value) {
462462
partials<0>(ops_partials)[i] = deriv_t_7;
463463
}
464-
if (!is_constant_all<T_t0>::value) {
464+
if constexpr (!is_constant_all<T_t0>::value) {
465465
partials<2>(ops_partials)[i] = -deriv_t_7;
466466
}
467467
}
468468
T_partials_return deriv;
469-
if (!is_constant_all<T_a>::value) {
469+
if constexpr (!is_constant_all<T_a>::value) {
470470
partials<1>(ops_partials)[i]
471471
= internal::wiener7_integrate_cdf(
472472
[&](auto&&... args) {
@@ -477,7 +477,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
477477
relative_error_hcubature / 2)
478478
/ cdf;
479479
}
480-
if (!is_constant_all<T_w>::value) {
480+
if constexpr (!is_constant_all<T_w>::value) {
481481
partials<3>(ops_partials)[i]
482482
= internal::wiener7_integrate_cdf<GradientCalc::OFF,
483483
GradientCalc::ON>(
@@ -489,7 +489,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
489489
relative_error_hcubature / 2)
490490
/ cdf;
491491
}
492-
if (!is_constant_all<T_v>::value) {
492+
if constexpr (!is_constant_all<T_v>::value) {
493493
partials<4>(ops_partials)[i]
494494
= internal::wiener7_integrate_cdf(
495495
[&](auto&&... args) {
@@ -500,7 +500,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
500500
relative_error_hcubature / 2)
501501
/ cdf;
502502
}
503-
if (!is_constant_all<T_sv>::value) {
503+
if constexpr (!is_constant_all<T_sv>::value) {
504504
if (sv_value == 0) {
505505
partials<5>(ops_partials)[i] = 0;
506506
} else {
@@ -516,7 +516,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
516516
/ cdf;
517517
}
518518
}
519-
if (!is_constant_all<T_sw>::value) {
519+
if constexpr (!is_constant_all<T_sw>::value) {
520520
if (sw_value == 0) {
521521
partials<6>(ops_partials)[i] = 0;
522522
} else {
@@ -544,7 +544,7 @@ inline auto wiener_lcdf_unnorm(const T_y& y, const T_a& a, const T_t0& t0,
544544
partials<6>(ops_partials)[i] = deriv;
545545
}
546546
}
547-
if (!is_constant_all<T_st0>::value) {
547+
if constexpr (!is_constant_all<T_st0>::value) {
548548
if (st0_value == 0) {
549549
partials<7>(ops_partials)[i] = 0;
550550
} else if (y_value - (t0_value + st0_value) <= 0) {

stan/math/prim/prob/wiener_full_lpdf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0,
352352
auto sw_val = to_ref(as_value_column_array_or_scalar(sw_ref));
353353
auto st0_val = to_ref(as_value_column_array_or_scalar(st0_ref));
354354

355-
if (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
355+
if constexpr (!include_summand<propto, T_y, T_a, T_v, T_w, T_t0, T_sv, T_sw,
356356
T_st0>::value) {
357357
return ret_t(0);
358358
}

0 commit comments

Comments
 (0)