@@ -44,7 +44,7 @@ let pp_unused = fmt "(void) %s; // suppress unused var warning"
4444 @param fname Name of the function.
4545 *)
4646let pp_function__ ppf (prog_name , fname ) =
47- pf ppf {|@ [< v> static const char * function__ = " %s_namespace::%s" ;@ ,% a@ ]| }
47+ pf ppf {|@ [< v> static constexpr char * function__ = " %s_namespace::%s" ;@ ,% a@ ]| }
4848 prog_name fname pp_unused " function__"
4949
5050(* * Print the body of exception handling for functions *)
@@ -217,10 +217,11 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _})
217217 in
218218 let pp_body ppf (Stmt.Fixed. ({pattern; _} ) as fdbody ) =
219219 pf ppf " @[<hv 8>using local_scalar_t__ = %a;@]@," pp_promoted_scalar fdargs ;
220+ pf ppf " int current_statement__ = 0; @ " ;
220221 if List. exists ~f: (fun (_ , _ , t ) -> UnsizedType. is_eigen_type t) fdargs
221222 then pp_eigen_arg_to_ref ppf fdargs ;
222223 if not (is_dist || is_lp) then (
223- pf ppf " %s@ " " const static bool propto__ = true;" ;
224+ pf ppf " %s@ " " static constexpr bool propto__ = true;" ;
224225 pf ppf " %s@ " " (void) propto__;" ) ;
225226 pf ppf " %s@ "
226227 " local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());" ;
@@ -397,6 +398,7 @@ let pp_ctor ppf p =
397398 in
398399 pp_block ppf
399400 ( (fun ppf {Program. prog_name; prepare_data; output_vars; _} ->
401+ pf ppf " int current_statement__ = 0;@ " ;
400402 pf ppf " using local_scalar_t__ = double ;@ " ;
401403 pf ppf " boost::ecuyer1988 base_rng__ = @ " ;
402404 pf ppf " stan::services::util::create_rng(random_seed__, 0);@ " ;
@@ -493,10 +495,11 @@ let pp_method_b ppf rt name params intro ?(outro = nop) ?(cv_attr = ["const"])
493495(* * Print the write_array method of the model class *)
494496let pp_write_array ppf {Program. prog_name; generate_quantities; _} =
495497 pf ppf
496- " template <typename RNG, typename VecR, typename VecI, typename VecVar, \
497- stan::require_vector_like_vt<std::is_floating_point, VecR>* = nullptr, \
498- stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr, \
499- stan::require_std_vector_vt<std::is_floating_point, VecVar>* = nullptr>" ;
498+ " template <typename RNG, typename VecR, typename VecI, typename VecVar, @ \
499+ stan::require_vector_like_vt<std::is_floating_point, VecR>* = nullptr, @ \
500+ stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr, @ \
501+ stan::require_std_vector_vt<std::is_floating_point, VecVar>* = nullptr> \
502+ @ " ;
500503 let params =
501504 [ " RNG& base_rng__" ; " VecR& params_r__" ; " VecI& params_i__"
502505 ; " VecVar& vars__" ; " const bool emit_transformed_parameters__ = true"
@@ -509,6 +512,7 @@ let pp_write_array ppf {Program.prog_name; generate_quantities; _} =
509512 ; " stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);"
510513 ; " double lp__ = 0.0;"
511514 ; " (void) lp__; // dummy to suppress unused var warning"
515+ ; " int current_statement__ = 0; "
512516 ; " stan::math::accumulator<double> lp_accum__;"
513517 ; " local_scalar_t__ \
514518 DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());" ]
@@ -637,17 +641,18 @@ let pp_unconstrained_param_names ppf {Program.output_vars; _} =
637641(* * Print the `transform_inits` method of the model class *)
638642let pp_transform_inits ppf {Program. transform_inits; _} =
639643 pf ppf
640- " template <typename VecVar, typename VecI, \
641- stan::require_std_vector_t<VecVar>* = nullptr, \
642- stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>" ;
644+ " template <typename VecVar, typename VecI, @ \
645+ stan::require_std_vector_t<VecVar>* = nullptr, @ \
646+ stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr> @ " ;
643647 let params =
644648 [ " const stan::io::var_context& context__" ; " VecI& params_i__"
645649 ; " VecVar& vars__" ; " std::ostream* pstream__ = nullptr" ]
646650 in
647651 let intro ppf () =
648652 pf ppf
649653 " using local_scalar_t__ = \
650- double;@,vars__.clear();@,vars__.reserve(num_params_r__);"
654+ double;@,vars__.clear();@,vars__.reserve(num_params_r__);@ int \
655+ current_statement__ = 0; "
651656 in
652657 let cv_attr = [" const" ] in
653658 pp_method_b ppf " void" " transform_inits_impl" params intro transform_inits
@@ -656,9 +661,9 @@ let pp_transform_inits ppf {Program.transform_inits; _} =
656661(* * Print the `log_prob` method of the model class *)
657662let pp_log_prob ppf Program. ({prog_name; log_prob; _} ) =
658663 pf ppf
659- " template <bool propto__, bool jacobian__, typename VecR, typename VecI, \
660- stan::require_vector_like_t<VecR>* = nullptr, \
661- stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>" ;
664+ " template <bool propto__, bool jacobian__ , typename VecR, typename VecI, \
665+ @ stan::require_vector_like_t<VecR>* = nullptr, @ \
666+ stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr> @ " ;
662667 let params =
663668 [ " VecR& params_r__" ; " VecI& params_i__"
664669 ; " std::ostream* pstream__ = nullptr" ]
@@ -669,6 +674,7 @@ let pp_log_prob ppf Program.({prog_name; log_prob; _}) =
669674 ; " using local_scalar_t__ = T__;" ; " T__ lp__(0.0);"
670675 ; " stan::math::accumulator<T__> lp_accum__;"
671676 ; " stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);"
677+ ; " int current_statement__ = 0;"
672678 ; " local_scalar_t__ \
673679 DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());" ]
674680 pp_unused " DUMMY_VAR__" pp_function__ (prog_name, " log_prob" )
0 commit comments