@@ -382,11 +382,7 @@ class deserializer {
382382 template <typename Ret, bool Jacobian, typename LB, typename LP,
383383 typename ... Sizes>
384384 inline auto read_constrain_lb (const LB& lb, LP& lp, Sizes... sizes) {
385- if (Jacobian) {
386- return stan::math::lb_constrain (this ->read <Ret>(sizes...), lb, lp);
387- } else {
388- return stan::math::lb_constrain (this ->read <Ret>(sizes...), lb);
389- }
385+ return stan::math::lb_constrain<Jacobian>(this ->read <Ret>(sizes...), lb, lp);
390386 }
391387
392388 /* *
@@ -408,11 +404,7 @@ class deserializer {
408404 template <typename Ret, bool Jacobian, typename UB, typename LP,
409405 typename ... Sizes>
410406 inline auto read_constrain_ub (const UB& ub, LP& lp, Sizes... sizes) {
411- if (Jacobian) {
412- return stan::math::ub_constrain (this ->read <Ret>(sizes...), ub, lp);
413- } else {
414- return stan::math::ub_constrain (this ->read <Ret>(sizes...), ub);
415- }
407+ return stan::math::ub_constrain<Jacobian>(this ->read <Ret>(sizes...), ub, lp);
416408 }
417409
418410 /* *
@@ -437,12 +429,8 @@ class deserializer {
437429 typename ... Sizes>
438430 inline auto read_constrain_lub (const LB& lb, const UB& ub, LP& lp,
439431 Sizes... sizes) {
440- if (Jacobian) {
441- return stan::math::lub_constrain (this ->read <Ret>(sizes...), lb, ub, lp);
442- } else {
443- return stan::math::lub_constrain (this ->read <Ret>(sizes...), lb, ub);
432+ return stan::math::lub_constrain<Jacobian>(this ->read <Ret>(sizes...), lb, ub, lp);
444433 }
445- }
446434
447435 /* *
448436 * Return the next object transformed to have the specified offset and
@@ -470,14 +458,8 @@ class deserializer {
470458 inline auto read_constrain_offset_multiplier (const Offset& offset,
471459 const Mult& multiplier, LP& lp,
472460 Sizes... sizes) {
473- using stan::math::offset_multiplier_constrain;
474- if (Jacobian) {
475- return offset_multiplier_constrain (this ->read <Ret>(sizes...), offset,
461+ return stan::math::offset_multiplier_constrain<Jacobian>(this ->read <Ret>(sizes...), offset,
476462 multiplier, lp);
477- } else {
478- return offset_multiplier_constrain (this ->read <Ret>(sizes...), offset,
479- multiplier);
480- }
481463 }
482464
483465 /* *
@@ -501,12 +483,7 @@ class deserializer {
501483 template <typename Ret, bool Jacobian, typename LP, typename ... Sizes,
502484 require_not_std_vector_t <Ret>* = nullptr >
503485 inline auto read_constrain_unit_vector (LP& lp, Sizes... sizes) {
504- using stan::math::unit_vector_constrain;
505- if (Jacobian) {
506- return math::eval (unit_vector_constrain (this ->read <Ret>(sizes...), lp));
507- } else {
508- return math::eval (unit_vector_constrain (this ->read <Ret>(sizes...)));
509- }
486+ return stan::math::eval (stan::math::unit_vector_constrain<Jacobian>(this ->read <Ret>(sizes...), lp));
510487 }
511488
512489 /* *
@@ -562,13 +539,8 @@ class deserializer {
562539 template <typename Ret, bool Jacobian, typename LP,
563540 require_not_std_vector_t <Ret>* = nullptr >
564541 inline auto read_constrain_simplex (LP& lp, size_t size) {
565- using stan::math::simplex_constrain;
566542 stan::math::check_positive (" read_simplex" , " size" , size);
567- if (Jacobian) {
568- return simplex_constrain (this ->read <Ret>(size - 1 ), lp);
569- } else {
570- return simplex_constrain (this ->read <Ret>(size - 1 ));
571- }
543+ return stan::math::simplex_constrain<Jacobian>(this ->read <Ret>(size - 1 ), lp);
572544 }
573545
574546 /* *
@@ -624,12 +596,7 @@ class deserializer {
624596 template <typename Ret, bool Jacobian, typename LP, typename ... Sizes,
625597 require_not_std_vector_t <Ret>* = nullptr >
626598 inline auto read_constrain_ordered (LP& lp, Sizes... sizes) {
627- using stan::math::ordered_constrain;
628- if (Jacobian) {
629- return ordered_constrain (this ->read <Ret>(sizes...), lp);
630- } else {
631- return ordered_constrain (this ->read <Ret>(sizes...));
632- }
599+ return stan::math::ordered_constrain<Jacobian>(this ->read <Ret>(sizes...), lp);
633600 }
634601
635602 /* *
@@ -684,12 +651,7 @@ class deserializer {
684651 template <typename Ret, bool Jacobian, typename LP, typename ... Sizes,
685652 require_not_std_vector_t <Ret>* = nullptr >
686653 inline auto read_constrain_positive_ordered (LP& lp, Sizes... sizes) {
687- using stan::math::positive_ordered_constrain;
688- if (Jacobian) {
689- return positive_ordered_constrain (this ->read <Ret>(sizes...), lp);
690- } else {
691- return positive_ordered_constrain (this ->read <Ret>(sizes...));
692- }
654+ return stan::math::positive_ordered_constrain<Jacobian>(this ->read <Ret>(sizes...), lp);
693655 }
694656
695657 /* *
@@ -745,17 +707,10 @@ class deserializer {
745707 require_matrix_t <Ret>* = nullptr >
746708 inline auto read_constrain_cholesky_factor_cov (LP& lp, Eigen::Index M,
747709 Eigen::Index N) {
748- if (Jacobian) {
749- return stan::math::cholesky_factor_constrain (
710+ return stan::math::cholesky_factor_constrain<Jacobian>(
750711 this ->read <conditional_var_val_t <Ret, vector_t >>((N * (N + 1 )) / 2
751712 + (M - N) * N),
752713 M, N, lp);
753- } else {
754- return stan::math::cholesky_factor_constrain (
755- this ->read <conditional_var_val_t <Ret, vector_t >>((N * (N + 1 )) / 2
756- + (M - N) * N),
757- M, N);
758- }
759714 }
760715
761716 /* *
@@ -811,16 +766,9 @@ class deserializer {
811766 template <typename Ret, bool Jacobian, typename LP,
812767 require_matrix_t <Ret>* = nullptr >
813768 inline auto read_constrain_cholesky_factor_corr (LP& lp, Eigen::Index K) {
814- using stan::math::cholesky_corr_constrain;
815- if (Jacobian) {
816- return cholesky_corr_constrain (
769+ return stan::math::cholesky_corr_constrain<Jacobian>(
817770 this ->read <conditional_var_val_t <Ret, vector_t >>((K * (K - 1 )) / 2 ),
818771 K, lp);
819- } else {
820- return cholesky_corr_constrain (
821- this ->read <conditional_var_val_t <Ret, vector_t >>((K * (K - 1 )) / 2 ),
822- K);
823- }
824772 }
825773
826774 /* *
@@ -875,18 +823,10 @@ class deserializer {
875823 template <typename Ret, bool Jacobian, typename LP,
876824 require_matrix_t <Ret>* = nullptr >
877825 inline auto read_constrain_cov_matrix (LP& lp, Eigen::Index k) {
878- using stan::math::cov_matrix_constrain;
879- if (Jacobian) {
880- return cov_matrix_constrain (
826+ return stan::math::cov_matrix_constrain<Jacobian>(
881827 this ->read <conditional_var_val_t <Ret, vector_t >>(k
882828 + (k * (k - 1 )) / 2 ),
883829 k, lp);
884- } else {
885- return cov_matrix_constrain (
886- this ->read <conditional_var_val_t <Ret, vector_t >>(k
887- + (k * (k - 1 )) / 2 ),
888- k);
889- }
890830 }
891831
892832 /* *
@@ -939,16 +879,9 @@ class deserializer {
939879 require_not_std_vector_t <Ret>* = nullptr ,
940880 require_matrix_t <Ret>* = nullptr >
941881 inline auto read_constrain_corr_matrix (LP& lp, Eigen::Index k) {
942- using stan::math::corr_matrix_constrain;
943- if (Jacobian) {
944- return corr_matrix_constrain (
882+ return stan::math::corr_matrix_constrain<Jacobian>(
945883 this ->read <conditional_var_val_t <Ret, vector_t >>((k * (k - 1 )) / 2 ),
946884 k, lp);
947- } else {
948- return corr_matrix_constrain (
949- this ->read <conditional_var_val_t <Ret, vector_t >>((k * (k - 1 )) / 2 ),
950- k);
951- }
952885 }
953886
954887 /* *
@@ -999,14 +932,8 @@ class deserializer {
999932 require_not_std_vector_t <Ret>* = nullptr ,
1000933 require_matrix_t <Ret>* = nullptr >
1001934 inline auto read_constrain_stochastic_column (LP& lp, Eigen::Index rows, Eigen::Index cols) {
1002- using stan::math::stochastic_column_constrain;
1003- if (Jacobian) {
1004- return stochastic_column_constrain (
935+ return stan::math::stochastic_column_constrain<Jacobian>(
1005936 this ->read <conditional_var_val_t <Ret, matrix_t >>(rows - 1 , cols), lp);
1006- } else {
1007- return stochastic_column_constrain (
1008- this ->read <conditional_var_val_t <Ret, matrix_t >>(rows - 1 , cols));
1009- }
1010937 }
1011938
1012939 /* *
@@ -1057,14 +984,8 @@ class deserializer {
1057984 require_not_std_vector_t <Ret>* = nullptr ,
1058985 require_matrix_t <Ret>* = nullptr >
1059986 inline auto read_constrain_stochastic_row (LP& lp, Eigen::Index rows, Eigen::Index cols) {
1060- using stan::math::stochastic_row_constrain;
1061- if (Jacobian) {
1062- return stochastic_row_constrain (
987+ return stan::math::stochastic_row_constrain<Jacobian>(
1063988 this ->read <conditional_var_val_t <Ret, matrix_t >>(rows, cols - 1 ), lp);
1064- } else {
1065- return stochastic_row_constrain (
1066- this ->read <conditional_var_val_t <Ret, matrix_t >>(rows, cols - 1 ));
1067- }
1068989 }
1069990
1070991 /* *
0 commit comments