From f2afb935b0844c581276016ee318eb0fafcca942 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Sat, 9 May 2020 09:12:53 +0300 Subject: [PATCH 1/9] Add closures to AST and parser --- src/frontend/Ast.ml | 16 +++++++++++----- src/frontend/Ast_to_Mir.ml | 3 ++- src/frontend/Canonicalize.ml | 16 ++++++++++++---- src/frontend/Pretty_printing.ml | 2 +- src/frontend/Semantic_check.ml | 15 +++++++++++---- src/frontend/parser.mly | 19 +++++++++++++++++++ 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/frontend/Ast.ml b/src/frontend/Ast.ml index 89c13eddab..2550b0b8ec 100644 --- a/src/frontend/Ast.ml +++ b/src/frontend/Ast.ml @@ -116,7 +116,7 @@ type typed_lval = (typed_expression, typed_expr_meta) lval_with (** Statement shapes, where we substitute untyped_expression and untyped_statement for 'e and 's respectively to get untyped_statement and typed_expression and typed_statement to get typed_statement *) -type ('e, 's, 'l, 'f) statement = +type ('e, 's, 'l, 'f, 'c) statement = | Assignment of { assign_lhs: 'l ; assign_op: assignmentoperator @@ -155,6 +155,8 @@ type ('e, 's, 'l, 'f) statement = | FunDef of { returntype: Middle.UnsizedType.returntype ; funname: identifier + ; is_closure: bool + ; captures: 'c ; arguments: (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * identifier) list @@ -176,13 +178,14 @@ type statement_returntype = | AnyReturnType [@@deriving sexp, hash, compare] -type ('e, 'm, 'l, 'f) statement_with = - {stmt: ('e, ('e, 'm, 'l, 'f) statement_with, 'l, 'f) statement; smeta: 'm} +type ('e, 'm, 'l, 'f, 'c) statement_with = + { stmt: ('e, ('e, 'm, 'l, 'f, 'c) statement_with, 'l, 'f, 'c) statement + ; smeta: 'm } [@@deriving sexp, compare, map, hash] (** Untyped statements, which have location_spans as meta-data *) type untyped_statement = - (untyped_expression, located_meta, untyped_lval, unit) statement_with + (untyped_expression, located_meta, untyped_lval, unit, unit) statement_with [@@deriving sexp, compare, map, hash] let mk_untyped_statement ~stmt ~loc : untyped_statement = {stmt; smeta= {loc}} @@ -198,7 +201,9 @@ type typed_statement = ( typed_expression , stmt_typed_located_meta , typed_lval - , fun_kind ) + , fun_kind + , (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * identifier) list + ) statement_with [@@deriving sexp, compare, map, hash] @@ -246,6 +251,7 @@ let rec untyped_statement_of_typed_statement {stmt; smeta} = map_statement untyped_expression_of_typed_expression untyped_statement_of_typed_statement untyped_lvalue_of_typed_lvalue (fun _ -> ()) + (fun _ -> ()) stmt ; smeta= {loc= smeta.loc} } diff --git a/src/frontend/Ast_to_Mir.ml b/src/frontend/Ast_to_Mir.ml index d1f970c90d..9e413aa568 100644 --- a/src/frontend/Ast_to_Mir.ml +++ b/src/frontend/Ast_to_Mir.ml @@ -631,7 +631,8 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = let trans_fun_def ud_dists (ts : Ast.typed_statement) = match ts.stmt with - | Ast.FunDef {returntype; funname; arguments; body} -> + | Ast.FunDef + {returntype; funname; is_closure= _; captures= _; arguments; body} -> [ Program. { fdrt= (match returntype with Void -> None | ReturnType ut -> Some ut) diff --git a/src/frontend/Canonicalize.ml b/src/frontend/Canonicalize.ml index 7772b61e59..664cf3b9eb 100644 --- a/src/frontend/Canonicalize.ml +++ b/src/frontend/Canonicalize.ml @@ -89,7 +89,7 @@ let rec repair_syntax_stmt user_dists {stmt; smeta} = { stmt= map_statement repair_syntax_expr (repair_syntax_stmt user_dists) - repair_syntax_lval ident stmt + repair_syntax_lval ident ident stmt ; smeta } let rec replace_deprecated_expr {expr; emeta} = @@ -140,7 +140,13 @@ let rec replace_deprecated_stmt {stmt; smeta} = { assign_lhs= replace_deprecated_lval l ; assign_op= Assign ; assign_rhs= replace_deprecated_expr e } - | FunDef {returntype; funname= {name; id_loc}; arguments; body} -> + | FunDef + { returntype + ; funname= {name; id_loc} + ; is_closure + ; captures + ; arguments + ; body } -> FunDef { returntype ; funname= @@ -148,11 +154,13 @@ let rec replace_deprecated_stmt {stmt; smeta} = Option.value ~default:name (String.Table.find deprecated_userdefined name) ; id_loc } + ; is_closure + ; captures ; arguments ; body= replace_deprecated_stmt body } | _ -> map_statement replace_deprecated_expr replace_deprecated_stmt - replace_deprecated_lval ident stmt + replace_deprecated_lval ident ident stmt in {stmt; smeta} @@ -209,7 +217,7 @@ let rec parens_stmt {stmt; smeta} = ; lower_bound= keep_parens lower_bound ; upper_bound= keep_parens upper_bound ; loop_body= parens_stmt loop_body } - | _ -> map_statement no_parens parens_stmt parens_lval ident stmt + | _ -> map_statement no_parens parens_stmt parens_lval ident ident stmt in {stmt; smeta} diff --git a/src/frontend/Pretty_printing.ml b/src/frontend/Pretty_printing.ml index f7b2a1955e..fcdeee7772 100644 --- a/src/frontend/Pretty_printing.ml +++ b/src/frontend/Pretty_printing.ml @@ -354,7 +354,7 @@ and pp_statement ppf ({stmt= s_content; _} as ss) = with_hbox ppf (fun () -> Fmt.pf ppf "%a %a%a%a;" pp_transformed_type (pst, trans) pp_identifier id pp_array_dims es pp_init init ) - | FunDef {returntype= rt; funname= id; arguments= args; body= b} -> ( + | FunDef {returntype= rt; funname= id; arguments= args; body= b; _} -> ( Fmt.pf ppf "%a %a(" pp_returntype rt pp_identifier id ; with_box ppf 0 (fun () -> Fmt.pf ppf "%a" (Fmt.list ~sep:Fmt.comma pp_args) args ) ; diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 6643359613..1c4684d99a 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -1585,7 +1585,7 @@ and semantic_check_fundef_return_tys ~loc id return_type body = then ok () else error @@ Semantic_error.incompatible_return_types loc) -and semantic_check_fundef ~loc ~cf return_ty id args body = +and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = let uargs = List.map args ~f:(fun (at, ut, id) -> Validate.( @@ -1652,7 +1652,13 @@ and semantic_check_fundef ~loc ~cf return_ty id args body = (* WARNING: SIDE EFFECTING *) Symbol_table.end_scope vm ; let stmt = - FunDef {returntype= urt; funname= id; arguments= uargs; body= ub} + FunDef + { returntype= urt + ; funname= id + ; is_closure + ; captures= [] + ; arguments= uargs + ; body= ub } in mk_typed_statement ~return_type:NoReturnType ~loc ~stmt )) @@ -1692,8 +1698,9 @@ and semantic_check_statement cf (s : Ast.untyped_statement) : ; is_global } -> semantic_check_var_decl ~loc ~cf st transformation identifier initial_value is_global - | FunDef {returntype; funname; arguments; body} -> - semantic_check_fundef ~loc ~cf returntype funname arguments body + | FunDef {returntype; funname; is_closure; captures= (); arguments; body} -> + semantic_check_fundef ~loc ~cf returntype funname is_closure arguments + body (* == Untyped programs ====================================================== *) diff --git a/src/frontend/parser.mly b/src/frontend/parser.mly index 3c80f535e9..ac69830a9d 100644 --- a/src/frontend/parser.mly +++ b/src/frontend/parser.mly @@ -176,6 +176,21 @@ function_def: { grammar_logger "function_def" ; {stmt=FunDef {returntype = rt; funname = name; + is_closure = false; + captures = (); + arguments = args; body=b;}; + smeta={loc=Location_span.of_positions_exn $startpos $endpos} + } + } + +closure_def: + | FUNCTIONBLOCK rt=return_type name=decl_identifier + LPAREN args=separated_list(COMMA, arg_decl) RPAREN b=statement + { + grammar_logger "function_def" ; + {stmt=FunDef {returntype = rt; funname = name; + is_closure = true; + captures = (); arguments = args; body=b;}; smeta={loc=Location_span.of_positions_exn $startpos $endpos} } @@ -635,9 +650,13 @@ vardecl_or_statement: { grammar_logger "vardecl_or_statement_statement" ; s } | v=var_decl { grammar_logger "vardecl_or_statement_vardecl" ; v } + | f=closure_def + { grammar_logger "vardecl_or_statement_vardecl" ; f } top_vardecl_or_statement: | s=statement { grammar_logger "top_vardecl_or_statement_statement" ; s } | v=top_var_decl { grammar_logger "top_vardecl_or_statement_top_vardecl" ; v } + | f=closure_def + { grammar_logger "vardecl_or_statement_vardecl" ; f } From 309fb6a74c2ad93d57c91c66c9b40e16dd1a5ec5 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Sat, 9 May 2020 12:11:34 +0300 Subject: [PATCH 2/9] find captures during sematic checking --- src/frontend/Ast.ml | 2 +- src/frontend/Pretty_printing.ml | 2 +- src/frontend/Semantic_check.ml | 186 ++++++++++-------- src/frontend/Semantic_error.ml | 21 +- src/frontend/Semantic_error.mli | 2 + src/frontend/Symbol_table.ml | 62 ++++-- src/frontend/Symbol_table.mli | 4 + src/middle/Stan_math_signatures.ml | 41 ++-- src/middle/UnsizedType.ml | 8 +- src/stan_math_backend/Expression_gen.ml | 3 +- test/integration/bad/closures/closure_lp.stan | 10 + test/integration/bad/closures/closure_lpdf | 10 + test/integration/bad/closures/closure_lpmf | 10 + .../integration/bad/closures/closure_rng.stan | 10 + test/integration/bad/closures/dune | 1 + .../bad/closures/forward-declaration.stan | 12 ++ test/integration/bad/closures/mutate1.stan | 12 ++ test/integration/bad/closures/mutate2.stan | 12 ++ test/integration/bad/closures/shadowing.stan | 19 ++ test/integration/bad/closures/stanc.expected | 84 ++++++++ .../bad/compound-assign/stanc.expected | 14 +- test/integration/bad/for_loops/stanc.expected | 16 +- test/integration/bad/stanc.expected | 2 +- test/integration/good/code-gen/mir.expected | 30 +-- 24 files changed, 411 insertions(+), 162 deletions(-) create mode 100644 test/integration/bad/closures/closure_lp.stan create mode 100644 test/integration/bad/closures/closure_lpdf create mode 100644 test/integration/bad/closures/closure_lpmf create mode 100644 test/integration/bad/closures/closure_rng.stan create mode 100644 test/integration/bad/closures/dune create mode 100644 test/integration/bad/closures/forward-declaration.stan create mode 100644 test/integration/bad/closures/mutate1.stan create mode 100644 test/integration/bad/closures/mutate2.stan create mode 100644 test/integration/bad/closures/shadowing.stan create mode 100644 test/integration/bad/closures/stanc.expected diff --git a/src/frontend/Ast.ml b/src/frontend/Ast.ml index 2550b0b8ec..b3ac390906 100644 --- a/src/frontend/Ast.ml +++ b/src/frontend/Ast.ml @@ -202,7 +202,7 @@ type typed_statement = , stmt_typed_located_meta , typed_lval , fun_kind - , (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * identifier) list + , (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * string) list ) statement_with [@@deriving sexp, compare, map, hash] diff --git a/src/frontend/Pretty_printing.ml b/src/frontend/Pretty_printing.ml index fcdeee7772..efebef7a45 100644 --- a/src/frontend/Pretty_printing.ml +++ b/src/frontend/Pretty_printing.ml @@ -66,7 +66,7 @@ and pp_unsizedtype ppf = function let ut2, d = unwind_array_type ut in let array_str = "[" ^ String.make d ',' ^ "]" in Fmt.(suffix (const string array_str) pp_unsizedtype ppf ut2) - | UFun (argtypes, rt) -> + | UFun (argtypes, rt, _) -> Fmt.pf ppf "{|@[(%a) => %a@]|}" Fmt.(list ~sep:comma_no_break pp_argtype) argtypes pp_returntype rt diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 1c4684d99a..820ac8e80f 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -168,7 +168,7 @@ let semantic_check_autodifftype at = Validate.ok at (* Probably nothing to do here *) let rec semantic_check_unsizedtype : UnsizedType.t -> unit Validate.t = function - | UFun (l, rt) -> + | UFun (l, rt, _) -> (* fold over argument types accumulating errors with initial state given by validating the return type *) List.fold @@ -272,10 +272,10 @@ let mk_fun_app ~is_cond_dist (x, y, z) = let semantic_check_fn_normal ~is_cond_dist ~loc id es = Validate.( match Symbol_table.look vm id.name with - | Some (_, UnsizedType.UFun (_, Void)) -> + | Some (_, UnsizedType.UFun (_, Void, _)) -> Semantic_error.returning_fn_expected_nonreturning_found loc id.name |> error - | Some (_, UFun (listedtypes, rt)) + | Some (_, UFun (listedtypes, rt, _)) when not (UnsizedType.check_compatible_arguments_mod_conv id.name listedtypes (get_arg_types es)) -> @@ -284,7 +284,7 @@ let semantic_check_fn_normal ~is_cond_dist ~loc id es = |> Semantic_error.illtyped_userdefined_fn_app loc id.name listedtypes rt |> error - | Some (_, UFun (_, ReturnType ut)) -> + | Some (_, UFun (_, ReturnType ut, _)) -> mk_typed_expression ~expr:(mk_fun_app ~is_cond_dist (UserDefined, id, es)) ~ad_level:(lub_ad_e es) ~type_:ut ~loc @@ -329,7 +329,8 @@ let semantic_check_reduce_sum ~is_cond_dist ~loc id es = UnsizedType.UFun ( ((_, sliced_arg_fun_type) as sliced_arg_fun) :: (_, UInt) :: (_, UInt) :: fun_args - , ReturnType UReal ); _ }; _ } + , ReturnType UReal + , _ ); _ }; _ } :: sliced :: {emeta= {type_= UInt; _}; _} :: args when arg_match sliced_arg_fun sliced && List.mem Stan_math_signatures.reduce_sum_slice_types @@ -859,20 +860,20 @@ let semantic_check_nrfn_target ~loc ~cf id = let semantic_check_nrfn_normal ~loc id es = Validate.( match Symbol_table.look vm id.name with - | Some (_, UFun (listedtypes, Void)) + | Some (_, UFun (listedtypes, Void, _)) when UnsizedType.check_compatible_arguments_mod_conv id.name listedtypes (get_arg_types es) -> mk_typed_statement ~stmt:(NRFunApp (UserDefined, id, es)) ~return_type:NoReturnType ~loc |> ok - | Some (_, UFun (listedtypes, Void)) -> + | Some (_, UFun (listedtypes, Void, _)) -> es |> List.map ~f:type_of_expr_typed |> Semantic_error.illtyped_userdefined_fn_app loc id.name listedtypes Void |> error - | Some (_, UFun (_, ReturnType _)) -> + | Some (_, UFun (_, ReturnType _, _)) -> Semantic_error.nonreturning_fn_expected_returning_found loc id.name |> error | Some _ -> @@ -1058,7 +1059,7 @@ let semantic_check_sampling_distribution ~loc id arguments = |> Option.value_map ~default:false ~f:is_real_rt and valid_arg_types_for_suffix suffix = match Symbol_table.look vm (name ^ suffix) with - | Some (Functions, UFun (listedtypes, ReturnType UReal)) -> + | Some (Functions, UFun (listedtypes, ReturnType UReal, _)) -> UnsizedType.check_compatible_arguments_mod_conv name listedtypes argumenttypes | _ -> false @@ -1088,7 +1089,7 @@ let cumulative_density_is_defined id arguments = |> Option.value_map ~default:false ~f:is_real_rt and valid_arg_types_for_suffix suffix = match Symbol_table.look vm (name ^ suffix) with - | Some (Functions, UFun (listedtypes, ReturnType UReal)) -> + | Some (Functions, UFun (listedtypes, ReturnType UReal, _)) -> UnsizedType.check_compatible_arguments_mod_conv name listedtypes argumenttypes | _ -> false @@ -1272,18 +1273,20 @@ and semantic_check_while ~loc ~cf e s = ue us (* -- For Statements -------------------------------------------------------- *) -and semantic_check_loop_body ~cf loop_var loop_var_ty loop_body = - Symbol_table.begin_scope vm ; - let is_fresh_var = check_fresh_variable loop_var false in - Symbol_table.enter vm loop_var.name (cf.current_block, loop_var_ty) ; - (* Check that function args and loop identifiers are not modified in - function. (passed by const ref) *) - Symbol_table.set_read_only vm loop_var.name ; - let us = - semantic_check_statement {cf with loop_depth= cf.loop_depth + 1} loop_body - |> Validate.apply_const is_fresh_var - in - Symbol_table.end_scope vm ; us +and semantic_check_loop_body ~cf loop_var loop_var_ty = + Symbol_table.with_scope vm (fun loop_body -> + let is_fresh_var = check_fresh_variable loop_var false in + Symbol_table.enter vm loop_var.name (cf.current_block, loop_var_ty) ; + (* Check that function args and loop identifiers are not modified in + function. (passed by const ref) *) + Symbol_table.set_read_only vm loop_var.name ; + let us = + semantic_check_statement + {cf with loop_depth= cf.loop_depth + 1} + loop_body + |> Validate.apply_const is_fresh_var + in + us ) and semantic_check_for ~loc ~cf loop_var lower_bound_e upper_bound_e loop_body = @@ -1370,14 +1373,14 @@ and try_compute_block_statement_returntype loc srt1 srt2 = Validate.ok AnyReturnType and semantic_check_block ~loc ~cf stmts = - Symbol_table.begin_scope vm ; (* Any statements after a break or continue or return or reject do not count for the return type. *) let validated_stmts = - List.map ~f:(semantic_check_statement cf) stmts |> Validate.sequence + stmts + |> Symbol_table.with_scope vm (List.map ~f:(semantic_check_statement cf)) + |> Validate.sequence in - Symbol_table.end_scope vm ; Validate.( validated_stmts >>= fun xs -> @@ -1485,12 +1488,12 @@ and semantic_check_var_decl ~loc ~cf sized_ty trans id init is_global = mk_typed_statement ~stmt ~loc ~return_type:NoReturnType )) (* -- Function definitions -------------------------------------------------- *) -and semantic_check_fundef_overloaded ~loc id arg_tys rt = +and semantic_check_fundef_overloaded ~loc is_closure id arg_tys rt = Validate.( (* User defined functions cannot be overloaded *) - if Symbol_table.check_is_unassigned vm id.name then + if (not is_closure) && Symbol_table.check_is_unassigned vm id.name then match Symbol_table.look vm id.name with - | Some (Functions, UFun (arg_tys', rt')) + | Some (Functions, UFun (arg_tys', rt', _)) when arg_tys' = arg_tys && rt' = rt -> ok () | _ -> @@ -1501,11 +1504,12 @@ and semantic_check_fundef_overloaded ~loc id arg_tys rt = else check_fresh_variable id (List.length arg_tys = 0)) (** WARNING: side effecting *) -and semantic_check_fundef_decl ~loc id body = +and semantic_check_fundef_decl ~loc is_closure id body = Validate.( match body with | {stmt= Skip; _} -> - if Symbol_table.check_is_unassigned vm id.name then + if is_closure then error @@ Semantic_error.invalid_forward_decl loc + else if Symbol_table.check_is_unassigned vm id.name then error @@ Semantic_error.fn_decl_without_def loc else let () = Symbol_table.set_is_unassigned vm id.name in @@ -1514,6 +1518,17 @@ and semantic_check_fundef_decl ~loc id body = Symbol_table.set_is_assigned vm id.name ; ok ()) +and semantic_check_fundef_suffix ~loc is_closure id = + Validate.( + let is_special = + List.exists + ~f:(fun x -> String.is_suffix id.name ~suffix:x) + ["_log"; "_lpdf"; "_lpmf"; "_lcdf"; "_lccdf"; "_rng"; "_lp"] + in + if is_closure && is_special then + error @@ Semantic_error.invalid_special_fn loc + else ok ()) + and semantic_check_fundef_dist_rt ~loc id return_ty = Validate.( let is_dist = @@ -1582,7 +1597,7 @@ and semantic_check_fundef_return_tys ~loc id return_type body = if Symbol_table.check_is_unassigned vm id.name || check_of_compatible_return_type return_type body.smeta.return_type - then ok () + then ok body else error @@ Semantic_error.incompatible_return_types loc) and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = @@ -1604,59 +1619,70 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = let uarg_types = List.map ~f:(fun (w, y, _) -> (w, y)) uargs in let uarg_identifiers = List.map ~f:(fun (_, _, z) -> z) uargs in let uarg_names = List.map ~f:(fun x -> x.name) uarg_identifiers in - semantic_check_fundef_overloaded ~loc id uarg_types urt - |> apply_const (semantic_check_fundef_decl ~loc id body) - >>= fun _ -> + semantic_check_fundef_overloaded ~loc is_closure id uarg_types urt + |> apply_const (semantic_check_fundef_decl ~loc is_closure id body) + >>= fun () -> (* WARNING: SIDE EFFECTING *) - Symbol_table.enter vm id.name (Functions, UFun (uarg_types, urt)) ; - (* Check that function args and loop identifiers are not modified in - function. (passed by const ref)*) - List.iter ~f:(Symbol_table.set_read_only vm) uarg_names ; - semantic_check_fundef_dist_rt ~loc id urt + Symbol_table.enter vm id.name + ( Functions + , UFun (uarg_types, urt, if is_closure then Closure else Function) ) ; + Symbol_table.set_read_only vm id.name ; + semantic_check_fundef_suffix ~loc:id.id_loc is_closure id + |> apply_const (semantic_check_fundef_dist_rt ~loc id urt) |> apply_const (semantic_check_pdf_fundef_first_arg_ty ~loc id uarg_types) |> apply_const (semantic_check_pmf_fundef_first_arg_ty ~loc id uarg_types) - >>= fun _ -> - (* WARNING: SIDE EFFECTING *) - Symbol_table.begin_scope vm ; - List.map ~f:(fun x -> check_fresh_variable x false) uarg_identifiers - |> sequence - |> apply_const (semantic_check_fundef_distinct_arg_ids ~loc uarg_names) - >>= fun _ -> - (* TODO: Bob was suggesting that function arguments must be allowed to - shadow user defined functions but not library functions. - Should we allow for that? - *) - (* We treat DataOnly arguments as if they are data and AutoDiffable arguments - as if they are parameters, for the purposes of type checking. - *) - (* WARNING: SIDE EFFECTING *) - let _ : unit Base.List.Or_unequal_lengths.t = - List.iter2 ~f:(Symbol_table.enter vm) uarg_names - (List.map - ~f:(function - | UnsizedType.DataOnly, ut -> (Data, ut) - | AutoDiffable, ut -> (Param, ut)) - uarg_types) - and context = - { cf with - in_fun_def= true - ; in_rng_fun_def= String.is_suffix id.name ~suffix:"_rng" - ; in_lp_fun_def= String.is_suffix id.name ~suffix:"_lp" - ; in_returning_fun_def= urt <> Void } - in - let body' = semantic_check_statement context body in - body' - >>= fun ub -> - semantic_check_fundef_return_tys ~loc id urt ub - |> map ~f:(fun _ -> - (* WARNING: SIDE EFFECTING *) - Symbol_table.end_scope vm ; + >>= Symbol_table.with_closure vm (fun captures () -> + List.map + ~f:(fun x -> + Symbol_table.set_read_only vm x.name ; + check_fresh_variable x false ) + uarg_identifiers + |> sequence + |> map ~f:(List.iter ~f:Fn.id) + |> apply_const + (semantic_check_fundef_distinct_arg_ids ~loc uarg_names) + >>= fun () -> + (* TODO: Bob was suggesting that function arguments must be allowed to + shadow user defined functions but not library functions. + Should we allow for that? + *) + (* We treat DataOnly arguments as if they are data and AutoDiffable arguments + as if they are parameters, for the purposes of type checking. + *) + (* WARNING: SIDE EFFECTING *) + let _ : unit = + List.iter2_exn ~f:(Symbol_table.enter vm) uarg_names + (List.map + ~f:(function + | UnsizedType.DataOnly, ut -> (Data, ut) + | AutoDiffable, ut -> (Param, ut)) + uarg_types) + and context = + { cf with + in_fun_def= true + ; in_rng_fun_def= String.is_suffix id.name ~suffix:"_rng" + ; in_lp_fun_def= String.is_suffix id.name ~suffix:"_lp" + ; in_returning_fun_def= urt <> Void } + in + semantic_check_statement context body + >>= fun ub -> + semantic_check_fundef_return_tys ~loc id urt ub + |> map ~f:(fun ub -> (ub, Set.to_list !captures)) ) + |> map ~f:(fun (ub, captures) -> let stmt = FunDef { returntype= urt ; funname= id ; is_closure - ; captures= [] + ; captures= + List.filter_map captures ~f:(fun name -> + match Symbol_table.look vm name with + | None | Some (Functions, UFun (_, _, Function)) -> None + | Some (block, type_) -> + Symbol_table.set_read_only vm name ; + Some + (calculate_autodifftype block type_, type_, name) + ) ; arguments= uargs ; body= ub } in @@ -1773,9 +1799,11 @@ let semantic_check_program let upb = semantic_check_ostatements_in_block ~cf Param pb in let utpb = semantic_check_ostatements_in_block ~cf TParam tpb in (* Model top level variables only assigned and read in model *) - Symbol_table.begin_scope vm ; - let umb = semantic_check_ostatements_in_block ~cf Model mb in - Symbol_table.end_scope vm ; + let umb = + Symbol_table.with_scope vm + (semantic_check_ostatements_in_block ~cf Model) + mb + in let ugb = semantic_check_ostatements_in_block ~cf GQuant gb in let mk_typed_prog ufb udb utdb upb utpb umb ugb : Ast.typed_program = { functionblock= ufb diff --git a/src/frontend/Semantic_error.ml b/src/frontend/Semantic_error.ml index a354a0d5fc..0a1a969558 100644 --- a/src/frontend/Semantic_error.ml +++ b/src/frontend/Semantic_error.ml @@ -101,7 +101,8 @@ module TypeError = struct [ [ UnsizedType.UFun ( List.hd_exn args :: (AutoDiffable, UInt) :: (AutoDiffable, UInt) :: List.tl_exn args - , ReturnType UReal ) ] + , ReturnType UReal + , Function ) ] ; first; [UInt]; rest ] in Fmt.pf ppf @@ -186,7 +187,7 @@ module TypeError = struct signatures:%a\n\ @[Instead supplied arguments of incompatible type: %a.@]" name UnsizedType.pp - (UFun (listed_tys, return_ty)) + (UFun (listed_tys, return_ty, Function)) Fmt.(list UnsizedType.pp ~sep:comma) arg_tys | IllTypedBinaryOperator (op, lt, rt) -> @@ -297,11 +298,12 @@ module StatementError = struct | ProbMassNonIntVariate of UnsizedType.t option | DuplicateArgNames | IncompatibleReturnType + | InvalidForwardDecl + | SpecialClosure let pp ppf = function | CannotAssignToReadOnly name -> - Fmt.pf ppf - "Cannot assign to function argument or loop identifier '%s'." name + Fmt.pf ppf "Cannot assign to read-only identifier '%s'." name | CannotAssignToGlobal name -> Fmt.pf ppf "Cannot assign to global variable '%s' declared in previous blocks." @@ -396,6 +398,12 @@ For example, "target += normal_lpdf(y, 0, 1)" should become "y ~ normal(0, 1)." Fmt.pf ppf "Function bodies must contain a return statement of correct type in \ every branch." + | InvalidForwardDecl -> + Fmt.pf ppf "Cannot declare a closure without definition." + | SpecialClosure -> + Fmt.pf ppf + "Cannot declare a closure with suffix _lpdf, _lpmf, _log, _lcdf, \ + _lccdf, _rng or _lp." end type t = @@ -588,3 +596,8 @@ let duplicate_arg_names loc = let incompatible_return_types loc = StatementError (loc, StatementError.IncompatibleReturnType) + +let invalid_forward_decl loc = + StatementError (loc, StatementError.InvalidForwardDecl) + +let invalid_special_fn loc = StatementError (loc, StatementError.SpecialClosure) diff --git a/src/frontend/Semantic_error.mli b/src/frontend/Semantic_error.mli index 5765b2332b..99141fb63e 100644 --- a/src/frontend/Semantic_error.mli +++ b/src/frontend/Semantic_error.mli @@ -108,3 +108,5 @@ val prob_density_non_real_variate : val prob_mass_non_int_variate : Location_span.t -> UnsizedType.t option -> t val duplicate_arg_names : Location_span.t -> t val incompatible_return_types : Location_span.t -> t +val invalid_forward_decl : Location_span.t -> t +val invalid_special_fn : Location_span.t -> t diff --git a/src/frontend/Symbol_table.ml b/src/frontend/Symbol_table.ml index a6d975ae21..7730f29612 100644 --- a/src/frontend/Symbol_table.ml +++ b/src/frontend/Symbol_table.ml @@ -10,6 +10,8 @@ type 'a state = ; scopedepth: int ref ; readonly: (string, unit) Hashtbl.t ; isunassigned: (string, unit) Hashtbl.t + ; locals: (string, unit) Hashtbl.t ref + ; captures: String.Set.t ref ; globals: (string, unit) Hashtbl.t } let initialize () = @@ -18,17 +20,22 @@ let initialize () = ; scopedepth= ref 0 ; readonly= String.Table.create () ; isunassigned= String.Table.create () + ; locals= ref (String.Table.create ()) + ; captures= ref String.Set.empty ; globals= String.Table.create () } let enter s str ty = - let _ : [`Duplicate | `Ok] = - if !(s.scopedepth) = 0 then Hashtbl.add s.globals ~key:str ~data:() - else `Ok - in + if !(s.scopedepth) = 0 then + ignore (Hashtbl.add s.globals ~key:str ~data:() : [`Duplicate | `Ok]) ; + let _ : [`Duplicate | `Ok] = Hashtbl.add !(s.locals) ~key:str ~data:() in let _ : [`Duplicate | `Ok] = Hashtbl.add s.table ~key:str ~data:ty in Stack.push s.stack str -let look s str = Hashtbl.find s.table str +let look s str = + ( match Hashtbl.find !(s.locals) str with + | None -> s.captures := Set.add !(s.captures) str + | Some () -> () ) ; + Hashtbl.find s.table str let begin_scope s = s.scopedepth := !(s.scopedepth) + 1 ; @@ -41,34 +48,47 @@ let end_scope s = (* we pop the stack down to where we entered the current scope and remove all variables defined since from the var map *) Hashtbl.remove s.table (Stack.top_exn s.stack) ; Hashtbl.remove s.readonly (Stack.top_exn s.stack) ; + Hashtbl.remove !(s.locals) (Stack.top_exn s.stack) ; Hashtbl.remove s.isunassigned (Stack.top_exn s.stack) ; - let _ : string = Stack.pop_exn s.stack in - () + Stack.pop_exn s.stack |> (ignore : string -> unit) done ; - let _ : string = Stack.pop_exn s.stack in - () + Stack.pop_exn s.stack |> (ignore : string -> unit) + +let with_scope s f x = + begin_scope s ; + let x = f x in + end_scope s ; x + +let with_closure s f x = + let locals = !(s.locals) in + let captures = !(s.captures) in + s.locals := String.Table.create () ; + s.captures := String.Set.empty ; + begin_scope s ; + let x = f s.captures x in + end_scope s ; + s.locals := locals ; + s.captures := captures ; + x let set_read_only s str = - let _ : [`Duplicate | `Ok] = Hashtbl.add s.readonly ~key:str ~data:() in - () + Hashtbl.add s.readonly ~key:str ~data:() + |> (ignore : [`Duplicate | `Ok] -> unit) let get_read_only s str = - match Hashtbl.find s.readonly str with Some () -> true | _ -> false + Option.( + is_some (Hashtbl.find s.readonly str) + || not (is_some (Hashtbl.find !(s.locals) str))) let set_is_assigned s str = Hashtbl.remove s.isunassigned str let set_is_unassigned s str = - let _ : [`Duplicate | `Ok] = - if Hashtbl.mem s.isunassigned str then `Ok - else Hashtbl.add s.isunassigned ~key:str ~data:() - in - () + Hashtbl.add s.isunassigned ~key:str ~data:() + |> (ignore : [`Duplicate | `Ok] -> unit) let check_is_unassigned s str = Hashtbl.mem s.isunassigned str let check_some_id_is_unassigned s = not (Hashtbl.length s.isunassigned = 0) - -let is_global s str = - match Hashtbl.find s.globals str with Some _ -> true | _ -> false +let is_global s str = Option.is_some (Hashtbl.find s.globals str) let unsafe_clear_symbol_table s = Hashtbl.clear s.table ; @@ -76,4 +96,6 @@ let unsafe_clear_symbol_table s = s.scopedepth := 0 ; Hashtbl.clear s.readonly ; Hashtbl.clear s.isunassigned ; + s.captures := String.Set.empty ; + Hashtbl.clear !(s.locals) ; Hashtbl.clear s.globals diff --git a/src/frontend/Symbol_table.mli b/src/frontend/Symbol_table.mli index 60dae7583a..5176189e96 100644 --- a/src/frontend/Symbol_table.mli +++ b/src/frontend/Symbol_table.mli @@ -18,6 +18,10 @@ val begin_scope : 'a state -> unit val end_scope : 'a state -> unit (** Used to end a local scope, purging the symbol table of all symbols added in that scope *) +val with_scope : 'a state -> ('b -> 'c) -> 'b -> 'c + +val with_closure : 'a state -> (Core_kernel.String.Set.t ref -> 'b -> 'c) -> 'b -> 'c + val set_read_only : 'a state -> string -> unit (** Used to add a read only label to an identifier *) diff --git a/src/middle/Stan_math_signatures.ml b/src/middle/Stan_math_signatures.ml index 6363d57b02..e39dc41055 100644 --- a/src/middle/Stan_math_signatures.ml +++ b/src/middle/Stan_math_signatures.ml @@ -1,5 +1,6 @@ (** The signatures of the Stan Math library, which are used for type checking *) open Core_kernel + (** The "dimensionality" (bad name?) is supposed to help us represent the vectorized nature of many Stan functions. It allows us to represent when a function argument can be just a real or matrix, or some common forms of @@ -138,9 +139,7 @@ let mk_declarative_sig (fnkinds, name, args) = let full_lpdf = [Lpdf; Rng; Ccdf; Cdf] let full_lpmf = [Lpmf; Rng; Ccdf; Cdf] - let reduce_sum_functions = ["reduce_sum"; "reduce_sum_static"] - let is_reduce_sum_fn f = List.mem ~equal:String.equal reduce_sum_functions f let distributions = @@ -338,7 +337,7 @@ let get_sigs name = let name = Utils.stdlib_distribution_name name in Hashtbl.find_multi stan_math_signatures name |> List.sort ~compare -let pp_math_sig ppf (rt, args) = UnsizedType.pp ppf (UFun (args, rt)) +let pp_math_sig ppf (rt, args) = UnsizedType.pp ppf (UFun (args, rt, Function)) let pp_math_sigs ppf name = (Fmt.list ~sep:Fmt.cut pp_math_sig) ppf (get_sigs name) @@ -451,7 +450,8 @@ let () = , UFun ( [ (AutoDiffable, UVector); (AutoDiffable, UVector) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType UVector ) ) + , ReturnType UVector + , Function ) ) ; (AutoDiffable, UVector); (AutoDiffable, UVector) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] ) ; add_qualified @@ -461,7 +461,8 @@ let () = , UFun ( [ (AutoDiffable, UVector); (AutoDiffable, UVector) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType UVector ) ) + , ReturnType UVector + , Function ) ) ; (AutoDiffable, UVector); (AutoDiffable, UVector) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt); (DataOnly, UReal) ; (DataOnly, UReal); (DataOnly, UReal) ] ) ; @@ -983,7 +984,8 @@ let () = ( [ (AutoDiffable, UReal); (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType UReal ) ) + , ReturnType UReal + , Function ) ) ; (AutoDiffable, UReal); (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] ) ; @@ -995,7 +997,8 @@ let () = ( [ (AutoDiffable, UReal); (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType UReal ) ) + , ReturnType UReal + , Function ) ) ; (AutoDiffable, UReal); (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt); (DataOnly, UReal) ] @@ -1009,7 +1012,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1024,7 +1028,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1039,7 +1044,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1055,7 +1061,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1070,7 +1077,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1086,7 +1094,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1101,7 +1110,8 @@ let () = ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) ) ) + , ReturnType (UArray UReal) + , Function ) ) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) @@ -1186,7 +1196,8 @@ let () = , UFun ( [ (AutoDiffable, UVector); (AutoDiffable, UVector) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType UVector ) ) + , ReturnType UVector + , Function ) ) ; (AutoDiffable, UVector) ; (AutoDiffable, UArray UVector) ; (DataOnly, UArray (UArray UReal)) diff --git a/src/middle/UnsizedType.ml b/src/middle/UnsizedType.ml index f2e032338a..72fd8a15ab 100644 --- a/src/middle/UnsizedType.ml +++ b/src/middle/UnsizedType.ml @@ -8,9 +8,11 @@ type t = | URowVector | UMatrix | UArray of t - | UFun of (autodifftype * t) list * returntype + | UFun of (autodifftype * t) list * returntype * functiontype | UMathLibraryFunction +and functiontype = Function | Closure + and autodifftype = DataOnly | AutoDiffable and returntype = Void | ReturnType of t [@@deriving compare, hash, sexp] @@ -36,7 +38,7 @@ let rec pp ppf = function let ty, depth = unsized_array_depth ut in let commas = String.make depth ',' in Fmt.pf ppf "%a[%s]" pp ty commas - | UFun (argtypes, rt) -> + | UFun (argtypes, rt, _) -> Fmt.pf ppf {|@[(%a) => %a@]|} Fmt.(list pp_fun_arg ~sep:comma) argtypes pp_returntype rt @@ -61,7 +63,7 @@ let check_of_same_type_mod_conv name t1 t2 = else match (t1, t2) with | UReal, UInt -> true - | UFun (l1, rt1), UFun (l2, rt2) -> + | UFun (l1, rt1, _), UFun (l2, rt2, _) -> rt1 = rt2 && List.for_all ~f:(fun x -> x = true) diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index 25f744feed..19db6c1999 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -260,8 +260,7 @@ and read_data ut ppf es = match ut with | UnsizedType.UArray UInt -> "i" | UArray UReal -> "r" - | UInt | UReal | UVector | URowVector | UMatrix | UArray _ - |UFun (_, _) + | UInt | UReal | UVector | URowVector | UMatrix | UArray _ | UFun _ |UMathLibraryFunction -> raise_s [%message "Can't ReadData of " (ut : UnsizedType.t)] in diff --git a/test/integration/bad/closures/closure_lp.stan b/test/integration/bad/closures/closure_lp.stan new file mode 100644 index 0000000000..6b97d05d98 --- /dev/null +++ b/test/integration/bad/closures/closure_lp.stan @@ -0,0 +1,10 @@ +parameters { + real y; +} +model { + functions + real foo_lp(real x) { + return x + 1; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/closure_lpdf b/test/integration/bad/closures/closure_lpdf new file mode 100644 index 0000000000..36465326e4 --- /dev/null +++ b/test/integration/bad/closures/closure_lpdf @@ -0,0 +1,10 @@ +parameters { + real y; +} +model { + functions + real foo_lpdf(real x) { + return x + 1; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/closure_lpmf b/test/integration/bad/closures/closure_lpmf new file mode 100644 index 0000000000..71068c69f6 --- /dev/null +++ b/test/integration/bad/closures/closure_lpmf @@ -0,0 +1,10 @@ +parameters { + real y; +} +model { + functions + real foo_lpmf(int x) { + return x + 1; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/closure_rng.stan b/test/integration/bad/closures/closure_rng.stan new file mode 100644 index 0000000000..aa21b729bf --- /dev/null +++ b/test/integration/bad/closures/closure_rng.stan @@ -0,0 +1,10 @@ +parameters { + real y; +} +model { + functions + real foo_rng(real x) { + return x + 1; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/dune b/test/integration/bad/closures/dune new file mode 100644 index 0000000000..856a7fccef --- /dev/null +++ b/test/integration/bad/closures/dune @@ -0,0 +1 @@ +(include ../dune) diff --git a/test/integration/bad/closures/forward-declaration.stan b/test/integration/bad/closures/forward-declaration.stan new file mode 100644 index 0000000000..3b97e4c7b7 --- /dev/null +++ b/test/integration/bad/closures/forward-declaration.stan @@ -0,0 +1,12 @@ +parameters { + real y; +} +model { + functions + real foo(real x); + functions + real foo(real x) { + return x + 1; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/mutate1.stan b/test/integration/bad/closures/mutate1.stan new file mode 100644 index 0000000000..89173a0048 --- /dev/null +++ b/test/integration/bad/closures/mutate1.stan @@ -0,0 +1,12 @@ +parameters { + real y; +} +model { + real x = 0.0; + functions + real foo(real z) { + x = 2; + return x + z; + } + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/mutate2.stan b/test/integration/bad/closures/mutate2.stan new file mode 100644 index 0000000000..22b1dbe0f8 --- /dev/null +++ b/test/integration/bad/closures/mutate2.stan @@ -0,0 +1,12 @@ +parameters { + real y; +} +model { + real x = 0.0; + functions + real foo(real z) { + return x + z; + } + x = 2; + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/shadowing.stan b/test/integration/bad/closures/shadowing.stan new file mode 100644 index 0000000000..8537bc99e5 --- /dev/null +++ b/test/integration/bad/closures/shadowing.stan @@ -0,0 +1,19 @@ +functions { + real foo(real x); + real bar(real y) { + functions + real foo(real z) { + return z - 1; + } + return foo(y); + } + real foo(real x) { + return x + 1; + } +} +parameters { + real y; +} +model { + y ~ normal(0,1); +} \ No newline at end of file diff --git a/test/integration/bad/closures/stanc.expected b/test/integration/bad/closures/stanc.expected new file mode 100644 index 0000000000..3e3e3b3144 --- /dev/null +++ b/test/integration/bad/closures/stanc.expected @@ -0,0 +1,84 @@ + $ ../../../../../install/default/bin/stanc closure_lp.stan + +Semantic error in 'closure_lp.stan', line 6, column 7 to column 13: + ------------------------------------------------- + 4: model { + 5: functions + 6: real foo_lp(real x) { + ^ + 7: return x + 1; + 8: } + ------------------------------------------------- + +Cannot declare a closure with suffix _lpdf, _lpmf, _log, _lcdf, _lccdf, _rng or _lp. + + $ ../../../../../install/default/bin/stanc closure_rng.stan + +Semantic error in 'closure_rng.stan', line 6, column 7 to column 14: + ------------------------------------------------- + 4: model { + 5: functions + 6: real foo_rng(real x) { + ^ + 7: return x + 1; + 8: } + ------------------------------------------------- + +Cannot declare a closure with suffix _lpdf, _lpmf, _log, _lcdf, _lccdf, _rng or _lp. + + $ ../../../../../install/default/bin/stanc forward-declaration.stan + +Semantic error in 'forward-declaration.stan', line 5, column 2 to line 6, column 19: + ------------------------------------------------- + 3: } + 4: model { + 5: functions + ^ + 6: real foo(real x); + 7: functions + ------------------------------------------------- + +Cannot declare a closure without definition. + + $ ../../../../../install/default/bin/stanc mutate1.stan + +Semantic error in 'mutate1.stan', line 8, column 6 to column 12: + ------------------------------------------------- + 6: functions + 7: real foo(real z) { + 8: x = 2; + ^ + 9: return x + z; + 10: } + ------------------------------------------------- + +Cannot assign to read-only identifier 'x'. + + $ ../../../../../install/default/bin/stanc mutate2.stan + +Semantic error in 'mutate2.stan', line 10, column 2 to column 8: + ------------------------------------------------- + 8: return x + z; + 9: } + 10: x = 2; + ^ + 11: y ~ normal(0,1); + 12: } + ------------------------------------------------- + +Cannot assign to read-only identifier 'x'. + + $ ../../../../../install/default/bin/stanc shadowing.stan + +Semantic error in 'shadowing.stan', line 5, column 9 to column 12: + ------------------------------------------------- + 3: real bar(real y) { + 4: functions + 5: real foo(real z) { + ^ + 6: return z - 1; + 7: } + ------------------------------------------------- + +Identifier 'foo' is already in use. + diff --git a/test/integration/bad/compound-assign/stanc.expected b/test/integration/bad/compound-assign/stanc.expected index 9d70e1f414..c932444943 100644 --- a/test/integration/bad/compound-assign/stanc.expected +++ b/test/integration/bad/compound-assign/stanc.expected @@ -75,19 +75,7 @@ Semantic error in 'plus_equals_bad_var_lhs.stan', line 3, column 4 to column 14: 5: } ------------------------------------------------- -Ill-typed arguments supplied to assignment operator +=: lhs has type (real) => real and rhs has type real. Available signatures: -(int, int) => void -(real, int) => void -(real, real) => void -(vector, int) => void -(vector, real) => void -(vector, vector) => void -(row_vector, int) => void -(row_vector, real) => void -(row_vector, row_vector) => void -(matrix, int) => void -(matrix, real) => void -(matrix, matrix) => void +Cannot assign to read-only identifier 'foo'. $ ../../../../../install/default/bin/stanc plus_equals_bad_var_lhs2.stan diff --git a/test/integration/bad/for_loops/stanc.expected b/test/integration/bad/for_loops/stanc.expected index 1db1ebbdf6..2cc2667178 100644 --- a/test/integration/bad/for_loops/stanc.expected +++ b/test/integration/bad/for_loops/stanc.expected @@ -10,7 +10,7 @@ Semantic error in 'assign_to_loop_var1.stan', line 5, column 18 to column 24: 7: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var2.stan @@ -24,7 +24,7 @@ Semantic error in 'assign_to_loop_var2.stan', line 5, column 18 to column 24: 7: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var3.stan @@ -38,7 +38,7 @@ Semantic error in 'assign_to_loop_var3.stan', line 6, column 6 to column 15: 8: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var4.stan @@ -52,7 +52,7 @@ Semantic error in 'assign_to_loop_var4.stan', line 5, column 6 to column 12: 7: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var5.stan @@ -66,7 +66,7 @@ Semantic error in 'assign_to_loop_var5.stan', line 5, column 6 to column 14: 7: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var6.stan @@ -80,7 +80,7 @@ Semantic error in 'assign_to_loop_var6.stan', line 4, column 4 to column 12: 6: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc assign_to_loop_var7.stan @@ -108,7 +108,7 @@ Semantic error in 'for_statements_bad_indices0.stan', line 5, column 20 to colum 7: return 0; ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc for_statements_bad_indices1.stan @@ -136,7 +136,7 @@ Semantic error in 'for_statements_bad_indices2.stan', line 5, column 20 to colum 7: return 0; ------------------------------------------------- -Cannot assign to function argument or loop identifier 'v'. +Cannot assign to read-only identifier 'v'. $ ../../../../../install/default/bin/stanc for_statements_bad_indices3.stan diff --git a/test/integration/bad/stanc.expected b/test/integration/bad/stanc.expected index 65157d459b..6ac093155b 100644 --- a/test/integration/bad/stanc.expected +++ b/test/integration/bad/stanc.expected @@ -1171,7 +1171,7 @@ Semantic error in 'functions-bad13.stan', line 3, column 4 to column 10: 5: } ------------------------------------------------- -Cannot assign to function argument or loop identifier 'x'. +Cannot assign to read-only identifier 'x'. $ ../../../../install/default/bin/stanc functions-bad14.stan diff --git a/test/integration/good/code-gen/mir.expected b/test/integration/good/code-gen/mir.expected index 9236f71b75..7727f754f4 100644 --- a/test/integration/good/code-gen/mir.expected +++ b/test/integration/good/code-gen/mir.expected @@ -5281,7 +5281,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -5303,7 +5303,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -5331,7 +5331,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -5359,7 +5359,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -5381,7 +5381,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -5409,7 +5409,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -5431,7 +5431,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -6591,7 +6591,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (DataOnly (UArray UReal)) (DataOnly (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var tmp)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -7892,7 +7892,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -7914,7 +7914,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -7942,7 +7942,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x)) (meta ((type_ UVector) (loc ) (adlevel DataOnly)))) @@ -7970,7 +7970,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -7992,7 +7992,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -8020,7 +8020,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) @@ -8042,7 +8042,7 @@ (UFun ((AutoDiffable UVector) (AutoDiffable UVector) (AutoDiffable (UArray UReal)) (AutoDiffable (UArray UInt))) - (ReturnType UVector))) + (ReturnType UVector) Function)) (loc ) (adlevel AutoDiffable)))) ((pattern (Var x_p)) (meta ((type_ UVector) (loc ) (adlevel AutoDiffable)))) From 618ea96ad7df9cb5c15036fa274c1d63e2622df3 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Mon, 11 May 2020 13:43:20 +0300 Subject: [PATCH 3/9] initial closure codegen --- src/frontend/Ast_to_Mir.ml | 52 +- src/middle/Internal_fun.ml | 1 + src/middle/Program.ml | 20 +- src/stan_math_backend/Expression_gen.ml | 17 + src/stan_math_backend/Stan_math_code_gen.ml | 148 +- src/stan_math_backend/Statement_gen.ml | 3 + src/stan_math_backend/Transform_Mir.ml | 16 +- test/integration/good/code-gen/cl.expected | 4 + test/integration/good/code-gen/closure.stan | 28 + test/integration/good/code-gen/cpp.expected | 1330 +++++++++++++++++ test/integration/good/code-gen/mir.expected | 3 +- .../good/compiler-optimizations/cpp.expected | 16 + test/unit/Optimize.ml | 5 +- test/unit/Stan_math_code_gen_tests.ml | 2 +- 14 files changed, 1611 insertions(+), 34 deletions(-) create mode 100644 test/integration/good/code-gen/closure.stan diff --git a/src/frontend/Ast_to_Mir.ml b/src/frontend/Ast_to_Mir.ml index 9e413aa568..383338247b 100644 --- a/src/frontend/Ast_to_Mir.ml +++ b/src/frontend/Ast_to_Mir.ml @@ -1,6 +1,8 @@ open Core_kernel open Middle +let closures = ref String.Map.empty + (* XXX fix exn *) let unwrap_return_exn = function | Some (UnsizedType.ReturnType ut) -> ut @@ -612,10 +614,52 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = ; meta= smeta } in Stmt.Helpers.[ensure_var (for_each bodyfn) iteratee' smeta] - | Ast.FunDef _ -> + | Ast.FunDef {is_closure= false; _} -> raise_s [%message "Found function definition statement outside of function block"] + | Ast.FunDef + {returntype; funname; is_closure= true; captures; arguments; body} -> + let clname = Fmt.strf "closure%d" (Map.length !closures) in + let type_ = + UnsizedType.UFun + (List.map arguments ~f:(fun (a, t, _) -> (a, t)), returntype, Closure) + in + ( match + Map.add !closures ~key:clname + ~data: + { Program.cdrt= + ( match returntype with + | Void -> None + | ReturnType ut -> Some ut ) + ; cdcaptures= List.map captures ~f:(fun (a, t, n) -> (a, n, t)) + ; cdargs= List.map arguments ~f:trans_arg + ; cdbody= trans_stmt body |> unwrap_block_or_skip } + with + | `Ok x -> closures := x + | `Duplicate -> () ) ; + [ Stmt. + { Fixed.pattern= + Decl + { decl_adtype= declc.dadlevel + ; decl_id= funname.name + ; decl_type= Unsized type_ } + ; meta= smeta } + ; { pattern= + Assignment + ( (funname.name, type_, []) + , Expr. + { pattern= + FunApp + ( CompilerInternal + , Internal_fun.to_string FnMakeClosure + , Helpers.str clname + :: List.map captures ~f:(fun (adlevel, type_, id) -> + { Fixed.pattern= Var id + ; meta= {Typed.Meta.type_; adlevel; loc= smeta} + } ) ) + ; meta= {type_; adlevel= declc.dadlevel; loc= smeta} } ) + ; meta= smeta } ] | Ast.VarDecl {decl_type; transformation; identifier; initial_value; is_global} -> ignore is_global ; @@ -632,7 +676,8 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = let trans_fun_def ud_dists (ts : Ast.typed_statement) = match ts.stmt with | Ast.FunDef - {returntype; funname; is_closure= _; captures= _; arguments; body} -> + {returntype; funname; is_closure= false; captures= []; arguments; body} + -> [ Program. { fdrt= (match returntype with Void -> None | ReturnType ut -> Some ut) @@ -766,7 +811,8 @@ let trans_prog filename (p : Ast.typed_program) : Program.Typed.t = let transform_inits = gen_from_block {declc with dconstrain= Some Unconstrain} Parameters in - { functions_block= map (trans_fun_def ud_dists) functionblock + { closures= !closures + ; functions_block= map (trans_fun_def ud_dists) functionblock ; input_vars ; prepare_data ; log_prob diff --git a/src/middle/Internal_fun.ml b/src/middle/Internal_fun.ml index e889bedf49..6d955aa460 100644 --- a/src/middle/Internal_fun.ml +++ b/src/middle/Internal_fun.ml @@ -4,6 +4,7 @@ type t = | FnLength | FnMakeArray | FnMakeRowVec + | FnMakeClosure | FnNegInf | FnReadData (* XXX move these to a backend specific file?*) diff --git a/src/middle/Program.ml b/src/middle/Program.ml index 5b93470ff4..2bd11525ef 100644 --- a/src/middle/Program.ml +++ b/src/middle/Program.ml @@ -5,6 +5,13 @@ open Helpers type fun_arg_decl = (UnsizedType.autodifftype * string * UnsizedType.t) list [@@deriving sexp, hash, map] +type 'a closure_def = + { cdrt: UnsizedType.t option + ; cdcaptures: (UnsizedType.autodifftype * string * UnsizedType.t) list + ; cdargs: (UnsizedType.autodifftype * string * UnsizedType.t) list + ; cdbody: 'a } +[@@deriving compare, hash, map, sexp, map, fold] + type 'a fun_def = { fdrt: UnsizedType.t option ; fdname: string @@ -42,8 +49,19 @@ type 'e outvar = ; out_trans: 'e transformation } [@@deriving sexp, map, hash, fold] +module StringMap = struct + include String.Map + + let map f = map ~f + + let fold f init = + let f ~key:_ ~data accum = f accum data in + fold ~init ~f +end + type ('a, 'b) t = - { functions_block: 'b fun_def list + { closures: 'b closure_def StringMap.t + ; functions_block: 'b fun_def list ; input_vars: (string * 'a SizedType.t) list ; prepare_data: 'b list (* data & transformed data decls and statements *) ; log_prob: 'b list (*assumes data & params are in scope and ready*) diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index 19db6c1999..2c988b7ceb 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -48,6 +48,12 @@ let rec local_scalar ut ad = | _, UnsizedType.DataOnly | UInt, AutoDiffable -> stantype_prim_str ut | _, AutoDiffable -> "local_scalar_t__" +let rec captured_scalar ut ad = + match (ut, ad) with + | UnsizedType.UArray t, _ -> captured_scalar t ad + | _, UnsizedType.DataOnly | UInt, AutoDiffable -> stantype_prim_str ut + | _, AutoDiffable -> "captured_t__" + let minus_one e = { e with Expr.Fixed.pattern= @@ -101,6 +107,11 @@ let pp_unsizedtype_local ppf (adtype, ut) = let s = local_scalar ut adtype in pp_unsizedtype_custom_scalar ppf (s, ut) +let pp_unsizedtype_captured ppf (adtype, ut) = + let s = captured_scalar ut adtype in + pp_unsizedtype_custom_scalar ppf (s, ut) + + let pp_expr_type ppf e = pp_unsizedtype_local ppf Expr.Typed.(adlevel_of e, type_of e) @@ -359,6 +370,12 @@ and pp_compiler_internal_fn ut f ppf es = raise_s [%message "Unexpected type for row vector literal" (ut : UnsizedType.t)] ) + | Some FnMakeClosure -> ( + match es with + | {Expr.Fixed.pattern= Lit (Str, clname); _} :: captures -> + pf ppf "@[%s__(@,%a)@]" clname + (list ~sep:comma pp_expr) captures + | _ -> raise_s [%message "Bad closure " (es : Expr.Typed.t list)] ) | Some FnConstrain -> pp_constrain_funapp "constrain" ppf es | Some FnUnconstrain -> pp_constrain_funapp "free" ppf es | Some FnReadData -> read_data ut ppf es diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 8e9f476176..d26927b387 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -85,6 +85,17 @@ let pp_returntype ppf arg_types rt = | Some ut -> pf ppf "%a@," pp_unsizedtype_custom_scalar (scalar, ut) | None -> pf ppf "void@," +let pp_returntype_closure ppf (arg_types, rt) = + let scalar = + strf "typename boost::math::tools::promote_args::type" + pp_promoted_scalar arg_types + in + match rt with + | Some ut when contains_int ut -> + pf ppf "%a@," pp_unsizedtype_custom_scalar ("int", ut) + | Some ut -> pf ppf "%a@," pp_unsizedtype_custom_scalar (scalar, ut) + | None -> pf ppf "void@," + (** [pp_located_error ppf (pp_body_block, body_block, err_msg)] surrounds [body_block] with a C++ try-catch that will rethrow the error with the proper source location from the [body_block] (required to be a [stmt_loc Block] variant).*) @@ -124,7 +135,7 @@ let pp_template_decorator ppf = function (* XXX refactor this please - one idea might be to have different functions for printing user defined distributions vs rngs vs regular functions. *) -let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) +let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure funs_used_in_reduce_sum = let is_lp = is_user_lp fdname in let is_dist = is_user_dist fdname in @@ -181,26 +192,93 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) pp_sig ppf fdname ; match Stmt.Fixed.(fdbody.pattern) with | Skip -> pf ppf ";@ " - | _ -> ( + | _ -> pp_block ppf (pp_body, fdbody) ; - pf ppf "@,@,struct %s%s {@,%a const @,{@,return %a;@,}@,};@," fdname - functor_suffix pp_sig "operator()" pp_call_str - ( fdname - , List.map ~f:(fun (_, name, _) -> name) fdargs @ extra @ ["pstream__"] - ) ; - if String.Set.mem funs_used_in_reduce_sum fdname then - (* Produces the reduce_sum functors that has the pstream argument - as the third and not last argument *) - match fdargs with - | (_, slice, _) :: (_, start, _) :: (_, end_, _) :: rest -> - pf ppf "@,@,struct %s%s {@,%a const @,{@,return %a;@,}@,};@," - fdname reduce_sum_functor_suffix pp_sig_rs "operator()" - pp_call_str - ( (if is_dist then fdname ^ "" else fdname) - , slice :: (start ^ " + 1") :: (end_ ^ " + 1") - :: List.map ~f:(fun (_, name, _) -> name) rest - @ extra @ ["pstream__"] ) - | _ -> raise_s [%message "impossible!"] ) + if not is_closure then ( + pf ppf "@,@,struct %s%s {@,%a const @,{@,return %a;@,}@,};@," fdname + functor_suffix pp_sig "operator()" pp_call_str + ( fdname + , List.map ~f:(fun (_, name, _) -> name) fdargs + @ extra @ ["pstream__"] ) ; + if String.Set.mem funs_used_in_reduce_sum fdname then + (* Produces the reduce_sum functors that has the pstream argument + as the third and not last argument *) + match fdargs with + | (_, slice, _) :: (_, start, _) :: (_, end_, _) :: rest -> + pf ppf "@,@,struct %s%s {@,%a const @,{@,return %a;@,}@,};@," + fdname reduce_sum_functor_suffix pp_sig_rs "operator()" + pp_call_str + ( (if is_dist then fdname ^ "" else fdname) + , slice :: (start ^ " + 1") :: (end_ ^ " + 1") + :: List.map ~f:(fun (_, name, _) -> name) rest + @ extra @ ["pstream__"] ) + | _ -> raise_s [%message "impossible!"] ) + +let forward_decl fun_def = + Program.{fun_def with fdbody= {fun_def.fdbody with Stmt.Fixed.pattern= Skip}} + +let closure_to_function clname Program.({cdrt; cdcaptures; cdargs; cdbody}) = + Program. + { fdname= clname ^ "_impl__" + ; fdrt= cdrt + ; fdargs= cdargs @ cdcaptures + ; fdbody= cdbody + ; fdloc= Location_span.empty } + +let pp_closure_defs ppf closures = + let pp_arg ppf (ad, id, ut) = + if UnsizedType.is_scalar_type ut then + pf ppf "const %a %s" pp_unsizedtype_captured (ad, ut) id + else pf ppf "const %a& %s" pp_unsizedtype_captured (ad, ut) id + in + let pp_members ppf captures = + (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures + in + let pp_ctor ppf (clname, captures) = + let pp_count ppf captures = + if List.is_empty captures then pf ppf "0" + else + (list + ~sep:(fun ppf () -> pf ppf "@ +@ ") + (fun ppf (_, n, t) -> + if UnsizedType.is_scalar_type t then pf ppf "1" + else pf ppf "num_elements(%s__)" n )) + ppf captures + in + pf ppf "@[%s__(%a)@ : %a%snum_vars__(%a) { }@]" clname + (list ~sep:comma (fun ppf a -> pf ppf "%a__" pp_arg a)) + captures + (list ~sep:comma (fun ppf (_, id, _) -> pf ppf "%s(%s__)" id id)) + captures + (if List.is_empty captures then "" else ", ") + pp_count + (List.filter + ~f:(fun (ad, _, _) -> ad = UnsizedType.AutoDiffable) + captures) + in + let pp_op ppf (rt, name, captures, args) = + let argtypetemplates, s_args = get_templates_and_args args in + pp_template_decorator ppf List.(map ~f:typename argtypetemplates) ; + pf ppf + "@[%aoperator()(%a%sstd::ostream* pstream__) const {@ return \ + %a;@,}@]" + pp_returntype_closure (args, rt) (list ~sep:comma text) s_args + (if List.is_empty args then "" else ", ") + pp_call + ( name ^ "_impl__" + , text + , List.map ~f:(fun (_, n, _) -> n) (args @ captures) @ ["pstream__"] ) + in + let f ~key ~data:Program.({cdrt; cdargs; cdcaptures; _}) = + pf ppf + "@,%a@[class %s__ {@ %a@ public:@ %s@ const int num_vars__;@ %a@ \ + %a@]@,};@," + pp_template_decorator ["typename captured_t__"] key pp_members cdcaptures + "using captured_scalar_t__ = captured_t__;" pp_ctor (key, cdcaptures) + pp_op + (cdrt, key, cdcaptures, cdargs) + in + String.Map.iteri ~f closures let version = "// Code generated by %%NAME%% %%VERSION%%" let includes = "#include " @@ -287,6 +365,7 @@ let pp_ctor ppf p = let pp_model_private ppf {Program.prepare_data; _} = let decl Stmt.Fixed.({pattern; _}) = match pattern with + | Decl {decl_type= Unsized (UFun _); _} -> None | Decl d -> Some (d.decl_id, Type.to_unsized d.decl_type, UnsizedType.DataOnly) | _ -> None @@ -703,18 +782,39 @@ let pp_prog ppf (p : Program.Typed.t) = (* First, do some transformations on the MIR itself before we begin printing it.*) let p, s = Locations.prepare_prog p in let pp_fun_def_with_rs_list ppf fblock = - pp_fun_def ppf fblock (fun_used_in_reduce_sum p) + pp_fun_def ppf fblock false (fun_used_in_reduce_sum p) in let reduce_sum_struct_decl = String.Set.map ~f:(fun x -> "struct " ^ x ^ reduce_sum_functor_suffix ^ ";") (fun_used_in_reduce_sum p) in - pf ppf "@[@ %s@ %s@ namespace %s {@ %s@ %s@ %a@ %s@ %a@ %a@ }@ @]" version - includes (namespace p) custom_functions usings Locations.pp_globals s + (* Closures may call user-defined functions so functions must be declared before closures. + But closures may also appear inside functions so closures must be defined before functions. + Redundant forward declarations are harmless so just declare all user functions first + then define closure classes and after that define user functions. + TODO: nested closures are still broken. *) + pf ppf + "@[@ %s@ %s@ namespace %s {@ %s@ %s@ %a@ %s@ %a@ %a@ %a@ %a@ %a@ %a@ \ + }@ @]" + version includes (namespace p) custom_functions usings Locations.pp_globals + s (String.concat ~sep:"\n" (String.Set.elements reduce_sum_struct_decl)) (list ~sep:cut pp_fun_def_with_rs_list) - p.functions_block pp_model p ; + (List.map ~f:forward_decl p.functions_block) + (list ~sep:cut pp_fun_def_with_rs_list) + (Map.fold ~init:[] + ~f:(fun ~key ~data accum -> + (closure_to_function key data |> forward_decl) :: accum ) + p.closures) + pp_closure_defs p.closures + (list ~sep:cut pp_fun_def_with_rs_list) + p.functions_block + (list ~sep:cut (fun ppf fd -> pp_fun_def ppf fd true String.Set.empty)) + (Map.fold ~init:[] + ~f:(fun ~key ~data accum -> closure_to_function key data :: accum) + p.closures) + pp_model p ; pf ppf "@,typedef %s_namespace::%s stan_model;@," p.prog_name p.prog_name ; pf ppf {| diff --git a/src/stan_math_backend/Statement_gen.ml b/src/stan_math_backend/Statement_gen.ml index 3018330f90..c6dc659cb6 100644 --- a/src/stan_math_backend/Statement_gen.ml +++ b/src/stan_math_backend/Statement_gen.ml @@ -90,6 +90,8 @@ let rec pp_statement (ppf : Format.formatter) | Block _ | SList _ | Decl _ | Skip | Break | Continue -> () | _ -> Locations.pp_smeta ppf meta ) ; match pattern with + | Assignment ((vident, UFun _, []), rhs) -> + pf ppf "@[auto %s = %a;@]" vident pp_expr rhs | Assignment ((vident, _, []), ({meta= Expr.Typed.Meta.({type_= UInt; _}); _} as rhs)) |Assignment ((vident, _, []), ({meta= {type_= UReal; _}; _} as rhs)) -> @@ -190,6 +192,7 @@ let rec pp_statement (ppf : Format.formatter) pp_for_loop ppf (loopvar, lower, upper, pp_statement, body) | Block ls -> pp_block ppf (pp_stmt_list, ls) | SList ls -> pp_stmt_list ppf ls + | Decl {decl_adtype= _; decl_id= _; decl_type= Unsized (UFun _)} -> () | Decl {decl_adtype; decl_id; decl_type} -> pp_possibly_sized_decl ppf (decl_id, decl_type, decl_adtype) diff --git a/src/stan_math_backend/Transform_Mir.ml b/src/stan_math_backend/Transform_Mir.ml index e63c1a252b..97f1a303ad 100644 --- a/src/stan_math_backend/Transform_Mir.ml +++ b/src/stan_math_backend/Transform_Mir.ml @@ -679,10 +679,22 @@ let trans_prog (p : Program.Typed.t) = ; meta= Expr.Typed.Meta.empty } ) ; meta= Location_span.empty } ] ) in + let recreate_closures = + (* Closures are not default-constructible so they cannot be + private class members like all other transformed data. + The workaround is to recreate them at the start of each block. *) + List.filter_map p.prepare_data ~f:(function + | Stmt.Fixed.({pattern= Decl {decl_type= Unsized (UFun _); _}; _}) as d + -> + Some d + | Stmt.Fixed.({pattern= Assignment ((_, UFun _, _), _); _}) as d -> + Some d + | _ -> None ) + in let p = { p with functions_block - ; log_prob + ; log_prob= recreate_closures @ log_prob ; prog_name= escape_name p.prog_name ; prepare_data= init_pos @@ -694,7 +706,7 @@ let trans_prog (p : Program.Typed.t) = @ ( add_validate_dims p.output_vars p.transform_inits |> add_reads constrained_params data_read ) @ List.map ~f:gen_write free_params - ; generate_quantities } + ; generate_quantities= recreate_closures @ generate_quantities } in Program.( p diff --git a/test/integration/good/code-gen/cl.expected b/test/integration/good/code-gen/cl.expected index afd743549e..c2ad5100cc 100644 --- a/test/integration/good/code-gen/cl.expected +++ b/test/integration/good/code-gen/cl.expected @@ -285,6 +285,10 @@ static const std::vector locations_array__ = {" (found before start of p + + + + class optimize_glm_model : public model_base_crtp { private: diff --git a/test/integration/good/code-gen/closure.stan b/test/integration/good/code-gen/closure.stan new file mode 100644 index 0000000000..fc0ad19fd4 --- /dev/null +++ b/test/integration/good/code-gen/closure.stan @@ -0,0 +1,28 @@ +data { + int N; + real x; + real y[N]; + vector[N] v; +} +transformed data { + functions + real foo(real z, row_vector r) { + return z + sum(r) + x + sum(y) + sum(v); + } +} +parameters { + real p; + real pa[N]; + vector[N] pv; +} +model { + functions + real bar(real z, row_vector r) { + return z + sum(r) + x + sum(y) + sum(v) + + p + sum(pa) + sum(pv); + } + target += foo(0.0,[1.0]); + target += foo(p,[1.0]); + target += bar(0.0,[1.0]); + target += bar(p,[1.0]); +} diff --git a/test/integration/good/code-gen/cpp.expected b/test/integration/good/code-gen/cpp.expected index 1a45857242..a4e8217604 100644 --- a/test/integration/good/code-gen/cpp.expected +++ b/test/integration/good/code-gen/cpp.expected @@ -1,3 +1,644 @@ + $ ../../../../../install/default/bin/stanc --print-cpp closure.stan + +// Code generated by %%NAME%% %%VERSION%% +#include +namespace closure_model_namespace { + +template +std::vector resize_to_match__(std::vector& dst, const std::vector& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.rows(), src.cols()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} +std::vector to_doubles__(std::initializer_list x) { + return x; +} + +std::vector to_vars__(std::initializer_list x) { + return x; +} + +inline void validate_positive_index(const char* var_name, const char* expr, + int val) { + if (val < 1) { + std::stringstream msg; + msg << "Found dimension size less than one in simplex declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + +inline void validate_unit_vector_index(const char* var_name, const char* expr, + int val) { + if (val <= 1) { + std::stringstream msg; + if (val == 1) { + msg << "Found dimension size one in unit vector declaration." + << " One-dimensional unit vector is discrete" + << " but the target distribution must be continuous." + << " variable=" << var_name << "; dimension size expression=" << expr; + } else { + msg << "Found dimension size less than one in unit vector declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + } + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + + +using std::istream; +using std::string; +using std::stringstream; +using std::vector; +using std::pow; +using stan::io::dump; +using stan::math::lgamma; +using stan::model::model_base_crtp; +using stan::model::rvalue; +using stan::model::cons_list; +using stan::model::index_uni; +using stan::model::index_max; +using stan::model::index_min; +using stan::model::index_min_max; +using stan::model::index_multi; +using stan::model::index_omni; +using stan::model::nil_index_list; +using namespace stan::math; + +static int current_statement__ = 0; +static const std::vector locations_array__ = {" (found before start of program)", + " (in 'closure.stan', line 14, column 4 to column 11)", + " (in 'closure.stan', line 15, column 4 to column 15)", + " (in 'closure.stan', line 16, column 4 to column 17)", + " (in 'closure.stan', line 8, column 4 to line 11, column 5)", + " (in 'closure.stan', line 19, column 4 to line 23, column 5)", + " (in 'closure.stan', line 24, column 4 to column 29)", + " (in 'closure.stan', line 25, column 4 to column 27)", + " (in 'closure.stan', line 26, column 4 to column 29)", + " (in 'closure.stan', line 27, column 4 to column 27)", + " (in 'closure.stan', line 2, column 4 to column 10)", + " (in 'closure.stan', line 3, column 4 to column 11)", + " (in 'closure.stan', line 4, column 4 to column 14)", + " (in 'closure.stan', line 5, column 4 to column 16)", + " (in 'closure.stan', line 10, column 8 to column 48)", + " (in 'closure.stan', line 9, column 35 to line 11, column 5)", + " (in 'closure.stan', line 21, column 8 to line 22, column 40)", + " (in 'closure.stan', line 20, column 35 to line 23, column 5)"}; + + + +template +typename boost::math::tools::promote_args::type +closure1_impl__(const T0__& z, const Eigen::Matrix& r, + const T2__& p, const std::vector& pa, + const Eigen::Matrix& pv, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +closure0_impl__(const T0__& z, const Eigen::Matrix& r, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) ; + + +template +class closure0__ { + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure0__(const Eigen::Matrix& v__, const double x__, + const std::vector& y__) : v(v__), x(x__), y(y__), num_vars__(0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure0_impl__(z, r, v, x, y, pstream__);} +}; + +template +class closure1__ { + const captured_t__ p; + const std::vector& pa; + const Eigen::Matrix& pv; + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure1__(const captured_t__ p__, const std::vector& pa__, + const Eigen::Matrix& pv__, + const Eigen::Matrix& v__, const double x__, + const std::vector& y__) : p(p__), pa(pa__), pv(pv__), v(v__), + x(x__), y(y__), num_vars__(1 + num_elements(pa__) + num_elements(pv__)) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure1_impl__(z, r, p, pa, pv, v, x, y, pstream__);} +}; + + +template +typename boost::math::tools::promote_args::type +closure1_impl__(const T0__& z, const Eigen::Matrix& r, + const T2__& p, const std::vector& pa, + const Eigen::Matrix& pv, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 16; + return (((((((z + sum(r)) + x) + sum(y)) + sum(v)) + p) + sum(pa)) + + sum(pv)); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} +template +typename boost::math::tools::promote_args::type +closure0_impl__(const T0__& z, const Eigen::Matrix& r, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 14; + return ((((z + sum(r)) + x) + sum(y)) + sum(v)); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} +class closure_model : public model_base_crtp { + + private: + int pos__; + int N; + double x; + std::vector y; + Eigen::Matrix v; + + public: + ~closure_model() { } + + std::string model_name() const { return "closure_model"; } + + closure_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "closure_model_namespace::closure_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + context__.validate_dims("data initialization","N","int", + context__.to_vec()); + + current_statement__ = 10; + N = context__.vals_i("N")[(1 - 1)]; + context__.validate_dims("data initialization","x","double", + context__.to_vec()); + + current_statement__ = 11; + x = context__.vals_r("x")[(1 - 1)]; + current_statement__ = 12; + validate_non_negative_index("y", "N", N); + context__.validate_dims("data initialization","y","double", + context__.to_vec(N)); + y = std::vector(N, 0); + + current_statement__ = 12; + assign(y, nil_index_list(), context__.vals_r("y"), + "assigning variable y"); + current_statement__ = 13; + validate_non_negative_index("v", "N", N); + context__.validate_dims("data initialization","v","double", + context__.to_vec(N)); + v = Eigen::Matrix(N); + + { + std::vector v_flat__; + current_statement__ = 13; + assign(v_flat__, nil_index_list(), context__.vals_r("v"), + "assigning variable v_flat__"); + current_statement__ = 13; + pos__ = 1; + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 13; + assign(v, cons_list(index_uni(sym1__), nil_index_list()), + v_flat__[(pos__ - 1)], "assigning variable v"); + current_statement__ = 13; + pos__ = (pos__ + 1);} + } + + current_statement__ = 4; + auto foo = closure0__(v, x, y); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + num_params_r__ += 1; + current_statement__ = 2; + validate_non_negative_index("pa", "N", N); + num_params_r__ += N; + current_statement__ = 3; + validate_non_negative_index("pv", "N", N); + num_params_r__ += N; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "closure_model_namespace::log_prob"; +(void) function__; // suppress unused var warning + + stan::io::reader in__(params_r__, params_i__); + + try { + + current_statement__ = 4; + auto foo = closure0__(v, x, y); + local_scalar_t__ p; + + current_statement__ = 1; + p = in__.scalar(); + current_statement__ = 2; + validate_non_negative_index("pa", "N", N); + std::vector pa; + pa = std::vector(N, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 2; + assign(pa, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable pa");} + current_statement__ = 3; + validate_non_negative_index("pv", "N", N); + Eigen::Matrix pv; + pv = Eigen::Matrix(N); + + current_statement__ = 3; + pv = in__.vector(N); + { + + current_statement__ = 5; + auto bar = closure1__(p, pa, pv, v, x, y); + current_statement__ = 6; + lp_accum__.add( + foo(0.0, stan::math::to_row_vector( + stan::math::array_builder().add(1.0).array()), pstream__)); + current_statement__ = 7; + lp_accum__.add( + foo(p, stan::math::to_row_vector( + stan::math::array_builder().add(1.0).array()), pstream__)); + current_statement__ = 8; + lp_accum__.add( + bar(0.0, stan::math::to_row_vector( + stan::math::array_builder().add(1.0).array()), pstream__)); + current_statement__ = 9; + lp_accum__.add( + bar(p, stan::math::to_row_vector( + stan::math::array_builder().add(1.0).array()), pstream__)); + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() + + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "closure_model_namespace::write_array"; +(void) function__; // suppress unused var warning + + (void) function__; // suppress unused var warning + + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; + + try { + + current_statement__ = 4; + auto foo = closure0__(v, x, y); + double p; + + current_statement__ = 1; + p = in__.scalar(); + current_statement__ = 2; + validate_non_negative_index("pa", "N", N); + std::vector pa; + pa = std::vector(N, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 2; + assign(pa, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable pa");} + current_statement__ = 3; + validate_non_negative_index("pv", "N", N); + Eigen::Matrix pv; + pv = Eigen::Matrix(N); + + current_statement__ = 3; + pv = in__.vector(N); + vars__.push_back(p); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(pa[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(pv[(sym1__ - 1)]);} + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + if (logical_negation(emit_generated_quantities__)) { + return ; + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // write_array() + + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { + typedef double local_scalar_t__; + vars__.resize(0); + vars__.reserve(num_params_r__); + + try { + int pos__; + + pos__ = 1; + double p; + + current_statement__ = 1; + p = context__.vals_r("p")[(1 - 1)]; + current_statement__ = 2; + validate_non_negative_index("pa", "N", N); + std::vector pa; + pa = std::vector(N, 0); + + current_statement__ = 2; + assign(pa, nil_index_list(), context__.vals_r("pa"), + "assigning variable pa"); + current_statement__ = 3; + validate_non_negative_index("pv", "N", N); + Eigen::Matrix pv; + pv = Eigen::Matrix(N); + + { + std::vector pv_flat__; + current_statement__ = 3; + assign(pv_flat__, nil_index_list(), context__.vals_r("pv"), + "assigning variable pv_flat__"); + current_statement__ = 3; + pos__ = 1; + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 3; + assign(pv, cons_list(index_uni(sym1__), nil_index_list()), + pv_flat__[(pos__ - 1)], "assigning variable pv"); + current_statement__ = 3; + pos__ = (pos__ + 1);} + } + vars__.push_back(p); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(pa[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(pv[(sym1__ - 1)]);} + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("p"); + names__.push_back("pa"); + names__.push_back("pv"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "p"); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "pa" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "pv" + '.' + std::to_string(sym1__)); + }} + if (emit_transformed_parameters__) { + + } + + if (emit_generated_quantities__) { + + } + + } // constrained_param_names() + + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "p"); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "pa" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "pv" + '.' + std::to_string(sym1__)); + }} + if (emit_transformed_parameters__) { + + } + + if (emit_generated_quantities__) { + + } + + } // unconstrained_param_names() + + std::string get_constrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"p\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"pa\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"pv\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"}]"; + return s__.str(); + } // get_constrained_sizedtypes() + + std::string get_unconstrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"p\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"pa\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"pv\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"}]"; + return s__.str(); + } // get_unconstrained_sizedtypes() + + + // Begin method overload boilerplate + template + void write_array(RNG& base_rng__, + Eigen::Matrix& params_r, + Eigen::Matrix& vars, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream = 0) const { + std::vector params_r_vec(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r_vec[i] = params_r(i); + std::vector vars_vec; + std::vector params_i_vec; + write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, + emit_transformed_parameters__, emit_generated_quantities__, pstream); + vars.resize(vars_vec.size()); + for (int i = 0; i < vars.size(); ++i) + vars(i) = vars_vec[i]; + } + + template + T_ log_prob(Eigen::Matrix& params_r, + std::ostream* pstream = 0) const { + std::vector vec_params_r; + vec_params_r.reserve(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + vec_params_r.push_back(params_r(i)); + std::vector vec_params_i; + return log_prob(vec_params_r, vec_params_i, pstream); + } + + void transform_inits(const stan::io::var_context& context, + Eigen::Matrix& params_r, + std::ostream* pstream__) const { + std::vector params_r_vec; + std::vector params_i_vec; + transform_inits(context, params_i_vec, params_r_vec, pstream__); + params_r.resize(params_r_vec.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r(i) = params_r_vec[i]; + } + +}; +} +typedef closure_model_namespace::closure_model stan_model; + +#ifndef USING_R + +// Boilerplate +stan::model::model_base& new_model( + stan::io::var_context& data_context, + unsigned int seed, + std::ostream* msg_stream) { + stan_model* m = new stan_model(data_context, seed, msg_stream); + return *m; +} + +#endif + + + $ ../../../../../install/default/bin/stanc --print-cpp eight_schools_ncp.stan // Code generated by %%NAME%% %%VERSION%% @@ -105,6 +746,10 @@ static const std::vector locations_array__ = {" (found before start of p + + + + class eight_schools_ncp_model : public model_base_crtp { private: @@ -1073,6 +1718,353 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'mother.stan', line 309, column 78 to line 313, column 3)"}; +int +foo(const int& n, std::ostream* pstream__) ; + +int +foo(const int& n, std::ostream* pstream__) ; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +double +foo_bar0(std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_bar1(const T0__& x, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, + std::ostream* pstream__) ; + +template +void +unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +int +foo_1(const int& a, std::ostream* pstream__) ; + +int +foo_2(const int& a, std::ostream* pstream__) ; + +template +std::vector::type> +foo_3(const T0__& t, const int& n, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +template +void +foo_4(const T0__& x, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +relative_diff(const T0__& x, const T1__& y, const T2__& max_, + const T3__& min_, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +foo_5(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, + const T4__& x5, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type>::type +foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, + const T3__& x4, const T4__& x5, const T5__& x6, + T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, -1> +covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, + std::ostream* pstream__) ; + +template +void +f0(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +int +f1(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector +f2(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector> +f3(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type>::type +f4(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type> +f5(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type>> +f6(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type>::type, -1, 1> +f7(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, 1>> +f8(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, 1>>> +f9(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type>::type, -1, -1> +f10(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, -1>> +f11(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, -1>>> +f12(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +void +foo_6(std::ostream* pstream__) ; + +Eigen::Matrix +matfoo(std::ostream* pstream__) ; + +Eigen::Matrix +vecfoo(std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +vecmufoo(const T0__& mu, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +vecmubar(const T0__& mu, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +algebra_system(const Eigen::Matrix& x, + const Eigen::Matrix& y, + const std::vector& dat, const std::vector& dat_int, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +binomialf(const Eigen::Matrix& phi, + const Eigen::Matrix& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) ; + + + int foo(const int& n, std::ostream* pstream__) ; @@ -3099,6 +4091,7 @@ return binomialf(phi, theta, x_r, x_i, pstream__); } }; + class mother_model : public model_base_crtp { private: @@ -9687,6 +10680,42 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'motherHOF.stan', line 25, column 39 to line 30, column 3)"}; +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +integrand(const T0__& x, const T1__& xc, const std::vector& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +foo(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +map_rectfake(const T0__& x, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +algebra_system(const Eigen::Matrix& x, + const Eigen::Matrix& y, + const std::vector& dat, const std::vector& dat_int, + std::ostream* pstream__) ; + + + template std::vector::type> @@ -9888,6 +10917,7 @@ return algebra_system(x, y, dat, dat_int, pstream__); } }; + class motherHOF_model : public model_base_crtp { private: @@ -11702,6 +12732,10 @@ static const std::vector locations_array__ = {" (found before start of p + + + + class optimize_glm_model : public model_base_crtp { private: @@ -13207,6 +14241,24 @@ static const std::vector locations_array__ = {" (found before start of p struct foo_lpdf_rsfunctor__; struct g_rsfunctor__; struct h_rsfunctor__; +template +typename boost::math::tools::promote_args::type +g(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h(const std::vector& y_slice, const int& start, const int& end, + const std::vector& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lpdf(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + + + template typename boost::math::tools::promote_args::type g(const std::vector& y_slice, const int& start, const int& end, @@ -13345,6 +14397,7 @@ return foo_lpdf(y_slice, start + 1, end + 1, pstream__); } }; + class reduce_sum_m1_model : public model_base_crtp { private: @@ -13968,6 +15021,99 @@ struct h5_rsfunctor__; struct h6_rsfunctor__; struct h7_rsfunctor__; struct h8_rsfunctor__; +template +typename boost::math::tools::promote_args::type +g1(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g2(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g3(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g4(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g5(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g6(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g7(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g8(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h1(const std::vector& y, const int& start, const int& end, + const std::vector& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h2(const std::vector& y, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h3(const std::vector& y, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h4(const std::vector& y, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h5(const std::vector& y, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h6(const std::vector& y, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h7(const std::vector& y, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +h8(const std::vector& y, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + + + template typename boost::math::tools::promote_args::type g1(const std::vector& y_slice, const int& start, const int& end, @@ -14830,6 +15976,7 @@ return h8(y, start + 1, end + 1, a, pstream__); } }; + class reduce_sum_m2_model : public model_base_crtp { private: @@ -16990,6 +18137,172 @@ struct g7_rsfunctor__; struct g8_rsfunctor__; struct g9_rsfunctor__; struct s_rsfunctor__; +template +typename boost::math::tools::promote_args::type +f1(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f1a(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f2(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f3(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f4(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f5(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f6(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f7(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f8(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +double +f9(const std::vector& y_slice, const int& start, const int& end, + std::ostream* pstream__) ; + +double +f10(const std::vector>& y_slice, const int& start, + const int& end, std::ostream* pstream__) ; + +double +f11(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +f12(const std::vector>>& y_slice, + const int& start, const int& end, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g1(const std::vector& y_slice, const int& start, const int& end, + const T3__& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g2(const std::vector& y_slice, const int& start, const int& end, + const Eigen::Matrix& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g3(const std::vector& y_slice, const int& start, const int& end, + const Eigen::Matrix& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g4(const std::vector& y_slice, const int& start, const int& end, + const Eigen::Matrix& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g5(const std::vector& y_slice, const int& start, const int& end, + const std::vector& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g6(const std::vector& y_slice, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g7(const std::vector& y_slice, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g8(const std::vector& y_slice, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g9(const std::vector& y_slice, const int& start, const int& end, + const std::vector>& a, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g10(const std::vector& y_slice, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g11(const std::vector& y_slice, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +g12(const std::vector& y_slice, const int& start, const int& end, + const std::vector>>& a, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type>::type>::type +s(const std::vector& y_slice, const int& start, const int& end, + const int& a, const T4__& b, const Eigen::Matrix& c, + const Eigen::Matrix& d, const Eigen::Matrix& e, + const std::vector& f, const std::vector& g, + const std::vector>& h, + const std::vector>& i, + const std::vector>& j, + const std::vector>& k, + const std::vector>& l, + const std::vector>>& m, + const std::vector>>& n, + const std::vector>>& o, + const std::vector>>& p, + const std::vector>>& q, + std::ostream* pstream__) ; + +double +r(std::ostream* pstream__) ; + + + template typename boost::math::tools::promote_args::type f1(const std::vector& y_slice, const int& start, const int& end, @@ -18563,6 +19876,7 @@ return r(pstream__); } }; + class reduce_sum_m3_model : public model_base_crtp { private: @@ -21053,6 +22367,10 @@ static const std::vector locations_array__ = {" (found before start of p + + + + class tilde_block_model : public model_base_crtp { private: @@ -21455,6 +22773,10 @@ static const std::vector locations_array__ = {" (found before start of p + + + + class truncate_model : public model_base_crtp { private: @@ -21922,6 +23244,13 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'user_constrain.stan', line 2, column 36 to line 4, column 3)"}; +template +typename boost::math::tools::promote_args::type +lb_constrain(const T0__& x, const T1__& y, std::ostream* pstream__) ; + + + template typename boost::math::tools::promote_args::type @@ -21952,6 +23281,7 @@ return lb_constrain(x, y, pstream__); } }; + class user_constrain_model : public model_base_crtp { private: diff --git a/test/integration/good/code-gen/mir.expected b/test/integration/good/code-gen/mir.expected index 7727f754f4..be4ea38b8c 100644 --- a/test/integration/good/code-gen/mir.expected +++ b/test/integration/good/code-gen/mir.expected @@ -1,5 +1,6 @@ $ ../../../../../install/default/bin/stanc --debug-mir mother.stan -((functions_block +((closures ()) + (functions_block (((fdrt (UInt)) (fdname foo) (fdargs ((AutoDiffable n UInt))) (fdbody ((pattern Skip) (meta ))) (fdloc )) ((fdrt (UInt)) (fdname foo) (fdargs ((AutoDiffable n UInt))) diff --git a/test/integration/good/compiler-optimizations/cpp.expected b/test/integration/good/compiler-optimizations/cpp.expected index 7e090713d3..874348d584 100644 --- a/test/integration/good/compiler-optimizations/cpp.expected +++ b/test/integration/good/compiler-optimizations/cpp.expected @@ -182,6 +182,21 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'optimizations.stan', line 16, column 8 to column 18)"}; +template +void +nrfun_lp(const T0__& x, const int& y, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +int +rfun(const int& y, std::ostream* pstream__) ; + +template +int +rfun_lp(T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) ; + + + template void @@ -288,6 +303,7 @@ return rfun_lp(lp__, lp_accum__, pstream__); } }; + class optimizations_model : public model_base_crtp { private: diff --git a/test/unit/Optimize.ml b/test/unit/Optimize.ml index b03d1e678c..f9fdfba68b 100644 --- a/test/unit/Optimize.ml +++ b/test/unit/Optimize.ml @@ -253,7 +253,8 @@ let%expect_test "list collapsing" = print_s [%sexp (mir : Middle.Program.Typed.t)] ; [%expect {| - ((functions_block + ((closures ()) + (functions_block (((fdrt ()) (fdname f) (fdargs ((AutoDiffable x UInt) (AutoDiffable y UMatrix))) (fdbody @@ -3238,7 +3239,7 @@ let%expect_test "block fixing" = print_s [%sexp (mir : Program.Typed.t)] ; [%expect {| - ((functions_block ()) (input_vars ()) (prepare_data ()) + ((closures ()) (functions_block ()) (input_vars ()) (prepare_data ()) (log_prob (((pattern (IfElse diff --git a/test/unit/Stan_math_code_gen_tests.ml b/test/unit/Stan_math_code_gen_tests.ml index 3d8a13cceb..6bfa4b56e8 100644 --- a/test/unit/Stan_math_code_gen_tests.ml +++ b/test/unit/Stan_math_code_gen_tests.ml @@ -9,7 +9,7 @@ let%expect_test "udf" = Stmt.Fixed.{pattern= stmt; meta= Locations.no_span_num} in let w e = Expr.{Fixed.pattern= e; meta= Typed.Meta.empty} in - let pp_fun_def_w_rs a b = pp_fun_def a b String.Set.empty in + let pp_fun_def_w_rs a b = pp_fun_def a b false String.Set.empty in { fdrt= None ; fdname= "sars" ; fdargs= [(DataOnly, "x", UMatrix); (AutoDiffable, "y", URowVector)] From 610ed76f63cb71a4a54887787530e7e9b92dee71 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Wed, 13 May 2020 12:56:42 +0300 Subject: [PATCH 4/9] more closure codegen + switch to variadic ode_bdf --- src/frontend/Ast_to_Mir.ml | 15 +- src/middle/Stan_math_signatures.ml | 39 ++++- src/middle/UnsizedType.ml | 17 ++- src/stan_math_backend/Expression_gen.ml | 11 +- src/stan_math_backend/Stan_math_code_gen.ml | 153 ++++++++++++++++++-- 5 files changed, 203 insertions(+), 32 deletions(-) diff --git a/src/frontend/Ast_to_Mir.ml b/src/frontend/Ast_to_Mir.ml index 383338247b..7824b32c8c 100644 --- a/src/frontend/Ast_to_Mir.ml +++ b/src/frontend/Ast_to_Mir.ml @@ -74,6 +74,16 @@ and trans_expr {Ast.expr; Ast.emeta} = | Variable {name; _} -> Var name | IntNumeral x -> Lit (Int, format_number x) | RealNumeral x -> Lit (Real, format_number x) + | FunApp + ( Ast.StanLib + , {name= "integrate_ode_bdf"; _} + , ({emeta= {type_= UFun (fargs, _, _); _}; _} :: _ as args) ) + when 2 + List.length fargs = List.length args -> + FunApp + ( Fun_kind.StanLib + , "integrate_ode_bdf" + , trans_exprs args + @ Expr.Helpers.[float 1e-10; float 1e-10; float 1e8] ) | FunApp (fn_kind, {name; _}, args) |CondDistApp (fn_kind, {name; _}, args) -> FunApp (trans_fn_kind fn_kind, name, trans_exprs args) @@ -469,6 +479,9 @@ let%expect_test "dist name suffix" = let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = let stmt_typed = ts.stmt and smeta = ts.smeta.loc in + let trans_stmt_ad = + trans_stmt ud_dists {dconstrain= None; dadlevel= AutoDiffable} + in let trans_stmt = trans_stmt ud_dists {declc with dconstrain= None} in let trans_single_stmt s = match trans_stmt s with @@ -634,7 +647,7 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = | ReturnType ut -> Some ut ) ; cdcaptures= List.map captures ~f:(fun (a, t, n) -> (a, n, t)) ; cdargs= List.map arguments ~f:trans_arg - ; cdbody= trans_stmt body |> unwrap_block_or_skip } + ; cdbody= trans_stmt_ad body |> unwrap_block_or_skip } with | `Ok x -> closures := x | `Duplicate -> () ) ; diff --git a/src/middle/Stan_math_signatures.ml b/src/middle/Stan_math_signatures.ml index e39dc41055..8db87340aa 100644 --- a/src/middle/Stan_math_signatures.ml +++ b/src/middle/Stan_math_signatures.ml @@ -1054,37 +1054,60 @@ let () = ; (DataOnly, UReal); (DataOnly, UReal) ] ) ; add_qualified ( "integrate_ode_bdf" - , ReturnType (UArray (UArray UReal)) + , ReturnType (UArray UVector) , [ ( AutoDiffable , UFun ( [ (AutoDiffable, UReal) - ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UVector) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) + , ReturnType (UVector) , Function ) ) - ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UVector) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] ) ; add_qualified ( "integrate_ode_bdf" - , ReturnType (UArray (UArray UReal)) + , ReturnType (UArray (UVector)) , [ ( AutoDiffable , UFun ( [ (AutoDiffable, UReal) - ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UVector) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] - , ReturnType (UArray UReal) + , ReturnType (UVector) , Function ) ) - ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UVector) ; (AutoDiffable, UReal) ; (AutoDiffable, UArray UReal) ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt); (DataOnly, UReal) ; (DataOnly, UReal); (DataOnly, UReal) ] ) ; + add_qualified + ( "integrate_ode_bdf" + , ReturnType (UArray UVector) + , [ ( AutoDiffable + , UFun + ( [(AutoDiffable, UReal); (AutoDiffable, UVector)] + , ReturnType UVector + , Function ) ) + ; (AutoDiffable, UVector) + ; (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) ] ) ; + add_qualified + ( "integrate_ode_bdf" + , ReturnType (UArray UVector) + , [ ( AutoDiffable + , UFun + ( [(AutoDiffable, UReal); (AutoDiffable, UVector)] + , ReturnType (UVector) + , Function ) ) + ; (AutoDiffable, UVector) + ; (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) + ; (DataOnly, UReal); (DataOnly, UReal); (DataOnly, UReal) ] ) ; add_qualified ( "integrate_ode_rk45" , ReturnType (UArray (UArray UReal)) diff --git a/src/middle/UnsizedType.ml b/src/middle/UnsizedType.ml index 72fd8a15ab..94d4e21ca2 100644 --- a/src/middle/UnsizedType.ml +++ b/src/middle/UnsizedType.ml @@ -63,14 +63,17 @@ let check_of_same_type_mod_conv name t1 t2 = else match (t1, t2) with | UReal, UInt -> true - | UFun (l1, rt1, _), UFun (l2, rt2, _) -> + | UFun (l1, rt1, _), UFun (l2, rt2, _) -> ( rt1 = rt2 - && List.for_all - ~f:(fun x -> x = true) - (List.map2_exn - ~f:(fun (at1, ut1) (at2, ut2) -> - ut1 = ut2 && autodifftype_can_convert at2 at1 ) - l1 l2) + && + match + List.for_all2 + ~f:(fun (at1, ut1) (at2, ut2) -> + ut1 = ut2 && autodifftype_can_convert at2 at1 ) + l1 l2 + with + | List.Or_unequal_lengths.Ok ok -> ok + | Unequal_lengths -> false ) | _ -> t1 = t2 let rec check_of_same_type_mod_array_conv name t1 t2 = diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index 2c988b7ceb..b858ae8a90 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -111,7 +111,6 @@ let pp_unsizedtype_captured ppf (adtype, ut) = let s = captured_scalar ut adtype in pp_unsizedtype_custom_scalar ppf (s, ut) - let pp_expr_type ppf e = pp_unsizedtype_local ppf Expr.Typed.(adlevel_of e, type_of e) @@ -282,8 +281,8 @@ and gen_fun_app ppf fname es = let default ppf es = let to_var s = Expr.{Fixed.pattern= Var s; meta= Typed.Meta.empty} in let convert_hof_vars = function - | {Expr.Fixed.pattern= Var name; meta= {Expr.Typed.Meta.type_= UFun _; _}} - as e -> + | { Expr.Fixed.pattern= Var name + ; meta= {Expr.Typed.Meta.type_= UFun (_, _, Function); _} } as e -> { e with pattern= FunApp (StanLib, name ^ functor_suffix_select fname, []) } @@ -307,10 +306,10 @@ and gen_fun_app ppf fname es = (fname, f :: x :: y :: dat :: datint :: msgs :: tl) | true, "integrate_1d", f :: a :: b :: theta :: x_r :: x_i :: tl -> (fname, f :: a :: b :: theta :: x_r :: x_i :: msgs :: tl) + | _, "integrate_ode_bdf", f :: y0 :: t0 :: ts :: tl -> + let args, tols = List.split_n tl (List.length tl - 3) in + ("ode_bdf_tol", (f :: y0 :: t0 :: ts :: tols) @ (msgs :: args)) | ( true - , "integrate_ode_bdf" - , f :: y0 :: t0 :: ts :: theta :: x :: x_int :: tl ) - |( true , "integrate_ode_adams" , f :: y0 :: t0 :: ts :: theta :: x :: x_int :: tl ) |( true diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index d26927b387..a1b506b04c 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -85,10 +85,12 @@ let pp_returntype ppf arg_types rt = | Some ut -> pf ppf "%a@," pp_unsizedtype_custom_scalar (scalar, ut) | None -> pf ppf "void@," -let pp_returntype_closure ppf (arg_types, rt) = +let pp_returntype_closure ppf (arg_types, (rt, promote)) = let scalar = - strf "typename boost::math::tools::promote_args::type" - pp_promoted_scalar arg_types + if promote then + strf "typename boost::math::tools::promote_args::type" + pp_promoted_scalar arg_types + else strf "%a" pp_promoted_scalar arg_types in match rt with | Some ut when contains_int ut -> @@ -176,6 +178,15 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure in pf ppf "%s(@[%a@]) " name (list ~sep:comma string) arg_strs in + let pp_ode_sig ppf name = + pp_template_decorator ppf templates ; + pp_returntype ppf fdargs fdrt ; + let arg_strs = + let two, rest = List.split_n args 2 in + two @ ["std::ostream* pstream__"] @ rest + in + pf ppf "%s(@[%a@]) " name (list ~sep:comma string) arg_strs + in let pp_sig_rs ppf name = if is_dist then pp_template_decorator ppf (List.tl_exn templates) else pp_template_decorator ppf templates ; @@ -195,11 +206,34 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure | _ -> pp_block ppf (pp_body, fdbody) ; if not is_closure then ( - pf ppf "@,@,struct %s%s {@,%a const @,{@,return %a;@,}@,};@," fdname - functor_suffix pp_sig "operator()" pp_call_str + let pp_zeros ppf () = pf ppf "void set_zero_adjoints() const { }" in + let pp_adjoints ppf () = + pf ppf "void accumulate_adjoints(double*) const { }" + in + let pp_varis ppf () = pf ppf "void save_varis(vari**) const { }" in + let pp_valueof ppf () = + pf ppf "using ValueOf__ = %s%s;" fdname functor_suffix + in + let pp_deepcopy ppf () = + pf ppf "using DeepCopy__ = %s%s;" fdname functor_suffix + in + let pp_ode ppf () = + if not (is_dist || is_lp || is_rng || List.length args < 3) then + pf ppf "%a const @,{@,return %a;@,}@,%a@,%a@,%a@,%a@,%a@,%s" + pp_ode_sig "operator()" pp_call_str + ( fdname + , List.map ~f:(fun (_, name, _) -> name) fdargs + @ extra @ ["pstream__"] ) + pp_zeros () pp_varis () pp_adjoints () pp_valueof () pp_deepcopy + () "using captured_scalar_t__ = double;" + in + pf ppf "@,@,struct %s%s {@,%s@,%a const @,{@,return %a;}@,%a};@," + fdname functor_suffix "const static int num_vars__ = 0;" pp_sig + "operator()" pp_call_str ( fdname , List.map ~f:(fun (_, name, _) -> name) fdargs - @ extra @ ["pstream__"] ) ; + @ extra @ ["pstream__"] ) + pp_ode () ; if String.Set.mem funs_used_in_reduce_sum fdname then (* Produces the reduce_sum functors that has the pstream argument as the third and not last argument *) @@ -245,7 +279,10 @@ let pp_closure_defs ppf closures = else pf ppf "num_elements(%s__)" n )) ppf captures in - pf ppf "@[%s__(%a)@ : %a%snum_vars__(%a) { }@]" clname + pf ppf + "@[%s__(@[%a@])@ : \ + %a%snum_vars__(@[stan::is_var::value ?@ %a : 0@]) { }@]" + clname (list ~sep:comma (fun ppf a -> pf ppf "%a__" pp_arg a)) captures (list ~sep:comma (fun ppf (_, id, _) -> pf ppf "%s(%s__)" id id)) @@ -258,25 +295,121 @@ let pp_closure_defs ppf closures = in let pp_op ppf (rt, name, captures, args) = let argtypetemplates, s_args = get_templates_and_args args in + let pp_ode ppf () = + if List.length s_args > 2 then ( + let two, tl = List.split_n s_args 2 in + pp_template_decorator ppf List.(map ~f:typename argtypetemplates) ; + pf ppf + "@[%aoperator()(@[%a, std::ostream* pstream__, %a@]) const \ + {@ @[return %a;@]@,}@]@," + pp_returntype_closure (args, rt) (list ~sep:comma text) two + (list ~sep:comma text) tl pp_call + ( name ^ "_impl__" + , text + , List.map ~f:(fun (_, n, _) -> n) (args @ captures) @ ["pstream__"] + ) ) + in pp_template_decorator ppf List.(map ~f:typename argtypetemplates) ; pf ppf - "@[%aoperator()(%a%sstd::ostream* pstream__) const {@ return \ - %a;@,}@]" + "@[%aoperator()(@[%a%sstd::ostream* pstream__@]) const {@ \ + @[return %a;@]@,}@]@,%a" pp_returntype_closure (args, rt) (list ~sep:comma text) s_args (if List.is_empty args then "" else ", ") pp_call ( name ^ "_impl__" , text , List.map ~f:(fun (_, n, _) -> n) (args @ captures) @ ["pstream__"] ) + pp_ode () + in + let pp_valueof ppf (rt, name, captures, args) = + let pp_arg ppf (ad, id, ut) = + if UnsizedType.is_scalar_type ut || ad = UnsizedType.AutoDiffable then + pf ppf "const %a %s" pp_unsizedtype_captured (DataOnly, ut) id + else pf ppf "const %a& %s" pp_unsizedtype_captured (DataOnly, ut) id + in + let pp_mem ppf captures = + (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures + in + let pp_init ppf (name, captures) = + let pp_items ppf captures = + if List.is_empty captures then pf ppf "" + else + pf ppf " : %a" + (list ~sep:comma (fun ppf (ad, n, _) -> + if ad = UnsizedType.AutoDiffable then + pf ppf "%s(value_of(init.%s))" n n + else pf ppf "%s(init.%s)" n n )) + captures + in + pf ppf "@[ValueOf__(const %s__& init)%a { }@]" name pp_items + captures + in + pf ppf "@[class ValueOf__ {@ %a@ public:@ %a@ %a};@]" pp_mem captures + pp_init (name, captures) pp_op + ((rt, false), name, captures, args) + in + let pp_zeroadjoints ppf captures = + let pp_loop ppf (ad, id, _) = + if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + in + pf ppf "@[void set_zero_adjoints() const {@ %a@ }@]" + (list ~sep:cut pp_loop) captures + in + let pp_accumulateadjoints ppf captures = + let pp_loop ppf (ad, id, _) = + if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + in + pf ppf "@[void accumulate_adjoints(double*) const {@ %a}@]" + (list ~sep:cut pp_loop) captures + in + let pp_savevaris ppf captures = + let pp_loop ppf (ad, id, _) = + if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + in + pf ppf "@[void save_varis(vari**) const {@ %a}@]" + (list ~sep:cut pp_loop) captures + in + let pp_deepcopy ppf (rt, id, captures, args) = + let pp_arg ppf (ad, id, ut) = + if UnsizedType.is_scalar_type ut || ad = UnsizedType.AutoDiffable then + pf ppf "const %a %s" pp_unsizedtype_captured (ad, ut) id + else pf ppf "const %a& %s" pp_unsizedtype_captured (ad, ut) id + in + let pp_members ppf captures = + (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures + in + let pp_init ppf (id, captures) = + let pp_items ppf captures = + if List.is_empty captures then pf ppf "" + else + pf ppf " : %a" + (list ~sep:comma (fun ppf (ad, n, _) -> + if ad = UnsizedType.AutoDiffable then + pf ppf "%s(deep_copy_vars(init.%s))" n n + else pf ppf "%s(init.%s)" n n )) + captures + in + pf ppf "@[DeepCopy__(const %s__& init)%a { }@]" id pp_items captures + in + pf ppf "@[class DeepCopy__ {@ %a@ public:@ %a@ %a@ %a@ };@]" + pp_members captures pp_init (id, captures) pp_op + ((rt, true), id, captures, args) + pp_accumulateadjoints captures in let f ~key ~data:Program.({cdrt; cdargs; cdcaptures; _}) = pf ppf "@,%a@[class %s__ {@ %a@ public:@ %s@ const int num_vars__;@ %a@ \ - %a@]@,};@," + %a@ %a@ %a@ %a@ %a@ %a@]@,};@," pp_template_decorator ["typename captured_t__"] key pp_members cdcaptures "using captured_scalar_t__ = captured_t__;" pp_ctor (key, cdcaptures) pp_op + ((cdrt, true), key, cdcaptures, cdargs) + pp_valueof + (cdrt, key, cdcaptures, cdargs) + pp_deepcopy (cdrt, key, cdcaptures, cdargs) + pp_zeroadjoints cdcaptures pp_accumulateadjoints cdcaptures pp_savevaris + cdcaptures in String.Map.iteri ~f closures From 16d7cbff2de03e865ff4621f3323d82bf639ff73 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Sat, 16 May 2020 11:14:16 +0300 Subject: [PATCH 5/9] autodiff API for closures --- src/middle/Internal_fun.ml | 3 + src/middle/Stmt.ml | 9 +-- src/middle/Stmt.mli | 21 +++--- src/stan_math_backend/Expression_gen.ml | 4 ++ src/stan_math_backend/Stan_math_code_gen.ml | 72 ++++++++++++++++++--- src/stan_math_backend/Statement_gen.ml | 3 + 6 files changed, 88 insertions(+), 24 deletions(-) diff --git a/src/middle/Internal_fun.ml b/src/middle/Internal_fun.ml index 6d955aa460..8306464da2 100644 --- a/src/middle/Internal_fun.ml +++ b/src/middle/Internal_fun.ml @@ -20,6 +20,9 @@ type t = | FnReject | FnResizeToMatch | FnNaN + | FnZeroAdjoint + | FnGetAdjoint + | FnGetVariPtr [@@deriving sexp] let to_string x = Sexp.to_string (sexp_of_t x) ^ "__" diff --git a/src/middle/Stmt.ml b/src/middle/Stmt.ml index d5b5e6c721..4cfdae6bf6 100644 --- a/src/middle/Stmt.ml +++ b/src/middle/Stmt.ml @@ -261,14 +261,11 @@ module Helpers = struct in let loopvar, reset = Gensym.enter () in let lower = Expr.Helpers.loop_bottom in - let stmt = - Fixed.Pattern.Block - [bodyfn (Expr.Helpers.add_int_index iteratee (idx loopvar))] - in + let body = bodyfn (Expr.Helpers.add_int_index iteratee (idx loopvar)) in reset () ; - let body = Fixed.{meta; pattern= stmt} in + let body = Fixed.{body with pattern= Pattern.Block [body]} in let pattern = Fixed.Pattern.For {loopvar; lower; upper; body} in - Fixed.{meta; pattern} + Fixed.{body with pattern} let rec for_each bodyfn iteratee smeta = let len (e : Expr.Typed.t) = diff --git a/src/middle/Stmt.mli b/src/middle/Stmt.mli index f6a2527d0c..c3a4ab2449 100644 --- a/src/middle/Stmt.mli +++ b/src/middle/Stmt.mli @@ -125,34 +125,37 @@ module Helpers : sig val mkfor : Expr.Typed.t - -> (Expr.Typed.t -> Located.t) + -> (Expr.Typed.t -> (Expr.Typed.Meta.t, 'a) Fixed.t) -> Expr.Typed.t -> Location_span.t - -> Located.t + -> (Expr.Typed.Meta.t, 'a) Fixed.t val for_each : - (Expr.Typed.t -> Located.t) -> Expr.Typed.t -> Location_span.t -> Located.t + (Expr.Typed.t -> (Expr.Typed.Meta.t, 'a) Fixed.t) + -> Expr.Typed.t + -> Location_span.t + -> (Expr.Typed.Meta.t, 'a) Fixed.t val for_scalar : Expr.Typed.t SizedType.t - -> (Expr.Typed.t -> Located.t) + -> (Expr.Typed.t -> (Expr.Typed.Meta.t, 'a) Fixed.t) -> Expr.Typed.t -> Location_span.t - -> Located.t + -> (Expr.Typed.Meta.t, 'a) Fixed.t val for_scalar_inv : Expr.Typed.t SizedType.t - -> (Expr.Typed.t -> Located.t) + -> (Expr.Typed.t -> (Expr.Typed.Meta.t, 'a) Fixed.t) -> Expr.Typed.t -> Location_span.t - -> Located.t + -> (Expr.Typed.Meta.t, 'a) Fixed.t val for_eigen : Expr.Typed.t SizedType.t - -> (Expr.Typed.t -> Located.t) + -> (Expr.Typed.t -> (Expr.Typed.Meta.t, 'a) Fixed.t) -> Expr.Typed.t -> Location_span.t - -> Located.t + -> (Expr.Typed.Meta.t, 'a) Fixed.t val assign_indexed : UnsizedType.t diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index b858ae8a90..83ea589719 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -375,6 +375,10 @@ and pp_compiler_internal_fn ut f ppf es = pf ppf "@[%s__(@,%a)@]" clname (list ~sep:comma pp_expr) captures | _ -> raise_s [%message "Bad closure " (es : Expr.Typed.t list)] ) + | Some FnGetAdjoint -> + pf ppf "%a.adj()" pp_expr (List.hd_exn es) + | Some FnGetVariPtr -> + pf ppf "%a.vi_" pp_expr (List.hd_exn es) | Some FnConstrain -> pp_constrain_funapp "constrain" ppf es | Some FnUnconstrain -> pp_constrain_funapp "free" ppf es | Some FnReadData -> read_data ut ppf es diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index a1b506b04c..82764344fd 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -348,25 +348,79 @@ let pp_closure_defs ppf closures = pp_init (name, captures) pp_op ((rt, false), name, captures, args) in + let to_var adlevel type_ id = + Expr.{Fixed.pattern= Var id; meta= {Typed.Meta.empty with type_; adlevel}} + in + let rec for_each_scalar bodyfn (iteratee : Expr.Typed.t) = + let bodyfn' = + match iteratee.meta.type_ with + | UArray _ -> for_each_scalar bodyfn + | _ -> bodyfn + in + Stmt.Helpers.for_each bodyfn' iteratee iteratee.meta.loc + in let pp_zeroadjoints ppf captures = - let pp_loop ppf (ad, id, _) = - if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + let pp_loop ppf (adlevel, id, type_) = + let f v = + Stmt.Helpers.internal_nrfunapp FnZeroAdjoint [v] + Stmt.Numbered.Meta.empty + in + let s = for_each_scalar f (to_var adlevel type_ id) in + if adlevel = UnsizedType.AutoDiffable then pp_statement ppf s in - pf ppf "@[void set_zero_adjoints() const {@ %a@ }@]" + pf ppf + "@[void set_zero_adjoints() const {@ if \ + (stan::is_var::value) {@ %a@ }@ }@]" (list ~sep:cut pp_loop) captures in + let swrap pattern = Stmt.{Fixed.pattern; meta= Numbered.Meta.empty} in + let pos = Expr.{Fixed.pattern= Var "pos__"; meta= Typed.Meta.empty} in + let indexed v i = + Expr.{Fixed.pattern= Indexed (v, [Single i]); meta= Typed.Meta.empty} + in let pp_accumulateadjoints ppf captures = - let pp_loop ppf (ad, id, _) = - if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + let pp_loop ppf (ad, id, ut) = + let adj v = + Expr.Helpers.internal_funapp FnGetAdjoint [v] Expr.Typed.Meta.empty + in + let go v = + SList + [ Assignment + ( ("ptr", UReal, [Single pos]) + , Expr.Helpers.binop + (indexed (to_var DataOnly (UArray UReal) "ptr") pos) + Plus (adj v) ) + |> swrap + ; Assignment (("pos__", UInt, []), Expr.Helpers.(binop pos Plus one)) + |> swrap ] + |> swrap + in + let s = for_each_scalar go (to_var ad ut id) in + if ad = UnsizedType.AutoDiffable then pp_statement ppf s in - pf ppf "@[void accumulate_adjoints(double*) const {@ %a}@]" + pf ppf + "@[void accumulate_adjoints(double* ptr) const {@ if \ + (stan::is_var::value) {@ size_t pos__ = 1;@ %a@ }@ }@]" (list ~sep:cut pp_loop) captures in let pp_savevaris ppf captures = - let pp_loop ppf (ad, id, _) = - if ad = UnsizedType.AutoDiffable then pf ppf "/* %s */" id + let pp_loop ppf (ad, id, ut) = + let vari v = + Expr.Helpers.internal_funapp FnGetVariPtr [v] Expr.Typed.Meta.empty + in + let go v = + SList + [ Assignment (("ptr", UInt, [Single pos]), vari v) |> swrap + ; Assignment (("pos__", UInt, []), Expr.Helpers.(binop pos Plus one)) + |> swrap ] + |> swrap + in + let s = for_each_scalar go (to_var ad ut id) in + if ad = UnsizedType.AutoDiffable then pp_statement ppf s in - pf ppf "@[void save_varis(vari**) const {@ %a}@]" + pf ppf + "@[void save_varis(vari** ptr) const {@ if \ + (stan::is_var::value) {@ size_t pos__ = 1;@ %a@ }@ }@]" (list ~sep:cut pp_loop) captures in let pp_deepcopy ppf (rt, id, captures, args) = diff --git a/src/stan_math_backend/Statement_gen.ml b/src/stan_math_backend/Statement_gen.ml index c6dc659cb6..a2d2494739 100644 --- a/src/stan_math_backend/Statement_gen.ml +++ b/src/stan_math_backend/Statement_gen.ml @@ -162,6 +162,9 @@ let rec pp_statement (ppf : Format.formatter) | NRFunApp (CompilerInternal, fname, [var]) when fname = Internal_fun.to_string FnWriteParam -> pf ppf "@[vars__.push_back(@,%a);@]" pp_expr var + | NRFunApp (CompilerInternal, fname, [var]) + when fname = Internal_fun.to_string FnZeroAdjoint -> + pf ppf "@[%a.set_zero_adjoint();@]" pp_expr var | NRFunApp (CompilerInternal, fname, args) -> let fname, extra_args = trans_math_fn fname in pf ppf "%s(@[%a@]);" fname (list ~sep:comma pp_expr) From 62dbdeb7be035d959a1617aba668fbc4d3bfbc5d Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Mon, 18 May 2020 21:11:55 +0300 Subject: [PATCH 6/9] closures capturing closures --- src/frontend/Ast.ml | 17 +- src/frontend/Ast_to_Mir.ml | 12 +- src/frontend/Canonicalize.ml | 6 +- src/frontend/Pretty_printing.ml | 3 +- src/frontend/Semantic_check.ml | 38 +- src/frontend/Symbol_table.ml | 11 + src/frontend/Symbol_table.mli | 2 + src/frontend/parser.mly | 6 +- src/middle/UnsizedType.ml | 2 +- src/stan_math_backend/Expression_gen.ml | 24 +- src/stan_math_backend/Stan_math_code_gen.ml | 132 +- test/integration/bad/ode/adams/stanc.expected | 6 +- test/integration/bad/ode/stanc.expected | 102 +- test/integration/good/code-gen/closure2.stan | 27 + test/integration/good/code-gen/cpp.expected | 22908 ++++++++-------- .../good/compiler-optimizations/cpp.expected | 3 + .../good/parser-generator/pretty.expected | 18 + test/integration/good/pretty.expected | 36 + .../pretty.expected | 36 + .../signatures/stan_math_sigs.expected | 13 +- test/unit/Stan_math_code_gen_tests.ml | 1 + 21 files changed, 11824 insertions(+), 11579 deletions(-) create mode 100644 test/integration/good/code-gen/closure2.stan diff --git a/src/frontend/Ast.ml b/src/frontend/Ast.ml index b3ac390906..dcf1006832 100644 --- a/src/frontend/Ast.ml +++ b/src/frontend/Ast.ml @@ -155,8 +155,7 @@ type ('e, 's, 'l, 'f, 'c) statement = | FunDef of { returntype: Middle.UnsizedType.returntype ; funname: identifier - ; is_closure: bool - ; captures: 'c + ; closure: 'c ; arguments: (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * identifier) list @@ -183,9 +182,15 @@ type ('e, 'm, 'l, 'f, 'c) statement_with = ; smeta: 'm } [@@deriving sexp, compare, map, hash] +type closure_info = + { clname: string + ; captures: + (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * string) list } +[@@deriving sexp, compare, map, hash] + (** Untyped statements, which have location_spans as meta-data *) type untyped_statement = - (untyped_expression, located_meta, untyped_lval, unit, unit) statement_with + (untyped_expression, located_meta, untyped_lval, unit, bool) statement_with [@@deriving sexp, compare, map, hash] let mk_untyped_statement ~stmt ~loc : untyped_statement = {stmt; smeta= {loc}} @@ -202,8 +207,7 @@ type typed_statement = , stmt_typed_located_meta , typed_lval , fun_kind - , (Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * string) list - ) + , closure_info option ) statement_with [@@deriving sexp, compare, map, hash] @@ -251,8 +255,7 @@ let rec untyped_statement_of_typed_statement {stmt; smeta} = map_statement untyped_expression_of_typed_expression untyped_statement_of_typed_statement untyped_lvalue_of_typed_lvalue (fun _ -> ()) - (fun _ -> ()) - stmt + Option.is_some stmt ; smeta= {loc= smeta.loc} } (** Forgetful function from typed to untyped programs *) diff --git a/src/frontend/Ast_to_Mir.ml b/src/frontend/Ast_to_Mir.ml index 7824b32c8c..f37978b0d5 100644 --- a/src/frontend/Ast_to_Mir.ml +++ b/src/frontend/Ast_to_Mir.ml @@ -627,16 +627,16 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = ; meta= smeta } in Stmt.Helpers.[ensure_var (for_each bodyfn) iteratee' smeta] - | Ast.FunDef {is_closure= false; _} -> + | Ast.FunDef {closure= None; _} -> raise_s [%message "Found function definition statement outside of function block"] | Ast.FunDef - {returntype; funname; is_closure= true; captures; arguments; body} -> - let clname = Fmt.strf "closure%d" (Map.length !closures) in + {returntype; funname; closure= Some {clname; captures}; arguments; body} + -> let type_ = UnsizedType.UFun - (List.map arguments ~f:(fun (a, t, _) -> (a, t)), returntype, Closure) + (List.map arguments ~f:(fun (a, t, _) -> (a, t)), returntype, Closure clname) in ( match Map.add !closures ~key:clname @@ -688,9 +688,7 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = let trans_fun_def ud_dists (ts : Ast.typed_statement) = match ts.stmt with - | Ast.FunDef - {returntype; funname; is_closure= false; captures= []; arguments; body} - -> + | Ast.FunDef {returntype; funname; closure= None; arguments; body} -> [ Program. { fdrt= (match returntype with Void -> None | ReturnType ut -> Some ut) diff --git a/src/frontend/Canonicalize.ml b/src/frontend/Canonicalize.ml index 664cf3b9eb..ef099a9f38 100644 --- a/src/frontend/Canonicalize.ml +++ b/src/frontend/Canonicalize.ml @@ -143,8 +143,7 @@ let rec replace_deprecated_stmt {stmt; smeta} = | FunDef { returntype ; funname= {name; id_loc} - ; is_closure - ; captures + ; closure ; arguments ; body } -> FunDef @@ -154,8 +153,7 @@ let rec replace_deprecated_stmt {stmt; smeta} = Option.value ~default:name (String.Table.find deprecated_userdefined name) ; id_loc } - ; is_closure - ; captures + ; closure ; arguments ; body= replace_deprecated_stmt body } | _ -> diff --git a/src/frontend/Pretty_printing.ml b/src/frontend/Pretty_printing.ml index efebef7a45..26cb717310 100644 --- a/src/frontend/Pretty_printing.ml +++ b/src/frontend/Pretty_printing.ml @@ -354,7 +354,8 @@ and pp_statement ppf ({stmt= s_content; _} as ss) = with_hbox ppf (fun () -> Fmt.pf ppf "%a %a%a%a;" pp_transformed_type (pst, trans) pp_identifier id pp_array_dims es pp_init init ) - | FunDef {returntype= rt; funname= id; arguments= args; body= b; _} -> ( + | FunDef {returntype= rt; funname= id; arguments= args; body= b; closure= _} + -> ( Fmt.pf ppf "%a %a(" pp_returntype rt pp_identifier id ; with_box ppf 0 (fun () -> Fmt.pf ppf "%a" (Fmt.list ~sep:Fmt.comma pp_args) args ) ; diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 820ac8e80f..60995374a8 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -1610,6 +1610,7 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = |> map ~f:(fun at -> (at, ut, id))) ) |> Validate.sequence in + let clname = if is_closure then Symbol_table.new_clname vm else "" in Validate.( uargs |> apply_const (semantic_check_identifier id) @@ -1624,8 +1625,9 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = >>= fun () -> (* WARNING: SIDE EFFECTING *) Symbol_table.enter vm id.name - ( Functions - , UFun (uarg_types, urt, if is_closure then Closure else Function) ) ; + ( cf.current_block + , UFun (uarg_types, urt, if is_closure then Closure clname else Function) + ) ; Symbol_table.set_read_only vm id.name ; semantic_check_fundef_suffix ~loc:id.id_loc is_closure id |> apply_const (semantic_check_fundef_dist_rt ~loc id urt) @@ -1673,16 +1675,23 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = FunDef { returntype= urt ; funname= id - ; is_closure - ; captures= - List.filter_map captures ~f:(fun name -> - match Symbol_table.look vm name with - | None | Some (Functions, UFun (_, _, Function)) -> None - | Some (block, type_) -> - Symbol_table.set_read_only vm name ; - Some - (calculate_autodifftype block type_, type_, name) - ) + ; closure= + ( if is_closure then + Some + { clname + ; captures= + List.filter_map captures ~f:(fun name -> + match Symbol_table.look vm name with + | None | Some (Functions, UFun (_, _, Function)) + -> + None + | Some (block, type_) -> + Symbol_table.set_read_only vm name ; + Some + ( calculate_autodifftype block type_ + , type_ + , name ) ) } + else None ) ; arguments= uargs ; body= ub } in @@ -1724,9 +1733,8 @@ and semantic_check_statement cf (s : Ast.untyped_statement) : ; is_global } -> semantic_check_var_decl ~loc ~cf st transformation identifier initial_value is_global - | FunDef {returntype; funname; is_closure; captures= (); arguments; body} -> - semantic_check_fundef ~loc ~cf returntype funname is_closure arguments - body + | FunDef {returntype; funname; closure; arguments; body} -> + semantic_check_fundef ~loc ~cf returntype funname closure arguments body (* == Untyped programs ====================================================== *) diff --git a/src/frontend/Symbol_table.ml b/src/frontend/Symbol_table.ml index 7730f29612..0a1cfcac5d 100644 --- a/src/frontend/Symbol_table.ml +++ b/src/frontend/Symbol_table.ml @@ -12,6 +12,7 @@ type 'a state = ; isunassigned: (string, unit) Hashtbl.t ; locals: (string, unit) Hashtbl.t ref ; captures: String.Set.t ref + ; closures: String.Set.t ref ; globals: (string, unit) Hashtbl.t } let initialize () = @@ -22,6 +23,7 @@ let initialize () = ; isunassigned= String.Table.create () ; locals= ref (String.Table.create ()) ; captures= ref String.Set.empty + ; closures= ref String.Set.empty ; globals= String.Table.create () } let enter s str ty = @@ -90,6 +92,14 @@ let check_is_unassigned s str = Hashtbl.mem s.isunassigned str let check_some_id_is_unassigned s = not (Hashtbl.length s.isunassigned = 0) let is_global s str = Option.is_some (Hashtbl.find s.globals str) +let new_clname vm = + let clname = + let n = Set.length !(vm.closures) in + if n < 10 then Fmt.strf "closure0%d" n else Fmt.strf "closure%d" n + in + vm.closures := Set.add !(vm.closures) clname ; + clname + let unsafe_clear_symbol_table s = Hashtbl.clear s.table ; Stack.clear s.stack ; @@ -97,5 +107,6 @@ let unsafe_clear_symbol_table s = Hashtbl.clear s.readonly ; Hashtbl.clear s.isunassigned ; s.captures := String.Set.empty ; + s.closures := String.Set.empty ; Hashtbl.clear !(s.locals) ; Hashtbl.clear s.globals diff --git a/src/frontend/Symbol_table.mli b/src/frontend/Symbol_table.mli index 5176189e96..1b9a8e35d3 100644 --- a/src/frontend/Symbol_table.mli +++ b/src/frontend/Symbol_table.mli @@ -45,3 +45,5 @@ val is_global : 'a state -> string -> bool val unsafe_clear_symbol_table : 'a state -> unit (** Used to clear the whole symbol table *) + +val new_clname : 'a state -> string diff --git a/src/frontend/parser.mly b/src/frontend/parser.mly index ac69830a9d..9c6fe8cb11 100644 --- a/src/frontend/parser.mly +++ b/src/frontend/parser.mly @@ -176,8 +176,7 @@ function_def: { grammar_logger "function_def" ; {stmt=FunDef {returntype = rt; funname = name; - is_closure = false; - captures = (); + closure = false; arguments = args; body=b;}; smeta={loc=Location_span.of_positions_exn $startpos $endpos} } @@ -189,8 +188,7 @@ closure_def: { grammar_logger "function_def" ; {stmt=FunDef {returntype = rt; funname = name; - is_closure = true; - captures = (); + closure = true; arguments = args; body=b;}; smeta={loc=Location_span.of_positions_exn $startpos $endpos} } diff --git a/src/middle/UnsizedType.ml b/src/middle/UnsizedType.ml index 94d4e21ca2..5e7e02f3ea 100644 --- a/src/middle/UnsizedType.ml +++ b/src/middle/UnsizedType.ml @@ -11,7 +11,7 @@ type t = | UFun of (autodifftype * t) list * returntype * functiontype | UMathLibraryFunction -and functiontype = Function | Closure +and functiontype = Function | Closure of string and autodifftype = DataOnly | AutoDiffable diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index 83ea589719..5b770e347b 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -95,7 +95,7 @@ let%expect_test "promote_unsized" = let rec pp_unsizedtype_custom_scalar ppf (scalar, ut) = match ut with - | UnsizedType.UInt | UReal -> string ppf scalar + | UnsizedType.UInt | UReal | UFun _ -> string ppf scalar | UArray t -> pf ppf "std::vector<%a>" pp_unsizedtype_custom_scalar (scalar, t) | UMatrix -> pf ppf "Eigen::Matrix<%s, -1, -1>" scalar @@ -349,7 +349,7 @@ and pp_user_defined_fun ppf (f, es) = (list ~sep:comma pp_expr) es (sep ^ String.concat ~sep:", " extra_args) -and pp_compiler_internal_fn ut f ppf es = +and pp_compiler_internal_fn (meta : Expr.Typed.Meta.t) f ppf es = let pp_array_literal ppf es = let pp_add_method ppf () = pf ppf ")@,.add(" in pf ppf "stan::math::array_builder<%a>()@,.add(%a)@,.array()" @@ -361,27 +361,29 @@ and pp_compiler_internal_fn ut f ppf es = match Internal_fun.of_string_opt f with | Some FnMakeArray -> pp_array_literal ppf es | Some FnMakeRowVec -> ( - match ut with + match meta.type_ with | UnsizedType.URowVector -> pf ppf "stan::math::to_row_vector(@,%a)" pp_array_literal es | UMatrix -> pf ppf "stan::math::to_matrix(@,%a)" pp_array_literal es | _ -> raise_s [%message - "Unexpected type for row vector literal" (ut : UnsizedType.t)] ) + "Unexpected type for row vector literal" + (meta.type_ : UnsizedType.t)] ) | Some FnMakeClosure -> ( match es with | {Expr.Fixed.pattern= Lit (Str, clname); _} :: captures -> - pf ppf "@[%s__(@,%a)@]" clname + let scalar_t = + if meta.adlevel = AutoDiffable then "local_scalar_t__" else "double" + in + pf ppf "@[%s__<%s>(@,%a)@]" clname scalar_t (list ~sep:comma pp_expr) captures | _ -> raise_s [%message "Bad closure " (es : Expr.Typed.t list)] ) - | Some FnGetAdjoint -> - pf ppf "%a.adj()" pp_expr (List.hd_exn es) - | Some FnGetVariPtr -> - pf ppf "%a.vi_" pp_expr (List.hd_exn es) + | Some FnGetAdjoint -> pf ppf "%a.adj()" pp_expr (List.hd_exn es) + | Some FnGetVariPtr -> pf ppf "%a.vi_" pp_expr (List.hd_exn es) | Some FnConstrain -> pp_constrain_funapp "constrain" ppf es | Some FnUnconstrain -> pp_constrain_funapp "free" ppf es - | Some FnReadData -> read_data ut ppf es + | Some FnReadData -> read_data meta.type_ ppf es | Some FnReadParam -> ( match es with | {Expr.Fixed.pattern= Lit (Str, base_type); _} :: dims -> @@ -422,7 +424,7 @@ and pp_expr ppf Expr.Fixed.({pattern; meta} as e) = | Lit (_, s) -> pf ppf "%s" s | FunApp (StanLib, f, es) -> gen_fun_app ppf f es | FunApp (CompilerInternal, f, es) -> - pp_compiler_internal_fn meta.type_ (stan_namespace_qualify f) ppf es + pp_compiler_internal_fn meta (stan_namespace_qualify f) ppf es | FunApp (UserDefined, f, es) -> pp_user_defined_fun ppf (f, es) | EAnd (e1, e2) -> pp_logical_op ppf "&&" e1 e2 | EOr (e1, e2) -> pp_logical_op ppf "||" e1 e2 diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 82764344fd..056e78feb9 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -41,6 +41,7 @@ let rec contains_int = function | _ -> false let arg_needs_template = function + | _, _, UnsizedType.UFun _ -> true | UnsizedType.DataOnly, _, _ -> false | _, _, t when contains_int t -> false | _ -> true @@ -227,7 +228,7 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure pp_zeros () pp_varis () pp_adjoints () pp_valueof () pp_deepcopy () "using captured_scalar_t__ = double;" in - pf ppf "@,@,struct %s%s {@,%s@,%a const @,{@,return %a;}@,%a};@," + pf ppf "@,@,struct %s%s {@,%s@,%a const @,{@,return %a;@,}@,%a};@," fdname functor_suffix "const static int num_vars__ = 0;" pp_sig "operator()" pp_call_str ( fdname @@ -260,30 +261,57 @@ let closure_to_function clname Program.({cdrt; cdcaptures; cdargs; cdbody}) = ; fdloc= Location_span.empty } let pp_closure_defs ppf closures = - let pp_arg ppf (ad, id, ut) = - if UnsizedType.is_scalar_type ut then - pf ppf "const %a %s" pp_unsizedtype_captured (ad, ut) id - else pf ppf "const %a& %s" pp_unsizedtype_captured (ad, ut) id + let pp_type ppf = function + | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> + pf ppf "%s__&" clname + | AutoDiffable, UnsizedType.UFun (_, _, Closure clname) -> + pf ppf "%s__&" clname + | ad, ut when UnsizedType.is_scalar_type ut -> + pp_unsizedtype_captured ppf (ad, ut) + | ad, ut -> pf ppf "%a&" pp_unsizedtype_captured (ad, ut) in - let pp_members ppf captures = - (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures + let pp_valuetype ppf = function + | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> + pf ppf "typename %s__::ValueOf__" clname + | AutoDiffable, UFun (_, _, Closure clname) -> + pf ppf "typename %s__::ValueOf__" clname + | AutoDiffable, ut -> pp_unsizedtype_captured ppf (DataOnly, ut) + | _, ut when UnsizedType.is_scalar_type ut -> + pp_unsizedtype_captured ppf (DataOnly, ut) + | _, ut -> pf ppf "%a&" pp_unsizedtype_captured (DataOnly, ut) + in + let pp_copytype ppf = function + | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> + pf ppf "typename %s__::DeepCopy__" clname + | AutoDiffable, UFun (_, _, Closure clname) -> + pf ppf "typename %s__::DeepCopy__" clname + | ad, ut when UnsizedType.is_scalar_type ut -> + pp_unsizedtype_captured ppf (ad, ut) + | ad, ut -> pf ppf "%a&" pp_unsizedtype_captured (ad, ut) + in + let pp_members ppf (pp_type, captures) = + (list ~sep:cut (fun ppf (ad, id, ut) -> + pf ppf "const %a %s;" pp_type (ad, ut) id )) + ppf captures in let pp_ctor ppf (clname, captures) = let pp_count ppf captures = if List.is_empty captures then pf ppf "0" else (list - ~sep:(fun ppf () -> pf ppf "@ +@ ") - (fun ppf (_, n, t) -> - if UnsizedType.is_scalar_type t then pf ppf "1" - else pf ppf "num_elements(%s__)" n )) + ~sep:(fun ppf () -> pf ppf "@ + ") + (fun ppf -> function + | _, _, UnsizedType.(UReal | UInt) -> pf ppf "1" + | _, n, UFun _ -> pf ppf "%s__.num_vars__" n + | _, n, _ -> pf ppf "num_elements(%s__)" n )) ppf captures in pf ppf "@[%s__(@[%a@])@ : \ %a%snum_vars__(@[stan::is_var::value ?@ %a : 0@]) { }@]" clname - (list ~sep:comma (fun ppf a -> pf ppf "%a__" pp_arg a)) + (list ~sep:comma (fun ppf (ad, id, ut) -> + pf ppf "const %a %s__" pp_type (ad, ut) id )) captures (list ~sep:comma (fun ppf (_, id, _) -> pf ppf "%s(%s__)" id id)) captures @@ -322,30 +350,24 @@ let pp_closure_defs ppf closures = pp_ode () in let pp_valueof ppf (rt, name, captures, args) = - let pp_arg ppf (ad, id, ut) = - if UnsizedType.is_scalar_type ut || ad = UnsizedType.AutoDiffable then - pf ppf "const %a %s" pp_unsizedtype_captured (DataOnly, ut) id - else pf ppf "const %a& %s" pp_unsizedtype_captured (DataOnly, ut) id - in - let pp_mem ppf captures = - (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures - in let pp_init ppf (name, captures) = let pp_items ppf captures = if List.is_empty captures then pf ppf "" else pf ppf " : %a" - (list ~sep:comma (fun ppf (ad, n, _) -> - if ad = UnsizedType.AutoDiffable then - pf ppf "%s(value_of(init.%s))" n n + (list ~sep:comma (fun ppf (ad, n, ut) -> + if + ad = UnsizedType.AutoDiffable + && not (UnsizedType.is_fun_type ut) + then pf ppf "%s(value_of(init.%s))" n n else pf ppf "%s(init.%s)" n n )) captures in pf ppf "@[ValueOf__(const %s__& init)%a { }@]" name pp_items captures in - pf ppf "@[class ValueOf__ {@ %a@ public:@ %a@ %a};@]" pp_mem captures - pp_init (name, captures) pp_op + pf ppf "@[class ValueOf__ {@ %a@ public:@ %a@ %a};@]" pp_members + (pp_valuetype, captures) pp_init (name, captures) pp_op ((rt, false), name, captures, args) in let to_var adlevel type_ id = @@ -359,19 +381,24 @@ let pp_closure_defs ppf closures = in Stmt.Helpers.for_each bodyfn' iteratee iteratee.meta.loc in + let ad_filter = function + | UnsizedType.DataOnly, _, _ -> None + | AutoDiffable, id, type_ -> Some (id, type_) + in let pp_zeroadjoints ppf captures = - let pp_loop ppf (adlevel, id, type_) = + let pp_loop ppf (id, type_) = let f v = Stmt.Helpers.internal_nrfunapp FnZeroAdjoint [v] Stmt.Numbered.Meta.empty in - let s = for_each_scalar f (to_var adlevel type_ id) in - if adlevel = UnsizedType.AutoDiffable then pp_statement ppf s + if UnsizedType.is_fun_type type_ then pf ppf "%s.set_zero_adjoints();" id + else pp_statement ppf (for_each_scalar f (to_var AutoDiffable type_ id)) in pf ppf "@[void set_zero_adjoints() const {@ if \ (stan::is_var::value) {@ %a@ }@ }@]" - (list ~sep:cut pp_loop) captures + (list ~sep:cut pp_loop) + (List.filter_map captures ~f:ad_filter) in let swrap pattern = Stmt.{Fixed.pattern; meta= Numbered.Meta.empty} in let pos = Expr.{Fixed.pattern= Var "pos__"; meta= Typed.Meta.empty} in @@ -379,7 +406,7 @@ let pp_closure_defs ppf closures = Expr.{Fixed.pattern= Indexed (v, [Single i]); meta= Typed.Meta.empty} in let pp_accumulateadjoints ppf captures = - let pp_loop ppf (ad, id, ut) = + let pp_loop ppf (id, ut) = let adj v = Expr.Helpers.internal_funapp FnGetAdjoint [v] Expr.Typed.Meta.empty in @@ -395,16 +422,20 @@ let pp_closure_defs ppf closures = |> swrap ] |> swrap in - let s = for_each_scalar go (to_var ad ut id) in - if ad = UnsizedType.AutoDiffable then pp_statement ppf s + if UnsizedType.is_fun_type ut then + pf ppf + "%s.accumulate_adjoints(ptr + (pos__ - 1));@,pos__ += %s.num_vars__;" + id id + else pp_statement ppf (for_each_scalar go (to_var AutoDiffable ut id)) in pf ppf "@[void accumulate_adjoints(double* ptr) const {@ if \ (stan::is_var::value) {@ size_t pos__ = 1;@ %a@ }@ }@]" - (list ~sep:cut pp_loop) captures + (list ~sep:cut pp_loop) + (List.filter_map captures ~f:ad_filter) in let pp_savevaris ppf captures = - let pp_loop ppf (ad, id, ut) = + let pp_loop ppf (id, ut) = let vari v = Expr.Helpers.internal_funapp FnGetVariPtr [v] Expr.Typed.Meta.empty in @@ -415,38 +446,35 @@ let pp_closure_defs ppf closures = |> swrap ] |> swrap in - let s = for_each_scalar go (to_var ad ut id) in - if ad = UnsizedType.AutoDiffable then pp_statement ppf s + if UnsizedType.is_fun_type ut then + pf ppf "%s.save_varis(ptr + (pos__ - 1));@,pos__ += %s.num_vars__;" id + id + else pp_statement ppf (for_each_scalar go (to_var AutoDiffable ut id)) in pf ppf "@[void save_varis(vari** ptr) const {@ if \ (stan::is_var::value) {@ size_t pos__ = 1;@ %a@ }@ }@]" - (list ~sep:cut pp_loop) captures + (list ~sep:cut pp_loop) + (List.filter_map captures ~f:ad_filter) in let pp_deepcopy ppf (rt, id, captures, args) = - let pp_arg ppf (ad, id, ut) = - if UnsizedType.is_scalar_type ut || ad = UnsizedType.AutoDiffable then - pf ppf "const %a %s" pp_unsizedtype_captured (ad, ut) id - else pf ppf "const %a& %s" pp_unsizedtype_captured (ad, ut) id - in - let pp_members ppf captures = - (list ~sep:cut (fun ppf a -> pf ppf "%a;" pp_arg a)) ppf captures - in let pp_init ppf (id, captures) = let pp_items ppf captures = if List.is_empty captures then pf ppf "" else pf ppf " : %a" - (list ~sep:comma (fun ppf (ad, n, _) -> - if ad = UnsizedType.AutoDiffable then - pf ppf "%s(deep_copy_vars(init.%s))" n n + (list ~sep:comma (fun ppf (ad, n, ut) -> + if + ad = UnsizedType.AutoDiffable + && not (UnsizedType.is_fun_type ut) + then pf ppf "%s(deep_copy_vars(init.%s))" n n else pf ppf "%s(init.%s)" n n )) captures in pf ppf "@[DeepCopy__(const %s__& init)%a { }@]" id pp_items captures in pf ppf "@[class DeepCopy__ {@ %a@ public:@ %a@ %a@ %a@ };@]" - pp_members captures pp_init (id, captures) pp_op + pp_members (pp_copytype, captures) pp_init (id, captures) pp_op ((rt, true), id, captures, args) pp_accumulateadjoints captures in @@ -454,9 +482,9 @@ let pp_closure_defs ppf closures = pf ppf "@,%a@[class %s__ {@ %a@ public:@ %s@ const int num_vars__;@ %a@ \ %a@ %a@ %a@ %a@ %a@ %a@]@,};@," - pp_template_decorator ["typename captured_t__"] key pp_members cdcaptures - "using captured_scalar_t__ = captured_t__;" pp_ctor (key, cdcaptures) - pp_op + pp_template_decorator ["typename captured_t__"] key pp_members + (pp_type, cdcaptures) "using captured_scalar_t__ = captured_t__;" pp_ctor + (key, cdcaptures) pp_op ((cdrt, true), key, cdcaptures, cdargs) pp_valueof (cdrt, key, cdcaptures, cdargs) diff --git a/test/integration/bad/ode/adams/stanc.expected b/test/integration/bad/ode/adams/stanc.expected index 183615c738..c2c303b91b 100644 --- a/test/integration/bad/ode/adams/stanc.expected +++ b/test/integration/bad/ode/adams/stanc.expected @@ -283,8 +283,10 @@ Semantic error in 'bad_x_var_type_control.stan', line 26, column 10 to line 32, ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../../install/default/bin/stanc bad_y_type.stan diff --git a/test/integration/bad/ode/stanc.expected b/test/integration/bad/ode/stanc.expected index 232aa4d20b..0621411d92 100644 --- a/test/integration/bad/ode/stanc.expected +++ b/test/integration/bad/ode/stanc.expected @@ -11,8 +11,10 @@ Semantic error in 'bad_bdf_control_function_return.stan', line 13, column 6 to l ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real, real[], real, real[], real[], real[], int[], int, int, int. $ ../../../../../install/default/bin/stanc bad_fun_type.stan @@ -44,8 +46,10 @@ Semantic error in 'bad_fun_type_bdf.stan', line 27, column 10 to line 33, column ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real[], real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_fun_type_bdf_control.stan @@ -61,8 +65,10 @@ Semantic error in 'bad_fun_type_bdf_control.stan', line 27, column 10 to line 33 ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real[], real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_fun_type_rk45.stan @@ -128,8 +134,10 @@ Semantic error in 'bad_t_type_bdf.stan', line 26, column 10 to line 32, column 2 ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], matrix, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_t_type_bdf_control.stan @@ -145,8 +153,10 @@ Semantic error in 'bad_t_type_bdf_control.stan', line 26, column 10 to line 32, ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], matrix, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_t_type_rk45.stan @@ -212,8 +222,10 @@ Semantic error in 'bad_theta_type_bdf.stan', line 27, column 10 to line 33, colu ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[,], real[], int[]. $ ../../../../../install/default/bin/stanc bad_theta_type_bdf_control.stan @@ -229,8 +241,10 @@ Semantic error in 'bad_theta_type_bdf_control.stan', line 27, column 10 to line ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[,], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_theta_type_rk45.stan @@ -296,8 +310,10 @@ Semantic error in 'bad_ts_type_bdf.stan', line 26, column 10 to line 32, column ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[,], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_ts_type_bdf_control.stan @@ -313,8 +329,10 @@ Semantic error in 'bad_ts_type_bdf_control.stan', line 26, column 10 to line 32, ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[,], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_ts_type_rk45.stan @@ -380,8 +398,10 @@ Semantic error in 'bad_x_int_type_bdf.stan', line 26, column 10 to line 32, colu ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[,]. $ ../../../../../install/default/bin/stanc bad_x_int_type_bdf_control.stan @@ -397,8 +417,10 @@ Semantic error in 'bad_x_int_type_bdf_control.stan', line 26, column 10 to line ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[,], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_int_type_rk45.stan @@ -464,8 +486,10 @@ Semantic error in 'bad_x_type_bdf.stan', line 27, column 10 to line 33, column 2 ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], vector[], int[]. $ ../../../../../install/default/bin/stanc bad_x_type_bdf_control.stan @@ -481,8 +505,10 @@ Semantic error in 'bad_x_type_bdf_control.stan', line 27, column 10 to line 33, ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], vector[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_type_rk45.stan @@ -548,8 +574,10 @@ Semantic error in 'bad_x_var_type_bdf.stan', line 26, column 10 to line 32, colu ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_x_var_type_bdf_control.stan @@ -565,8 +593,10 @@ Semantic error in 'bad_x_var_type_bdf_control.stan', line 26, column 10 to line ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_var_type_rk45.stan @@ -632,8 +662,10 @@ Semantic error in 'bad_y_type_bdf.stan', line 26, column 10 to line 32, column 2 ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[,], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_y_type_bdf_control.stan @@ -649,8 +681,10 @@ Semantic error in 'bad_y_type_bdf_control.stan', line 26, column 10 to line 32, ------------------------------------------------- Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] -((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[,], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_y_type_rk45.stan diff --git a/test/integration/good/code-gen/closure2.stan b/test/integration/good/code-gen/closure2.stan new file mode 100644 index 0000000000..717119a7a1 --- /dev/null +++ b/test/integration/good/code-gen/closure2.stan @@ -0,0 +1,27 @@ +transformed data { + functions + real foo(real x) { + return x; + } + functions + real bar(real y) { + return foo(y); + } +} +parameters { + real alpha; +} +transformed parameters { + functions + real baz(real y) { + return foo(y); + } + functions + real goo(real s) { + functions + real gar(real b) { + return b; + } + return gar(s); + } +} diff --git a/test/integration/good/code-gen/cpp.expected b/test/integration/good/code-gen/cpp.expected index a4e8217604..acd28feb6e 100644 --- a/test/integration/good/code-gen/cpp.expected +++ b/test/integration/good/code-gen/cpp.expected @@ -115,41 +115,97 @@ template typename boost::math::tools::promote_args::type -closure1_impl__(const T0__& z, const Eigen::Matrix& r, - const T2__& p, const std::vector& pa, - const Eigen::Matrix& pv, - const Eigen::Matrix& v, const double& x, - const std::vector& y, std::ostream* pstream__) ; +closure01_impl__(const T0__& z, const Eigen::Matrix& r, + const T2__& p, const std::vector& pa, + const Eigen::Matrix& pv, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) ; template typename boost::math::tools::promote_args::type -closure0_impl__(const T0__& z, const Eigen::Matrix& r, - const Eigen::Matrix& v, const double& x, - const std::vector& y, std::ostream* pstream__) ; +closure00_impl__(const T0__& z, const Eigen::Matrix& r, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) ; template -class closure0__ { +class closure00__ { const Eigen::Matrix& v; const double x; const std::vector& y; public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure0__(const Eigen::Matrix& v__, const double x__, - const std::vector& y__) : v(v__), x(x__), y(y__), num_vars__(0) { } + closure00__(const Eigen::Matrix& v__, const double x__, + const std::vector& y__) : v(v__), x(x__), + y(y__), num_vars__(stan::is_var::value ? 0 : 0) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& z, const Eigen::Matrix& - r, std::ostream* pstream__) const { - return closure0_impl__(z, r, v, x, y, pstream__);} + r, std::ostream* pstream__) const { + return closure00_impl__(z, r, v, x, y, pstream__); + } + + class ValueOf__ { + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + ValueOf__(const closure00__& init) : v(init.v), x(init.x), y(init.y) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure00_impl__(z, r, v, x, y, pstream__); + } + }; + class DeepCopy__ { + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + DeepCopy__(const closure00__& init) : v(init.v), x(init.x), y(init.y) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure00_impl__(z, r, v, x, y, pstream__); + } + + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } }; template -class closure1__ { +class closure01__ { const captured_t__ p; const std::vector& pa; const Eigen::Matrix& pv; @@ -159,18 +215,110 @@ class closure1__ { public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure1__(const captured_t__ p__, const std::vector& pa__, - const Eigen::Matrix& pv__, - const Eigen::Matrix& v__, const double x__, - const std::vector& y__) : p(p__), pa(pa__), pv(pv__), v(v__), - x(x__), y(y__), num_vars__(1 + num_elements(pa__) + num_elements(pv__)) { } + closure01__(const captured_t__ p__, const std::vector& pa__, + const Eigen::Matrix& pv__, + const Eigen::Matrix& v__, const double x__, + const std::vector& y__) : p(p__), pa(pa__), pv(pv__), + v(v__), x(x__), + y(y__), num_vars__(stan::is_var::value ? 1 + + num_elements(pa__) + num_elements(pv__) : 0) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& z, const Eigen::Matrix& - r, std::ostream* pstream__) const { - return closure1_impl__(z, r, p, pa, pv, v, x, y, pstream__);} + r, std::ostream* pstream__) const { + return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); + } + + class ValueOf__ { + const double p; + const std::vector pa; + const Eigen::Matrix pv; + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + ValueOf__(const closure01__& init) : p(value_of(init.p)), + pa(value_of(init.pa)), pv(value_of(init.pv)), v(init.v), x(init.x), + y(init.y) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); + } + }; + class DeepCopy__ { + const captured_t__ p; + const std::vector& pa; + const Eigen::Matrix& pv; + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + DeepCopy__(const closure01__& init) : p(deep_copy_vars(init.p)), + pa(deep_copy_vars(init.pa)), pv(deep_copy_vars(init.pv)), v(init.v), + x(init.x), y(init.y) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); + } + + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + pos__ = (pos__ + 1); + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pa[(sym1__ - 1)].adj()); + pos__ = (pos__ + 1);} + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pv[(sym1__ - 1)].adj()); + pos__ = (pos__ + 1);} + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + p.set_zero_adjoint(); + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { + pa[(sym1__ - 1)].set_zero_adjoint();} + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { + pv[(sym1__ - 1)].set_zero_adjoint();} + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + pos__ = (pos__ + 1); + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pa[(sym1__ - 1)].adj()); + pos__ = (pos__ + 1);} + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pv[(sym1__ - 1)].adj()); + pos__ = (pos__ + 1);} + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = p.vi_; + pos__ = (pos__ + 1); + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { + ptr[(pos__ - 1)] = pa[(sym1__ - 1)].vi_; + pos__ = (pos__ + 1);} + for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { + ptr[(pos__ - 1)] = pv[(sym1__ - 1)].vi_; + pos__ = (pos__ + 1);} + } + } }; @@ -178,11 +326,11 @@ template typename boost::math::tools::promote_args::type -closure1_impl__(const T0__& z, const Eigen::Matrix& r, - const T2__& p, const std::vector& pa, - const Eigen::Matrix& pv, - const Eigen::Matrix& v, const double& x, - const std::vector& y, std::ostream* pstream__) { +closure01_impl__(const T0__& z, const Eigen::Matrix& r, + const T2__& p, const std::vector& pa, + const Eigen::Matrix& pv, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args& r, template typename boost::math::tools::promote_args::type -closure0_impl__(const T0__& z, const Eigen::Matrix& r, - const Eigen::Matrix& v, const double& x, - const std::vector& y, std::ostream* pstream__) { +closure00_impl__(const T0__& z, const Eigen::Matrix& r, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; const static bool propto__ = true; @@ -292,7 +440,7 @@ class closure_model : public model_base_crtp { } current_statement__ = 4; - auto foo = closure0__(v, x, y); + auto foo = closure00__(v, x, y); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -328,7 +476,7 @@ class closure_model : public model_base_crtp { try { current_statement__ = 4; - auto foo = closure0__(v, x, y); + auto foo = closure00__(v, x, y); local_scalar_t__ p; current_statement__ = 1; @@ -353,7 +501,7 @@ class closure_model : public model_base_crtp { { current_statement__ = 5; - auto bar = closure1__(p, pa, pv, v, x, y); + auto bar = closure01__(p, pa, pv, v, x, y); current_statement__ = 6; lp_accum__.add( foo(0.0, stan::math::to_row_vector( @@ -401,7 +549,7 @@ class closure_model : public model_base_crtp { try { current_statement__ = 4; - auto foo = closure0__(v, x, y); + auto foo = closure00__(v, x, y); double p; current_statement__ = 1; @@ -639,11 +787,11 @@ stan::model::model_base& new_model( - $ ../../../../../install/default/bin/stanc --print-cpp eight_schools_ncp.stan + $ ../../../../../install/default/bin/stanc --print-cpp closure2.stan // Code generated by %%NAME%% %%VERSION%% #include -namespace eight_schools_ncp_model_namespace { +namespace closure2_model_namespace { template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { @@ -732,9979 +880,4454 @@ using namespace stan::math; static int current_statement__ = 0; static const std::vector locations_array__ = {" (found before start of program)", - " (in 'eight_schools_ncp.stan', line 8, column 2 to column 10)", - " (in 'eight_schools_ncp.stan', line 9, column 2 to column 20)", - " (in 'eight_schools_ncp.stan', line 10, column 2 to column 24)", - " (in 'eight_schools_ncp.stan', line 14, column 2 to column 43)", - " (in 'eight_schools_ncp.stan', line 18, column 2 to column 20)", - " (in 'eight_schools_ncp.stan', line 19, column 2 to column 21)", - " (in 'eight_schools_ncp.stan', line 20, column 2 to column 29)", - " (in 'eight_schools_ncp.stan', line 21, column 2 to column 27)", - " (in 'eight_schools_ncp.stan', line 2, column 2 to column 17)", - " (in 'eight_schools_ncp.stan', line 3, column 2 to column 12)", - " (in 'eight_schools_ncp.stan', line 4, column 2 to column 25)"}; + " (in 'closure2.stan', line 12, column 2 to column 13)", + " (in 'closure2.stan', line 2, column 2 to line 5, column 3)", + " (in 'closure2.stan', line 6, column 2 to line 9, column 3)", + " (in 'closure2.stan', line 15, column 2 to line 18, column 3)", + " (in 'closure2.stan', line 19, column 2 to line 26, column 3)", + " (in 'closure2.stan', line 4, column 4 to column 13)", + " (in 'closure2.stan', line 3, column 19 to line 5, column 3)", + " (in 'closure2.stan', line 8, column 4 to column 18)", + " (in 'closure2.stan', line 7, column 19 to line 9, column 3)", + " (in 'closure2.stan', line 17, column 4 to column 18)", + " (in 'closure2.stan', line 16, column 19 to line 18, column 3)", + " (in 'closure2.stan', line 21, column 4 to line 24, column 5)", + " (in 'closure2.stan', line 25, column 4 to column 18)", + " (in 'closure2.stan', line 20, column 19 to line 26, column 3)", + " (in 'closure2.stan', line 23, column 6 to column 15)", + " (in 'closure2.stan', line 22, column 21 to line 24, column 5)"}; +template +typename boost::math::tools::promote_args::type +closure04_impl__(const T0__& b, std::ostream* pstream__) ; +template +typename boost::math::tools::promote_args::type +closure03_impl__(const T0__& s, std::ostream* pstream__) ; +template +typename boost::math::tools::promote_args::type +closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; -class eight_schools_ncp_model : public model_base_crtp { +template +typename boost::math::tools::promote_args::type +closure00_impl__(const T0__& x, std::ostream* pstream__) ; - private: - int pos__; - int J; - std::vector y; - std::vector sigma; - - public: - ~eight_schools_ncp_model() { } + +template +class closure00__ { - std::string model_name() const { return "eight_schools_ncp_model"; } + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure00__() : num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& x, std::ostream* pstream__) const { + return closure00_impl__(x, pstream__); + } - eight_schools_ncp_model(stan::io::var_context& context__, - unsigned int random_seed__ = 0, - std::ostream* pstream__ = nullptr) : model_base_crtp(0) { - typedef double local_scalar_t__; - boost::ecuyer1988 base_rng__ = - stan::services::util::create_rng(random_seed__, 0); - (void) base_rng__; // suppress unused var warning - static const char* function__ = "eight_schools_ncp_model_namespace::eight_schools_ncp_model"; - (void) function__; // suppress unused var warning + class ValueOf__ { + + public: + ValueOf__(const closure00__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& x, std::ostream* pstream__) const { + return closure00_impl__(x, pstream__); + } + }; + class DeepCopy__ { + + public: + DeepCopy__(const closure00__& init) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& x, std::ostream* pstream__) const { + return closure00_impl__(x, pstream__); + } - try { - - pos__ = 1; - context__.validate_dims("data initialization","J","int", - context__.to_vec()); - - current_statement__ = 9; - J = context__.vals_i("J")[(1 - 1)]; - current_statement__ = 10; - validate_non_negative_index("y", "J", J); - context__.validate_dims("data initialization","y","double", - context__.to_vec(J)); - y = std::vector(J, 0); - - current_statement__ = 10; - assign(y, nil_index_list(), context__.vals_r("y"), - "assigning variable y"); - current_statement__ = 11; - validate_non_negative_index("sigma", "J", J); - context__.validate_dims("data initialization","sigma","double", - context__.to_vec(J)); - sigma = std::vector(J, 0); + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - current_statement__ = 11; - assign(sigma, nil_index_list(), context__.vals_r("sigma"), - "assigning variable sigma"); - current_statement__ = 9; - current_statement__ = 9; - check_greater_or_equal(function__, "J", J, 0); - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - current_statement__ = 11; - current_statement__ = 11; - check_greater_or_equal(function__, "sigma[sym1__]", - sigma[(sym1__ - 1)], 0);} - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + } - num_params_r__ = 0U; + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - try { - num_params_r__ += 1; - num_params_r__ += 1; - current_statement__ = 3; - validate_non_negative_index("theta_tilde", "J", J); - num_params_r__ += J; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } - } - template - T__ log_prob(std::vector& params_r__, std::vector& params_i__, - std::ostream* pstream__ = 0) const { - typedef T__ local_scalar_t__; - T__ lp__(0.0); - stan::math::accumulator lp_accum__; - static const char* function__ = "eight_schools_ncp_model_namespace::log_prob"; -(void) function__; // suppress unused var warning + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } +}; - stan::io::reader in__(params_r__, params_i__); +template +class closure01__ { + const closure00__& foo; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure01__(const closure00__& foo__) + : foo(foo__), num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, foo, pstream__); + } + + class ValueOf__ { + const typename closure00__::ValueOf__ foo; + public: + ValueOf__(const closure01__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, foo, pstream__); + } + }; + class DeepCopy__ { + const typename closure00__::DeepCopy__ foo; + public: + DeepCopy__(const closure01__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, foo, pstream__); + } - try { - local_scalar_t__ mu; + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - current_statement__ = 1; - mu = in__.scalar(); - local_scalar_t__ tau; - - current_statement__ = 2; - tau = in__.scalar(); - current_statement__ = 2; - if (jacobian__) { - current_statement__ = 2; - tau = stan::math::lb_constrain(tau, 0, lp__); - } else { - current_statement__ = 2; - tau = stan::math::lb_constrain(tau, 0); } - current_statement__ = 3; - validate_non_negative_index("theta_tilde", "J", J); - Eigen::Matrix theta_tilde; - theta_tilde = Eigen::Matrix(J); - - current_statement__ = 3; - theta_tilde = in__.vector(J); - current_statement__ = 4; - validate_non_negative_index("theta", "J", J); - Eigen::Matrix theta; - theta = Eigen::Matrix(J); - - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - current_statement__ = 4; - assign(theta, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta");} - current_statement__ = 4; - assign(theta, nil_index_list(), add(mu, multiply(tau, theta_tilde)), - "assigning variable theta"); - { - current_statement__ = 5; - lp_accum__.add(normal_log(mu, 0, 5)); - current_statement__ = 6; - lp_accum__.add(normal_log(tau, 0, 5)); - current_statement__ = 7; - lp_accum__.add(normal_log(theta_tilde, 0, 1)); - current_statement__ = 8; - lp_accum__.add(normal_log(y, theta, sigma)); } - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + } - lp_accum__.add(lp__); - return lp_accum__.sum(); - } // log_prob() + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - template - void write_array(RNG& base_rng__, std::vector& params_r__, - std::vector& params_i__, std::vector& vars__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true, - std::ostream* pstream__ = 0) const { - typedef double local_scalar_t__; - vars__.resize(0); - stan::io::reader in__(params_r__, params_i__); - static const char* function__ = "eight_schools_ncp_model_namespace::write_array"; -(void) function__; // suppress unused var warning - - (void) function__; // suppress unused var warning + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } +}; - double lp__ = 0.0; - (void) lp__; // dummy to suppress unused var warning - stan::math::accumulator lp_accum__; +template +class closure02__ { + const closure00__& foo; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure02__(const closure00__& foo__) + : foo(foo__), num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure02_impl__(y, foo, pstream__); + } + + class ValueOf__ { + const typename closure00__::ValueOf__ foo; + public: + ValueOf__(const closure02__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure02_impl__(y, foo, pstream__); + } + }; + class DeepCopy__ { + const typename closure00__::DeepCopy__ foo; + public: + DeepCopy__(const closure02__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure02_impl__(y, foo, pstream__); + } - try { - double mu; + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - current_statement__ = 1; - mu = in__.scalar(); - double tau; - - current_statement__ = 2; - tau = in__.scalar(); - current_statement__ = 2; - tau = stan::math::lb_constrain(tau, 0); - current_statement__ = 3; - validate_non_negative_index("theta_tilde", "J", J); - Eigen::Matrix theta_tilde; - theta_tilde = Eigen::Matrix(J); - - current_statement__ = 3; - theta_tilde = in__.vector(J); - current_statement__ = 4; - validate_non_negative_index("theta", "J", J); - Eigen::Matrix theta; - theta = Eigen::Matrix(J); - - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - current_statement__ = 4; - assign(theta, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta");} - vars__.push_back(mu); - vars__.push_back(tau); - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - vars__.push_back(theta_tilde[(sym1__ - 1)]);} - if (logical_negation((primitive_value(emit_transformed_parameters__) || - primitive_value(emit_generated_quantities__)))) { - return ; - } - current_statement__ = 4; - assign(theta, nil_index_list(), add(mu, multiply(tau, theta_tilde)), - "assigning variable theta"); - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - vars__.push_back(theta[(sym1__ - 1)]);} - if (logical_negation(emit_generated_quantities__)) { - return ; - } - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } // write_array() - - void transform_inits(const stan::io::var_context& context__, - std::vector& params_i__, - std::vector& vars__, std::ostream* pstream__) const { - typedef double local_scalar_t__; - vars__.resize(0); - vars__.reserve(num_params_r__); - - try { - int pos__; - - pos__ = 1; - double mu; - - current_statement__ = 1; - mu = context__.vals_r("mu")[(1 - 1)]; - double tau; - - current_statement__ = 2; - tau = context__.vals_r("tau")[(1 - 1)]; - current_statement__ = 2; - tau = stan::math::lb_free(tau, 0); - current_statement__ = 3; - validate_non_negative_index("theta_tilde", "J", J); - Eigen::Matrix theta_tilde; - theta_tilde = Eigen::Matrix(J); - - { - std::vector theta_tilde_flat__; - current_statement__ = 3; - assign(theta_tilde_flat__, nil_index_list(), - context__.vals_r("theta_tilde"), - "assigning variable theta_tilde_flat__"); - current_statement__ = 3; - pos__ = 1; - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - current_statement__ = 3; - assign(theta_tilde, cons_list(index_uni(sym1__), nil_index_list()), - theta_tilde_flat__[(pos__ - 1)], "assigning variable theta_tilde"); - current_statement__ = 3; - pos__ = (pos__ + 1);} } - vars__.push_back(mu); - vars__.push_back(tau); - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - vars__.push_back(theta_tilde[(sym1__ - 1)]);} - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } // transform_inits() - - void get_param_names(std::vector& names__) const { - - names__.resize(0); - names__.push_back("mu"); - names__.push_back("tau"); - names__.push_back("theta_tilde"); - names__.push_back("theta"); - } // get_param_names() - - void get_dims(std::vector>& dimss__) const { - dimss__.resize(0); - std::vector dims__; - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(J); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(J); - dimss__.push_back(dims__); - dims__.resize(0); - - } // get_dims() - - void constrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { - param_names__.push_back(std::string() + "mu"); - param_names__.push_back(std::string() + "tau"); - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - { - param_names__.push_back(std::string() + "theta_tilde" + '.' + std::to_string(sym1__)); - }} - if (emit_transformed_parameters__) { - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - { - param_names__.push_back(std::string() + "theta" + '.' + std::to_string(sym1__)); - }} } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - if (emit_generated_quantities__) { - } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - } // constrained_param_names() + } + } +}; + +template +class closure03__ { + + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure03__() : num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& s, std::ostream* pstream__) const { + return closure03_impl__(s, pstream__); + } + + class ValueOf__ { + + public: + ValueOf__(const closure03__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& s, std::ostream* pstream__) const { + return closure03_impl__(s, pstream__); + } + }; + class DeepCopy__ { + + public: + DeepCopy__(const closure03__& init) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& s, std::ostream* pstream__) const { + return closure03_impl__(s, pstream__); + } - void unconstrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { - param_names__.push_back(std::string() + "mu"); - param_names__.push_back(std::string() + "tau"); - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - { - param_names__.push_back(std::string() + "theta_tilde" + '.' + std::to_string(sym1__)); - }} - if (emit_transformed_parameters__) { - for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { - { - param_names__.push_back(std::string() + "theta" + '.' + std::to_string(sym1__)); - }} } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - if (emit_generated_quantities__) { - } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - } // unconstrained_param_names() + } + } +}; + +template +class closure04__ { + + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure04__() : num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& b, std::ostream* pstream__) const { + return closure04_impl__(b, pstream__); + } + + class ValueOf__ { + + public: + ValueOf__(const closure04__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& b, std::ostream* pstream__) const { + return closure04_impl__(b, pstream__); + } + }; + class DeepCopy__ { + + public: + DeepCopy__(const closure04__& init) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& b, std::ostream* pstream__) const { + return closure04_impl__(b, pstream__); + } - std::string get_constrained_sizedtypes() const { - stringstream s__; - s__ << "[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"theta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"parameters\"},{\"name\":\"theta\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"transformed_parameters\"}]"; - return s__.str(); - } // get_constrained_sizedtypes() + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { - std::string get_unconstrained_sizedtypes() const { - stringstream s__; - s__ << "[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"theta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"parameters\"},{\"name\":\"theta\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"transformed_parameters\"}]"; - return s__.str(); - } // get_unconstrained_sizedtypes() + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; - - // Begin method overload boilerplate - template - void write_array(RNG& base_rng__, - Eigen::Matrix& params_r, - Eigen::Matrix& vars, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true, - std::ostream* pstream = 0) const { - std::vector params_r_vec(params_r.size()); - for (int i = 0; i < params_r.size(); ++i) - params_r_vec[i] = params_r(i); - std::vector vars_vec; - std::vector params_i_vec; - write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, - emit_transformed_parameters__, emit_generated_quantities__, pstream); - vars.resize(vars_vec.size()); - for (int i = 0; i < vars.size(); ++i) - vars(i) = vars_vec[i]; } - - template - T_ log_prob(Eigen::Matrix& params_r, - std::ostream* pstream = 0) const { - std::vector vec_params_r; - vec_params_r.reserve(params_r.size()); - for (int i = 0; i < params_r.size(); ++i) - vec_params_r.push_back(params_r(i)); - std::vector vec_params_i; - return log_prob(vec_params_r, vec_params_i, pstream); } - - void transform_inits(const stan::io::var_context& context, - Eigen::Matrix& params_r, - std::ostream* pstream__) const { - std::vector params_r_vec; - std::vector params_i_vec; - transform_inits(context, params_i_vec, params_r_vec, pstream__); - params_r.resize(params_r_vec.size()); - for (int i = 0; i < params_r.size(); ++i) - params_r(i) = params_r_vec[i]; + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } } - }; -} - -typedef eight_schools_ncp_model_namespace::eight_schools_ncp_model stan_model; -#ifndef USING_R -// Boilerplate -stan::model::model_base& new_model( - stan::io::var_context& data_context, - unsigned int seed, - std::ostream* msg_stream) { - stan_model* m = new stan_model(data_context, seed, msg_stream); - return *m; -} - -#endif - - - - $ ../../../../../install/default/bin/stanc --print-cpp mother.stan - -// Code generated by %%NAME%% %%VERSION%% -#include -namespace mother_model_namespace { - -template -std::vector resize_to_match__(std::vector& dst, const std::vector& src) { - dst.resize(src.size()); - return dst; -} - -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.rows(), src.cols()); - return dst; -} - -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.size()); - return dst; +template +typename boost::math::tools::promote_args::type +closure04_impl__(const T0__& b, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 15; + return b; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } - -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.size()); - return dst; +template +typename boost::math::tools::promote_args::type +closure03_impl__(const T0__& s, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + + current_statement__ = 12; + auto gar = closure04__(); + current_statement__ = 13; + return gar(s, pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } -std::vector to_doubles__(std::initializer_list x) { - return x; +template +typename boost::math::tools::promote_args::type +closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 10; + return foo(y, pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } - -std::vector to_vars__(std::initializer_list x) { - return x; +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 8; + return foo(y, pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } - -inline void validate_positive_index(const char* var_name, const char* expr, - int val) { - if (val < 1) { - std::stringstream msg; - msg << "Found dimension size less than one in simplex declaration" - << "; variable=" << var_name << "; dimension size expression=" << expr - << "; expression value=" << val; - std::string msg_str(msg.str()); - throw std::invalid_argument(msg_str.c_str()); +template +typename boost::math::tools::promote_args::type +closure00_impl__(const T0__& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 6; + return x; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } + } +class closure2_model : public model_base_crtp { -inline void validate_unit_vector_index(const char* var_name, const char* expr, - int val) { - if (val <= 1) { - std::stringstream msg; - if (val == 1) { - msg << "Found dimension size one in unit vector declaration." - << " One-dimensional unit vector is discrete" - << " but the target distribution must be continuous." - << " variable=" << var_name << "; dimension size expression=" << expr; - } else { - msg << "Found dimension size less than one in unit vector declaration" - << "; variable=" << var_name << "; dimension size expression=" << expr - << "; expression value=" << val; + private: + int pos__; + + public: + ~closure2_model() { } + + std::string model_name() const { return "closure2_model"; } + + closure2_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "closure2_model_namespace::closure2_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + + current_statement__ = 2; + auto foo = closure00__(); + + current_statement__ = 3; + auto bar = closure01__(foo); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + num_params_r__ += 1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } - std::string msg_str(msg.str()); - throw std::invalid_argument(msg_str.c_str()); } -} + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "closure2_model_namespace::log_prob"; +(void) function__; // suppress unused var warning + stan::io::reader in__(params_r__, params_i__); + + try { + + current_statement__ = 2; + auto foo = closure00__(); + + current_statement__ = 3; + auto bar = closure01__(foo); + local_scalar_t__ alpha; + + current_statement__ = 1; + alpha = in__.scalar(); + + current_statement__ = 4; + auto baz = closure02__(foo); + + current_statement__ = 5; + auto goo = closure03__(); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() + + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "closure2_model_namespace::write_array"; +(void) function__; // suppress unused var warning -using std::istream; -using std::string; -using std::stringstream; -using std::vector; -using std::pow; -using stan::io::dump; -using stan::math::lgamma; -using stan::model::model_base_crtp; -using stan::model::rvalue; -using stan::model::cons_list; -using stan::model::index_uni; -using stan::model::index_max; -using stan::model::index_min; -using stan::model::index_min_max; -using stan::model::index_multi; -using stan::model::index_omni; -using stan::model::nil_index_list; -using namespace stan::math; + (void) function__; // suppress unused var warning -static int current_statement__ = 0; -static const std::vector locations_array__ = {" (found before start of program)", - " (in 'mother.stan', line 401, column 2 to column 14)", - " (in 'mother.stan', line 402, column 2 to column 52)", - " (in 'mother.stan', line 403, column 2 to column 45)", - " (in 'mother.stan', line 404, column 2 to column 41)", - " (in 'mother.stan', line 405, column 2 to column 32)", - " (in 'mother.stan', line 406, column 2 to column 36)", - " (in 'mother.stan', line 407, column 2 to column 27)", - " (in 'mother.stan', line 408, column 2 to column 24)", - " (in 'mother.stan', line 409, column 2 to column 28)", - " (in 'mother.stan', line 410, column 2 to column 26)", - " (in 'mother.stan', line 411, column 2 to column 32)", - " (in 'mother.stan', line 412, column 2 to column 36)", - " (in 'mother.stan', line 413, column 2 to column 45)", - " (in 'mother.stan', line 414, column 2 to column 23)", - " (in 'mother.stan', line 415, column 2 to column 29)", - " (in 'mother.stan', line 416, column 2 to column 33)", - " (in 'mother.stan', line 417, column 2 to column 38)", - " (in 'mother.stan', line 418, column 2 to column 36)", - " (in 'mother.stan', line 419, column 2 to column 42)", - " (in 'mother.stan', line 420, column 2 to column 16)", - " (in 'mother.stan', line 421, column 2 to column 16)", - " (in 'mother.stan', line 424, column 2 to column 33)", - " (in 'mother.stan', line 425, column 2 to column 37)", - " (in 'mother.stan', line 426, column 2 to column 28)", - " (in 'mother.stan', line 427, column 2 to column 25)", - " (in 'mother.stan', line 428, column 2 to column 29)", - " (in 'mother.stan', line 429, column 2 to column 27)", - " (in 'mother.stan', line 430, column 2 to column 33)", - " (in 'mother.stan', line 431, column 2 to column 37)", - " (in 'mother.stan', line 432, column 2 to column 46)", - " (in 'mother.stan', line 433, column 2 to column 24)", - " (in 'mother.stan', line 434, column 2 to column 30)", - " (in 'mother.stan', line 435, column 2 to column 34)", - " (in 'mother.stan', line 436, column 2 to column 39)", - " (in 'mother.stan', line 437, column 2 to column 37)", - " (in 'mother.stan', line 438, column 2 to column 43)", - " (in 'mother.stan', line 439, column 2 to column 20)", - " (in 'mother.stan', line 441, column 2 to column 31)", - " (in 'mother.stan', line 442, column 2 to column 31)", - " (in 'mother.stan', line 443, column 2 to column 23)", - " (in 'mother.stan', line 444, column 2 to column 23)", - " (in 'mother.stan', line 446, column 2 to column 25)", - " (in 'mother.stan', line 447, column 2 to column 31)", - " (in 'mother.stan', line 448, column 2 to column 31)", - " (in 'mother.stan', line 450, column 2 to column 27)", - " (in 'mother.stan', line 451, column 2 to column 27)", - " (in 'mother.stan', line 452, column 2 to column 33)", - " (in 'mother.stan', line 458, column 10 to column 38)", - " (in 'mother.stan', line 457, column 23 to line 458, column 39)", - " (in 'mother.stan', line 457, column 8 to line 458, column 39)", - " (in 'mother.stan', line 456, column 21 to line 458, column 40)", - " (in 'mother.stan', line 456, column 6 to line 458, column 40)", - " (in 'mother.stan', line 455, column 19 to line 458, column 41)", - " (in 'mother.stan', line 455, column 4 to line 458, column 41)", - " (in 'mother.stan', line 454, column 17 to line 458, column 42)", - " (in 'mother.stan', line 454, column 2 to line 458, column 42)", - " (in 'mother.stan', line 460, column 17 to column 45)", - " (in 'mother.stan', line 460, column 2 to column 45)", - " (in 'mother.stan', line 461, column 2 to column 29)", - " (in 'mother.stan', line 462, column 2 to column 31)", - " (in 'mother.stan', line 463, column 2 to column 31)", - " (in 'mother.stan', line 465, column 2 to column 63)", - " (in 'mother.stan', line 466, column 2 to column 79)", - " (in 'mother.stan', line 467, column 2 to column 81)", - " (in 'mother.stan', line 468, column 2 to column 65)", - " (in 'mother.stan', line 469, column 2 to column 81)", - " (in 'mother.stan', line 470, column 2 to column 67)", - " (in 'mother.stan', line 471, column 2 to column 83)", - " (in 'mother.stan', line 515, column 2 to column 32)", - " (in 'mother.stan', line 516, column 2 to column 27)", - " (in 'mother.stan', line 517, column 2 to column 35)", - " (in 'mother.stan', line 518, column 2 to column 39)", - " (in 'mother.stan', line 519, column 2 to column 28)", - " (in 'mother.stan', line 520, column 2 to column 25)", - " (in 'mother.stan', line 521, column 2 to column 29)", - " (in 'mother.stan', line 522, column 2 to column 27)", - " (in 'mother.stan', line 523, column 2 to column 33)", - " (in 'mother.stan', line 524, column 2 to column 37)", - " (in 'mother.stan', line 525, column 2 to column 46)", - " (in 'mother.stan', line 526, column 2 to column 24)", - " (in 'mother.stan', line 527, column 2 to column 30)", - " (in 'mother.stan', line 528, column 2 to column 34)", - " (in 'mother.stan', line 529, column 2 to column 39)", - " (in 'mother.stan', line 530, column 2 to column 37)", - " (in 'mother.stan', line 531, column 2 to column 43)", - " (in 'mother.stan', line 532, column 2 to column 29)", - " (in 'mother.stan', line 533, column 2 to column 31)", - " (in 'mother.stan', line 534, column 2 to column 27)", - " (in 'mother.stan', line 535, column 2 to column 27)", - " (in 'mother.stan', line 536, column 2 to column 27)", - " (in 'mother.stan', line 537, column 2 to column 28)", - " (in 'mother.stan', line 538, column 2 to column 28)", - " (in 'mother.stan', line 539, column 2 to column 28)", - " (in 'mother.stan', line 540, column 2 to column 28)", - " (in 'mother.stan', line 541, column 2 to column 24)", - " (in 'mother.stan', line 543, column 2 to column 35)", - " (in 'mother.stan', line 544, column 2 to column 31)", - " (in 'mother.stan', line 545, column 2 to column 23)", - " (in 'mother.stan', line 546, column 2 to column 23)", - " (in 'mother.stan', line 547, column 2 to column 25)", - " (in 'mother.stan', line 548, column 2 to column 31)", - " (in 'mother.stan', line 549, column 2 to column 31)", - " (in 'mother.stan', line 551, column 2 to column 35)", - " (in 'mother.stan', line 552, column 2 to column 31)", - " (in 'mother.stan', line 553, column 2 to column 31)", - " (in 'mother.stan', line 555, column 2 to column 27)", - " (in 'mother.stan', line 556, column 2 to column 27)", - " (in 'mother.stan', line 557, column 2 to column 33)", - " (in 'mother.stan', line 563, column 10 to column 38)", - " (in 'mother.stan', line 562, column 23 to line 563, column 39)", - " (in 'mother.stan', line 562, column 8 to line 563, column 39)", - " (in 'mother.stan', line 561, column 21 to line 563, column 40)", - " (in 'mother.stan', line 561, column 6 to line 563, column 40)", - " (in 'mother.stan', line 560, column 19 to line 563, column 41)", - " (in 'mother.stan', line 560, column 4 to line 563, column 41)", - " (in 'mother.stan', line 559, column 17 to line 563, column 42)", - " (in 'mother.stan', line 559, column 2 to line 563, column 42)", - " (in 'mother.stan', line 565, column 17 to column 45)", - " (in 'mother.stan', line 565, column 2 to column 45)", - " (in 'mother.stan', line 571, column 8 to column 49)", - " (in 'mother.stan', line 570, column 6 to line 571, column 49)", - " (in 'mother.stan', line 569, column 4 to line 571, column 49)", - " (in 'mother.stan', line 568, column 2 to line 571, column 49)", - " (in 'mother.stan', line 576, column 6 to column 60)", - " (in 'mother.stan', line 575, column 4 to line 576, column 60)", - " (in 'mother.stan', line 574, column 2 to line 576, column 60)", - " (in 'mother.stan', line 578, column 2 to column 45)", - " (in 'mother.stan', line 579, column 64 to column 97)", - " (in 'mother.stan', line 579, column 2 to column 97)", - " (in 'mother.stan', line 584, column 6 to column 51)", - " (in 'mother.stan', line 583, column 4 to line 584, column 51)", - " (in 'mother.stan', line 582, column 2 to line 584, column 51)", - " (in 'mother.stan', line 585, column 2 to column 39)", - " (in 'mother.stan', line 587, column 58 to column 91)", - " (in 'mother.stan', line 587, column 2 to column 91)", - " (in 'mother.stan', line 593, column 8 to column 68)", - " (in 'mother.stan', line 592, column 6 to line 593, column 68)", - " (in 'mother.stan', line 591, column 4 to line 593, column 68)", - " (in 'mother.stan', line 590, column 2 to line 593, column 68)", - " (in 'mother.stan', line 594, column 2 to column 48)", - " (in 'mother.stan', line 595, column 67 to column 100)", - " (in 'mother.stan', line 595, column 2 to column 100)", - " (in 'mother.stan', line 597, column 2 to column 36)", - " (in 'mother.stan', line 598, column 2 to column 38)", - " (in 'mother.stan', line 474, column 2 to column 16)", - " (in 'mother.stan', line 475, column 2 to column 20)", - " (in 'mother.stan', line 476, column 2 to column 29)", - " (in 'mother.stan', line 477, column 2 to column 24)", - " (in 'mother.stan', line 478, column 2 to column 23)", - " (in 'mother.stan', line 479, column 2 to column 35)", - " (in 'mother.stan', line 481, column 2 to column 38)", - " (in 'mother.stan', line 482, column 2 to column 38)", - " (in 'mother.stan', line 484, column 2 to column 41)", - " (in 'mother.stan', line 486, column 4 to column 42)", - " (in 'mother.stan', line 487, column 4 to column 46)", - " (in 'mother.stan', line 488, column 4 to column 46)", - " (in 'mother.stan', line 491, column 8 to column 68)", - " (in 'mother.stan', line 492, column 8 to column 76)", - " (in 'mother.stan', line 493, column 8 to column 76)", - " (in 'mother.stan', line 494, column 8 to column 65)", - " (in 'mother.stan', line 490, column 21 to line 495, column 7)", - " (in 'mother.stan', line 490, column 6 to line 495, column 7)", - " (in 'mother.stan', line 489, column 19 to line 496, column 5)", - " (in 'mother.stan', line 489, column 4 to line 496, column 5)", - " (in 'mother.stan', line 485, column 17 to line 497, column 3)", - " (in 'mother.stan', line 485, column 2 to line 497, column 3)", - " (in 'mother.stan', line 500, column 6 to column 47)", - " (in 'mother.stan', line 499, column 19 to line 501, column 5)", - " (in 'mother.stan', line 499, column 4 to line 501, column 5)", - " (in 'mother.stan', line 498, column 17 to line 502, column 3)", - " (in 'mother.stan', line 498, column 2 to line 502, column 3)", - " (in 'mother.stan', line 504, column 4 to column 47)", - " (in 'mother.stan', line 503, column 17 to line 505, column 3)", - " (in 'mother.stan', line 503, column 2 to line 505, column 3)", - " (in 'mother.stan', line 506, column 2 to column 38)", - " (in 'mother.stan', line 507, column 2 to column 38)", - " (in 'mother.stan', line 508, column 2 to column 38)", - " (in 'mother.stan', line 509, column 2 to column 39)", - " (in 'mother.stan', line 510, column 2 to column 39)", - " (in 'mother.stan', line 512, column 2 to column 53)", - " (in 'mother.stan', line 316, column 2 to column 17)", - " (in 'mother.stan', line 317, column 2 to column 17)", - " (in 'mother.stan', line 318, column 2 to column 28)", - " (in 'mother.stan', line 319, column 2 to column 30)", - " (in 'mother.stan', line 320, column 2 to column 34)", - " (in 'mother.stan', line 321, column 2 to column 32)", - " (in 'mother.stan', line 322, column 2 to column 23)", - " (in 'mother.stan', line 323, column 2 to column 27)", - " (in 'mother.stan', line 324, column 2 to column 18)", - " (in 'mother.stan', line 325, column 2 to column 24)", - " (in 'mother.stan', line 326, column 2 to column 28)", - " (in 'mother.stan', line 327, column 2 to column 26)", - " (in 'mother.stan', line 328, column 2 to column 32)", - " (in 'mother.stan', line 329, column 2 to column 36)", - " (in 'mother.stan', line 330, column 2 to column 45)", - " (in 'mother.stan', line 331, column 2 to column 23)", - " (in 'mother.stan', line 332, column 2 to column 29)", - " (in 'mother.stan', line 333, column 2 to column 33)", - " (in 'mother.stan', line 334, column 2 to column 38)", - " (in 'mother.stan', line 335, column 2 to column 36)", - " (in 'mother.stan', line 336, column 2 to column 42)", - " (in 'mother.stan', line 339, column 2 to column 13)", - " (in 'mother.stan', line 340, column 2 to column 15)", - " (in 'mother.stan', line 341, column 2 to column 34)", - " (in 'mother.stan', line 342, column 2 to column 15)", - " (in 'mother.stan', line 343, column 2 to column 20)", - " (in 'mother.stan', line 344, column 2 to column 29)", - " (in 'mother.stan', line 345, column 2 to column 46)", - " (in 'mother.stan', line 346, column 2 to column 24)", - " (in 'mother.stan', line 347, column 2 to column 30)", - " (in 'mother.stan', line 348, column 2 to column 34)", - " (in 'mother.stan', line 349, column 2 to column 39)", - " (in 'mother.stan', line 350, column 2 to column 37)", - " (in 'mother.stan', line 351, column 2 to column 14)", - " (in 'mother.stan', line 352, column 2 to column 14)", - " (in 'mother.stan', line 353, column 2 to column 14)", - " (in 'mother.stan', line 354, column 2 to column 17)", - " (in 'mother.stan', line 355, column 2 to column 17)", - " (in 'mother.stan', line 356, column 2 to column 16)", - " (in 'mother.stan', line 357, column 2 to column 18)", - " (in 'mother.stan', line 358, column 2 to column 18)", - " (in 'mother.stan', line 363, column 10 to column 38)", - " (in 'mother.stan', line 362, column 23 to line 363, column 39)", - " (in 'mother.stan', line 362, column 8 to line 363, column 39)", - " (in 'mother.stan', line 361, column 21 to line 363, column 40)", - " (in 'mother.stan', line 361, column 6 to line 363, column 40)", - " (in 'mother.stan', line 360, column 19 to line 363, column 41)", - " (in 'mother.stan', line 360, column 4 to line 363, column 41)", - " (in 'mother.stan', line 359, column 17 to line 363, column 42)", - " (in 'mother.stan', line 359, column 2 to line 363, column 42)", - " (in 'mother.stan', line 365, column 4 to column 28)", - " (in 'mother.stan', line 367, column 6 to column 36)", - " (in 'mother.stan', line 370, column 10 to column 46)", - " (in 'mother.stan', line 369, column 23 to line 370, column 47)", - " (in 'mother.stan', line 369, column 8 to line 370, column 47)", - " (in 'mother.stan', line 368, column 21 to line 370, column 48)", - " (in 'mother.stan', line 368, column 6 to line 370, column 48)", - " (in 'mother.stan', line 366, column 19 to line 370, column 49)", - " (in 'mother.stan', line 366, column 4 to line 370, column 49)", - " (in 'mother.stan', line 364, column 17 to line 370, column 50)", - " (in 'mother.stan', line 364, column 2 to line 370, column 50)", - " (in 'mother.stan', line 373, column 6 to column 40)", - " (in 'mother.stan', line 374, column 6 to column 63)", - " (in 'mother.stan', line 372, column 19 to line 375, column 5)", - " (in 'mother.stan', line 372, column 4 to line 375, column 5)", - " (in 'mother.stan', line 371, column 17 to line 375, column 6)", - " (in 'mother.stan', line 371, column 2 to line 375, column 6)", - " (in 'mother.stan', line 376, column 2 to column 62)", - " (in 'mother.stan', line 377, column 2 to column 62)", - " (in 'mother.stan', line 379, column 4 to column 11)", - " (in 'mother.stan', line 380, column 4 to column 35)", - " (in 'mother.stan', line 381, column 4 to line 383, column 5)", - " (in 'mother.stan', line 382, column 6 to column 12)", - " (in 'mother.stan', line 384, column 4 to column 31)", - " (in 'mother.stan', line 385, column 4 to line 387, column 5)", - " (in 'mother.stan', line 386, column 6 to column 12)", - " (in 'mother.stan', line 378, column 2 to line 388, column 3)", - " (in 'mother.stan', line 390, column 2 to column 25)", - " (in 'mother.stan', line 391, column 2 to column 34)", - " (in 'mother.stan', line 392, column 2 to column 33)", - " (in 'mother.stan', line 393, column 2 to column 36)", - " (in 'mother.stan', line 395, column 2 to column 23)", - " (in 'mother.stan', line 396, column 2 to column 30)", - " (in 'mother.stan', line 398, column 2 to column 28)", - " (in 'mother.stan', line 10, column 16 to column 17)", - " (in 'mother.stan', line 13, column 16 to column 25)", - " (in 'mother.stan', line 13, column 4 to column 25)", - " (in 'mother.stan', line 14, column 4 to column 26)", - " (in 'mother.stan', line 12, column 17 to line 15, column 3)", - " (in 'mother.stan', line 22, column 31 to column 32)", - " (in 'mother.stan', line 29, column 4 to column 17)", - " (in 'mother.stan', line 30, column 4 to column 19)", - " (in 'mother.stan', line 31, column 4 to column 38)", - " (in 'mother.stan', line 32, column 4 to column 16)", - " (in 'mother.stan', line 28, column 31 to line 33, column 3)", - " (in 'mother.stan', line 36, column 4 to column 15)", - " (in 'mother.stan', line 35, column 18 to line 37, column 3)", - " (in 'mother.stan', line 40, column 4 to column 15)", - " (in 'mother.stan', line 39, column 24 to line 41, column 3)", - " (in 'mother.stan', line 44, column 4 to column 15)", - " (in 'mother.stan', line 43, column 32 to line 45, column 3)", - " (in 'mother.stan', line 48, column 4 to column 15)", - " (in 'mother.stan', line 47, column 36 to line 49, column 3)", - " (in 'mother.stan', line 52, column 4 to column 15)", - " (in 'mother.stan', line 51, column 36 to line 53, column 3)", - " (in 'mother.stan', line 56, column 4 to column 15)", - " (in 'mother.stan', line 55, column 37 to line 57, column 3)", - " (in 'mother.stan', line 59, column 4 to column 33)", - " (in 'mother.stan', line 58, column 36 to line 60, column 3)", - " (in 'mother.stan', line 63, column 4 to column 42)", - " (in 'mother.stan', line 64, column 4 to column 26)", - " (in 'mother.stan', line 62, column 30 to line 65, column 3)", - " (in 'mother.stan', line 69, column 14 to column 20)", - " (in 'mother.stan', line 69, column 4 to column 20)", - " (in 'mother.stan', line 70, column 14 to column 23)", - " (in 'mother.stan', line 70, column 4 to column 23)", - " (in 'mother.stan', line 73, column 20 to column 26)", - " (in 'mother.stan', line 73, column 4 to column 26)", - " (in 'mother.stan', line 74, column 20 to column 29)", - " (in 'mother.stan', line 74, column 4 to column 29)", - " (in 'mother.stan', line 78, column 6 to column 12)", - " (in 'mother.stan', line 79, column 6 to column 12)", - " (in 'mother.stan', line 80, column 6 to column 12)", - " (in 'mother.stan', line 77, column 14 to line 81, column 5)", - " (in 'mother.stan', line 77, column 4 to line 81, column 5)", - " (in 'mother.stan', line 87, column 11 to column 17)", - " (in 'mother.stan', line 86, column 18 to column 24)", - " (in 'mother.stan', line 86, column 11 to line 87, column 17)", - " (in 'mother.stan', line 85, column 13 to column 19)", - " (in 'mother.stan', line 85, column 6 to line 87, column 17)", - " (in 'mother.stan', line 84, column 14 to line 88, column 5)", - " (in 'mother.stan', line 84, column 4 to line 88, column 5)", - " (in 'mother.stan', line 91, column 24 to column 30)", - " (in 'mother.stan', line 91, column 14 to column 30)", - " (in 'mother.stan', line 91, column 4 to column 30)", - " (in 'mother.stan', line 95, column 22 to column 28)", - " (in 'mother.stan', line 95, column 6 to column 28)", - " (in 'mother.stan', line 94, column 14 to line 96, column 5)", - " (in 'mother.stan', line 94, column 4 to line 96, column 5)", - " (in 'mother.stan', line 100, column 6 to column 19)", - " (in 'mother.stan', line 101, column 6 to column 12)", - " (in 'mother.stan', line 102, column 6 to line 105, column 7)", - " (in 'mother.stan', line 103, column 8 to column 14)", - " (in 'mother.stan', line 104, column 8 to column 14)", - " (in 'mother.stan', line 106, column 6 to line 109, column 7)", - " (in 'mother.stan', line 107, column 8 to column 14)", - " (in 'mother.stan', line 108, column 8 to column 17)", - " (in 'mother.stan', line 110, column 6 to line 116, column 7)", - " (in 'mother.stan', line 111, column 8 to line 114, column 9)", - " (in 'mother.stan', line 112, column 10 to column 16)", - " (in 'mother.stan', line 113, column 10 to column 16)", - " (in 'mother.stan', line 115, column 8 to column 14)", - " (in 'mother.stan', line 99, column 14 to line 117, column 5)", - " (in 'mother.stan', line 99, column 4 to line 117, column 5)", - " (in 'mother.stan', line 121, column 6 to column 13)", - " (in 'mother.stan', line 122, column 6 to column 21)", - " (in 'mother.stan', line 123, column 6 to line 126, column 7)", - " (in 'mother.stan', line 124, column 8 to column 14)", - " (in 'mother.stan', line 125, column 8 to column 14)", - " (in 'mother.stan', line 127, column 6 to line 130, column 7)", - " (in 'mother.stan', line 128, column 8 to column 16)", - " (in 'mother.stan', line 129, column 8 to column 17)", - " (in 'mother.stan', line 120, column 14 to line 131, column 5)", - " (in 'mother.stan', line 120, column 4 to line 131, column 5)", - " (in 'mother.stan', line 135, column 6 to column 13)", - " (in 'mother.stan', line 136, column 6 to column 19)", - " (in 'mother.stan', line 137, column 6 to line 140, column 7)", - " (in 'mother.stan', line 138, column 8 to column 14)", - " (in 'mother.stan', line 139, column 8 to column 14)", - " (in 'mother.stan', line 141, column 6 to line 144, column 7)", - " (in 'mother.stan', line 142, column 8 to column 16)", - " (in 'mother.stan', line 143, column 8 to column 17)", - " (in 'mother.stan', line 134, column 14 to line 145, column 5)", - " (in 'mother.stan', line 134, column 4 to line 145, column 5)", - " (in 'mother.stan', line 149, column 6 to column 13)", - " (in 'mother.stan', line 150, column 6 to column 23)", - " (in 'mother.stan', line 151, column 6 to line 154, column 7)", - " (in 'mother.stan', line 152, column 8 to column 14)", - " (in 'mother.stan', line 153, column 8 to column 14)", - " (in 'mother.stan', line 155, column 6 to line 158, column 7)", - " (in 'mother.stan', line 156, column 8 to column 16)", - " (in 'mother.stan', line 157, column 8 to column 17)", - " (in 'mother.stan', line 148, column 14 to line 159, column 5)", - " (in 'mother.stan', line 148, column 4 to line 159, column 5)", - " (in 'mother.stan', line 163, column 6 to column 12)", - " (in 'mother.stan', line 164, column 6 to column 12)", - " (in 'mother.stan', line 166, column 8 to column 14)", - " (in 'mother.stan', line 167, column 8 to column 14)", - " (in 'mother.stan', line 168, column 8 to column 14)", - " (in 'mother.stan', line 165, column 6 to line 169, column 7)", - " (in 'mother.stan', line 162, column 14 to line 170, column 5)", - " (in 'mother.stan', line 162, column 4 to line 170, column 5)", - " (in 'mother.stan', line 172, column 4 to column 13)", - " (in 'mother.stan', line 67, column 19 to line 173, column 3)", - " (in 'mother.stan', line 176, column 4 to column 14)", - " (in 'mother.stan', line 177, column 4 to column 10)", - " (in 'mother.stan', line 178, column 4 to column 24)", - " (in 'mother.stan', line 178, column 18 to column 24)", - " (in 'mother.stan', line 179, column 4 to column 13)", - " (in 'mother.stan', line 175, column 19 to line 180, column 3)", - " (in 'mother.stan', line 183, column 4 to column 26)", - " (in 'mother.stan', line 182, column 30 to line 184, column 3)", - " (in 'mother.stan', line 187, column 4 to column 24)", - " (in 'mother.stan', line 186, column 22 to line 188, column 3)", - " (in 'mother.stan', line 191, column 4 to column 42)", - " (in 'mother.stan', line 190, column 21 to line 192, column 3)", - " (in 'mother.stan', line 195, column 4 to column 18)", - " (in 'mother.stan', line 196, column 4 to column 19)", - " (in 'mother.stan', line 197, column 4 to column 27)", - " (in 'mother.stan', line 198, column 4 to column 40)", - " (in 'mother.stan', line 200, column 6 to column 81)", - " (in 'mother.stan', line 199, column 4 to line 200, column 81)", - " (in 'mother.stan', line 202, column 6 to column 81)", - " (in 'mother.stan', line 201, column 4 to line 202, column 81)", - " (in 'mother.stan', line 203, column 4 to column 32)", - " (in 'mother.stan', line 194, column 59 to line 204, column 3)", - " (in 'mother.stan', line 208, column 4 to column 22)", - " (in 'mother.stan', line 207, column 52 to line 209, column 3)", - " (in 'mother.stan', line 212, column 4 to column 14)", - " (in 'mother.stan', line 211, column 66 to line 213, column 3)", - " (in 'mother.stan', line 215, column 4 to column 14)", - " (in 'mother.stan', line 214, column 78 to line 216, column 3)", - " (in 'mother.stan', line 219, column 4 to column 35)", - " (in 'mother.stan', line 220, column 4 to column 12)", - " (in 'mother.stan', line 221, column 4 to column 16)", - " (in 'mother.stan', line 222, column 4 to column 20)", - " (in 'mother.stan', line 223, column 4 to column 13)", - " (in 'mother.stan', line 218, column 49 to line 224, column 3)", - " (in 'mother.stan', line 226, column 4 to column 16)", - " (in 'mother.stan', line 225, column 150 to line 227, column 3)", - " (in 'mother.stan', line 230, column 4 to column 14)", - " (in 'mother.stan', line 229, column 149 to line 231, column 3)", - " (in 'mother.stan', line 234, column 4 to column 14)", - " (in 'mother.stan', line 233, column 151 to line 235, column 3)", - " (in 'mother.stan', line 238, column 4 to column 14)", - " (in 'mother.stan', line 237, column 152 to line 239, column 3)", - " (in 'mother.stan', line 242, column 4 to column 14)", - " (in 'mother.stan', line 241, column 150 to line 243, column 3)", - " (in 'mother.stan', line 246, column 4 to column 14)", - " (in 'mother.stan', line 245, column 152 to line 247, column 3)", - " (in 'mother.stan', line 250, column 4 to column 14)", - " (in 'mother.stan', line 249, column 153 to line 251, column 3)", - " (in 'mother.stan', line 254, column 4 to column 14)", - " (in 'mother.stan', line 253, column 152 to line 255, column 3)", - " (in 'mother.stan', line 258, column 4 to column 14)", - " (in 'mother.stan', line 257, column 154 to line 259, column 3)", - " (in 'mother.stan', line 262, column 4 to column 14)", - " (in 'mother.stan', line 261, column 155 to line 263, column 3)", - " (in 'mother.stan', line 266, column 4 to column 15)", - " (in 'mother.stan', line 265, column 153 to line 267, column 3)", - " (in 'mother.stan', line 270, column 4 to column 15)", - " (in 'mother.stan', line 269, column 155 to line 271, column 3)", - " (in 'mother.stan', line 274, column 4 to column 15)", - " (in 'mother.stan', line 273, column 156 to line 275, column 3)", - " (in 'mother.stan', line 277, column 4 to column 10)", - " (in 'mother.stan', line 278, column 4 to column 11)", - " (in 'mother.stan', line 279, column 4 to column 18)", - " (in 'mother.stan', line 280, column 4 to column 32)", - " (in 'mother.stan', line 281, column 4 to column 24)", - " (in 'mother.stan', line 276, column 14 to line 282, column 3)", - " (in 'mother.stan', line 284, column 4 to line 286, column 40)", - " (in 'mother.stan', line 283, column 18 to line 287, column 3)", - " (in 'mother.stan', line 289, column 4 to column 35)", - " (in 'mother.stan', line 288, column 18 to line 290, column 3)", - " (in 'mother.stan', line 292, column 4 to column 33)", - " (in 'mother.stan', line 293, column 4 to column 13)", - " (in 'mother.stan', line 291, column 27 to line 294, column 3)", - " (in 'mother.stan', line 296, column 4 to column 48)", - " (in 'mother.stan', line 297, column 4 to column 26)", - " (in 'mother.stan', line 295, column 27 to line 298, column 3)", - " (in 'mother.stan', line 303, column 4 to column 18)", - " (in 'mother.stan', line 304, column 4 to column 25)", - " (in 'mother.stan', line 305, column 4 to column 25)", - " (in 'mother.stan', line 306, column 4 to column 15)", - " (in 'mother.stan', line 302, column 39 to line 307, column 3)", - " (in 'mother.stan', line 310, column 4 to column 19)", - " (in 'mother.stan', line 311, column 4 to column 18)", - " (in 'mother.stan', line 312, column 4 to column 16)", - " (in 'mother.stan', line 309, column 78 to line 313, column 3)"}; - - -int -foo(const int& n, std::ostream* pstream__) ; - -int -foo(const int& n, std::ostream* pstream__) ; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -double -foo_bar0(std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_bar1(const T0__& x, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, - std::ostream* pstream__) ; - -template -void -unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -int -foo_1(const int& a, std::ostream* pstream__) ; - -int -foo_2(const int& a, std::ostream* pstream__) ; - -template -std::vector::type> -foo_3(const T0__& t, const int& n, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -template -void -foo_4(const T0__& x, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -relative_diff(const T0__& x, const T1__& y, const T2__& max_, - const T3__& min_, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -foo_5(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, - const T4__& x5, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type>::type -foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, - const T3__& x4, const T4__& x5, const T5__& x6, - T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, -1> -covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, - std::ostream* pstream__) ; - -template -void -f0(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -int -f1(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector -f2(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector> -f3(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type>::type -f4(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type> -f5(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type>> -f6(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type>::type, -1, 1> -f7(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, 1>> -f8(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, 1>>> -f9(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type>::type, -1, -1> -f10(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, -1>> -f11(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, -1>>> -f12(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -void -foo_6(std::ostream* pstream__) ; - -Eigen::Matrix -matfoo(std::ostream* pstream__) ; - -Eigen::Matrix -vecfoo(std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -vecmufoo(const T0__& mu, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -vecmubar(const T0__& mu, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -algebra_system(const Eigen::Matrix& x, - const Eigen::Matrix& y, - const std::vector& dat, const std::vector& dat_int, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -binomialf(const Eigen::Matrix& phi, - const Eigen::Matrix& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) ; - - - -int -foo(const int& n, std::ostream* pstream__) ; - -int -foo(const int& n, std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 267; - if (logical_eq(n, 0)) { - current_statement__ = 266; - return 1; - } - current_statement__ = 268; - return (n * foo((n - 1), pstream__)); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_functor__ { -int -operator()(const int& n, std::ostream* pstream__) const -{ -return foo(n, pstream__); -} -}; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 271; - validate_non_negative_index("dydt", "2", 2); - std::vector dydt; - dydt = std::vector(2, 0); - - current_statement__ = 272; - assign(dydt, cons_list(index_uni(1), nil_index_list()), y[(2 - 1)], - "assigning variable dydt"); - current_statement__ = 273; - assign(dydt, cons_list(index_uni(2), nil_index_list()), - (-y[(1 - 1)] - (theta[(1 - 1)] * y[(2 - 1)])), - "assigning variable dydt"); - current_statement__ = 274; - return dydt; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct sho_functor__ { -template -std::vector::type> -operator()(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) const -{ -return sho(t, y, theta, x, x_int, pstream__); -} -}; - -double -foo_bar0(std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 276; - return 0.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_bar0_functor__ { -double -operator()(std::ostream* pstream__) const -{ -return foo_bar0(pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_bar1(const T0__& x, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 278; - return 1.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_bar1_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, std::ostream* pstream__) const -{ -return foo_bar1(x, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 280; - return 2.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_bar2_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, const T1__& y, std::ostream* pstream__) const -{ -return foo_bar2(x, y, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - - try { - current_statement__ = 282; - return 1.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_lpmf_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const -{ -return foo_lpmf(y, lambda, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 284; - return 1.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_lcdf_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const -{ -return foo_lcdf(y, lambda, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 286; - return 1.0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_lccdf_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const -{ -return foo_lccdf(y, lambda, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 288; - return normal_rng(mu, sigma, base_rng__); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_rng_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& mu, const T1__& sigma, RNG& base_rng__, - std::ostream* pstream__) const -{ -return foo_rng(mu, sigma, base_rng__, pstream__); -} -}; - -template -void -unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - - try { - current_statement__ = 290; - lp_accum__.add(normal_log(u, 0, 1)); - current_statement__ = 291; - lp_accum__.add(uniform_log(u, -100, 100)); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct unit_normal_lp_functor__ { -template -void -operator()(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) const -{ -return unit_normal_lp(u, lp__, lp_accum__, pstream__); -} -}; - -int -foo_1(const int& a, std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 294; - while (1) { - break; - } - current_statement__ = 296; - while (0) { - continue; - } - current_statement__ = 298; - for (size_t i = 1; i <= 10; ++i) { break;} - current_statement__ = 300; - for (size_t i = 1; i <= 10; ++i) { continue;} - current_statement__ = 305; - while (1) { - int b; - - current_statement__ = 302; - b = 5; - break; - } - current_statement__ = 312; - while (1) { - current_statement__ = 310; - if (0) { - break; - } else { - current_statement__ = 308; - if (1) { - break; - } else { - break; - } - } - } - current_statement__ = 315; - while (1) { - current_statement__ = 314; - while (0) { - break; - } - } - current_statement__ = 319; - while (1) { - current_statement__ = 317; - for (size_t i = 1; i <= 10; ++i) { break;} - } - current_statement__ = 334; - while (1) { - current_statement__ = 320; - validate_non_negative_index("vs", "2", 2); - current_statement__ = 320; - validate_non_negative_index("vs", "3", 3); - std::vector> vs; - vs = std::vector>(2, std::vector(3, 0)); - - int z; - - current_statement__ = 322; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - std::vector v; - current_statement__ = 322; - assign(v, nil_index_list(), vs[(sym1__ - 1)], - "assigning variable v"); - current_statement__ = 323; - z = 0; - break; - }} - current_statement__ = 325; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - std::vector v; - current_statement__ = 325; - assign(v, nil_index_list(), vs[(sym1__ - 1)], - "assigning variable v"); - current_statement__ = 326; - z = 0; - continue; - }} - current_statement__ = 328; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - std::vector v; - current_statement__ = 328; - assign(v, nil_index_list(), vs[(sym1__ - 1)], - "assigning variable v"); - current_statement__ = 329; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(v); ++sym1__) { - { - int vv; - current_statement__ = 329; - vv = v[(sym1__ - 1)]; - current_statement__ = 330; - z = 0; - break; - }} - current_statement__ = 332; - z = 1; - }} - } - current_statement__ = 344; - while (1) { - local_scalar_t__ z; - - current_statement__ = 335; - z = std::numeric_limits::quiet_NaN(); - current_statement__ = 336; - validate_non_negative_index("vs", "2", 2); - current_statement__ = 336; - validate_non_negative_index("vs", "3", 3); - Eigen::Matrix vs; - vs = Eigen::Matrix(2, 3); - - current_statement__ = 336; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 336; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 336; - assign(vs, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), "assigning variable vs"); - }} - current_statement__ = 337; - for (size_t sym1__ = 1; sym1__ <= rows(vs); ++sym1__) { - current_statement__ = 337; - for (size_t sym2__ = 1; - sym2__ <= stan::math::size( - rvalue(vs, - cons_list(index_uni(sym1__), nil_index_list()), - "vs")); ++sym2__) { - { - local_scalar_t__ v; - current_statement__ = 337; - v = rvalue(vs, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), "vs"); - current_statement__ = 338; - z = 0; - break; - }}} - current_statement__ = 340; - for (size_t sym1__ = 1; sym1__ <= rows(vs); ++sym1__) { - current_statement__ = 340; - for (size_t sym2__ = 1; - sym2__ <= stan::math::size( - rvalue(vs, - cons_list(index_uni(sym1__), nil_index_list()), - "vs")); ++sym2__) { - { - local_scalar_t__ v; - current_statement__ = 340; - v = rvalue(vs, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), "vs"); - current_statement__ = 341; - z = 3.1; - continue; - }}} - } - current_statement__ = 354; - while (1) { - local_scalar_t__ z; - - current_statement__ = 345; - z = std::numeric_limits::quiet_NaN(); - current_statement__ = 346; - validate_non_negative_index("vs", "2", 2); - Eigen::Matrix vs; - vs = Eigen::Matrix(2); - - current_statement__ = 346; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 346; - assign(vs, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable vs"); - } - current_statement__ = 347; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - local_scalar_t__ v; - current_statement__ = 347; - v = vs[(sym1__ - 1)]; - current_statement__ = 348; - z = 0; - break; - }} - current_statement__ = 350; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - local_scalar_t__ v; - current_statement__ = 350; - v = vs[(sym1__ - 1)]; - current_statement__ = 351; - z = 3.2; - continue; - }} - } - current_statement__ = 364; - while (1) { - local_scalar_t__ z; - - current_statement__ = 355; - z = std::numeric_limits::quiet_NaN(); - current_statement__ = 356; - validate_non_negative_index("vs", "2", 2); - Eigen::Matrix vs; - vs = Eigen::Matrix(2); - - current_statement__ = 356; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 356; - assign(vs, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable vs"); - } - current_statement__ = 357; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - local_scalar_t__ v; - current_statement__ = 357; - v = vs[(sym1__ - 1)]; - current_statement__ = 358; - z = 0; - break; - }} - current_statement__ = 360; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - local_scalar_t__ v; - current_statement__ = 360; - v = vs[(sym1__ - 1)]; - current_statement__ = 361; - z = 3.3; - continue; - }} - } - current_statement__ = 372; - while (1) { - int b; - - current_statement__ = 366; - b = 5; - { - int c; - - current_statement__ = 368; - c = 6; - break; - } - } - current_statement__ = 373; - return 0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_1_functor__ { -int -operator()(const int& a, std::ostream* pstream__) const -{ -return foo_1(a, pstream__); -} -}; - -int -foo_2(const int& a, std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 375; - validate_non_negative_index("vs", "2", 2); - std::vector vs; - vs = std::vector(2, 0); - - int y; - - current_statement__ = 377; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { - { - int v; - current_statement__ = 377; - v = vs[(sym1__ - 1)]; - current_statement__ = 378; - y = v; - }} - current_statement__ = 379; - return 0; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_2_functor__ { -int -operator()(const int& a, std::ostream* pstream__) const -{ -return foo_2(a, pstream__); -} -}; - -template -std::vector::type> -foo_3(const T0__& t, const int& n, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 381; - return rep_array(t, n); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_3_functor__ { -template -std::vector::type> -operator()(const T0__& t, const int& n, std::ostream* pstream__) const -{ -return foo_3(t, n, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - - try { - current_statement__ = 383; - return (x + get_lp(lp__, lp_accum__)); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_lp_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) const -{ -return foo_lp(x, lp__, lp_accum__, pstream__); -} -}; - -template -void -foo_4(const T0__& x, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 385; - std::stringstream errmsg_stream__; - errmsg_stream__ << "user-specified rejection"; - errmsg_stream__ << x; - throw std::domain_error(errmsg_stream__.str()); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_4_functor__ { -template -void -operator()(const T0__& x, std::ostream* pstream__) const -{ -return foo_4(x, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -relative_diff(const T0__& x, const T1__& y, const T2__& max_, - const T3__& min_, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - local_scalar_t__ abs_diff; - - current_statement__ = 387; - abs_diff = std::numeric_limits::quiet_NaN(); - local_scalar_t__ avg_scale; - - current_statement__ = 388; - avg_scale = std::numeric_limits::quiet_NaN(); - current_statement__ = 389; - abs_diff = stan::math::fabs((x - y)); - current_statement__ = 390; - avg_scale = ((stan::math::fabs(x) + stan::math::fabs(y)) / 2); - current_statement__ = 392; - if (logical_gt((abs_diff / avg_scale), max_)) { - current_statement__ = 391; - std::stringstream errmsg_stream__; - errmsg_stream__ << "user-specified rejection, difference above "; - errmsg_stream__ << max_; - errmsg_stream__ << " x:"; - errmsg_stream__ << x; - errmsg_stream__ << " y:"; - errmsg_stream__ << y; - throw std::domain_error(errmsg_stream__.str()); - } - current_statement__ = 394; - if (logical_lt((abs_diff / avg_scale), min_)) { - current_statement__ = 393; - std::stringstream errmsg_stream__; - errmsg_stream__ << "user-specified rejection, difference below "; - errmsg_stream__ << min_; - errmsg_stream__ << " x:"; - errmsg_stream__ << x; - errmsg_stream__ << " y:"; - errmsg_stream__ << y; - throw std::domain_error(errmsg_stream__.str()); - } - current_statement__ = 395; - return (abs_diff / avg_scale); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct relative_diff_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, const T1__& y, const T2__& max_, const T3__& min_, - std::ostream* pstream__) const -{ -return relative_diff(x, y, max_, min_, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -foo_5(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 397; - return transpose(stan::math::to_row_vector( - stan::math::array_builder().add(1).add(2).add(3).array())); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_5_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) const -{ -return foo_5(shared_params, job_params, data_r, data_i, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type -foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, - const T4__& x5, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 399; - return x1; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_five_args_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, - const T4__& x5, std::ostream* pstream__) const -{ -return foo_five_args(x1, x2, x3, x4, x5, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type>::type -foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, - const T3__& x4, const T4__& x5, const T5__& x6, - T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - - try { - current_statement__ = 401; - return x1; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_five_args_lp_functor__ { -template -typename boost::math::tools::promote_args::type>::type -operator()(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, - const T4__& x5, const T5__& x6, T_lp__& lp__, - T_lp_accum__& lp_accum__, std::ostream* pstream__) const -{ -return foo_five_args_lp(x1, x2, x3, x4, x5, x6, lp__, lp_accum__, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, -1> -covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 403; - validate_non_negative_index("o", "rows(mat)", rows(mat)); - current_statement__ = 403; - validate_non_negative_index("o", "cols(mat)", cols(mat)); - Eigen::Matrix o; - o = Eigen::Matrix(rows(mat), cols(mat)); - - current_statement__ = 403; - for (size_t sym1__ = 1; sym1__ <= rows(mat); ++sym1__) { - current_statement__ = 403; - for (size_t sym2__ = 1; sym2__ <= cols(mat); ++sym2__) { - current_statement__ = 403; - assign(o, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), "assigning variable o");} - } - current_statement__ = 404; - assign(o, nil_index_list(), mat, "assigning variable o"); - current_statement__ = 405; - assign(o, cons_list(index_uni(1), nil_index_list()), - stan::model::deep_copy( - rvalue(o, cons_list(index_uni(2), nil_index_list()), "o")), - "assigning variable o"); - current_statement__ = 406; - assign(o, cons_list(index_min_max(3, 4), nil_index_list()), - stan::model::deep_copy( - rvalue(o, cons_list(index_min_max(1, 2), nil_index_list()), "o")), - "assigning variable o"); - current_statement__ = 407; - return o; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct covsqrt2corsqrt_functor__ { -template -Eigen::Matrix::type, -1, -1> -operator()(const Eigen::Matrix& mat, const int& invert, - std::ostream* pstream__) const -{ -return covsqrt2corsqrt(mat, invert, pstream__); -} -}; - -template -void -f0(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 409; - if (pstream__) { - stan_print(pstream__, "hi"); - stan_print(pstream__, "\n"); - } - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f0_functor__ { -template -void -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -int -f1(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 411; - return a1; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f1_functor__ { -template -int -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector -f2(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 413; - return a2; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f2_functor__ { -template -std::vector -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f2(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector> -f3(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 415; - return a3; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f3_functor__ { -template -std::vector> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f3(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -typename boost::math::tools::promote_args::type>::type -f4(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 417; - return a4; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f4_functor__ { -template -typename boost::math::tools::promote_args::type>::type -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f4(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type> -f5(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 419; - return a5; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f5_functor__ { -template -std::vector::type>::type> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f5(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type>> -f6(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 421; - return a6; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f6_functor__ { -template -std::vector::type>::type>> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f6(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -Eigen::Matrix::type>::type, -1, 1> -f7(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 423; - return a7; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f7_functor__ { -template -Eigen::Matrix::type>::type, -1, 1> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f7(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type, -1, 1>> -f8(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 425; - return a8; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f8_functor__ { -template -std::vector::type>::type, -1, 1>> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f8(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type, -1, 1>>> -f9(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 427; - return a9; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f9_functor__ { -template -std::vector::type>::type, -1, 1>>> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f9(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -Eigen::Matrix::type>::type, -1, -1> -f10(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 429; - return a10; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f10_functor__ { -template -Eigen::Matrix::type>::type, -1, -1> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type, -1, -1>> -f11(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 431; - return a11; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f11_functor__ { -template -std::vector::type>::type, -1, -1>> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -template -std::vector::type>::type, -1, -1>>> -f12(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 433; - return a12; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct f12_functor__ { -template -std::vector::type>::type, -1, -1>>> -operator()(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, - const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) const -{ -return f12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); -} -}; - -void -foo_6(std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - int a; - - local_scalar_t__ b; - - current_statement__ = 436; - b = std::numeric_limits::quiet_NaN(); - current_statement__ = 437; - validate_non_negative_index("c", "20", 20); - current_statement__ = 437; - validate_non_negative_index("c", "30", 30); - std::vector> c; - c = std::vector>(20, std::vector(30, 0)); - - current_statement__ = 438; - validate_non_negative_index("ar_mat", "60", 60); - current_statement__ = 438; - validate_non_negative_index("ar_mat", "70", 70); - current_statement__ = 438; - validate_non_negative_index("ar_mat", "40", 40); - current_statement__ = 438; - validate_non_negative_index("ar_mat", "50", 50); - std::vector>> ar_mat; - ar_mat = std::vector>>(60, std::vector>(70, Eigen::Matrix(40, 50))); - - current_statement__ = 438; - for (size_t sym1__ = 1; sym1__ <= 60; ++sym1__) { - current_statement__ = 438; - for (size_t sym2__ = 1; sym2__ <= 70; ++sym2__) { - current_statement__ = 438; - for (size_t sym3__ = 1; sym3__ <= 40; ++sym3__) { - current_statement__ = 438; - for (size_t sym4__ = 1; sym4__ <= 50; ++sym4__) { - current_statement__ = 438; - assign(ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable ar_mat");}}}} - current_statement__ = 439; - assign(ar_mat, - cons_list(index_uni(1), - cons_list(index_uni(1), - cons_list(index_uni(1), cons_list(index_uni(1), nil_index_list())))), - b, "assigning variable ar_mat"); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct foo_6_functor__ { -void -operator()(std::ostream* pstream__) const -{ -return foo_6(pstream__); -} -}; - -Eigen::Matrix -matfoo(std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 441; - return stan::math::to_matrix( - stan::math::array_builder>() - .add(stan::math::to_row_vector(stan::math::array_builder() - .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) - .add(10).array())).add(stan::math::to_row_vector( - stan::math::array_builder().add(1).add(2).add(3).add(4).add(5) - .add(6).add(7).add(8).add(9).add(10).array())) - .add(stan::math::to_row_vector(stan::math::array_builder() - .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) - .add(10).array())).array()); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct matfoo_functor__ { -Eigen::Matrix -operator()(std::ostream* pstream__) const -{ -return matfoo(pstream__); -} -}; - -Eigen::Matrix -vecfoo(std::ostream* pstream__) { - using local_scalar_t__ = double; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 443; - return transpose(stan::math::to_row_vector( - stan::math::array_builder().add(1).add(2).add(3).add(4) - .add(5).add(6).add(7).add(8).add(9).add(10).array())); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct vecfoo_functor__ { -Eigen::Matrix -operator()(std::ostream* pstream__) const -{ -return vecfoo(pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -vecmufoo(const T0__& mu, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 445; - validate_non_negative_index("l", "10", 10); - Eigen::Matrix l; - l = Eigen::Matrix(10); - - current_statement__ = 445; - for (size_t sym1__ = 1; sym1__ <= 10; ++sym1__) { - current_statement__ = 445; - assign(l, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable l");} - current_statement__ = 445; - assign(l, nil_index_list(), multiply(mu, vecfoo(pstream__)), - "assigning variable l"); - current_statement__ = 446; - return l; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct vecmufoo_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const T0__& mu, std::ostream* pstream__) const -{ -return vecmufoo(mu, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -vecmubar(const T0__& mu, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 448; - validate_non_negative_index("l", "10", 10); - Eigen::Matrix l; - l = Eigen::Matrix(10); - - current_statement__ = 448; - for (size_t sym1__ = 1; sym1__ <= 10; ++sym1__) { - current_statement__ = 448; - assign(l, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable l");} - current_statement__ = 448; - assign(l, nil_index_list(), - multiply(mu, - transpose(stan::math::to_row_vector(stan::math::array_builder() - .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) - .add(10).array()))), "assigning variable l"); - current_statement__ = 449; - return rvalue(l, - cons_list(index_multi(stan::math::array_builder().add(1) - .add(2).add(3).add(4).add(5).array()), nil_index_list()), "l"); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct vecmubar_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const T0__& mu, std::ostream* pstream__) const -{ -return vecmubar(mu, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -algebra_system(const Eigen::Matrix& x, - const Eigen::Matrix& y, - const std::vector& dat, const std::vector& dat_int, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 451; - validate_non_negative_index("f_x", "2", 2); - Eigen::Matrix f_x; - f_x = Eigen::Matrix(2); - - current_statement__ = 451; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 451; - assign(f_x, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable f_x");} - current_statement__ = 452; - assign(f_x, cons_list(index_uni(1), nil_index_list()), - (x[(1 - 1)] - y[(1 - 1)]), "assigning variable f_x"); - current_statement__ = 453; - assign(f_x, cons_list(index_uni(2), nil_index_list()), - (x[(2 - 1)] - y[(2 - 1)]), "assigning variable f_x"); - current_statement__ = 454; - return f_x; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct algebra_system_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const Eigen::Matrix& x, - const Eigen::Matrix& y, const std::vector& dat, - const std::vector& dat_int, std::ostream* pstream__) const -{ -return algebra_system(x, y, dat, dat_int, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -binomialf(const Eigen::Matrix& phi, - const Eigen::Matrix& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 456; - validate_non_negative_index("lpmf", "1", 1); - Eigen::Matrix lpmf; - lpmf = Eigen::Matrix(1); - - current_statement__ = 456; - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - current_statement__ = 456; - assign(lpmf, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable lpmf"); - } - current_statement__ = 457; - assign(lpmf, cons_list(index_uni(1), nil_index_list()), 0.0, - "assigning variable lpmf"); - current_statement__ = 458; - return lpmf; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct binomialf_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const Eigen::Matrix& phi, - const Eigen::Matrix& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) const -{ -return binomialf(phi, theta, x_r, x_i, pstream__); -} -}; - - -class mother_model : public model_base_crtp { - - private: - int pos__; - int N; - int M; - int K; - std::vector d_int_1d_ar; - std::vector>> d_int_3d_ar; - double J; - std::vector d_real_1d_ar; - std::vector>> d_real_3d_ar; - Eigen::Matrix d_vec; - std::vector> d_1d_vec; - std::vector>>> d_3d_vec; - Eigen::Matrix d_row_vec; - std::vector> d_1d_row_vec; - std::vector>>> d_3d_row_vec; - std::vector>> d_ar_mat; - Eigen::Matrix d_simplex; - std::vector> d_1d_simplex; - std::vector>>> d_3d_simplex; - Eigen::Matrix d_cfcov_54; - Eigen::Matrix d_cfcov_33; - std::vector> d_cfcov_33_ar; - int td_int; - std::vector td_1d; - std::vector td_1dk; - int td_a; - double td_b; - double td_c; - std::vector>> td_ar_mat; - Eigen::Matrix td_simplex; - std::vector> td_1d_simplex; - std::vector>>> td_3d_simplex; - Eigen::Matrix td_cfcov_54; - Eigen::Matrix td_cfcov_33; - Eigen::Matrix x; - Eigen::Matrix y; - std::vector dat; - std::vector dat_int; - std::vector> x_r; - std::vector> x_i; - std::vector> arr_mul_ind; - std::vector x_mul_ind; - - public: - ~mother_model() { } - - std::string model_name() const { return "mother_model"; } - - mother_model(stan::io::var_context& context__, - unsigned int random_seed__ = 0, - std::ostream* pstream__ = nullptr) : model_base_crtp(0) { - typedef double local_scalar_t__; - boost::ecuyer1988 base_rng__ = - stan::services::util::create_rng(random_seed__, 0); - (void) base_rng__; // suppress unused var warning - static const char* function__ = "mother_model_namespace::mother_model"; - (void) function__; // suppress unused var warning - - try { - - pos__ = 1; - context__.validate_dims("data initialization","N","int", - context__.to_vec()); - - current_statement__ = 181; - N = context__.vals_i("N")[(1 - 1)]; - context__.validate_dims("data initialization","M","int", - context__.to_vec()); - - current_statement__ = 182; - M = context__.vals_i("M")[(1 - 1)]; - context__.validate_dims("data initialization","K","int", - context__.to_vec()); - - current_statement__ = 183; - K = context__.vals_i("K")[(1 - 1)]; - current_statement__ = 184; - validate_non_negative_index("d_int_1d_ar", "N", N); - context__.validate_dims("data initialization","d_int_1d_ar","int", - context__.to_vec(N)); - d_int_1d_ar = std::vector(N, 0); - - current_statement__ = 184; - assign(d_int_1d_ar, nil_index_list(), context__.vals_i("d_int_1d_ar"), - "assigning variable d_int_1d_ar"); - current_statement__ = 185; - validate_non_negative_index("d_int_3d_ar", "N", N); - current_statement__ = 185; - validate_non_negative_index("d_int_3d_ar", "M", M); - current_statement__ = 185; - validate_non_negative_index("d_int_3d_ar", "K", K); - context__.validate_dims("data initialization","d_int_3d_ar","int", - context__.to_vec(N, M, K)); - d_int_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - { - std::vector d_int_3d_ar_flat__; - current_statement__ = 185; - assign(d_int_3d_ar_flat__, nil_index_list(), - context__.vals_i("d_int_3d_ar"), - "assigning variable d_int_3d_ar_flat__"); - current_statement__ = 185; - pos__ = 1; - current_statement__ = 185; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 185; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 185; - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - current_statement__ = 185; - assign(d_int_3d_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - d_int_3d_ar_flat__[(pos__ - 1)], - "assigning variable d_int_3d_ar"); - current_statement__ = 185; - pos__ = (pos__ + 1);}}} - } - context__.validate_dims("data initialization","J","double", - context__.to_vec()); - - current_statement__ = 186; - J = context__.vals_r("J")[(1 - 1)]; - current_statement__ = 187; - validate_non_negative_index("d_real_1d_ar", "N", N); - context__.validate_dims("data initialization","d_real_1d_ar","double", - context__.to_vec(N)); - d_real_1d_ar = std::vector(N, 0); - - current_statement__ = 187; - assign(d_real_1d_ar, nil_index_list(), - context__.vals_r("d_real_1d_ar"), "assigning variable d_real_1d_ar"); - current_statement__ = 188; - validate_non_negative_index("d_real_3d_ar", "N", N); - current_statement__ = 188; - validate_non_negative_index("d_real_3d_ar", "M", M); - current_statement__ = 188; - validate_non_negative_index("d_real_3d_ar", "K", K); - context__.validate_dims("data initialization","d_real_3d_ar","double", - context__.to_vec(N, M, K)); - d_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - { - std::vector d_real_3d_ar_flat__; - current_statement__ = 188; - assign(d_real_3d_ar_flat__, nil_index_list(), - context__.vals_r("d_real_3d_ar"), - "assigning variable d_real_3d_ar_flat__"); - current_statement__ = 188; - pos__ = 1; - current_statement__ = 188; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 188; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 188; - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - current_statement__ = 188; - assign(d_real_3d_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - d_real_3d_ar_flat__[(pos__ - 1)], - "assigning variable d_real_3d_ar"); - current_statement__ = 188; - pos__ = (pos__ + 1);}}} - } - current_statement__ = 189; - validate_non_negative_index("d_vec", "N", N); - context__.validate_dims("data initialization","d_vec","double", - context__.to_vec(N)); - d_vec = Eigen::Matrix(N); - - { - std::vector d_vec_flat__; - current_statement__ = 189; - assign(d_vec_flat__, nil_index_list(), context__.vals_r("d_vec"), - "assigning variable d_vec_flat__"); - current_statement__ = 189; - pos__ = 1; - current_statement__ = 189; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 189; - assign(d_vec, cons_list(index_uni(sym1__), nil_index_list()), - d_vec_flat__[(pos__ - 1)], "assigning variable d_vec"); - current_statement__ = 189; - pos__ = (pos__ + 1);} - } - current_statement__ = 190; - validate_non_negative_index("d_1d_vec", "N", N); - current_statement__ = 190; - validate_non_negative_index("d_1d_vec", "N", N); - context__.validate_dims("data initialization","d_1d_vec","double", - context__.to_vec(N, N)); - d_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector d_1d_vec_flat__; - current_statement__ = 190; - assign(d_1d_vec_flat__, nil_index_list(), - context__.vals_r("d_1d_vec"), "assigning variable d_1d_vec_flat__"); - current_statement__ = 190; - pos__ = 1; - current_statement__ = 190; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 190; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 190; - assign(d_1d_vec, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - d_1d_vec_flat__[(pos__ - 1)], "assigning variable d_1d_vec"); - current_statement__ = 190; - pos__ = (pos__ + 1);}} - } - current_statement__ = 191; - validate_non_negative_index("d_3d_vec", "N", N); - current_statement__ = 191; - validate_non_negative_index("d_3d_vec", "M", M); - current_statement__ = 191; - validate_non_negative_index("d_3d_vec", "K", K); - current_statement__ = 191; - validate_non_negative_index("d_3d_vec", "N", N); - context__.validate_dims("data initialization","d_3d_vec","double", - context__.to_vec(N, M, K, N)); - d_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector d_3d_vec_flat__; - current_statement__ = 191; - assign(d_3d_vec_flat__, nil_index_list(), - context__.vals_r("d_3d_vec"), "assigning variable d_3d_vec_flat__"); - current_statement__ = 191; - pos__ = 1; - current_statement__ = 191; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 191; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 191; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 191; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 191; - assign(d_3d_vec, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - d_3d_vec_flat__[(pos__ - 1)], "assigning variable d_3d_vec"); - current_statement__ = 191; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 192; - validate_non_negative_index("d_row_vec", "N", N); - context__.validate_dims("data initialization","d_row_vec","double", - context__.to_vec(N)); - d_row_vec = Eigen::Matrix(N); - - { - std::vector d_row_vec_flat__; - current_statement__ = 192; - assign(d_row_vec_flat__, nil_index_list(), - context__.vals_r("d_row_vec"), - "assigning variable d_row_vec_flat__"); - current_statement__ = 192; - pos__ = 1; - current_statement__ = 192; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 192; - assign(d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - d_row_vec_flat__[(pos__ - 1)], "assigning variable d_row_vec"); - current_statement__ = 192; - pos__ = (pos__ + 1);} - } - current_statement__ = 193; - validate_non_negative_index("d_1d_row_vec", "N", N); - current_statement__ = 193; - validate_non_negative_index("d_1d_row_vec", "N", N); - context__.validate_dims("data initialization","d_1d_row_vec","double", - context__.to_vec(N, N)); - d_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector d_1d_row_vec_flat__; - current_statement__ = 193; - assign(d_1d_row_vec_flat__, nil_index_list(), - context__.vals_r("d_1d_row_vec"), - "assigning variable d_1d_row_vec_flat__"); - current_statement__ = 193; - pos__ = 1; - current_statement__ = 193; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 193; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 193; - assign(d_1d_row_vec, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - d_1d_row_vec_flat__[(pos__ - 1)], - "assigning variable d_1d_row_vec"); - current_statement__ = 193; - pos__ = (pos__ + 1);}} - } - current_statement__ = 194; - validate_non_negative_index("d_3d_row_vec", "N", N); - current_statement__ = 194; - validate_non_negative_index("d_3d_row_vec", "M", M); - current_statement__ = 194; - validate_non_negative_index("d_3d_row_vec", "K", K); - current_statement__ = 194; - validate_non_negative_index("d_3d_row_vec", "N", N); - context__.validate_dims("data initialization","d_3d_row_vec","double", - context__.to_vec(N, M, K, N)); - d_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector d_3d_row_vec_flat__; - current_statement__ = 194; - assign(d_3d_row_vec_flat__, nil_index_list(), - context__.vals_r("d_3d_row_vec"), - "assigning variable d_3d_row_vec_flat__"); - current_statement__ = 194; - pos__ = 1; - current_statement__ = 194; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 194; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 194; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 194; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 194; - assign(d_3d_row_vec, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - d_3d_row_vec_flat__[(pos__ - 1)], - "assigning variable d_3d_row_vec"); - current_statement__ = 194; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 195; - validate_non_negative_index("d_ar_mat", "4", 4); - current_statement__ = 195; - validate_non_negative_index("d_ar_mat", "5", 5); - current_statement__ = 195; - validate_non_negative_index("d_ar_mat", "2", 2); - current_statement__ = 195; - validate_non_negative_index("d_ar_mat", "3", 3); - context__.validate_dims("data initialization","d_ar_mat","double", - context__.to_vec(4, 5, 2, 3)); - d_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - { - std::vector d_ar_mat_flat__; - current_statement__ = 195; - assign(d_ar_mat_flat__, nil_index_list(), - context__.vals_r("d_ar_mat"), "assigning variable d_ar_mat_flat__"); - current_statement__ = 195; - pos__ = 1; - current_statement__ = 195; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 195; - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - current_statement__ = 195; - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - current_statement__ = 195; - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - current_statement__ = 195; - assign(d_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - d_ar_mat_flat__[(pos__ - 1)], "assigning variable d_ar_mat"); - current_statement__ = 195; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 196; - validate_non_negative_index("d_simplex", "N", N); - context__.validate_dims("data initialization","d_simplex","double", - context__.to_vec(N)); - d_simplex = Eigen::Matrix(N); - - { - std::vector d_simplex_flat__; - current_statement__ = 196; - assign(d_simplex_flat__, nil_index_list(), - context__.vals_r("d_simplex"), - "assigning variable d_simplex_flat__"); - current_statement__ = 196; - pos__ = 1; - current_statement__ = 196; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 196; - assign(d_simplex, cons_list(index_uni(sym1__), nil_index_list()), - d_simplex_flat__[(pos__ - 1)], "assigning variable d_simplex"); - current_statement__ = 196; - pos__ = (pos__ + 1);} - } - current_statement__ = 197; - validate_non_negative_index("d_1d_simplex", "N", N); - current_statement__ = 197; - validate_non_negative_index("d_1d_simplex", "N", N); - context__.validate_dims("data initialization","d_1d_simplex","double", - context__.to_vec(N, N)); - d_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector d_1d_simplex_flat__; - current_statement__ = 197; - assign(d_1d_simplex_flat__, nil_index_list(), - context__.vals_r("d_1d_simplex"), - "assigning variable d_1d_simplex_flat__"); - current_statement__ = 197; - pos__ = 1; - current_statement__ = 197; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 197; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 197; - assign(d_1d_simplex, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - d_1d_simplex_flat__[(pos__ - 1)], - "assigning variable d_1d_simplex"); - current_statement__ = 197; - pos__ = (pos__ + 1);}} - } - current_statement__ = 198; - validate_non_negative_index("d_3d_simplex", "N", N); - current_statement__ = 198; - validate_non_negative_index("d_3d_simplex", "M", M); - current_statement__ = 198; - validate_non_negative_index("d_3d_simplex", "K", K); - current_statement__ = 198; - validate_non_negative_index("d_3d_simplex", "N", N); - context__.validate_dims("data initialization","d_3d_simplex","double", - context__.to_vec(N, M, K, N)); - d_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector d_3d_simplex_flat__; - current_statement__ = 198; - assign(d_3d_simplex_flat__, nil_index_list(), - context__.vals_r("d_3d_simplex"), - "assigning variable d_3d_simplex_flat__"); - current_statement__ = 198; - pos__ = 1; - current_statement__ = 198; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 198; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 198; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 198; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 198; - assign(d_3d_simplex, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - d_3d_simplex_flat__[(pos__ - 1)], - "assigning variable d_3d_simplex"); - current_statement__ = 198; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 199; - validate_non_negative_index("d_cfcov_54", "5", 5); - current_statement__ = 199; - validate_non_negative_index("d_cfcov_54", "4", 4); - context__.validate_dims("data initialization","d_cfcov_54","double", - context__.to_vec(5, 4)); - d_cfcov_54 = Eigen::Matrix(5, 4); - - { - std::vector d_cfcov_54_flat__; - current_statement__ = 199; - assign(d_cfcov_54_flat__, nil_index_list(), - context__.vals_r("d_cfcov_54"), - "assigning variable d_cfcov_54_flat__"); - current_statement__ = 199; - pos__ = 1; - current_statement__ = 199; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 199; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 199; - assign(d_cfcov_54, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - d_cfcov_54_flat__[(pos__ - 1)], "assigning variable d_cfcov_54"); - current_statement__ = 199; - pos__ = (pos__ + 1);}} - } - current_statement__ = 200; - validate_non_negative_index("d_cfcov_33", "3", 3); - current_statement__ = 200; - validate_non_negative_index("d_cfcov_33", "3", 3); - context__.validate_dims("data initialization","d_cfcov_33","double", - context__.to_vec(3, 3)); - d_cfcov_33 = Eigen::Matrix(3, 3); - - { - std::vector d_cfcov_33_flat__; - current_statement__ = 200; - assign(d_cfcov_33_flat__, nil_index_list(), - context__.vals_r("d_cfcov_33"), - "assigning variable d_cfcov_33_flat__"); - current_statement__ = 200; - pos__ = 1; - current_statement__ = 200; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 200; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 200; - assign(d_cfcov_33, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - d_cfcov_33_flat__[(pos__ - 1)], "assigning variable d_cfcov_33"); - current_statement__ = 200; - pos__ = (pos__ + 1);}} - } - current_statement__ = 201; - validate_non_negative_index("d_cfcov_33_ar", "K", K); - current_statement__ = 201; - validate_non_negative_index("d_cfcov_33_ar", "3", 3); - current_statement__ = 201; - validate_non_negative_index("d_cfcov_33_ar", "3", 3); - context__.validate_dims("data initialization","d_cfcov_33_ar","double", - context__.to_vec(K, 3, 3)); - d_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - { - std::vector d_cfcov_33_ar_flat__; - current_statement__ = 201; - assign(d_cfcov_33_ar_flat__, nil_index_list(), - context__.vals_r("d_cfcov_33_ar"), - "assigning variable d_cfcov_33_ar_flat__"); - current_statement__ = 201; - pos__ = 1; - current_statement__ = 201; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 201; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 201; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 201; - assign(d_cfcov_33_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - d_cfcov_33_ar_flat__[(pos__ - 1)], - "assigning variable d_cfcov_33_ar"); - current_statement__ = 201; - pos__ = (pos__ + 1);}}} - } - - current_statement__ = 203; - validate_non_negative_index("td_1d", "N", N); - td_1d = std::vector(N, 0); - - current_statement__ = 204; - validate_non_negative_index("td_1dk", "M", M); - td_1dk = std::vector(M, 0); - - current_statement__ = 204; - assign(td_1dk, nil_index_list(), rep_array(1, M), - "assigning variable td_1dk"); - - current_statement__ = 205; - td_a = N; - - current_statement__ = 206; - td_b = std::numeric_limits::quiet_NaN(); - current_statement__ = 206; - td_b = (N * J); - - current_statement__ = 207; - td_c = std::numeric_limits::quiet_NaN(); - current_statement__ = 207; - td_c = foo_bar1(td_b, pstream__); - current_statement__ = 208; - validate_non_negative_index("td_ar_mat", "4", 4); - current_statement__ = 208; - validate_non_negative_index("td_ar_mat", "5", 5); - current_statement__ = 208; - validate_non_negative_index("td_ar_mat", "2", 2); - current_statement__ = 208; - validate_non_negative_index("td_ar_mat", "3", 3); - td_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 208; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 208; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 208; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 208; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 208; - assign(td_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable td_ar_mat");}}}} - current_statement__ = 209; - validate_non_negative_index("td_simplex", "N", N); - td_simplex = Eigen::Matrix(N); - - current_statement__ = 209; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 209; - assign(td_simplex, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable td_simplex");} - current_statement__ = 210; - validate_non_negative_index("td_1d_simplex", "N", N); - current_statement__ = 210; - validate_non_negative_index("td_1d_simplex", "N", N); - td_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 210; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 210; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 210; - assign(td_1d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable td_1d_simplex");}} - current_statement__ = 211; - validate_non_negative_index("td_3d_simplex", "N", N); - current_statement__ = 211; - validate_non_negative_index("td_3d_simplex", "M", M); - current_statement__ = 211; - validate_non_negative_index("td_3d_simplex", "K", K); - current_statement__ = 211; - validate_non_negative_index("td_3d_simplex", "N", N); - td_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 211; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 211; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 211; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 211; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 211; - assign(td_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable td_3d_simplex");}}}} - current_statement__ = 212; - validate_non_negative_index("td_cfcov_54", "5", 5); - current_statement__ = 212; - validate_non_negative_index("td_cfcov_54", "5", 5); - td_cfcov_54 = Eigen::Matrix(5, 5); - - current_statement__ = 212; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 212; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 212; - assign(td_cfcov_54, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable td_cfcov_54");}} - current_statement__ = 213; - validate_non_negative_index("td_cfcov_33", "3", 3); - current_statement__ = 213; - validate_non_negative_index("td_cfcov_33", "3", 3); - td_cfcov_33 = Eigen::Matrix(3, 3); - - current_statement__ = 213; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 213; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 213; - assign(td_cfcov_33, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable td_cfcov_33");}} - current_statement__ = 214; - validate_non_negative_index("x", "2", 2); - x = Eigen::Matrix(2); - - current_statement__ = 214; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 214; - assign(x, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable x");} - current_statement__ = 215; - validate_non_negative_index("y", "2", 2); - y = Eigen::Matrix(2); - - current_statement__ = 215; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 215; - assign(y, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable y");} - current_statement__ = 216; - validate_non_negative_index("dat", "0", 0); - dat = std::vector(0, 0); - - current_statement__ = 217; - validate_non_negative_index("dat_int", "0", 0); - dat_int = std::vector(0, 0); - - current_statement__ = 218; - validate_non_negative_index("x_r", "0", 0); - current_statement__ = 218; - validate_non_negative_index("x_r", "0", 0); - x_r = std::vector>(0, std::vector(0, 0)); - - current_statement__ = 219; - validate_non_negative_index("x_i", "0", 0); - current_statement__ = 219; - validate_non_negative_index("x_i", "0", 0); - x_i = std::vector>(0, std::vector(0, 0)); - - current_statement__ = 220; - td_int = (primitive_value(1) || primitive_value(2)); - current_statement__ = 221; - td_int = (primitive_value(1) && primitive_value(2)); - current_statement__ = 230; - for (size_t i = 1; i <= 2; ++i) { - current_statement__ = 228; - for (size_t j = 1; j <= 3; ++j) { - current_statement__ = 226; - for (size_t m = 1; m <= 4; ++m) { - current_statement__ = 224; - for (size_t n = 1; n <= 5; ++n) { - current_statement__ = 222; - assign(td_ar_mat, - cons_list(index_uni(m), - cons_list(index_uni(n), - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())))), 0.4, - "assigning variable td_ar_mat");}}}} - current_statement__ = 241; - for (size_t i = 1; i <= N; ++i) { - current_statement__ = 231; - assign(td_simplex, cons_list(index_uni(i), nil_index_list()), - (1.0 / N), "assigning variable td_simplex"); - current_statement__ = 239; - for (size_t n = 1; n <= N; ++n) { - current_statement__ = 232; - assign(td_1d_simplex, - cons_list(index_uni(n), - cons_list(index_uni(i), nil_index_list())), (1.0 / N), - "assigning variable td_1d_simplex"); - current_statement__ = 237; - for (size_t m = 1; m <= M; ++m) { - current_statement__ = 235; - for (size_t k = 1; k <= K; ++k) { - current_statement__ = 233; - assign(td_3d_simplex, - cons_list(index_uni(n), - cons_list(index_uni(m), - cons_list(index_uni(k), - cons_list(index_uni(i), nil_index_list())))), - (1.0 / N), "assigning variable td_3d_simplex");}}}} - current_statement__ = 247; - for (size_t i = 1; i <= 4; ++i) { - current_statement__ = 245; - for (size_t j = 1; j <= 5; ++j) { - current_statement__ = 242; - validate_non_negative_index("l_mat", "2", 2); - current_statement__ = 242; - validate_non_negative_index("l_mat", "3", 3); - Eigen::Matrix l_mat; - l_mat = Eigen::Matrix(2, 3); - - current_statement__ = 242; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 242; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 242; - assign(l_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable l_mat");}} - current_statement__ = 242; - assign(l_mat, nil_index_list(), d_ar_mat[(i - 1)][(j - 1)], - "assigning variable l_mat"); - current_statement__ = 243; - if (pstream__) { - stan_print(pstream__, "ar dim1: "); - stan_print(pstream__, i); - stan_print(pstream__, " ar dim2: "); - stan_print(pstream__, j); - stan_print(pstream__, " matrix: "); - stan_print(pstream__, l_mat); - stan_print(pstream__, "\n"); - }}} - current_statement__ = 248; - assign(td_cfcov_54, nil_index_list(), - diag_matrix(rep_vector(1, rows(td_cfcov_54))), - "assigning variable td_cfcov_54"); - current_statement__ = 249; - assign(td_cfcov_33, nil_index_list(), - diag_matrix(rep_vector(1, rows(td_cfcov_33))), - "assigning variable td_cfcov_33"); - { - double z; - - current_statement__ = 250; - z = std::numeric_limits::quiet_NaN(); - current_statement__ = 251; - validate_non_negative_index("blocked_tdata_vs", "2", 2); - Eigen::Matrix blocked_tdata_vs; - blocked_tdata_vs = Eigen::Matrix(2); - - current_statement__ = 251; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 251; - assign(blocked_tdata_vs, - cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable blocked_tdata_vs");} - current_statement__ = 252; - for (size_t sym1__ = 1; sym1__ <= stan::math::size(blocked_tdata_vs); - ++sym1__) { - { - double v; - current_statement__ = 252; - v = blocked_tdata_vs[(sym1__ - 1)]; - current_statement__ = 253; - z = 0; - }} - current_statement__ = 254; - validate_non_negative_index("indices", "4", 4); - std::vector indices; - indices = std::vector(4, 0); - - current_statement__ = 254; - assign(indices, nil_index_list(), stan::math::array_builder() - .add(1).add(2).add(3).add(4).array(), "assigning variable indices"); - { - std::vector sym1__; - current_statement__ = 255; - assign(sym1__, nil_index_list(), - rvalue(indices, cons_list(index_min_max(1, 3), nil_index_list()), - "indices"), "assigning variable sym1__"); - current_statement__ = 255; - for (size_t sym2__ = 1; sym2__ <= stan::math::size(sym1__); - ++sym2__) { - { - int i; - current_statement__ = 255; - i = sym1__[(sym2__ - 1)]; - current_statement__ = 256; - z = i; - }} - } - } - current_statement__ = 258; - assign(td_1dk, nil_index_list(), - rvalue(td_1d, - cons_list(index_multi(stan::model::deep_copy(td_1dk)), - nil_index_list()), "td_1d"), "assigning variable td_1dk"); - current_statement__ = 259; - assign(td_simplex, nil_index_list(), - rvalue(td_1d_simplex, - cons_list(index_uni(1), cons_list(index_omni(), nil_index_list())), - "td_1d_simplex"), "assigning variable td_simplex"); - current_statement__ = 260; - assign(td_simplex, nil_index_list(), - rvalue(td_1d_simplex, - cons_list(index_uni(1), cons_list(index_omni(), nil_index_list())), - "td_1d_simplex"), "assigning variable td_simplex"); - current_statement__ = 261; - assign(td_simplex, nil_index_list(), - rvalue(td_1d_simplex, - cons_list(index_uni(1), - cons_list(index_min_max(1, N), nil_index_list())), - "td_1d_simplex"), "assigning variable td_simplex"); - current_statement__ = 262; - validate_non_negative_index("arr_mul_ind", "2", 2); - current_statement__ = 262; - validate_non_negative_index("arr_mul_ind", "2", 2); - arr_mul_ind = std::vector>(2, std::vector(2, 0)); - - current_statement__ = 263; - assign(arr_mul_ind, - cons_list(index_uni(1), - cons_list(index_min_max(1, 2), nil_index_list())), - stan::math::array_builder().add(1).add(1).array(), - "assigning variable arr_mul_ind"); - current_statement__ = 264; - validate_non_negative_index("x_mul_ind", "2", 2); - x_mul_ind = std::vector(2, 0); - - current_statement__ = 264; - assign(x_mul_ind, nil_index_list(), stan::math::array_builder() - .add(1).add(2).array(), "assigning variable x_mul_ind"); - current_statement__ = 181; - current_statement__ = 181; - check_greater_or_equal(function__, "N", N, 0); - current_statement__ = 182; - current_statement__ = 182; - check_greater_or_equal(function__, "M", M, 0); - current_statement__ = 183; - current_statement__ = 183; - check_greater_or_equal(function__, "K", K, 0); - current_statement__ = 183; - current_statement__ = 183; - check_less_or_equal(function__, "K", K, (N * M)); - current_statement__ = 184; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 184; - current_statement__ = 184; - check_less_or_equal(function__, "d_int_1d_ar[sym1__]", - d_int_1d_ar[(sym1__ - 1)], N);} - current_statement__ = 185; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 185; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 185; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 185; - current_statement__ = 185; - check_less_or_equal(function__, - "d_int_3d_ar[sym1__, sym2__, sym3__]", - d_int_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ - (sym3__ - 1)], N);}}} - current_statement__ = 186; - current_statement__ = 186; - check_greater_or_equal(function__, "J", J, -2.0); - current_statement__ = 186; - current_statement__ = 186; - check_less_or_equal(function__, "J", J, 2.0); - current_statement__ = 195; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 195; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 195; - current_statement__ = 195; - check_greater_or_equal(function__, "d_ar_mat[sym1__, sym2__]", - d_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} - current_statement__ = 195; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 195; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 195; - current_statement__ = 195; - check_less_or_equal(function__, "d_ar_mat[sym1__, sym2__]", - d_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} - current_statement__ = 196; - current_statement__ = 196; - check_simplex(function__, "d_simplex", d_simplex); - current_statement__ = 197; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 197; - current_statement__ = 197; - check_simplex(function__, "d_1d_simplex[sym1__]", - d_1d_simplex[(sym1__ - 1)]);} - current_statement__ = 198; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 198; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 198; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 198; - current_statement__ = 198; - check_simplex(function__, "d_3d_simplex[sym1__, sym2__, sym3__]", - d_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - - 1)]);}}} - current_statement__ = 199; - current_statement__ = 199; - check_cholesky_factor(function__, "d_cfcov_54", d_cfcov_54); - current_statement__ = 200; - current_statement__ = 200; - check_cholesky_factor(function__, "d_cfcov_33", d_cfcov_33); - current_statement__ = 201; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 201; - current_statement__ = 201; - check_cholesky_factor(function__, "d_cfcov_33_ar[sym1__]", - d_cfcov_33_ar[(sym1__ - 1)]);} - current_statement__ = 208; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 208; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 208; - current_statement__ = 208; - check_greater_or_equal(function__, "td_ar_mat[sym1__, sym2__]", - td_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} - current_statement__ = 208; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 208; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 208; - current_statement__ = 208; - check_less_or_equal(function__, "td_ar_mat[sym1__, sym2__]", - td_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} - current_statement__ = 209; - current_statement__ = 209; - check_simplex(function__, "td_simplex", td_simplex); - current_statement__ = 210; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 210; - current_statement__ = 210; - check_simplex(function__, "td_1d_simplex[sym1__]", - td_1d_simplex[(sym1__ - 1)]);} - current_statement__ = 211; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 211; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 211; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 211; - current_statement__ = 211; - check_simplex(function__, - "td_3d_simplex[sym1__, sym2__, sym3__]", - td_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - - 1)]);}}} - current_statement__ = 212; - current_statement__ = 212; - check_cholesky_factor(function__, "td_cfcov_54", td_cfcov_54); - current_statement__ = 213; - current_statement__ = 213; - check_cholesky_factor(function__, "td_cfcov_33", td_cfcov_33); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - num_params_r__ = 0U; - - try { - num_params_r__ += 1; - current_statement__ = 2; - validate_non_negative_index("offset_multiplier", "5", 5); - num_params_r__ += 5; - current_statement__ = 3; - validate_non_negative_index("no_offset_multiplier", "5", 5); - num_params_r__ += 5; - current_statement__ = 4; - validate_non_negative_index("offset_no_multiplier", "5", 5); - num_params_r__ += 5; - current_statement__ = 5; - validate_non_negative_index("p_real_1d_ar", "N", N); - num_params_r__ += N; - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "N", N); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "M", M); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "K", K); - num_params_r__ += N * M * K; - current_statement__ = 7; - validate_non_negative_index("p_vec", "N", N); - num_params_r__ += N; - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - num_params_r__ += N * N; - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "M", M); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "K", K); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - num_params_r__ += N * M * K * N; - current_statement__ = 10; - validate_non_negative_index("p_row_vec", "N", N); - num_params_r__ += N; - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - num_params_r__ += N * N; - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "M", M); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "K", K); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - num_params_r__ += N * M * K * N; - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "4", 4); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "5", 5); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "2", 2); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "3", 3); - num_params_r__ += 4 * 5 * 2 * 3; - current_statement__ = 14; - validate_positive_index("p_simplex", "N", N); - num_params_r__ += (N - 1); - current_statement__ = 15; - validate_non_negative_index("p_1d_simplex", "N", N); - current_statement__ = 15; - validate_positive_index("p_1d_simplex", "N", N); - num_params_r__ += N * (N - 1); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "N", N); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "M", M); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "K", K); - current_statement__ = 16; - validate_positive_index("p_3d_simplex", "N", N); - num_params_r__ += N * M * K * (N - 1); - current_statement__ = 17; - check_greater_or_equal("cholesky_factor_cov p_cfcov_54", - "num rows (must be greater or equal to num cols)", - 5, 4); - current_statement__ = 17; - validate_non_negative_index("p_cfcov_54", "4", 4); - num_params_r__ += ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); - current_statement__ = 18; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 18; - validate_non_negative_index("p_cfcov_33", "3", 3); - num_params_r__ += ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "K", K); - current_statement__ = 19; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "3", 3); - num_params_r__ += K * ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); - current_statement__ = 20; - validate_non_negative_index("x_p", "2", 2); - num_params_r__ += 2; - current_statement__ = 21; - validate_non_negative_index("y_p", "2", 2); - num_params_r__ += 2; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } - template - T__ log_prob(std::vector& params_r__, std::vector& params_i__, - std::ostream* pstream__ = 0) const { - typedef T__ local_scalar_t__; - T__ lp__(0.0); - stan::math::accumulator lp_accum__; - static const char* function__ = "mother_model_namespace::log_prob"; -(void) function__; // suppress unused var warning - - stan::io::reader in__(params_r__, params_i__); - - try { - local_scalar_t__ p_real; - - current_statement__ = 1; - p_real = in__.scalar(); - current_statement__ = 2; - validate_non_negative_index("offset_multiplier", "5", 5); - std::vector offset_multiplier; - offset_multiplier = std::vector(5, 0); - - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable offset_multiplier");} - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 2; - if (jacobian__) { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_multiplier[(sym1__ - 1)], 1, 2, lp__), - "assigning variable offset_multiplier"); - } else { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_multiplier[(sym1__ - 1)], 1, 2), - "assigning variable offset_multiplier"); - }} - current_statement__ = 3; - validate_non_negative_index("no_offset_multiplier", "5", 5); - std::vector no_offset_multiplier; - no_offset_multiplier = std::vector(5, 0); - - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable no_offset_multiplier");} - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 3; - if (jacobian__) { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - no_offset_multiplier[(sym1__ - 1)], 0, 2, lp__), - "assigning variable no_offset_multiplier"); - } else { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - no_offset_multiplier[(sym1__ - 1)], 0, 2), - "assigning variable no_offset_multiplier"); - }} - current_statement__ = 4; - validate_non_negative_index("offset_no_multiplier", "5", 5); - std::vector offset_no_multiplier; - offset_no_multiplier = std::vector(5, 0); - - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable offset_no_multiplier");} - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 4; - if (jacobian__) { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_no_multiplier[(sym1__ - 1)], 3, 1, lp__), - "assigning variable offset_no_multiplier"); - } else { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_no_multiplier[(sym1__ - 1)], 3, 1), - "assigning variable offset_no_multiplier"); - }} - current_statement__ = 5; - validate_non_negative_index("p_real_1d_ar", "N", N); - std::vector p_real_1d_ar; - p_real_1d_ar = std::vector(N, 0); - - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 5; - assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable p_real_1d_ar");} - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 5; - if (jacobian__) { - current_statement__ = 5; - assign(p_real_1d_ar, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0, lp__), - "assigning variable p_real_1d_ar"); - } else { - current_statement__ = 5; - assign(p_real_1d_ar, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0), - "assigning variable p_real_1d_ar"); - }} - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "N", N); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "M", M); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "K", K); - std::vector>> p_real_3d_ar; - p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.scalar(), "assigning variable p_real_3d_ar");}}} - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 6; - if (jacobian__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::lb_constrain( - p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0, - lp__), "assigning variable p_real_3d_ar"); - } else { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::lb_constrain( - p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), - "assigning variable p_real_3d_ar"); - }}}} - current_statement__ = 7; - validate_non_negative_index("p_vec", "N", N); - Eigen::Matrix p_vec; - p_vec = Eigen::Matrix(N); - - current_statement__ = 7; - p_vec = in__.vector(N); - current_statement__ = 7; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 7; - if (jacobian__) { - current_statement__ = 7; - assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0, lp__), - "assigning variable p_vec"); - } else { - current_statement__ = 7; - assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0), - "assigning variable p_vec"); - }} - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - std::vector> p_1d_vec; - p_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 8; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 8; - assign(p_1d_vec, cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(N), "assigning variable p_1d_vec");} - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "M", M); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "K", K); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - std::vector>>> p_3d_vec; - p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 9; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 9; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 9; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 9; - assign(p_3d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.vector(N), "assigning variable p_3d_vec");}}} - current_statement__ = 10; - validate_non_negative_index("p_row_vec", "N", N); - Eigen::Matrix p_row_vec; - p_row_vec = Eigen::Matrix(N); - - current_statement__ = 10; - p_row_vec = in__.row_vector(N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - std::vector> p_1d_row_vec; - p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 11; - assign(p_1d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - in__.row_vector(N), "assigning variable p_1d_row_vec");} - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "M", M); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "K", K); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - std::vector>>> p_3d_row_vec; - p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 12; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 12; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 12; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 12; - assign(p_3d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.row_vector(N), "assigning variable p_3d_row_vec");}}} - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "4", 4); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "5", 5); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "2", 2); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "3", 3); - std::vector>> p_ar_mat; - p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - in__.matrix(2, 3), "assigning variable p_ar_mat");}} - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 13; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 13; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 13; - if (jacobian__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - stan::math::lub_constrain( - rvalue(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - "p_ar_mat"), 0, 1, lp__), "assigning variable p_ar_mat"); - } else { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - stan::math::lub_constrain( - rvalue(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - "p_ar_mat"), 0, 1), "assigning variable p_ar_mat"); - }}}}} - current_statement__ = 14; - validate_positive_index("p_simplex", "N", N); - Eigen::Matrix p_simplex; - p_simplex = Eigen::Matrix(N); - - Eigen::Matrix p_simplex_in__; - p_simplex_in__ = Eigen::Matrix((N - 1)); - - current_statement__ = 14; - p_simplex_in__ = in__.vector((N - 1)); - current_statement__ = 14; - if (jacobian__) { - current_statement__ = 14; - assign(p_simplex, nil_index_list(), - stan::math::simplex_constrain(p_simplex_in__, lp__), - "assigning variable p_simplex"); - } else { - current_statement__ = 14; - assign(p_simplex, nil_index_list(), - stan::math::simplex_constrain(p_simplex_in__), - "assigning variable p_simplex"); - } - current_statement__ = 15; - validate_non_negative_index("p_1d_simplex", "N", N); - current_statement__ = 15; - validate_positive_index("p_1d_simplex", "N", N); - std::vector> p_1d_simplex; - p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - std::vector> p_1d_simplex_in__; - p_1d_simplex_in__ = std::vector>(N, Eigen::Matrix( - (N - 1))); - - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - assign(p_1d_simplex_in__, - cons_list(index_uni(sym1__), nil_index_list()), - in__.vector((N - 1)), "assigning variable p_1d_simplex_in__");} - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - if (jacobian__) { - current_statement__ = 15; - assign(p_1d_simplex, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)], - lp__), "assigning variable p_1d_simplex"); - } else { - current_statement__ = 15; - assign(p_1d_simplex, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)]), - "assigning variable p_1d_simplex"); - }} - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "N", N); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "M", M); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "K", K); - current_statement__ = 16; - validate_positive_index("p_3d_simplex", "N", N); - std::vector>>> p_3d_simplex; - p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - std::vector>>> p_3d_simplex_in__; - p_3d_simplex_in__ = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix( - (N - 1))))); - - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 16; - assign(p_3d_simplex_in__, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.vector((N - 1)), "assigning variable p_3d_simplex_in__");} - }} - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 16; - if (jacobian__) { - current_statement__ = 16; - assign(p_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::simplex_constrain( - p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], - lp__), "assigning variable p_3d_simplex"); - } else { - current_statement__ = 16; - assign(p_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::simplex_constrain( - p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), - "assigning variable p_3d_simplex"); - }}}} - current_statement__ = 17; - check_greater_or_equal("cholesky_factor_cov p_cfcov_54", - "num rows (must be greater or equal to num cols)", - 5, 4); - current_statement__ = 17; - validate_non_negative_index("p_cfcov_54", "4", 4); - Eigen::Matrix p_cfcov_54; - p_cfcov_54 = Eigen::Matrix(5, 4); - - Eigen::Matrix p_cfcov_54_in__; - p_cfcov_54_in__ = Eigen::Matrix(((((4 * - (4 - 1)) - / 2) + 4) - + - ((5 - 4) * - 4))); - - current_statement__ = 17; - p_cfcov_54_in__ = in__.vector( - ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); - current_statement__ = 17; - if (jacobian__) { - current_statement__ = 17; - assign(p_cfcov_54, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4, lp__), - "assigning variable p_cfcov_54"); - } else { - current_statement__ = 17; - assign(p_cfcov_54, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4), - "assigning variable p_cfcov_54"); - } - current_statement__ = 18; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 18; - validate_non_negative_index("p_cfcov_33", "3", 3); - Eigen::Matrix p_cfcov_33; - p_cfcov_33 = Eigen::Matrix(3, 3); - - Eigen::Matrix p_cfcov_33_in__; - p_cfcov_33_in__ = Eigen::Matrix(((((3 * - (3 - 1)) - / 2) + 3) - + - ((3 - 3) * - 3))); - - current_statement__ = 18; - p_cfcov_33_in__ = in__.vector( - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); - current_statement__ = 18; - if (jacobian__) { - current_statement__ = 18; - assign(p_cfcov_33, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3, lp__), - "assigning variable p_cfcov_33"); - } else { - current_statement__ = 18; - assign(p_cfcov_33, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3), - "assigning variable p_cfcov_33"); - } - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "K", K); - current_statement__ = 19; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "3", 3); - std::vector> p_cfcov_33_ar; - p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - std::vector> p_cfcov_33_ar_in__; - p_cfcov_33_ar_in__ = std::vector>(K, Eigen::Matrix( - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); - - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 19; - assign(p_cfcov_33_ar_in__, - cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))), - "assigning variable p_cfcov_33_ar_in__");} - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 19; - if (jacobian__) { - current_statement__ = 19; - assign(p_cfcov_33_ar, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::cholesky_factor_constrain( - p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3, lp__), - "assigning variable p_cfcov_33_ar"); - } else { - current_statement__ = 19; - assign(p_cfcov_33_ar, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::cholesky_factor_constrain( - p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3), - "assigning variable p_cfcov_33_ar"); - }} - current_statement__ = 20; - validate_non_negative_index("x_p", "2", 2); - Eigen::Matrix x_p; - x_p = Eigen::Matrix(2); - - current_statement__ = 20; - x_p = in__.vector(2); - current_statement__ = 21; - validate_non_negative_index("y_p", "2", 2); - Eigen::Matrix y_p; - y_p = Eigen::Matrix(2); - - current_statement__ = 21; - y_p = in__.vector(2); - current_statement__ = 22; - validate_non_negative_index("tp_real_1d_ar", "N", N); - std::vector tp_real_1d_ar; - tp_real_1d_ar = std::vector(N, 0); - - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "N", N); - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "M", M); - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "K", K); - std::vector>> tp_real_3d_ar; - tp_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - current_statement__ = 24; - validate_non_negative_index("tp_vec", "N", N); - Eigen::Matrix tp_vec; - tp_vec = Eigen::Matrix(N); - - current_statement__ = 24; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 24; - assign(tp_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_vec");} - current_statement__ = 25; - validate_non_negative_index("tp_1d_vec", "N", N); - current_statement__ = 25; - validate_non_negative_index("tp_1d_vec", "N", N); - std::vector> tp_1d_vec; - tp_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 25; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 25; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 25; - assign(tp_1d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_vec");}} - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "N", N); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "M", M); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "K", K); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "N", N); - std::vector>>> tp_3d_vec; - tp_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 26; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 26; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 26; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 26; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 26; - assign(tp_3d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_vec");}}}} - current_statement__ = 27; - validate_non_negative_index("tp_row_vec", "N", N); - Eigen::Matrix tp_row_vec; - tp_row_vec = Eigen::Matrix(N); - - current_statement__ = 27; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 27; - assign(tp_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_row_vec");} - current_statement__ = 28; - validate_non_negative_index("tp_1d_row_vec", "N", N); - current_statement__ = 28; - validate_non_negative_index("tp_1d_row_vec", "N", N); - std::vector> tp_1d_row_vec; - tp_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 28; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 28; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 28; - assign(tp_1d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_row_vec");}} - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "N", N); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "M", M); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "K", K); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "N", N); - std::vector>>> tp_3d_row_vec; - tp_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 29; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 29; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 29; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 29; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 29; - assign(tp_3d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_row_vec");}}}} - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "4", 4); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "5", 5); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "2", 2); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "3", 3); - std::vector>> tp_ar_mat; - tp_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 30; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 30; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 30; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 30; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 30; - assign(tp_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_ar_mat");}}}} - current_statement__ = 31; - validate_non_negative_index("tp_simplex", "N", N); - Eigen::Matrix tp_simplex; - tp_simplex = Eigen::Matrix(N); - - current_statement__ = 31; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 31; - assign(tp_simplex, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_simplex");} - current_statement__ = 32; - validate_non_negative_index("tp_1d_simplex", "N", N); - current_statement__ = 32; - validate_non_negative_index("tp_1d_simplex", "N", N); - std::vector> tp_1d_simplex; - tp_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 32; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 32; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 32; - assign(tp_1d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_simplex");}} - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "N", N); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "M", M); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "K", K); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "N", N); - std::vector>>> tp_3d_simplex; - tp_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 33; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 33; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 33; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 33; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 33; - assign(tp_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_simplex");}}}} - current_statement__ = 34; - validate_non_negative_index("tp_cfcov_54", "5", 5); - current_statement__ = 34; - validate_non_negative_index("tp_cfcov_54", "4", 4); - Eigen::Matrix tp_cfcov_54; - tp_cfcov_54 = Eigen::Matrix(5, 4); - - current_statement__ = 34; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 34; - for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { - current_statement__ = 34; - assign(tp_cfcov_54, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_54");}} - current_statement__ = 35; - validate_non_negative_index("tp_cfcov_33", "3", 3); - current_statement__ = 35; - validate_non_negative_index("tp_cfcov_33", "3", 3); - Eigen::Matrix tp_cfcov_33; - tp_cfcov_33 = Eigen::Matrix(3, 3); - - current_statement__ = 35; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 35; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 35; - assign(tp_cfcov_33, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_33");}} - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "K", K); - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "3", 3); - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "3", 3); - std::vector> tp_cfcov_33_ar; - tp_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - current_statement__ = 36; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 36; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 36; - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - current_statement__ = 36; - assign(tp_cfcov_33_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_33_ar");}}} - current_statement__ = 37; - validate_non_negative_index("theta_p", "2", 2); - Eigen::Matrix theta_p; - theta_p = Eigen::Matrix(2); - - current_statement__ = 37; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 37; - assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta_p");} - current_statement__ = 38; - assign(tp_real_1d_ar, nil_index_list(), p_real_1d_ar, - "assigning variable tp_real_1d_ar"); - current_statement__ = 39; - assign(tp_real_3d_ar, nil_index_list(), p_real_3d_ar, - "assigning variable tp_real_3d_ar"); - current_statement__ = 40; - assign(tp_1d_vec, nil_index_list(), p_1d_vec, - "assigning variable tp_1d_vec"); - current_statement__ = 41; - assign(tp_3d_vec, nil_index_list(), p_3d_vec, - "assigning variable tp_3d_vec"); - current_statement__ = 42; - assign(tp_simplex, nil_index_list(), p_simplex, - "assigning variable tp_simplex"); - current_statement__ = 43; - assign(tp_1d_simplex, nil_index_list(), p_1d_simplex, - "assigning variable tp_1d_simplex"); - current_statement__ = 44; - assign(tp_3d_simplex, nil_index_list(), p_3d_simplex, - "assigning variable tp_3d_simplex"); - current_statement__ = 45; - assign(tp_cfcov_54, nil_index_list(), p_cfcov_54, - "assigning variable tp_cfcov_54"); - current_statement__ = 46; - assign(tp_cfcov_33, nil_index_list(), p_cfcov_33, - "assigning variable tp_cfcov_33"); - current_statement__ = 47; - assign(tp_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, - "assigning variable tp_cfcov_33_ar"); - current_statement__ = 56; - for (size_t i = 1; i <= 2; ++i) { - current_statement__ = 54; - for (size_t j = 1; j <= 3; ++j) { - current_statement__ = 52; - for (size_t m = 1; m <= 4; ++m) { - current_statement__ = 50; - for (size_t n = 1; n <= 5; ++n) { - current_statement__ = 48; - assign(tp_ar_mat, - cons_list(index_uni(m), - cons_list(index_uni(n), - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())))), 0.4, - "assigning variable tp_ar_mat");}}}} - current_statement__ = 58; - for (size_t i = 1; i <= N; ++i) { - current_statement__ = 57; - assign(tp_vec, cons_list(index_uni(i), nil_index_list()), - (-1.0 * p_vec[(i - 1)]), "assigning variable tp_vec");} - current_statement__ = 59; - assign(tp_row_vec, nil_index_list(), transpose(tp_1d_vec[(1 - 1)]), - "assigning variable tp_row_vec"); - current_statement__ = 60; - assign(tp_1d_row_vec, nil_index_list(), p_1d_row_vec, - "assigning variable tp_1d_row_vec"); - current_statement__ = 61; - assign(tp_3d_row_vec, nil_index_list(), p_3d_row_vec, - "assigning variable tp_3d_row_vec"); - current_statement__ = 62; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 63; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 64; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y_p, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 65; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 66; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 67; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 68; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 22; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 22; - current_statement__ = 22; - check_greater_or_equal(function__, "tp_real_1d_ar[sym1__]", - tp_real_1d_ar[(sym1__ - 1)], 0);} - current_statement__ = 23; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 23; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 23; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 23; - current_statement__ = 23; - check_greater_or_equal(function__, - "tp_real_3d_ar[sym1__, sym2__, sym3__]", - tp_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ - (sym3__ - 1)], 0);}}} - current_statement__ = 24; - current_statement__ = 24; - check_less_or_equal(function__, "tp_vec", tp_vec, 0); - current_statement__ = 30; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 30; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 30; - current_statement__ = 30; - check_greater_or_equal(function__, "tp_ar_mat[sym1__, sym2__]", - tp_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} - current_statement__ = 30; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 30; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 30; - current_statement__ = 30; - check_less_or_equal(function__, "tp_ar_mat[sym1__, sym2__]", - tp_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} - current_statement__ = 31; - current_statement__ = 31; - check_simplex(function__, "tp_simplex", tp_simplex); - current_statement__ = 32; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 32; - current_statement__ = 32; - check_simplex(function__, "tp_1d_simplex[sym1__]", - tp_1d_simplex[(sym1__ - 1)]);} - current_statement__ = 33; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 33; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 33; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 33; - current_statement__ = 33; - check_simplex(function__, - "tp_3d_simplex[sym1__, sym2__, sym3__]", - tp_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - - 1)]);}}} - current_statement__ = 34; - current_statement__ = 34; - check_cholesky_factor(function__, "tp_cfcov_54", tp_cfcov_54); - current_statement__ = 35; - current_statement__ = 35; - check_cholesky_factor(function__, "tp_cfcov_33", tp_cfcov_33); - current_statement__ = 36; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 36; - current_statement__ = 36; - check_cholesky_factor(function__, "tp_cfcov_33_ar[sym1__]", - tp_cfcov_33_ar[(sym1__ - 1)]);} - { - current_statement__ = 145; - validate_non_negative_index("tmp", "0", 0); - Eigen::Matrix tmp; - tmp = Eigen::Matrix(0); - - current_statement__ = 145; - for (size_t sym1__ = 1; sym1__ <= 0; ++sym1__) { - current_statement__ = 145; - assign(tmp, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tmp");} - current_statement__ = 146; - validate_non_negative_index("tmp2", "0", 0); - current_statement__ = 146; - validate_non_negative_index("tmp2", "0", 0); - std::vector> tmp2; - tmp2 = std::vector>(0, Eigen::Matrix(0)); - - current_statement__ = 146; - for (size_t sym1__ = 1; sym1__ <= 0; ++sym1__) { - current_statement__ = 146; - for (size_t sym2__ = 1; sym2__ <= 0; ++sym2__) { - current_statement__ = 146; - assign(tmp2, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tmp2");}} - local_scalar_t__ r1; - - current_statement__ = 147; - r1 = std::numeric_limits::quiet_NaN(); - current_statement__ = 147; - r1 = foo_bar1(p_real, pstream__); - local_scalar_t__ r2; - - current_statement__ = 148; - r2 = std::numeric_limits::quiet_NaN(); - current_statement__ = 148; - r2 = foo_bar1(J, pstream__); - current_statement__ = 149; - lp_accum__.add(normal_log(p_real, 0, 1)); - current_statement__ = 150; - lp_accum__.add(normal_log(offset_multiplier, 0, 1)); - current_statement__ = 151; - lp_accum__.add(normal_log(no_offset_multiplier, 0, 1)); - current_statement__ = 152; - lp_accum__.add(normal_log(offset_no_multiplier, 0, 1)); - current_statement__ = 153; - lp_accum__.add(normal_log(to_vector(p_real_1d_ar), 0, 1)); - current_statement__ = 166; - for (size_t n = 1; n <= N; ++n) { - current_statement__ = 154; - lp_accum__.add( - normal_log(to_vector(p_1d_vec[(n - 1)]), 0, 1)); - current_statement__ = 155; - lp_accum__.add( - normal_log(to_vector(p_1d_row_vec[(n - 1)]), 0, 1)); - current_statement__ = 156; - lp_accum__.add( - normal_log(to_vector(p_1d_simplex[(n - 1)]), 0, 1)); - current_statement__ = 164; - for (size_t m = 1; m <= M; ++m) { - current_statement__ = 162; - for (size_t k = 1; k <= K; ++k) { - current_statement__ = 157; - lp_accum__.add( - normal_log( - to_vector(p_3d_vec[(n - 1)][(m - 1)][(k - 1)]), - d_3d_vec[(n - 1)][(m - 1)][(k - 1)], 1)); - current_statement__ = 158; - lp_accum__.add( - normal_log( - to_vector(p_3d_row_vec[(n - 1)][(m - 1)][(k - 1)]), - d_3d_row_vec[(n - 1)][(m - 1)][(k - 1)], 1)); - current_statement__ = 159; - lp_accum__.add( - normal_log( - to_vector(p_3d_simplex[(n - 1)][(m - 1)][(k - 1)]), - d_3d_simplex[(n - 1)][(m - 1)][(k - 1)], 1)); - current_statement__ = 160; - lp_accum__.add( - normal_log(p_real_3d_ar[(n - 1)][(m - 1)][(k - 1)], - p_real_3d_ar[(n - 1)][(m - 1)][(k - 1)], 1));}}} - current_statement__ = 171; - for (size_t i = 1; i <= 4; ++i) { - current_statement__ = 169; - for (size_t j = 1; j <= 5; ++j) { - current_statement__ = 167; - lp_accum__.add( - normal_log(to_vector(p_ar_mat[(i - 1)][(j - 1)]), 0, - 1));}} - current_statement__ = 174; - for (size_t k = 1; k <= K; ++k) { - current_statement__ = 172; - lp_accum__.add( - normal_log(to_vector(p_cfcov_33_ar[(k - 1)]), 0, 1));} - current_statement__ = 175; - lp_accum__.add(normal_log(to_vector(p_vec), d_vec, 1)); - current_statement__ = 176; - lp_accum__.add(normal_log(to_vector(p_row_vec), 0, 1)); - current_statement__ = 177; - lp_accum__.add(normal_log(to_vector(p_simplex), 0, 1)); - current_statement__ = 178; - lp_accum__.add(normal_log(to_vector(p_cfcov_54), 0, 1)); - current_statement__ = 179; - lp_accum__.add(normal_log(to_vector(p_cfcov_33), 0, 1)); - current_statement__ = 180; - lp_accum__.add( - map_rect<1, binomialf_functor__>(tmp, tmp2, x_r, x_i, pstream__)); - } - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - lp_accum__.add(lp__); - return lp_accum__.sum(); - } // log_prob() - - template - void write_array(RNG& base_rng__, std::vector& params_r__, - std::vector& params_i__, std::vector& vars__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true, - std::ostream* pstream__ = 0) const { - typedef double local_scalar_t__; - vars__.resize(0); - stan::io::reader in__(params_r__, params_i__); - static const char* function__ = "mother_model_namespace::write_array"; -(void) function__; // suppress unused var warning - - (void) function__; // suppress unused var warning - - double lp__ = 0.0; - (void) lp__; // dummy to suppress unused var warning - stan::math::accumulator lp_accum__; - - try { - double p_real; - - current_statement__ = 1; - p_real = in__.scalar(); - current_statement__ = 2; - validate_non_negative_index("offset_multiplier", "5", 5); - std::vector offset_multiplier; - offset_multiplier = std::vector(5, 0); - - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable offset_multiplier");} - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_multiplier[(sym1__ - 1)], 1, 2), - "assigning variable offset_multiplier");} - current_statement__ = 3; - validate_non_negative_index("no_offset_multiplier", "5", 5); - std::vector no_offset_multiplier; - no_offset_multiplier = std::vector(5, 0); - - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable no_offset_multiplier");} - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - no_offset_multiplier[(sym1__ - 1)], 0, 2), - "assigning variable no_offset_multiplier");} - current_statement__ = 4; - validate_non_negative_index("offset_no_multiplier", "5", 5); - std::vector offset_no_multiplier; - offset_no_multiplier = std::vector(5, 0); - - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), - "assigning variable offset_no_multiplier");} - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_constrain( - offset_no_multiplier[(sym1__ - 1)], 3, 1), - "assigning variable offset_no_multiplier");} - current_statement__ = 5; - validate_non_negative_index("p_real_1d_ar", "N", N); - std::vector p_real_1d_ar; - p_real_1d_ar = std::vector(N, 0); - - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 5; - assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable p_real_1d_ar");} - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 5; - assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0), - "assigning variable p_real_1d_ar");} - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "N", N); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "M", M); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "K", K); - std::vector>> p_real_3d_ar; - p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.scalar(), "assigning variable p_real_3d_ar");}}} - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::lb_constrain( - p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), - "assigning variable p_real_3d_ar");}}} - current_statement__ = 7; - validate_non_negative_index("p_vec", "N", N); - Eigen::Matrix p_vec; - p_vec = Eigen::Matrix(N); - - current_statement__ = 7; - p_vec = in__.vector(N); - current_statement__ = 7; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 7; - assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0), - "assigning variable p_vec");} - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - std::vector> p_1d_vec; - p_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 8; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 8; - assign(p_1d_vec, cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(N), "assigning variable p_1d_vec");} - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "M", M); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "K", K); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - std::vector>>> p_3d_vec; - p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 9; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 9; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 9; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 9; - assign(p_3d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.vector(N), "assigning variable p_3d_vec");}}} - current_statement__ = 10; - validate_non_negative_index("p_row_vec", "N", N); - Eigen::Matrix p_row_vec; - p_row_vec = Eigen::Matrix(N); - - current_statement__ = 10; - p_row_vec = in__.row_vector(N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - std::vector> p_1d_row_vec; - p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 11; - assign(p_1d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - in__.row_vector(N), "assigning variable p_1d_row_vec");} - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "M", M); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "K", K); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - std::vector>>> p_3d_row_vec; - p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 12; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 12; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 12; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 12; - assign(p_3d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.row_vector(N), "assigning variable p_3d_row_vec");}}} - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "4", 4); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "5", 5); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "2", 2); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "3", 3); - std::vector>> p_ar_mat; - p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - in__.matrix(2, 3), "assigning variable p_ar_mat");}} - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 13; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 13; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - stan::math::lub_constrain( - rvalue(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - "p_ar_mat"), 0, 1), "assigning variable p_ar_mat");}}}} - current_statement__ = 14; - validate_positive_index("p_simplex", "N", N); - Eigen::Matrix p_simplex; - p_simplex = Eigen::Matrix(N); - - Eigen::Matrix p_simplex_in__; - p_simplex_in__ = Eigen::Matrix((N - 1)); - - current_statement__ = 14; - p_simplex_in__ = in__.vector((N - 1)); - current_statement__ = 14; - assign(p_simplex, nil_index_list(), - stan::math::simplex_constrain(p_simplex_in__), - "assigning variable p_simplex"); - current_statement__ = 15; - validate_non_negative_index("p_1d_simplex", "N", N); - current_statement__ = 15; - validate_positive_index("p_1d_simplex", "N", N); - std::vector> p_1d_simplex; - p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - std::vector> p_1d_simplex_in__; - p_1d_simplex_in__ = std::vector>(N, Eigen::Matrix( - (N - 1))); - - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - assign(p_1d_simplex_in__, - cons_list(index_uni(sym1__), nil_index_list()), - in__.vector((N - 1)), "assigning variable p_1d_simplex_in__");} - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - assign(p_1d_simplex, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)]), - "assigning variable p_1d_simplex");} - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "N", N); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "M", M); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "K", K); - current_statement__ = 16; - validate_positive_index("p_3d_simplex", "N", N); - std::vector>>> p_3d_simplex; - p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - std::vector>>> p_3d_simplex_in__; - p_3d_simplex_in__ = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix( - (N - 1))))); - - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 16; - assign(p_3d_simplex_in__, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - in__.vector((N - 1)), "assigning variable p_3d_simplex_in__");} - }} - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 16; - assign(p_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::simplex_constrain( - p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), - "assigning variable p_3d_simplex");}}} - current_statement__ = 17; - check_greater_or_equal("cholesky_factor_cov p_cfcov_54", - "num rows (must be greater or equal to num cols)", - 5, 4); - current_statement__ = 17; - validate_non_negative_index("p_cfcov_54", "4", 4); - Eigen::Matrix p_cfcov_54; - p_cfcov_54 = Eigen::Matrix(5, 4); - - Eigen::Matrix p_cfcov_54_in__; - p_cfcov_54_in__ = Eigen::Matrix(((((4 * - (4 - 1)) - / 2) + 4) - + - ((5 - 4) * - 4))); - - current_statement__ = 17; - p_cfcov_54_in__ = in__.vector( - ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); - current_statement__ = 17; - assign(p_cfcov_54, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4), - "assigning variable p_cfcov_54"); - current_statement__ = 18; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 18; - validate_non_negative_index("p_cfcov_33", "3", 3); - Eigen::Matrix p_cfcov_33; - p_cfcov_33 = Eigen::Matrix(3, 3); - - Eigen::Matrix p_cfcov_33_in__; - p_cfcov_33_in__ = Eigen::Matrix(((((3 * - (3 - 1)) - / 2) + 3) - + - ((3 - 3) * - 3))); - - current_statement__ = 18; - p_cfcov_33_in__ = in__.vector( - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); - current_statement__ = 18; - assign(p_cfcov_33, nil_index_list(), - stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3), - "assigning variable p_cfcov_33"); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "K", K); - current_statement__ = 19; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "3", 3); - std::vector> p_cfcov_33_ar; - p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - std::vector> p_cfcov_33_ar_in__; - p_cfcov_33_ar_in__ = std::vector>(K, Eigen::Matrix( - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); - - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 19; - assign(p_cfcov_33_ar_in__, - cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))), - "assigning variable p_cfcov_33_ar_in__");} - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 19; - assign(p_cfcov_33_ar, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::cholesky_factor_constrain( - p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3), - "assigning variable p_cfcov_33_ar");} - current_statement__ = 20; - validate_non_negative_index("x_p", "2", 2); - Eigen::Matrix x_p; - x_p = Eigen::Matrix(2); - - current_statement__ = 20; - x_p = in__.vector(2); - current_statement__ = 21; - validate_non_negative_index("y_p", "2", 2); - Eigen::Matrix y_p; - y_p = Eigen::Matrix(2); - - current_statement__ = 21; - y_p = in__.vector(2); - current_statement__ = 22; - validate_non_negative_index("tp_real_1d_ar", "N", N); - std::vector tp_real_1d_ar; - tp_real_1d_ar = std::vector(N, 0); - - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "N", N); - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "M", M); - current_statement__ = 23; - validate_non_negative_index("tp_real_3d_ar", "K", K); - std::vector>> tp_real_3d_ar; - tp_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - current_statement__ = 24; - validate_non_negative_index("tp_vec", "N", N); - Eigen::Matrix tp_vec; - tp_vec = Eigen::Matrix(N); - - current_statement__ = 24; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 24; - assign(tp_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_vec");} - current_statement__ = 25; - validate_non_negative_index("tp_1d_vec", "N", N); - current_statement__ = 25; - validate_non_negative_index("tp_1d_vec", "N", N); - std::vector> tp_1d_vec; - tp_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 25; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 25; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 25; - assign(tp_1d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_vec");}} - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "N", N); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "M", M); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "K", K); - current_statement__ = 26; - validate_non_negative_index("tp_3d_vec", "N", N); - std::vector>>> tp_3d_vec; - tp_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 26; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 26; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 26; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 26; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 26; - assign(tp_3d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_vec");}}}} - current_statement__ = 27; - validate_non_negative_index("tp_row_vec", "N", N); - Eigen::Matrix tp_row_vec; - tp_row_vec = Eigen::Matrix(N); - - current_statement__ = 27; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 27; - assign(tp_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_row_vec");} - current_statement__ = 28; - validate_non_negative_index("tp_1d_row_vec", "N", N); - current_statement__ = 28; - validate_non_negative_index("tp_1d_row_vec", "N", N); - std::vector> tp_1d_row_vec; - tp_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 28; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 28; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 28; - assign(tp_1d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_row_vec");}} - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "N", N); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "M", M); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "K", K); - current_statement__ = 29; - validate_non_negative_index("tp_3d_row_vec", "N", N); - std::vector>>> tp_3d_row_vec; - tp_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 29; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 29; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 29; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 29; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 29; - assign(tp_3d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_row_vec");}}}} - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "4", 4); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "5", 5); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "2", 2); - current_statement__ = 30; - validate_non_negative_index("tp_ar_mat", "3", 3); - std::vector>> tp_ar_mat; - tp_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 30; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 30; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 30; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 30; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 30; - assign(tp_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_ar_mat");}}}} - current_statement__ = 31; - validate_non_negative_index("tp_simplex", "N", N); - Eigen::Matrix tp_simplex; - tp_simplex = Eigen::Matrix(N); - - current_statement__ = 31; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 31; - assign(tp_simplex, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_simplex");} - current_statement__ = 32; - validate_non_negative_index("tp_1d_simplex", "N", N); - current_statement__ = 32; - validate_non_negative_index("tp_1d_simplex", "N", N); - std::vector> tp_1d_simplex; - tp_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 32; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 32; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 32; - assign(tp_1d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_1d_simplex");}} - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "N", N); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "M", M); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "K", K); - current_statement__ = 33; - validate_non_negative_index("tp_3d_simplex", "N", N); - std::vector>>> tp_3d_simplex; - tp_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 33; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 33; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 33; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 33; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 33; - assign(tp_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_3d_simplex");}}}} - current_statement__ = 34; - validate_non_negative_index("tp_cfcov_54", "5", 5); - current_statement__ = 34; - validate_non_negative_index("tp_cfcov_54", "4", 4); - Eigen::Matrix tp_cfcov_54; - tp_cfcov_54 = Eigen::Matrix(5, 4); - - current_statement__ = 34; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 34; - for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { - current_statement__ = 34; - assign(tp_cfcov_54, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_54");}} - current_statement__ = 35; - validate_non_negative_index("tp_cfcov_33", "3", 3); - current_statement__ = 35; - validate_non_negative_index("tp_cfcov_33", "3", 3); - Eigen::Matrix tp_cfcov_33; - tp_cfcov_33 = Eigen::Matrix(3, 3); - - current_statement__ = 35; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 35; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 35; - assign(tp_cfcov_33, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_33");}} - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "K", K); - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "3", 3); - current_statement__ = 36; - validate_non_negative_index("tp_cfcov_33_ar", "3", 3); - std::vector> tp_cfcov_33_ar; - tp_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - current_statement__ = 36; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 36; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 36; - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - current_statement__ = 36; - assign(tp_cfcov_33_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable tp_cfcov_33_ar");}}} - current_statement__ = 37; - validate_non_negative_index("theta_p", "2", 2); - Eigen::Matrix theta_p; - theta_p = Eigen::Matrix(2); - - current_statement__ = 37; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 37; - assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta_p");} - vars__.push_back(p_real); - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(offset_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(no_offset_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(offset_no_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_real_1d_ar[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - vars__.push_back( - p_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_row_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - vars__.push_back( - rvalue(p_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - "p_ar_mat"));}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_simplex[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - vars__.push_back( - rvalue(p_cfcov_54, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "p_cfcov_54"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back( - rvalue(p_cfcov_33, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "p_cfcov_33"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - vars__.push_back( - rvalue(p_cfcov_33_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "p_cfcov_33_ar"));}}} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(x_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y_p[(sym1__ - 1)]);} - if (logical_negation((primitive_value(emit_transformed_parameters__) || - primitive_value(emit_generated_quantities__)))) { - return ; - } - current_statement__ = 38; - assign(tp_real_1d_ar, nil_index_list(), p_real_1d_ar, - "assigning variable tp_real_1d_ar"); - current_statement__ = 39; - assign(tp_real_3d_ar, nil_index_list(), p_real_3d_ar, - "assigning variable tp_real_3d_ar"); - current_statement__ = 40; - assign(tp_1d_vec, nil_index_list(), p_1d_vec, - "assigning variable tp_1d_vec"); - current_statement__ = 41; - assign(tp_3d_vec, nil_index_list(), p_3d_vec, - "assigning variable tp_3d_vec"); - current_statement__ = 42; - assign(tp_simplex, nil_index_list(), p_simplex, - "assigning variable tp_simplex"); - current_statement__ = 43; - assign(tp_1d_simplex, nil_index_list(), p_1d_simplex, - "assigning variable tp_1d_simplex"); - current_statement__ = 44; - assign(tp_3d_simplex, nil_index_list(), p_3d_simplex, - "assigning variable tp_3d_simplex"); - current_statement__ = 45; - assign(tp_cfcov_54, nil_index_list(), p_cfcov_54, - "assigning variable tp_cfcov_54"); - current_statement__ = 46; - assign(tp_cfcov_33, nil_index_list(), p_cfcov_33, - "assigning variable tp_cfcov_33"); - current_statement__ = 47; - assign(tp_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, - "assigning variable tp_cfcov_33_ar"); - current_statement__ = 56; - for (size_t i = 1; i <= 2; ++i) { - current_statement__ = 54; - for (size_t j = 1; j <= 3; ++j) { - current_statement__ = 52; - for (size_t m = 1; m <= 4; ++m) { - current_statement__ = 50; - for (size_t n = 1; n <= 5; ++n) { - current_statement__ = 48; - assign(tp_ar_mat, - cons_list(index_uni(m), - cons_list(index_uni(n), - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())))), 0.4, - "assigning variable tp_ar_mat");}}}} - current_statement__ = 58; - for (size_t i = 1; i <= N; ++i) { - current_statement__ = 57; - assign(tp_vec, cons_list(index_uni(i), nil_index_list()), - (-1.0 * p_vec[(i - 1)]), "assigning variable tp_vec");} - current_statement__ = 59; - assign(tp_row_vec, nil_index_list(), transpose(tp_1d_vec[(1 - 1)]), - "assigning variable tp_row_vec"); - current_statement__ = 60; - assign(tp_1d_row_vec, nil_index_list(), p_1d_row_vec, - "assigning variable tp_1d_row_vec"); - current_statement__ = 61; - assign(tp_3d_row_vec, nil_index_list(), p_3d_row_vec, - "assigning variable tp_3d_row_vec"); - current_statement__ = 62; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 63; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 64; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x, y_p, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 65; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 66; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - current_statement__ = 67; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, - pstream__), "assigning variable theta_p"); - current_statement__ = 68; - assign(theta_p, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(tp_real_1d_ar[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - vars__.push_back( - tp_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(tp_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(tp_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - tp_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(tp_row_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(tp_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - tp_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - vars__.push_back( - rvalue(tp_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - "tp_ar_mat"));}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(tp_simplex[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(tp_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - tp_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - vars__.push_back( - rvalue(tp_cfcov_54, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "tp_cfcov_54"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back( - rvalue(tp_cfcov_33, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "tp_cfcov_33"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - vars__.push_back( - rvalue(tp_cfcov_33_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "tp_cfcov_33_ar"));}}} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(theta_p[(sym1__ - 1)]);} - if (logical_negation(emit_generated_quantities__)) { - return ; - } - double gq_r1; - - current_statement__ = 69; - gq_r1 = std::numeric_limits::quiet_NaN(); - current_statement__ = 69; - gq_r1 = foo_bar1(p_real, pstream__); - double gq_r2; - - current_statement__ = 70; - gq_r2 = std::numeric_limits::quiet_NaN(); - current_statement__ = 70; - gq_r2 = foo_bar1(J, pstream__); - current_statement__ = 71; - validate_non_negative_index("gq_real_1d_ar", "N", N); - std::vector gq_real_1d_ar; - gq_real_1d_ar = std::vector(N, 0); - - current_statement__ = 72; - validate_non_negative_index("gq_real_3d_ar", "N", N); - current_statement__ = 72; - validate_non_negative_index("gq_real_3d_ar", "M", M); - current_statement__ = 72; - validate_non_negative_index("gq_real_3d_ar", "K", K); - std::vector>> gq_real_3d_ar; - gq_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - current_statement__ = 73; - validate_non_negative_index("gq_vec", "N", N); - Eigen::Matrix gq_vec; - gq_vec = Eigen::Matrix(N); - - current_statement__ = 73; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 73; - assign(gq_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_vec");} - current_statement__ = 74; - validate_non_negative_index("gq_1d_vec", "N", N); - current_statement__ = 74; - validate_non_negative_index("gq_1d_vec", "N", N); - std::vector> gq_1d_vec; - gq_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 74; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 74; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 74; - assign(gq_1d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_1d_vec");}} - current_statement__ = 75; - validate_non_negative_index("gq_3d_vec", "N", N); - current_statement__ = 75; - validate_non_negative_index("gq_3d_vec", "M", M); - current_statement__ = 75; - validate_non_negative_index("gq_3d_vec", "K", K); - current_statement__ = 75; - validate_non_negative_index("gq_3d_vec", "N", N); - std::vector>>> gq_3d_vec; - gq_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 75; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 75; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 75; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 75; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 75; - assign(gq_3d_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_3d_vec");}}}} - current_statement__ = 76; - validate_non_negative_index("gq_row_vec", "N", N); - Eigen::Matrix gq_row_vec; - gq_row_vec = Eigen::Matrix(N); - - current_statement__ = 76; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 76; - assign(gq_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_row_vec");} - current_statement__ = 77; - validate_non_negative_index("gq_1d_row_vec", "N", N); - current_statement__ = 77; - validate_non_negative_index("gq_1d_row_vec", "N", N); - std::vector> gq_1d_row_vec; - gq_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 77; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 77; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 77; - assign(gq_1d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_1d_row_vec");}} - current_statement__ = 78; - validate_non_negative_index("gq_3d_row_vec", "N", N); - current_statement__ = 78; - validate_non_negative_index("gq_3d_row_vec", "M", M); - current_statement__ = 78; - validate_non_negative_index("gq_3d_row_vec", "K", K); - current_statement__ = 78; - validate_non_negative_index("gq_3d_row_vec", "N", N); - std::vector>>> gq_3d_row_vec; - gq_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 78; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 78; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 78; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 78; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 78; - assign(gq_3d_row_vec, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_3d_row_vec");}}}} - current_statement__ = 79; - validate_non_negative_index("gq_ar_mat", "4", 4); - current_statement__ = 79; - validate_non_negative_index("gq_ar_mat", "5", 5); - current_statement__ = 79; - validate_non_negative_index("gq_ar_mat", "2", 2); - current_statement__ = 79; - validate_non_negative_index("gq_ar_mat", "3", 3); - std::vector>> gq_ar_mat; - gq_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - current_statement__ = 79; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 79; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 79; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 79; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 79; - assign(gq_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_ar_mat");}}}} - current_statement__ = 80; - validate_non_negative_index("gq_simplex", "N", N); - Eigen::Matrix gq_simplex; - gq_simplex = Eigen::Matrix(N); - - current_statement__ = 80; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 80; - assign(gq_simplex, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_simplex");} - current_statement__ = 81; - validate_non_negative_index("gq_1d_simplex", "N", N); - current_statement__ = 81; - validate_non_negative_index("gq_1d_simplex", "N", N); - std::vector> gq_1d_simplex; - gq_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - current_statement__ = 81; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 81; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 81; - assign(gq_1d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_1d_simplex");}} - current_statement__ = 82; - validate_non_negative_index("gq_3d_simplex", "N", N); - current_statement__ = 82; - validate_non_negative_index("gq_3d_simplex", "M", M); - current_statement__ = 82; - validate_non_negative_index("gq_3d_simplex", "K", K); - current_statement__ = 82; - validate_non_negative_index("gq_3d_simplex", "N", N); - std::vector>>> gq_3d_simplex; - gq_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - current_statement__ = 82; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 82; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 82; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 82; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 82; - assign(gq_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_3d_simplex");}}}} - current_statement__ = 83; - validate_non_negative_index("gq_cfcov_54", "5", 5); - current_statement__ = 83; - validate_non_negative_index("gq_cfcov_54", "4", 4); - Eigen::Matrix gq_cfcov_54; - gq_cfcov_54 = Eigen::Matrix(5, 4); - - current_statement__ = 83; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 83; - for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { - current_statement__ = 83; - assign(gq_cfcov_54, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_cfcov_54");}} - current_statement__ = 84; - validate_non_negative_index("gq_cfcov_33", "3", 3); - current_statement__ = 84; - validate_non_negative_index("gq_cfcov_33", "3", 3); - Eigen::Matrix gq_cfcov_33; - gq_cfcov_33 = Eigen::Matrix(3, 3); - - current_statement__ = 84; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 84; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 84; - assign(gq_cfcov_33, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_cfcov_33");}} - current_statement__ = 85; - validate_non_negative_index("gq_cfcov_33_ar", "K", K); - current_statement__ = 85; - validate_non_negative_index("gq_cfcov_33_ar", "3", 3); - current_statement__ = 85; - validate_non_negative_index("gq_cfcov_33_ar", "3", 3); - std::vector> gq_cfcov_33_ar; - gq_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - current_statement__ = 85; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 85; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 85; - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - current_statement__ = 85; - assign(gq_cfcov_33_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable gq_cfcov_33_ar");}}} - current_statement__ = 86; - validate_non_negative_index("indices", "3", 3); - std::vector indices; - indices = std::vector(3, 0); - - current_statement__ = 86; - assign(indices, nil_index_list(), stan::math::array_builder() - .add(2).add(3).add(1).array(), "assigning variable indices"); - current_statement__ = 87; - validate_non_negative_index("indexing_mat", "5", 5); - current_statement__ = 87; - validate_non_negative_index("indexing_mat", "3", 3); - current_statement__ = 87; - validate_non_negative_index("indexing_mat", "4", 4); - std::vector> indexing_mat; - indexing_mat = std::vector>(5, Eigen::Matrix(3, 4)); - - current_statement__ = 87; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 87; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 87; - for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { - current_statement__ = 87; - assign(indexing_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable indexing_mat");}}} - current_statement__ = 88; - validate_non_negative_index("idx_res1", "3", 3); - current_statement__ = 88; - validate_non_negative_index("idx_res1", "3", 3); - current_statement__ = 88; - validate_non_negative_index("idx_res1", "4", 4); - std::vector> idx_res1; - idx_res1 = std::vector>(3, Eigen::Matrix(3, 4)); - - current_statement__ = 88; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 88; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 88; - for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { - current_statement__ = 88; - assign(idx_res1, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res1");}}} - current_statement__ = 89; - validate_non_negative_index("idx_res2", "5", 5); - current_statement__ = 89; - validate_non_negative_index("idx_res2", "3", 3); - current_statement__ = 89; - validate_non_negative_index("idx_res2", "4", 4); - std::vector> idx_res2; - idx_res2 = std::vector>(5, Eigen::Matrix(3, 4)); - - current_statement__ = 89; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 89; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 89; - for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { - current_statement__ = 89; - assign(idx_res2, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res2");}}} - current_statement__ = 90; - validate_non_negative_index("idx_res3", "3", 3); - current_statement__ = 90; - validate_non_negative_index("idx_res3", "3", 3); - current_statement__ = 90; - validate_non_negative_index("idx_res3", "3", 3); - std::vector> idx_res3; - idx_res3 = std::vector>(3, Eigen::Matrix(3, 3)); - - current_statement__ = 90; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 90; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 90; - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - current_statement__ = 90; - assign(idx_res3, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res3");}}} - current_statement__ = 91; - validate_non_negative_index("idx_res11", "3", 3); - current_statement__ = 91; - validate_non_negative_index("idx_res11", "3", 3); - current_statement__ = 91; - validate_non_negative_index("idx_res11", "4", 4); - std::vector> idx_res11; - idx_res11 = std::vector>(3, Eigen::Matrix(3, 4)); - - current_statement__ = 91; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 91; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 91; - for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { - current_statement__ = 91; - assign(idx_res11, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res11");}}} - current_statement__ = 92; - validate_non_negative_index("idx_res21", "5", 5); - current_statement__ = 92; - validate_non_negative_index("idx_res21", "3", 3); - current_statement__ = 92; - validate_non_negative_index("idx_res21", "4", 4); - std::vector> idx_res21; - idx_res21 = std::vector>(5, Eigen::Matrix(3, 4)); - - current_statement__ = 92; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 92; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 92; - for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { - current_statement__ = 92; - assign(idx_res21, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res21");}}} - current_statement__ = 93; - validate_non_negative_index("idx_res31", "3", 3); - current_statement__ = 93; - validate_non_negative_index("idx_res31", "3", 3); - current_statement__ = 93; - validate_non_negative_index("idx_res31", "3", 3); - std::vector> idx_res31; - idx_res31 = std::vector>(3, Eigen::Matrix(3, 3)); - - current_statement__ = 93; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 93; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 93; - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - current_statement__ = 93; - assign(idx_res31, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res31");}}} - current_statement__ = 94; - validate_non_negative_index("idx_res4", "3", 3); - current_statement__ = 94; - validate_non_negative_index("idx_res4", "4", 4); - std::vector> idx_res4; - idx_res4 = std::vector>(3, Eigen::Matrix(4)); - - current_statement__ = 94; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 94; - for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { - current_statement__ = 94; - assign(idx_res4, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res4");}} - current_statement__ = 95; - validate_non_negative_index("idx_res5", "2", 2); - current_statement__ = 95; - validate_non_negative_index("idx_res5", "2", 2); - std::vector> idx_res5; - idx_res5 = std::vector>(2, Eigen::Matrix(2)); - - current_statement__ = 95; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 95; - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - current_statement__ = 95; - assign(idx_res5, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), nil_index_list())), - std::numeric_limits::quiet_NaN(), - "assigning variable idx_res5");}} - current_statement__ = 96; - assign(gq_real_1d_ar, nil_index_list(), - rvalue(p_1d_simplex, - cons_list(index_omni(), cons_list(index_uni(1), nil_index_list())), - "p_1d_simplex"), "assigning variable gq_real_1d_ar"); - current_statement__ = 97; - assign(gq_real_3d_ar, nil_index_list(), p_real_3d_ar, - "assigning variable gq_real_3d_ar"); - current_statement__ = 98; - assign(gq_1d_vec, nil_index_list(), p_1d_vec, - "assigning variable gq_1d_vec"); - current_statement__ = 99; - assign(gq_3d_vec, nil_index_list(), p_3d_vec, - "assigning variable gq_3d_vec"); - current_statement__ = 100; - assign(gq_row_vec, nil_index_list(), p_row_vec, - "assigning variable gq_row_vec"); - current_statement__ = 101; - assign(gq_1d_row_vec, nil_index_list(), p_1d_row_vec, - "assigning variable gq_1d_row_vec"); - current_statement__ = 102; - assign(gq_3d_row_vec, nil_index_list(), p_3d_row_vec, - "assigning variable gq_3d_row_vec"); - current_statement__ = 103; - assign(gq_simplex, nil_index_list(), - rvalue(p_1d_simplex, - cons_list(index_uni(1), - cons_list(index_min_max(1, N), nil_index_list())), - "p_1d_simplex"), "assigning variable gq_simplex"); - current_statement__ = 104; - assign(gq_1d_simplex, nil_index_list(), p_1d_simplex, - "assigning variable gq_1d_simplex"); - current_statement__ = 105; - assign(gq_3d_simplex, nil_index_list(), p_3d_simplex, - "assigning variable gq_3d_simplex"); - current_statement__ = 106; - assign(gq_cfcov_54, nil_index_list(), p_cfcov_54, - "assigning variable gq_cfcov_54"); - current_statement__ = 107; - assign(gq_cfcov_33, nil_index_list(), p_cfcov_33, - "assigning variable gq_cfcov_33"); - current_statement__ = 108; - assign(gq_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, - "assigning variable gq_cfcov_33_ar"); - current_statement__ = 117; - for (size_t i = 1; i <= 2; ++i) { - current_statement__ = 115; - for (size_t j = 1; j <= 3; ++j) { - current_statement__ = 113; - for (size_t m = 1; m <= 4; ++m) { - current_statement__ = 111; - for (size_t n = 1; n <= 5; ++n) { - current_statement__ = 109; - assign(gq_ar_mat, - cons_list(index_uni(m), - cons_list(index_uni(n), - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())))), 0.4, - "assigning variable gq_ar_mat");}}}} - current_statement__ = 119; - for (size_t i = 1; i <= N; ++i) { - current_statement__ = 118; - assign(gq_vec, cons_list(index_uni(i), nil_index_list()), - (-1.0 * p_vec[(i - 1)]), "assigning variable gq_vec");} - current_statement__ = 123; - for (size_t i = 1; i <= 3; ++i) { - current_statement__ = 122; - for (size_t j = 1; j <= 4; ++j) { - current_statement__ = 121; - for (size_t k = 1; k <= 5; ++k) { - current_statement__ = 120; - assign(indexing_mat, - cons_list(index_uni(k), - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list()))), - normal_rng(0, 1, base_rng__), "assigning variable indexing_mat"); - }}} - current_statement__ = 126; - for (size_t i = 1; i <= size(indices); ++i) { - current_statement__ = 125; - for (size_t j = 1; j <= size(indices); ++j) { - current_statement__ = 124; - assign(idx_res1, - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())), - rvalue(indexing_mat, - cons_list(index_uni(indices[(i - 1)]), - cons_list(index_uni(indices[(j - 1)]), nil_index_list())), - "indexing_mat"), "assigning variable idx_res1");}} - current_statement__ = 127; - assign(idx_res11, nil_index_list(), - rvalue(indexing_mat, - cons_list(index_multi(indices), - cons_list(index_multi(indices), nil_index_list())), - "indexing_mat"), "assigning variable idx_res11"); - current_statement__ = 129; - if (logical_neq( - rvalue( - rvalue(indexing_mat, - cons_list(index_multi(indices), - cons_list(index_multi(indices), nil_index_list())), "indexing_mat"), - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), - "indexing_mat[indices, indices]"), - rvalue(idx_res1, - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), "idx_res1"))) { - current_statement__ = 128; - std::stringstream errmsg_stream__; - errmsg_stream__ << "indexing test 1 failed"; - throw std::domain_error(errmsg_stream__.str()); - } - current_statement__ = 132; - for (size_t i = 1; i <= 5; ++i) { - current_statement__ = 131; - for (size_t j = 1; j <= size(indices); ++j) { - current_statement__ = 130; - assign(idx_res2, - cons_list(index_uni(i), - cons_list(index_uni(j), nil_index_list())), - rvalue(indexing_mat, - cons_list(index_uni(i), - cons_list(index_uni(indices[(j - 1)]), nil_index_list())), - "indexing_mat"), "assigning variable idx_res2");}} - current_statement__ = 133; - assign(idx_res21, nil_index_list(), - rvalue(indexing_mat, - cons_list(index_omni(), - cons_list(index_multi(indices), nil_index_list())), - "indexing_mat"), "assigning variable idx_res21"); - current_statement__ = 135; - if (logical_neq( - rvalue( - rvalue(indexing_mat, - cons_list(index_omni(), cons_list(index_multi(indices), nil_index_list())), - "indexing_mat"), - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), - "indexing_mat[:, indices]"), - rvalue(idx_res2, - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), "idx_res2"))) { - current_statement__ = 134; - std::stringstream errmsg_stream__; - errmsg_stream__ << "indexing test 2 failed"; - throw std::domain_error(errmsg_stream__.str()); - } - current_statement__ = 139; - for (size_t i = 1; i <= size(indices); ++i) { - current_statement__ = 138; - for (size_t j = 1; j <= 3; ++j) { - current_statement__ = 137; - for (size_t k = 1; k <= size(indices); ++k) { - current_statement__ = 136; - assign(idx_res3, - cons_list(index_uni(i), - cons_list(index_uni(j), - cons_list(index_uni(k), nil_index_list()))), - rvalue(indexing_mat, - cons_list(index_uni(indices[(i - 1)]), - cons_list(index_uni(j), - cons_list(index_uni(indices[(k - 1)]), nil_index_list()))), - "indexing_mat"), "assigning variable idx_res3");}}} - current_statement__ = 140; - assign(idx_res31, nil_index_list(), - rvalue(indexing_mat, - cons_list(index_multi(indices), - cons_list(index_omni(), - cons_list(index_multi(indices), nil_index_list()))), - "indexing_mat"), "assigning variable idx_res31"); - current_statement__ = 142; - if (logical_neq( - rvalue( - rvalue(indexing_mat, - cons_list(index_multi(indices), - cons_list(index_omni(), - cons_list(index_multi(indices), nil_index_list()))), "indexing_mat"), - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), - "indexing_mat[indices, :, indices]"), - rvalue(idx_res3, - cons_list(index_uni(2), - cons_list(index_uni(1), - cons_list(index_uni(1), nil_index_list()))), "idx_res3"))) { - current_statement__ = 141; - std::stringstream errmsg_stream__; - errmsg_stream__ << "indexing test 3 failed"; - throw std::domain_error(errmsg_stream__.str()); - } - current_statement__ = 143; - assign(idx_res4, nil_index_list(), - rvalue(indexing_mat, - cons_list(index_min_max(1, 3), - cons_list(index_uni(1), - cons_list(index_omni(), nil_index_list()))), "indexing_mat"), - "assigning variable idx_res4"); - current_statement__ = 144; - assign(idx_res5, nil_index_list(), - rvalue(indexing_mat, - cons_list(index_min(4), - cons_list(index_min_max(2, 3), - cons_list(index_uni(1), nil_index_list()))), "indexing_mat"), - "assigning variable idx_res5"); - current_statement__ = 71; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 71; - current_statement__ = 71; - check_greater_or_equal(function__, "gq_real_1d_ar[sym1__]", - gq_real_1d_ar[(sym1__ - 1)], 0);} - current_statement__ = 72; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 72; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 72; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 72; - current_statement__ = 72; - check_greater_or_equal(function__, - "gq_real_3d_ar[sym1__, sym2__, sym3__]", - gq_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ - (sym3__ - 1)], 0);}}} - current_statement__ = 73; - current_statement__ = 73; - check_less_or_equal(function__, "gq_vec", gq_vec, 1); - current_statement__ = 79; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 79; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 79; - current_statement__ = 79; - check_greater_or_equal(function__, "gq_ar_mat[sym1__, sym2__]", - gq_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} - current_statement__ = 79; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 79; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 79; - current_statement__ = 79; - check_less_or_equal(function__, "gq_ar_mat[sym1__, sym2__]", - gq_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} - current_statement__ = 80; - current_statement__ = 80; - check_simplex(function__, "gq_simplex", gq_simplex); - current_statement__ = 81; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 81; - current_statement__ = 81; - check_simplex(function__, "gq_1d_simplex[sym1__]", - gq_1d_simplex[(sym1__ - 1)]);} - current_statement__ = 82; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 82; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 82; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 82; - current_statement__ = 82; - check_simplex(function__, - "gq_3d_simplex[sym1__, sym2__, sym3__]", - gq_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - - 1)]);}}} - current_statement__ = 83; - current_statement__ = 83; - check_cholesky_factor(function__, "gq_cfcov_54", gq_cfcov_54); - current_statement__ = 84; - current_statement__ = 84; - check_cholesky_factor(function__, "gq_cfcov_33", gq_cfcov_33); - current_statement__ = 85; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 85; - current_statement__ = 85; - check_cholesky_factor(function__, "gq_cfcov_33_ar[sym1__]", - gq_cfcov_33_ar[(sym1__ - 1)]);} - vars__.push_back(gq_r1); - vars__.push_back(gq_r2); - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(gq_real_1d_ar[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - vars__.push_back( - gq_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(gq_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(gq_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - gq_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(gq_row_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(gq_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - gq_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - vars__.push_back( - rvalue(gq_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - "gq_ar_mat"));}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(gq_simplex[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(gq_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - gq_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - vars__.push_back( - rvalue(gq_cfcov_54, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "gq_cfcov_54"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back( - rvalue(gq_cfcov_33, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - "gq_cfcov_33"));}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - vars__.push_back( - rvalue(gq_cfcov_33_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "gq_cfcov_33_ar"));}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(indices[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - vars__.push_back( - rvalue(indexing_mat, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "indexing_mat"));}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - vars__.push_back( - rvalue(idx_res1, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res1"));}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - vars__.push_back( - rvalue(idx_res2, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res2"));}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - vars__.push_back( - rvalue(idx_res3, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res3"));}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - vars__.push_back( - rvalue(idx_res11, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res11"));}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - vars__.push_back( - rvalue(idx_res21, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res21"));}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - vars__.push_back( - rvalue(idx_res31, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - "idx_res31"));}}} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back(idx_res4[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - vars__.push_back(idx_res5[(sym2__ - 1)][(sym1__ - 1)]);}} - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } // write_array() - - void transform_inits(const stan::io::var_context& context__, - std::vector& params_i__, - std::vector& vars__, std::ostream* pstream__) const { - typedef double local_scalar_t__; - vars__.resize(0); - vars__.reserve(num_params_r__); - - try { - int pos__; - - pos__ = 1; - double p_real; - - current_statement__ = 1; - p_real = context__.vals_r("p_real")[(1 - 1)]; - current_statement__ = 2; - validate_non_negative_index("offset_multiplier", "5", 5); - std::vector offset_multiplier; - offset_multiplier = std::vector(5, 0); - - current_statement__ = 2; - assign(offset_multiplier, nil_index_list(), - context__.vals_r("offset_multiplier"), - "assigning variable offset_multiplier"); - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 2; - assign(offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_free(offset_multiplier[(sym1__ - 1)], - 1, 2), "assigning variable offset_multiplier");} - current_statement__ = 3; - validate_non_negative_index("no_offset_multiplier", "5", 5); - std::vector no_offset_multiplier; - no_offset_multiplier = std::vector(5, 0); - - current_statement__ = 3; - assign(no_offset_multiplier, nil_index_list(), - context__.vals_r("no_offset_multiplier"), - "assigning variable no_offset_multiplier"); - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 3; - assign(no_offset_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_free( - no_offset_multiplier[(sym1__ - 1)], 0, 2), - "assigning variable no_offset_multiplier");} - current_statement__ = 4; - validate_non_negative_index("offset_no_multiplier", "5", 5); - std::vector offset_no_multiplier; - offset_no_multiplier = std::vector(5, 0); - - current_statement__ = 4; - assign(offset_no_multiplier, nil_index_list(), - context__.vals_r("offset_no_multiplier"), - "assigning variable offset_no_multiplier"); - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - current_statement__ = 4; - assign(offset_no_multiplier, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::offset_multiplier_free( - offset_no_multiplier[(sym1__ - 1)], 3, 1), - "assigning variable offset_no_multiplier");} - current_statement__ = 5; - validate_non_negative_index("p_real_1d_ar", "N", N); - std::vector p_real_1d_ar; - p_real_1d_ar = std::vector(N, 0); - - current_statement__ = 5; - assign(p_real_1d_ar, nil_index_list(), - context__.vals_r("p_real_1d_ar"), "assigning variable p_real_1d_ar"); - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 5; - assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_free(p_real_1d_ar[(sym1__ - 1)], 0), - "assigning variable p_real_1d_ar");} - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "N", N); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "M", M); - current_statement__ = 6; - validate_non_negative_index("p_real_3d_ar", "K", K); - std::vector>> p_real_3d_ar; - p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); - - { - std::vector p_real_3d_ar_flat__; - current_statement__ = 6; - assign(p_real_3d_ar_flat__, nil_index_list(), - context__.vals_r("p_real_3d_ar"), - "assigning variable p_real_3d_ar_flat__"); - current_statement__ = 6; - pos__ = 1; - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - p_real_3d_ar_flat__[(pos__ - 1)], - "assigning variable p_real_3d_ar"); - current_statement__ = 6; - pos__ = (pos__ + 1);}}} - } - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 6; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 6; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 6; - assign(p_real_3d_ar, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::lb_free( - p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), - "assigning variable p_real_3d_ar");}}} - current_statement__ = 7; - validate_non_negative_index("p_vec", "N", N); - Eigen::Matrix p_vec; - p_vec = Eigen::Matrix(N); - - { - std::vector p_vec_flat__; - current_statement__ = 7; - assign(p_vec_flat__, nil_index_list(), context__.vals_r("p_vec"), - "assigning variable p_vec_flat__"); - current_statement__ = 7; - pos__ = 1; - current_statement__ = 7; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 7; - assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), - p_vec_flat__[(pos__ - 1)], "assigning variable p_vec"); - current_statement__ = 7; - pos__ = (pos__ + 1);} - } - current_statement__ = 7; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 7; - assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::lb_free(p_vec[(sym1__ - 1)], 0), - "assigning variable p_vec");} - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - current_statement__ = 8; - validate_non_negative_index("p_1d_vec", "N", N); - std::vector> p_1d_vec; - p_1d_vec = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector p_1d_vec_flat__; - current_statement__ = 8; - assign(p_1d_vec_flat__, nil_index_list(), - context__.vals_r("p_1d_vec"), "assigning variable p_1d_vec_flat__"); - current_statement__ = 8; - pos__ = 1; - current_statement__ = 8; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 8; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 8; - assign(p_1d_vec, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - p_1d_vec_flat__[(pos__ - 1)], "assigning variable p_1d_vec"); - current_statement__ = 8; - pos__ = (pos__ + 1);}} - } - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "M", M); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "K", K); - current_statement__ = 9; - validate_non_negative_index("p_3d_vec", "N", N); - std::vector>>> p_3d_vec; - p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector p_3d_vec_flat__; - current_statement__ = 9; - assign(p_3d_vec_flat__, nil_index_list(), - context__.vals_r("p_3d_vec"), "assigning variable p_3d_vec_flat__"); - current_statement__ = 9; - pos__ = 1; - current_statement__ = 9; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 9; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 9; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 9; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 9; - assign(p_3d_vec, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - p_3d_vec_flat__[(pos__ - 1)], "assigning variable p_3d_vec"); - current_statement__ = 9; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 10; - validate_non_negative_index("p_row_vec", "N", N); - Eigen::Matrix p_row_vec; - p_row_vec = Eigen::Matrix(N); - - { - std::vector p_row_vec_flat__; - current_statement__ = 10; - assign(p_row_vec_flat__, nil_index_list(), - context__.vals_r("p_row_vec"), - "assigning variable p_row_vec_flat__"); - current_statement__ = 10; - pos__ = 1; - current_statement__ = 10; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 10; - assign(p_row_vec, cons_list(index_uni(sym1__), nil_index_list()), - p_row_vec_flat__[(pos__ - 1)], "assigning variable p_row_vec"); - current_statement__ = 10; - pos__ = (pos__ + 1);} - } - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - current_statement__ = 11; - validate_non_negative_index("p_1d_row_vec", "N", N); - std::vector> p_1d_row_vec; - p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector p_1d_row_vec_flat__; - current_statement__ = 11; - assign(p_1d_row_vec_flat__, nil_index_list(), - context__.vals_r("p_1d_row_vec"), - "assigning variable p_1d_row_vec_flat__"); - current_statement__ = 11; - pos__ = 1; - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 11; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 11; - assign(p_1d_row_vec, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - p_1d_row_vec_flat__[(pos__ - 1)], - "assigning variable p_1d_row_vec"); - current_statement__ = 11; - pos__ = (pos__ + 1);}} - } - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "M", M); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "K", K); - current_statement__ = 12; - validate_non_negative_index("p_3d_row_vec", "N", N); - std::vector>>> p_3d_row_vec; - p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector p_3d_row_vec_flat__; - current_statement__ = 12; - assign(p_3d_row_vec_flat__, nil_index_list(), - context__.vals_r("p_3d_row_vec"), - "assigning variable p_3d_row_vec_flat__"); - current_statement__ = 12; - pos__ = 1; - current_statement__ = 12; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 12; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 12; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 12; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 12; - assign(p_3d_row_vec, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - p_3d_row_vec_flat__[(pos__ - 1)], - "assigning variable p_3d_row_vec"); - current_statement__ = 12; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "4", 4); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "5", 5); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "2", 2); - current_statement__ = 13; - validate_non_negative_index("p_ar_mat", "3", 3); - std::vector>> p_ar_mat; - p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - - { - std::vector p_ar_mat_flat__; - current_statement__ = 13; - assign(p_ar_mat_flat__, nil_index_list(), - context__.vals_r("p_ar_mat"), "assigning variable p_ar_mat_flat__"); - current_statement__ = 13; - pos__ = 1; - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - current_statement__ = 13; - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - current_statement__ = 13; - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - p_ar_mat_flat__[(pos__ - 1)], "assigning variable p_ar_mat"); - current_statement__ = 13; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 13; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 13; - for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { - current_statement__ = 13; - for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { - current_statement__ = 13; - assign(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - stan::math::lub_free( - rvalue(p_ar_mat, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym4__), nil_index_list())))), - "p_ar_mat"), 0, 1), "assigning variable p_ar_mat");}}}} - current_statement__ = 14; - validate_positive_index("p_simplex", "N", N); - Eigen::Matrix p_simplex; - p_simplex = Eigen::Matrix(N); - - { - std::vector p_simplex_flat__; - current_statement__ = 14; - assign(p_simplex_flat__, nil_index_list(), - context__.vals_r("p_simplex"), - "assigning variable p_simplex_flat__"); - current_statement__ = 14; - pos__ = 1; - current_statement__ = 14; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 14; - assign(p_simplex, cons_list(index_uni(sym1__), nil_index_list()), - p_simplex_flat__[(pos__ - 1)], "assigning variable p_simplex"); - current_statement__ = 14; - pos__ = (pos__ + 1);} - } - current_statement__ = 14; - assign(p_simplex, nil_index_list(), - stan::math::simplex_free(p_simplex), "assigning variable p_simplex"); - current_statement__ = 15; - validate_non_negative_index("p_1d_simplex", "N", N); - current_statement__ = 15; - validate_positive_index("p_1d_simplex", "N", N); - std::vector> p_1d_simplex; - p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - - { - std::vector p_1d_simplex_flat__; - current_statement__ = 15; - assign(p_1d_simplex_flat__, nil_index_list(), - context__.vals_r("p_1d_simplex"), - "assigning variable p_1d_simplex_flat__"); - current_statement__ = 15; - pos__ = 1; - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - current_statement__ = 15; - assign(p_1d_simplex, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - p_1d_simplex_flat__[(pos__ - 1)], - "assigning variable p_1d_simplex"); - current_statement__ = 15; - pos__ = (pos__ + 1);}} - } - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 15; - assign(p_1d_simplex, cons_list(index_uni(sym1__), nil_index_list()), - stan::math::simplex_free(p_1d_simplex[(sym1__ - 1)]), - "assigning variable p_1d_simplex");} - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "N", N); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "M", M); - current_statement__ = 16; - validate_non_negative_index("p_3d_simplex", "K", K); - current_statement__ = 16; - validate_positive_index("p_3d_simplex", "N", N); - std::vector>>> p_3d_simplex; - p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - - { - std::vector p_3d_simplex_flat__; - current_statement__ = 16; - assign(p_3d_simplex_flat__, nil_index_list(), - context__.vals_r("p_3d_simplex"), - "assigning variable p_3d_simplex_flat__"); - current_statement__ = 16; - pos__ = 1; - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - current_statement__ = 16; - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - current_statement__ = 16; - assign(p_3d_simplex, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - p_3d_simplex_flat__[(pos__ - 1)], - "assigning variable p_3d_simplex"); - current_statement__ = 16; - pos__ = (pos__ + 1);}}}} - } - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - current_statement__ = 16; - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - current_statement__ = 16; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 16; - assign(p_3d_simplex, - cons_list(index_uni(sym1__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym3__), nil_index_list()))), - stan::math::simplex_free( - p_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), - "assigning variable p_3d_simplex");}}} - current_statement__ = 17; - check_greater_or_equal("cholesky_factor_cov p_cfcov_54", - "num rows (must be greater or equal to num cols)", - 5, 4); - current_statement__ = 17; - validate_non_negative_index("p_cfcov_54", "4", 4); - Eigen::Matrix p_cfcov_54; - p_cfcov_54 = Eigen::Matrix(5, 4); - - { - std::vector p_cfcov_54_flat__; - current_statement__ = 17; - assign(p_cfcov_54_flat__, nil_index_list(), - context__.vals_r("p_cfcov_54"), - "assigning variable p_cfcov_54_flat__"); - current_statement__ = 17; - pos__ = 1; - current_statement__ = 17; - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - current_statement__ = 17; - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - current_statement__ = 17; - assign(p_cfcov_54, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - p_cfcov_54_flat__[(pos__ - 1)], "assigning variable p_cfcov_54"); - current_statement__ = 17; - pos__ = (pos__ + 1);}} - } - current_statement__ = 17; - validate_non_negative_index("p_cfcov_54_free__", - "((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))", - ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); - Eigen::Matrix p_cfcov_54_free__; - p_cfcov_54_free__ = Eigen::Matrix(((((4 * (4 - 1)) / 2) - + 4) + - ((5 - 4) * 4))); - - current_statement__ = 17; - assign(p_cfcov_54_free__, nil_index_list(), - stan::math::cholesky_factor_free(p_cfcov_54), - "assigning variable p_cfcov_54_free__"); - current_statement__ = 18; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 18; - validate_non_negative_index("p_cfcov_33", "3", 3); - Eigen::Matrix p_cfcov_33; - p_cfcov_33 = Eigen::Matrix(3, 3); - - { - std::vector p_cfcov_33_flat__; - current_statement__ = 18; - assign(p_cfcov_33_flat__, nil_index_list(), - context__.vals_r("p_cfcov_33"), - "assigning variable p_cfcov_33_flat__"); - current_statement__ = 18; - pos__ = 1; - current_statement__ = 18; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 18; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 18; - assign(p_cfcov_33, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - p_cfcov_33_flat__[(pos__ - 1)], "assigning variable p_cfcov_33"); - current_statement__ = 18; - pos__ = (pos__ + 1);}} - } - current_statement__ = 18; - validate_non_negative_index("p_cfcov_33_free__", - "((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))", - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); - Eigen::Matrix p_cfcov_33_free__; - p_cfcov_33_free__ = Eigen::Matrix(((((3 * (3 - 1)) / 2) - + 3) + - ((3 - 3) * 3))); - - current_statement__ = 18; - assign(p_cfcov_33_free__, nil_index_list(), - stan::math::cholesky_factor_free(p_cfcov_33), - "assigning variable p_cfcov_33_free__"); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "K", K); - current_statement__ = 19; - check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", - "num rows (must be greater or equal to num cols)", - 3, 3); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar", "3", 3); - std::vector> p_cfcov_33_ar; - p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); - - { - std::vector p_cfcov_33_ar_flat__; - current_statement__ = 19; - assign(p_cfcov_33_ar_flat__, nil_index_list(), - context__.vals_r("p_cfcov_33_ar"), - "assigning variable p_cfcov_33_ar_flat__"); - current_statement__ = 19; - pos__ = 1; - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 19; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 19; - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - current_statement__ = 19; - assign(p_cfcov_33_ar, - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list()))), - p_cfcov_33_ar_flat__[(pos__ - 1)], - "assigning variable p_cfcov_33_ar"); - current_statement__ = 19; - pos__ = (pos__ + 1);}}} - } - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar_free__", "K", K); - current_statement__ = 19; - validate_non_negative_index("p_cfcov_33_ar_free__", - "((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))", - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); - std::vector> p_cfcov_33_ar_free__; - p_cfcov_33_ar_free__ = std::vector>(K, Eigen::Matrix( - ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); - - current_statement__ = 19; - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - current_statement__ = 19; - assign(p_cfcov_33_ar_free__, - cons_list(index_uni(sym1__), nil_index_list()), - stan::math::cholesky_factor_free(p_cfcov_33_ar[(sym1__ - 1)]), - "assigning variable p_cfcov_33_ar_free__");} - current_statement__ = 20; - validate_non_negative_index("x_p", "2", 2); - Eigen::Matrix x_p; - x_p = Eigen::Matrix(2); - - { - std::vector x_p_flat__; - current_statement__ = 20; - assign(x_p_flat__, nil_index_list(), context__.vals_r("x_p"), - "assigning variable x_p_flat__"); - current_statement__ = 20; - pos__ = 1; - current_statement__ = 20; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 20; - assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), - x_p_flat__[(pos__ - 1)], "assigning variable x_p"); - current_statement__ = 20; - pos__ = (pos__ + 1);} - } - current_statement__ = 21; - validate_non_negative_index("y_p", "2", 2); - Eigen::Matrix y_p; - y_p = Eigen::Matrix(2); - - { - std::vector y_p_flat__; - current_statement__ = 21; - assign(y_p_flat__, nil_index_list(), context__.vals_r("y_p"), - "assigning variable y_p_flat__"); - current_statement__ = 21; - pos__ = 1; - current_statement__ = 21; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 21; - assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), - y_p_flat__[(pos__ - 1)], "assigning variable y_p"); - current_statement__ = 21; - pos__ = (pos__ + 1);} - } - vars__.push_back(p_real); - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(offset_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(no_offset_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - vars__.push_back(offset_no_multiplier[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_real_1d_ar[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - vars__.push_back( - p_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - vars__.push_back(p_row_vec[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - vars__.push_back( - rvalue(p_ar_mat, - cons_list(index_uni(sym4__), - cons_list(index_uni(sym3__), - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())))), - "p_ar_mat"));}}}} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - vars__.push_back(p_simplex[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - vars__.push_back(p_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - vars__.push_back( - p_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ - (sym1__ - 1)]);}}}} - for (size_t sym1__ = 1; - sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { - vars__.push_back(p_cfcov_54_free__[(sym1__ - 1)]);} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - vars__.push_back(p_cfcov_33_free__[(sym1__ - 1)]);} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - vars__.push_back(p_cfcov_33_ar_free__[(sym2__ - 1)][(sym1__ - 1)]); - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(x_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y_p[(sym1__ - 1)]);} - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } // transform_inits() - - void get_param_names(std::vector& names__) const { - - names__.resize(0); - names__.push_back("p_real"); - names__.push_back("offset_multiplier"); - names__.push_back("no_offset_multiplier"); - names__.push_back("offset_no_multiplier"); - names__.push_back("p_real_1d_ar"); - names__.push_back("p_real_3d_ar"); - names__.push_back("p_vec"); - names__.push_back("p_1d_vec"); - names__.push_back("p_3d_vec"); - names__.push_back("p_row_vec"); - names__.push_back("p_1d_row_vec"); - names__.push_back("p_3d_row_vec"); - names__.push_back("p_ar_mat"); - names__.push_back("p_simplex"); - names__.push_back("p_1d_simplex"); - names__.push_back("p_3d_simplex"); - names__.push_back("p_cfcov_54"); - names__.push_back("p_cfcov_33"); - names__.push_back("p_cfcov_33_ar"); - names__.push_back("x_p"); - names__.push_back("y_p"); - names__.push_back("tp_real_1d_ar"); - names__.push_back("tp_real_3d_ar"); - names__.push_back("tp_vec"); - names__.push_back("tp_1d_vec"); - names__.push_back("tp_3d_vec"); - names__.push_back("tp_row_vec"); - names__.push_back("tp_1d_row_vec"); - names__.push_back("tp_3d_row_vec"); - names__.push_back("tp_ar_mat"); - names__.push_back("tp_simplex"); - names__.push_back("tp_1d_simplex"); - names__.push_back("tp_3d_simplex"); - names__.push_back("tp_cfcov_54"); - names__.push_back("tp_cfcov_33"); - names__.push_back("tp_cfcov_33_ar"); - names__.push_back("theta_p"); - names__.push_back("gq_r1"); - names__.push_back("gq_r2"); - names__.push_back("gq_real_1d_ar"); - names__.push_back("gq_real_3d_ar"); - names__.push_back("gq_vec"); - names__.push_back("gq_1d_vec"); - names__.push_back("gq_3d_vec"); - names__.push_back("gq_row_vec"); - names__.push_back("gq_1d_row_vec"); - names__.push_back("gq_3d_row_vec"); - names__.push_back("gq_ar_mat"); - names__.push_back("gq_simplex"); - names__.push_back("gq_1d_simplex"); - names__.push_back("gq_3d_simplex"); - names__.push_back("gq_cfcov_54"); - names__.push_back("gq_cfcov_33"); - names__.push_back("gq_cfcov_33_ar"); - names__.push_back("indices"); - names__.push_back("indexing_mat"); - names__.push_back("idx_res1"); - names__.push_back("idx_res2"); - names__.push_back("idx_res3"); - names__.push_back("idx_res11"); - names__.push_back("idx_res21"); - names__.push_back("idx_res31"); - names__.push_back("idx_res4"); - names__.push_back("idx_res5"); - } // get_param_names() - - void get_dims(std::vector>& dimss__) const { - dimss__.resize(0); - std::vector dims__; - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(4); - - dims__.push_back(5); - - dims__.push_back(2); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(K); - - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(4); - - dims__.push_back(5); - - dims__.push_back(2); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(K); - - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(4); - - dims__.push_back(5); - - dims__.push_back(2); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(N); - - dims__.push_back(M); - - dims__.push_back(K); - - dims__.push_back(N); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(K); - - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(5); - - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(4); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - - } // get_dims() - - void constrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { - - param_names__.push_back(std::string() + "p_real"); - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "offset_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "no_offset_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "offset_no_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "p_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "p_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_simplex" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - { - param_names__.push_back(std::string() + "p_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "p_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - { - param_names__.push_back(std::string() + "p_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); - }} + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; + + try { + + current_statement__ = 2; + auto foo = closure00__(); + + current_statement__ = 3; + auto bar = closure01__(foo); + double alpha; + + current_statement__ = 1; + alpha = in__.scalar(); + + + vars__.push_back(alpha); + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + current_statement__ = 4; + auto baz = closure02__(foo); + current_statement__ = 5; + auto goo = closure03__(); + if (logical_negation(emit_generated_quantities__)) { + return ; + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // write_array() + + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { + typedef double local_scalar_t__; + vars__.resize(0); + vars__.reserve(num_params_r__); + + try { + int pos__; + + pos__ = 1; + double alpha; + + current_statement__ = 1; + alpha = context__.vals_r("alpha")[(1 - 1)]; + vars__.push_back(alpha); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("alpha"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "alpha"); if (emit_transformed_parameters__) { - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "tp_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_simplex" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - { - param_names__.push_back(std::string() + "tp_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); - }} + + } + + if (emit_generated_quantities__) { + + } + + } // constrained_param_names() + + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "alpha"); + if (emit_transformed_parameters__) { + + } + + if (emit_generated_quantities__) { + + } + + } // unconstrained_param_names() + + std::string get_constrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"; + return s__.str(); + } // get_constrained_sizedtypes() + + std::string get_unconstrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"; + return s__.str(); + } // get_unconstrained_sizedtypes() + + + // Begin method overload boilerplate + template + void write_array(RNG& base_rng__, + Eigen::Matrix& params_r, + Eigen::Matrix& vars, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream = 0) const { + std::vector params_r_vec(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r_vec[i] = params_r(i); + std::vector vars_vec; + std::vector params_i_vec; + write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, + emit_transformed_parameters__, emit_generated_quantities__, pstream); + vars.resize(vars_vec.size()); + for (int i = 0; i < vars.size(); ++i) + vars(i) = vars_vec[i]; + } + + template + T_ log_prob(Eigen::Matrix& params_r, + std::ostream* pstream = 0) const { + std::vector vec_params_r; + vec_params_r.reserve(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + vec_params_r.push_back(params_r(i)); + std::vector vec_params_i; + return log_prob(vec_params_r, vec_params_i, pstream); + } + + void transform_inits(const stan::io::var_context& context, + Eigen::Matrix& params_r, + std::ostream* pstream__) const { + std::vector params_r_vec; + std::vector params_i_vec; + transform_inits(context, params_i_vec, params_r_vec, pstream__); + params_r.resize(params_r_vec.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r(i) = params_r_vec[i]; + } + +}; +} +typedef closure2_model_namespace::closure2_model stan_model; + +#ifndef USING_R + +// Boilerplate +stan::model::model_base& new_model( + stan::io::var_context& data_context, + unsigned int seed, + std::ostream* msg_stream) { + stan_model* m = new stan_model(data_context, seed, msg_stream); + return *m; +} + +#endif + + + + $ ../../../../../install/default/bin/stanc --print-cpp eight_schools_ncp.stan + +// Code generated by %%NAME%% %%VERSION%% +#include +namespace eight_schools_ncp_model_namespace { + +template +std::vector resize_to_match__(std::vector& dst, const std::vector& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.rows(), src.cols()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} +std::vector to_doubles__(std::initializer_list x) { + return x; +} + +std::vector to_vars__(std::initializer_list x) { + return x; +} + +inline void validate_positive_index(const char* var_name, const char* expr, + int val) { + if (val < 1) { + std::stringstream msg; + msg << "Found dimension size less than one in simplex declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + +inline void validate_unit_vector_index(const char* var_name, const char* expr, + int val) { + if (val <= 1) { + std::stringstream msg; + if (val == 1) { + msg << "Found dimension size one in unit vector declaration." + << " One-dimensional unit vector is discrete" + << " but the target distribution must be continuous." + << " variable=" << var_name << "; dimension size expression=" << expr; + } else { + msg << "Found dimension size less than one in unit vector declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + } + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + + +using std::istream; +using std::string; +using std::stringstream; +using std::vector; +using std::pow; +using stan::io::dump; +using stan::math::lgamma; +using stan::model::model_base_crtp; +using stan::model::rvalue; +using stan::model::cons_list; +using stan::model::index_uni; +using stan::model::index_max; +using stan::model::index_min; +using stan::model::index_min_max; +using stan::model::index_multi; +using stan::model::index_omni; +using stan::model::nil_index_list; +using namespace stan::math; + +static int current_statement__ = 0; +static const std::vector locations_array__ = {" (found before start of program)", + " (in 'eight_schools_ncp.stan', line 8, column 2 to column 10)", + " (in 'eight_schools_ncp.stan', line 9, column 2 to column 20)", + " (in 'eight_schools_ncp.stan', line 10, column 2 to column 24)", + " (in 'eight_schools_ncp.stan', line 14, column 2 to column 43)", + " (in 'eight_schools_ncp.stan', line 18, column 2 to column 20)", + " (in 'eight_schools_ncp.stan', line 19, column 2 to column 21)", + " (in 'eight_schools_ncp.stan', line 20, column 2 to column 29)", + " (in 'eight_schools_ncp.stan', line 21, column 2 to column 27)", + " (in 'eight_schools_ncp.stan', line 2, column 2 to column 17)", + " (in 'eight_schools_ncp.stan', line 3, column 2 to column 12)", + " (in 'eight_schools_ncp.stan', line 4, column 2 to column 25)"}; + + + + + + + +class eight_schools_ncp_model : public model_base_crtp { + + private: + int pos__; + int J; + std::vector y; + std::vector sigma; + + public: + ~eight_schools_ncp_model() { } + + std::string model_name() const { return "eight_schools_ncp_model"; } + + eight_schools_ncp_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "eight_schools_ncp_model_namespace::eight_schools_ncp_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + context__.validate_dims("data initialization","J","int", + context__.to_vec()); + + current_statement__ = 9; + J = context__.vals_i("J")[(1 - 1)]; + current_statement__ = 10; + validate_non_negative_index("y", "J", J); + context__.validate_dims("data initialization","y","double", + context__.to_vec(J)); + y = std::vector(J, 0); + + current_statement__ = 10; + assign(y, nil_index_list(), context__.vals_r("y"), + "assigning variable y"); + current_statement__ = 11; + validate_non_negative_index("sigma", "J", J); + context__.validate_dims("data initialization","sigma","double", + context__.to_vec(J)); + sigma = std::vector(J, 0); + + current_statement__ = 11; + assign(sigma, nil_index_list(), context__.vals_r("sigma"), + "assigning variable sigma"); + current_statement__ = 9; + current_statement__ = 9; + check_greater_or_equal(function__, "J", J, 0); + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + current_statement__ = 11; + current_statement__ = 11; + check_greater_or_equal(function__, "sigma[sym1__]", + sigma[(sym1__ - 1)], 0);} + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + num_params_r__ += 1; + num_params_r__ += 1; + current_statement__ = 3; + validate_non_negative_index("theta_tilde", "J", J); + num_params_r__ += J; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } + } + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "eight_schools_ncp_model_namespace::log_prob"; +(void) function__; // suppress unused var warning + + stan::io::reader in__(params_r__, params_i__); - if (emit_generated_quantities__) { - param_names__.push_back(std::string() + "gq_r1"); - param_names__.push_back(std::string() + "gq_r2"); - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "gq_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_simplex" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { - { - param_names__.push_back(std::string() + "gq_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - param_names__.push_back(std::string() + "indices" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "indexing_mat" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res1" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res2" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res3" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res11" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res21" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res31" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "idx_res4" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - param_names__.push_back(std::string() + "idx_res5" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} + try { + local_scalar_t__ mu; + + current_statement__ = 1; + mu = in__.scalar(); + local_scalar_t__ tau; + + current_statement__ = 2; + tau = in__.scalar(); + current_statement__ = 2; + if (jacobian__) { + current_statement__ = 2; + tau = stan::math::lb_constrain(tau, 0, lp__); + } else { + current_statement__ = 2; + tau = stan::math::lb_constrain(tau, 0); + } + current_statement__ = 3; + validate_non_negative_index("theta_tilde", "J", J); + Eigen::Matrix theta_tilde; + theta_tilde = Eigen::Matrix(J); + + current_statement__ = 3; + theta_tilde = in__.vector(J); + current_statement__ = 4; + validate_non_negative_index("theta", "J", J); + Eigen::Matrix theta; + theta = Eigen::Matrix(J); + + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + current_statement__ = 4; + assign(theta, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta");} + current_statement__ = 4; + assign(theta, nil_index_list(), add(mu, multiply(tau, theta_tilde)), + "assigning variable theta"); + { + current_statement__ = 5; + lp_accum__.add(normal_log(mu, 0, 5)); + current_statement__ = 6; + lp_accum__.add(normal_log(tau, 0, 5)); + current_statement__ = 7; + lp_accum__.add(normal_log(theta_tilde, 0, 1)); + current_statement__ = 8; + lp_accum__.add(normal_log(y, theta, sigma)); + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() - } // constrained_param_names() + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "eight_schools_ncp_model_namespace::write_array"; +(void) function__; // suppress unused var warning + + (void) function__; // suppress unused var warning + + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; - void unconstrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { + try { + double mu; + + current_statement__ = 1; + mu = in__.scalar(); + double tau; + + current_statement__ = 2; + tau = in__.scalar(); + current_statement__ = 2; + tau = stan::math::lb_constrain(tau, 0); + current_statement__ = 3; + validate_non_negative_index("theta_tilde", "J", J); + Eigen::Matrix theta_tilde; + theta_tilde = Eigen::Matrix(J); + + current_statement__ = 3; + theta_tilde = in__.vector(J); + current_statement__ = 4; + validate_non_negative_index("theta", "J", J); + Eigen::Matrix theta; + theta = Eigen::Matrix(J); + + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + current_statement__ = 4; + assign(theta, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta");} + vars__.push_back(mu); + vars__.push_back(tau); + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + vars__.push_back(theta_tilde[(sym1__ - 1)]);} + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + current_statement__ = 4; + assign(theta, nil_index_list(), add(mu, multiply(tau, theta_tilde)), + "assigning variable theta"); + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + vars__.push_back(theta[(sym1__ - 1)]);} + if (logical_negation(emit_generated_quantities__)) { + return ; + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // write_array() - param_names__.push_back(std::string() + "p_real"); - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "offset_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "no_offset_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { - { - param_names__.push_back(std::string() + "offset_no_multiplier" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "p_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "p_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "p_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - param_names__.push_back(std::string() + "p_simplex" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "p_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "p_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; - sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { - { - param_names__.push_back(std::string() + "p_cfcov_54" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - { - param_names__.push_back(std::string() + "p_cfcov_33" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - param_names__.push_back(std::string() + "p_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { + typedef double local_scalar_t__; + vars__.resize(0); + vars__.reserve(num_params_r__); + + try { + int pos__; + + pos__ = 1; + double mu; + + current_statement__ = 1; + mu = context__.vals_r("mu")[(1 - 1)]; + double tau; + + current_statement__ = 2; + tau = context__.vals_r("tau")[(1 - 1)]; + current_statement__ = 2; + tau = stan::math::lb_free(tau, 0); + current_statement__ = 3; + validate_non_negative_index("theta_tilde", "J", J); + Eigen::Matrix theta_tilde; + theta_tilde = Eigen::Matrix(J); + { - param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + std::vector theta_tilde_flat__; + current_statement__ = 3; + assign(theta_tilde_flat__, nil_index_list(), + context__.vals_r("theta_tilde"), + "assigning variable theta_tilde_flat__"); + current_statement__ = 3; + pos__ = 1; + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + current_statement__ = 3; + assign(theta_tilde, cons_list(index_uni(sym1__), nil_index_list()), + theta_tilde_flat__[(pos__ - 1)], "assigning variable theta_tilde"); + current_statement__ = 3; + pos__ = (pos__ + 1);} + } + vars__.push_back(mu); + vars__.push_back(tau); + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + vars__.push_back(theta_tilde[(sym1__ - 1)]);} + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("mu"); + names__.push_back("tau"); + names__.push_back("theta_tilde"); + names__.push_back("theta"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(J); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(J); + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "mu"); + param_names__.push_back(std::string() + "tau"); + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { { - param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "theta_tilde" + '.' + std::to_string(sym1__)); }} if (emit_transformed_parameters__) { - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "tp_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "tp_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} + param_names__.push_back(std::string() + "theta" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + } + + if (emit_generated_quantities__) { + + } + + } // constrained_param_names() + + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "mu"); + param_names__.push_back(std::string() + "tau"); + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_tilde" + '.' + std::to_string(sym1__)); + }} + if (emit_transformed_parameters__) { + for (size_t sym1__ = 1; sym1__ <= J; ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} + param_names__.push_back(std::string() + "theta" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + } + + if (emit_generated_quantities__) { + + } + + } // unconstrained_param_names() + + std::string get_constrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"theta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"parameters\"},{\"name\":\"theta\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"transformed_parameters\"}]"; + return s__.str(); + } // get_constrained_sizedtypes() + + std::string get_unconstrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"theta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"parameters\"},{\"name\":\"theta\",\"type\":{\"name\":\"vector\",\"length\":" << J << "},\"block\":\"transformed_parameters\"}]"; + return s__.str(); + } // get_unconstrained_sizedtypes() + + + // Begin method overload boilerplate + template + void write_array(RNG& base_rng__, + Eigen::Matrix& params_r, + Eigen::Matrix& vars, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream = 0) const { + std::vector params_r_vec(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r_vec[i] = params_r(i); + std::vector vars_vec; + std::vector params_i_vec; + write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, + emit_transformed_parameters__, emit_generated_quantities__, pstream); + vars.resize(vars_vec.size()); + for (int i = 0; i < vars.size(); ++i) + vars(i) = vars_vec[i]; + } + + template + T_ log_prob(Eigen::Matrix& params_r, + std::ostream* pstream = 0) const { + std::vector vec_params_r; + vec_params_r.reserve(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + vec_params_r.push_back(params_r(i)); + std::vector vec_params_i; + return log_prob(vec_params_r, vec_params_i, pstream); + } + + void transform_inits(const stan::io::var_context& context, + Eigen::Matrix& params_r, + std::ostream* pstream__) const { + std::vector params_r_vec; + std::vector params_i_vec; + transform_inits(context, params_i_vec, params_r_vec, pstream__); + params_r.resize(params_r_vec.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r(i) = params_r_vec[i]; + } + +}; +} + +typedef eight_schools_ncp_model_namespace::eight_schools_ncp_model stan_model; + +#ifndef USING_R + +// Boilerplate +stan::model::model_base& new_model( + stan::io::var_context& data_context, + unsigned int seed, + std::ostream* msg_stream) { + stan_model* m = new stan_model(data_context, seed, msg_stream); + return *m; +} + +#endif + + + + $ ../../../../../install/default/bin/stanc --print-cpp mother.stan + +// Code generated by %%NAME%% %%VERSION%% +#include +namespace mother_model_namespace { + +template +std::vector resize_to_match__(std::vector& dst, const std::vector& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.rows(), src.cols()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} +std::vector to_doubles__(std::initializer_list x) { + return x; +} + +std::vector to_vars__(std::initializer_list x) { + return x; +} + +inline void validate_positive_index(const char* var_name, const char* expr, + int val) { + if (val < 1) { + std::stringstream msg; + msg << "Found dimension size less than one in simplex declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + +inline void validate_unit_vector_index(const char* var_name, const char* expr, + int val) { + if (val <= 1) { + std::stringstream msg; + if (val == 1) { + msg << "Found dimension size one in unit vector declaration." + << " One-dimensional unit vector is discrete" + << " but the target distribution must be continuous." + << " variable=" << var_name << "; dimension size expression=" << expr; + } else { + msg << "Found dimension size less than one in unit vector declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + } + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + + +using std::istream; +using std::string; +using std::stringstream; +using std::vector; +using std::pow; +using stan::io::dump; +using stan::math::lgamma; +using stan::model::model_base_crtp; +using stan::model::rvalue; +using stan::model::cons_list; +using stan::model::index_uni; +using stan::model::index_max; +using stan::model::index_min; +using stan::model::index_min_max; +using stan::model::index_multi; +using stan::model::index_omni; +using stan::model::nil_index_list; +using namespace stan::math; + +static int current_statement__ = 0; +static const std::vector locations_array__ = {" (found before start of program)", + " (in 'mother.stan', line 401, column 2 to column 14)", + " (in 'mother.stan', line 402, column 2 to column 52)", + " (in 'mother.stan', line 403, column 2 to column 45)", + " (in 'mother.stan', line 404, column 2 to column 41)", + " (in 'mother.stan', line 405, column 2 to column 32)", + " (in 'mother.stan', line 406, column 2 to column 36)", + " (in 'mother.stan', line 407, column 2 to column 27)", + " (in 'mother.stan', line 408, column 2 to column 24)", + " (in 'mother.stan', line 409, column 2 to column 28)", + " (in 'mother.stan', line 410, column 2 to column 26)", + " (in 'mother.stan', line 411, column 2 to column 32)", + " (in 'mother.stan', line 412, column 2 to column 36)", + " (in 'mother.stan', line 413, column 2 to column 45)", + " (in 'mother.stan', line 414, column 2 to column 23)", + " (in 'mother.stan', line 415, column 2 to column 29)", + " (in 'mother.stan', line 416, column 2 to column 33)", + " (in 'mother.stan', line 417, column 2 to column 38)", + " (in 'mother.stan', line 418, column 2 to column 36)", + " (in 'mother.stan', line 419, column 2 to column 42)", + " (in 'mother.stan', line 420, column 2 to column 16)", + " (in 'mother.stan', line 421, column 2 to column 16)", + " (in 'mother.stan', line 424, column 2 to column 33)", + " (in 'mother.stan', line 425, column 2 to column 37)", + " (in 'mother.stan', line 426, column 2 to column 28)", + " (in 'mother.stan', line 427, column 2 to column 25)", + " (in 'mother.stan', line 428, column 2 to column 29)", + " (in 'mother.stan', line 429, column 2 to column 27)", + " (in 'mother.stan', line 430, column 2 to column 33)", + " (in 'mother.stan', line 431, column 2 to column 37)", + " (in 'mother.stan', line 432, column 2 to column 46)", + " (in 'mother.stan', line 433, column 2 to column 24)", + " (in 'mother.stan', line 434, column 2 to column 30)", + " (in 'mother.stan', line 435, column 2 to column 34)", + " (in 'mother.stan', line 436, column 2 to column 39)", + " (in 'mother.stan', line 437, column 2 to column 37)", + " (in 'mother.stan', line 438, column 2 to column 43)", + " (in 'mother.stan', line 439, column 2 to column 20)", + " (in 'mother.stan', line 441, column 2 to column 31)", + " (in 'mother.stan', line 442, column 2 to column 31)", + " (in 'mother.stan', line 443, column 2 to column 23)", + " (in 'mother.stan', line 444, column 2 to column 23)", + " (in 'mother.stan', line 446, column 2 to column 25)", + " (in 'mother.stan', line 447, column 2 to column 31)", + " (in 'mother.stan', line 448, column 2 to column 31)", + " (in 'mother.stan', line 450, column 2 to column 27)", + " (in 'mother.stan', line 451, column 2 to column 27)", + " (in 'mother.stan', line 452, column 2 to column 33)", + " (in 'mother.stan', line 458, column 10 to column 38)", + " (in 'mother.stan', line 457, column 23 to line 458, column 39)", + " (in 'mother.stan', line 457, column 8 to line 458, column 39)", + " (in 'mother.stan', line 456, column 21 to line 458, column 40)", + " (in 'mother.stan', line 456, column 6 to line 458, column 40)", + " (in 'mother.stan', line 455, column 19 to line 458, column 41)", + " (in 'mother.stan', line 455, column 4 to line 458, column 41)", + " (in 'mother.stan', line 454, column 17 to line 458, column 42)", + " (in 'mother.stan', line 454, column 2 to line 458, column 42)", + " (in 'mother.stan', line 460, column 17 to column 45)", + " (in 'mother.stan', line 460, column 2 to column 45)", + " (in 'mother.stan', line 461, column 2 to column 29)", + " (in 'mother.stan', line 462, column 2 to column 31)", + " (in 'mother.stan', line 463, column 2 to column 31)", + " (in 'mother.stan', line 465, column 2 to column 63)", + " (in 'mother.stan', line 466, column 2 to column 79)", + " (in 'mother.stan', line 467, column 2 to column 81)", + " (in 'mother.stan', line 468, column 2 to column 65)", + " (in 'mother.stan', line 469, column 2 to column 81)", + " (in 'mother.stan', line 470, column 2 to column 67)", + " (in 'mother.stan', line 471, column 2 to column 83)", + " (in 'mother.stan', line 515, column 2 to column 32)", + " (in 'mother.stan', line 516, column 2 to column 27)", + " (in 'mother.stan', line 517, column 2 to column 35)", + " (in 'mother.stan', line 518, column 2 to column 39)", + " (in 'mother.stan', line 519, column 2 to column 28)", + " (in 'mother.stan', line 520, column 2 to column 25)", + " (in 'mother.stan', line 521, column 2 to column 29)", + " (in 'mother.stan', line 522, column 2 to column 27)", + " (in 'mother.stan', line 523, column 2 to column 33)", + " (in 'mother.stan', line 524, column 2 to column 37)", + " (in 'mother.stan', line 525, column 2 to column 46)", + " (in 'mother.stan', line 526, column 2 to column 24)", + " (in 'mother.stan', line 527, column 2 to column 30)", + " (in 'mother.stan', line 528, column 2 to column 34)", + " (in 'mother.stan', line 529, column 2 to column 39)", + " (in 'mother.stan', line 530, column 2 to column 37)", + " (in 'mother.stan', line 531, column 2 to column 43)", + " (in 'mother.stan', line 532, column 2 to column 29)", + " (in 'mother.stan', line 533, column 2 to column 31)", + " (in 'mother.stan', line 534, column 2 to column 27)", + " (in 'mother.stan', line 535, column 2 to column 27)", + " (in 'mother.stan', line 536, column 2 to column 27)", + " (in 'mother.stan', line 537, column 2 to column 28)", + " (in 'mother.stan', line 538, column 2 to column 28)", + " (in 'mother.stan', line 539, column 2 to column 28)", + " (in 'mother.stan', line 540, column 2 to column 28)", + " (in 'mother.stan', line 541, column 2 to column 24)", + " (in 'mother.stan', line 543, column 2 to column 35)", + " (in 'mother.stan', line 544, column 2 to column 31)", + " (in 'mother.stan', line 545, column 2 to column 23)", + " (in 'mother.stan', line 546, column 2 to column 23)", + " (in 'mother.stan', line 547, column 2 to column 25)", + " (in 'mother.stan', line 548, column 2 to column 31)", + " (in 'mother.stan', line 549, column 2 to column 31)", + " (in 'mother.stan', line 551, column 2 to column 35)", + " (in 'mother.stan', line 552, column 2 to column 31)", + " (in 'mother.stan', line 553, column 2 to column 31)", + " (in 'mother.stan', line 555, column 2 to column 27)", + " (in 'mother.stan', line 556, column 2 to column 27)", + " (in 'mother.stan', line 557, column 2 to column 33)", + " (in 'mother.stan', line 563, column 10 to column 38)", + " (in 'mother.stan', line 562, column 23 to line 563, column 39)", + " (in 'mother.stan', line 562, column 8 to line 563, column 39)", + " (in 'mother.stan', line 561, column 21 to line 563, column 40)", + " (in 'mother.stan', line 561, column 6 to line 563, column 40)", + " (in 'mother.stan', line 560, column 19 to line 563, column 41)", + " (in 'mother.stan', line 560, column 4 to line 563, column 41)", + " (in 'mother.stan', line 559, column 17 to line 563, column 42)", + " (in 'mother.stan', line 559, column 2 to line 563, column 42)", + " (in 'mother.stan', line 565, column 17 to column 45)", + " (in 'mother.stan', line 565, column 2 to column 45)", + " (in 'mother.stan', line 571, column 8 to column 49)", + " (in 'mother.stan', line 570, column 6 to line 571, column 49)", + " (in 'mother.stan', line 569, column 4 to line 571, column 49)", + " (in 'mother.stan', line 568, column 2 to line 571, column 49)", + " (in 'mother.stan', line 576, column 6 to column 60)", + " (in 'mother.stan', line 575, column 4 to line 576, column 60)", + " (in 'mother.stan', line 574, column 2 to line 576, column 60)", + " (in 'mother.stan', line 578, column 2 to column 45)", + " (in 'mother.stan', line 579, column 64 to column 97)", + " (in 'mother.stan', line 579, column 2 to column 97)", + " (in 'mother.stan', line 584, column 6 to column 51)", + " (in 'mother.stan', line 583, column 4 to line 584, column 51)", + " (in 'mother.stan', line 582, column 2 to line 584, column 51)", + " (in 'mother.stan', line 585, column 2 to column 39)", + " (in 'mother.stan', line 587, column 58 to column 91)", + " (in 'mother.stan', line 587, column 2 to column 91)", + " (in 'mother.stan', line 593, column 8 to column 68)", + " (in 'mother.stan', line 592, column 6 to line 593, column 68)", + " (in 'mother.stan', line 591, column 4 to line 593, column 68)", + " (in 'mother.stan', line 590, column 2 to line 593, column 68)", + " (in 'mother.stan', line 594, column 2 to column 48)", + " (in 'mother.stan', line 595, column 67 to column 100)", + " (in 'mother.stan', line 595, column 2 to column 100)", + " (in 'mother.stan', line 597, column 2 to column 36)", + " (in 'mother.stan', line 598, column 2 to column 38)", + " (in 'mother.stan', line 474, column 2 to column 16)", + " (in 'mother.stan', line 475, column 2 to column 20)", + " (in 'mother.stan', line 476, column 2 to column 29)", + " (in 'mother.stan', line 477, column 2 to column 24)", + " (in 'mother.stan', line 478, column 2 to column 23)", + " (in 'mother.stan', line 479, column 2 to column 35)", + " (in 'mother.stan', line 481, column 2 to column 38)", + " (in 'mother.stan', line 482, column 2 to column 38)", + " (in 'mother.stan', line 484, column 2 to column 41)", + " (in 'mother.stan', line 486, column 4 to column 42)", + " (in 'mother.stan', line 487, column 4 to column 46)", + " (in 'mother.stan', line 488, column 4 to column 46)", + " (in 'mother.stan', line 491, column 8 to column 68)", + " (in 'mother.stan', line 492, column 8 to column 76)", + " (in 'mother.stan', line 493, column 8 to column 76)", + " (in 'mother.stan', line 494, column 8 to column 65)", + " (in 'mother.stan', line 490, column 21 to line 495, column 7)", + " (in 'mother.stan', line 490, column 6 to line 495, column 7)", + " (in 'mother.stan', line 489, column 19 to line 496, column 5)", + " (in 'mother.stan', line 489, column 4 to line 496, column 5)", + " (in 'mother.stan', line 485, column 17 to line 497, column 3)", + " (in 'mother.stan', line 485, column 2 to line 497, column 3)", + " (in 'mother.stan', line 500, column 6 to column 47)", + " (in 'mother.stan', line 499, column 19 to line 501, column 5)", + " (in 'mother.stan', line 499, column 4 to line 501, column 5)", + " (in 'mother.stan', line 498, column 17 to line 502, column 3)", + " (in 'mother.stan', line 498, column 2 to line 502, column 3)", + " (in 'mother.stan', line 504, column 4 to column 47)", + " (in 'mother.stan', line 503, column 17 to line 505, column 3)", + " (in 'mother.stan', line 503, column 2 to line 505, column 3)", + " (in 'mother.stan', line 506, column 2 to column 38)", + " (in 'mother.stan', line 507, column 2 to column 38)", + " (in 'mother.stan', line 508, column 2 to column 38)", + " (in 'mother.stan', line 509, column 2 to column 39)", + " (in 'mother.stan', line 510, column 2 to column 39)", + " (in 'mother.stan', line 512, column 2 to column 53)", + " (in 'mother.stan', line 316, column 2 to column 17)", + " (in 'mother.stan', line 317, column 2 to column 17)", + " (in 'mother.stan', line 318, column 2 to column 28)", + " (in 'mother.stan', line 319, column 2 to column 30)", + " (in 'mother.stan', line 320, column 2 to column 34)", + " (in 'mother.stan', line 321, column 2 to column 32)", + " (in 'mother.stan', line 322, column 2 to column 23)", + " (in 'mother.stan', line 323, column 2 to column 27)", + " (in 'mother.stan', line 324, column 2 to column 18)", + " (in 'mother.stan', line 325, column 2 to column 24)", + " (in 'mother.stan', line 326, column 2 to column 28)", + " (in 'mother.stan', line 327, column 2 to column 26)", + " (in 'mother.stan', line 328, column 2 to column 32)", + " (in 'mother.stan', line 329, column 2 to column 36)", + " (in 'mother.stan', line 330, column 2 to column 45)", + " (in 'mother.stan', line 331, column 2 to column 23)", + " (in 'mother.stan', line 332, column 2 to column 29)", + " (in 'mother.stan', line 333, column 2 to column 33)", + " (in 'mother.stan', line 334, column 2 to column 38)", + " (in 'mother.stan', line 335, column 2 to column 36)", + " (in 'mother.stan', line 336, column 2 to column 42)", + " (in 'mother.stan', line 339, column 2 to column 13)", + " (in 'mother.stan', line 340, column 2 to column 15)", + " (in 'mother.stan', line 341, column 2 to column 34)", + " (in 'mother.stan', line 342, column 2 to column 15)", + " (in 'mother.stan', line 343, column 2 to column 20)", + " (in 'mother.stan', line 344, column 2 to column 29)", + " (in 'mother.stan', line 345, column 2 to column 46)", + " (in 'mother.stan', line 346, column 2 to column 24)", + " (in 'mother.stan', line 347, column 2 to column 30)", + " (in 'mother.stan', line 348, column 2 to column 34)", + " (in 'mother.stan', line 349, column 2 to column 39)", + " (in 'mother.stan', line 350, column 2 to column 37)", + " (in 'mother.stan', line 351, column 2 to column 14)", + " (in 'mother.stan', line 352, column 2 to column 14)", + " (in 'mother.stan', line 353, column 2 to column 14)", + " (in 'mother.stan', line 354, column 2 to column 17)", + " (in 'mother.stan', line 355, column 2 to column 17)", + " (in 'mother.stan', line 356, column 2 to column 16)", + " (in 'mother.stan', line 357, column 2 to column 18)", + " (in 'mother.stan', line 358, column 2 to column 18)", + " (in 'mother.stan', line 363, column 10 to column 38)", + " (in 'mother.stan', line 362, column 23 to line 363, column 39)", + " (in 'mother.stan', line 362, column 8 to line 363, column 39)", + " (in 'mother.stan', line 361, column 21 to line 363, column 40)", + " (in 'mother.stan', line 361, column 6 to line 363, column 40)", + " (in 'mother.stan', line 360, column 19 to line 363, column 41)", + " (in 'mother.stan', line 360, column 4 to line 363, column 41)", + " (in 'mother.stan', line 359, column 17 to line 363, column 42)", + " (in 'mother.stan', line 359, column 2 to line 363, column 42)", + " (in 'mother.stan', line 365, column 4 to column 28)", + " (in 'mother.stan', line 367, column 6 to column 36)", + " (in 'mother.stan', line 370, column 10 to column 46)", + " (in 'mother.stan', line 369, column 23 to line 370, column 47)", + " (in 'mother.stan', line 369, column 8 to line 370, column 47)", + " (in 'mother.stan', line 368, column 21 to line 370, column 48)", + " (in 'mother.stan', line 368, column 6 to line 370, column 48)", + " (in 'mother.stan', line 366, column 19 to line 370, column 49)", + " (in 'mother.stan', line 366, column 4 to line 370, column 49)", + " (in 'mother.stan', line 364, column 17 to line 370, column 50)", + " (in 'mother.stan', line 364, column 2 to line 370, column 50)", + " (in 'mother.stan', line 373, column 6 to column 40)", + " (in 'mother.stan', line 374, column 6 to column 63)", + " (in 'mother.stan', line 372, column 19 to line 375, column 5)", + " (in 'mother.stan', line 372, column 4 to line 375, column 5)", + " (in 'mother.stan', line 371, column 17 to line 375, column 6)", + " (in 'mother.stan', line 371, column 2 to line 375, column 6)", + " (in 'mother.stan', line 376, column 2 to column 62)", + " (in 'mother.stan', line 377, column 2 to column 62)", + " (in 'mother.stan', line 379, column 4 to column 11)", + " (in 'mother.stan', line 380, column 4 to column 35)", + " (in 'mother.stan', line 381, column 4 to line 383, column 5)", + " (in 'mother.stan', line 382, column 6 to column 12)", + " (in 'mother.stan', line 384, column 4 to column 31)", + " (in 'mother.stan', line 385, column 4 to line 387, column 5)", + " (in 'mother.stan', line 386, column 6 to column 12)", + " (in 'mother.stan', line 378, column 2 to line 388, column 3)", + " (in 'mother.stan', line 390, column 2 to column 25)", + " (in 'mother.stan', line 391, column 2 to column 34)", + " (in 'mother.stan', line 392, column 2 to column 33)", + " (in 'mother.stan', line 393, column 2 to column 36)", + " (in 'mother.stan', line 395, column 2 to column 23)", + " (in 'mother.stan', line 396, column 2 to column 30)", + " (in 'mother.stan', line 398, column 2 to column 28)", + " (in 'mother.stan', line 10, column 16 to column 17)", + " (in 'mother.stan', line 13, column 16 to column 25)", + " (in 'mother.stan', line 13, column 4 to column 25)", + " (in 'mother.stan', line 14, column 4 to column 26)", + " (in 'mother.stan', line 12, column 17 to line 15, column 3)", + " (in 'mother.stan', line 22, column 31 to column 32)", + " (in 'mother.stan', line 29, column 4 to column 17)", + " (in 'mother.stan', line 30, column 4 to column 19)", + " (in 'mother.stan', line 31, column 4 to column 38)", + " (in 'mother.stan', line 32, column 4 to column 16)", + " (in 'mother.stan', line 28, column 31 to line 33, column 3)", + " (in 'mother.stan', line 36, column 4 to column 15)", + " (in 'mother.stan', line 35, column 18 to line 37, column 3)", + " (in 'mother.stan', line 40, column 4 to column 15)", + " (in 'mother.stan', line 39, column 24 to line 41, column 3)", + " (in 'mother.stan', line 44, column 4 to column 15)", + " (in 'mother.stan', line 43, column 32 to line 45, column 3)", + " (in 'mother.stan', line 48, column 4 to column 15)", + " (in 'mother.stan', line 47, column 36 to line 49, column 3)", + " (in 'mother.stan', line 52, column 4 to column 15)", + " (in 'mother.stan', line 51, column 36 to line 53, column 3)", + " (in 'mother.stan', line 56, column 4 to column 15)", + " (in 'mother.stan', line 55, column 37 to line 57, column 3)", + " (in 'mother.stan', line 59, column 4 to column 33)", + " (in 'mother.stan', line 58, column 36 to line 60, column 3)", + " (in 'mother.stan', line 63, column 4 to column 42)", + " (in 'mother.stan', line 64, column 4 to column 26)", + " (in 'mother.stan', line 62, column 30 to line 65, column 3)", + " (in 'mother.stan', line 69, column 14 to column 20)", + " (in 'mother.stan', line 69, column 4 to column 20)", + " (in 'mother.stan', line 70, column 14 to column 23)", + " (in 'mother.stan', line 70, column 4 to column 23)", + " (in 'mother.stan', line 73, column 20 to column 26)", + " (in 'mother.stan', line 73, column 4 to column 26)", + " (in 'mother.stan', line 74, column 20 to column 29)", + " (in 'mother.stan', line 74, column 4 to column 29)", + " (in 'mother.stan', line 78, column 6 to column 12)", + " (in 'mother.stan', line 79, column 6 to column 12)", + " (in 'mother.stan', line 80, column 6 to column 12)", + " (in 'mother.stan', line 77, column 14 to line 81, column 5)", + " (in 'mother.stan', line 77, column 4 to line 81, column 5)", + " (in 'mother.stan', line 87, column 11 to column 17)", + " (in 'mother.stan', line 86, column 18 to column 24)", + " (in 'mother.stan', line 86, column 11 to line 87, column 17)", + " (in 'mother.stan', line 85, column 13 to column 19)", + " (in 'mother.stan', line 85, column 6 to line 87, column 17)", + " (in 'mother.stan', line 84, column 14 to line 88, column 5)", + " (in 'mother.stan', line 84, column 4 to line 88, column 5)", + " (in 'mother.stan', line 91, column 24 to column 30)", + " (in 'mother.stan', line 91, column 14 to column 30)", + " (in 'mother.stan', line 91, column 4 to column 30)", + " (in 'mother.stan', line 95, column 22 to column 28)", + " (in 'mother.stan', line 95, column 6 to column 28)", + " (in 'mother.stan', line 94, column 14 to line 96, column 5)", + " (in 'mother.stan', line 94, column 4 to line 96, column 5)", + " (in 'mother.stan', line 100, column 6 to column 19)", + " (in 'mother.stan', line 101, column 6 to column 12)", + " (in 'mother.stan', line 102, column 6 to line 105, column 7)", + " (in 'mother.stan', line 103, column 8 to column 14)", + " (in 'mother.stan', line 104, column 8 to column 14)", + " (in 'mother.stan', line 106, column 6 to line 109, column 7)", + " (in 'mother.stan', line 107, column 8 to column 14)", + " (in 'mother.stan', line 108, column 8 to column 17)", + " (in 'mother.stan', line 110, column 6 to line 116, column 7)", + " (in 'mother.stan', line 111, column 8 to line 114, column 9)", + " (in 'mother.stan', line 112, column 10 to column 16)", + " (in 'mother.stan', line 113, column 10 to column 16)", + " (in 'mother.stan', line 115, column 8 to column 14)", + " (in 'mother.stan', line 99, column 14 to line 117, column 5)", + " (in 'mother.stan', line 99, column 4 to line 117, column 5)", + " (in 'mother.stan', line 121, column 6 to column 13)", + " (in 'mother.stan', line 122, column 6 to column 21)", + " (in 'mother.stan', line 123, column 6 to line 126, column 7)", + " (in 'mother.stan', line 124, column 8 to column 14)", + " (in 'mother.stan', line 125, column 8 to column 14)", + " (in 'mother.stan', line 127, column 6 to line 130, column 7)", + " (in 'mother.stan', line 128, column 8 to column 16)", + " (in 'mother.stan', line 129, column 8 to column 17)", + " (in 'mother.stan', line 120, column 14 to line 131, column 5)", + " (in 'mother.stan', line 120, column 4 to line 131, column 5)", + " (in 'mother.stan', line 135, column 6 to column 13)", + " (in 'mother.stan', line 136, column 6 to column 19)", + " (in 'mother.stan', line 137, column 6 to line 140, column 7)", + " (in 'mother.stan', line 138, column 8 to column 14)", + " (in 'mother.stan', line 139, column 8 to column 14)", + " (in 'mother.stan', line 141, column 6 to line 144, column 7)", + " (in 'mother.stan', line 142, column 8 to column 16)", + " (in 'mother.stan', line 143, column 8 to column 17)", + " (in 'mother.stan', line 134, column 14 to line 145, column 5)", + " (in 'mother.stan', line 134, column 4 to line 145, column 5)", + " (in 'mother.stan', line 149, column 6 to column 13)", + " (in 'mother.stan', line 150, column 6 to column 23)", + " (in 'mother.stan', line 151, column 6 to line 154, column 7)", + " (in 'mother.stan', line 152, column 8 to column 14)", + " (in 'mother.stan', line 153, column 8 to column 14)", + " (in 'mother.stan', line 155, column 6 to line 158, column 7)", + " (in 'mother.stan', line 156, column 8 to column 16)", + " (in 'mother.stan', line 157, column 8 to column 17)", + " (in 'mother.stan', line 148, column 14 to line 159, column 5)", + " (in 'mother.stan', line 148, column 4 to line 159, column 5)", + " (in 'mother.stan', line 163, column 6 to column 12)", + " (in 'mother.stan', line 164, column 6 to column 12)", + " (in 'mother.stan', line 166, column 8 to column 14)", + " (in 'mother.stan', line 167, column 8 to column 14)", + " (in 'mother.stan', line 168, column 8 to column 14)", + " (in 'mother.stan', line 165, column 6 to line 169, column 7)", + " (in 'mother.stan', line 162, column 14 to line 170, column 5)", + " (in 'mother.stan', line 162, column 4 to line 170, column 5)", + " (in 'mother.stan', line 172, column 4 to column 13)", + " (in 'mother.stan', line 67, column 19 to line 173, column 3)", + " (in 'mother.stan', line 176, column 4 to column 14)", + " (in 'mother.stan', line 177, column 4 to column 10)", + " (in 'mother.stan', line 178, column 4 to column 24)", + " (in 'mother.stan', line 178, column 18 to column 24)", + " (in 'mother.stan', line 179, column 4 to column 13)", + " (in 'mother.stan', line 175, column 19 to line 180, column 3)", + " (in 'mother.stan', line 183, column 4 to column 26)", + " (in 'mother.stan', line 182, column 30 to line 184, column 3)", + " (in 'mother.stan', line 187, column 4 to column 24)", + " (in 'mother.stan', line 186, column 22 to line 188, column 3)", + " (in 'mother.stan', line 191, column 4 to column 42)", + " (in 'mother.stan', line 190, column 21 to line 192, column 3)", + " (in 'mother.stan', line 195, column 4 to column 18)", + " (in 'mother.stan', line 196, column 4 to column 19)", + " (in 'mother.stan', line 197, column 4 to column 27)", + " (in 'mother.stan', line 198, column 4 to column 40)", + " (in 'mother.stan', line 200, column 6 to column 81)", + " (in 'mother.stan', line 199, column 4 to line 200, column 81)", + " (in 'mother.stan', line 202, column 6 to column 81)", + " (in 'mother.stan', line 201, column 4 to line 202, column 81)", + " (in 'mother.stan', line 203, column 4 to column 32)", + " (in 'mother.stan', line 194, column 59 to line 204, column 3)", + " (in 'mother.stan', line 208, column 4 to column 22)", + " (in 'mother.stan', line 207, column 52 to line 209, column 3)", + " (in 'mother.stan', line 212, column 4 to column 14)", + " (in 'mother.stan', line 211, column 66 to line 213, column 3)", + " (in 'mother.stan', line 215, column 4 to column 14)", + " (in 'mother.stan', line 214, column 78 to line 216, column 3)", + " (in 'mother.stan', line 219, column 4 to column 35)", + " (in 'mother.stan', line 220, column 4 to column 12)", + " (in 'mother.stan', line 221, column 4 to column 16)", + " (in 'mother.stan', line 222, column 4 to column 20)", + " (in 'mother.stan', line 223, column 4 to column 13)", + " (in 'mother.stan', line 218, column 49 to line 224, column 3)", + " (in 'mother.stan', line 226, column 4 to column 16)", + " (in 'mother.stan', line 225, column 150 to line 227, column 3)", + " (in 'mother.stan', line 230, column 4 to column 14)", + " (in 'mother.stan', line 229, column 149 to line 231, column 3)", + " (in 'mother.stan', line 234, column 4 to column 14)", + " (in 'mother.stan', line 233, column 151 to line 235, column 3)", + " (in 'mother.stan', line 238, column 4 to column 14)", + " (in 'mother.stan', line 237, column 152 to line 239, column 3)", + " (in 'mother.stan', line 242, column 4 to column 14)", + " (in 'mother.stan', line 241, column 150 to line 243, column 3)", + " (in 'mother.stan', line 246, column 4 to column 14)", + " (in 'mother.stan', line 245, column 152 to line 247, column 3)", + " (in 'mother.stan', line 250, column 4 to column 14)", + " (in 'mother.stan', line 249, column 153 to line 251, column 3)", + " (in 'mother.stan', line 254, column 4 to column 14)", + " (in 'mother.stan', line 253, column 152 to line 255, column 3)", + " (in 'mother.stan', line 258, column 4 to column 14)", + " (in 'mother.stan', line 257, column 154 to line 259, column 3)", + " (in 'mother.stan', line 262, column 4 to column 14)", + " (in 'mother.stan', line 261, column 155 to line 263, column 3)", + " (in 'mother.stan', line 266, column 4 to column 15)", + " (in 'mother.stan', line 265, column 153 to line 267, column 3)", + " (in 'mother.stan', line 270, column 4 to column 15)", + " (in 'mother.stan', line 269, column 155 to line 271, column 3)", + " (in 'mother.stan', line 274, column 4 to column 15)", + " (in 'mother.stan', line 273, column 156 to line 275, column 3)", + " (in 'mother.stan', line 277, column 4 to column 10)", + " (in 'mother.stan', line 278, column 4 to column 11)", + " (in 'mother.stan', line 279, column 4 to column 18)", + " (in 'mother.stan', line 280, column 4 to column 32)", + " (in 'mother.stan', line 281, column 4 to column 24)", + " (in 'mother.stan', line 276, column 14 to line 282, column 3)", + " (in 'mother.stan', line 284, column 4 to line 286, column 40)", + " (in 'mother.stan', line 283, column 18 to line 287, column 3)", + " (in 'mother.stan', line 289, column 4 to column 35)", + " (in 'mother.stan', line 288, column 18 to line 290, column 3)", + " (in 'mother.stan', line 292, column 4 to column 33)", + " (in 'mother.stan', line 293, column 4 to column 13)", + " (in 'mother.stan', line 291, column 27 to line 294, column 3)", + " (in 'mother.stan', line 296, column 4 to column 48)", + " (in 'mother.stan', line 297, column 4 to column 26)", + " (in 'mother.stan', line 295, column 27 to line 298, column 3)", + " (in 'mother.stan', line 303, column 4 to column 18)", + " (in 'mother.stan', line 304, column 4 to column 25)", + " (in 'mother.stan', line 305, column 4 to column 25)", + " (in 'mother.stan', line 306, column 4 to column 15)", + " (in 'mother.stan', line 302, column 39 to line 307, column 3)", + " (in 'mother.stan', line 310, column 4 to column 19)", + " (in 'mother.stan', line 311, column 4 to column 18)", + " (in 'mother.stan', line 312, column 4 to column 16)", + " (in 'mother.stan', line 309, column 78 to line 313, column 3)"}; + + +int +foo(const int& n, std::ostream* pstream__) ; + +int +foo(const int& n, std::ostream* pstream__) ; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +double +foo_bar0(std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_bar1(const T0__& x, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, + std::ostream* pstream__) ; + +template +void +unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +int +foo_1(const int& a, std::ostream* pstream__) ; + +int +foo_2(const int& a, std::ostream* pstream__) ; + +template +std::vector::type> +foo_3(const T0__& t, const int& n, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +template +void +foo_4(const T0__& x, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +relative_diff(const T0__& x, const T1__& y, const T2__& max_, + const T3__& min_, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +foo_5(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, + const T4__& x5, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type>::type +foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, + const T3__& x4, const T4__& x5, const T5__& x6, + T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, -1> +covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, + std::ostream* pstream__) ; + +template +void +f0(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +int +f1(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector +f2(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector> +f3(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type>::type +f4(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type> +f5(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type>> +f6(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type>::type, -1, 1> +f7(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, 1>> +f8(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, 1>>> +f9(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type>::type, -1, -1> +f10(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, -1>> +f11(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +template +std::vector::type>::type, -1, -1>>> +f12(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) ; + +void +foo_6(std::ostream* pstream__) ; + +Eigen::Matrix +matfoo(std::ostream* pstream__) ; + +Eigen::Matrix +vecfoo(std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +vecmufoo(const T0__& mu, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +vecmubar(const T0__& mu, std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +algebra_system(const Eigen::Matrix& x, + const Eigen::Matrix& y, + const std::vector& dat, const std::vector& dat_int, + std::ostream* pstream__) ; + +template +Eigen::Matrix::type, -1, 1> +binomialf(const Eigen::Matrix& phi, + const Eigen::Matrix& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) ; + + + +int +foo(const int& n, std::ostream* pstream__) ; + +int +foo(const int& n, std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 267; + if (logical_eq(n, 0)) { + current_statement__ = 266; + return 1; + } + current_statement__ = 268; + return (n * foo((n - 1), pstream__)); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_functor__ { +const static int num_vars__ = 0; +int +operator()(const int& n, std::ostream* pstream__) const +{ +return foo(n, pstream__); +} +}; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) ; + +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 271; + validate_non_negative_index("dydt", "2", 2); + std::vector dydt; + dydt = std::vector(2, 0); + + current_statement__ = 272; + assign(dydt, cons_list(index_uni(1), nil_index_list()), y[(2 - 1)], + "assigning variable dydt"); + current_statement__ = 273; + assign(dydt, cons_list(index_uni(2), nil_index_list()), + (-y[(1 - 1)] - (theta[(1 - 1)] * y[(2 - 1)])), + "assigning variable dydt"); + current_statement__ = 274; + return dydt; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct sho_functor__ { +const static int num_vars__ = 0; +template +std::vector::type> +operator()(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) const +{ +return sho(t, y, theta, x, x_int, pstream__); +} +template +std::vector::type> +operator()(const T0__& t, const std::vector& y, + std::ostream* pstream__, const std::vector& theta, + const std::vector& x, const std::vector& x_int) const +{ +return sho(t, y, theta, x, x_int, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = sho_functor__; +using DeepCopy__ = sho_functor__; +using captured_scalar_t__ = double;}; + +double +foo_bar0(std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 276; + return 0.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_bar0_functor__ { +const static int num_vars__ = 0; +double +operator()(std::ostream* pstream__) const +{ +return foo_bar0(pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_bar1(const T0__& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 278; + return 1.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_bar1_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, std::ostream* pstream__) const +{ +return foo_bar1(x, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 280; + return 2.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_bar2_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, const T1__& y, std::ostream* pstream__) const +{ +return foo_bar2(x, y, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + + try { + current_statement__ = 282; + return 1.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_lpmf_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const +{ +return foo_lpmf(y, lambda, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 284; + return 1.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_lcdf_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const +{ +return foo_lcdf(y, lambda, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 286; + return 1.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_lccdf_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const int& y, const T1__& lambda, std::ostream* pstream__) const +{ +return foo_lccdf(y, lambda, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 288; + return normal_rng(mu, sigma, base_rng__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_rng_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& mu, const T1__& sigma, RNG& base_rng__, + std::ostream* pstream__) const +{ +return foo_rng(mu, sigma, base_rng__, pstream__); +} +}; + +template +void +unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + + try { + current_statement__ = 290; + lp_accum__.add(normal_log(u, 0, 1)); + current_statement__ = 291; + lp_accum__.add(uniform_log(u, -100, 100)); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct unit_normal_lp_functor__ { +const static int num_vars__ = 0; +template +void +operator()(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) const +{ +return unit_normal_lp(u, lp__, lp_accum__, pstream__); +} +}; + +int +foo_1(const int& a, std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 294; + while (1) { + break; + } + current_statement__ = 296; + while (0) { + continue; + } + current_statement__ = 298; + for (size_t i = 1; i <= 10; ++i) { break;} + current_statement__ = 300; + for (size_t i = 1; i <= 10; ++i) { continue;} + current_statement__ = 305; + while (1) { + int b; + + current_statement__ = 302; + b = 5; + break; + } + current_statement__ = 312; + while (1) { + current_statement__ = 310; + if (0) { + break; + } else { + current_statement__ = 308; + if (1) { + break; + } else { + break; + } + } + } + current_statement__ = 315; + while (1) { + current_statement__ = 314; + while (0) { + break; + } + } + current_statement__ = 319; + while (1) { + current_statement__ = 317; + for (size_t i = 1; i <= 10; ++i) { break;} + } + current_statement__ = 334; + while (1) { + current_statement__ = 320; + validate_non_negative_index("vs", "2", 2); + current_statement__ = 320; + validate_non_negative_index("vs", "3", 3); + std::vector> vs; + vs = std::vector>(2, std::vector(3, 0)); + + int z; + + current_statement__ = 322; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} + std::vector v; + current_statement__ = 322; + assign(v, nil_index_list(), vs[(sym1__ - 1)], + "assigning variable v"); + current_statement__ = 323; + z = 0; + break; }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + current_statement__ = 325; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - param_names__.push_back(std::string() + "tp_simplex" + '.' + std::to_string(sym1__)); + std::vector v; + current_statement__ = 325; + assign(v, nil_index_list(), vs[(sym1__ - 1)], + "assigning variable v"); + current_statement__ = 326; + z = 0; + continue; }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + current_statement__ = 328; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + std::vector v; + current_statement__ = 328; + assign(v, nil_index_list(), vs[(sym1__ - 1)], + "assigning variable v"); + current_statement__ = 329; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(v); ++sym1__) { { - param_names__.push_back(std::string() + "tp_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + int vv; + current_statement__ = 329; + vv = v[(sym1__ - 1)]; + current_statement__ = 330; + z = 0; + break; }} + current_statement__ = 332; + z = 1; }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "tp_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} + } + current_statement__ = 344; + while (1) { + local_scalar_t__ z; + + current_statement__ = 335; + z = std::numeric_limits::quiet_NaN(); + current_statement__ = 336; + validate_non_negative_index("vs", "2", 2); + current_statement__ = 336; + validate_non_negative_index("vs", "3", 3); + Eigen::Matrix vs; + vs = Eigen::Matrix(2, 3); + + current_statement__ = 336; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 336; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 336; + assign(vs, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), "assigning variable vs"); }} - for (size_t sym1__ = 1; - sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { + current_statement__ = 337; + for (size_t sym1__ = 1; sym1__ <= rows(vs); ++sym1__) { + current_statement__ = 337; + for (size_t sym2__ = 1; + sym2__ <= stan::math::size( + rvalue(vs, + cons_list(index_uni(sym1__), nil_index_list()), + "vs")); ++sym2__) { + { + local_scalar_t__ v; + current_statement__ = 337; + v = rvalue(vs, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), "vs"); + current_statement__ = 338; + z = 0; + break; + }}} + current_statement__ = 340; + for (size_t sym1__ = 1; sym1__ <= rows(vs); ++sym1__) { + current_statement__ = 340; + for (size_t sym2__ = 1; + sym2__ <= stan::math::size( + rvalue(vs, + cons_list(index_uni(sym1__), nil_index_list()), + "vs")); ++sym2__) { + { + local_scalar_t__ v; + current_statement__ = 340; + v = rvalue(vs, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), "vs"); + current_statement__ = 341; + z = 3.1; + continue; + }}} + } + current_statement__ = 354; + while (1) { + local_scalar_t__ z; + + current_statement__ = 345; + z = std::numeric_limits::quiet_NaN(); + current_statement__ = 346; + validate_non_negative_index("vs", "2", 2); + Eigen::Matrix vs; + vs = Eigen::Matrix(2); + + current_statement__ = 346; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 346; + assign(vs, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable vs"); + } + current_statement__ = 347; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - param_names__.push_back(std::string() + "tp_cfcov_54" + '.' + std::to_string(sym1__)); + local_scalar_t__ v; + current_statement__ = 347; + v = vs[(sym1__ - 1)]; + current_statement__ = 348; + z = 0; + break; }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + current_statement__ = 350; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - param_names__.push_back(std::string() + "tp_cfcov_33" + '.' + std::to_string(sym1__)); + local_scalar_t__ v; + current_statement__ = 350; + v = vs[(sym1__ - 1)]; + current_statement__ = 351; + z = 3.2; + continue; }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + } + current_statement__ = 364; + while (1) { + local_scalar_t__ z; + + current_statement__ = 355; + z = std::numeric_limits::quiet_NaN(); + current_statement__ = 356; + validate_non_negative_index("vs", "2", 2); + Eigen::Matrix vs; + vs = Eigen::Matrix(2); + + current_statement__ = 356; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 356; + assign(vs, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable vs"); + } + current_statement__ = 357; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - param_names__.push_back(std::string() + "tp_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} + local_scalar_t__ v; + current_statement__ = 357; + v = vs[(sym1__ - 1)]; + current_statement__ = 358; + z = 0; + break; }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 360; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { { - param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + local_scalar_t__ v; + current_statement__ = 360; + v = vs[(sym1__ - 1)]; + current_statement__ = 361; + z = 3.3; + continue; }} } + current_statement__ = 372; + while (1) { + int b; + + current_statement__ = 366; + b = 5; + { + int c; + + current_statement__ = 368; + c = 6; + break; + } + } + current_statement__ = 373; + return 0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_1_functor__ { +const static int num_vars__ = 0; +int +operator()(const int& a, std::ostream* pstream__) const +{ +return foo_1(a, pstream__); +} +}; + +int +foo_2(const int& a, std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 375; + validate_non_negative_index("vs", "2", 2); + std::vector vs; + vs = std::vector(2, 0); + + int y; + + current_statement__ = 377; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(vs); ++sym1__) { + { + int v; + current_statement__ = 377; + v = vs[(sym1__ - 1)]; + current_statement__ = 378; + y = v; + }} + current_statement__ = 379; + return 0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_2_functor__ { +const static int num_vars__ = 0; +int +operator()(const int& a, std::ostream* pstream__) const +{ +return foo_2(a, pstream__); +} +}; + +template +std::vector::type> +foo_3(const T0__& t, const int& n, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 381; + return rep_array(t, n); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_3_functor__ { +const static int num_vars__ = 0; +template +std::vector::type> +operator()(const T0__& t, const int& n, std::ostream* pstream__) const +{ +return foo_3(t, n, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + + try { + current_statement__ = 383; + return (x + get_lp(lp__, lp_accum__)); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_lp_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) const +{ +return foo_lp(x, lp__, lp_accum__, pstream__); +} +}; + +template +void +foo_4(const T0__& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 385; + std::stringstream errmsg_stream__; + errmsg_stream__ << "user-specified rejection"; + errmsg_stream__ << x; + throw std::domain_error(errmsg_stream__.str()); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_4_functor__ { +const static int num_vars__ = 0; +template +void +operator()(const T0__& x, std::ostream* pstream__) const +{ +return foo_4(x, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +relative_diff(const T0__& x, const T1__& y, const T2__& max_, + const T3__& min_, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + local_scalar_t__ abs_diff; + + current_statement__ = 387; + abs_diff = std::numeric_limits::quiet_NaN(); + local_scalar_t__ avg_scale; + + current_statement__ = 388; + avg_scale = std::numeric_limits::quiet_NaN(); + current_statement__ = 389; + abs_diff = stan::math::fabs((x - y)); + current_statement__ = 390; + avg_scale = ((stan::math::fabs(x) + stan::math::fabs(y)) / 2); + current_statement__ = 392; + if (logical_gt((abs_diff / avg_scale), max_)) { + current_statement__ = 391; + std::stringstream errmsg_stream__; + errmsg_stream__ << "user-specified rejection, difference above "; + errmsg_stream__ << max_; + errmsg_stream__ << " x:"; + errmsg_stream__ << x; + errmsg_stream__ << " y:"; + errmsg_stream__ << y; + throw std::domain_error(errmsg_stream__.str()); + } + current_statement__ = 394; + if (logical_lt((abs_diff / avg_scale), min_)) { + current_statement__ = 393; + std::stringstream errmsg_stream__; + errmsg_stream__ << "user-specified rejection, difference below "; + errmsg_stream__ << min_; + errmsg_stream__ << " x:"; + errmsg_stream__ << x; + errmsg_stream__ << " y:"; + errmsg_stream__ << y; + throw std::domain_error(errmsg_stream__.str()); + } + current_statement__ = 395; + return (abs_diff / avg_scale); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct relative_diff_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, const T1__& y, const T2__& max_, const T3__& min_, + std::ostream* pstream__) const +{ +return relative_diff(x, y, max_, min_, pstream__); +} +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, const T1__& y, std::ostream* pstream__, + const T2__& max_, const T3__& min_) const +{ +return relative_diff(x, y, max_, min_, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = relative_diff_functor__; +using DeepCopy__ = relative_diff_functor__; +using captured_scalar_t__ = double;}; + +template +Eigen::Matrix::type, -1, 1> +foo_5(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 397; + return transpose(stan::math::to_row_vector( + stan::math::array_builder().add(1).add(2).add(3).array())); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_5_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) const +{ +return foo_5(shared_params, job_params, data_r, data_i, pstream__); +} +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + std::ostream* pstream__, const std::vector& data_r, + const std::vector& data_i) const +{ +return foo_5(shared_params, job_params, data_r, data_i, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = foo_5_functor__; +using DeepCopy__ = foo_5_functor__; +using captured_scalar_t__ = double;}; + +template +typename boost::math::tools::promote_args::type +foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, + const T4__& x5, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 399; + return x1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_five_args_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, + const T4__& x5, std::ostream* pstream__) const +{ +return foo_five_args(x1, x2, x3, x4, x5, pstream__); +} +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x1, const T1__& x2, std::ostream* pstream__, + const T2__& x3, const T3__& x4, const T4__& x5) const +{ +return foo_five_args(x1, x2, x3, x4, x5, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = foo_five_args_functor__; +using DeepCopy__ = foo_five_args_functor__; +using captured_scalar_t__ = double;}; + +template +typename boost::math::tools::promote_args::type>::type +foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, + const T3__& x4, const T4__& x5, const T5__& x6, + T_lp__& lp__, T_lp_accum__& lp_accum__, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + + try { + current_statement__ = 401; + return x1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_five_args_lp_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type>::type +operator()(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, + const T4__& x5, const T5__& x6, T_lp__& lp__, + T_lp_accum__& lp_accum__, std::ostream* pstream__) const +{ +return foo_five_args_lp(x1, x2, x3, x4, x5, x6, lp__, lp_accum__, pstream__); +} +}; + +template +Eigen::Matrix::type, -1, -1> +covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 403; + validate_non_negative_index("o", "rows(mat)", rows(mat)); + current_statement__ = 403; + validate_non_negative_index("o", "cols(mat)", cols(mat)); + Eigen::Matrix o; + o = Eigen::Matrix(rows(mat), cols(mat)); - if (emit_generated_quantities__) { - param_names__.push_back(std::string() + "gq_r1"); - param_names__.push_back(std::string() + "gq_r2"); - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_real_1d_ar" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { - { - param_names__.push_back(std::string() + "gq_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - param_names__.push_back(std::string() + "gq_row_vec" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - param_names__.push_back(std::string() + "gq_simplex" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { - { - for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { - { - param_names__.push_back(std::string() + "gq_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - }} - for (size_t sym1__ = 1; - sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { - { - param_names__.push_back(std::string() + "gq_cfcov_54" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - { - param_names__.push_back(std::string() + "gq_cfcov_33" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; - sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { - { - param_names__.push_back(std::string() + "gq_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - param_names__.push_back(std::string() + "indices" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "indexing_mat" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res1" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res2" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res3" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res11" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res21" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { - { - param_names__.push_back(std::string() + "idx_res31" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - }} - for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "idx_res4" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { - { - param_names__.push_back(std::string() + "idx_res5" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} + current_statement__ = 403; + for (size_t sym1__ = 1; sym1__ <= rows(mat); ++sym1__) { + current_statement__ = 403; + for (size_t sym2__ = 1; sym2__ <= cols(mat); ++sym2__) { + current_statement__ = 403; + assign(o, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), "assigning variable o");} + } + current_statement__ = 404; + assign(o, nil_index_list(), mat, "assigning variable o"); + current_statement__ = 405; + assign(o, cons_list(index_uni(1), nil_index_list()), + stan::model::deep_copy( + rvalue(o, cons_list(index_uni(2), nil_index_list()), "o")), + "assigning variable o"); + current_statement__ = 406; + assign(o, cons_list(index_min_max(3, 4), nil_index_list()), + stan::model::deep_copy( + rvalue(o, cons_list(index_min_max(1, 2), nil_index_list()), "o")), + "assigning variable o"); + current_statement__ = 407; + return o; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct covsqrt2corsqrt_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, -1> +operator()(const Eigen::Matrix& mat, const int& invert, + std::ostream* pstream__) const +{ +return covsqrt2corsqrt(mat, invert, pstream__); +} +}; + +template +void +f0(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 409; + if (pstream__) { + stan_print(pstream__, "hi"); + stan_print(pstream__, "\n"); } - - } // unconstrained_param_names() - - std::string get_constrained_sizedtypes() const { - stringstream s__; - s__ << "[{\"name\":\"p_real\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"no_offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"offset_no_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"parameters\"},{\"name\":\"p_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"parameters\"},{\"name\":\"p_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"tp_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"gq_r1\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_r2\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"indices\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"int\"}},\"block\":\"generated_quantities\"},{\"name\":\"indexing_mat\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res1\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res2\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res3\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res11\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res21\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res31\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res4\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res5\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 2 << "}},\"block\":\"generated_quantities\"}]"; - return s__.str(); - } // get_constrained_sizedtypes() - - std::string get_unconstrained_sizedtypes() const { - stringstream s__; - s__ << "[{\"name\":\"p_real\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"no_offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"offset_no_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"parameters\"},{\"name\":\"p_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"parameters\"},{\"name\":\"p_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"parameters\"},{\"name\":\"p_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"parameters\"},{\"name\":\"p_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"tp_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"gq_r1\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_r2\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"generated_quantities\"},{\"name\":\"indices\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"int\"}},\"block\":\"generated_quantities\"},{\"name\":\"indexing_mat\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res1\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res2\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res3\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res11\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res21\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res31\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res4\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res5\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 2 << "}},\"block\":\"generated_quantities\"}]"; - return s__.str(); - } // get_unconstrained_sizedtypes() - + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f0_functor__ { +const static int num_vars__ = 0; +template +void +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +void +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f0_functor__; +using DeepCopy__ = f0_functor__; +using captured_scalar_t__ = double;}; + +template +int +f1(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 411; + return a1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f1_functor__ { +const static int num_vars__ = 0; +template +int +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +int +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f1_functor__; +using DeepCopy__ = f1_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector +f2(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 413; + return a2; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f2_functor__ { +const static int num_vars__ = 0; +template +std::vector +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f2(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f2(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f2_functor__; +using DeepCopy__ = f2_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector> +f3(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 415; + return a3; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f3_functor__ { +const static int num_vars__ = 0; +template +std::vector> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f3(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f3(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f3_functor__; +using DeepCopy__ = f3_functor__; +using captured_scalar_t__ = double;}; + +template +typename boost::math::tools::promote_args::type>::type +f4(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 417; + return a4; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f4_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type>::type +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f4(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +typename boost::math::tools::promote_args::type>::type +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f4(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f4_functor__; +using DeepCopy__ = f4_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector::type>::type> +f5(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 419; + return a5; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f5_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f5(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f5(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f5_functor__; +using DeepCopy__ = f5_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector::type>::type>> +f6(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 421; + return a6; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f6_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type>> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f6(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type>> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f6(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f6_functor__; +using DeepCopy__ = f6_functor__; +using captured_scalar_t__ = double;}; + +template +Eigen::Matrix::type>::type, -1, 1> +f7(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 423; + return a7; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f7_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type>::type, -1, 1> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f7(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +Eigen::Matrix::type>::type, -1, 1> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f7(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f7_functor__; +using DeepCopy__ = f7_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector::type>::type, -1, 1>> +f8(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 425; + return a8; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f8_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type, -1, 1>> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f8(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type, -1, 1>> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f8(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f8_functor__; +using DeepCopy__ = f8_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector::type>::type, -1, 1>>> +f9(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 427; + return a9; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f9_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type, -1, 1>>> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f9(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type, -1, 1>>> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f9(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f9_functor__; +using DeepCopy__ = f9_functor__; +using captured_scalar_t__ = double;}; + +template +Eigen::Matrix::type>::type, -1, -1> +f10(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; - // Begin method overload boilerplate - template - void write_array(RNG& base_rng__, - Eigen::Matrix& params_r, - Eigen::Matrix& vars, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true, - std::ostream* pstream = 0) const { - std::vector params_r_vec(params_r.size()); - for (int i = 0; i < params_r.size(); ++i) - params_r_vec[i] = params_r(i); - std::vector vars_vec; - std::vector params_i_vec; - write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, - emit_transformed_parameters__, emit_generated_quantities__, pstream); - vars.resize(vars_vec.size()); - for (int i = 0; i < vars.size(); ++i) - vars(i) = vars_vec[i]; - } + try { + current_statement__ = 429; + return a10; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} - template - T_ log_prob(Eigen::Matrix& params_r, - std::ostream* pstream = 0) const { - std::vector vec_params_r; - vec_params_r.reserve(params_r.size()); - for (int i = 0; i < params_r.size(); ++i) - vec_params_r.push_back(params_r(i)); - std::vector vec_params_i; - return log_prob(vec_params_r, vec_params_i, pstream); - } +struct f10_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type>::type, -1, -1> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +Eigen::Matrix::type>::type, -1, -1> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f10_functor__; +using DeepCopy__ = f10_functor__; +using captured_scalar_t__ = double;}; - void transform_inits(const stan::io::var_context& context, - Eigen::Matrix& params_r, - std::ostream* pstream__) const { - std::vector params_r_vec; - std::vector params_i_vec; - transform_inits(context, params_i_vec, params_r_vec, pstream__); - params_r.resize(params_r_vec.size()); - for (int i = 0; i < params_r.size(); ++i) - params_r(i) = params_r_vec[i]; - } +template +std::vector::type>::type, -1, -1>> +f11(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 431; + return a11; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} -}; +struct f11_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type, -1, -1>> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type, -1, -1>> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f11_functor__; +using DeepCopy__ = f11_functor__; +using captured_scalar_t__ = double;}; + +template +std::vector::type>::type, -1, -1>>> +f12(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type>::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 433; + return a12; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct f12_functor__ { +const static int num_vars__ = 0; +template +std::vector::type>::type, -1, -1>>> +operator()(const int& a1, const std::vector& a2, + const std::vector>& a3, const T3__& a4, + const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12, + std::ostream* pstream__) const +{ +return f12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +template +std::vector::type>::type, -1, -1>>> +operator()(const int& a1, const std::vector& a2, + std::ostream* pstream__, const std::vector>& a3, + const T3__& a4, const std::vector& a5, + const std::vector>& a6, + const Eigen::Matrix& a7, + const std::vector>& a8, + const std::vector>>& a9, + const Eigen::Matrix& a10, + const std::vector>& a11, + const std::vector>>& a12) const +{ +return f12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f12_functor__; +using DeepCopy__ = f12_functor__; +using captured_scalar_t__ = double;}; + +void +foo_6(std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + int a; + + local_scalar_t__ b; + + current_statement__ = 436; + b = std::numeric_limits::quiet_NaN(); + current_statement__ = 437; + validate_non_negative_index("c", "20", 20); + current_statement__ = 437; + validate_non_negative_index("c", "30", 30); + std::vector> c; + c = std::vector>(20, std::vector(30, 0)); + + current_statement__ = 438; + validate_non_negative_index("ar_mat", "60", 60); + current_statement__ = 438; + validate_non_negative_index("ar_mat", "70", 70); + current_statement__ = 438; + validate_non_negative_index("ar_mat", "40", 40); + current_statement__ = 438; + validate_non_negative_index("ar_mat", "50", 50); + std::vector>> ar_mat; + ar_mat = std::vector>>(60, std::vector>(70, Eigen::Matrix(40, 50))); + + current_statement__ = 438; + for (size_t sym1__ = 1; sym1__ <= 60; ++sym1__) { + current_statement__ = 438; + for (size_t sym2__ = 1; sym2__ <= 70; ++sym2__) { + current_statement__ = 438; + for (size_t sym3__ = 1; sym3__ <= 40; ++sym3__) { + current_statement__ = 438; + for (size_t sym4__ = 1; sym4__ <= 50; ++sym4__) { + current_statement__ = 438; + assign(ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable ar_mat");}}}} + current_statement__ = 439; + assign(ar_mat, + cons_list(index_uni(1), + cons_list(index_uni(1), + cons_list(index_uni(1), cons_list(index_uni(1), nil_index_list())))), + b, "assigning variable ar_mat"); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } -typedef mother_model_namespace::mother_model stan_model; - -#ifndef USING_R -// Boilerplate -stan::model::model_base& new_model( - stan::io::var_context& data_context, - unsigned int seed, - std::ostream* msg_stream) { - stan_model* m = new stan_model(data_context, seed, msg_stream); - return *m; +struct foo_6_functor__ { +const static int num_vars__ = 0; +void +operator()(std::ostream* pstream__) const +{ +return foo_6(pstream__); } +}; -#endif - - -STAN_REGISTER_MAP_RECT(1, mother_model_namespace::binomialf_functor__) - -Warning: deprecated language construct used in 'mother.stan', line 63, column 21: - ------------------------------------------------- - 61: - 62: void unit_normal_lp(real u) { - 63: increment_log_prob(normal_log(u,0,1)); - ^ - 64: u ~ uniform(-100,100); - 65: } - ------------------------------------------------- - -increment_log_prob(...); is deprecated and will be removed in the future. Use target += ...; instead. - - -Warning: deprecated language construct used in 'mother.stan', line 187, column 20: - ------------------------------------------------- - 185: - 186: real foo_lp(real x) { - 187: return x + get_lp(); - ^ - 188: } - 189: - ------------------------------------------------- - -get_lp() function is deprecated. It will be removed in a future release. Use target() instead. - - $ ../../../../../install/default/bin/stanc --print-cpp motherHOF.stan - -// Code generated by %%NAME%% %%VERSION%% -#include -namespace motherHOF_model_namespace { - -template -std::vector resize_to_match__(std::vector& dst, const std::vector& src) { - dst.resize(src.size()); - return dst; +Eigen::Matrix +matfoo(std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 441; + return stan::math::to_matrix( + stan::math::array_builder>() + .add(stan::math::to_row_vector(stan::math::array_builder() + .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) + .add(10).array())).add(stan::math::to_row_vector( + stan::math::array_builder().add(1).add(2).add(3).add(4).add(5) + .add(6).add(7).add(8).add(9).add(10).array())) + .add(stan::math::to_row_vector(stan::math::array_builder() + .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) + .add(10).array())).array()); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.rows(), src.cols()); - return dst; +struct matfoo_functor__ { +const static int num_vars__ = 0; +Eigen::Matrix +operator()(std::ostream* pstream__) const +{ +return matfoo(pstream__); } +}; -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.size()); - return dst; +Eigen::Matrix +vecfoo(std::ostream* pstream__) { + using local_scalar_t__ = double; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 443; + return transpose(stan::math::to_row_vector( + stan::math::array_builder().add(1).add(2).add(3).add(4) + .add(5).add(6).add(7).add(8).add(9).add(10).array())); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } -template -Eigen::Matrix -resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { - dst.resize(src.size()); - return dst; -} -std::vector to_doubles__(std::initializer_list x) { - return x; +struct vecfoo_functor__ { +const static int num_vars__ = 0; +Eigen::Matrix +operator()(std::ostream* pstream__) const +{ +return vecfoo(pstream__); } +}; -std::vector to_vars__(std::initializer_list x) { - return x; +template +Eigen::Matrix::type, -1, 1> +vecmufoo(const T0__& mu, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 445; + validate_non_negative_index("l", "10", 10); + Eigen::Matrix l; + l = Eigen::Matrix(10); + + current_statement__ = 445; + for (size_t sym1__ = 1; sym1__ <= 10; ++sym1__) { + current_statement__ = 445; + assign(l, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable l");} + current_statement__ = 445; + assign(l, nil_index_list(), multiply(mu, vecfoo(pstream__)), + "assigning variable l"); + current_statement__ = 446; + return l; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } -inline void validate_positive_index(const char* var_name, const char* expr, - int val) { - if (val < 1) { - std::stringstream msg; - msg << "Found dimension size less than one in simplex declaration" - << "; variable=" << var_name << "; dimension size expression=" << expr - << "; expression value=" << val; - std::string msg_str(msg.str()); - throw std::invalid_argument(msg_str.c_str()); - } +struct vecmufoo_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const T0__& mu, std::ostream* pstream__) const +{ +return vecmufoo(mu, pstream__); } +}; -inline void validate_unit_vector_index(const char* var_name, const char* expr, - int val) { - if (val <= 1) { - std::stringstream msg; - if (val == 1) { - msg << "Found dimension size one in unit vector declaration." - << " One-dimensional unit vector is discrete" - << " but the target distribution must be continuous." - << " variable=" << var_name << "; dimension size expression=" << expr; - } else { - msg << "Found dimension size less than one in unit vector declaration" - << "; variable=" << var_name << "; dimension size expression=" << expr - << "; expression value=" << val; - } - std::string msg_str(msg.str()); - throw std::invalid_argument(msg_str.c_str()); +template +Eigen::Matrix::type, -1, 1> +vecmubar(const T0__& mu, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 448; + validate_non_negative_index("l", "10", 10); + Eigen::Matrix l; + l = Eigen::Matrix(10); + + current_statement__ = 448; + for (size_t sym1__ = 1; sym1__ <= 10; ++sym1__) { + current_statement__ = 448; + assign(l, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable l");} + current_statement__ = 448; + assign(l, nil_index_list(), + multiply(mu, + transpose(stan::math::to_row_vector(stan::math::array_builder() + .add(1).add(2).add(3).add(4).add(5).add(6).add(7).add(8).add(9) + .add(10).array()))), "assigning variable l"); + current_statement__ = 449; + return rvalue(l, + cons_list(index_multi(stan::math::array_builder().add(1) + .add(2).add(3).add(4).add(5).array()), nil_index_list()), "l"); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } + } - -using std::istream; -using std::string; -using std::stringstream; -using std::vector; -using std::pow; -using stan::io::dump; -using stan::math::lgamma; -using stan::model::model_base_crtp; -using stan::model::rvalue; -using stan::model::cons_list; -using stan::model::index_uni; -using stan::model::index_max; -using stan::model::index_min; -using stan::model::index_min_max; -using stan::model::index_multi; -using stan::model::index_omni; -using stan::model::nil_index_list; -using namespace stan::math; - -static int current_statement__ = 0; -static const std::vector locations_array__ = {" (found before start of program)", - " (in 'motherHOF.stan', line 48, column 2 to column 15)", - " (in 'motherHOF.stan', line 49, column 2 to column 18)", - " (in 'motherHOF.stan', line 50, column 2 to column 14)", - " (in 'motherHOF.stan', line 51, column 2 to column 18)", - " (in 'motherHOF.stan', line 52, column 2 to column 28)", - " (in 'motherHOF.stan', line 53, column 2 to column 28)", - " (in 'motherHOF.stan', line 54, column 2 to column 11)", - " (in 'motherHOF.stan', line 57, column 2 to column 18)", - " (in 'motherHOF.stan', line 58, column 2 to column 37)", - " (in 'motherHOF.stan', line 59, column 2 to column 33)", - " (in 'motherHOF.stan', line 60, column 2 to line 61, column 69)", - " (in 'motherHOF.stan', line 62, column 2 to line 63, column 69)", - " (in 'motherHOF.stan', line 64, column 2 to line 65, column 69)", - " (in 'motherHOF.stan', line 66, column 2 to column 23)", - " (in 'motherHOF.stan', line 67, column 2 to column 16)", - " (in 'motherHOF.stan', line 68, column 2 to column 16)", - " (in 'motherHOF.stan', line 69, column 2 to column 16)", - " (in 'motherHOF.stan', line 70, column 2 to column 70)", - " (in 'motherHOF.stan', line 71, column 2 to column 86)", - " (in 'motherHOF.stan', line 72, column 2 to column 86)", - " (in 'motherHOF.stan', line 73, column 2 to column 72)", - " (in 'motherHOF.stan', line 75, column 2 to column 88)", - " (in 'motherHOF.stan', line 76, column 2 to column 72)", - " (in 'motherHOF.stan', line 77, column 2 to column 88)", - " (in 'motherHOF.stan', line 132, column 2 to column 18)", - " (in 'motherHOF.stan', line 133, column 2 to column 68)", - " (in 'motherHOF.stan', line 134, column 2 to column 68)", - " (in 'motherHOF.stan', line 135, column 2 to column 68)", - " (in 'motherHOF.stan', line 136, column 2 to column 68)", - " (in 'motherHOF.stan', line 138, column 2 to column 87)", - " (in 'motherHOF.stan', line 139, column 2 to column 87)", - " (in 'motherHOF.stan', line 140, column 2 to column 87)", - " (in 'motherHOF.stan', line 141, column 2 to column 87)", - " (in 'motherHOF.stan', line 143, column 2 to column 66)", - " (in 'motherHOF.stan', line 144, column 2 to column 66)", - " (in 'motherHOF.stan', line 145, column 2 to column 66)", - " (in 'motherHOF.stan', line 146, column 2 to column 66)", - " (in 'motherHOF.stan', line 148, column 2 to column 85)", - " (in 'motherHOF.stan', line 149, column 2 to column 85)", - " (in 'motherHOF.stan', line 150, column 2 to column 85)", - " (in 'motherHOF.stan', line 151, column 2 to column 85)", - " (in 'motherHOF.stan', line 153, column 2 to column 67)", - " (in 'motherHOF.stan', line 154, column 2 to column 67)", - " (in 'motherHOF.stan', line 155, column 2 to column 67)", - " (in 'motherHOF.stan', line 156, column 2 to column 67)", - " (in 'motherHOF.stan', line 158, column 2 to column 61)", - " (in 'motherHOF.stan', line 159, column 2 to column 58)", - " (in 'motherHOF.stan', line 160, column 2 to column 58)", - " (in 'motherHOF.stan', line 161, column 2 to column 60)", - " (in 'motherHOF.stan', line 163, column 2 to column 67)", - " (in 'motherHOF.stan', line 164, column 2 to column 64)", - " (in 'motherHOF.stan', line 165, column 2 to column 64)", - " (in 'motherHOF.stan', line 166, column 2 to column 66)", - " (in 'motherHOF.stan', line 168, column 2 to column 34)", - " (in 'motherHOF.stan', line 169, column 2 to column 38)", - " (in 'motherHOF.stan', line 170, column 2 to line 171, column 69)", - " (in 'motherHOF.stan', line 81, column 2 to column 18)", - " (in 'motherHOF.stan', line 82, column 2 to column 68)", - " (in 'motherHOF.stan', line 83, column 2 to column 68)", - " (in 'motherHOF.stan', line 84, column 2 to column 68)", - " (in 'motherHOF.stan', line 86, column 2 to column 87)", - " (in 'motherHOF.stan', line 87, column 2 to column 87)", - " (in 'motherHOF.stan', line 88, column 2 to column 87)", - " (in 'motherHOF.stan', line 90, column 2 to column 66)", - " (in 'motherHOF.stan', line 91, column 2 to column 66)", - " (in 'motherHOF.stan', line 92, column 2 to column 66)", - " (in 'motherHOF.stan', line 93, column 2 to column 66)", - " (in 'motherHOF.stan', line 95, column 2 to column 85)", - " (in 'motherHOF.stan', line 96, column 2 to column 85)", - " (in 'motherHOF.stan', line 97, column 2 to column 85)", - " (in 'motherHOF.stan', line 98, column 2 to column 85)", - " (in 'motherHOF.stan', line 100, column 2 to column 67)", - " (in 'motherHOF.stan', line 101, column 2 to column 67)", - " (in 'motherHOF.stan', line 102, column 2 to column 67)", - " (in 'motherHOF.stan', line 103, column 2 to column 67)", - " (in 'motherHOF.stan', line 105, column 2 to column 61)", - " (in 'motherHOF.stan', line 106, column 2 to column 58)", - " (in 'motherHOF.stan', line 107, column 2 to column 58)", - " (in 'motherHOF.stan', line 108, column 2 to column 60)", - " (in 'motherHOF.stan', line 109, column 2 to column 56)", - " (in 'motherHOF.stan', line 110, column 2 to column 58)", - " (in 'motherHOF.stan', line 111, column 2 to column 58)", - " (in 'motherHOF.stan', line 112, column 2 to column 60)", - " (in 'motherHOF.stan', line 113, column 2 to column 62)", - " (in 'motherHOF.stan', line 114, column 2 to column 62)", - " (in 'motherHOF.stan', line 115, column 2 to column 64)", - " (in 'motherHOF.stan', line 117, column 2 to column 67)", - " (in 'motherHOF.stan', line 118, column 2 to column 64)", - " (in 'motherHOF.stan', line 119, column 2 to column 64)", - " (in 'motherHOF.stan', line 120, column 2 to column 66)", - " (in 'motherHOF.stan', line 121, column 2 to column 62)", - " (in 'motherHOF.stan', line 122, column 2 to column 64)", - " (in 'motherHOF.stan', line 123, column 2 to column 64)", - " (in 'motherHOF.stan', line 124, column 2 to column 66)", - " (in 'motherHOF.stan', line 125, column 2 to column 68)", - " (in 'motherHOF.stan', line 126, column 2 to column 68)", - " (in 'motherHOF.stan', line 127, column 2 to column 70)", - " (in 'motherHOF.stan', line 129, column 2 to column 36)", - " (in 'motherHOF.stan', line 33, column 2 to column 17)", - " (in 'motherHOF.stan', line 34, column 2 to column 15)", - " (in 'motherHOF.stan', line 35, column 2 to column 10)", - " (in 'motherHOF.stan', line 36, column 2 to column 13)", - " (in 'motherHOF.stan', line 37, column 2 to column 18)", - " (in 'motherHOF.stan', line 38, column 2 to column 12)", - " (in 'motherHOF.stan', line 39, column 2 to column 15)", - " (in 'motherHOF.stan', line 40, column 2 to column 16)", - " (in 'motherHOF.stan', line 41, column 2 to column 15)", - " (in 'motherHOF.stan', line 42, column 2 to column 28)", - " (in 'motherHOF.stan', line 43, column 2 to column 28)", - " (in 'motherHOF.stan', line 44, column 2 to column 20)", - " (in 'motherHOF.stan', line 45, column 2 to column 19)", - " (in 'motherHOF.stan', line 7, column 4 to column 17)", - " (in 'motherHOF.stan', line 8, column 4 to column 19)", - " (in 'motherHOF.stan', line 9, column 4 to column 38)", - " (in 'motherHOF.stan', line 10, column 4 to column 16)", - " (in 'motherHOF.stan', line 6, column 26 to line 11, column 3)", - " (in 'motherHOF.stan', line 13, column 4 to column 15)", - " (in 'motherHOF.stan', line 12, column 71 to line 14, column 3)", - " (in 'motherHOF.stan', line 17, column 4 to column 22)", - " (in 'motherHOF.stan', line 16, column 42 to line 18, column 3)", - " (in 'motherHOF.stan', line 20, column 4 to column 17)", - " (in 'motherHOF.stan', line 19, column 28 to line 21, column 3)", - " (in 'motherHOF.stan', line 26, column 4 to column 18)", - " (in 'motherHOF.stan', line 27, column 4 to column 25)", - " (in 'motherHOF.stan', line 28, column 4 to column 25)", - " (in 'motherHOF.stan', line 29, column 4 to column 15)", - " (in 'motherHOF.stan', line 25, column 39 to line 30, column 3)"}; - - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -integrand(const T0__& x, const T1__& xc, const std::vector& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -foo(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) ; - +struct vecmubar_functor__ { +const static int num_vars__ = 0; template -typename boost::math::tools::promote_args::type -map_rectfake(const T0__& x, std::ostream* pstream__) ; +Eigen::Matrix::type, -1, 1> +operator()(const T0__& mu, std::ostream* pstream__) const +{ +return vecmubar(mu, pstream__); +} +}; template Eigen::Matrix::type, -1, 1> algebra_system(const Eigen::Matrix& x, const Eigen::Matrix& y, const std::vector& dat, const std::vector& dat_int, - std::ostream* pstream__) ; - - - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) { + std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; + T2__>::type; const static bool propto__ = true; (void) propto__; try { - current_statement__ = 112; - validate_non_negative_index("dydt", "2", 2); - std::vector dydt; - dydt = std::vector(2, 0); + current_statement__ = 451; + validate_non_negative_index("f_x", "2", 2); + Eigen::Matrix f_x; + f_x = Eigen::Matrix(2); - current_statement__ = 113; - assign(dydt, cons_list(index_uni(1), nil_index_list()), y[(2 - 1)], - "assigning variable dydt"); - current_statement__ = 114; - assign(dydt, cons_list(index_uni(2), nil_index_list()), - (-y[(1 - 1)] - (theta[(1 - 1)] * y[(2 - 1)])), - "assigning variable dydt"); - current_statement__ = 115; - return dydt; + current_statement__ = 451; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 451; + assign(f_x, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable f_x");} + current_statement__ = 452; + assign(f_x, cons_list(index_uni(1), nil_index_list()), + (x[(1 - 1)] - y[(1 - 1)]), "assigning variable f_x"); + current_statement__ = 453; + assign(f_x, cons_list(index_uni(2), nil_index_list()), + (x[(2 - 1)] - y[(2 - 1)]), "assigning variable f_x"); + current_statement__ = 454; + return f_x; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -10752,1614 +5369,6360 @@ sho(const T0__& t, const std::vector& y, } -struct sho_functor__ { -template -std::vector::type> -operator()(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) const +struct algebra_system_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& x, + const Eigen::Matrix& y, const std::vector& dat, + const std::vector& dat_int, std::ostream* pstream__) const { -return sho(t, y, theta, x, x_int, pstream__); +return algebra_system(x, y, dat, dat_int, pstream__); } -}; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& x, + const Eigen::Matrix& y, std::ostream* pstream__, + const std::vector& dat, const std::vector& dat_int) const +{ +return algebra_system(x, y, dat, dat_int, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = algebra_system_functor__; +using DeepCopy__ = algebra_system_functor__; +using captured_scalar_t__ = double;}; -template -typename boost::math::tools::promote_args::type -integrand(const T0__& x, const T1__& xc, const std::vector& theta, - const std::vector& x_r, const std::vector& x_i, +template +Eigen::Matrix::type, -1, 1> +binomialf(const Eigen::Matrix& phi, + const Eigen::Matrix& theta, + const std::vector& x_r, const std::vector& x_i, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; + T1__>::type; const static bool propto__ = true; (void) propto__; try { - current_statement__ = 117; - return 0.0; + current_statement__ = 456; + validate_non_negative_index("lpmf", "1", 1); + Eigen::Matrix lpmf; + lpmf = Eigen::Matrix(1); + + current_statement__ = 456; + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + current_statement__ = 456; + assign(lpmf, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable lpmf"); + } + current_statement__ = 457; + assign(lpmf, cons_list(index_uni(1), nil_index_list()), 0.0, + "assigning variable lpmf"); + current_statement__ = 458; + return lpmf; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct integrand_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, const T1__& xc, const std::vector& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) const -{ -return integrand(x, xc, theta, x_r, x_i, pstream__); -} -}; - -template -Eigen::Matrix::type, -1, 1> -foo(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 119; - return transpose(stan::math::to_row_vector( - stan::math::array_builder().add(1).add(2).add(3).array())); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); + } + +} + +struct binomialf_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& phi, + const Eigen::Matrix& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) const +{ +return binomialf(phi, theta, x_r, x_i, pstream__); +} +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& phi, + const Eigen::Matrix& theta, std::ostream* pstream__, + const std::vector& x_r, const std::vector& x_i) const +{ +return binomialf(phi, theta, x_r, x_i, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = binomialf_functor__; +using DeepCopy__ = binomialf_functor__; +using captured_scalar_t__ = double;}; + + +class mother_model : public model_base_crtp { + + private: + int pos__; + int N; + int M; + int K; + std::vector d_int_1d_ar; + std::vector>> d_int_3d_ar; + double J; + std::vector d_real_1d_ar; + std::vector>> d_real_3d_ar; + Eigen::Matrix d_vec; + std::vector> d_1d_vec; + std::vector>>> d_3d_vec; + Eigen::Matrix d_row_vec; + std::vector> d_1d_row_vec; + std::vector>>> d_3d_row_vec; + std::vector>> d_ar_mat; + Eigen::Matrix d_simplex; + std::vector> d_1d_simplex; + std::vector>>> d_3d_simplex; + Eigen::Matrix d_cfcov_54; + Eigen::Matrix d_cfcov_33; + std::vector> d_cfcov_33_ar; + int td_int; + std::vector td_1d; + std::vector td_1dk; + int td_a; + double td_b; + double td_c; + std::vector>> td_ar_mat; + Eigen::Matrix td_simplex; + std::vector> td_1d_simplex; + std::vector>>> td_3d_simplex; + Eigen::Matrix td_cfcov_54; + Eigen::Matrix td_cfcov_33; + Eigen::Matrix x; + Eigen::Matrix y; + std::vector dat; + std::vector dat_int; + std::vector> x_r; + std::vector> x_i; + std::vector> arr_mul_ind; + std::vector x_mul_ind; + + public: + ~mother_model() { } + + std::string model_name() const { return "mother_model"; } + + mother_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "mother_model_namespace::mother_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + context__.validate_dims("data initialization","N","int", + context__.to_vec()); + + current_statement__ = 181; + N = context__.vals_i("N")[(1 - 1)]; + context__.validate_dims("data initialization","M","int", + context__.to_vec()); + + current_statement__ = 182; + M = context__.vals_i("M")[(1 - 1)]; + context__.validate_dims("data initialization","K","int", + context__.to_vec()); + + current_statement__ = 183; + K = context__.vals_i("K")[(1 - 1)]; + current_statement__ = 184; + validate_non_negative_index("d_int_1d_ar", "N", N); + context__.validate_dims("data initialization","d_int_1d_ar","int", + context__.to_vec(N)); + d_int_1d_ar = std::vector(N, 0); + + current_statement__ = 184; + assign(d_int_1d_ar, nil_index_list(), context__.vals_i("d_int_1d_ar"), + "assigning variable d_int_1d_ar"); + current_statement__ = 185; + validate_non_negative_index("d_int_3d_ar", "N", N); + current_statement__ = 185; + validate_non_negative_index("d_int_3d_ar", "M", M); + current_statement__ = 185; + validate_non_negative_index("d_int_3d_ar", "K", K); + context__.validate_dims("data initialization","d_int_3d_ar","int", + context__.to_vec(N, M, K)); + d_int_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + { + std::vector d_int_3d_ar_flat__; + current_statement__ = 185; + assign(d_int_3d_ar_flat__, nil_index_list(), + context__.vals_i("d_int_3d_ar"), + "assigning variable d_int_3d_ar_flat__"); + current_statement__ = 185; + pos__ = 1; + current_statement__ = 185; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 185; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 185; + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + current_statement__ = 185; + assign(d_int_3d_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + d_int_3d_ar_flat__[(pos__ - 1)], + "assigning variable d_int_3d_ar"); + current_statement__ = 185; + pos__ = (pos__ + 1);}}} + } + context__.validate_dims("data initialization","J","double", + context__.to_vec()); + + current_statement__ = 186; + J = context__.vals_r("J")[(1 - 1)]; + current_statement__ = 187; + validate_non_negative_index("d_real_1d_ar", "N", N); + context__.validate_dims("data initialization","d_real_1d_ar","double", + context__.to_vec(N)); + d_real_1d_ar = std::vector(N, 0); + + current_statement__ = 187; + assign(d_real_1d_ar, nil_index_list(), + context__.vals_r("d_real_1d_ar"), "assigning variable d_real_1d_ar"); + current_statement__ = 188; + validate_non_negative_index("d_real_3d_ar", "N", N); + current_statement__ = 188; + validate_non_negative_index("d_real_3d_ar", "M", M); + current_statement__ = 188; + validate_non_negative_index("d_real_3d_ar", "K", K); + context__.validate_dims("data initialization","d_real_3d_ar","double", + context__.to_vec(N, M, K)); + d_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + { + std::vector d_real_3d_ar_flat__; + current_statement__ = 188; + assign(d_real_3d_ar_flat__, nil_index_list(), + context__.vals_r("d_real_3d_ar"), + "assigning variable d_real_3d_ar_flat__"); + current_statement__ = 188; + pos__ = 1; + current_statement__ = 188; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 188; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 188; + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + current_statement__ = 188; + assign(d_real_3d_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + d_real_3d_ar_flat__[(pos__ - 1)], + "assigning variable d_real_3d_ar"); + current_statement__ = 188; + pos__ = (pos__ + 1);}}} + } + current_statement__ = 189; + validate_non_negative_index("d_vec", "N", N); + context__.validate_dims("data initialization","d_vec","double", + context__.to_vec(N)); + d_vec = Eigen::Matrix(N); + + { + std::vector d_vec_flat__; + current_statement__ = 189; + assign(d_vec_flat__, nil_index_list(), context__.vals_r("d_vec"), + "assigning variable d_vec_flat__"); + current_statement__ = 189; + pos__ = 1; + current_statement__ = 189; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 189; + assign(d_vec, cons_list(index_uni(sym1__), nil_index_list()), + d_vec_flat__[(pos__ - 1)], "assigning variable d_vec"); + current_statement__ = 189; + pos__ = (pos__ + 1);} + } + current_statement__ = 190; + validate_non_negative_index("d_1d_vec", "N", N); + current_statement__ = 190; + validate_non_negative_index("d_1d_vec", "N", N); + context__.validate_dims("data initialization","d_1d_vec","double", + context__.to_vec(N, N)); + d_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + { + std::vector d_1d_vec_flat__; + current_statement__ = 190; + assign(d_1d_vec_flat__, nil_index_list(), + context__.vals_r("d_1d_vec"), "assigning variable d_1d_vec_flat__"); + current_statement__ = 190; + pos__ = 1; + current_statement__ = 190; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 190; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 190; + assign(d_1d_vec, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + d_1d_vec_flat__[(pos__ - 1)], "assigning variable d_1d_vec"); + current_statement__ = 190; + pos__ = (pos__ + 1);}} + } + current_statement__ = 191; + validate_non_negative_index("d_3d_vec", "N", N); + current_statement__ = 191; + validate_non_negative_index("d_3d_vec", "M", M); + current_statement__ = 191; + validate_non_negative_index("d_3d_vec", "K", K); + current_statement__ = 191; + validate_non_negative_index("d_3d_vec", "N", N); + context__.validate_dims("data initialization","d_3d_vec","double", + context__.to_vec(N, M, K, N)); + d_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + { + std::vector d_3d_vec_flat__; + current_statement__ = 191; + assign(d_3d_vec_flat__, nil_index_list(), + context__.vals_r("d_3d_vec"), "assigning variable d_3d_vec_flat__"); + current_statement__ = 191; + pos__ = 1; + current_statement__ = 191; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 191; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 191; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 191; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 191; + assign(d_3d_vec, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + d_3d_vec_flat__[(pos__ - 1)], "assigning variable d_3d_vec"); + current_statement__ = 191; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 192; + validate_non_negative_index("d_row_vec", "N", N); + context__.validate_dims("data initialization","d_row_vec","double", + context__.to_vec(N)); + d_row_vec = Eigen::Matrix(N); + + { + std::vector d_row_vec_flat__; + current_statement__ = 192; + assign(d_row_vec_flat__, nil_index_list(), + context__.vals_r("d_row_vec"), + "assigning variable d_row_vec_flat__"); + current_statement__ = 192; + pos__ = 1; + current_statement__ = 192; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 192; + assign(d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + d_row_vec_flat__[(pos__ - 1)], "assigning variable d_row_vec"); + current_statement__ = 192; + pos__ = (pos__ + 1);} + } + current_statement__ = 193; + validate_non_negative_index("d_1d_row_vec", "N", N); + current_statement__ = 193; + validate_non_negative_index("d_1d_row_vec", "N", N); + context__.validate_dims("data initialization","d_1d_row_vec","double", + context__.to_vec(N, N)); + d_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + { + std::vector d_1d_row_vec_flat__; + current_statement__ = 193; + assign(d_1d_row_vec_flat__, nil_index_list(), + context__.vals_r("d_1d_row_vec"), + "assigning variable d_1d_row_vec_flat__"); + current_statement__ = 193; + pos__ = 1; + current_statement__ = 193; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 193; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 193; + assign(d_1d_row_vec, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + d_1d_row_vec_flat__[(pos__ - 1)], + "assigning variable d_1d_row_vec"); + current_statement__ = 193; + pos__ = (pos__ + 1);}} + } + current_statement__ = 194; + validate_non_negative_index("d_3d_row_vec", "N", N); + current_statement__ = 194; + validate_non_negative_index("d_3d_row_vec", "M", M); + current_statement__ = 194; + validate_non_negative_index("d_3d_row_vec", "K", K); + current_statement__ = 194; + validate_non_negative_index("d_3d_row_vec", "N", N); + context__.validate_dims("data initialization","d_3d_row_vec","double", + context__.to_vec(N, M, K, N)); + d_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + { + std::vector d_3d_row_vec_flat__; + current_statement__ = 194; + assign(d_3d_row_vec_flat__, nil_index_list(), + context__.vals_r("d_3d_row_vec"), + "assigning variable d_3d_row_vec_flat__"); + current_statement__ = 194; + pos__ = 1; + current_statement__ = 194; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 194; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 194; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 194; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 194; + assign(d_3d_row_vec, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + d_3d_row_vec_flat__[(pos__ - 1)], + "assigning variable d_3d_row_vec"); + current_statement__ = 194; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 195; + validate_non_negative_index("d_ar_mat", "4", 4); + current_statement__ = 195; + validate_non_negative_index("d_ar_mat", "5", 5); + current_statement__ = 195; + validate_non_negative_index("d_ar_mat", "2", 2); + current_statement__ = 195; + validate_non_negative_index("d_ar_mat", "3", 3); + context__.validate_dims("data initialization","d_ar_mat","double", + context__.to_vec(4, 5, 2, 3)); + d_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + { + std::vector d_ar_mat_flat__; + current_statement__ = 195; + assign(d_ar_mat_flat__, nil_index_list(), + context__.vals_r("d_ar_mat"), "assigning variable d_ar_mat_flat__"); + current_statement__ = 195; + pos__ = 1; + current_statement__ = 195; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 195; + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + current_statement__ = 195; + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + current_statement__ = 195; + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + current_statement__ = 195; + assign(d_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + d_ar_mat_flat__[(pos__ - 1)], "assigning variable d_ar_mat"); + current_statement__ = 195; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 196; + validate_non_negative_index("d_simplex", "N", N); + context__.validate_dims("data initialization","d_simplex","double", + context__.to_vec(N)); + d_simplex = Eigen::Matrix(N); + + { + std::vector d_simplex_flat__; + current_statement__ = 196; + assign(d_simplex_flat__, nil_index_list(), + context__.vals_r("d_simplex"), + "assigning variable d_simplex_flat__"); + current_statement__ = 196; + pos__ = 1; + current_statement__ = 196; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 196; + assign(d_simplex, cons_list(index_uni(sym1__), nil_index_list()), + d_simplex_flat__[(pos__ - 1)], "assigning variable d_simplex"); + current_statement__ = 196; + pos__ = (pos__ + 1);} + } + current_statement__ = 197; + validate_non_negative_index("d_1d_simplex", "N", N); + current_statement__ = 197; + validate_non_negative_index("d_1d_simplex", "N", N); + context__.validate_dims("data initialization","d_1d_simplex","double", + context__.to_vec(N, N)); + d_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + { + std::vector d_1d_simplex_flat__; + current_statement__ = 197; + assign(d_1d_simplex_flat__, nil_index_list(), + context__.vals_r("d_1d_simplex"), + "assigning variable d_1d_simplex_flat__"); + current_statement__ = 197; + pos__ = 1; + current_statement__ = 197; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 197; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 197; + assign(d_1d_simplex, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + d_1d_simplex_flat__[(pos__ - 1)], + "assigning variable d_1d_simplex"); + current_statement__ = 197; + pos__ = (pos__ + 1);}} + } + current_statement__ = 198; + validate_non_negative_index("d_3d_simplex", "N", N); + current_statement__ = 198; + validate_non_negative_index("d_3d_simplex", "M", M); + current_statement__ = 198; + validate_non_negative_index("d_3d_simplex", "K", K); + current_statement__ = 198; + validate_non_negative_index("d_3d_simplex", "N", N); + context__.validate_dims("data initialization","d_3d_simplex","double", + context__.to_vec(N, M, K, N)); + d_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + { + std::vector d_3d_simplex_flat__; + current_statement__ = 198; + assign(d_3d_simplex_flat__, nil_index_list(), + context__.vals_r("d_3d_simplex"), + "assigning variable d_3d_simplex_flat__"); + current_statement__ = 198; + pos__ = 1; + current_statement__ = 198; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 198; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 198; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 198; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 198; + assign(d_3d_simplex, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + d_3d_simplex_flat__[(pos__ - 1)], + "assigning variable d_3d_simplex"); + current_statement__ = 198; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 199; + validate_non_negative_index("d_cfcov_54", "5", 5); + current_statement__ = 199; + validate_non_negative_index("d_cfcov_54", "4", 4); + context__.validate_dims("data initialization","d_cfcov_54","double", + context__.to_vec(5, 4)); + d_cfcov_54 = Eigen::Matrix(5, 4); + + { + std::vector d_cfcov_54_flat__; + current_statement__ = 199; + assign(d_cfcov_54_flat__, nil_index_list(), + context__.vals_r("d_cfcov_54"), + "assigning variable d_cfcov_54_flat__"); + current_statement__ = 199; + pos__ = 1; + current_statement__ = 199; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 199; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 199; + assign(d_cfcov_54, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + d_cfcov_54_flat__[(pos__ - 1)], "assigning variable d_cfcov_54"); + current_statement__ = 199; + pos__ = (pos__ + 1);}} + } + current_statement__ = 200; + validate_non_negative_index("d_cfcov_33", "3", 3); + current_statement__ = 200; + validate_non_negative_index("d_cfcov_33", "3", 3); + context__.validate_dims("data initialization","d_cfcov_33","double", + context__.to_vec(3, 3)); + d_cfcov_33 = Eigen::Matrix(3, 3); + + { + std::vector d_cfcov_33_flat__; + current_statement__ = 200; + assign(d_cfcov_33_flat__, nil_index_list(), + context__.vals_r("d_cfcov_33"), + "assigning variable d_cfcov_33_flat__"); + current_statement__ = 200; + pos__ = 1; + current_statement__ = 200; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 200; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 200; + assign(d_cfcov_33, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + d_cfcov_33_flat__[(pos__ - 1)], "assigning variable d_cfcov_33"); + current_statement__ = 200; + pos__ = (pos__ + 1);}} + } + current_statement__ = 201; + validate_non_negative_index("d_cfcov_33_ar", "K", K); + current_statement__ = 201; + validate_non_negative_index("d_cfcov_33_ar", "3", 3); + current_statement__ = 201; + validate_non_negative_index("d_cfcov_33_ar", "3", 3); + context__.validate_dims("data initialization","d_cfcov_33_ar","double", + context__.to_vec(K, 3, 3)); + d_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + { + std::vector d_cfcov_33_ar_flat__; + current_statement__ = 201; + assign(d_cfcov_33_ar_flat__, nil_index_list(), + context__.vals_r("d_cfcov_33_ar"), + "assigning variable d_cfcov_33_ar_flat__"); + current_statement__ = 201; + pos__ = 1; + current_statement__ = 201; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 201; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 201; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 201; + assign(d_cfcov_33_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + d_cfcov_33_ar_flat__[(pos__ - 1)], + "assigning variable d_cfcov_33_ar"); + current_statement__ = 201; + pos__ = (pos__ + 1);}}} + } + + current_statement__ = 203; + validate_non_negative_index("td_1d", "N", N); + td_1d = std::vector(N, 0); + + current_statement__ = 204; + validate_non_negative_index("td_1dk", "M", M); + td_1dk = std::vector(M, 0); + + current_statement__ = 204; + assign(td_1dk, nil_index_list(), rep_array(1, M), + "assigning variable td_1dk"); + + current_statement__ = 205; + td_a = N; + + current_statement__ = 206; + td_b = std::numeric_limits::quiet_NaN(); + current_statement__ = 206; + td_b = (N * J); + + current_statement__ = 207; + td_c = std::numeric_limits::quiet_NaN(); + current_statement__ = 207; + td_c = foo_bar1(td_b, pstream__); + current_statement__ = 208; + validate_non_negative_index("td_ar_mat", "4", 4); + current_statement__ = 208; + validate_non_negative_index("td_ar_mat", "5", 5); + current_statement__ = 208; + validate_non_negative_index("td_ar_mat", "2", 2); + current_statement__ = 208; + validate_non_negative_index("td_ar_mat", "3", 3); + td_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 208; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 208; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 208; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 208; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 208; + assign(td_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable td_ar_mat");}}}} + current_statement__ = 209; + validate_non_negative_index("td_simplex", "N", N); + td_simplex = Eigen::Matrix(N); + + current_statement__ = 209; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 209; + assign(td_simplex, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable td_simplex");} + current_statement__ = 210; + validate_non_negative_index("td_1d_simplex", "N", N); + current_statement__ = 210; + validate_non_negative_index("td_1d_simplex", "N", N); + td_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 210; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 210; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 210; + assign(td_1d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable td_1d_simplex");}} + current_statement__ = 211; + validate_non_negative_index("td_3d_simplex", "N", N); + current_statement__ = 211; + validate_non_negative_index("td_3d_simplex", "M", M); + current_statement__ = 211; + validate_non_negative_index("td_3d_simplex", "K", K); + current_statement__ = 211; + validate_non_negative_index("td_3d_simplex", "N", N); + td_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 211; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 211; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 211; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 211; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 211; + assign(td_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable td_3d_simplex");}}}} + current_statement__ = 212; + validate_non_negative_index("td_cfcov_54", "5", 5); + current_statement__ = 212; + validate_non_negative_index("td_cfcov_54", "5", 5); + td_cfcov_54 = Eigen::Matrix(5, 5); + + current_statement__ = 212; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 212; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 212; + assign(td_cfcov_54, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable td_cfcov_54");}} + current_statement__ = 213; + validate_non_negative_index("td_cfcov_33", "3", 3); + current_statement__ = 213; + validate_non_negative_index("td_cfcov_33", "3", 3); + td_cfcov_33 = Eigen::Matrix(3, 3); + + current_statement__ = 213; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 213; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 213; + assign(td_cfcov_33, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable td_cfcov_33");}} + current_statement__ = 214; + validate_non_negative_index("x", "2", 2); + x = Eigen::Matrix(2); + + current_statement__ = 214; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 214; + assign(x, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable x");} + current_statement__ = 215; + validate_non_negative_index("y", "2", 2); + y = Eigen::Matrix(2); + + current_statement__ = 215; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 215; + assign(y, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable y");} + current_statement__ = 216; + validate_non_negative_index("dat", "0", 0); + dat = std::vector(0, 0); + + current_statement__ = 217; + validate_non_negative_index("dat_int", "0", 0); + dat_int = std::vector(0, 0); + + current_statement__ = 218; + validate_non_negative_index("x_r", "0", 0); + current_statement__ = 218; + validate_non_negative_index("x_r", "0", 0); + x_r = std::vector>(0, std::vector(0, 0)); + + current_statement__ = 219; + validate_non_negative_index("x_i", "0", 0); + current_statement__ = 219; + validate_non_negative_index("x_i", "0", 0); + x_i = std::vector>(0, std::vector(0, 0)); + + current_statement__ = 220; + td_int = (primitive_value(1) || primitive_value(2)); + current_statement__ = 221; + td_int = (primitive_value(1) && primitive_value(2)); + current_statement__ = 230; + for (size_t i = 1; i <= 2; ++i) { + current_statement__ = 228; + for (size_t j = 1; j <= 3; ++j) { + current_statement__ = 226; + for (size_t m = 1; m <= 4; ++m) { + current_statement__ = 224; + for (size_t n = 1; n <= 5; ++n) { + current_statement__ = 222; + assign(td_ar_mat, + cons_list(index_uni(m), + cons_list(index_uni(n), + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())))), 0.4, + "assigning variable td_ar_mat");}}}} + current_statement__ = 241; + for (size_t i = 1; i <= N; ++i) { + current_statement__ = 231; + assign(td_simplex, cons_list(index_uni(i), nil_index_list()), + (1.0 / N), "assigning variable td_simplex"); + current_statement__ = 239; + for (size_t n = 1; n <= N; ++n) { + current_statement__ = 232; + assign(td_1d_simplex, + cons_list(index_uni(n), + cons_list(index_uni(i), nil_index_list())), (1.0 / N), + "assigning variable td_1d_simplex"); + current_statement__ = 237; + for (size_t m = 1; m <= M; ++m) { + current_statement__ = 235; + for (size_t k = 1; k <= K; ++k) { + current_statement__ = 233; + assign(td_3d_simplex, + cons_list(index_uni(n), + cons_list(index_uni(m), + cons_list(index_uni(k), + cons_list(index_uni(i), nil_index_list())))), + (1.0 / N), "assigning variable td_3d_simplex");}}}} + current_statement__ = 247; + for (size_t i = 1; i <= 4; ++i) { + current_statement__ = 245; + for (size_t j = 1; j <= 5; ++j) { + current_statement__ = 242; + validate_non_negative_index("l_mat", "2", 2); + current_statement__ = 242; + validate_non_negative_index("l_mat", "3", 3); + Eigen::Matrix l_mat; + l_mat = Eigen::Matrix(2, 3); + + current_statement__ = 242; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 242; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 242; + assign(l_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable l_mat");}} + current_statement__ = 242; + assign(l_mat, nil_index_list(), d_ar_mat[(i - 1)][(j - 1)], + "assigning variable l_mat"); + current_statement__ = 243; + if (pstream__) { + stan_print(pstream__, "ar dim1: "); + stan_print(pstream__, i); + stan_print(pstream__, " ar dim2: "); + stan_print(pstream__, j); + stan_print(pstream__, " matrix: "); + stan_print(pstream__, l_mat); + stan_print(pstream__, "\n"); + }}} + current_statement__ = 248; + assign(td_cfcov_54, nil_index_list(), + diag_matrix(rep_vector(1, rows(td_cfcov_54))), + "assigning variable td_cfcov_54"); + current_statement__ = 249; + assign(td_cfcov_33, nil_index_list(), + diag_matrix(rep_vector(1, rows(td_cfcov_33))), + "assigning variable td_cfcov_33"); + { + double z; + + current_statement__ = 250; + z = std::numeric_limits::quiet_NaN(); + current_statement__ = 251; + validate_non_negative_index("blocked_tdata_vs", "2", 2); + Eigen::Matrix blocked_tdata_vs; + blocked_tdata_vs = Eigen::Matrix(2); + + current_statement__ = 251; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 251; + assign(blocked_tdata_vs, + cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable blocked_tdata_vs");} + current_statement__ = 252; + for (size_t sym1__ = 1; sym1__ <= stan::math::size(blocked_tdata_vs); + ++sym1__) { + { + double v; + current_statement__ = 252; + v = blocked_tdata_vs[(sym1__ - 1)]; + current_statement__ = 253; + z = 0; + }} + current_statement__ = 254; + validate_non_negative_index("indices", "4", 4); + std::vector indices; + indices = std::vector(4, 0); + + current_statement__ = 254; + assign(indices, nil_index_list(), stan::math::array_builder() + .add(1).add(2).add(3).add(4).array(), "assigning variable indices"); + { + std::vector sym1__; + current_statement__ = 255; + assign(sym1__, nil_index_list(), + rvalue(indices, cons_list(index_min_max(1, 3), nil_index_list()), + "indices"), "assigning variable sym1__"); + current_statement__ = 255; + for (size_t sym2__ = 1; sym2__ <= stan::math::size(sym1__); + ++sym2__) { + { + int i; + current_statement__ = 255; + i = sym1__[(sym2__ - 1)]; + current_statement__ = 256; + z = i; + }} + } + } + current_statement__ = 258; + assign(td_1dk, nil_index_list(), + rvalue(td_1d, + cons_list(index_multi(stan::model::deep_copy(td_1dk)), + nil_index_list()), "td_1d"), "assigning variable td_1dk"); + current_statement__ = 259; + assign(td_simplex, nil_index_list(), + rvalue(td_1d_simplex, + cons_list(index_uni(1), cons_list(index_omni(), nil_index_list())), + "td_1d_simplex"), "assigning variable td_simplex"); + current_statement__ = 260; + assign(td_simplex, nil_index_list(), + rvalue(td_1d_simplex, + cons_list(index_uni(1), cons_list(index_omni(), nil_index_list())), + "td_1d_simplex"), "assigning variable td_simplex"); + current_statement__ = 261; + assign(td_simplex, nil_index_list(), + rvalue(td_1d_simplex, + cons_list(index_uni(1), + cons_list(index_min_max(1, N), nil_index_list())), + "td_1d_simplex"), "assigning variable td_simplex"); + current_statement__ = 262; + validate_non_negative_index("arr_mul_ind", "2", 2); + current_statement__ = 262; + validate_non_negative_index("arr_mul_ind", "2", 2); + arr_mul_ind = std::vector>(2, std::vector(2, 0)); + + current_statement__ = 263; + assign(arr_mul_ind, + cons_list(index_uni(1), + cons_list(index_min_max(1, 2), nil_index_list())), + stan::math::array_builder().add(1).add(1).array(), + "assigning variable arr_mul_ind"); + current_statement__ = 264; + validate_non_negative_index("x_mul_ind", "2", 2); + x_mul_ind = std::vector(2, 0); + + current_statement__ = 264; + assign(x_mul_ind, nil_index_list(), stan::math::array_builder() + .add(1).add(2).array(), "assigning variable x_mul_ind"); + current_statement__ = 181; + current_statement__ = 181; + check_greater_or_equal(function__, "N", N, 0); + current_statement__ = 182; + current_statement__ = 182; + check_greater_or_equal(function__, "M", M, 0); + current_statement__ = 183; + current_statement__ = 183; + check_greater_or_equal(function__, "K", K, 0); + current_statement__ = 183; + current_statement__ = 183; + check_less_or_equal(function__, "K", K, (N * M)); + current_statement__ = 184; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 184; + current_statement__ = 184; + check_less_or_equal(function__, "d_int_1d_ar[sym1__]", + d_int_1d_ar[(sym1__ - 1)], N);} + current_statement__ = 185; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 185; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 185; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 185; + current_statement__ = 185; + check_less_or_equal(function__, + "d_int_3d_ar[sym1__, sym2__, sym3__]", + d_int_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ + (sym3__ - 1)], N);}}} + current_statement__ = 186; + current_statement__ = 186; + check_greater_or_equal(function__, "J", J, -2.0); + current_statement__ = 186; + current_statement__ = 186; + check_less_or_equal(function__, "J", J, 2.0); + current_statement__ = 195; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 195; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 195; + current_statement__ = 195; + check_greater_or_equal(function__, "d_ar_mat[sym1__, sym2__]", + d_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} + current_statement__ = 195; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 195; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 195; + current_statement__ = 195; + check_less_or_equal(function__, "d_ar_mat[sym1__, sym2__]", + d_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} + current_statement__ = 196; + current_statement__ = 196; + check_simplex(function__, "d_simplex", d_simplex); + current_statement__ = 197; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 197; + current_statement__ = 197; + check_simplex(function__, "d_1d_simplex[sym1__]", + d_1d_simplex[(sym1__ - 1)]);} + current_statement__ = 198; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 198; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 198; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 198; + current_statement__ = 198; + check_simplex(function__, "d_3d_simplex[sym1__, sym2__, sym3__]", + d_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - + 1)]);}}} + current_statement__ = 199; + current_statement__ = 199; + check_cholesky_factor(function__, "d_cfcov_54", d_cfcov_54); + current_statement__ = 200; + current_statement__ = 200; + check_cholesky_factor(function__, "d_cfcov_33", d_cfcov_33); + current_statement__ = 201; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 201; + current_statement__ = 201; + check_cholesky_factor(function__, "d_cfcov_33_ar[sym1__]", + d_cfcov_33_ar[(sym1__ - 1)]);} + current_statement__ = 208; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 208; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 208; + current_statement__ = 208; + check_greater_or_equal(function__, "td_ar_mat[sym1__, sym2__]", + td_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} + current_statement__ = 208; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 208; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 208; + current_statement__ = 208; + check_less_or_equal(function__, "td_ar_mat[sym1__, sym2__]", + td_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} + current_statement__ = 209; + current_statement__ = 209; + check_simplex(function__, "td_simplex", td_simplex); + current_statement__ = 210; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 210; + current_statement__ = 210; + check_simplex(function__, "td_1d_simplex[sym1__]", + td_1d_simplex[(sym1__ - 1)]);} + current_statement__ = 211; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 211; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 211; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 211; + current_statement__ = 211; + check_simplex(function__, + "td_3d_simplex[sym1__, sym2__, sym3__]", + td_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - + 1)]);}}} + current_statement__ = 212; + current_statement__ = 212; + check_cholesky_factor(function__, "td_cfcov_54", td_cfcov_54); + current_statement__ = 213; + current_statement__ = 213; + check_cholesky_factor(function__, "td_cfcov_33", td_cfcov_33); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + num_params_r__ += 1; + current_statement__ = 2; + validate_non_negative_index("offset_multiplier", "5", 5); + num_params_r__ += 5; + current_statement__ = 3; + validate_non_negative_index("no_offset_multiplier", "5", 5); + num_params_r__ += 5; + current_statement__ = 4; + validate_non_negative_index("offset_no_multiplier", "5", 5); + num_params_r__ += 5; + current_statement__ = 5; + validate_non_negative_index("p_real_1d_ar", "N", N); + num_params_r__ += N; + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "N", N); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "M", M); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "K", K); + num_params_r__ += N * M * K; + current_statement__ = 7; + validate_non_negative_index("p_vec", "N", N); + num_params_r__ += N; + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + num_params_r__ += N * N; + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "M", M); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "K", K); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + num_params_r__ += N * M * K * N; + current_statement__ = 10; + validate_non_negative_index("p_row_vec", "N", N); + num_params_r__ += N; + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + num_params_r__ += N * N; + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "M", M); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "K", K); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + num_params_r__ += N * M * K * N; + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "4", 4); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "5", 5); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "2", 2); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "3", 3); + num_params_r__ += 4 * 5 * 2 * 3; + current_statement__ = 14; + validate_positive_index("p_simplex", "N", N); + num_params_r__ += (N - 1); + current_statement__ = 15; + validate_non_negative_index("p_1d_simplex", "N", N); + current_statement__ = 15; + validate_positive_index("p_1d_simplex", "N", N); + num_params_r__ += N * (N - 1); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "N", N); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "M", M); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "K", K); + current_statement__ = 16; + validate_positive_index("p_3d_simplex", "N", N); + num_params_r__ += N * M * K * (N - 1); + current_statement__ = 17; + check_greater_or_equal("cholesky_factor_cov p_cfcov_54", + "num rows (must be greater or equal to num cols)", + 5, 4); + current_statement__ = 17; + validate_non_negative_index("p_cfcov_54", "4", 4); + num_params_r__ += ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); + current_statement__ = 18; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 18; + validate_non_negative_index("p_cfcov_33", "3", 3); + num_params_r__ += ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "K", K); + current_statement__ = 19; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "3", 3); + num_params_r__ += K * ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); + current_statement__ = 20; + validate_non_negative_index("x_p", "2", 2); + num_params_r__ += 2; + current_statement__ = 21; + validate_non_negative_index("y_p", "2", 2); + num_params_r__ += 2; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } } - -} - -struct foo_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) const -{ -return foo(shared_params, job_params, data_r, data_i, pstream__); -} -}; + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "mother_model_namespace::log_prob"; +(void) function__; // suppress unused var warning -template -typename boost::math::tools::promote_args::type -map_rectfake(const T0__& x, std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 121; - return (2 * x); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); + stan::io::reader in__(params_r__, params_i__); + + try { + local_scalar_t__ p_real; + + current_statement__ = 1; + p_real = in__.scalar(); + current_statement__ = 2; + validate_non_negative_index("offset_multiplier", "5", 5); + std::vector offset_multiplier; + offset_multiplier = std::vector(5, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable offset_multiplier");} + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 2; + if (jacobian__) { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_multiplier[(sym1__ - 1)], 1, 2, lp__), + "assigning variable offset_multiplier"); + } else { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_multiplier[(sym1__ - 1)], 1, 2), + "assigning variable offset_multiplier"); + }} + current_statement__ = 3; + validate_non_negative_index("no_offset_multiplier", "5", 5); + std::vector no_offset_multiplier; + no_offset_multiplier = std::vector(5, 0); + + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable no_offset_multiplier");} + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 3; + if (jacobian__) { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + no_offset_multiplier[(sym1__ - 1)], 0, 2, lp__), + "assigning variable no_offset_multiplier"); + } else { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + no_offset_multiplier[(sym1__ - 1)], 0, 2), + "assigning variable no_offset_multiplier"); + }} + current_statement__ = 4; + validate_non_negative_index("offset_no_multiplier", "5", 5); + std::vector offset_no_multiplier; + offset_no_multiplier = std::vector(5, 0); + + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable offset_no_multiplier");} + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 4; + if (jacobian__) { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_no_multiplier[(sym1__ - 1)], 3, 1, lp__), + "assigning variable offset_no_multiplier"); + } else { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_no_multiplier[(sym1__ - 1)], 3, 1), + "assigning variable offset_no_multiplier"); + }} + current_statement__ = 5; + validate_non_negative_index("p_real_1d_ar", "N", N); + std::vector p_real_1d_ar; + p_real_1d_ar = std::vector(N, 0); + + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 5; + assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable p_real_1d_ar");} + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 5; + if (jacobian__) { + current_statement__ = 5; + assign(p_real_1d_ar, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0, lp__), + "assigning variable p_real_1d_ar"); + } else { + current_statement__ = 5; + assign(p_real_1d_ar, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0), + "assigning variable p_real_1d_ar"); + }} + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "N", N); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "M", M); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "K", K); + std::vector>> p_real_3d_ar; + p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.scalar(), "assigning variable p_real_3d_ar");}}} + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 6; + if (jacobian__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::lb_constrain( + p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0, + lp__), "assigning variable p_real_3d_ar"); + } else { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::lb_constrain( + p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), + "assigning variable p_real_3d_ar"); + }}}} + current_statement__ = 7; + validate_non_negative_index("p_vec", "N", N); + Eigen::Matrix p_vec; + p_vec = Eigen::Matrix(N); + + current_statement__ = 7; + p_vec = in__.vector(N); + current_statement__ = 7; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 7; + if (jacobian__) { + current_statement__ = 7; + assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0, lp__), + "assigning variable p_vec"); + } else { + current_statement__ = 7; + assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0), + "assigning variable p_vec"); + }} + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + std::vector> p_1d_vec; + p_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 8; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 8; + assign(p_1d_vec, cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(N), "assigning variable p_1d_vec");} + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "M", M); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "K", K); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + std::vector>>> p_3d_vec; + p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 9; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 9; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 9; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 9; + assign(p_3d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.vector(N), "assigning variable p_3d_vec");}}} + current_statement__ = 10; + validate_non_negative_index("p_row_vec", "N", N); + Eigen::Matrix p_row_vec; + p_row_vec = Eigen::Matrix(N); + + current_statement__ = 10; + p_row_vec = in__.row_vector(N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + std::vector> p_1d_row_vec; + p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 11; + assign(p_1d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + in__.row_vector(N), "assigning variable p_1d_row_vec");} + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "M", M); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "K", K); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + std::vector>>> p_3d_row_vec; + p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 12; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 12; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 12; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 12; + assign(p_3d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.row_vector(N), "assigning variable p_3d_row_vec");}}} + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "4", 4); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "5", 5); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "2", 2); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "3", 3); + std::vector>> p_ar_mat; + p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + in__.matrix(2, 3), "assigning variable p_ar_mat");}} + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 13; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 13; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 13; + if (jacobian__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + stan::math::lub_constrain( + rvalue(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + "p_ar_mat"), 0, 1, lp__), "assigning variable p_ar_mat"); + } else { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + stan::math::lub_constrain( + rvalue(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + "p_ar_mat"), 0, 1), "assigning variable p_ar_mat"); + }}}}} + current_statement__ = 14; + validate_positive_index("p_simplex", "N", N); + Eigen::Matrix p_simplex; + p_simplex = Eigen::Matrix(N); + + Eigen::Matrix p_simplex_in__; + p_simplex_in__ = Eigen::Matrix((N - 1)); + + current_statement__ = 14; + p_simplex_in__ = in__.vector((N - 1)); + current_statement__ = 14; + if (jacobian__) { + current_statement__ = 14; + assign(p_simplex, nil_index_list(), + stan::math::simplex_constrain(p_simplex_in__, lp__), + "assigning variable p_simplex"); + } else { + current_statement__ = 14; + assign(p_simplex, nil_index_list(), + stan::math::simplex_constrain(p_simplex_in__), + "assigning variable p_simplex"); + } + current_statement__ = 15; + validate_non_negative_index("p_1d_simplex", "N", N); + current_statement__ = 15; + validate_positive_index("p_1d_simplex", "N", N); + std::vector> p_1d_simplex; + p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + std::vector> p_1d_simplex_in__; + p_1d_simplex_in__ = std::vector>(N, Eigen::Matrix( + (N - 1))); + + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + assign(p_1d_simplex_in__, + cons_list(index_uni(sym1__), nil_index_list()), + in__.vector((N - 1)), "assigning variable p_1d_simplex_in__");} + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + if (jacobian__) { + current_statement__ = 15; + assign(p_1d_simplex, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)], + lp__), "assigning variable p_1d_simplex"); + } else { + current_statement__ = 15; + assign(p_1d_simplex, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)]), + "assigning variable p_1d_simplex"); + }} + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "N", N); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "M", M); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "K", K); + current_statement__ = 16; + validate_positive_index("p_3d_simplex", "N", N); + std::vector>>> p_3d_simplex; + p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + std::vector>>> p_3d_simplex_in__; + p_3d_simplex_in__ = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix( + (N - 1))))); + + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 16; + assign(p_3d_simplex_in__, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.vector((N - 1)), "assigning variable p_3d_simplex_in__");} + }} + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 16; + if (jacobian__) { + current_statement__ = 16; + assign(p_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::simplex_constrain( + p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], + lp__), "assigning variable p_3d_simplex"); + } else { + current_statement__ = 16; + assign(p_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::simplex_constrain( + p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), + "assigning variable p_3d_simplex"); + }}}} + current_statement__ = 17; + check_greater_or_equal("cholesky_factor_cov p_cfcov_54", + "num rows (must be greater or equal to num cols)", + 5, 4); + current_statement__ = 17; + validate_non_negative_index("p_cfcov_54", "4", 4); + Eigen::Matrix p_cfcov_54; + p_cfcov_54 = Eigen::Matrix(5, 4); + + Eigen::Matrix p_cfcov_54_in__; + p_cfcov_54_in__ = Eigen::Matrix(((((4 * + (4 - 1)) + / 2) + 4) + + + ((5 - 4) * + 4))); + + current_statement__ = 17; + p_cfcov_54_in__ = in__.vector( + ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); + current_statement__ = 17; + if (jacobian__) { + current_statement__ = 17; + assign(p_cfcov_54, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4, lp__), + "assigning variable p_cfcov_54"); + } else { + current_statement__ = 17; + assign(p_cfcov_54, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4), + "assigning variable p_cfcov_54"); + } + current_statement__ = 18; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 18; + validate_non_negative_index("p_cfcov_33", "3", 3); + Eigen::Matrix p_cfcov_33; + p_cfcov_33 = Eigen::Matrix(3, 3); + + Eigen::Matrix p_cfcov_33_in__; + p_cfcov_33_in__ = Eigen::Matrix(((((3 * + (3 - 1)) + / 2) + 3) + + + ((3 - 3) * + 3))); + + current_statement__ = 18; + p_cfcov_33_in__ = in__.vector( + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); + current_statement__ = 18; + if (jacobian__) { + current_statement__ = 18; + assign(p_cfcov_33, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3, lp__), + "assigning variable p_cfcov_33"); + } else { + current_statement__ = 18; + assign(p_cfcov_33, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3), + "assigning variable p_cfcov_33"); + } + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "K", K); + current_statement__ = 19; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "3", 3); + std::vector> p_cfcov_33_ar; + p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + std::vector> p_cfcov_33_ar_in__; + p_cfcov_33_ar_in__ = std::vector>(K, Eigen::Matrix( + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); + + current_statement__ = 19; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 19; + assign(p_cfcov_33_ar_in__, + cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))), + "assigning variable p_cfcov_33_ar_in__");} + current_statement__ = 19; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 19; + if (jacobian__) { + current_statement__ = 19; + assign(p_cfcov_33_ar, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::cholesky_factor_constrain( + p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3, lp__), + "assigning variable p_cfcov_33_ar"); + } else { + current_statement__ = 19; + assign(p_cfcov_33_ar, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::cholesky_factor_constrain( + p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3), + "assigning variable p_cfcov_33_ar"); + }} + current_statement__ = 20; + validate_non_negative_index("x_p", "2", 2); + Eigen::Matrix x_p; + x_p = Eigen::Matrix(2); + + current_statement__ = 20; + x_p = in__.vector(2); + current_statement__ = 21; + validate_non_negative_index("y_p", "2", 2); + Eigen::Matrix y_p; + y_p = Eigen::Matrix(2); + + current_statement__ = 21; + y_p = in__.vector(2); + current_statement__ = 22; + validate_non_negative_index("tp_real_1d_ar", "N", N); + std::vector tp_real_1d_ar; + tp_real_1d_ar = std::vector(N, 0); + + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "N", N); + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "M", M); + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "K", K); + std::vector>> tp_real_3d_ar; + tp_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + current_statement__ = 24; + validate_non_negative_index("tp_vec", "N", N); + Eigen::Matrix tp_vec; + tp_vec = Eigen::Matrix(N); + + current_statement__ = 24; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 24; + assign(tp_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_vec");} + current_statement__ = 25; + validate_non_negative_index("tp_1d_vec", "N", N); + current_statement__ = 25; + validate_non_negative_index("tp_1d_vec", "N", N); + std::vector> tp_1d_vec; + tp_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 25; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 25; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 25; + assign(tp_1d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_vec");}} + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "N", N); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "M", M); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "K", K); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "N", N); + std::vector>>> tp_3d_vec; + tp_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 26; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 26; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 26; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 26; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 26; + assign(tp_3d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_vec");}}}} + current_statement__ = 27; + validate_non_negative_index("tp_row_vec", "N", N); + Eigen::Matrix tp_row_vec; + tp_row_vec = Eigen::Matrix(N); + + current_statement__ = 27; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 27; + assign(tp_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_row_vec");} + current_statement__ = 28; + validate_non_negative_index("tp_1d_row_vec", "N", N); + current_statement__ = 28; + validate_non_negative_index("tp_1d_row_vec", "N", N); + std::vector> tp_1d_row_vec; + tp_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 28; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 28; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 28; + assign(tp_1d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_row_vec");}} + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "N", N); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "M", M); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "K", K); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "N", N); + std::vector>>> tp_3d_row_vec; + tp_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 29; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 29; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 29; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 29; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 29; + assign(tp_3d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_row_vec");}}}} + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "4", 4); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "5", 5); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "2", 2); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "3", 3); + std::vector>> tp_ar_mat; + tp_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 30; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 30; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 30; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 30; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 30; + assign(tp_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_ar_mat");}}}} + current_statement__ = 31; + validate_non_negative_index("tp_simplex", "N", N); + Eigen::Matrix tp_simplex; + tp_simplex = Eigen::Matrix(N); + + current_statement__ = 31; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 31; + assign(tp_simplex, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_simplex");} + current_statement__ = 32; + validate_non_negative_index("tp_1d_simplex", "N", N); + current_statement__ = 32; + validate_non_negative_index("tp_1d_simplex", "N", N); + std::vector> tp_1d_simplex; + tp_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 32; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 32; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 32; + assign(tp_1d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_simplex");}} + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "N", N); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "M", M); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "K", K); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "N", N); + std::vector>>> tp_3d_simplex; + tp_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 33; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 33; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 33; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 33; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 33; + assign(tp_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_simplex");}}}} + current_statement__ = 34; + validate_non_negative_index("tp_cfcov_54", "5", 5); + current_statement__ = 34; + validate_non_negative_index("tp_cfcov_54", "4", 4); + Eigen::Matrix tp_cfcov_54; + tp_cfcov_54 = Eigen::Matrix(5, 4); + + current_statement__ = 34; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 34; + for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { + current_statement__ = 34; + assign(tp_cfcov_54, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_54");}} + current_statement__ = 35; + validate_non_negative_index("tp_cfcov_33", "3", 3); + current_statement__ = 35; + validate_non_negative_index("tp_cfcov_33", "3", 3); + Eigen::Matrix tp_cfcov_33; + tp_cfcov_33 = Eigen::Matrix(3, 3); + + current_statement__ = 35; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 35; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 35; + assign(tp_cfcov_33, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_33");}} + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "K", K); + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "3", 3); + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "3", 3); + std::vector> tp_cfcov_33_ar; + tp_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + current_statement__ = 36; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 36; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 36; + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + current_statement__ = 36; + assign(tp_cfcov_33_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_33_ar");}}} + current_statement__ = 37; + validate_non_negative_index("theta_p", "2", 2); + Eigen::Matrix theta_p; + theta_p = Eigen::Matrix(2); + + current_statement__ = 37; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 37; + assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta_p");} + current_statement__ = 38; + assign(tp_real_1d_ar, nil_index_list(), p_real_1d_ar, + "assigning variable tp_real_1d_ar"); + current_statement__ = 39; + assign(tp_real_3d_ar, nil_index_list(), p_real_3d_ar, + "assigning variable tp_real_3d_ar"); + current_statement__ = 40; + assign(tp_1d_vec, nil_index_list(), p_1d_vec, + "assigning variable tp_1d_vec"); + current_statement__ = 41; + assign(tp_3d_vec, nil_index_list(), p_3d_vec, + "assigning variable tp_3d_vec"); + current_statement__ = 42; + assign(tp_simplex, nil_index_list(), p_simplex, + "assigning variable tp_simplex"); + current_statement__ = 43; + assign(tp_1d_simplex, nil_index_list(), p_1d_simplex, + "assigning variable tp_1d_simplex"); + current_statement__ = 44; + assign(tp_3d_simplex, nil_index_list(), p_3d_simplex, + "assigning variable tp_3d_simplex"); + current_statement__ = 45; + assign(tp_cfcov_54, nil_index_list(), p_cfcov_54, + "assigning variable tp_cfcov_54"); + current_statement__ = 46; + assign(tp_cfcov_33, nil_index_list(), p_cfcov_33, + "assigning variable tp_cfcov_33"); + current_statement__ = 47; + assign(tp_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, + "assigning variable tp_cfcov_33_ar"); + current_statement__ = 56; + for (size_t i = 1; i <= 2; ++i) { + current_statement__ = 54; + for (size_t j = 1; j <= 3; ++j) { + current_statement__ = 52; + for (size_t m = 1; m <= 4; ++m) { + current_statement__ = 50; + for (size_t n = 1; n <= 5; ++n) { + current_statement__ = 48; + assign(tp_ar_mat, + cons_list(index_uni(m), + cons_list(index_uni(n), + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())))), 0.4, + "assigning variable tp_ar_mat");}}}} + current_statement__ = 58; + for (size_t i = 1; i <= N; ++i) { + current_statement__ = 57; + assign(tp_vec, cons_list(index_uni(i), nil_index_list()), + (-1.0 * p_vec[(i - 1)]), "assigning variable tp_vec");} + current_statement__ = 59; + assign(tp_row_vec, nil_index_list(), transpose(tp_1d_vec[(1 - 1)]), + "assigning variable tp_row_vec"); + current_statement__ = 60; + assign(tp_1d_row_vec, nil_index_list(), p_1d_row_vec, + "assigning variable tp_1d_row_vec"); + current_statement__ = 61; + assign(tp_3d_row_vec, nil_index_list(), p_3d_row_vec, + "assigning variable tp_3d_row_vec"); + current_statement__ = 62; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 63; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 64; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y_p, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 65; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 66; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 67; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 68; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 22; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 22; + current_statement__ = 22; + check_greater_or_equal(function__, "tp_real_1d_ar[sym1__]", + tp_real_1d_ar[(sym1__ - 1)], 0);} + current_statement__ = 23; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 23; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 23; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 23; + current_statement__ = 23; + check_greater_or_equal(function__, + "tp_real_3d_ar[sym1__, sym2__, sym3__]", + tp_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ + (sym3__ - 1)], 0);}}} + current_statement__ = 24; + current_statement__ = 24; + check_less_or_equal(function__, "tp_vec", tp_vec, 0); + current_statement__ = 30; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 30; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 30; + current_statement__ = 30; + check_greater_or_equal(function__, "tp_ar_mat[sym1__, sym2__]", + tp_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} + current_statement__ = 30; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 30; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 30; + current_statement__ = 30; + check_less_or_equal(function__, "tp_ar_mat[sym1__, sym2__]", + tp_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} + current_statement__ = 31; + current_statement__ = 31; + check_simplex(function__, "tp_simplex", tp_simplex); + current_statement__ = 32; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 32; + current_statement__ = 32; + check_simplex(function__, "tp_1d_simplex[sym1__]", + tp_1d_simplex[(sym1__ - 1)]);} + current_statement__ = 33; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 33; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 33; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 33; + current_statement__ = 33; + check_simplex(function__, + "tp_3d_simplex[sym1__, sym2__, sym3__]", + tp_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - + 1)]);}}} + current_statement__ = 34; + current_statement__ = 34; + check_cholesky_factor(function__, "tp_cfcov_54", tp_cfcov_54); + current_statement__ = 35; + current_statement__ = 35; + check_cholesky_factor(function__, "tp_cfcov_33", tp_cfcov_33); + current_statement__ = 36; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 36; + current_statement__ = 36; + check_cholesky_factor(function__, "tp_cfcov_33_ar[sym1__]", + tp_cfcov_33_ar[(sym1__ - 1)]);} + { + current_statement__ = 145; + validate_non_negative_index("tmp", "0", 0); + Eigen::Matrix tmp; + tmp = Eigen::Matrix(0); + + current_statement__ = 145; + for (size_t sym1__ = 1; sym1__ <= 0; ++sym1__) { + current_statement__ = 145; + assign(tmp, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tmp");} + current_statement__ = 146; + validate_non_negative_index("tmp2", "0", 0); + current_statement__ = 146; + validate_non_negative_index("tmp2", "0", 0); + std::vector> tmp2; + tmp2 = std::vector>(0, Eigen::Matrix(0)); + + current_statement__ = 146; + for (size_t sym1__ = 1; sym1__ <= 0; ++sym1__) { + current_statement__ = 146; + for (size_t sym2__ = 1; sym2__ <= 0; ++sym2__) { + current_statement__ = 146; + assign(tmp2, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tmp2");}} + local_scalar_t__ r1; + + current_statement__ = 147; + r1 = std::numeric_limits::quiet_NaN(); + current_statement__ = 147; + r1 = foo_bar1(p_real, pstream__); + local_scalar_t__ r2; + + current_statement__ = 148; + r2 = std::numeric_limits::quiet_NaN(); + current_statement__ = 148; + r2 = foo_bar1(J, pstream__); + current_statement__ = 149; + lp_accum__.add(normal_log(p_real, 0, 1)); + current_statement__ = 150; + lp_accum__.add(normal_log(offset_multiplier, 0, 1)); + current_statement__ = 151; + lp_accum__.add(normal_log(no_offset_multiplier, 0, 1)); + current_statement__ = 152; + lp_accum__.add(normal_log(offset_no_multiplier, 0, 1)); + current_statement__ = 153; + lp_accum__.add(normal_log(to_vector(p_real_1d_ar), 0, 1)); + current_statement__ = 166; + for (size_t n = 1; n <= N; ++n) { + current_statement__ = 154; + lp_accum__.add( + normal_log(to_vector(p_1d_vec[(n - 1)]), 0, 1)); + current_statement__ = 155; + lp_accum__.add( + normal_log(to_vector(p_1d_row_vec[(n - 1)]), 0, 1)); + current_statement__ = 156; + lp_accum__.add( + normal_log(to_vector(p_1d_simplex[(n - 1)]), 0, 1)); + current_statement__ = 164; + for (size_t m = 1; m <= M; ++m) { + current_statement__ = 162; + for (size_t k = 1; k <= K; ++k) { + current_statement__ = 157; + lp_accum__.add( + normal_log( + to_vector(p_3d_vec[(n - 1)][(m - 1)][(k - 1)]), + d_3d_vec[(n - 1)][(m - 1)][(k - 1)], 1)); + current_statement__ = 158; + lp_accum__.add( + normal_log( + to_vector(p_3d_row_vec[(n - 1)][(m - 1)][(k - 1)]), + d_3d_row_vec[(n - 1)][(m - 1)][(k - 1)], 1)); + current_statement__ = 159; + lp_accum__.add( + normal_log( + to_vector(p_3d_simplex[(n - 1)][(m - 1)][(k - 1)]), + d_3d_simplex[(n - 1)][(m - 1)][(k - 1)], 1)); + current_statement__ = 160; + lp_accum__.add( + normal_log(p_real_3d_ar[(n - 1)][(m - 1)][(k - 1)], + p_real_3d_ar[(n - 1)][(m - 1)][(k - 1)], 1));}}} + current_statement__ = 171; + for (size_t i = 1; i <= 4; ++i) { + current_statement__ = 169; + for (size_t j = 1; j <= 5; ++j) { + current_statement__ = 167; + lp_accum__.add( + normal_log(to_vector(p_ar_mat[(i - 1)][(j - 1)]), 0, + 1));}} + current_statement__ = 174; + for (size_t k = 1; k <= K; ++k) { + current_statement__ = 172; + lp_accum__.add( + normal_log(to_vector(p_cfcov_33_ar[(k - 1)]), 0, 1));} + current_statement__ = 175; + lp_accum__.add(normal_log(to_vector(p_vec), d_vec, 1)); + current_statement__ = 176; + lp_accum__.add(normal_log(to_vector(p_row_vec), 0, 1)); + current_statement__ = 177; + lp_accum__.add(normal_log(to_vector(p_simplex), 0, 1)); + current_statement__ = 178; + lp_accum__.add(normal_log(to_vector(p_cfcov_54), 0, 1)); + current_statement__ = 179; + lp_accum__.add(normal_log(to_vector(p_cfcov_33), 0, 1)); + current_statement__ = 180; + lp_accum__.add( + map_rect<1, binomialf_functor__>(tmp, tmp2, x_r, x_i, pstream__)); + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} + } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() + + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "mother_model_namespace::write_array"; +(void) function__; // suppress unused var warning -struct map_rectfake_functor__ { -template -typename boost::math::tools::promote_args::type -operator()(const T0__& x, std::ostream* pstream__) const -{ -return map_rectfake(x, pstream__); -} -}; + (void) function__; // suppress unused var warning -template -Eigen::Matrix::type, -1, 1> -algebra_system(const Eigen::Matrix& x, - const Eigen::Matrix& y, - const std::vector& dat, const std::vector& dat_int, - std::ostream* pstream__) { - using local_scalar_t__ = typename boost::math::tools::promote_args::type; - const static bool propto__ = true; - (void) propto__; - - try { - current_statement__ = 123; - validate_non_negative_index("f_x", "2", 2); - Eigen::Matrix f_x; - f_x = Eigen::Matrix(2); + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; - current_statement__ = 123; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + try { + double p_real; + + current_statement__ = 1; + p_real = in__.scalar(); + current_statement__ = 2; + validate_non_negative_index("offset_multiplier", "5", 5); + std::vector offset_multiplier; + offset_multiplier = std::vector(5, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable offset_multiplier");} + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_multiplier[(sym1__ - 1)], 1, 2), + "assigning variable offset_multiplier");} + current_statement__ = 3; + validate_non_negative_index("no_offset_multiplier", "5", 5); + std::vector no_offset_multiplier; + no_offset_multiplier = std::vector(5, 0); + + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable no_offset_multiplier");} + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + no_offset_multiplier[(sym1__ - 1)], 0, 2), + "assigning variable no_offset_multiplier");} + current_statement__ = 4; + validate_non_negative_index("offset_no_multiplier", "5", 5); + std::vector offset_no_multiplier; + offset_no_multiplier = std::vector(5, 0); + + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), in__.scalar(), + "assigning variable offset_no_multiplier");} + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_constrain( + offset_no_multiplier[(sym1__ - 1)], 3, 1), + "assigning variable offset_no_multiplier");} + current_statement__ = 5; + validate_non_negative_index("p_real_1d_ar", "N", N); + std::vector p_real_1d_ar; + p_real_1d_ar = std::vector(N, 0); + + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 5; + assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable p_real_1d_ar");} + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 5; + assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_real_1d_ar[(sym1__ - 1)], 0), + "assigning variable p_real_1d_ar");} + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "N", N); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "M", M); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "K", K); + std::vector>> p_real_3d_ar; + p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.scalar(), "assigning variable p_real_3d_ar");}}} + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::lb_constrain( + p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), + "assigning variable p_real_3d_ar");}}} + current_statement__ = 7; + validate_non_negative_index("p_vec", "N", N); + Eigen::Matrix p_vec; + p_vec = Eigen::Matrix(N); + + current_statement__ = 7; + p_vec = in__.vector(N); + current_statement__ = 7; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 7; + assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_constrain(p_vec[(sym1__ - 1)], 0), + "assigning variable p_vec");} + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + std::vector> p_1d_vec; + p_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 8; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 8; + assign(p_1d_vec, cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(N), "assigning variable p_1d_vec");} + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "M", M); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "K", K); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + std::vector>>> p_3d_vec; + p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 9; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 9; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 9; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 9; + assign(p_3d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.vector(N), "assigning variable p_3d_vec");}}} + current_statement__ = 10; + validate_non_negative_index("p_row_vec", "N", N); + Eigen::Matrix p_row_vec; + p_row_vec = Eigen::Matrix(N); + + current_statement__ = 10; + p_row_vec = in__.row_vector(N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + std::vector> p_1d_row_vec; + p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 11; + assign(p_1d_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + in__.row_vector(N), "assigning variable p_1d_row_vec");} + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "M", M); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "K", K); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + std::vector>>> p_3d_row_vec; + p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 12; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 12; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 12; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 12; + assign(p_3d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.row_vector(N), "assigning variable p_3d_row_vec");}}} + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "4", 4); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "5", 5); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "2", 2); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "3", 3); + std::vector>> p_ar_mat; + p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + in__.matrix(2, 3), "assigning variable p_ar_mat");}} + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 13; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 13; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + stan::math::lub_constrain( + rvalue(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + "p_ar_mat"), 0, 1), "assigning variable p_ar_mat");}}}} + current_statement__ = 14; + validate_positive_index("p_simplex", "N", N); + Eigen::Matrix p_simplex; + p_simplex = Eigen::Matrix(N); + + Eigen::Matrix p_simplex_in__; + p_simplex_in__ = Eigen::Matrix((N - 1)); + + current_statement__ = 14; + p_simplex_in__ = in__.vector((N - 1)); + current_statement__ = 14; + assign(p_simplex, nil_index_list(), + stan::math::simplex_constrain(p_simplex_in__), + "assigning variable p_simplex"); + current_statement__ = 15; + validate_non_negative_index("p_1d_simplex", "N", N); + current_statement__ = 15; + validate_positive_index("p_1d_simplex", "N", N); + std::vector> p_1d_simplex; + p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + std::vector> p_1d_simplex_in__; + p_1d_simplex_in__ = std::vector>(N, Eigen::Matrix( + (N - 1))); + + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + assign(p_1d_simplex_in__, + cons_list(index_uni(sym1__), nil_index_list()), + in__.vector((N - 1)), "assigning variable p_1d_simplex_in__");} + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + assign(p_1d_simplex, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::simplex_constrain(p_1d_simplex_in__[(sym1__ - 1)]), + "assigning variable p_1d_simplex");} + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "N", N); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "M", M); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "K", K); + current_statement__ = 16; + validate_positive_index("p_3d_simplex", "N", N); + std::vector>>> p_3d_simplex; + p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + std::vector>>> p_3d_simplex_in__; + p_3d_simplex_in__ = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix( + (N - 1))))); + + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 16; + assign(p_3d_simplex_in__, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + in__.vector((N - 1)), "assigning variable p_3d_simplex_in__");} + }} + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 16; + assign(p_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::simplex_constrain( + p_3d_simplex_in__[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), + "assigning variable p_3d_simplex");}}} + current_statement__ = 17; + check_greater_or_equal("cholesky_factor_cov p_cfcov_54", + "num rows (must be greater or equal to num cols)", + 5, 4); + current_statement__ = 17; + validate_non_negative_index("p_cfcov_54", "4", 4); + Eigen::Matrix p_cfcov_54; + p_cfcov_54 = Eigen::Matrix(5, 4); + + Eigen::Matrix p_cfcov_54_in__; + p_cfcov_54_in__ = Eigen::Matrix(((((4 * + (4 - 1)) + / 2) + 4) + + + ((5 - 4) * + 4))); + + current_statement__ = 17; + p_cfcov_54_in__ = in__.vector( + ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); + current_statement__ = 17; + assign(p_cfcov_54, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_54_in__, 5, 4), + "assigning variable p_cfcov_54"); + current_statement__ = 18; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 18; + validate_non_negative_index("p_cfcov_33", "3", 3); + Eigen::Matrix p_cfcov_33; + p_cfcov_33 = Eigen::Matrix(3, 3); + + Eigen::Matrix p_cfcov_33_in__; + p_cfcov_33_in__ = Eigen::Matrix(((((3 * + (3 - 1)) + / 2) + 3) + + + ((3 - 3) * + 3))); + + current_statement__ = 18; + p_cfcov_33_in__ = in__.vector( + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); + current_statement__ = 18; + assign(p_cfcov_33, nil_index_list(), + stan::math::cholesky_factor_constrain(p_cfcov_33_in__, 3, 3), + "assigning variable p_cfcov_33"); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "K", K); + current_statement__ = 19; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "3", 3); + std::vector> p_cfcov_33_ar; + p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + std::vector> p_cfcov_33_ar_in__; + p_cfcov_33_ar_in__ = std::vector>(K, Eigen::Matrix( + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); + + current_statement__ = 19; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 19; + assign(p_cfcov_33_ar_in__, + cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))), + "assigning variable p_cfcov_33_ar_in__");} + current_statement__ = 19; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 19; + assign(p_cfcov_33_ar, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::cholesky_factor_constrain( + p_cfcov_33_ar_in__[(sym1__ - 1)], 3, 3), + "assigning variable p_cfcov_33_ar");} + current_statement__ = 20; + validate_non_negative_index("x_p", "2", 2); + Eigen::Matrix x_p; + x_p = Eigen::Matrix(2); + + current_statement__ = 20; + x_p = in__.vector(2); + current_statement__ = 21; + validate_non_negative_index("y_p", "2", 2); + Eigen::Matrix y_p; + y_p = Eigen::Matrix(2); + + current_statement__ = 21; + y_p = in__.vector(2); + current_statement__ = 22; + validate_non_negative_index("tp_real_1d_ar", "N", N); + std::vector tp_real_1d_ar; + tp_real_1d_ar = std::vector(N, 0); + + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "N", N); + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "M", M); + current_statement__ = 23; + validate_non_negative_index("tp_real_3d_ar", "K", K); + std::vector>> tp_real_3d_ar; + tp_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + current_statement__ = 24; + validate_non_negative_index("tp_vec", "N", N); + Eigen::Matrix tp_vec; + tp_vec = Eigen::Matrix(N); + + current_statement__ = 24; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 24; + assign(tp_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_vec");} + current_statement__ = 25; + validate_non_negative_index("tp_1d_vec", "N", N); + current_statement__ = 25; + validate_non_negative_index("tp_1d_vec", "N", N); + std::vector> tp_1d_vec; + tp_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 25; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 25; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 25; + assign(tp_1d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_vec");}} + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "N", N); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "M", M); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "K", K); + current_statement__ = 26; + validate_non_negative_index("tp_3d_vec", "N", N); + std::vector>>> tp_3d_vec; + tp_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 26; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 26; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 26; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 26; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 26; + assign(tp_3d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_vec");}}}} + current_statement__ = 27; + validate_non_negative_index("tp_row_vec", "N", N); + Eigen::Matrix tp_row_vec; + tp_row_vec = Eigen::Matrix(N); + + current_statement__ = 27; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 27; + assign(tp_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_row_vec");} + current_statement__ = 28; + validate_non_negative_index("tp_1d_row_vec", "N", N); + current_statement__ = 28; + validate_non_negative_index("tp_1d_row_vec", "N", N); + std::vector> tp_1d_row_vec; + tp_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 28; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 28; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 28; + assign(tp_1d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_row_vec");}} + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "N", N); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "M", M); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "K", K); + current_statement__ = 29; + validate_non_negative_index("tp_3d_row_vec", "N", N); + std::vector>>> tp_3d_row_vec; + tp_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 29; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 29; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 29; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 29; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 29; + assign(tp_3d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_row_vec");}}}} + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "4", 4); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "5", 5); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "2", 2); + current_statement__ = 30; + validate_non_negative_index("tp_ar_mat", "3", 3); + std::vector>> tp_ar_mat; + tp_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 30; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 30; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 30; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 30; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 30; + assign(tp_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_ar_mat");}}}} + current_statement__ = 31; + validate_non_negative_index("tp_simplex", "N", N); + Eigen::Matrix tp_simplex; + tp_simplex = Eigen::Matrix(N); + + current_statement__ = 31; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 31; + assign(tp_simplex, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_simplex");} + current_statement__ = 32; + validate_non_negative_index("tp_1d_simplex", "N", N); + current_statement__ = 32; + validate_non_negative_index("tp_1d_simplex", "N", N); + std::vector> tp_1d_simplex; + tp_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 32; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 32; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 32; + assign(tp_1d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_1d_simplex");}} + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "N", N); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "M", M); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "K", K); + current_statement__ = 33; + validate_non_negative_index("tp_3d_simplex", "N", N); + std::vector>>> tp_3d_simplex; + tp_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 33; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 33; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 33; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 33; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 33; + assign(tp_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_3d_simplex");}}}} + current_statement__ = 34; + validate_non_negative_index("tp_cfcov_54", "5", 5); + current_statement__ = 34; + validate_non_negative_index("tp_cfcov_54", "4", 4); + Eigen::Matrix tp_cfcov_54; + tp_cfcov_54 = Eigen::Matrix(5, 4); + + current_statement__ = 34; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 34; + for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { + current_statement__ = 34; + assign(tp_cfcov_54, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_54");}} + current_statement__ = 35; + validate_non_negative_index("tp_cfcov_33", "3", 3); + current_statement__ = 35; + validate_non_negative_index("tp_cfcov_33", "3", 3); + Eigen::Matrix tp_cfcov_33; + tp_cfcov_33 = Eigen::Matrix(3, 3); + + current_statement__ = 35; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 35; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 35; + assign(tp_cfcov_33, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_33");}} + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "K", K); + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "3", 3); + current_statement__ = 36; + validate_non_negative_index("tp_cfcov_33_ar", "3", 3); + std::vector> tp_cfcov_33_ar; + tp_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + current_statement__ = 36; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 36; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 36; + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + current_statement__ = 36; + assign(tp_cfcov_33_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable tp_cfcov_33_ar");}}} + current_statement__ = 37; + validate_non_negative_index("theta_p", "2", 2); + Eigen::Matrix theta_p; + theta_p = Eigen::Matrix(2); + + current_statement__ = 37; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 37; + assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta_p");} + vars__.push_back(p_real); + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(offset_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(no_offset_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(offset_no_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_real_1d_ar[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + vars__.push_back( + p_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - + 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_row_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + vars__.push_back( + rvalue(p_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + "p_ar_mat"));}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_simplex[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + vars__.push_back( + rvalue(p_cfcov_54, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "p_cfcov_54"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back( + rvalue(p_cfcov_33, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "p_cfcov_33"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + vars__.push_back( + rvalue(p_cfcov_33_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "p_cfcov_33_ar"));}}} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(x_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y_p[(sym1__ - 1)]);} + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + current_statement__ = 38; + assign(tp_real_1d_ar, nil_index_list(), p_real_1d_ar, + "assigning variable tp_real_1d_ar"); + current_statement__ = 39; + assign(tp_real_3d_ar, nil_index_list(), p_real_3d_ar, + "assigning variable tp_real_3d_ar"); + current_statement__ = 40; + assign(tp_1d_vec, nil_index_list(), p_1d_vec, + "assigning variable tp_1d_vec"); + current_statement__ = 41; + assign(tp_3d_vec, nil_index_list(), p_3d_vec, + "assigning variable tp_3d_vec"); + current_statement__ = 42; + assign(tp_simplex, nil_index_list(), p_simplex, + "assigning variable tp_simplex"); + current_statement__ = 43; + assign(tp_1d_simplex, nil_index_list(), p_1d_simplex, + "assigning variable tp_1d_simplex"); + current_statement__ = 44; + assign(tp_3d_simplex, nil_index_list(), p_3d_simplex, + "assigning variable tp_3d_simplex"); + current_statement__ = 45; + assign(tp_cfcov_54, nil_index_list(), p_cfcov_54, + "assigning variable tp_cfcov_54"); + current_statement__ = 46; + assign(tp_cfcov_33, nil_index_list(), p_cfcov_33, + "assigning variable tp_cfcov_33"); + current_statement__ = 47; + assign(tp_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, + "assigning variable tp_cfcov_33_ar"); + current_statement__ = 56; + for (size_t i = 1; i <= 2; ++i) { + current_statement__ = 54; + for (size_t j = 1; j <= 3; ++j) { + current_statement__ = 52; + for (size_t m = 1; m <= 4; ++m) { + current_statement__ = 50; + for (size_t n = 1; n <= 5; ++n) { + current_statement__ = 48; + assign(tp_ar_mat, + cons_list(index_uni(m), + cons_list(index_uni(n), + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())))), 0.4, + "assigning variable tp_ar_mat");}}}} + current_statement__ = 58; + for (size_t i = 1; i <= N; ++i) { + current_statement__ = 57; + assign(tp_vec, cons_list(index_uni(i), nil_index_list()), + (-1.0 * p_vec[(i - 1)]), "assigning variable tp_vec");} + current_statement__ = 59; + assign(tp_row_vec, nil_index_list(), transpose(tp_1d_vec[(1 - 1)]), + "assigning variable tp_row_vec"); + current_statement__ = 60; + assign(tp_1d_row_vec, nil_index_list(), p_1d_row_vec, + "assigning variable tp_1d_row_vec"); + current_statement__ = 61; + assign(tp_3d_row_vec, nil_index_list(), p_3d_row_vec, + "assigning variable tp_3d_row_vec"); + current_statement__ = 62; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 63; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 64; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x, y_p, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 65; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 66; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + current_statement__ = 67; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, + pstream__), "assigning variable theta_p"); + current_statement__ = 68; + assign(theta_p, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p, y_p, dat, dat_int, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p"); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(tp_real_1d_ar[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + vars__.push_back( + tp_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(tp_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(tp_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + tp_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - + 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(tp_row_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(tp_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + tp_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + vars__.push_back( + rvalue(tp_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + "tp_ar_mat"));}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(tp_simplex[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(tp_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + tp_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + vars__.push_back( + rvalue(tp_cfcov_54, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "tp_cfcov_54"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back( + rvalue(tp_cfcov_33, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "tp_cfcov_33"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + vars__.push_back( + rvalue(tp_cfcov_33_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "tp_cfcov_33_ar"));}}} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(theta_p[(sym1__ - 1)]);} + if (logical_negation(emit_generated_quantities__)) { + return ; + } + double gq_r1; + + current_statement__ = 69; + gq_r1 = std::numeric_limits::quiet_NaN(); + current_statement__ = 69; + gq_r1 = foo_bar1(p_real, pstream__); + double gq_r2; + + current_statement__ = 70; + gq_r2 = std::numeric_limits::quiet_NaN(); + current_statement__ = 70; + gq_r2 = foo_bar1(J, pstream__); + current_statement__ = 71; + validate_non_negative_index("gq_real_1d_ar", "N", N); + std::vector gq_real_1d_ar; + gq_real_1d_ar = std::vector(N, 0); + + current_statement__ = 72; + validate_non_negative_index("gq_real_3d_ar", "N", N); + current_statement__ = 72; + validate_non_negative_index("gq_real_3d_ar", "M", M); + current_statement__ = 72; + validate_non_negative_index("gq_real_3d_ar", "K", K); + std::vector>> gq_real_3d_ar; + gq_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + current_statement__ = 73; + validate_non_negative_index("gq_vec", "N", N); + Eigen::Matrix gq_vec; + gq_vec = Eigen::Matrix(N); + + current_statement__ = 73; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 73; + assign(gq_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_vec");} + current_statement__ = 74; + validate_non_negative_index("gq_1d_vec", "N", N); + current_statement__ = 74; + validate_non_negative_index("gq_1d_vec", "N", N); + std::vector> gq_1d_vec; + gq_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 74; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 74; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 74; + assign(gq_1d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_1d_vec");}} + current_statement__ = 75; + validate_non_negative_index("gq_3d_vec", "N", N); + current_statement__ = 75; + validate_non_negative_index("gq_3d_vec", "M", M); + current_statement__ = 75; + validate_non_negative_index("gq_3d_vec", "K", K); + current_statement__ = 75; + validate_non_negative_index("gq_3d_vec", "N", N); + std::vector>>> gq_3d_vec; + gq_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 75; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 75; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 75; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 75; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 75; + assign(gq_3d_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_3d_vec");}}}} + current_statement__ = 76; + validate_non_negative_index("gq_row_vec", "N", N); + Eigen::Matrix gq_row_vec; + gq_row_vec = Eigen::Matrix(N); + + current_statement__ = 76; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 76; + assign(gq_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_row_vec");} + current_statement__ = 77; + validate_non_negative_index("gq_1d_row_vec", "N", N); + current_statement__ = 77; + validate_non_negative_index("gq_1d_row_vec", "N", N); + std::vector> gq_1d_row_vec; + gq_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 77; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 77; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 77; + assign(gq_1d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_1d_row_vec");}} + current_statement__ = 78; + validate_non_negative_index("gq_3d_row_vec", "N", N); + current_statement__ = 78; + validate_non_negative_index("gq_3d_row_vec", "M", M); + current_statement__ = 78; + validate_non_negative_index("gq_3d_row_vec", "K", K); + current_statement__ = 78; + validate_non_negative_index("gq_3d_row_vec", "N", N); + std::vector>>> gq_3d_row_vec; + gq_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 78; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 78; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 78; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 78; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 78; + assign(gq_3d_row_vec, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_3d_row_vec");}}}} + current_statement__ = 79; + validate_non_negative_index("gq_ar_mat", "4", 4); + current_statement__ = 79; + validate_non_negative_index("gq_ar_mat", "5", 5); + current_statement__ = 79; + validate_non_negative_index("gq_ar_mat", "2", 2); + current_statement__ = 79; + validate_non_negative_index("gq_ar_mat", "3", 3); + std::vector>> gq_ar_mat; + gq_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); + + current_statement__ = 79; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 79; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 79; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 79; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 79; + assign(gq_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_ar_mat");}}}} + current_statement__ = 80; + validate_non_negative_index("gq_simplex", "N", N); + Eigen::Matrix gq_simplex; + gq_simplex = Eigen::Matrix(N); + + current_statement__ = 80; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 80; + assign(gq_simplex, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_simplex");} + current_statement__ = 81; + validate_non_negative_index("gq_1d_simplex", "N", N); + current_statement__ = 81; + validate_non_negative_index("gq_1d_simplex", "N", N); + std::vector> gq_1d_simplex; + gq_1d_simplex = std::vector>(N, Eigen::Matrix(N)); + + current_statement__ = 81; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 81; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 81; + assign(gq_1d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_1d_simplex");}} + current_statement__ = 82; + validate_non_negative_index("gq_3d_simplex", "N", N); + current_statement__ = 82; + validate_non_negative_index("gq_3d_simplex", "M", M); + current_statement__ = 82; + validate_non_negative_index("gq_3d_simplex", "K", K); + current_statement__ = 82; + validate_non_negative_index("gq_3d_simplex", "N", N); + std::vector>>> gq_3d_simplex; + gq_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + current_statement__ = 82; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 82; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 82; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 82; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 82; + assign(gq_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_3d_simplex");}}}} + current_statement__ = 83; + validate_non_negative_index("gq_cfcov_54", "5", 5); + current_statement__ = 83; + validate_non_negative_index("gq_cfcov_54", "4", 4); + Eigen::Matrix gq_cfcov_54; + gq_cfcov_54 = Eigen::Matrix(5, 4); + + current_statement__ = 83; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 83; + for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { + current_statement__ = 83; + assign(gq_cfcov_54, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_cfcov_54");}} + current_statement__ = 84; + validate_non_negative_index("gq_cfcov_33", "3", 3); + current_statement__ = 84; + validate_non_negative_index("gq_cfcov_33", "3", 3); + Eigen::Matrix gq_cfcov_33; + gq_cfcov_33 = Eigen::Matrix(3, 3); + + current_statement__ = 84; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 84; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 84; + assign(gq_cfcov_33, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_cfcov_33");}} + current_statement__ = 85; + validate_non_negative_index("gq_cfcov_33_ar", "K", K); + current_statement__ = 85; + validate_non_negative_index("gq_cfcov_33_ar", "3", 3); + current_statement__ = 85; + validate_non_negative_index("gq_cfcov_33_ar", "3", 3); + std::vector> gq_cfcov_33_ar; + gq_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); + + current_statement__ = 85; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 85; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 85; + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + current_statement__ = 85; + assign(gq_cfcov_33_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable gq_cfcov_33_ar");}}} + current_statement__ = 86; + validate_non_negative_index("indices", "3", 3); + std::vector indices; + indices = std::vector(3, 0); + + current_statement__ = 86; + assign(indices, nil_index_list(), stan::math::array_builder() + .add(2).add(3).add(1).array(), "assigning variable indices"); + current_statement__ = 87; + validate_non_negative_index("indexing_mat", "5", 5); + current_statement__ = 87; + validate_non_negative_index("indexing_mat", "3", 3); + current_statement__ = 87; + validate_non_negative_index("indexing_mat", "4", 4); + std::vector> indexing_mat; + indexing_mat = std::vector>(5, Eigen::Matrix(3, 4)); + + current_statement__ = 87; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 87; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 87; + for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { + current_statement__ = 87; + assign(indexing_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable indexing_mat");}}} + current_statement__ = 88; + validate_non_negative_index("idx_res1", "3", 3); + current_statement__ = 88; + validate_non_negative_index("idx_res1", "3", 3); + current_statement__ = 88; + validate_non_negative_index("idx_res1", "4", 4); + std::vector> idx_res1; + idx_res1 = std::vector>(3, Eigen::Matrix(3, 4)); + + current_statement__ = 88; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 88; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 88; + for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { + current_statement__ = 88; + assign(idx_res1, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res1");}}} + current_statement__ = 89; + validate_non_negative_index("idx_res2", "5", 5); + current_statement__ = 89; + validate_non_negative_index("idx_res2", "3", 3); + current_statement__ = 89; + validate_non_negative_index("idx_res2", "4", 4); + std::vector> idx_res2; + idx_res2 = std::vector>(5, Eigen::Matrix(3, 4)); + + current_statement__ = 89; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 89; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 89; + for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { + current_statement__ = 89; + assign(idx_res2, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res2");}}} + current_statement__ = 90; + validate_non_negative_index("idx_res3", "3", 3); + current_statement__ = 90; + validate_non_negative_index("idx_res3", "3", 3); + current_statement__ = 90; + validate_non_negative_index("idx_res3", "3", 3); + std::vector> idx_res3; + idx_res3 = std::vector>(3, Eigen::Matrix(3, 3)); + + current_statement__ = 90; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 90; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 90; + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + current_statement__ = 90; + assign(idx_res3, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res3");}}} + current_statement__ = 91; + validate_non_negative_index("idx_res11", "3", 3); + current_statement__ = 91; + validate_non_negative_index("idx_res11", "3", 3); + current_statement__ = 91; + validate_non_negative_index("idx_res11", "4", 4); + std::vector> idx_res11; + idx_res11 = std::vector>(3, Eigen::Matrix(3, 4)); + + current_statement__ = 91; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 91; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 91; + for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { + current_statement__ = 91; + assign(idx_res11, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res11");}}} + current_statement__ = 92; + validate_non_negative_index("idx_res21", "5", 5); + current_statement__ = 92; + validate_non_negative_index("idx_res21", "3", 3); + current_statement__ = 92; + validate_non_negative_index("idx_res21", "4", 4); + std::vector> idx_res21; + idx_res21 = std::vector>(5, Eigen::Matrix(3, 4)); + + current_statement__ = 92; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 92; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 92; + for (size_t sym3__ = 1; sym3__ <= 4; ++sym3__) { + current_statement__ = 92; + assign(idx_res21, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res21");}}} + current_statement__ = 93; + validate_non_negative_index("idx_res31", "3", 3); + current_statement__ = 93; + validate_non_negative_index("idx_res31", "3", 3); + current_statement__ = 93; + validate_non_negative_index("idx_res31", "3", 3); + std::vector> idx_res31; + idx_res31 = std::vector>(3, Eigen::Matrix(3, 3)); + + current_statement__ = 93; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 93; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 93; + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + current_statement__ = 93; + assign(idx_res31, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res31");}}} + current_statement__ = 94; + validate_non_negative_index("idx_res4", "3", 3); + current_statement__ = 94; + validate_non_negative_index("idx_res4", "4", 4); + std::vector> idx_res4; + idx_res4 = std::vector>(3, Eigen::Matrix(4)); + + current_statement__ = 94; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 94; + for (size_t sym2__ = 1; sym2__ <= 4; ++sym2__) { + current_statement__ = 94; + assign(idx_res4, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res4");}} + current_statement__ = 95; + validate_non_negative_index("idx_res5", "2", 2); + current_statement__ = 95; + validate_non_negative_index("idx_res5", "2", 2); + std::vector> idx_res5; + idx_res5 = std::vector>(2, Eigen::Matrix(2)); + + current_statement__ = 95; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 95; + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + current_statement__ = 95; + assign(idx_res5, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), nil_index_list())), + std::numeric_limits::quiet_NaN(), + "assigning variable idx_res5");}} + current_statement__ = 96; + assign(gq_real_1d_ar, nil_index_list(), + rvalue(p_1d_simplex, + cons_list(index_omni(), cons_list(index_uni(1), nil_index_list())), + "p_1d_simplex"), "assigning variable gq_real_1d_ar"); + current_statement__ = 97; + assign(gq_real_3d_ar, nil_index_list(), p_real_3d_ar, + "assigning variable gq_real_3d_ar"); + current_statement__ = 98; + assign(gq_1d_vec, nil_index_list(), p_1d_vec, + "assigning variable gq_1d_vec"); + current_statement__ = 99; + assign(gq_3d_vec, nil_index_list(), p_3d_vec, + "assigning variable gq_3d_vec"); + current_statement__ = 100; + assign(gq_row_vec, nil_index_list(), p_row_vec, + "assigning variable gq_row_vec"); + current_statement__ = 101; + assign(gq_1d_row_vec, nil_index_list(), p_1d_row_vec, + "assigning variable gq_1d_row_vec"); + current_statement__ = 102; + assign(gq_3d_row_vec, nil_index_list(), p_3d_row_vec, + "assigning variable gq_3d_row_vec"); + current_statement__ = 103; + assign(gq_simplex, nil_index_list(), + rvalue(p_1d_simplex, + cons_list(index_uni(1), + cons_list(index_min_max(1, N), nil_index_list())), + "p_1d_simplex"), "assigning variable gq_simplex"); + current_statement__ = 104; + assign(gq_1d_simplex, nil_index_list(), p_1d_simplex, + "assigning variable gq_1d_simplex"); + current_statement__ = 105; + assign(gq_3d_simplex, nil_index_list(), p_3d_simplex, + "assigning variable gq_3d_simplex"); + current_statement__ = 106; + assign(gq_cfcov_54, nil_index_list(), p_cfcov_54, + "assigning variable gq_cfcov_54"); + current_statement__ = 107; + assign(gq_cfcov_33, nil_index_list(), p_cfcov_33, + "assigning variable gq_cfcov_33"); + current_statement__ = 108; + assign(gq_cfcov_33_ar, nil_index_list(), p_cfcov_33_ar, + "assigning variable gq_cfcov_33_ar"); + current_statement__ = 117; + for (size_t i = 1; i <= 2; ++i) { + current_statement__ = 115; + for (size_t j = 1; j <= 3; ++j) { + current_statement__ = 113; + for (size_t m = 1; m <= 4; ++m) { + current_statement__ = 111; + for (size_t n = 1; n <= 5; ++n) { + current_statement__ = 109; + assign(gq_ar_mat, + cons_list(index_uni(m), + cons_list(index_uni(n), + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())))), 0.4, + "assigning variable gq_ar_mat");}}}} + current_statement__ = 119; + for (size_t i = 1; i <= N; ++i) { + current_statement__ = 118; + assign(gq_vec, cons_list(index_uni(i), nil_index_list()), + (-1.0 * p_vec[(i - 1)]), "assigning variable gq_vec");} current_statement__ = 123; - assign(f_x, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable f_x");} - current_statement__ = 124; - assign(f_x, cons_list(index_uni(1), nil_index_list()), - (x[(1 - 1)] - y[(1 - 1)]), "assigning variable f_x"); - current_statement__ = 125; - assign(f_x, cons_list(index_uni(2), nil_index_list()), - (x[(2 - 1)] - y[(2 - 1)]), "assigning variable f_x"); - current_statement__ = 126; - return f_x; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); + for (size_t i = 1; i <= 3; ++i) { + current_statement__ = 122; + for (size_t j = 1; j <= 4; ++j) { + current_statement__ = 121; + for (size_t k = 1; k <= 5; ++k) { + current_statement__ = 120; + assign(indexing_mat, + cons_list(index_uni(k), + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list()))), + normal_rng(0, 1, base_rng__), "assigning variable indexing_mat"); + }}} + current_statement__ = 126; + for (size_t i = 1; i <= size(indices); ++i) { + current_statement__ = 125; + for (size_t j = 1; j <= size(indices); ++j) { + current_statement__ = 124; + assign(idx_res1, + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())), + rvalue(indexing_mat, + cons_list(index_uni(indices[(i - 1)]), + cons_list(index_uni(indices[(j - 1)]), nil_index_list())), + "indexing_mat"), "assigning variable idx_res1");}} + current_statement__ = 127; + assign(idx_res11, nil_index_list(), + rvalue(indexing_mat, + cons_list(index_multi(indices), + cons_list(index_multi(indices), nil_index_list())), + "indexing_mat"), "assigning variable idx_res11"); + current_statement__ = 129; + if (logical_neq( + rvalue( + rvalue(indexing_mat, + cons_list(index_multi(indices), + cons_list(index_multi(indices), nil_index_list())), "indexing_mat"), + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), + "indexing_mat[indices, indices]"), + rvalue(idx_res1, + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), "idx_res1"))) { + current_statement__ = 128; + std::stringstream errmsg_stream__; + errmsg_stream__ << "indexing test 1 failed"; + throw std::domain_error(errmsg_stream__.str()); + } + current_statement__ = 132; + for (size_t i = 1; i <= 5; ++i) { + current_statement__ = 131; + for (size_t j = 1; j <= size(indices); ++j) { + current_statement__ = 130; + assign(idx_res2, + cons_list(index_uni(i), + cons_list(index_uni(j), nil_index_list())), + rvalue(indexing_mat, + cons_list(index_uni(i), + cons_list(index_uni(indices[(j - 1)]), nil_index_list())), + "indexing_mat"), "assigning variable idx_res2");}} + current_statement__ = 133; + assign(idx_res21, nil_index_list(), + rvalue(indexing_mat, + cons_list(index_omni(), + cons_list(index_multi(indices), nil_index_list())), + "indexing_mat"), "assigning variable idx_res21"); + current_statement__ = 135; + if (logical_neq( + rvalue( + rvalue(indexing_mat, + cons_list(index_omni(), cons_list(index_multi(indices), nil_index_list())), + "indexing_mat"), + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), + "indexing_mat[:, indices]"), + rvalue(idx_res2, + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), "idx_res2"))) { + current_statement__ = 134; + std::stringstream errmsg_stream__; + errmsg_stream__ << "indexing test 2 failed"; + throw std::domain_error(errmsg_stream__.str()); + } + current_statement__ = 139; + for (size_t i = 1; i <= size(indices); ++i) { + current_statement__ = 138; + for (size_t j = 1; j <= 3; ++j) { + current_statement__ = 137; + for (size_t k = 1; k <= size(indices); ++k) { + current_statement__ = 136; + assign(idx_res3, + cons_list(index_uni(i), + cons_list(index_uni(j), + cons_list(index_uni(k), nil_index_list()))), + rvalue(indexing_mat, + cons_list(index_uni(indices[(i - 1)]), + cons_list(index_uni(j), + cons_list(index_uni(indices[(k - 1)]), nil_index_list()))), + "indexing_mat"), "assigning variable idx_res3");}}} + current_statement__ = 140; + assign(idx_res31, nil_index_list(), + rvalue(indexing_mat, + cons_list(index_multi(indices), + cons_list(index_omni(), + cons_list(index_multi(indices), nil_index_list()))), + "indexing_mat"), "assigning variable idx_res31"); + current_statement__ = 142; + if (logical_neq( + rvalue( + rvalue(indexing_mat, + cons_list(index_multi(indices), + cons_list(index_omni(), + cons_list(index_multi(indices), nil_index_list()))), "indexing_mat"), + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), + "indexing_mat[indices, :, indices]"), + rvalue(idx_res3, + cons_list(index_uni(2), + cons_list(index_uni(1), + cons_list(index_uni(1), nil_index_list()))), "idx_res3"))) { + current_statement__ = 141; + std::stringstream errmsg_stream__; + errmsg_stream__ << "indexing test 3 failed"; + throw std::domain_error(errmsg_stream__.str()); + } + current_statement__ = 143; + assign(idx_res4, nil_index_list(), + rvalue(indexing_mat, + cons_list(index_min_max(1, 3), + cons_list(index_uni(1), + cons_list(index_omni(), nil_index_list()))), "indexing_mat"), + "assigning variable idx_res4"); + current_statement__ = 144; + assign(idx_res5, nil_index_list(), + rvalue(indexing_mat, + cons_list(index_min(4), + cons_list(index_min_max(2, 3), + cons_list(index_uni(1), nil_index_list()))), "indexing_mat"), + "assigning variable idx_res5"); + current_statement__ = 71; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 71; + current_statement__ = 71; + check_greater_or_equal(function__, "gq_real_1d_ar[sym1__]", + gq_real_1d_ar[(sym1__ - 1)], 0);} + current_statement__ = 72; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 72; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 72; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 72; + current_statement__ = 72; + check_greater_or_equal(function__, + "gq_real_3d_ar[sym1__, sym2__, sym3__]", + gq_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][ + (sym3__ - 1)], 0);}}} + current_statement__ = 73; + current_statement__ = 73; + check_less_or_equal(function__, "gq_vec", gq_vec, 1); + current_statement__ = 79; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 79; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 79; + current_statement__ = 79; + check_greater_or_equal(function__, "gq_ar_mat[sym1__, sym2__]", + gq_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 0);}} + current_statement__ = 79; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 79; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 79; + current_statement__ = 79; + check_less_or_equal(function__, "gq_ar_mat[sym1__, sym2__]", + gq_ar_mat[(sym1__ - 1)][(sym2__ - 1)], 1);}} + current_statement__ = 80; + current_statement__ = 80; + check_simplex(function__, "gq_simplex", gq_simplex); + current_statement__ = 81; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 81; + current_statement__ = 81; + check_simplex(function__, "gq_1d_simplex[sym1__]", + gq_1d_simplex[(sym1__ - 1)]);} + current_statement__ = 82; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 82; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 82; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 82; + current_statement__ = 82; + check_simplex(function__, + "gq_3d_simplex[sym1__, sym2__, sym3__]", + gq_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - + 1)]);}}} + current_statement__ = 83; + current_statement__ = 83; + check_cholesky_factor(function__, "gq_cfcov_54", gq_cfcov_54); + current_statement__ = 84; + current_statement__ = 84; + check_cholesky_factor(function__, "gq_cfcov_33", gq_cfcov_33); + current_statement__ = 85; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 85; + current_statement__ = 85; + check_cholesky_factor(function__, "gq_cfcov_33_ar[sym1__]", + gq_cfcov_33_ar[(sym1__ - 1)]);} + vars__.push_back(gq_r1); + vars__.push_back(gq_r2); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(gq_real_1d_ar[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + vars__.push_back( + gq_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(gq_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(gq_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + gq_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - + 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(gq_row_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(gq_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + gq_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + vars__.push_back( + rvalue(gq_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + "gq_ar_mat"));}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(gq_simplex[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(gq_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + gq_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + vars__.push_back( + rvalue(gq_cfcov_54, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "gq_cfcov_54"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back( + rvalue(gq_cfcov_33, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + "gq_cfcov_33"));}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + vars__.push_back( + rvalue(gq_cfcov_33_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "gq_cfcov_33_ar"));}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(indices[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + vars__.push_back( + rvalue(indexing_mat, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "indexing_mat"));}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + vars__.push_back( + rvalue(idx_res1, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res1"));}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + vars__.push_back( + rvalue(idx_res2, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res2"));}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + vars__.push_back( + rvalue(idx_res3, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res3"));}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + vars__.push_back( + rvalue(idx_res11, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res11"));}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + vars__.push_back( + rvalue(idx_res21, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res21"));}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + vars__.push_back( + rvalue(idx_res31, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + "idx_res31"));}}} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back(idx_res4[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + vars__.push_back(idx_res5[(sym2__ - 1)][(sym1__ - 1)]);}} + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - -} - -struct algebra_system_functor__ { -template -Eigen::Matrix::type, -1, 1> -operator()(const Eigen::Matrix& x, - const Eigen::Matrix& y, const std::vector& dat, - const std::vector& dat_int, std::ostream* pstream__) const -{ -return algebra_system(x, y, dat, dat_int, pstream__); -} -}; - - -class motherHOF_model : public model_base_crtp { - - private: - int pos__; - int T; - std::vector y0_d; - double t0; - std::vector ts; - std::vector theta_d; - std::vector x; - std::vector x_int; - std::vector x_d_r; - std::vector x_d_i; - Eigen::Matrix shared_params_d; - std::vector> job_params_d; - std::vector> data_r; - std::vector> data_i; - - public: - ~motherHOF_model() { } - - std::string model_name() const { return "motherHOF_model"; } - - motherHOF_model(stan::io::var_context& context__, - unsigned int random_seed__ = 0, - std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + } + } // write_array() + + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { typedef double local_scalar_t__; - boost::ecuyer1988 base_rng__ = - stan::services::util::create_rng(random_seed__, 0); - (void) base_rng__; // suppress unused var warning - static const char* function__ = "motherHOF_model_namespace::motherHOF_model"; - (void) function__; // suppress unused var warning + vars__.resize(0); + vars__.reserve(num_params_r__); try { + int pos__; pos__ = 1; - context__.validate_dims("data initialization","T","int", - context__.to_vec()); + double p_real; - current_statement__ = 99; - T = context__.vals_i("T")[(1 - 1)]; - current_statement__ = 100; - validate_non_negative_index("y0_d", "2", 2); - context__.validate_dims("data initialization","y0_d","double", - context__.to_vec(2)); - y0_d = std::vector(2, 0); + current_statement__ = 1; + p_real = context__.vals_r("p_real")[(1 - 1)]; + current_statement__ = 2; + validate_non_negative_index("offset_multiplier", "5", 5); + std::vector offset_multiplier; + offset_multiplier = std::vector(5, 0); - current_statement__ = 100; - assign(y0_d, nil_index_list(), context__.vals_r("y0_d"), - "assigning variable y0_d"); - context__.validate_dims("data initialization","t0","double", - context__.to_vec()); + current_statement__ = 2; + assign(offset_multiplier, nil_index_list(), + context__.vals_r("offset_multiplier"), + "assigning variable offset_multiplier"); + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 2; + assign(offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_free(offset_multiplier[(sym1__ - 1)], + 1, 2), "assigning variable offset_multiplier");} + current_statement__ = 3; + validate_non_negative_index("no_offset_multiplier", "5", 5); + std::vector no_offset_multiplier; + no_offset_multiplier = std::vector(5, 0); - current_statement__ = 101; - t0 = context__.vals_r("t0")[(1 - 1)]; - current_statement__ = 102; - validate_non_negative_index("ts", "T", T); - context__.validate_dims("data initialization","ts","double", - context__.to_vec(T)); - ts = std::vector(T, 0); + current_statement__ = 3; + assign(no_offset_multiplier, nil_index_list(), + context__.vals_r("no_offset_multiplier"), + "assigning variable no_offset_multiplier"); + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 3; + assign(no_offset_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_free( + no_offset_multiplier[(sym1__ - 1)], 0, 2), + "assigning variable no_offset_multiplier");} + current_statement__ = 4; + validate_non_negative_index("offset_no_multiplier", "5", 5); + std::vector offset_no_multiplier; + offset_no_multiplier = std::vector(5, 0); + + current_statement__ = 4; + assign(offset_no_multiplier, nil_index_list(), + context__.vals_r("offset_no_multiplier"), + "assigning variable offset_no_multiplier"); + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + current_statement__ = 4; + assign(offset_no_multiplier, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::offset_multiplier_free( + offset_no_multiplier[(sym1__ - 1)], 3, 1), + "assigning variable offset_no_multiplier");} + current_statement__ = 5; + validate_non_negative_index("p_real_1d_ar", "N", N); + std::vector p_real_1d_ar; + p_real_1d_ar = std::vector(N, 0); + + current_statement__ = 5; + assign(p_real_1d_ar, nil_index_list(), + context__.vals_r("p_real_1d_ar"), "assigning variable p_real_1d_ar"); + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 5; + assign(p_real_1d_ar, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_free(p_real_1d_ar[(sym1__ - 1)], 0), + "assigning variable p_real_1d_ar");} + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "N", N); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "M", M); + current_statement__ = 6; + validate_non_negative_index("p_real_3d_ar", "K", K); + std::vector>> p_real_3d_ar; + p_real_3d_ar = std::vector>>(N, std::vector>(M, std::vector(K, 0))); + + { + std::vector p_real_3d_ar_flat__; + current_statement__ = 6; + assign(p_real_3d_ar_flat__, nil_index_list(), + context__.vals_r("p_real_3d_ar"), + "assigning variable p_real_3d_ar_flat__"); + current_statement__ = 6; + pos__ = 1; + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + p_real_3d_ar_flat__[(pos__ - 1)], + "assigning variable p_real_3d_ar"); + current_statement__ = 6; + pos__ = (pos__ + 1);}}} + } + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 6; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 6; + assign(p_real_3d_ar, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::lb_free( + p_real_3d_ar[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)], 0), + "assigning variable p_real_3d_ar");}}} + current_statement__ = 7; + validate_non_negative_index("p_vec", "N", N); + Eigen::Matrix p_vec; + p_vec = Eigen::Matrix(N); + + { + std::vector p_vec_flat__; + current_statement__ = 7; + assign(p_vec_flat__, nil_index_list(), context__.vals_r("p_vec"), + "assigning variable p_vec_flat__"); + current_statement__ = 7; + pos__ = 1; + current_statement__ = 7; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 7; + assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), + p_vec_flat__[(pos__ - 1)], "assigning variable p_vec"); + current_statement__ = 7; + pos__ = (pos__ + 1);} + } + current_statement__ = 7; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 7; + assign(p_vec, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::lb_free(p_vec[(sym1__ - 1)], 0), + "assigning variable p_vec");} + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + current_statement__ = 8; + validate_non_negative_index("p_1d_vec", "N", N); + std::vector> p_1d_vec; + p_1d_vec = std::vector>(N, Eigen::Matrix(N)); + + { + std::vector p_1d_vec_flat__; + current_statement__ = 8; + assign(p_1d_vec_flat__, nil_index_list(), + context__.vals_r("p_1d_vec"), "assigning variable p_1d_vec_flat__"); + current_statement__ = 8; + pos__ = 1; + current_statement__ = 8; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 8; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 8; + assign(p_1d_vec, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + p_1d_vec_flat__[(pos__ - 1)], "assigning variable p_1d_vec"); + current_statement__ = 8; + pos__ = (pos__ + 1);}} + } + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "M", M); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "K", K); + current_statement__ = 9; + validate_non_negative_index("p_3d_vec", "N", N); + std::vector>>> p_3d_vec; + p_3d_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); + + { + std::vector p_3d_vec_flat__; + current_statement__ = 9; + assign(p_3d_vec_flat__, nil_index_list(), + context__.vals_r("p_3d_vec"), "assigning variable p_3d_vec_flat__"); + current_statement__ = 9; + pos__ = 1; + current_statement__ = 9; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 9; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 9; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 9; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 9; + assign(p_3d_vec, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + p_3d_vec_flat__[(pos__ - 1)], "assigning variable p_3d_vec"); + current_statement__ = 9; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 10; + validate_non_negative_index("p_row_vec", "N", N); + Eigen::Matrix p_row_vec; + p_row_vec = Eigen::Matrix(N); - current_statement__ = 102; - assign(ts, nil_index_list(), context__.vals_r("ts"), - "assigning variable ts"); - current_statement__ = 103; - validate_non_negative_index("theta_d", "1", 1); - context__.validate_dims("data initialization","theta_d","double", - context__.to_vec(1)); - theta_d = std::vector(1, 0); + { + std::vector p_row_vec_flat__; + current_statement__ = 10; + assign(p_row_vec_flat__, nil_index_list(), + context__.vals_r("p_row_vec"), + "assigning variable p_row_vec_flat__"); + current_statement__ = 10; + pos__ = 1; + current_statement__ = 10; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 10; + assign(p_row_vec, cons_list(index_uni(sym1__), nil_index_list()), + p_row_vec_flat__[(pos__ - 1)], "assigning variable p_row_vec"); + current_statement__ = 10; + pos__ = (pos__ + 1);} + } + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + current_statement__ = 11; + validate_non_negative_index("p_1d_row_vec", "N", N); + std::vector> p_1d_row_vec; + p_1d_row_vec = std::vector>(N, Eigen::Matrix(N)); - current_statement__ = 103; - assign(theta_d, nil_index_list(), context__.vals_r("theta_d"), - "assigning variable theta_d"); - current_statement__ = 104; - validate_non_negative_index("x", "0", 0); - context__.validate_dims("data initialization","x","double", - context__.to_vec(0)); - x = std::vector(0, 0); + { + std::vector p_1d_row_vec_flat__; + current_statement__ = 11; + assign(p_1d_row_vec_flat__, nil_index_list(), + context__.vals_r("p_1d_row_vec"), + "assigning variable p_1d_row_vec_flat__"); + current_statement__ = 11; + pos__ = 1; + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 11; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 11; + assign(p_1d_row_vec, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + p_1d_row_vec_flat__[(pos__ - 1)], + "assigning variable p_1d_row_vec"); + current_statement__ = 11; + pos__ = (pos__ + 1);}} + } + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "M", M); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "K", K); + current_statement__ = 12; + validate_non_negative_index("p_3d_row_vec", "N", N); + std::vector>>> p_3d_row_vec; + p_3d_row_vec = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); - current_statement__ = 104; - assign(x, nil_index_list(), context__.vals_r("x"), - "assigning variable x"); - current_statement__ = 105; - validate_non_negative_index("x_int", "0", 0); - context__.validate_dims("data initialization","x_int","int", - context__.to_vec(0)); - x_int = std::vector(0, 0); + { + std::vector p_3d_row_vec_flat__; + current_statement__ = 12; + assign(p_3d_row_vec_flat__, nil_index_list(), + context__.vals_r("p_3d_row_vec"), + "assigning variable p_3d_row_vec_flat__"); + current_statement__ = 12; + pos__ = 1; + current_statement__ = 12; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 12; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 12; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 12; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 12; + assign(p_3d_row_vec, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + p_3d_row_vec_flat__[(pos__ - 1)], + "assigning variable p_3d_row_vec"); + current_statement__ = 12; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "4", 4); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "5", 5); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "2", 2); + current_statement__ = 13; + validate_non_negative_index("p_ar_mat", "3", 3); + std::vector>> p_ar_mat; + p_ar_mat = std::vector>>(4, std::vector>(5, Eigen::Matrix(2, 3))); - current_statement__ = 105; - assign(x_int, nil_index_list(), context__.vals_i("x_int"), - "assigning variable x_int"); - current_statement__ = 106; - validate_non_negative_index("x_d_r", "0", 0); - context__.validate_dims("data initialization","x_d_r","double", - context__.to_vec(0)); - x_d_r = std::vector(0, 0); + { + std::vector p_ar_mat_flat__; + current_statement__ = 13; + assign(p_ar_mat_flat__, nil_index_list(), + context__.vals_r("p_ar_mat"), "assigning variable p_ar_mat_flat__"); + current_statement__ = 13; + pos__ = 1; + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + current_statement__ = 13; + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + current_statement__ = 13; + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + p_ar_mat_flat__[(pos__ - 1)], "assigning variable p_ar_mat"); + current_statement__ = 13; + pos__ = (pos__ + 1);}}}} + } + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 13; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 13; + for (size_t sym3__ = 1; sym3__ <= 2; ++sym3__) { + current_statement__ = 13; + for (size_t sym4__ = 1; sym4__ <= 3; ++sym4__) { + current_statement__ = 13; + assign(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + stan::math::lub_free( + rvalue(p_ar_mat, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym4__), nil_index_list())))), + "p_ar_mat"), 0, 1), "assigning variable p_ar_mat");}}}} + current_statement__ = 14; + validate_positive_index("p_simplex", "N", N); + Eigen::Matrix p_simplex; + p_simplex = Eigen::Matrix(N); - current_statement__ = 106; - assign(x_d_r, nil_index_list(), context__.vals_r("x_d_r"), - "assigning variable x_d_r"); - current_statement__ = 107; - validate_non_negative_index("x_d_i", "0", 0); - context__.validate_dims("data initialization","x_d_i","int", - context__.to_vec(0)); - x_d_i = std::vector(0, 0); + { + std::vector p_simplex_flat__; + current_statement__ = 14; + assign(p_simplex_flat__, nil_index_list(), + context__.vals_r("p_simplex"), + "assigning variable p_simplex_flat__"); + current_statement__ = 14; + pos__ = 1; + current_statement__ = 14; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 14; + assign(p_simplex, cons_list(index_uni(sym1__), nil_index_list()), + p_simplex_flat__[(pos__ - 1)], "assigning variable p_simplex"); + current_statement__ = 14; + pos__ = (pos__ + 1);} + } + current_statement__ = 14; + assign(p_simplex, nil_index_list(), + stan::math::simplex_free(p_simplex), "assigning variable p_simplex"); + current_statement__ = 15; + validate_non_negative_index("p_1d_simplex", "N", N); + current_statement__ = 15; + validate_positive_index("p_1d_simplex", "N", N); + std::vector> p_1d_simplex; + p_1d_simplex = std::vector>(N, Eigen::Matrix(N)); - current_statement__ = 107; - assign(x_d_i, nil_index_list(), context__.vals_i("x_d_i"), - "assigning variable x_d_i"); - current_statement__ = 108; - validate_non_negative_index("shared_params_d", "3", 3); - context__.validate_dims("data initialization","shared_params_d", - "double",context__.to_vec(3)); - shared_params_d = Eigen::Matrix(3); + { + std::vector p_1d_simplex_flat__; + current_statement__ = 15; + assign(p_1d_simplex_flat__, nil_index_list(), + context__.vals_r("p_1d_simplex"), + "assigning variable p_1d_simplex_flat__"); + current_statement__ = 15; + pos__ = 1; + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + current_statement__ = 15; + assign(p_1d_simplex, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + p_1d_simplex_flat__[(pos__ - 1)], + "assigning variable p_1d_simplex"); + current_statement__ = 15; + pos__ = (pos__ + 1);}} + } + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 15; + assign(p_1d_simplex, cons_list(index_uni(sym1__), nil_index_list()), + stan::math::simplex_free(p_1d_simplex[(sym1__ - 1)]), + "assigning variable p_1d_simplex");} + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "N", N); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "M", M); + current_statement__ = 16; + validate_non_negative_index("p_3d_simplex", "K", K); + current_statement__ = 16; + validate_positive_index("p_3d_simplex", "N", N); + std::vector>>> p_3d_simplex; + p_3d_simplex = std::vector>>>(N, std::vector>>(M, std::vector>(K, Eigen::Matrix(N)))); { - std::vector shared_params_d_flat__; - current_statement__ = 108; - assign(shared_params_d_flat__, nil_index_list(), - context__.vals_r("shared_params_d"), - "assigning variable shared_params_d_flat__"); - current_statement__ = 108; + std::vector p_3d_simplex_flat__; + current_statement__ = 16; + assign(p_3d_simplex_flat__, nil_index_list(), + context__.vals_r("p_3d_simplex"), + "assigning variable p_3d_simplex_flat__"); + current_statement__ = 16; pos__ = 1; - current_statement__ = 108; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 108; - assign(shared_params_d, - cons_list(index_uni(sym1__), nil_index_list()), - shared_params_d_flat__[(pos__ - 1)], - "assigning variable shared_params_d"); - current_statement__ = 108; - pos__ = (pos__ + 1);} + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + current_statement__ = 16; + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + current_statement__ = 16; + assign(p_3d_simplex, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + p_3d_simplex_flat__[(pos__ - 1)], + "assigning variable p_3d_simplex"); + current_statement__ = 16; + pos__ = (pos__ + 1);}}}} } - current_statement__ = 109; - validate_non_negative_index("job_params_d", "3", 3); - current_statement__ = 109; - validate_non_negative_index("job_params_d", "3", 3); - context__.validate_dims("data initialization","job_params_d","double", - context__.to_vec(3, 3)); - job_params_d = std::vector>(3, Eigen::Matrix(3)); + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + current_statement__ = 16; + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + current_statement__ = 16; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 16; + assign(p_3d_simplex, + cons_list(index_uni(sym1__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym3__), nil_index_list()))), + stan::math::simplex_free( + p_3d_simplex[(sym1__ - 1)][(sym2__ - 1)][(sym3__ - 1)]), + "assigning variable p_3d_simplex");}}} + current_statement__ = 17; + check_greater_or_equal("cholesky_factor_cov p_cfcov_54", + "num rows (must be greater or equal to num cols)", + 5, 4); + current_statement__ = 17; + validate_non_negative_index("p_cfcov_54", "4", 4); + Eigen::Matrix p_cfcov_54; + p_cfcov_54 = Eigen::Matrix(5, 4); { - std::vector job_params_d_flat__; - current_statement__ = 109; - assign(job_params_d_flat__, nil_index_list(), - context__.vals_r("job_params_d"), - "assigning variable job_params_d_flat__"); - current_statement__ = 109; + std::vector p_cfcov_54_flat__; + current_statement__ = 17; + assign(p_cfcov_54_flat__, nil_index_list(), + context__.vals_r("p_cfcov_54"), + "assigning variable p_cfcov_54_flat__"); + current_statement__ = 17; pos__ = 1; - current_statement__ = 109; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 109; - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 109; - assign(job_params_d, + current_statement__ = 17; + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + current_statement__ = 17; + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + current_statement__ = 17; + assign(p_cfcov_54, cons_list(index_uni(sym2__), cons_list(index_uni(sym1__), nil_index_list())), - job_params_d_flat__[(pos__ - 1)], - "assigning variable job_params_d"); - current_statement__ = 109; + p_cfcov_54_flat__[(pos__ - 1)], "assigning variable p_cfcov_54"); + current_statement__ = 17; pos__ = (pos__ + 1);}} } - current_statement__ = 110; - validate_non_negative_index("data_r", "3", 3); - current_statement__ = 110; - validate_non_negative_index("data_r", "3", 3); - context__.validate_dims("data initialization","data_r","double", - context__.to_vec(3, 3)); - data_r = std::vector>(3, std::vector(3, 0)); + current_statement__ = 17; + validate_non_negative_index("p_cfcov_54_free__", + "((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))", + ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4))); + Eigen::Matrix p_cfcov_54_free__; + p_cfcov_54_free__ = Eigen::Matrix(((((4 * (4 - 1)) / 2) + + 4) + + ((5 - 4) * 4))); + + current_statement__ = 17; + assign(p_cfcov_54_free__, nil_index_list(), + stan::math::cholesky_factor_free(p_cfcov_54), + "assigning variable p_cfcov_54_free__"); + current_statement__ = 18; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 18; + validate_non_negative_index("p_cfcov_33", "3", 3); + Eigen::Matrix p_cfcov_33; + p_cfcov_33 = Eigen::Matrix(3, 3); { - std::vector data_r_flat__; - current_statement__ = 110; - assign(data_r_flat__, nil_index_list(), context__.vals_r("data_r"), - "assigning variable data_r_flat__"); - current_statement__ = 110; + std::vector p_cfcov_33_flat__; + current_statement__ = 18; + assign(p_cfcov_33_flat__, nil_index_list(), + context__.vals_r("p_cfcov_33"), + "assigning variable p_cfcov_33_flat__"); + current_statement__ = 18; pos__ = 1; - current_statement__ = 110; + current_statement__ = 18; for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 110; + current_statement__ = 18; for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 110; - assign(data_r, + current_statement__ = 18; + assign(p_cfcov_33, cons_list(index_uni(sym2__), cons_list(index_uni(sym1__), nil_index_list())), - data_r_flat__[(pos__ - 1)], "assigning variable data_r"); - current_statement__ = 110; + p_cfcov_33_flat__[(pos__ - 1)], "assigning variable p_cfcov_33"); + current_statement__ = 18; pos__ = (pos__ + 1);}} } - current_statement__ = 111; - validate_non_negative_index("data_i", "3", 3); - current_statement__ = 111; - validate_non_negative_index("data_i", "3", 3); - context__.validate_dims("data initialization","data_i","int", - context__.to_vec(3, 3)); - data_i = std::vector>(3, std::vector(3, 0)); + current_statement__ = 18; + validate_non_negative_index("p_cfcov_33_free__", + "((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))", + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); + Eigen::Matrix p_cfcov_33_free__; + p_cfcov_33_free__ = Eigen::Matrix(((((3 * (3 - 1)) / 2) + + 3) + + ((3 - 3) * 3))); + + current_statement__ = 18; + assign(p_cfcov_33_free__, nil_index_list(), + stan::math::cholesky_factor_free(p_cfcov_33), + "assigning variable p_cfcov_33_free__"); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "K", K); + current_statement__ = 19; + check_greater_or_equal("cholesky_factor_cov p_cfcov_33_ar", + "num rows (must be greater or equal to num cols)", + 3, 3); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar", "3", 3); + std::vector> p_cfcov_33_ar; + p_cfcov_33_ar = std::vector>(K, Eigen::Matrix(3, 3)); { - std::vector data_i_flat__; - current_statement__ = 111; - assign(data_i_flat__, nil_index_list(), context__.vals_i("data_i"), - "assigning variable data_i_flat__"); - current_statement__ = 111; + std::vector p_cfcov_33_ar_flat__; + current_statement__ = 19; + assign(p_cfcov_33_ar_flat__, nil_index_list(), + context__.vals_r("p_cfcov_33_ar"), + "assigning variable p_cfcov_33_ar_flat__"); + current_statement__ = 19; pos__ = 1; - current_statement__ = 111; + current_statement__ = 19; for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 111; + current_statement__ = 19; for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 111; - assign(data_i, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - data_i_flat__[(pos__ - 1)], "assigning variable data_i"); - current_statement__ = 111; - pos__ = (pos__ + 1);}} + current_statement__ = 19; + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + current_statement__ = 19; + assign(p_cfcov_33_ar, + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list()))), + p_cfcov_33_ar_flat__[(pos__ - 1)], + "assigning variable p_cfcov_33_ar"); + current_statement__ = 19; + pos__ = (pos__ + 1);}}} } - current_statement__ = 99; - current_statement__ = 99; - check_greater_or_equal(function__, "T", T, 1); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar_free__", "K", K); + current_statement__ = 19; + validate_non_negative_index("p_cfcov_33_ar_free__", + "((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))", + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3))); + std::vector> p_cfcov_33_ar_free__; + p_cfcov_33_ar_free__ = std::vector>(K, Eigen::Matrix( + ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)))); + + current_statement__ = 19; + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + current_statement__ = 19; + assign(p_cfcov_33_ar_free__, + cons_list(index_uni(sym1__), nil_index_list()), + stan::math::cholesky_factor_free(p_cfcov_33_ar[(sym1__ - 1)]), + "assigning variable p_cfcov_33_ar_free__");} + current_statement__ = 20; + validate_non_negative_index("x_p", "2", 2); + Eigen::Matrix x_p; + x_p = Eigen::Matrix(2); + + { + std::vector x_p_flat__; + current_statement__ = 20; + assign(x_p_flat__, nil_index_list(), context__.vals_r("x_p"), + "assigning variable x_p_flat__"); + current_statement__ = 20; + pos__ = 1; + current_statement__ = 20; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 20; + assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), + x_p_flat__[(pos__ - 1)], "assigning variable x_p"); + current_statement__ = 20; + pos__ = (pos__ + 1);} + } + current_statement__ = 21; + validate_non_negative_index("y_p", "2", 2); + Eigen::Matrix y_p; + y_p = Eigen::Matrix(2); + + { + std::vector y_p_flat__; + current_statement__ = 21; + assign(y_p_flat__, nil_index_list(), context__.vals_r("y_p"), + "assigning variable y_p_flat__"); + current_statement__ = 21; + pos__ = 1; + current_statement__ = 21; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 21; + assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), + y_p_flat__[(pos__ - 1)], "assigning variable y_p"); + current_statement__ = 21; + pos__ = (pos__ + 1);} + } + vars__.push_back(p_real); + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(offset_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(no_offset_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + vars__.push_back(offset_no_multiplier[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_real_1d_ar[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + vars__.push_back( + p_real_3d_ar[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][(sym1__ - + 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + vars__.push_back(p_row_vec[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_row_vec[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_row_vec[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + vars__.push_back( + rvalue(p_ar_mat, + cons_list(index_uni(sym4__), + cons_list(index_uni(sym3__), + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())))), + "p_ar_mat"));}}}} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + vars__.push_back(p_simplex[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + vars__.push_back(p_1d_simplex[(sym2__ - 1)][(sym1__ - 1)]);}} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + vars__.push_back( + p_3d_simplex[(sym4__ - 1)][(sym3__ - 1)][(sym2__ - 1)][ + (sym1__ - 1)]);}}}} + for (size_t sym1__ = 1; + sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { + vars__.push_back(p_cfcov_54_free__[(sym1__ - 1)]);} + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + vars__.push_back(p_cfcov_33_free__[(sym1__ - 1)]);} + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + vars__.push_back(p_cfcov_33_ar_free__[(sym2__ - 1)][(sym1__ - 1)]); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(x_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y_p[(sym1__ - 1)]);} } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } - num_params_r__ = 0U; + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("p_real"); + names__.push_back("offset_multiplier"); + names__.push_back("no_offset_multiplier"); + names__.push_back("offset_no_multiplier"); + names__.push_back("p_real_1d_ar"); + names__.push_back("p_real_3d_ar"); + names__.push_back("p_vec"); + names__.push_back("p_1d_vec"); + names__.push_back("p_3d_vec"); + names__.push_back("p_row_vec"); + names__.push_back("p_1d_row_vec"); + names__.push_back("p_3d_row_vec"); + names__.push_back("p_ar_mat"); + names__.push_back("p_simplex"); + names__.push_back("p_1d_simplex"); + names__.push_back("p_3d_simplex"); + names__.push_back("p_cfcov_54"); + names__.push_back("p_cfcov_33"); + names__.push_back("p_cfcov_33_ar"); + names__.push_back("x_p"); + names__.push_back("y_p"); + names__.push_back("tp_real_1d_ar"); + names__.push_back("tp_real_3d_ar"); + names__.push_back("tp_vec"); + names__.push_back("tp_1d_vec"); + names__.push_back("tp_3d_vec"); + names__.push_back("tp_row_vec"); + names__.push_back("tp_1d_row_vec"); + names__.push_back("tp_3d_row_vec"); + names__.push_back("tp_ar_mat"); + names__.push_back("tp_simplex"); + names__.push_back("tp_1d_simplex"); + names__.push_back("tp_3d_simplex"); + names__.push_back("tp_cfcov_54"); + names__.push_back("tp_cfcov_33"); + names__.push_back("tp_cfcov_33_ar"); + names__.push_back("theta_p"); + names__.push_back("gq_r1"); + names__.push_back("gq_r2"); + names__.push_back("gq_real_1d_ar"); + names__.push_back("gq_real_3d_ar"); + names__.push_back("gq_vec"); + names__.push_back("gq_1d_vec"); + names__.push_back("gq_3d_vec"); + names__.push_back("gq_row_vec"); + names__.push_back("gq_1d_row_vec"); + names__.push_back("gq_3d_row_vec"); + names__.push_back("gq_ar_mat"); + names__.push_back("gq_simplex"); + names__.push_back("gq_1d_simplex"); + names__.push_back("gq_3d_simplex"); + names__.push_back("gq_cfcov_54"); + names__.push_back("gq_cfcov_33"); + names__.push_back("gq_cfcov_33_ar"); + names__.push_back("indices"); + names__.push_back("indexing_mat"); + names__.push_back("idx_res1"); + names__.push_back("idx_res2"); + names__.push_back("idx_res3"); + names__.push_back("idx_res11"); + names__.push_back("idx_res21"); + names__.push_back("idx_res31"); + names__.push_back("idx_res4"); + names__.push_back("idx_res5"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(4); + + dims__.push_back(5); + + dims__.push_back(2); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(K); + + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(4); + + dims__.push_back(5); + + dims__.push_back(2); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); - try { - current_statement__ = 1; - validate_non_negative_index("y0_p", "2", 2); - num_params_r__ += 2; - current_statement__ = 2; - validate_non_negative_index("theta_p", "1", 1); - num_params_r__ += 1; - current_statement__ = 3; - validate_non_negative_index("x_p", "1", 1); - num_params_r__ += 1; - current_statement__ = 4; - validate_non_negative_index("x_p_v", "2", 2); - num_params_r__ += 2; - current_statement__ = 5; - validate_non_negative_index("shared_params_p", "3", 3); - num_params_r__ += 3; - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - num_params_r__ += 3 * 3; - num_params_r__ += 1; - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - } - template - T__ log_prob(std::vector& params_r__, std::vector& params_i__, - std::ostream* pstream__ = 0) const { - typedef T__ local_scalar_t__; - T__ lp__(0.0); - stan::math::accumulator lp_accum__; - static const char* function__ = "motherHOF_model_namespace::log_prob"; -(void) function__; // suppress unused var warning - - stan::io::reader in__(params_r__, params_i__); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); - try { - current_statement__ = 1; - validate_non_negative_index("y0_p", "2", 2); - std::vector y0_p; - y0_p = std::vector(2, 0); - - current_statement__ = 1; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 1; - assign(y0_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable y0_p");} - current_statement__ = 2; - validate_non_negative_index("theta_p", "1", 1); - std::vector theta_p; - theta_p = std::vector(1, 0); - - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - current_statement__ = 2; - assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable theta_p");} - current_statement__ = 3; - validate_non_negative_index("x_p", "1", 1); - std::vector x_p; - x_p = std::vector(1, 0); - - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - current_statement__ = 3; - assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable x_p");} - current_statement__ = 4; - validate_non_negative_index("x_p_v", "2", 2); - Eigen::Matrix x_p_v; - x_p_v = Eigen::Matrix(2); - - current_statement__ = 4; - x_p_v = in__.vector(2); - current_statement__ = 5; - validate_non_negative_index("shared_params_p", "3", 3); - Eigen::Matrix shared_params_p; - shared_params_p = Eigen::Matrix(3); - - current_statement__ = 5; - shared_params_p = in__.vector(3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - std::vector> job_params_p; - job_params_p = std::vector>(3, Eigen::Matrix(3)); - - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 6; - assign(job_params_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(3), "assigning variable job_params_p");} - local_scalar_t__ x_r; - - current_statement__ = 7; - x_r = in__.scalar(); - local_scalar_t__ abc1_p; - - current_statement__ = 8; - abc1_p = std::numeric_limits::quiet_NaN(); - current_statement__ = 8; - abc1_p = 3; - local_scalar_t__ abc2_p; - - current_statement__ = 9; - abc2_p = std::numeric_limits::quiet_NaN(); - current_statement__ = 9; - abc2_p = map_rectfake(abc1_p, pstream__); - local_scalar_t__ abc3_p; - - current_statement__ = 10; - abc3_p = std::numeric_limits::quiet_NaN(); - current_statement__ = 10; - abc3_p = map_rectfake(12, pstream__); - current_statement__ = 11; - validate_non_negative_index("y_hat_tp1", "3", 3); - Eigen::Matrix y_hat_tp1; - y_hat_tp1 = Eigen::Matrix(3); - - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 11; - assign(y_hat_tp1, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp1");} - current_statement__ = 11; - assign(y_hat_tp1, nil_index_list(), - map_rect<1, foo_functor__>(shared_params_p, job_params_d, data_r, - data_i, pstream__), "assigning variable y_hat_tp1"); - current_statement__ = 12; - validate_non_negative_index("y_hat_tp2", "3", 3); - Eigen::Matrix y_hat_tp2; - y_hat_tp2 = Eigen::Matrix(3); - - current_statement__ = 12; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 12; - assign(y_hat_tp2, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp2");} - current_statement__ = 12; - assign(y_hat_tp2, nil_index_list(), - map_rect<2, foo_functor__>(shared_params_d, job_params_p, data_r, - data_i, pstream__), "assigning variable y_hat_tp2"); - current_statement__ = 13; - validate_non_negative_index("y_hat_tp3", "3", 3); - Eigen::Matrix y_hat_tp3; - y_hat_tp3 = Eigen::Matrix(3); - - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 13; - assign(y_hat_tp3, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp3");} - current_statement__ = 13; - assign(y_hat_tp3, nil_index_list(), - map_rect<3, foo_functor__>(shared_params_p, job_params_d, data_r, - data_i, pstream__), "assigning variable y_hat_tp3"); - current_statement__ = 14; - validate_non_negative_index("theta_p_as", "2", 2); - Eigen::Matrix theta_p_as; - theta_p_as = Eigen::Matrix(2); - - current_statement__ = 14; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 14; - assign(theta_p_as, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta_p_as");} - current_statement__ = 15; - validate_non_negative_index("x_v", "2", 2); - Eigen::Matrix x_v; - x_v = Eigen::Matrix(2); - - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 15; - assign(x_v, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable x_v"); - } - current_statement__ = 16; - validate_non_negative_index("y_v", "2", 2); - Eigen::Matrix y_v; - y_v = Eigen::Matrix(2); - - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 16; - assign(y_v, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable y_v"); - } - current_statement__ = 17; - validate_non_negative_index("y_p", "2", 2); - Eigen::Matrix y_p; - y_p = Eigen::Matrix(2); - - current_statement__ = 17; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 17; - assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable y_p"); - } - current_statement__ = 18; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 19; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 20; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_p, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 21; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 22; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 23; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 24; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - { - current_statement__ = 57; - validate_non_negative_index("y_hat", "T", T); - current_statement__ = 57; - validate_non_negative_index("y_hat", "2", 2); - std::vector> y_hat; - y_hat = std::vector>(T, std::vector(2, 0)); - - current_statement__ = 58; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 59; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 60; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 61; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, - x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 62; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, - x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 63; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, - x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 64; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 65; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 66; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 67; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 68; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 69; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 70; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 71; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 72; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_d, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 73; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_p, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 74; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_d, x, - x_int, pstream__), "assigning variable y_hat"); - current_statement__ = 75; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_p, x, - x_int, pstream__), "assigning variable y_hat"); - local_scalar_t__ y_1d; - - current_statement__ = 76; - y_1d = std::numeric_limits::quiet_NaN(); - current_statement__ = 76; - y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 77; - y_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 78; - y_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 79; - y_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 80; - y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 81; - y_1d = integrate_1d(integrand_functor__(), x_r, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 82; - y_1d = integrate_1d(integrand_functor__(), 0, x_r, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 83; - y_1d = integrate_1d(integrand_functor__(), x_r, x_r, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 84; - y_1d = integrate_1d(integrand_functor__(), x_r, 1, x_d_r, x_d_r, - x_d_i, pstream__); - current_statement__ = 85; - y_1d = integrate_1d(integrand_functor__(), 0, x_r, x_d_r, x_d_r, - x_d_i, pstream__); - current_statement__ = 86; - y_1d = integrate_1d(integrand_functor__(), x_r, x_r, x_d_r, x_d_r, - x_d_i, pstream__); - local_scalar_t__ z_1d; - - current_statement__ = 87; - z_1d = std::numeric_limits::quiet_NaN(); - current_statement__ = 87; - z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 88; - z_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 89; - z_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 90; - z_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 91; - z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 92; - z_1d = integrate_1d(integrand_functor__(), x_r, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 93; - z_1d = integrate_1d(integrand_functor__(), 0, x_r, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 94; - z_1d = integrate_1d(integrand_functor__(), x_r, x_r, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 95; - z_1d = integrate_1d(integrand_functor__(), x_r, 1, x_d_r, x_d_r, - x_d_i, pstream__, 1e-8); - current_statement__ = 96; - z_1d = integrate_1d(integrand_functor__(), 0, x_r, x_d_r, x_d_r, - x_d_i, pstream__, 1e-8); - current_statement__ = 97; - z_1d = integrate_1d(integrand_functor__(), x_r, x_r, x_d_r, x_d_r, - x_d_i, pstream__, 1e-8); - local_scalar_t__ abc_m; - - current_statement__ = 98; - abc_m = std::numeric_limits::quiet_NaN(); - current_statement__ = 98; - abc_m = map_rectfake(abc1_p, pstream__); - } - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); - } - lp_accum__.add(lp__); - return lp_accum__.sum(); - } // log_prob() + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(K); + + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); - template - void write_array(RNG& base_rng__, std::vector& params_r__, - std::vector& params_i__, std::vector& vars__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true, - std::ostream* pstream__ = 0) const { - typedef double local_scalar_t__; - vars__.resize(0); - stan::io::reader in__(params_r__, params_i__); - static const char* function__ = "motherHOF_model_namespace::write_array"; -(void) function__; // suppress unused var warning - - (void) function__; // suppress unused var warning - - double lp__ = 0.0; - (void) lp__; // dummy to suppress unused var warning - stan::math::accumulator lp_accum__; + dims__.push_back(K); - try { - current_statement__ = 1; - validate_non_negative_index("y0_p", "2", 2); - std::vector y0_p; - y0_p = std::vector(2, 0); - - current_statement__ = 1; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 1; - assign(y0_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable y0_p");} - current_statement__ = 2; - validate_non_negative_index("theta_p", "1", 1); - std::vector theta_p; - theta_p = std::vector(1, 0); - - current_statement__ = 2; - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - current_statement__ = 2; - assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable theta_p");} - current_statement__ = 3; - validate_non_negative_index("x_p", "1", 1); - std::vector x_p; - x_p = std::vector(1, 0); - - current_statement__ = 3; - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - current_statement__ = 3; - assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.scalar(), "assigning variable x_p");} - current_statement__ = 4; - validate_non_negative_index("x_p_v", "2", 2); - Eigen::Matrix x_p_v; - x_p_v = Eigen::Matrix(2); - - current_statement__ = 4; - x_p_v = in__.vector(2); - current_statement__ = 5; - validate_non_negative_index("shared_params_p", "3", 3); - Eigen::Matrix shared_params_p; - shared_params_p = Eigen::Matrix(3); - - current_statement__ = 5; - shared_params_p = in__.vector(3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - std::vector> job_params_p; - job_params_p = std::vector>(3, Eigen::Matrix(3)); - - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 6; - assign(job_params_p, cons_list(index_uni(sym1__), nil_index_list()), - in__.vector(3), "assigning variable job_params_p");} - double x_r; - - current_statement__ = 7; - x_r = in__.scalar(); - double abc1_p; - - current_statement__ = 8; - abc1_p = std::numeric_limits::quiet_NaN(); - double abc2_p; - - current_statement__ = 9; - abc2_p = std::numeric_limits::quiet_NaN(); - double abc3_p; - - current_statement__ = 10; - abc3_p = std::numeric_limits::quiet_NaN(); - current_statement__ = 11; - validate_non_negative_index("y_hat_tp1", "3", 3); - Eigen::Matrix y_hat_tp1; - y_hat_tp1 = Eigen::Matrix(3); - - current_statement__ = 11; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 11; - assign(y_hat_tp1, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp1");} - current_statement__ = 12; - validate_non_negative_index("y_hat_tp2", "3", 3); - Eigen::Matrix y_hat_tp2; - y_hat_tp2 = Eigen::Matrix(3); - - current_statement__ = 12; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 12; - assign(y_hat_tp2, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp2");} - current_statement__ = 13; - validate_non_negative_index("y_hat_tp3", "3", 3); - Eigen::Matrix y_hat_tp3; - y_hat_tp3 = Eigen::Matrix(3); - - current_statement__ = 13; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 13; - assign(y_hat_tp3, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_tp3");} - current_statement__ = 14; - validate_non_negative_index("theta_p_as", "2", 2); - Eigen::Matrix theta_p_as; - theta_p_as = Eigen::Matrix(2); - - current_statement__ = 14; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 14; - assign(theta_p_as, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable theta_p_as");} - current_statement__ = 15; - validate_non_negative_index("x_v", "2", 2); - Eigen::Matrix x_v; - x_v = Eigen::Matrix(2); - - current_statement__ = 15; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 15; - assign(x_v, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable x_v"); - } - current_statement__ = 16; - validate_non_negative_index("y_v", "2", 2); - Eigen::Matrix y_v; - y_v = Eigen::Matrix(2); - - current_statement__ = 16; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 16; - assign(y_v, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable y_v"); - } - current_statement__ = 17; - validate_non_negative_index("y_p", "2", 2); - Eigen::Matrix y_p; - y_p = Eigen::Matrix(2); - - current_statement__ = 17; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 17; - assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), "assigning variable y_p"); - } - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y0_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - vars__.push_back(theta_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - vars__.push_back(x_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(x_p_v[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(shared_params_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(4); + + dims__.push_back(5); + + dims__.push_back(2); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(N); + + dims__.push_back(M); + + dims__.push_back(K); + + dims__.push_back(N); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(K); + + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(5); + + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(4); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "p_real"); + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "offset_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "no_offset_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "offset_no_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_real_1d_ar" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "p_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "p_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_simplex" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + { + param_names__.push_back(std::string() + "p_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back(job_params_p[(sym2__ - 1)][(sym1__ - 1)]);}} - vars__.push_back(x_r); - if (logical_negation((primitive_value(emit_transformed_parameters__) || - primitive_value(emit_generated_quantities__)))) { - return ; - } - current_statement__ = 8; - abc1_p = 3; - current_statement__ = 9; - abc2_p = map_rectfake(abc1_p, pstream__); - current_statement__ = 10; - abc3_p = map_rectfake(12, pstream__); - current_statement__ = 11; - assign(y_hat_tp1, nil_index_list(), - map_rect<4, foo_functor__>(shared_params_p, job_params_d, data_r, - data_i, pstream__), "assigning variable y_hat_tp1"); - current_statement__ = 12; - assign(y_hat_tp2, nil_index_list(), - map_rect<5, foo_functor__>(shared_params_d, job_params_p, data_r, - data_i, pstream__), "assigning variable y_hat_tp2"); - current_statement__ = 13; - assign(y_hat_tp3, nil_index_list(), - map_rect<6, foo_functor__>(shared_params_p, job_params_d, data_r, - data_i, pstream__), "assigning variable y_hat_tp3"); - current_statement__ = 18; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 19; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 20; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_v, y_p, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 21; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 22; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - current_statement__ = 23; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, - pstream__), "assigning variable theta_p_as"); - current_statement__ = 24; - assign(theta_p_as, nil_index_list(), - algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, - pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); - vars__.push_back(abc1_p); - vars__.push_back(abc2_p); - vars__.push_back(abc3_p); - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(y_hat_tp1[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(y_hat_tp2[(sym1__ - 1)]);} + { + param_names__.push_back(std::string() + "p_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + { + param_names__.push_back(std::string() + "p_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + }} + if (emit_transformed_parameters__) { + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_real_1d_ar" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "tp_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(y_hat_tp3[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(theta_p_as[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(x_v[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y_v[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y_p[(sym1__ - 1)]);} - if (logical_negation(emit_generated_quantities__)) { - return ; - } - current_statement__ = 25; - validate_non_negative_index("y_hat", "T", T); - current_statement__ = 25; - validate_non_negative_index("y_hat", "2", 2); - std::vector> y_hat; - y_hat = std::vector>(T, std::vector(2, 0)); - - current_statement__ = 26; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 27; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 28; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 29; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 30; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 31; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 32; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 33; - assign(y_hat, nil_index_list(), - integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 34; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 35; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 36; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 37; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 38; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 39; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 40; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 41; - assign(y_hat, nil_index_list(), - integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); - current_statement__ = 42; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 43; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 44; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, - pstream__), "assigning variable y_hat"); - current_statement__ = 45; - assign(y_hat, nil_index_list(), - integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, - pstream__), "assigning variable y_hat"); - double y_1d; - - current_statement__ = 46; - y_1d = std::numeric_limits::quiet_NaN(); - current_statement__ = 46; - y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 47; - y_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 48; - y_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, - pstream__); - current_statement__ = 49; - y_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, - pstream__); - double z_1d; - - current_statement__ = 50; - z_1d = std::numeric_limits::quiet_NaN(); - current_statement__ = 50; - z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 51; - z_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 52; - z_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, - pstream__, 1e-8); - current_statement__ = 53; - z_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, - pstream__, 1e-8); - double abc1_gq; - - current_statement__ = 54; - abc1_gq = std::numeric_limits::quiet_NaN(); - current_statement__ = 54; - abc1_gq = map_rectfake(12, pstream__); - double abc2_gq; - - current_statement__ = 55; - abc2_gq = std::numeric_limits::quiet_NaN(); - current_statement__ = 55; - abc2_gq = map_rectfake(abc1_p, pstream__); - current_statement__ = 56; - validate_non_negative_index("y_hat_gq", "3", 3); - Eigen::Matrix y_hat_gq; - y_hat_gq = Eigen::Matrix(3); - - current_statement__ = 56; + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_simplex" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 56; - assign(y_hat_gq, cons_list(index_uni(sym1__), nil_index_list()), - std::numeric_limits::quiet_NaN(), - "assigning variable y_hat_gq");} - current_statement__ = 56; - assign(y_hat_gq, nil_index_list(), - map_rect<7, foo_functor__>(shared_params_d, job_params_d, data_r, - data_i, pstream__), "assigning variable y_hat_gq"); - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { - vars__.push_back(y_hat[(sym2__ - 1)][(sym1__ - 1)]);}} - vars__.push_back(y_1d); - vars__.push_back(z_1d); - vars__.push_back(abc1_gq); - vars__.push_back(abc2_gq); + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(y_hat_gq[(sym1__ - 1)]);} - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + { + param_names__.push_back(std::string() + "tp_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + }} } - } // write_array() - - void transform_inits(const stan::io::var_context& context__, - std::vector& params_i__, - std::vector& vars__, std::ostream* pstream__) const { - typedef double local_scalar_t__; - vars__.resize(0); - vars__.reserve(num_params_r__); - try { - int pos__; - - pos__ = 1; - current_statement__ = 1; - validate_non_negative_index("y0_p", "2", 2); - std::vector y0_p; - y0_p = std::vector(2, 0); - - current_statement__ = 1; - assign(y0_p, nil_index_list(), context__.vals_r("y0_p"), - "assigning variable y0_p"); - current_statement__ = 2; - validate_non_negative_index("theta_p", "1", 1); - std::vector theta_p; - theta_p = std::vector(1, 0); - - current_statement__ = 2; - assign(theta_p, nil_index_list(), context__.vals_r("theta_p"), - "assigning variable theta_p"); - current_statement__ = 3; - validate_non_negative_index("x_p", "1", 1); - std::vector x_p; - x_p = std::vector(1, 0); - - current_statement__ = 3; - assign(x_p, nil_index_list(), context__.vals_r("x_p"), - "assigning variable x_p"); - current_statement__ = 4; - validate_non_negative_index("x_p_v", "2", 2); - Eigen::Matrix x_p_v; - x_p_v = Eigen::Matrix(2); - - { - std::vector x_p_v_flat__; - current_statement__ = 4; - assign(x_p_v_flat__, nil_index_list(), context__.vals_r("x_p_v"), - "assigning variable x_p_v_flat__"); - current_statement__ = 4; - pos__ = 1; - current_statement__ = 4; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - current_statement__ = 4; - assign(x_p_v, cons_list(index_uni(sym1__), nil_index_list()), - x_p_v_flat__[(pos__ - 1)], "assigning variable x_p_v"); - current_statement__ = 4; - pos__ = (pos__ + 1);} - } - current_statement__ = 5; - validate_non_negative_index("shared_params_p", "3", 3); - Eigen::Matrix shared_params_p; - shared_params_p = Eigen::Matrix(3); - - { - std::vector shared_params_p_flat__; - current_statement__ = 5; - assign(shared_params_p_flat__, nil_index_list(), - context__.vals_r("shared_params_p"), - "assigning variable shared_params_p_flat__"); - current_statement__ = 5; - pos__ = 1; - current_statement__ = 5; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 5; - assign(shared_params_p, - cons_list(index_uni(sym1__), nil_index_list()), - shared_params_p_flat__[(pos__ - 1)], - "assigning variable shared_params_p"); - current_statement__ = 5; - pos__ = (pos__ + 1);} - } - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - current_statement__ = 6; - validate_non_negative_index("job_params_p", "3", 3); - std::vector> job_params_p; - job_params_p = std::vector>(3, Eigen::Matrix(3)); - - { - std::vector job_params_p_flat__; - current_statement__ = 6; - assign(job_params_p_flat__, nil_index_list(), - context__.vals_r("job_params_p"), - "assigning variable job_params_p_flat__"); - current_statement__ = 6; - pos__ = 1; - current_statement__ = 6; - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - current_statement__ = 6; + if (emit_generated_quantities__) { + param_names__.push_back(std::string() + "gq_r1"); + param_names__.push_back(std::string() + "gq_r2"); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_real_1d_ar" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "gq_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_simplex" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 5; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_cfcov_54" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - current_statement__ = 6; - assign(job_params_p, - cons_list(index_uni(sym2__), - cons_list(index_uni(sym1__), nil_index_list())), - job_params_p_flat__[(pos__ - 1)], - "assigning variable job_params_p"); - current_statement__ = 6; - pos__ = (pos__ + 1);}} - } - double x_r; - - current_statement__ = 7; - x_r = context__.vals_r("x_r")[(1 - 1)]; - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(y0_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - vars__.push_back(theta_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - vars__.push_back(x_p[(sym1__ - 1)]);} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - vars__.push_back(x_p_v[(sym1__ - 1)]);} + { + param_names__.push_back(std::string() + "gq_cfcov_33" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= K; ++sym3__) { + { + param_names__.push_back(std::string() + "gq_cfcov_33_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "indices" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "indexing_mat" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res1" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res2" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - vars__.push_back(shared_params_p[(sym1__ - 1)]);} + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res3" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res11" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res21" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - vars__.push_back(job_params_p[(sym2__ - 1)][(sym1__ - 1)]);}} - vars__.push_back(x_r); - } catch (const std::exception& e) { - stan::lang::rethrow_located(e, locations_array__[current_statement__]); - // Next line prevents compiler griping about no return - throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res31" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + param_names__.push_back(std::string() + "idx_res4" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + param_names__.push_back(std::string() + "idx_res5" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} } - } // transform_inits() - - void get_param_names(std::vector& names__) const { - - names__.resize(0); - names__.push_back("y0_p"); - names__.push_back("theta_p"); - names__.push_back("x_p"); - names__.push_back("x_p_v"); - names__.push_back("shared_params_p"); - names__.push_back("job_params_p"); - names__.push_back("x_r"); - names__.push_back("abc1_p"); - names__.push_back("abc2_p"); - names__.push_back("abc3_p"); - names__.push_back("y_hat_tp1"); - names__.push_back("y_hat_tp2"); - names__.push_back("y_hat_tp3"); - names__.push_back("theta_p_as"); - names__.push_back("x_v"); - names__.push_back("y_v"); - names__.push_back("y_p"); - names__.push_back("y_hat"); - names__.push_back("y_1d"); - names__.push_back("z_1d"); - names__.push_back("abc1_gq"); - names__.push_back("abc2_gq"); - names__.push_back("y_hat_gq"); - } // get_param_names() - - void get_dims(std::vector>& dimss__) const { - dimss__.resize(0); - std::vector dims__; - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(1); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(1); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(T); - - dims__.push_back(2); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dimss__.push_back(dims__); - dims__.resize(0); - dims__.push_back(3); - dimss__.push_back(dims__); - dims__.resize(0); - } // get_dims() + } // constrained_param_names() - void constrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + param_names__.push_back(std::string() + "p_real"); + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "offset_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "no_offset_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 5; ++sym1__) { + { + param_names__.push_back(std::string() + "offset_no_multiplier" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_real_1d_ar" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "p_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "p_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "p_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + param_names__.push_back(std::string() + "p_simplex" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { { - param_names__.push_back(std::string() + "y0_p" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "p_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "p_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + for (size_t sym1__ = 1; + sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { { - param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "p_cfcov_54" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { { - param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "p_cfcov_33" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { { - param_names__.push_back(std::string() + "x_p_v" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + param_names__.push_back(std::string() + "p_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { { - param_names__.push_back(std::string() + "shared_params_p" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "job_params_p" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} + param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); }} - param_names__.push_back(std::string() + "x_r"); if (emit_transformed_parameters__) { - param_names__.push_back(std::string() + "abc1_p"); - param_names__.push_back(std::string() + "abc2_p"); - param_names__.push_back(std::string() + "abc3_p"); - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp1" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "tp_real_1d_ar" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "tp_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "tp_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp2" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} }} for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp3" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + param_names__.push_back(std::string() + "tp_simplex" + '.' + std::to_string(sym1__)); }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { { - param_names__.push_back(std::string() + "theta_p_as" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { { - param_names__.push_back(std::string() + "x_v" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "tp_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; + sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { + { + param_names__.push_back(std::string() + "tp_cfcov_54" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + { + param_names__.push_back(std::string() + "tp_cfcov_33" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { { - param_names__.push_back(std::string() + "y_v" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + param_names__.push_back(std::string() + "tp_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} }} for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { { - param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + }} + } + + if (emit_generated_quantities__) { + param_names__.push_back(std::string() + "gq_r1"); + param_names__.push_back(std::string() + "gq_r2"); + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_real_1d_ar" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= K; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= M; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= N; ++sym3__) { + { + param_names__.push_back(std::string() + "gq_real_3d_ar" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + param_names__.push_back(std::string() + "gq_row_vec" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_row_vec" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= N; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_row_vec" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= 4; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_ar_mat" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + param_names__.push_back(std::string() + "gq_simplex" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= N; ++sym2__) { + { + param_names__.push_back(std::string() + "gq_1d_simplex" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + for (size_t sym1__ = 1; sym1__ <= (N - 1); ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= M; ++sym3__) { + { + for (size_t sym4__ = 1; sym4__ <= N; ++sym4__) { + { + param_names__.push_back(std::string() + "gq_3d_simplex" + '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + }} + }} + for (size_t sym1__ = 1; + sym1__ <= ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)); ++sym1__) { + { + param_names__.push_back(std::string() + "gq_cfcov_54" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { + { + param_names__.push_back(std::string() + "gq_cfcov_33" + '.' + std::to_string(sym1__)); }} - } - - if (emit_generated_quantities__) { - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; + sym1__ <= ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)); ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { + for (size_t sym2__ = 1; sym2__ <= K; ++sym2__) { { - param_names__.push_back(std::string() + "y_hat" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "gq_cfcov_33_ar" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); }} }} - param_names__.push_back(std::string() + "y_1d"); - param_names__.push_back(std::string() + "z_1d"); - param_names__.push_back(std::string() + "abc1_gq"); - param_names__.push_back(std::string() + "abc2_gq"); for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_gq" + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "indices" + '.' + std::to_string(sym1__)); }} - } - - } // constrained_param_names() - - void unconstrained_param_names(std::vector& param_names__, - bool emit_transformed_parameters__ = true, - bool emit_generated_quantities__ = true) const { - - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - param_names__.push_back(std::string() + "y0_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - { - param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { - { - param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { - { - param_names__.push_back(std::string() + "x_p_v" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - param_names__.push_back(std::string() + "shared_params_p" + '.' + std::to_string(sym1__)); - }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { - { - for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { - { - param_names__.push_back(std::string() + "job_params_p" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); - }} - }} - param_names__.push_back(std::string() + "x_r"); - if (emit_transformed_parameters__) { - param_names__.push_back(std::string() + "abc1_p"); - param_names__.push_back(std::string() + "abc2_p"); - param_names__.push_back(std::string() + "abc3_p"); - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp1" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "indexing_mat" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp2" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res1" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_tp3" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res2" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { { - param_names__.push_back(std::string() + "theta_p_as" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res3" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - param_names__.push_back(std::string() + "x_v" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res11" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - param_names__.push_back(std::string() + "y_v" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 5; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res21" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { { - param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + for (size_t sym3__ = 1; sym3__ <= 3; ++sym3__) { + { + param_names__.push_back(std::string() + "idx_res31" + '.' + std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} }} - } - - if (emit_generated_quantities__) { - for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 4; ++sym1__) { { - for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { { - param_names__.push_back(std::string() + "y_hat" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + param_names__.push_back(std::string() + "idx_res4" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); }} }} - param_names__.push_back(std::string() + "y_1d"); - param_names__.push_back(std::string() + "z_1d"); - param_names__.push_back(std::string() + "abc1_gq"); - param_names__.push_back(std::string() + "abc2_gq"); - for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { { - param_names__.push_back(std::string() + "y_hat_gq" + '.' + std::to_string(sym1__)); + for (size_t sym2__ = 1; sym2__ <= 2; ++sym2__) { + { + param_names__.push_back(std::string() + "idx_res5" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} }} } @@ -12367,13 +11730,13 @@ class motherHOF_model : public model_base_crtp { std::string get_constrained_sizedtypes() const { stringstream s__; - s__ << "[{\"name\":\"y0_p\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"shared_params_p\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"job_params_p\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_r\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"abc1_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc2_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc3_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp1\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp2\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp3\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p_as\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"x_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat\",\"type\":{\"name\":\"array\",\"length\":" << T << ",\"element_type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"},{\"name\":\"y_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"z_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc1_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc2_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"y_hat_gq\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"generated_quantities\"}]"; + s__ << "[{\"name\":\"p_real\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"no_offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"offset_no_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"parameters\"},{\"name\":\"p_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"parameters\"},{\"name\":\"p_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"tp_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"gq_r1\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_r2\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_54\",\"type\":{\"name\":\"matrix\",\"rows\":" << 5 << ",\"cols\":" << 4 << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33\",\"type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"indices\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"int\"}},\"block\":\"generated_quantities\"},{\"name\":\"indexing_mat\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res1\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res2\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res3\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res11\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res21\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res31\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res4\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res5\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 2 << "}},\"block\":\"generated_quantities\"}]"; return s__.str(); } // get_constrained_sizedtypes() std::string get_unconstrained_sizedtypes() const { stringstream s__; - s__ << "[{\"name\":\"y0_p\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"shared_params_p\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"job_params_p\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_r\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"abc1_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc2_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc3_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp1\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp2\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp3\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p_as\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"x_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat\",\"type\":{\"name\":\"array\",\"length\":" << T << ",\"element_type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"},{\"name\":\"y_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"z_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc1_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc2_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"y_hat_gq\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"generated_quantities\"}]"; + s__ << "[{\"name\":\"p_real\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"no_offset_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"offset_no_multiplier\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"p_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"parameters\"},{\"name\":\"p_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"parameters\"},{\"name\":\"p_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"parameters\"},{\"name\":\"p_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"parameters\"},{\"name\":\"p_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"parameters\"},{\"name\":\"p_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"parameters\"},{\"name\":\"p_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"parameters\"},{\"name\":\"p_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"parameters\"},{\"name\":\"p_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"tp_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"transformed_parameters\"},{\"name\":\"tp_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"gq_r1\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_r2\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_1d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"gq_real_3d_ar\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_row_vec\",\"type\":{\"name\":\"vector\",\"length\":" << N << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_row_vec\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_ar_mat\",\"type\":{\"name\":\"array\",\"length\":" << 4 << ",\"element_type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 2 << ",\"cols\":" << 3 << "}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_simplex\",\"type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_1d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}},\"block\":\"generated_quantities\"},{\"name\":\"gq_3d_simplex\",\"type\":{\"name\":\"array\",\"length\":" << N << ",\"element_type\":{\"name\":\"array\",\"length\":" << M << ",\"element_type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << (N - 1) << "}}}},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_54\",\"type\":{\"name\":\"vector\",\"length\":" << ((((4 * (4 - 1)) / 2) + 4) + ((5 - 4) * 4)) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33\",\"type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "},\"block\":\"generated_quantities\"},{\"name\":\"gq_cfcov_33_ar\",\"type\":{\"name\":\"array\",\"length\":" << K << ",\"element_type\":{\"name\":\"vector\",\"length\":" << ((((3 * (3 - 1)) / 2) + 3) + ((3 - 3) * 3)) << "}},\"block\":\"generated_quantities\"},{\"name\":\"indices\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"int\"}},\"block\":\"generated_quantities\"},{\"name\":\"indexing_mat\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res1\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res2\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res3\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res11\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res21\",\"type\":{\"name\":\"array\",\"length\":" << 5 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res31\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"matrix\",\"rows\":" << 3 << ",\"cols\":" << 3 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res4\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 4 << "}},\"block\":\"generated_quantities\"},{\"name\":\"idx_res5\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 2 << "}},\"block\":\"generated_quantities\"}]"; return s__.str(); } // get_unconstrained_sizedtypes() @@ -12422,7 +11785,7 @@ class motherHOF_model : public model_base_crtp { }; } -typedef motherHOF_model_namespace::motherHOF_model stan_model; +typedef mother_model_namespace::mother_model stan_model; #ifndef USING_R @@ -12438,13 +11801,52 @@ stan::model::model_base& new_model( #endif -STAN_REGISTER_MAP_RECT(1, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(2, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(3, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(4, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(5, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(6, motherHOF_model_namespace::foo_functor__) -STAN_REGISTER_MAP_RECT(7, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(1, mother_model_namespace::binomialf_functor__) + +Warning: deprecated language construct used in 'mother.stan', line 63, column 21: + ------------------------------------------------- + 61: + 62: void unit_normal_lp(real u) { + 63: increment_log_prob(normal_log(u,0,1)); + ^ + 64: u ~ uniform(-100,100); + 65: } + ------------------------------------------------- + +increment_log_prob(...); is deprecated and will be removed in the future. Use target += ...; instead. + + +Warning: deprecated language construct used in 'mother.stan', line 187, column 20: + ------------------------------------------------- + 185: + 186: real foo_lp(real x) { + 187: return x + get_lp(); + ^ + 188: } + 189: + ------------------------------------------------- + +get_lp() function is deprecated. It will be removed in a future release. Use target() instead. + + $ ../../../../../install/default/bin/stanc --print-cpp motherHOF.stan + +Semantic error in 'motherHOF.stan', line 90, column 10 to column 65: + ------------------------------------------------- + 88: y_hat = integrate_ode_adams(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8); + 89: + 90: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int); + ^ + 91: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int); + 92: y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int); + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. + $ ../../../../../install/default/bin/stanc --print-cpp optimize_glm.stan // Code generated by %%NAME%% %%VERSION%% @@ -14285,6 +13687,7 @@ g(const std::vector& y_slice, const int& start, const int& end, } struct g_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector& y_slice, const int& start, @@ -14292,7 +13695,19 @@ operator()(const std::vector& y_slice, const int& start, { return g(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return g(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g_functor__; +using DeepCopy__ = g_functor__; +using captured_scalar_t__ = double;}; struct g_rsfunctor__ { @@ -14335,6 +13750,7 @@ h(const std::vector& y_slice, const int& start, const int& end, } struct h_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -14344,7 +13760,21 @@ operator()(const std::vector& y_slice, const int& start, { return h(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector& a) const +{ +return h(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h_functor__; +using DeepCopy__ = h_functor__; +using captured_scalar_t__ = double;}; struct h_rsfunctor__ { @@ -14377,6 +13807,7 @@ foo_lpdf(const std::vector& y_slice, const int& start, const int& end, } struct foo_lpdf_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector& y_slice, const int& start, @@ -15134,6 +14565,7 @@ g1(const std::vector& y_slice, const int& start, const int& end, } struct g1_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector& y_slice, const int& start, @@ -15141,7 +14573,19 @@ operator()(const std::vector& y_slice, const int& start, { return g1(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return g1(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g1_functor__; +using DeepCopy__ = g1_functor__; +using captured_scalar_t__ = double;}; struct g1_rsfunctor__ { @@ -15184,6 +14628,7 @@ g2(const std::vector>& y_slice, const int& start, } struct g2_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -15191,7 +14636,19 @@ operator()(const std::vector>& y_slice, { return g2(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g2(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g2_functor__; +using DeepCopy__ = g2_functor__; +using captured_scalar_t__ = double;}; struct g2_rsfunctor__ { @@ -15234,6 +14691,7 @@ g3(const std::vector>& y_slice, const int& start, } struct g3_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -15241,7 +14699,19 @@ operator()(const std::vector>& y_slice, { return g3(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g3(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g3_functor__; +using DeepCopy__ = g3_functor__; +using captured_scalar_t__ = double;}; struct g3_rsfunctor__ { @@ -15285,6 +14755,7 @@ g4(const std::vector>& y_slice, const int& start, } struct g4_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -15292,7 +14763,19 @@ operator()(const std::vector>& y_slice, { return g4(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g4(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g4_functor__; +using DeepCopy__ = g4_functor__; +using captured_scalar_t__ = double;}; struct g4_rsfunctor__ { @@ -15338,6 +14821,7 @@ g5(const std::vector>& y_slice, const int& start, } struct g5_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, const int& start, @@ -15345,7 +14829,19 @@ operator()(const std::vector>& y_slice, const int& start, { return g5(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return g5(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g5_functor__; +using DeepCopy__ = g5_functor__; +using captured_scalar_t__ = double;}; struct g5_rsfunctor__ { @@ -15392,6 +14888,7 @@ g6(const std::vector>>& y_slice, } struct g6_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -15399,7 +14896,19 @@ operator()(const std::vector>>& y_slice, { return g6(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g6(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g6_functor__; +using DeepCopy__ = g6_functor__; +using captured_scalar_t__ = double;}; struct g6_rsfunctor__ { @@ -15446,6 +14955,7 @@ g7(const std::vector>>& y_slice, } struct g7_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -15453,7 +14963,19 @@ operator()(const std::vector>>& y_slice, { return g7(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g7(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g7_functor__; +using DeepCopy__ = g7_functor__; +using captured_scalar_t__ = double;}; struct g7_rsfunctor__ { @@ -15500,6 +15022,7 @@ g8(const std::vector>>& y_slice, } struct g8_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -15507,7 +15030,19 @@ operator()(const std::vector>>& y_slice, { return g8(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return g8(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g8_functor__; +using DeepCopy__ = g8_functor__; +using captured_scalar_t__ = double;}; struct g8_rsfunctor__ { @@ -15545,6 +15080,7 @@ h1(const std::vector& y, const int& start, const int& end, } struct h1_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15553,7 +15089,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h1(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector& a) const +{ +return h1(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h1_functor__; +using DeepCopy__ = h1_functor__; +using captured_scalar_t__ = double;}; struct h1_rsfunctor__ { @@ -15599,6 +15149,7 @@ h2(const std::vector& y, const int& start, const int& end, } struct h2_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15608,7 +15159,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h2(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return h2(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h2_functor__; +using DeepCopy__ = h2_functor__; +using captured_scalar_t__ = double;}; struct h2_rsfunctor__ { @@ -15655,6 +15220,7 @@ h3(const std::vector& y, const int& start, const int& end, } struct h3_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15664,7 +15230,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h3(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return h3(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h3_functor__; +using DeepCopy__ = h3_functor__; +using captured_scalar_t__ = double;}; struct h3_rsfunctor__ { @@ -15712,6 +15292,7 @@ h4(const std::vector& y, const int& start, const int& end, } struct h4_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15721,7 +15302,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h4(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return h4(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h4_functor__; +using DeepCopy__ = h4_functor__; +using captured_scalar_t__ = double;}; struct h4_rsfunctor__ { @@ -15771,6 +15366,7 @@ h5(const std::vector& y, const int& start, const int& end, } struct h5_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15779,7 +15375,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h5(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return h5(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h5_functor__; +using DeepCopy__ = h5_functor__; +using captured_scalar_t__ = double;}; struct h5_rsfunctor__ { @@ -15830,6 +15440,7 @@ h6(const std::vector& y, const int& start, const int& end, } struct h6_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15839,7 +15450,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h6(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return h6(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h6_functor__; +using DeepCopy__ = h6_functor__; +using captured_scalar_t__ = double;}; struct h6_rsfunctor__ { @@ -15891,6 +15516,7 @@ h7(const std::vector& y, const int& start, const int& end, } struct h7_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15900,7 +15526,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h7(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return h7(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h7_functor__; +using DeepCopy__ = h7_functor__; +using captured_scalar_t__ = double;}; struct h7_rsfunctor__ { @@ -15952,6 +15592,7 @@ h8(const std::vector& y, const int& start, const int& end, } struct h8_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -15961,7 +15602,21 @@ operator()(const std::vector& y, const int& start, const int& end, { return h8(y, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return h8(y, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = h8_functor__; +using DeepCopy__ = h8_functor__; +using captured_scalar_t__ = double;}; struct h8_rsfunctor__ { @@ -18323,6 +17978,7 @@ f1(const std::vector& y_slice, const int& start, const int& end, } struct f1_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector& y_slice, const int& start, @@ -18330,7 +17986,19 @@ operator()(const std::vector& y_slice, const int& start, { return f1(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return f1(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f1_functor__; +using DeepCopy__ = f1_functor__; +using captured_scalar_t__ = double;}; struct f1_rsfunctor__ { @@ -18363,6 +18031,7 @@ f1a(const std::vector& y_slice, const int& start, const int& end, } struct f1a_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector& y_slice, const int& start, @@ -18370,7 +18039,19 @@ operator()(const std::vector& y_slice, const int& start, { return f1a(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return f1a(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f1a_functor__; +using DeepCopy__ = f1a_functor__; +using captured_scalar_t__ = double;}; struct f1a_rsfunctor__ { @@ -18403,6 +18084,7 @@ f2(const std::vector>& y_slice, const int& start, } struct f2_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -18410,7 +18092,19 @@ operator()(const std::vector>& y_slice, { return f2(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f2(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f2_functor__; +using DeepCopy__ = f2_functor__; +using captured_scalar_t__ = double;}; struct f2_rsfunctor__ { @@ -18443,6 +18137,7 @@ f3(const std::vector>& y_slice, const int& start, } struct f3_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -18450,7 +18145,19 @@ operator()(const std::vector>& y_slice, { return f3(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f3(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f3_functor__; +using DeepCopy__ = f3_functor__; +using captured_scalar_t__ = double;}; struct f3_rsfunctor__ { @@ -18483,6 +18190,7 @@ f4(const std::vector>& y_slice, const int& start, } struct f4_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, @@ -18490,7 +18198,19 @@ operator()(const std::vector>& y_slice, { return f4(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f4(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f4_functor__; +using DeepCopy__ = f4_functor__; +using captured_scalar_t__ = double;}; struct f4_rsfunctor__ { @@ -18523,6 +18243,7 @@ f5(const std::vector>& y_slice, const int& start, } struct f5_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>& y_slice, const int& start, @@ -18530,7 +18251,19 @@ operator()(const std::vector>& y_slice, const int& start, { return f5(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return f5(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f5_functor__; +using DeepCopy__ = f5_functor__; +using captured_scalar_t__ = double;}; struct f5_rsfunctor__ { @@ -18563,6 +18296,7 @@ f6(const std::vector>>& y_slice, } struct f6_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -18570,7 +18304,19 @@ operator()(const std::vector>>& y_slice, { return f6(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f6(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f6_functor__; +using DeepCopy__ = f6_functor__; +using captured_scalar_t__ = double;}; struct f6_rsfunctor__ { @@ -18603,6 +18349,7 @@ f7(const std::vector>>& y_slice, } struct f7_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -18610,7 +18357,19 @@ operator()(const std::vector>>& y_slice, { return f7(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f7(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f7_functor__; +using DeepCopy__ = f7_functor__; +using captured_scalar_t__ = double;}; struct f7_rsfunctor__ { @@ -18643,6 +18402,7 @@ f8(const std::vector>>& y_slice, } struct f8_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -18650,7 +18410,19 @@ operator()(const std::vector>>& y_slice, { return f8(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f8(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f8_functor__; +using DeepCopy__ = f8_functor__; +using captured_scalar_t__ = double;}; struct f8_rsfunctor__ { @@ -18682,13 +18454,25 @@ f9(const std::vector& y_slice, const int& start, const int& end, } struct f9_functor__ { +const static int num_vars__ = 0; double operator()(const std::vector& y_slice, const int& start, const int& end, std::ostream* pstream__) const { return f9(y_slice, start, end, pstream__); } -}; +double +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return f9(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f9_functor__; +using DeepCopy__ = f9_functor__; +using captured_scalar_t__ = double;}; struct f9_rsfunctor__ { @@ -18719,13 +18503,25 @@ f10(const std::vector>& y_slice, const int& start, } struct f10_functor__ { +const static int num_vars__ = 0; double operator()(const std::vector>& y_slice, const int& start, const int& end, std::ostream* pstream__) const { return f10(y_slice, start, end, pstream__); } -}; +double +operator()(const std::vector>& y_slice, const int& start, + std::ostream* pstream__, const int& end) const +{ +return f10(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f10_functor__; +using DeepCopy__ = f10_functor__; +using captured_scalar_t__ = double;}; struct f10_rsfunctor__ { @@ -18756,13 +18552,25 @@ f11(const std::vector>>& y_slice, } struct f11_functor__ { +const static int num_vars__ = 0; double operator()(const std::vector>>& y_slice, const int& start, const int& end, std::ostream* pstream__) const { return f11(y_slice, start, end, pstream__); } -}; +double +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f11(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f11_functor__; +using DeepCopy__ = f11_functor__; +using captured_scalar_t__ = double;}; struct f11_rsfunctor__ { @@ -18794,6 +18602,7 @@ f12(const std::vector>>& y_slice, } struct f12_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type operator()(const std::vector>>& y_slice, @@ -18801,7 +18610,19 @@ operator()(const std::vector>>& y_slice, { return f12(y_slice, start, end, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector>>& y_slice, + const int& start, std::ostream* pstream__, const int& end) const +{ +return f12(y_slice, start, end, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = f12_functor__; +using DeepCopy__ = f12_functor__; +using captured_scalar_t__ = double;}; struct f12_rsfunctor__ { @@ -18836,6 +18657,7 @@ g1(const std::vector& y_slice, const int& start, const int& end, } struct g1_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -18844,7 +18666,20 @@ operator()(const std::vector& y_slice, const int& start, { return g1(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, const T3__& a) const +{ +return g1(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g1_functor__; +using DeepCopy__ = g1_functor__; +using captured_scalar_t__ = double;}; struct g1_rsfunctor__ { @@ -18880,6 +18715,7 @@ g2(const std::vector& y_slice, const int& start, const int& end, } struct g2_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -18889,7 +18725,21 @@ operator()(const std::vector& y_slice, const int& start, { return g2(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const Eigen::Matrix& a) const +{ +return g2(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g2_functor__; +using DeepCopy__ = g2_functor__; +using captured_scalar_t__ = double;}; struct g2_rsfunctor__ { @@ -18926,6 +18776,7 @@ g3(const std::vector& y_slice, const int& start, const int& end, } struct g3_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -18935,7 +18786,21 @@ operator()(const std::vector& y_slice, const int& start, { return g3(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const Eigen::Matrix& a) const +{ +return g3(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g3_functor__; +using DeepCopy__ = g3_functor__; +using captured_scalar_t__ = double;}; struct g3_rsfunctor__ { @@ -18972,6 +18837,7 @@ g4(const std::vector& y_slice, const int& start, const int& end, } struct g4_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -18981,7 +18847,21 @@ operator()(const std::vector& y_slice, const int& start, { return g4(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const Eigen::Matrix& a) const +{ +return g4(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g4_functor__; +using DeepCopy__ = g4_functor__; +using captured_scalar_t__ = double;}; struct g4_rsfunctor__ { @@ -19018,6 +18898,7 @@ g5(const std::vector& y_slice, const int& start, const int& end, } struct g5_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19027,7 +18908,21 @@ operator()(const std::vector& y_slice, const int& start, { return g5(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector& a) const +{ +return g5(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g5_functor__; +using DeepCopy__ = g5_functor__; +using captured_scalar_t__ = double;}; struct g5_rsfunctor__ { @@ -19064,6 +18959,7 @@ g6(const std::vector& y_slice, const int& start, const int& end, } struct g6_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19073,7 +18969,21 @@ operator()(const std::vector& y_slice, const int& start, { return g6(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return g6(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g6_functor__; +using DeepCopy__ = g6_functor__; +using captured_scalar_t__ = double;}; struct g6_rsfunctor__ { @@ -19110,6 +19020,7 @@ g7(const std::vector& y_slice, const int& start, const int& end, } struct g7_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19119,7 +19030,21 @@ operator()(const std::vector& y_slice, const int& start, { return g7(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return g7(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g7_functor__; +using DeepCopy__ = g7_functor__; +using captured_scalar_t__ = double;}; struct g7_rsfunctor__ { @@ -19156,6 +19081,7 @@ g8(const std::vector& y_slice, const int& start, const int& end, } struct g8_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19165,7 +19091,21 @@ operator()(const std::vector& y_slice, const int& start, { return g8(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return g8(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g8_functor__; +using DeepCopy__ = g8_functor__; +using captured_scalar_t__ = double;}; struct g8_rsfunctor__ { @@ -19202,6 +19142,7 @@ g9(const std::vector& y_slice, const int& start, const int& end, } struct g9_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19211,7 +19152,21 @@ operator()(const std::vector& y_slice, const int& start, { return g9(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>& a) const +{ +return g9(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g9_functor__; +using DeepCopy__ = g9_functor__; +using captured_scalar_t__ = double;}; struct g9_rsfunctor__ { @@ -19249,6 +19204,7 @@ g10(const std::vector& y_slice, const int& start, const int& end, } struct g10_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19259,7 +19215,21 @@ operator()(const std::vector& y_slice, const int& start, { return g10(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return g10(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g10_functor__; +using DeepCopy__ = g10_functor__; +using captured_scalar_t__ = double;}; struct g10_rsfunctor__ { @@ -19297,6 +19267,7 @@ g11(const std::vector& y_slice, const int& start, const int& end, } struct g11_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19307,7 +19278,21 @@ operator()(const std::vector& y_slice, const int& start, { return g11(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return g11(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g11_functor__; +using DeepCopy__ = g11_functor__; +using captured_scalar_t__ = double;}; struct g11_rsfunctor__ { @@ -19345,6 +19330,7 @@ g12(const std::vector& y_slice, const int& start, const int& end, } struct g12_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type @@ -19355,7 +19341,21 @@ operator()(const std::vector& y_slice, const int& start, { return g12(y_slice, start, end, a, pstream__); } -}; +template +typename boost::math::tools::promote_args::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, + const std::vector>>& a) const +{ +return g12(y_slice, start, end, a, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = g12_functor__; +using DeepCopy__ = g12_functor__; +using captured_scalar_t__ = double;}; struct g12_rsfunctor__ { @@ -19421,6 +19421,7 @@ s(const std::vector& y_slice, const int& start, const int& end, } struct s_functor__ { +const static int num_vars__ = 0; template & y_slice, const int& start, return s(y_slice, start, end, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, pstream__); } -}; +template +typename boost::math::tools::promote_args::type>::type>::type +operator()(const std::vector& y_slice, const int& start, + std::ostream* pstream__, const int& end, const int& a, + const T4__& b, const Eigen::Matrix& c, + const Eigen::Matrix& d, + const Eigen::Matrix& e, const std::vector& f, + const std::vector& g, + const std::vector>& h, + const std::vector>& i, + const std::vector>& j, + const std::vector>& k, + const std::vector>& l, + const std::vector>>& m, + const std::vector>>& n, + const std::vector>>& o, + const std::vector>>& p, + const std::vector>>& q) const +{ +return s(y_slice, start, end, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, + q, pstream__); +} +void set_zero_adjoints() const { } +void save_varis(vari**) const { } +void accumulate_adjoints(double*) const { } +using ValueOf__ = s_functor__; +using DeepCopy__ = s_functor__; +using captured_scalar_t__ = double;}; struct s_rsfunctor__ { @@ -19869,6 +19903,7 @@ r(std::ostream* pstream__) { } struct r_functor__ { +const static int num_vars__ = 0; double operator()(std::ostream* pstream__) const { @@ -23272,6 +23307,7 @@ lb_constrain(const T0__& x, const T1__& y, std::ostream* pstream__) { } struct lb_constrain_functor__ { +const static int num_vars__ = 0; template typename boost::math::tools::promote_args::type diff --git a/test/integration/good/compiler-optimizations/cpp.expected b/test/integration/good/compiler-optimizations/cpp.expected index 874348d584..596e72f03b 100644 --- a/test/integration/good/compiler-optimizations/cpp.expected +++ b/test/integration/good/compiler-optimizations/cpp.expected @@ -227,6 +227,7 @@ nrfun_lp(const T0__& x, const int& y, T_lp__& lp__, T_lp_accum__& lp_accum__, } struct nrfun_lp_functor__ { +const static int num_vars__ = 0; template void @@ -267,6 +268,7 @@ rfun(const int& y, std::ostream* pstream__) { } struct rfun_functor__ { +const static int num_vars__ = 0; int operator()(const int& y, std::ostream* pstream__) const { @@ -295,6 +297,7 @@ rfun_lp(T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) { } struct rfun_lp_functor__ { +const static int num_vars__ = 0; template int operator()(T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) const diff --git a/test/integration/good/parser-generator/pretty.expected b/test/integration/good/parser-generator/pretty.expected index 07230b4e89..3f3ee0f157 100644 --- a/test/integration/good/parser-generator/pretty.expected +++ b/test/integration/good/parser-generator/pretty.expected @@ -367,6 +367,24 @@ generated quantities { } } + +Semantic error in 'ode_control.stan', line 30, column 10 to line 31, column 47: + ------------------------------------------------- + 28: y_hat = integrate_ode_rk45(sho, y0, t0, ts, theta, x, x_int, + 29: 1e-10, 1e-10, 1e6); + 30: y_hat = integrate_ode_bdf(sho, y0, t0, ts, theta, x, x_int, + ^ + 31: 1e-10, 1e-10, 1e6); + 32: y_hat = integrate_ode_adams(sho, y0, t0, ts, theta, x, x_int, + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, real. + $ ../../../../../install/default/bin/stanc --auto-format prim_var_data_block.stan data { int p1; diff --git a/test/integration/good/pretty.expected b/test/integration/good/pretty.expected index 58b45e23ee..1832c50102 100644 --- a/test/integration/good/pretty.expected +++ b/test/integration/good/pretty.expected @@ -3702,6 +3702,24 @@ generated quantities { 1e-10, 1e8); } + +Semantic error in 'integrate_ode_bdf.stan', line 28, column 10 to column 65: + ------------------------------------------------- + 26: model { + 27: real y_hat[T,2]; + 28: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int); + ^ + 29: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int); + 30: y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int); + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. + $ ../../../../install/default/bin/stanc --auto-format integrate_ode_deprecation.stan functions { real[] sho(real t, real[] y, real[] theta, real[] x, int[] x_int) { @@ -4374,6 +4392,24 @@ model { y[t] ~ normal(y_hat[t], sigma); } + +Semantic error in 'ode_good.stan', line 41, column 10 to line 47, column 35: + ------------------------------------------------- + 39: x, // data + 40: x_int); // integer data + 41: y_hat = integrate_ode_bdf(harm_osc_ode, // system + ^ + 42: y0, // initial state + 43: t0, // initial time + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. + $ ../../../../install/default/bin/stanc --auto-format old-log-funs.stan transformed data { real x; diff --git a/test/integration/good/stat_comp_benchmarks_models/pretty.expected b/test/integration/good/stat_comp_benchmarks_models/pretty.expected index 6ddb5f3bd6..2a27f00fca 100644 --- a/test/integration/good/stat_comp_benchmarks_models/pretty.expected +++ b/test/integration/good/stat_comp_benchmarks_models/pretty.expected @@ -326,6 +326,24 @@ generated quantities { C_ppc[n] = lognormal_rng(log(C[n, 1]), sigma); } + +Semantic error in 'one_comp_mm_elim_abs.stan', line 55, column 8 to column 79: + ------------------------------------------------- + 53: { + 54: real theta[3] = {k_a, K_m, V_m}; + 55: C = integrate_ode_bdf(one_comp_mm_elim_abs, C0, t0, times, theta, x_r, x_i); + ^ + 56: } + 57: } + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. + $ ../../../../../install/default/bin/stanc --auto-format sim_one_comp_mm_elim_abs.stan functions { real[] one_comp_mm_elim_abs(real t, real[] y, real[] theta, real[] x_r, @@ -374,6 +392,24 @@ generated quantities { C_hat[n] = lognormal_rng(log(C[n, 1]), sigma); } + +Semantic error in 'sim_one_comp_mm_elim_abs.stan', line 58, column 6 to column 77: + ------------------------------------------------- + 56: ts[n] = times[n]; + 57: + 58: C = integrate_ode_bdf(one_comp_mm_elim_abs, C0, t0, times, theta, x_r, x_i); + ^ + 59: + 60: for (n in 1:N_t) + ------------------------------------------------- + +Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: +((real, vector) => vector, vector, real, real[]) => vector[] +((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] +((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. + $ ../../../../../install/default/bin/stanc --auto-format sir.stan functions { real[] simple_SIR(real t, real[] y, real[] theta, real[] x_r, int[] x_i) { diff --git a/test/integration/signatures/stan_math_sigs.expected b/test/integration/signatures/stan_math_sigs.expected index c4cd98306f..e860ea0b51 100644 --- a/test/integration/signatures/stan_math_sigs.expected +++ b/test/integration/signatures/stan_math_sigs.expected @@ -7725,11 +7725,14 @@ real[,] integrate_ode_adams((real, real[], real[], data real[], data int[]) => r real[,] integrate_ode_adams((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], real[], int[], real, real, real) -real[,] integrate_ode_bdf((real, real[], real[], data real[], data int[]) => real[], - real[], real, real[], real[], real[], int[]) -real[,] integrate_ode_bdf((real, real[], real[], data real[], data int[]) => real[], - real[], real, real[], real[], real[], int[], - real, real, real) +vector[] integrate_ode_bdf((real, vector) => vector, vector, real, real[]) +vector[] integrate_ode_bdf((real, vector) => vector, vector, real, real[], + real, real, real) +vector[] integrate_ode_bdf((real, vector, real[], data real[], data int[]) => vector, + vector, real, real[], real[], real[], int[]) +vector[] integrate_ode_bdf((real, vector, real[], data real[], data int[]) => vector, + vector, real, real[], real[], real[], int[], + real, real, real) real[,] integrate_ode_rk45((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], real[], int[]) real[,] integrate_ode_rk45((real, real[], real[], data real[], data int[]) => real[], diff --git a/test/unit/Stan_math_code_gen_tests.ml b/test/unit/Stan_math_code_gen_tests.ml index 6bfa4b56e8..62dd410747 100644 --- a/test/unit/Stan_math_code_gen_tests.ml +++ b/test/unit/Stan_math_code_gen_tests.ml @@ -42,6 +42,7 @@ let%expect_test "udf" = } struct sars_functor__ { + const static int num_vars__ = 0; template void operator()(const Eigen::Matrix& x, From 40300088f54b654f2f8e1f3bdd1fecc02e3923eb Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Tue, 19 May 2020 09:45:01 +0300 Subject: [PATCH 7/9] user-defined higher-order functions --- src/frontend/Semantic_check.ml | 51 +- src/frontend/Semantic_error.ml | 10 + src/frontend/Semantic_error.mli | 2 + src/frontend/parser.mly | 20 +- src/middle/UnsizedType.ml | 2 +- src/stan_math_backend/Stan_math_code_gen.ml | 29 +- test/integration/bad/closures/capture.stan | 9 + test/integration/bad/closures/returntype.stan | 8 + test/integration/bad/closures/stanc.expected | 28 + .../code-gen/{closure.stan => closure_1.stan} | 0 .../{closure2.stan => closure_2.stan} | 0 test/integration/good/code-gen/closure_3.stan | 23 + test/integration/good/code-gen/cpp.expected | 727 ++++++++++++++++-- 13 files changed, 798 insertions(+), 111 deletions(-) create mode 100644 test/integration/bad/closures/capture.stan create mode 100644 test/integration/bad/closures/returntype.stan rename test/integration/good/code-gen/{closure.stan => closure_1.stan} (100%) rename test/integration/good/code-gen/{closure2.stan => closure_2.stan} (100%) create mode 100644 test/integration/good/code-gen/closure_3.stan diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 60995374a8..2d487150c0 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -165,8 +165,7 @@ let semantic_check_assignmentoperator op = Validate.ok op (* Probably nothing to do here *) let semantic_check_autodifftype at = Validate.ok at -(* Probably nothing to do here *) -let rec semantic_check_unsizedtype : UnsizedType.t -> unit Validate.t = +let rec semantic_check_unsizedtype ~loc : UnsizedType.t -> unit Validate.t = function | UFun (l, rt, _) -> (* fold over argument types accumulating errors with initial state @@ -176,16 +175,18 @@ let rec semantic_check_unsizedtype : UnsizedType.t -> unit Validate.t = Validate.( apply_const (apply_const v0 (semantic_check_autodifftype at)) - (semantic_check_unsizedtype ut)) ) - ~init:(semantic_check_returntype rt) + (semantic_check_unsizedtype ~loc ut)) ) + ~init:(semantic_check_returntype ~loc rt) l - | UArray ut -> semantic_check_unsizedtype ut + | UArray ut -> semantic_check_unsizedtype ~loc ut | _ -> Validate.ok () -and semantic_check_returntype : UnsizedType.returntype -> unit Validate.t = - function +and semantic_check_returntype ~loc : UnsizedType.returntype -> unit Validate.t + = function | Void -> Validate.ok () - | ReturnType ut -> semantic_check_unsizedtype ut + | ReturnType (UFun _) -> + Validate.error (Semantic_error.invalid_return_type loc) + | ReturnType ut -> semantic_check_unsizedtype ~loc ut (* -- Indentifiers ---------------------------------------------------------- *) let reserved_keywords = @@ -1605,7 +1606,7 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = List.map args ~f:(fun (at, ut, id) -> Validate.( semantic_check_autodifftype at - |> apply_const (semantic_check_unsizedtype ut) + |> apply_const (semantic_check_unsizedtype ~loc ut) |> apply_const (semantic_check_identifier id) |> map ~f:(fun at -> (at, ut, id))) ) |> Validate.sequence @@ -1614,7 +1615,7 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = Validate.( uargs |> apply_const (semantic_check_identifier id) - |> apply_const (semantic_check_returntype return_ty) + |> apply_const (semantic_check_returntype ~loc return_ty) >>= fun uargs -> let urt = return_ty in let uarg_types = List.map ~f:(fun (w, y, _) -> (w, y)) uargs in @@ -1670,28 +1671,22 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = >>= fun ub -> semantic_check_fundef_return_tys ~loc id urt ub |> map ~f:(fun ub -> (ub, Set.to_list !captures)) ) - |> map ~f:(fun (ub, captures) -> + >>= fun (ub, captures) -> + List.filter_map captures ~f:(fun name -> + match Symbol_table.look vm name with + | None | Some (Functions, UFun (_, _, Function)) -> None + | Some (_, UFun (_, _, Template)) -> + Some (error (Semantic_error.template_capture loc name)) + | Some (block, type_) -> + Symbol_table.set_read_only vm name ; + Some (ok (calculate_autodifftype block type_, type_, name)) ) + |> sequence + |> map ~f:(fun captures -> let stmt = FunDef { returntype= urt ; funname= id - ; closure= - ( if is_closure then - Some - { clname - ; captures= - List.filter_map captures ~f:(fun name -> - match Symbol_table.look vm name with - | None | Some (Functions, UFun (_, _, Function)) - -> - None - | Some (block, type_) -> - Symbol_table.set_read_only vm name ; - Some - ( calculate_autodifftype block type_ - , type_ - , name ) ) } - else None ) + ; closure= (if is_closure then Some {clname; captures} else None) ; arguments= uargs ; body= ub } in diff --git a/src/frontend/Semantic_error.ml b/src/frontend/Semantic_error.ml index 0a1a969558..9b4290c0f3 100644 --- a/src/frontend/Semantic_error.ml +++ b/src/frontend/Semantic_error.ml @@ -226,6 +226,7 @@ module IdentifierError = struct | IsStanMathName of string | InUse of string | NotInScope of string + | TemplateCapture of string let pp ppf = function | IsStanMathName name -> @@ -237,6 +238,7 @@ module IdentifierError = struct | IsKeyword name -> Fmt.pf ppf "Identifier '%s' clashes with reserved keyword." name | NotInScope name -> Fmt.pf ppf "Identifier '%s' not in scope." name + | TemplateCapture name -> Fmt.pf ppf "Cannot capture '%s'." name end module ExpressionError = struct @@ -300,6 +302,7 @@ module StatementError = struct | IncompatibleReturnType | InvalidForwardDecl | SpecialClosure + | InvalidReturnType let pp ppf = function | CannotAssignToReadOnly name -> @@ -404,6 +407,7 @@ For example, "target += normal_lpdf(y, 0, 1)" should become "y ~ normal(0, 1)." Fmt.pf ppf "Cannot declare a closure with suffix _lpdf, _lpmf, _log, _lcdf, \ _lccdf, _rng or _lp." + | InvalidReturnType -> Fmt.pf ppf "Return type cannot be a function type." end type t = @@ -512,6 +516,9 @@ let ident_in_use loc name = IdentifierError (loc, IdentifierError.InUse name) let ident_not_in_scope loc name = IdentifierError (loc, IdentifierError.NotInScope name) +let template_capture loc name = + IdentifierError (loc, IdentifierError.TemplateCapture name) + let invalid_map_rect_fn loc name = ExpressionError (loc, ExpressionError.InvalidMapRectFn name) @@ -601,3 +608,6 @@ let invalid_forward_decl loc = StatementError (loc, StatementError.InvalidForwardDecl) let invalid_special_fn loc = StatementError (loc, StatementError.SpecialClosure) + +let invalid_return_type loc = + StatementError (loc, StatementError.InvalidReturnType) diff --git a/src/frontend/Semantic_error.mli b/src/frontend/Semantic_error.mli index 99141fb63e..919ce132f7 100644 --- a/src/frontend/Semantic_error.mli +++ b/src/frontend/Semantic_error.mli @@ -72,6 +72,7 @@ val ident_is_model_name : Location_span.t -> string -> t val ident_is_stanmath_name : Location_span.t -> string -> t val ident_in_use : Location_span.t -> string -> t val ident_not_in_scope : Location_span.t -> string -> t +val template_capture : Location_span.t -> string -> t val invalid_map_rect_fn : Location_span.t -> string -> t val invalid_rng_fn : Location_span.t -> t val conditional_notation_not_allowed : Location_span.t -> t @@ -110,3 +111,4 @@ val duplicate_arg_names : Location_span.t -> t val incompatible_return_types : Location_span.t -> t val invalid_forward_decl : Location_span.t -> t val invalid_special_fn : Location_span.t -> t +val invalid_return_type : Location_span.t -> t diff --git a/src/frontend/parser.mly b/src/frontend/parser.mly index 9c6fe8cb11..e3b48bdcfd 100644 --- a/src/frontend/parser.mly +++ b/src/frontend/parser.mly @@ -205,15 +205,27 @@ arg_decl: { grammar_logger "arg_decl" ; match od with None -> (UnsizedType.AutoDiffable, ut, id) | _ -> (DataOnly, ut, id) } +arg_type: + | od=option(DATABLOCK) ut=unsized_type + { grammar_logger "arg_type" ; + match od with None -> (UnsizedType.AutoDiffable, ut) | _ -> (DataOnly, ut) } + +type_args: + | LPAREN args=separated_list(COMMA, arg_type) RPAREN + { grammar_logger "type_args" ; + args } + unsized_type: - | bt=basic_type ud=option(unsized_dims) + | bt=basic_type ud=option(unsized_dims) fa=option(type_args) { grammar_logger "unsized_type" ; let rec reparray n x = if n <= 0 then x else reparray (n-1) (UnsizedType.UArray x) in let size = - match ud with Some d -> 1 + d | None -> 0 - in - reparray size bt } + match ud with Some d -> 1 + d | None -> 0 in + let t = reparray size bt in + match fa with + | None -> t + | Some args -> UnsizedType.UFun (args, UnsizedType.ReturnType t, Template) } basic_type: | INT diff --git a/src/middle/UnsizedType.ml b/src/middle/UnsizedType.ml index 5e7e02f3ea..f4a69819a2 100644 --- a/src/middle/UnsizedType.ml +++ b/src/middle/UnsizedType.ml @@ -11,7 +11,7 @@ type t = | UFun of (autodifftype * t) list * returntype * functiontype | UMathLibraryFunction -and functiontype = Function | Closure of string +and functiontype = Function | Closure of string | Template and autodifftype = DataOnly | AutoDiffable diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 056e78feb9..0a0d77fdc9 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -40,22 +40,20 @@ let rec contains_int = function | UArray t -> contains_int t | _ -> false -let arg_needs_template = function - | _, _, UnsizedType.UFun _ -> true - | UnsizedType.DataOnly, _, _ -> false - | _, _, t when contains_int t -> false - | _ -> true - -let maybe_templated_arg_types (args : Program.fun_arg_decl) = - List.mapi args ~f:(fun i a -> - match arg_needs_template a with - | true -> Some (sprintf "T%d__" i) - | false -> None ) +let maybe_templated_arg_types scalar (args : Program.fun_arg_decl) = + List.mapi args ~f:(fun i -> function + | _, _, UnsizedType.UFun _ -> + Some + ( if scalar then sprintf "typename T%d__::captured_scalar_t__" i + else sprintf "T%d__" i ) + | UnsizedType.DataOnly, _, _ -> None + | _, _, t when contains_int t -> None + | _ -> Some (sprintf "T%d__" i) ) let%expect_test "arg types templated correctly" = [(AutoDiffable, "xreal", UReal); (DataOnly, "yint", UInt)] - |> maybe_templated_arg_types |> List.filter_opt |> String.concat ~sep:"," - |> print_endline ; + |> maybe_templated_arg_types false + |> List.filter_opt |> String.concat ~sep:"," |> print_endline ; [%expect {| T0__ |}] let pp_promoted_scalar ppf args = @@ -74,7 +72,8 @@ let pp_promoted_scalar ppf args = in promote_args_chunked ppf List.( - chunks_of ~length:5 (filter_opt (maybe_templated_arg_types args))) + chunks_of ~length:5 + (filter_opt (maybe_templated_arg_types true args))) (** Pretty-prints a function's return-type, taking into account templated argument promotion.*) @@ -124,7 +123,7 @@ let pp_located_error_b ppf body_stmts = let typename = ( ^ ) "typename " let get_templates_and_args fdargs = - let argtypetemplates = maybe_templated_arg_types fdargs in + let argtypetemplates = maybe_templated_arg_types false fdargs in ( List.filter_opt argtypetemplates , List.map ~f:(fun a -> strf "%a" pp_arg a) diff --git a/test/integration/bad/closures/capture.stan b/test/integration/bad/closures/capture.stan new file mode 100644 index 0000000000..3343f2f220 --- /dev/null +++ b/test/integration/bad/closures/capture.stan @@ -0,0 +1,9 @@ +functions { + real foo(real(real) g) { + functions + real f(real x) { + return g(x)^2; + } + return f(1.0) + f(2.0); + } +} \ No newline at end of file diff --git a/test/integration/bad/closures/returntype.stan b/test/integration/bad/closures/returntype.stan new file mode 100644 index 0000000000..4a2089434b --- /dev/null +++ b/test/integration/bad/closures/returntype.stan @@ -0,0 +1,8 @@ +functions { + real foo(real x) { + return 2*x; + } + real(real) bar(real x) { + return foo; + } +} \ No newline at end of file diff --git a/test/integration/bad/closures/stanc.expected b/test/integration/bad/closures/stanc.expected index 3e3e3b3144..32fbde37ea 100644 --- a/test/integration/bad/closures/stanc.expected +++ b/test/integration/bad/closures/stanc.expected @@ -1,3 +1,17 @@ + $ ../../../../../install/default/bin/stanc capture.stan + +Semantic error in 'capture.stan', line 3, column 8 to line 6, column 9: + ------------------------------------------------- + 1: functions { + 2: real foo(real(real) g) { + 3: functions + ^ + 4: real f(real x) { + 5: return g(x)^2; + ------------------------------------------------- + +Cannot capture 'g'. + $ ../../../../../install/default/bin/stanc closure_lp.stan Semantic error in 'closure_lp.stan', line 6, column 7 to column 13: @@ -68,6 +82,20 @@ Semantic error in 'mutate2.stan', line 10, column 2 to column 8: Cannot assign to read-only identifier 'x'. + $ ../../../../../install/default/bin/stanc returntype.stan + +Semantic error in 'returntype.stan', line 5, column 4 to line 7, column 5: + ------------------------------------------------- + 3: return 2*x; + 4: } + 5: real(real) bar(real x) { + ^ + 6: return foo; + 7: } + ------------------------------------------------- + +Return type cannot be a function type. + $ ../../../../../install/default/bin/stanc shadowing.stan Semantic error in 'shadowing.stan', line 5, column 9 to column 12: diff --git a/test/integration/good/code-gen/closure.stan b/test/integration/good/code-gen/closure_1.stan similarity index 100% rename from test/integration/good/code-gen/closure.stan rename to test/integration/good/code-gen/closure_1.stan diff --git a/test/integration/good/code-gen/closure2.stan b/test/integration/good/code-gen/closure_2.stan similarity index 100% rename from test/integration/good/code-gen/closure2.stan rename to test/integration/good/code-gen/closure_2.stan diff --git a/test/integration/good/code-gen/closure_3.stan b/test/integration/good/code-gen/closure_3.stan new file mode 100644 index 0000000000..2e0463456f --- /dev/null +++ b/test/integration/good/code-gen/closure_3.stan @@ -0,0 +1,23 @@ +functions { + real foo(real(real) g, real x) { + return g(1+x); + } +} +transformed data { + real x = 2.0; + functions + real bar(real y) { + return x*y; + } + real z = foo(bar, 1.0); +} +parameters { + real p; +} +transformed parameters { + functions + real baz(real y) { + return p*y; + } + real w = foo(baz, 1.0); +} \ No newline at end of file diff --git a/test/integration/good/code-gen/cpp.expected b/test/integration/good/code-gen/cpp.expected index acd28feb6e..32d4274c9c 100644 --- a/test/integration/good/code-gen/cpp.expected +++ b/test/integration/good/code-gen/cpp.expected @@ -1,8 +1,8 @@ - $ ../../../../../install/default/bin/stanc --print-cpp closure.stan + $ ../../../../../install/default/bin/stanc --print-cpp closure_1.stan // Code generated by %%NAME%% %%VERSION%% #include -namespace closure_model_namespace { +namespace closure_1_model_namespace { template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { @@ -91,23 +91,23 @@ using namespace stan::math; static int current_statement__ = 0; static const std::vector locations_array__ = {" (found before start of program)", - " (in 'closure.stan', line 14, column 4 to column 11)", - " (in 'closure.stan', line 15, column 4 to column 15)", - " (in 'closure.stan', line 16, column 4 to column 17)", - " (in 'closure.stan', line 8, column 4 to line 11, column 5)", - " (in 'closure.stan', line 19, column 4 to line 23, column 5)", - " (in 'closure.stan', line 24, column 4 to column 29)", - " (in 'closure.stan', line 25, column 4 to column 27)", - " (in 'closure.stan', line 26, column 4 to column 29)", - " (in 'closure.stan', line 27, column 4 to column 27)", - " (in 'closure.stan', line 2, column 4 to column 10)", - " (in 'closure.stan', line 3, column 4 to column 11)", - " (in 'closure.stan', line 4, column 4 to column 14)", - " (in 'closure.stan', line 5, column 4 to column 16)", - " (in 'closure.stan', line 10, column 8 to column 48)", - " (in 'closure.stan', line 9, column 35 to line 11, column 5)", - " (in 'closure.stan', line 21, column 8 to line 22, column 40)", - " (in 'closure.stan', line 20, column 35 to line 23, column 5)"}; + " (in 'closure_1.stan', line 14, column 4 to column 11)", + " (in 'closure_1.stan', line 15, column 4 to column 15)", + " (in 'closure_1.stan', line 16, column 4 to column 17)", + " (in 'closure_1.stan', line 8, column 4 to line 11, column 5)", + " (in 'closure_1.stan', line 19, column 4 to line 23, column 5)", + " (in 'closure_1.stan', line 24, column 4 to column 29)", + " (in 'closure_1.stan', line 25, column 4 to column 27)", + " (in 'closure_1.stan', line 26, column 4 to column 29)", + " (in 'closure_1.stan', line 27, column 4 to column 27)", + " (in 'closure_1.stan', line 2, column 4 to column 10)", + " (in 'closure_1.stan', line 3, column 4 to column 11)", + " (in 'closure_1.stan', line 4, column 4 to column 14)", + " (in 'closure_1.stan', line 5, column 4 to column 16)", + " (in 'closure_1.stan', line 10, column 8 to column 48)", + " (in 'closure_1.stan', line 9, column 35 to line 11, column 5)", + " (in 'closure_1.stan', line 21, column 8 to line 22, column 40)", + " (in 'closure_1.stan', line 20, column 35 to line 23, column 5)"}; @@ -371,7 +371,7 @@ closure00_impl__(const T0__& z, const Eigen::Matrix& r, } } -class closure_model : public model_base_crtp { +class closure_1_model : public model_base_crtp { private: int pos__; @@ -381,18 +381,18 @@ class closure_model : public model_base_crtp { Eigen::Matrix v; public: - ~closure_model() { } + ~closure_1_model() { } - std::string model_name() const { return "closure_model"; } + std::string model_name() const { return "closure_1_model"; } - closure_model(stan::io::var_context& context__, - unsigned int random_seed__ = 0, - std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + closure_1_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { typedef double local_scalar_t__; boost::ecuyer1988 base_rng__ = stan::services::util::create_rng(random_seed__, 0); (void) base_rng__; // suppress unused var warning - static const char* function__ = "closure_model_namespace::closure_model"; + static const char* function__ = "closure_1_model_namespace::closure_1_model"; (void) function__; // suppress unused var warning try { @@ -468,7 +468,7 @@ class closure_model : public model_base_crtp { typedef T__ local_scalar_t__; T__ lp__(0.0); stan::math::accumulator lp_accum__; - static const char* function__ = "closure_model_namespace::log_prob"; + static const char* function__ = "closure_1_model_namespace::log_prob"; (void) function__; // suppress unused var warning stan::io::reader in__(params_r__, params_i__); @@ -537,7 +537,7 @@ class closure_model : public model_base_crtp { typedef double local_scalar_t__; vars__.resize(0); stan::io::reader in__(params_r__, params_i__); - static const char* function__ = "closure_model_namespace::write_array"; + static const char* function__ = "closure_1_model_namespace::write_array"; (void) function__; // suppress unused var warning (void) function__; // suppress unused var warning @@ -770,7 +770,7 @@ class closure_model : public model_base_crtp { }; } -typedef closure_model_namespace::closure_model stan_model; +typedef closure_1_model_namespace::closure_1_model stan_model; #ifndef USING_R @@ -787,11 +787,11 @@ stan::model::model_base& new_model( - $ ../../../../../install/default/bin/stanc --print-cpp closure2.stan + $ ../../../../../install/default/bin/stanc --print-cpp closure_2.stan // Code generated by %%NAME%% %%VERSION%% #include -namespace closure2_model_namespace { +namespace closure_2_model_namespace { template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { @@ -880,22 +880,22 @@ using namespace stan::math; static int current_statement__ = 0; static const std::vector locations_array__ = {" (found before start of program)", - " (in 'closure2.stan', line 12, column 2 to column 13)", - " (in 'closure2.stan', line 2, column 2 to line 5, column 3)", - " (in 'closure2.stan', line 6, column 2 to line 9, column 3)", - " (in 'closure2.stan', line 15, column 2 to line 18, column 3)", - " (in 'closure2.stan', line 19, column 2 to line 26, column 3)", - " (in 'closure2.stan', line 4, column 4 to column 13)", - " (in 'closure2.stan', line 3, column 19 to line 5, column 3)", - " (in 'closure2.stan', line 8, column 4 to column 18)", - " (in 'closure2.stan', line 7, column 19 to line 9, column 3)", - " (in 'closure2.stan', line 17, column 4 to column 18)", - " (in 'closure2.stan', line 16, column 19 to line 18, column 3)", - " (in 'closure2.stan', line 21, column 4 to line 24, column 5)", - " (in 'closure2.stan', line 25, column 4 to column 18)", - " (in 'closure2.stan', line 20, column 19 to line 26, column 3)", - " (in 'closure2.stan', line 23, column 6 to column 15)", - " (in 'closure2.stan', line 22, column 21 to line 24, column 5)"}; + " (in 'closure_2.stan', line 12, column 2 to column 13)", + " (in 'closure_2.stan', line 2, column 2 to line 5, column 3)", + " (in 'closure_2.stan', line 6, column 2 to line 9, column 3)", + " (in 'closure_2.stan', line 15, column 2 to line 18, column 3)", + " (in 'closure_2.stan', line 19, column 2 to line 26, column 3)", + " (in 'closure_2.stan', line 4, column 4 to column 13)", + " (in 'closure_2.stan', line 3, column 19 to line 5, column 3)", + " (in 'closure_2.stan', line 8, column 4 to column 18)", + " (in 'closure_2.stan', line 7, column 19 to line 9, column 3)", + " (in 'closure_2.stan', line 17, column 4 to column 18)", + " (in 'closure_2.stan', line 16, column 19 to line 18, column 3)", + " (in 'closure_2.stan', line 21, column 4 to line 24, column 5)", + " (in 'closure_2.stan', line 25, column 4 to column 18)", + " (in 'closure_2.stan', line 20, column 19 to line 26, column 3)", + " (in 'closure_2.stan', line 23, column 6 to column 15)", + " (in 'closure_2.stan', line 22, column 21 to line 24, column 5)"}; @@ -909,12 +909,12 @@ closure03_impl__(const T0__& s, std::ostream* pstream__) ; template typename boost::math::tools::promote_args::type +typename T1__::captured_scalar_t__>::type closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; template typename boost::math::tools::promote_args::type +typename T1__::captured_scalar_t__>::type closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; template @@ -1269,10 +1269,10 @@ closure03_impl__(const T0__& s, std::ostream* pstream__) { } template typename boost::math::tools::promote_args::type +typename T1__::captured_scalar_t__>::type closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; + typename T1__::captured_scalar_t__>::type; const static bool propto__ = true; (void) propto__; @@ -1288,10 +1288,10 @@ closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { } template typename boost::math::tools::promote_args::type +typename T1__::captured_scalar_t__>::type closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; + typename T1__::captured_scalar_t__>::type; const static bool propto__ = true; (void) propto__; @@ -1322,24 +1322,24 @@ closure00_impl__(const T0__& x, std::ostream* pstream__) { } } -class closure2_model : public model_base_crtp { +class closure_2_model : public model_base_crtp { private: int pos__; public: - ~closure2_model() { } + ~closure_2_model() { } - std::string model_name() const { return "closure2_model"; } + std::string model_name() const { return "closure_2_model"; } - closure2_model(stan::io::var_context& context__, - unsigned int random_seed__ = 0, - std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + closure_2_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { typedef double local_scalar_t__; boost::ecuyer1988 base_rng__ = stan::services::util::create_rng(random_seed__, 0); (void) base_rng__; // suppress unused var warning - static const char* function__ = "closure2_model_namespace::closure2_model"; + static const char* function__ = "closure_2_model_namespace::closure_2_model"; (void) function__; // suppress unused var warning try { @@ -1372,7 +1372,7 @@ class closure2_model : public model_base_crtp { typedef T__ local_scalar_t__; T__ lp__(0.0); stan::math::accumulator lp_accum__; - static const char* function__ = "closure2_model_namespace::log_prob"; + static const char* function__ = "closure_2_model_namespace::log_prob"; (void) function__; // suppress unused var warning stan::io::reader in__(params_r__, params_i__); @@ -1412,7 +1412,7 @@ class closure2_model : public model_base_crtp { typedef double local_scalar_t__; vars__.resize(0); stan::io::reader in__(params_r__, params_i__); - static const char* function__ = "closure2_model_namespace::write_array"; + static const char* function__ = "closure_2_model_namespace::write_array"; (void) function__; // suppress unused var warning (void) function__; // suppress unused var warning @@ -1577,7 +1577,608 @@ class closure2_model : public model_base_crtp { }; } -typedef closure2_model_namespace::closure2_model stan_model; +typedef closure_2_model_namespace::closure_2_model stan_model; + +#ifndef USING_R + +// Boilerplate +stan::model::model_base& new_model( + stan::io::var_context& data_context, + unsigned int seed, + std::ostream* msg_stream) { + stan_model* m = new stan_model(data_context, seed, msg_stream); + return *m; +} + +#endif + + + + $ ../../../../../install/default/bin/stanc --print-cpp closure_3.stan + +// Code generated by %%NAME%% %%VERSION%% +#include +namespace closure_3_model_namespace { + +template +std::vector resize_to_match__(std::vector& dst, const std::vector& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.rows(), src.cols()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} +std::vector to_doubles__(std::initializer_list x) { + return x; +} + +std::vector to_vars__(std::initializer_list x) { + return x; +} + +inline void validate_positive_index(const char* var_name, const char* expr, + int val) { + if (val < 1) { + std::stringstream msg; + msg << "Found dimension size less than one in simplex declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + +inline void validate_unit_vector_index(const char* var_name, const char* expr, + int val) { + if (val <= 1) { + std::stringstream msg; + if (val == 1) { + msg << "Found dimension size one in unit vector declaration." + << " One-dimensional unit vector is discrete" + << " but the target distribution must be continuous." + << " variable=" << var_name << "; dimension size expression=" << expr; + } else { + msg << "Found dimension size less than one in unit vector declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + } + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + + +using std::istream; +using std::string; +using std::stringstream; +using std::vector; +using std::pow; +using stan::io::dump; +using stan::math::lgamma; +using stan::model::model_base_crtp; +using stan::model::rvalue; +using stan::model::cons_list; +using stan::model::index_uni; +using stan::model::index_max; +using stan::model::index_min; +using stan::model::index_min_max; +using stan::model::index_multi; +using stan::model::index_omni; +using stan::model::nil_index_list; +using namespace stan::math; + +static int current_statement__ = 0; +static const std::vector locations_array__ = {" (found before start of program)", + " (in 'closure_3.stan', line 15, column 4 to column 11)", + " (in 'closure_3.stan', line 8, column 4 to line 11, column 5)", + " (in 'closure_3.stan', line 18, column 4 to line 21, column 5)", + " (in 'closure_3.stan', line 22, column 4 to column 27)", + " (in 'closure_3.stan', line 7, column 4 to column 17)", + " (in 'closure_3.stan', line 12, column 4 to column 27)", + " (in 'closure_3.stan', line 3, column 8 to column 22)", + " (in 'closure_3.stan', line 2, column 35 to line 4, column 5)", + " (in 'closure_3.stan', line 10, column 8 to column 19)", + " (in 'closure_3.stan', line 9, column 21 to line 11, column 5)", + " (in 'closure_3.stan', line 20, column 8 to column 19)", + " (in 'closure_3.stan', line 19, column 21 to line 21, column 5)"}; + + +template +typename boost::math::tools::promote_args::type +foo(const T0__& g, const T1__& x, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) ; + +template +typename boost::math::tools::promote_args::type +closure00_impl__(const T0__& y, const double& x, std::ostream* pstream__) ; + + +template +class closure00__ { + const double x; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure00__(const double x__) + : x(x__), num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure00_impl__(y, x, pstream__); + } + + class ValueOf__ { + const double x; + public: + ValueOf__(const closure00__& init) : x(init.x) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure00_impl__(y, x, pstream__); + } + }; + class DeepCopy__ { + const double x; + public: + DeepCopy__(const closure00__& init) : x(init.x) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure00_impl__(y, x, pstream__); + } + + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + + } + } +}; + +template +class closure01__ { + const captured_t__ p; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure01__(const captured_t__ p__) + : p(p__), num_vars__(stan::is_var::value ? 1 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, p, pstream__); + } + + class ValueOf__ { + const double p; + public: + ValueOf__(const closure01__& init) : p(value_of(init.p)) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, p, pstream__); + } + }; + class DeepCopy__ { + const captured_t__ p; + public: + DeepCopy__(const closure01__& init) : p(deep_copy_vars(init.p)) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, p, pstream__); + } + + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + pos__ = (pos__ + 1); + } + } + }; + void set_zero_adjoints() const { + if (stan::is_var::value) { + p.set_zero_adjoint(); + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + pos__ = (pos__ + 1); + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + ptr[(pos__ - 1)] = p.vi_; + pos__ = (pos__ + 1); + } + } +}; + +template +typename boost::math::tools::promote_args::type +foo(const T0__& g, const T1__& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 7; + return g((1 + x), pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& g, const T1__& x, std::ostream* pstream__) const +{ +return foo(g, x, pstream__); +} +}; + +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 11; + return (p * y); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} +template +typename boost::math::tools::promote_args::type +closure00_impl__(const T0__& y, const double& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 9; + return (x * y); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} +class closure_3_model : public model_base_crtp { + + private: + int pos__; + double x; + double z; + + public: + ~closure_3_model() { } + + std::string model_name() const { return "closure_3_model"; } + + closure_3_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "closure_3_model_namespace::closure_3_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + + current_statement__ = 5; + x = std::numeric_limits::quiet_NaN(); + current_statement__ = 5; + x = 2.0; + + current_statement__ = 2; + auto bar = closure00__(x); + + current_statement__ = 6; + z = std::numeric_limits::quiet_NaN(); + current_statement__ = 6; + z = foo(bar, 1.0, pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + num_params_r__ += 1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "closure_3_model_namespace::log_prob"; +(void) function__; // suppress unused var warning + + stan::io::reader in__(params_r__, params_i__); + + try { + + current_statement__ = 2; + auto bar = closure00__(x); + local_scalar_t__ p; + + current_statement__ = 1; + p = in__.scalar(); + + current_statement__ = 3; + auto baz = closure01__(p); + local_scalar_t__ w; + + current_statement__ = 4; + w = std::numeric_limits::quiet_NaN(); + current_statement__ = 4; + w = foo(baz, 1.0, pstream__); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() + + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "closure_3_model_namespace::write_array"; +(void) function__; // suppress unused var warning + + (void) function__; // suppress unused var warning + + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; + + try { + + current_statement__ = 2; + auto bar = closure00__(x); + double p; + + current_statement__ = 1; + p = in__.scalar(); + + double w; + + current_statement__ = 4; + w = std::numeric_limits::quiet_NaN(); + vars__.push_back(p); + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + current_statement__ = 3; + auto baz = closure01__(p); + current_statement__ = 4; + w = foo(baz, 1.0, pstream__); + vars__.push_back(w); + if (logical_negation(emit_generated_quantities__)) { + return ; + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // write_array() + + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { + typedef double local_scalar_t__; + vars__.resize(0); + vars__.reserve(num_params_r__); + + try { + int pos__; + + pos__ = 1; + double p; + + current_statement__ = 1; + p = context__.vals_r("p")[(1 - 1)]; + vars__.push_back(p); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("p"); + names__.push_back("w"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "p"); + if (emit_transformed_parameters__) { + param_names__.push_back(std::string() + "w"); + } + + if (emit_generated_quantities__) { + + } + + } // constrained_param_names() + + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + param_names__.push_back(std::string() + "p"); + if (emit_transformed_parameters__) { + param_names__.push_back(std::string() + "w"); + } + + if (emit_generated_quantities__) { + + } + + } // unconstrained_param_names() + + std::string get_constrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"p\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"w\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"}]"; + return s__.str(); + } // get_constrained_sizedtypes() + + std::string get_unconstrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"p\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"w\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"}]"; + return s__.str(); + } // get_unconstrained_sizedtypes() + + + // Begin method overload boilerplate + template + void write_array(RNG& base_rng__, + Eigen::Matrix& params_r, + Eigen::Matrix& vars, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream = 0) const { + std::vector params_r_vec(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r_vec[i] = params_r(i); + std::vector vars_vec; + std::vector params_i_vec; + write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, + emit_transformed_parameters__, emit_generated_quantities__, pstream); + vars.resize(vars_vec.size()); + for (int i = 0; i < vars.size(); ++i) + vars(i) = vars_vec[i]; + } + + template + T_ log_prob(Eigen::Matrix& params_r, + std::ostream* pstream = 0) const { + std::vector vec_params_r; + vec_params_r.reserve(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + vec_params_r.push_back(params_r(i)); + std::vector vec_params_i; + return log_prob(vec_params_r, vec_params_i, pstream); + } + + void transform_inits(const stan::io::var_context& context, + Eigen::Matrix& params_r, + std::ostream* pstream__) const { + std::vector params_r_vec; + std::vector params_i_vec; + transform_inits(context, params_i_vec, params_r_vec, pstream__); + params_r.resize(params_r_vec.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r(i) = params_r_vec[i]; + } + +}; +} +typedef closure_3_model_namespace::closure_3_model stan_model; #ifndef USING_R From 3ae94d707c8c42f996ef3557aecafeac2d092c95 Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Thu, 21 May 2020 21:14:35 +0300 Subject: [PATCH 8/9] C++ template mess --- src/frontend/Semantic_check.ml | 2 - src/frontend/Semantic_error.ml | 5 - src/frontend/Semantic_error.mli | 1 - src/stan_math_backend/Expression_gen.ml | 4 +- src/stan_math_backend/Stan_math_code_gen.ml | 175 +- src/stan_math_backend/Statement_gen.ml | 3 - test/integration/bad/closures/capture.stan | 9 - test/integration/bad/closures/stanc.expected | 14 - test/integration/good/code-gen/cl.expected | 9 +- test/integration/good/code-gen/closure_2.stan | 3 + test/integration/good/code-gen/closure_3.stan | 6 +- test/integration/good/code-gen/cpp.expected | 1598 ++++++++--------- .../good/compiler-optimizations/cpp.expected | 21 +- 13 files changed, 832 insertions(+), 1018 deletions(-) delete mode 100644 test/integration/bad/closures/capture.stan diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 2d487150c0..8399b3802a 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -1675,8 +1675,6 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = List.filter_map captures ~f:(fun name -> match Symbol_table.look vm name with | None | Some (Functions, UFun (_, _, Function)) -> None - | Some (_, UFun (_, _, Template)) -> - Some (error (Semantic_error.template_capture loc name)) | Some (block, type_) -> Symbol_table.set_read_only vm name ; Some (ok (calculate_autodifftype block type_, type_, name)) ) diff --git a/src/frontend/Semantic_error.ml b/src/frontend/Semantic_error.ml index 9b4290c0f3..4951d8f0de 100644 --- a/src/frontend/Semantic_error.ml +++ b/src/frontend/Semantic_error.ml @@ -226,7 +226,6 @@ module IdentifierError = struct | IsStanMathName of string | InUse of string | NotInScope of string - | TemplateCapture of string let pp ppf = function | IsStanMathName name -> @@ -238,7 +237,6 @@ module IdentifierError = struct | IsKeyword name -> Fmt.pf ppf "Identifier '%s' clashes with reserved keyword." name | NotInScope name -> Fmt.pf ppf "Identifier '%s' not in scope." name - | TemplateCapture name -> Fmt.pf ppf "Cannot capture '%s'." name end module ExpressionError = struct @@ -516,9 +514,6 @@ let ident_in_use loc name = IdentifierError (loc, IdentifierError.InUse name) let ident_not_in_scope loc name = IdentifierError (loc, IdentifierError.NotInScope name) -let template_capture loc name = - IdentifierError (loc, IdentifierError.TemplateCapture name) - let invalid_map_rect_fn loc name = ExpressionError (loc, ExpressionError.InvalidMapRectFn name) diff --git a/src/frontend/Semantic_error.mli b/src/frontend/Semantic_error.mli index 919ce132f7..cfc7da889a 100644 --- a/src/frontend/Semantic_error.mli +++ b/src/frontend/Semantic_error.mli @@ -72,7 +72,6 @@ val ident_is_model_name : Location_span.t -> string -> t val ident_is_stanmath_name : Location_span.t -> string -> t val ident_in_use : Location_span.t -> string -> t val ident_not_in_scope : Location_span.t -> string -> t -val template_capture : Location_span.t -> string -> t val invalid_map_rect_fn : Location_span.t -> string -> t val invalid_rng_fn : Location_span.t -> t val conditional_notation_not_allowed : Location_span.t -> t diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index 5b770e347b..ed23eddd19 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -376,11 +376,9 @@ and pp_compiler_internal_fn (meta : Expr.Typed.Meta.t) f ppf es = let scalar_t = if meta.adlevel = AutoDiffable then "local_scalar_t__" else "double" in - pf ppf "@[%s__<%s>(@,%a)@]" clname scalar_t + pf ppf "@[make_%s__<%s>(@,%a)@]" clname scalar_t (list ~sep:comma pp_expr) captures | _ -> raise_s [%message "Bad closure " (es : Expr.Typed.t list)] ) - | Some FnGetAdjoint -> pf ppf "%a.adj()" pp_expr (List.hd_exn es) - | Some FnGetVariPtr -> pf ppf "%a.vi_" pp_expr (List.hd_exn es) | Some FnConstrain -> pp_constrain_funapp "constrain" ppf es | Some FnUnconstrain -> pp_constrain_funapp "free" ppf es | Some FnReadData -> read_data meta.type_ ppf es diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 0a0d77fdc9..196eb773b7 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -248,10 +248,7 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure @ extra @ ["pstream__"] ) | _ -> raise_s [%message "impossible!"] ) -let forward_decl fun_def = - Program.{fun_def with fdbody= {fun_def.fdbody with Stmt.Fixed.pattern= Skip}} - -let closure_to_function clname Program.({cdrt; cdcaptures; cdargs; cdbody}) = +let function_from_closure clname Program.({cdrt; cdcaptures; cdargs; cdbody}) = Program. { fdname= clname ^ "_impl__" ; fdrt= cdrt @@ -260,38 +257,38 @@ let closure_to_function clname Program.({cdrt; cdcaptures; cdargs; cdbody}) = ; fdloc= Location_span.empty } let pp_closure_defs ppf closures = + let numbered = List.mapi ~f:(fun i x -> (i, x)) in let pp_type ppf = function - | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> - pf ppf "%s__&" clname - | AutoDiffable, UnsizedType.UFun (_, _, Closure clname) -> - pf ppf "%s__&" clname - | ad, ut when UnsizedType.is_scalar_type ut -> + | i, (_, UnsizedType.UFun _) -> pf ppf "F%d__&" i + | _, (ad, ut) when UnsizedType.is_scalar_type ut -> pp_unsizedtype_captured ppf (ad, ut) - | ad, ut -> pf ppf "%a&" pp_unsizedtype_captured (ad, ut) + | _, (ad, ut) -> pf ppf "%a&" pp_unsizedtype_captured (ad, ut) in let pp_valuetype ppf = function - | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> - pf ppf "typename %s__::ValueOf__" clname - | AutoDiffable, UFun (_, _, Closure clname) -> - pf ppf "typename %s__::ValueOf__" clname - | AutoDiffable, ut -> pp_unsizedtype_captured ppf (DataOnly, ut) - | _, ut when UnsizedType.is_scalar_type ut -> + | i, (_, UnsizedType.UFun _) -> pf ppf "typename F%d__::ValueOf__" i + | _, (UnsizedType.AutoDiffable, ut) -> + pp_unsizedtype_captured ppf (DataOnly, ut) + | _, (_, ut) when UnsizedType.is_scalar_type ut -> pp_unsizedtype_captured ppf (DataOnly, ut) - | _, ut -> pf ppf "%a&" pp_unsizedtype_captured (DataOnly, ut) + | _, (DataOnly, ut) -> pf ppf "%a&" pp_unsizedtype_captured (DataOnly, ut) in let pp_copytype ppf = function - | UnsizedType.(DataOnly, UFun (_, _, Closure clname)) -> - pf ppf "typename %s__::DeepCopy__" clname - | AutoDiffable, UFun (_, _, Closure clname) -> - pf ppf "typename %s__::DeepCopy__" clname - | ad, ut when UnsizedType.is_scalar_type ut -> - pp_unsizedtype_captured ppf (ad, ut) - | ad, ut -> pf ppf "%a&" pp_unsizedtype_captured (ad, ut) + | i, (_, UnsizedType.UFun _) -> pf ppf "typename F%d__::DeepCopy__" i + | _, (UnsizedType.AutoDiffable, ut) -> + pp_unsizedtype_captured ppf (AutoDiffable, ut) + | _, (DataOnly, ut) when UnsizedType.is_scalar_type ut -> + pp_unsizedtype_captured ppf (DataOnly, ut) + | _, (DataOnly, ut) -> pf ppf "%a&" pp_unsizedtype_captured (DataOnly, ut) + in + let pp_args ppf captures = + (list ~sep:comma (fun ppf (i, (ad, id, ut)) -> + pf ppf "const %a %s" pp_type (i, (ad, ut)) id )) + ppf (numbered captures) in let pp_members ppf (pp_type, captures) = - (list ~sep:cut (fun ppf (ad, id, ut) -> - pf ppf "const %a %s;" pp_type (ad, ut) id )) - ppf captures + (list ~sep:cut (fun ppf (i, (ad, id, ut)) -> + pf ppf "const %a %s;" pp_type (i, (ad, ut)) id )) + ppf (numbered captures) in let pp_ctor ppf (clname, captures) = let pp_count ppf captures = @@ -309,9 +306,9 @@ let pp_closure_defs ppf closures = "@[%s__(@[%a@])@ : \ %a%snum_vars__(@[stan::is_var::value ?@ %a : 0@]) { }@]" clname - (list ~sep:comma (fun ppf (ad, id, ut) -> - pf ppf "const %a %s__" pp_type (ad, ut) id )) - captures + (list ~sep:comma (fun ppf (i, (ad, id, ut)) -> + pf ppf "const %a %s__" pp_type (i, (ad, ut)) id )) + (numbered captures) (list ~sep:comma (fun ppf (_, id, _) -> pf ppf "%s(%s__)" id id)) captures (if List.is_empty captures then "" else ", ") @@ -330,9 +327,8 @@ let pp_closure_defs ppf closures = "@[%aoperator()(@[%a, std::ostream* pstream__, %a@]) const \ {@ @[return %a;@]@,}@]@," pp_returntype_closure (args, rt) (list ~sep:comma text) two - (list ~sep:comma text) tl pp_call + (list ~sep:comma text) tl pp_call_str ( name ^ "_impl__" - , text , List.map ~f:(fun (_, n, _) -> n) (args @ captures) @ ["pstream__"] ) ) in @@ -342,9 +338,8 @@ let pp_closure_defs ppf closures = @[return %a;@]@,}@]@,%a" pp_returntype_closure (args, rt) (list ~sep:comma text) s_args (if List.is_empty args then "" else ", ") - pp_call + pp_call_str ( name ^ "_impl__" - , text , List.map ~f:(fun (_, n, _) -> n) (args @ captures) @ ["pstream__"] ) pp_ode () in @@ -362,11 +357,19 @@ let pp_closure_defs ppf closures = else pf ppf "%s(init.%s)" n n )) captures in - pf ppf "@[ValueOf__(const %s__& init)%a { }@]" name pp_items + pf ppf "@[ValueOf_cl__(const %s__& init)%a { }@]@," name pp_items + captures ; + pf ppf "@[ValueOf_cl__(const DeepCopy_cl__& init)%a { }@]" pp_items captures in - pf ppf "@[class ValueOf__ {@ %a@ public:@ %a@ %a};@]" pp_members - (pp_valuetype, captures) pp_init (name, captures) pp_op + pf ppf + "@[class ValueOf_cl__ {@ %a@ public:@ const static int num_vars__ \ + = 0;@ %a@ %a@ void set_zero_adjoints() const { }@ void \ + accumulate_adjoints(double*) const { }@ void save_varis(vari**) const \ + { }@ using captured_scalar_t__ = double;@ using ValueOf__ = \ + ValueOf_cl__;@ using DeepCopy__ = ValueOf_cl__;@ };@]@ using ValueOf__ \ + = ValueOf_cl__;" + pp_members (pp_valuetype, captures) pp_init (name, captures) pp_op ((rt, false), name, captures, args) in let to_var adlevel type_ id = @@ -459,38 +462,67 @@ let pp_closure_defs ppf closures = let pp_deepcopy ppf (rt, id, captures, args) = let pp_init ppf (id, captures) = let pp_items ppf captures = - if List.is_empty captures then pf ppf "" - else - pf ppf " : %a" - (list ~sep:comma (fun ppf (ad, n, ut) -> - if - ad = UnsizedType.AutoDiffable - && not (UnsizedType.is_fun_type ut) - then pf ppf "%s(deep_copy_vars(init.%s))" n n - else pf ppf "%s(init.%s)" n n )) - captures + (list ~sep:comma (fun ppf (ad, n, ut) -> + if + ad = UnsizedType.AutoDiffable + && not (UnsizedType.is_fun_type ut) + then pf ppf "%s(deep_copy_vars(init.%s))" n n + else pf ppf "%s(init.%s)" n n )) + ppf captures in - pf ppf "@[DeepCopy__(const %s__& init)%a { }@]" id pp_items captures + pf ppf + "@[DeepCopy_cl__(const %s__& init) : %a%s \ + num_vars__(init.num_vars__) { }@]" + id pp_items captures + (if List.is_empty captures then "" else ", ") in - pf ppf "@[class DeepCopy__ {@ %a@ public:@ %a@ %a@ %a@ };@]" + pf ppf + "@[class DeepCopy_cl__ {@ %a@ public:@ %a@ %a@ %a@ const int \ + num_vars__;@ using captured_scalar_t__ = captured_t__;@ %a@ using \ + DeepCopy__ = DeepCopy_cl__;@ };@]@ using DeepCopy__ = DeepCopy_cl__;@ \ + using ValueOf__ = typename DeepCopy__::ValueOf__;" pp_members (pp_copytype, captures) pp_init (id, captures) pp_op ((rt, true), id, captures, args) - pp_accumulateadjoints captures + pp_accumulateadjoints captures pp_valueof (rt, id, captures, args) in - let f ~key ~data:Program.({cdrt; cdargs; cdcaptures; _}) = + let f ~key ~data:Program.({cdrt; cdargs; cdcaptures; cdbody}) = + cut ppf () ; + pp_fun_def ppf + Program. + { fdname= key ^ "_impl__" + ; fdrt= cdrt + ; fdargs= cdargs @ cdcaptures + ; fdbody= {cdbody with Stmt.Fixed.pattern= Skip} + ; fdloc= Location_span.empty } + true String.Set.empty ; pf ppf - "@,%a@[class %s__ {@ %a@ public:@ %s@ const int num_vars__;@ %a@ \ - %a@ %a@ %a@ %a@ %a@ %a@]@,};@," - pp_template_decorator ["typename captured_t__"] key pp_members - (pp_type, cdcaptures) "using captured_scalar_t__ = captured_t__;" pp_ctor - (key, cdcaptures) pp_op + "@,%a@[class %s__ {@,%a@ public:@ %s@ const int num_vars__;@ %a@ \ + %a@ %a@ %a@ %a@ %a@]@,};@,%a auto make_%s__(%a) {@,return \ + %s__<%a>(%a);@,}" + pp_template_decorator + ( "typename captured_t__" + :: List.filter_mapi cdcaptures ~f:(fun i (_, _, ut) -> + if UnsizedType.is_fun_type ut then Some (strf "typename F%d__" i) + else None ) ) + key pp_members (pp_type, cdcaptures) + "using captured_scalar_t__ = captured_t__;" pp_ctor (key, cdcaptures) + pp_op ((cdrt, true), key, cdcaptures, cdargs) - pp_valueof - (cdrt, key, cdcaptures, cdargs) pp_deepcopy (cdrt, key, cdcaptures, cdargs) pp_zeroadjoints cdcaptures pp_accumulateadjoints cdcaptures pp_savevaris - cdcaptures + cdcaptures pp_template_decorator + ( "typename captured_t__" + :: List.filter_mapi cdcaptures ~f:(fun i (_, _, ut) -> + if UnsizedType.is_fun_type ut then Some (strf "typename F%d__" i) + else None ) ) + key pp_args cdcaptures key (list ~sep:comma string) + ( "captured_t__" + :: List.filter_mapi cdcaptures ~f:(fun i (_, _, ut) -> + if UnsizedType.is_fun_type ut then Some (strf "F%d__" i) else None + ) ) + (list ~sep:comma string) + (List.map cdcaptures ~f:(fun (_, id, _) -> id)) in String.Map.iteri ~f closures @@ -890,6 +922,13 @@ using namespace stan::math; |} (* XXX probably move these to the Stan repo when these repos are joined. *) let custom_functions = {| +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -1003,30 +1042,16 @@ let pp_prog ppf (p : Program.Typed.t) = ~f:(fun x -> "struct " ^ x ^ reduce_sum_functor_suffix ^ ";") (fun_used_in_reduce_sum p) in - (* Closures may call user-defined functions so functions must be declared before closures. - But closures may also appear inside functions so closures must be defined before functions. - Redundant forward declarations are harmless so just declare all user functions first - then define closure classes and after that define user functions. - TODO: nested closures are still broken. *) - pf ppf - "@[@ %s@ %s@ namespace %s {@ %s@ %s@ %a@ %s@ %a@ %a@ %a@ %a@ %a@ %a@ \ - }@ @]" + pf ppf "@[@ %s@ %s@ namespace %s {@ %s@ %s@ %a@ %s@ %a@ %a@ %a@ %a@ }@ @]" version includes (namespace p) custom_functions usings Locations.pp_globals s (String.concat ~sep:"\n" (String.Set.elements reduce_sum_struct_decl)) - (list ~sep:cut pp_fun_def_with_rs_list) - (List.map ~f:forward_decl p.functions_block) - (list ~sep:cut pp_fun_def_with_rs_list) - (Map.fold ~init:[] - ~f:(fun ~key ~data accum -> - (closure_to_function key data |> forward_decl) :: accum ) - p.closures) pp_closure_defs p.closures (list ~sep:cut pp_fun_def_with_rs_list) p.functions_block (list ~sep:cut (fun ppf fd -> pp_fun_def ppf fd true String.Set.empty)) (Map.fold ~init:[] - ~f:(fun ~key ~data accum -> closure_to_function key data :: accum) + ~f:(fun ~key ~data accum -> function_from_closure key data :: accum) p.closures) pp_model p ; pf ppf "@,typedef %s_namespace::%s stan_model;@," p.prog_name p.prog_name ; diff --git a/src/stan_math_backend/Statement_gen.ml b/src/stan_math_backend/Statement_gen.ml index a2d2494739..c6dc659cb6 100644 --- a/src/stan_math_backend/Statement_gen.ml +++ b/src/stan_math_backend/Statement_gen.ml @@ -162,9 +162,6 @@ let rec pp_statement (ppf : Format.formatter) | NRFunApp (CompilerInternal, fname, [var]) when fname = Internal_fun.to_string FnWriteParam -> pf ppf "@[vars__.push_back(@,%a);@]" pp_expr var - | NRFunApp (CompilerInternal, fname, [var]) - when fname = Internal_fun.to_string FnZeroAdjoint -> - pf ppf "@[%a.set_zero_adjoint();@]" pp_expr var | NRFunApp (CompilerInternal, fname, args) -> let fname, extra_args = trans_math_fn fname in pf ppf "%s(@[%a@]);" fname (list ~sep:comma pp_expr) diff --git a/test/integration/bad/closures/capture.stan b/test/integration/bad/closures/capture.stan deleted file mode 100644 index 3343f2f220..0000000000 --- a/test/integration/bad/closures/capture.stan +++ /dev/null @@ -1,9 +0,0 @@ -functions { - real foo(real(real) g) { - functions - real f(real x) { - return g(x)^2; - } - return f(1.0) + f(2.0); - } -} \ No newline at end of file diff --git a/test/integration/bad/closures/stanc.expected b/test/integration/bad/closures/stanc.expected index 32fbde37ea..df56181bf0 100644 --- a/test/integration/bad/closures/stanc.expected +++ b/test/integration/bad/closures/stanc.expected @@ -1,17 +1,3 @@ - $ ../../../../../install/default/bin/stanc capture.stan - -Semantic error in 'capture.stan', line 3, column 8 to line 6, column 9: - ------------------------------------------------- - 1: functions { - 2: real foo(real(real) g) { - 3: functions - ^ - 4: real f(real x) { - 5: return g(x)^2; - ------------------------------------------------- - -Cannot capture 'g'. - $ ../../../../../install/default/bin/stanc closure_lp.stan Semantic error in 'closure_lp.stan', line 6, column 7 to column 13: diff --git a/test/integration/good/code-gen/cl.expected b/test/integration/good/code-gen/cl.expected index c2ad5100cc..0cb48237e2 100644 --- a/test/integration/good/code-gen/cl.expected +++ b/test/integration/good/code-gen/cl.expected @@ -4,6 +4,13 @@ #include namespace optimize_glm_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -287,8 +294,6 @@ static const std::vector locations_array__ = {" (found before start of p - - class optimize_glm_model : public model_base_crtp { private: diff --git a/test/integration/good/code-gen/closure_2.stan b/test/integration/good/code-gen/closure_2.stan index 717119a7a1..b79f46b6fa 100644 --- a/test/integration/good/code-gen/closure_2.stan +++ b/test/integration/good/code-gen/closure_2.stan @@ -24,4 +24,7 @@ transformed parameters { } return gar(s); } + real s1 = bar(1.0); + real s2 = baz(1.0); + real s3 = goo(1.0); } diff --git a/test/integration/good/code-gen/closure_3.stan b/test/integration/good/code-gen/closure_3.stan index 2e0463456f..72a9bbef26 100644 --- a/test/integration/good/code-gen/closure_3.stan +++ b/test/integration/good/code-gen/closure_3.stan @@ -1,6 +1,10 @@ functions { real foo(real(real) g, real x) { - return g(1+x); + functions + real g2(real y) { + return g(y) * x; + } + return g2(1.0); } } transformed data { diff --git a/test/integration/good/code-gen/cpp.expected b/test/integration/good/code-gen/cpp.expected index 32d4274c9c..206c65f594 100644 --- a/test/integration/good/code-gen/cpp.expected +++ b/test/integration/good/code-gen/cpp.expected @@ -4,6 +4,13 @@ #include namespace closure_1_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -111,16 +118,6 @@ static const std::vector locations_array__ = {" (found before start of p -template -typename boost::math::tools::promote_args::type -closure01_impl__(const T0__& z, const Eigen::Matrix& r, - const T2__& p, const std::vector& pa, - const Eigen::Matrix& pv, - const Eigen::Matrix& v, const double& x, - const std::vector& y, std::ostream* pstream__) ; - template typename boost::math::tools::promote_args::type @@ -128,7 +125,6 @@ closure00_impl__(const T0__& z, const Eigen::Matrix& r, const Eigen::Matrix& v, const double& x, const std::vector& y, std::ostream* pstream__) ; - template class closure00__ { const Eigen::Matrix& v; @@ -149,26 +145,13 @@ T1__>::type>::type return closure00_impl__(z, r, v, x, y, pstream__); } - class ValueOf__ { - const Eigen::Matrix& v; - const double x; - const std::vector& y; - public: - ValueOf__(const closure00__& init) : v(init.v), x(init.x), y(init.y) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& z, const Eigen::Matrix& - r, std::ostream* pstream__) const { - return closure00_impl__(z, r, v, x, y, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { const Eigen::Matrix& v; const double x; const std::vector& y; public: - DeepCopy__(const closure00__& init) : v(init.v), x(init.x), y(init.y) { } + DeepCopy_cl__(const closure00__& init) : v(init.v), x(init.x), + y(init.y), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure00__& init) : v(init.v), x(init.x), + y(init.y) { } + ValueOf_cl__(const DeepCopy_cl__& init) : v(init.v), x(init.x), + y(init.y) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure00_impl__(z, r, v, x, y, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -203,6 +217,23 @@ T1__>::type>::type } } }; +template + auto make_closure00__(const Eigen::Matrix& v, +const double x, +const std::vector& y) { +return closure00__(v, +x, +y); +} +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& z, const Eigen::Matrix& r, + const T2__& p, const std::vector& pa, + const Eigen::Matrix& pv, + const Eigen::Matrix& v, const double& x, + const std::vector& y, std::ostream* pstream__) ; template class closure01__ { @@ -231,36 +262,17 @@ T1__>::type>::type return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); } - class ValueOf__ { - const double p; - const std::vector pa; - const Eigen::Matrix pv; - const Eigen::Matrix& v; - const double x; - const std::vector& y; - public: - ValueOf__(const closure01__& init) : p(value_of(init.p)), - pa(value_of(init.pa)), pv(value_of(init.pv)), v(init.v), x(init.x), - y(init.y) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& z, const Eigen::Matrix& - r, std::ostream* pstream__) const { - return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { const captured_t__ p; - const std::vector& pa; - const Eigen::Matrix& pv; + const std::vector pa; + const Eigen::Matrix pv; const Eigen::Matrix& v; const double x; const std::vector& y; public: - DeepCopy__(const closure01__& init) : p(deep_copy_vars(init.p)), + DeepCopy_cl__(const closure01__& init) : p(deep_copy_vars(init.p)), pa(deep_copy_vars(init.pa)), pv(deep_copy_vars(init.pv)), v(init.v), - x(init.x), y(init.y) { } + x(init.x), y(init.y), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type void accumulate_adjoints(double* ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(p)); pos__ = (pos__ + 1); for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pa[(sym1__ - 1)].adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + + FnGetAdjoint__(pa[(sym1__ - 1)])); pos__ = (pos__ + 1);} for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pv[(sym1__ - 1)].adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + + FnGetAdjoint__(pv[(sym1__ - 1)])); pos__ = (pos__ + 1);} } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const double p; + const std::vector pa; + const Eigen::Matrix pv; + const Eigen::Matrix& v; + const double x; + const std::vector& y; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure01__& init) : p(value_of(init.p)), + pa(value_of(init.pa)), pv(value_of(init.pv)), v(init.v), x(init.x), + y(init.y) { } + ValueOf_cl__(const DeepCopy_cl__& init) : p(value_of(init.p)), + pa(value_of(init.pa)), pv(value_of(init.pv)), v(init.v), x(init.x), + y(init.y) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& z, const Eigen::Matrix& + r, std::ostream* pstream__) const { + return closure01_impl__(z, r, p, pa, pv, v, x, y, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { - p.set_zero_adjoint(); + FnZeroAdjoint__(p); for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { - pa[(sym1__ - 1)].set_zero_adjoint();} + FnZeroAdjoint__(pa[(sym1__ - 1)]);} for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { - pv[(sym1__ - 1)].set_zero_adjoint();} + FnZeroAdjoint__(pv[(sym1__ - 1)]);} } } void accumulate_adjoints(double* ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(p)); pos__ = (pos__ + 1); for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pa[(sym1__ - 1)].adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + + FnGetAdjoint__(pa[(sym1__ - 1)])); pos__ = (pos__ + 1);} for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + pv[(sym1__ - 1)].adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + + FnGetAdjoint__(pv[(sym1__ - 1)])); pos__ = (pos__ + 1);} } } void save_varis(vari** ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = p.vi_; + ptr[(pos__ - 1)] = FnGetVariPtr__(p); pos__ = (pos__ + 1); for (size_t sym1__ = 1; sym1__ <= stan::math::size(pa); ++sym1__) { - ptr[(pos__ - 1)] = pa[(sym1__ - 1)].vi_; + ptr[(pos__ - 1)] = FnGetVariPtr__(pa[(sym1__ - 1)]); pos__ = (pos__ + 1);} for (size_t sym1__ = 1; sym1__ <= stan::math::size(pv); ++sym1__) { - ptr[(pos__ - 1)] = pv[(sym1__ - 1)].vi_; + ptr[(pos__ - 1)] = FnGetVariPtr__(pv[(sym1__ - 1)]); pos__ = (pos__ + 1);} } } }; - +template + auto make_closure01__(const captured_t__ p, +const std::vector& pa, +const Eigen::Matrix& pv, +const Eigen::Matrix& v, +const double x, +const std::vector& y) { +return closure01__(p, +pa, +pv, +v, +x, +y); +} template @@ -440,7 +505,7 @@ class closure_1_model : public model_base_crtp { } current_statement__ = 4; - auto foo = closure00__(v, x, y); + auto foo = make_closure00__(v, x, y); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -476,7 +541,7 @@ class closure_1_model : public model_base_crtp { try { current_statement__ = 4; - auto foo = closure00__(v, x, y); + auto foo = make_closure00__(v, x, y); local_scalar_t__ p; current_statement__ = 1; @@ -501,7 +566,7 @@ class closure_1_model : public model_base_crtp { { current_statement__ = 5; - auto bar = closure01__(p, pa, pv, v, x, y); + auto bar = make_closure01__(p, pa, pv, v, x, y); current_statement__ = 6; lp_accum__.add( foo(0.0, stan::math::to_row_vector( @@ -549,7 +614,7 @@ class closure_1_model : public model_base_crtp { try { current_statement__ = 4; - auto foo = closure00__(v, x, y); + auto foo = make_closure00__(v, x, y); double p; current_statement__ = 1; @@ -793,6 +858,13 @@ stan::model::model_base& new_model( #include namespace closure_2_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -885,6 +957,9 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'closure_2.stan', line 6, column 2 to line 9, column 3)", " (in 'closure_2.stan', line 15, column 2 to line 18, column 3)", " (in 'closure_2.stan', line 19, column 2 to line 26, column 3)", + " (in 'closure_2.stan', line 27, column 2 to column 21)", + " (in 'closure_2.stan', line 28, column 2 to column 21)", + " (in 'closure_2.stan', line 29, column 2 to column 21)", " (in 'closure_2.stan', line 4, column 4 to column 13)", " (in 'closure_2.stan', line 3, column 19 to line 5, column 3)", " (in 'closure_2.stan', line 8, column 4 to column 18)", @@ -899,29 +974,10 @@ static const std::vector locations_array__ = {" (found before start of p -template -typename boost::math::tools::promote_args::type -closure04_impl__(const T0__& b, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -closure03_impl__(const T0__& s, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; - template typename boost::math::tools::promote_args::type closure00_impl__(const T0__& x, std::ostream* pstream__) ; - template class closure00__ { @@ -936,20 +992,10 @@ typename boost::math::tools::promote_args::type>::type return closure00_impl__(x, pstream__); } - class ValueOf__ { - - public: - ValueOf__(const closure00__& init) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& x, std::ostream* pstream__) const { - return closure00_impl__(x, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { public: - DeepCopy__(const closure00__& init) { } + DeepCopy_cl__(const closure00__& init) : num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type @@ -963,7 +1009,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure00__& init) { } + ValueOf_cl__(const DeepCopy_cl__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& x, std::ostream* pstream__) const { + return closure00_impl__(x, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -982,14 +1053,22 @@ typename boost::math::tools::promote_args::type>::type } } }; - template + auto make_closure00__() { +return closure00__(); +} +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; + +template class closure01__ { - const closure00__& foo; + const F0__& foo; public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure01__(const closure00__& foo__) + closure01__(const F0__& foo__) : foo(foo__), num_vars__(stan::is_var::value ? 0 : 0) { } template typename boost::math::tools::promote_args::type>::type return closure01_impl__(y, foo, pstream__); } - class ValueOf__ { - const typename closure00__::ValueOf__ foo; - public: - ValueOf__(const closure01__& init) : foo(init.foo) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& y, std::ostream* pstream__) const { - return closure01_impl__(y, foo, pstream__); - } - }; - class DeepCopy__ { - const typename closure00__::DeepCopy__ foo; + class DeepCopy_cl__ { + const typename F0__::DeepCopy__ foo; public: - DeepCopy__(const closure01__& init) : foo(init.foo) { } + DeepCopy_cl__(const closure01__& init) : foo(init.foo), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type @@ -1025,7 +1094,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const typename F0__::ValueOf__ foo; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure01__& init) : foo(init.foo) { } + ValueOf_cl__(const DeepCopy_cl__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, foo, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -1044,14 +1138,23 @@ typename boost::math::tools::promote_args::type>::type } } }; +template + auto make_closure01__(const F0__& foo) { +return closure01__(foo); +} +template +typename boost::math::tools::promote_args::type +closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) ; -template +template class closure02__ { - const closure00__& foo; + const F0__& foo; public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure02__(const closure00__& foo__) + closure02__(const F0__& foo__) : foo(foo__), num_vars__(stan::is_var::value ? 0 : 0) { } template typename boost::math::tools::promote_args::type>::type return closure02_impl__(y, foo, pstream__); } - class ValueOf__ { - const typename closure00__::ValueOf__ foo; + class DeepCopy_cl__ { + const typename F0__::DeepCopy__ foo; public: - ValueOf__(const closure02__& init) : foo(init.foo) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& y, std::ostream* pstream__) const { - return closure02_impl__(y, foo, pstream__); - } - }; - class DeepCopy__ { - const typename closure00__::DeepCopy__ foo; - public: - DeepCopy__(const closure02__& init) : foo(init.foo) { } + DeepCopy_cl__(const closure02__& init) : foo(init.foo), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type @@ -1087,7 +1180,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const typename F0__::ValueOf__ foo; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure02__& init) : foo(init.foo) { } + ValueOf_cl__(const DeepCopy_cl__& init) : foo(init.foo) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure02_impl__(y, foo, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -1106,6 +1224,14 @@ typename boost::math::tools::promote_args::type>::type } } }; +template + auto make_closure02__(const F0__& foo) { +return closure02__(foo); +} +template +typename boost::math::tools::promote_args::type +closure03_impl__(const T0__& s, std::ostream* pstream__) ; template class closure03__ { @@ -1121,20 +1247,10 @@ typename boost::math::tools::promote_args::type>::type return closure03_impl__(s, pstream__); } - class ValueOf__ { - - public: - ValueOf__(const closure03__& init) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& s, std::ostream* pstream__) const { - return closure03_impl__(s, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { public: - DeepCopy__(const closure03__& init) { } + DeepCopy_cl__(const closure03__& init) : num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type @@ -1148,7 +1264,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure03__& init) { } + ValueOf_cl__(const DeepCopy_cl__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& s, std::ostream* pstream__) const { + return closure03_impl__(s, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -1167,6 +1308,13 @@ typename boost::math::tools::promote_args::type>::type } } }; +template + auto make_closure03__() { +return closure03__(); +} +template +typename boost::math::tools::promote_args::type +closure04_impl__(const T0__& b, std::ostream* pstream__) ; template class closure04__ { @@ -1182,20 +1330,10 @@ typename boost::math::tools::promote_args::type>::type return closure04_impl__(b, pstream__); } - class ValueOf__ { - - public: - ValueOf__(const closure04__& init) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& b, std::ostream* pstream__) const { - return closure04_impl__(b, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { public: - DeepCopy__(const closure04__& init) { } + DeepCopy_cl__(const closure04__& init) : num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type @@ -1209,7 +1347,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure04__& init) { } + ValueOf_cl__(const DeepCopy_cl__& init) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& b, std::ostream* pstream__) const { + return closure04_impl__(b, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -1228,7 +1391,10 @@ typename boost::math::tools::promote_args::type>::type } } }; - +template + auto make_closure04__() { +return closure04__(); +} template typename boost::math::tools::promote_args::type @@ -1238,7 +1404,7 @@ closure04_impl__(const T0__& b, std::ostream* pstream__) { (void) propto__; try { - current_statement__ = 15; + current_statement__ = 18; return b; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1256,9 +1422,9 @@ closure03_impl__(const T0__& s, std::ostream* pstream__) { try { - current_statement__ = 12; - auto gar = closure04__(); - current_statement__ = 13; + current_statement__ = 15; + auto gar = make_closure04__(); + current_statement__ = 16; return gar(s, pstream__); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1277,7 +1443,7 @@ closure02_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { (void) propto__; try { - current_statement__ = 10; + current_statement__ = 13; return foo(y, pstream__); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1296,7 +1462,7 @@ closure01_impl__(const T0__& y, const T1__& foo, std::ostream* pstream__) { (void) propto__; try { - current_statement__ = 8; + current_statement__ = 11; return foo(y, pstream__); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1313,7 +1479,7 @@ closure00_impl__(const T0__& x, std::ostream* pstream__) { (void) propto__; try { - current_statement__ = 6; + current_statement__ = 9; return x; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1347,10 +1513,10 @@ class closure_2_model : public model_base_crtp { pos__ = 1; current_statement__ = 2; - auto foo = closure00__(); + auto foo = make_closure00__(); current_statement__ = 3; - auto bar = closure01__(foo); + auto bar = make_closure01__(foo); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -1380,20 +1546,38 @@ class closure_2_model : public model_base_crtp { try { current_statement__ = 2; - auto foo = closure00__(); + auto foo = make_closure00__(); current_statement__ = 3; - auto bar = closure01__(foo); + auto bar = make_closure01__(foo); local_scalar_t__ alpha; current_statement__ = 1; alpha = in__.scalar(); current_statement__ = 4; - auto baz = closure02__(foo); + auto baz = make_closure02__(foo); current_statement__ = 5; - auto goo = closure03__(); + auto goo = make_closure03__(); + local_scalar_t__ s1; + + current_statement__ = 6; + s1 = std::numeric_limits::quiet_NaN(); + current_statement__ = 6; + s1 = bar(1.0, pstream__); + local_scalar_t__ s2; + + current_statement__ = 7; + s2 = std::numeric_limits::quiet_NaN(); + current_statement__ = 7; + s2 = baz(1.0, pstream__); + local_scalar_t__ s3; + + current_statement__ = 8; + s3 = std::numeric_limits::quiet_NaN(); + current_statement__ = 8; + s3 = goo(1.0, pstream__); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -1424,25 +1608,46 @@ class closure_2_model : public model_base_crtp { try { current_statement__ = 2; - auto foo = closure00__(); + auto foo = make_closure00__(); current_statement__ = 3; - auto bar = closure01__(foo); + auto bar = make_closure01__(foo); double alpha; current_statement__ = 1; alpha = in__.scalar(); + double s1; + + current_statement__ = 6; + s1 = std::numeric_limits::quiet_NaN(); + double s2; + + current_statement__ = 7; + s2 = std::numeric_limits::quiet_NaN(); + double s3; + + current_statement__ = 8; + s3 = std::numeric_limits::quiet_NaN(); vars__.push_back(alpha); if (logical_negation((primitive_value(emit_transformed_parameters__) || primitive_value(emit_generated_quantities__)))) { return ; } current_statement__ = 4; - auto baz = closure02__(foo); + auto baz = make_closure02__(foo); current_statement__ = 5; - auto goo = closure03__(); + auto goo = make_closure03__(); + current_statement__ = 6; + s1 = bar(1.0, pstream__); + current_statement__ = 7; + s2 = baz(1.0, pstream__); + current_statement__ = 8; + s3 = goo(1.0, pstream__); + vars__.push_back(s1); + vars__.push_back(s2); + vars__.push_back(s3); if (logical_negation(emit_generated_quantities__)) { return ; } @@ -1480,6 +1685,9 @@ class closure_2_model : public model_base_crtp { names__.resize(0); names__.push_back("alpha"); + names__.push_back("s1"); + names__.push_back("s2"); + names__.push_back("s3"); } // get_param_names() void get_dims(std::vector>& dimss__) const { @@ -1487,6 +1695,12 @@ class closure_2_model : public model_base_crtp { std::vector dims__; dimss__.push_back(dims__); dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); } // get_dims() @@ -1496,7 +1710,9 @@ class closure_2_model : public model_base_crtp { param_names__.push_back(std::string() + "alpha"); if (emit_transformed_parameters__) { - + param_names__.push_back(std::string() + "s1"); + param_names__.push_back(std::string() + "s2"); + param_names__.push_back(std::string() + "s3"); } if (emit_generated_quantities__) { @@ -1511,7 +1727,9 @@ class closure_2_model : public model_base_crtp { param_names__.push_back(std::string() + "alpha"); if (emit_transformed_parameters__) { - + param_names__.push_back(std::string() + "s1"); + param_names__.push_back(std::string() + "s2"); + param_names__.push_back(std::string() + "s3"); } if (emit_generated_quantities__) { @@ -1522,13 +1740,13 @@ class closure_2_model : public model_base_crtp { std::string get_constrained_sizedtypes() const { stringstream s__; - s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"; + s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"s1\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"s2\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"s3\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"}]"; return s__.str(); } // get_constrained_sizedtypes() std::string get_unconstrained_sizedtypes() const { stringstream s__; - s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"; + s__ << "[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"s1\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"s2\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"s3\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"}]"; return s__.str(); } // get_unconstrained_sizedtypes() @@ -1600,6 +1818,13 @@ stan::model::model_base& new_model( #include namespace closure_3_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -1687,69 +1912,159 @@ using namespace stan::math; static int current_statement__ = 0; static const std::vector locations_array__ = {" (found before start of program)", - " (in 'closure_3.stan', line 15, column 4 to column 11)", - " (in 'closure_3.stan', line 8, column 4 to line 11, column 5)", - " (in 'closure_3.stan', line 18, column 4 to line 21, column 5)", - " (in 'closure_3.stan', line 22, column 4 to column 27)", - " (in 'closure_3.stan', line 7, column 4 to column 17)", - " (in 'closure_3.stan', line 12, column 4 to column 27)", - " (in 'closure_3.stan', line 3, column 8 to column 22)", - " (in 'closure_3.stan', line 2, column 35 to line 4, column 5)", - " (in 'closure_3.stan', line 10, column 8 to column 19)", - " (in 'closure_3.stan', line 9, column 21 to line 11, column 5)", - " (in 'closure_3.stan', line 20, column 8 to column 19)", - " (in 'closure_3.stan', line 19, column 21 to line 21, column 5)"}; + " (in 'closure_3.stan', line 19, column 4 to column 11)", + " (in 'closure_3.stan', line 12, column 4 to line 15, column 5)", + " (in 'closure_3.stan', line 22, column 4 to line 25, column 5)", + " (in 'closure_3.stan', line 26, column 4 to column 27)", + " (in 'closure_3.stan', line 11, column 4 to column 17)", + " (in 'closure_3.stan', line 16, column 4 to column 27)", + " (in 'closure_3.stan', line 3, column 8 to line 6, column 9)", + " (in 'closure_3.stan', line 7, column 8 to column 23)", + " (in 'closure_3.stan', line 2, column 35 to line 8, column 5)", + " (in 'closure_3.stan', line 5, column 12 to column 28)", + " (in 'closure_3.stan', line 4, column 24 to line 6, column 9)", + " (in 'closure_3.stan', line 14, column 8 to column 19)", + " (in 'closure_3.stan', line 13, column 21 to line 15, column 5)", + " (in 'closure_3.stan', line 24, column 8 to column 19)", + " (in 'closure_3.stan', line 23, column 21 to line 25, column 5)"}; -template -typename boost::math::tools::promote_args::type -foo(const T0__& g, const T1__& x, std::ostream* pstream__) ; -template +template typename boost::math::tools::promote_args::type -closure01_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -closure00_impl__(const T0__& y, const double& x, std::ostream* pstream__) ; - +typename T1__::captured_scalar_t__, +T2__>::type +closure00_impl__(const T0__& y, const T1__& g, const T2__& x, + std::ostream* pstream__) ; -template +template class closure00__ { - const double x; + const F0__& g; + const captured_t__ x; public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure00__(const double x__) - : x(x__), num_vars__(stan::is_var::value ? 0 : 0) { } + closure00__(const F0__& g__, const captured_t__ x__) : g(g__), + x(x__), num_vars__(stan::is_var::value ? g__.num_vars__ + + 1 : 0) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& y, std::ostream* pstream__) const { - return closure00_impl__(y, x, pstream__); + return closure00_impl__(y, g, x, pstream__); } - class ValueOf__ { - const double x; + class DeepCopy_cl__ { + const typename F0__::DeepCopy__ g; + const captured_t__ x; public: - ValueOf__(const closure00__& init) : x(init.x) { } + DeepCopy_cl__(const closure00__& init) : g(init.g), + x(deep_copy_vars(init.x)), num_vars__(init.num_vars__) { } template - typename boost::math::tools::promote_args::type + typename boost::math::tools::promote_args::type>::type operator()(const T0__& y, std::ostream* pstream__) const { - return closure00_impl__(y, x, pstream__); + return closure00_impl__(y, g, x, pstream__); } + + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + g.accumulate_adjoints(ptr + (pos__ - 1)); + pos__ += g.num_vars__; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(x)); + pos__ = (pos__ + 1); + } + } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const typename F0__::ValueOf__ g; + const double x; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure00__& init) : g(init.g), + x(value_of(init.x)) { } + ValueOf_cl__(const DeepCopy_cl__& init) : g(init.g), + x(value_of(init.x)) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure00_impl__(y, g, x, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; - class DeepCopy__ { + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; + void set_zero_adjoints() const { + if (stan::is_var::value) { + g.set_zero_adjoints(); + FnZeroAdjoint__(x); + } + } + void accumulate_adjoints(double* ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + g.accumulate_adjoints(ptr + (pos__ - 1)); + pos__ += g.num_vars__; + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(x)); + pos__ = (pos__ + 1); + } + } + void save_varis(vari** ptr) const { + if (stan::is_var::value) { + size_t pos__ = 1; + g.save_varis(ptr + (pos__ - 1)); + pos__ += g.num_vars__; + ptr[(pos__ - 1)] = FnGetVariPtr__(x); + pos__ = (pos__ + 1); + } + } +}; +template + auto make_closure00__(const F0__& g, +const captured_t__ x) { +return closure00__(g, +x); +} +template +typename boost::math::tools::promote_args::type +closure01_impl__(const T0__& y, const double& x, std::ostream* pstream__) ; + +template +class closure01__ { + const double x; + public: + using captured_scalar_t__ = captured_t__; + const int num_vars__; + closure01__(const double x__) + : x(x__), num_vars__(stan::is_var::value ? 0 : 0) { } + template + typename boost::math::tools::promote_args::type>::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, x, pstream__); + } + + class DeepCopy_cl__ { const double x; public: - DeepCopy__(const closure00__& init) : x(init.x) { } + DeepCopy_cl__(const closure01__& init) : x(init.x), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& y, std::ostream* pstream__) const { - return closure00_impl__(y, x, pstream__); + return closure01_impl__(y, x, pstream__); } void accumulate_adjoints(double* ptr) const { @@ -1758,7 +2073,32 @@ typename boost::math::tools::promote_args::type>::type } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const double x; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure01__& init) : x(init.x) { } + ValueOf_cl__(const DeepCopy_cl__& init) : x(init.x) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure01_impl__(y, x, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { @@ -1777,72 +2117,98 @@ typename boost::math::tools::promote_args::type>::type } } }; +template + auto make_closure01__(const double x) { +return closure01__(x); +} +template +typename boost::math::tools::promote_args::type +closure02_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) ; template -class closure01__ { +class closure02__ { const captured_t__ p; public: using captured_scalar_t__ = captured_t__; const int num_vars__; - closure01__(const captured_t__ p__) + closure02__(const captured_t__ p__) : p(p__), num_vars__(stan::is_var::value ? 1 : 0) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& y, std::ostream* pstream__) const { - return closure01_impl__(y, p, pstream__); + return closure02_impl__(y, p, pstream__); } - class ValueOf__ { - const double p; - public: - ValueOf__(const closure01__& init) : p(value_of(init.p)) { } - template - typename boost::math::tools::promote_args::type - operator()(const T0__& y, std::ostream* pstream__) const { - return closure01_impl__(y, p, pstream__); - } - }; - class DeepCopy__ { + class DeepCopy_cl__ { const captured_t__ p; public: - DeepCopy__(const closure01__& init) : p(deep_copy_vars(init.p)) { } + DeepCopy_cl__(const closure02__& init) : p(deep_copy_vars(init.p)), num_vars__(init.num_vars__) { } template typename boost::math::tools::promote_args::type>::type operator()(const T0__& y, std::ostream* pstream__) const { - return closure01_impl__(y, p, pstream__); + return closure02_impl__(y, p, pstream__); } void accumulate_adjoints(double* ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(p)); pos__ = (pos__ + 1); } } + const int num_vars__; + using captured_scalar_t__ = captured_t__; + class ValueOf_cl__ { + const double p; + public: + const static int num_vars__ = 0; + ValueOf_cl__(const closure02__& init) : p(value_of(init.p)) { } + ValueOf_cl__(const DeepCopy_cl__& init) : p(value_of(init.p)) { } + template + typename boost::math::tools::promote_args::type + operator()(const T0__& y, std::ostream* pstream__) const { + return closure02_impl__(y, p, pstream__); + } + + void set_zero_adjoints() const { } + void accumulate_adjoints(double*) const { } + void save_varis(vari**) const { } + using captured_scalar_t__ = double; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = ValueOf_cl__; + }; + using ValueOf__ = ValueOf_cl__; + using DeepCopy__ = DeepCopy_cl__; }; + using DeepCopy__ = DeepCopy_cl__; + using ValueOf__ = typename DeepCopy__::ValueOf__; void set_zero_adjoints() const { if (stan::is_var::value) { - p.set_zero_adjoint(); + FnZeroAdjoint__(p); } } void accumulate_adjoints(double* ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + p.adj()); + ptr[(pos__ - 1)] = (ptr[(pos__ - 1)] + FnGetAdjoint__(p)); pos__ = (pos__ + 1); } } void save_varis(vari** ptr) const { if (stan::is_var::value) { size_t pos__ = 1; - ptr[(pos__ - 1)] = p.vi_; + ptr[(pos__ - 1)] = FnGetVariPtr__(p); pos__ = (pos__ + 1); } } }; - +template + auto make_closure02__(const captured_t__ p) { +return closure02__(p); +} template typename boost::math::tools::promote_args::type @@ -1853,8 +2219,11 @@ foo(const T0__& g, const T1__& x, std::ostream* pstream__) { (void) propto__; try { + current_statement__ = 7; - return g((1 + x), pstream__); + auto g2 = make_closure00__(g, x); + current_statement__ = 8; + return g2(1.0, pstream__); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); // Next line prevents compiler griping about no return @@ -1877,14 +2246,14 @@ return foo(g, x, pstream__); template typename boost::math::tools::promote_args::type -closure01_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) { +closure02_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; const static bool propto__ = true; (void) propto__; try { - current_statement__ = 11; + current_statement__ = 14; return (p * y); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1895,13 +2264,13 @@ closure01_impl__(const T0__& y, const T1__& p, std::ostream* pstream__) { } template typename boost::math::tools::promote_args::type -closure00_impl__(const T0__& y, const double& x, std::ostream* pstream__) { +closure01_impl__(const T0__& y, const double& x, std::ostream* pstream__) { using local_scalar_t__ = typename boost::math::tools::promote_args::type; const static bool propto__ = true; (void) propto__; try { - current_statement__ = 9; + current_statement__ = 12; return (x * y); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); @@ -1909,6 +2278,28 @@ closure00_impl__(const T0__& y, const double& x, std::ostream* pstream__) { throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); } +} +template +typename boost::math::tools::promote_args::type +closure00_impl__(const T0__& y, const T1__& g, const T2__& x, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 10; + return (g(y, pstream__) * x); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } class closure_3_model : public model_base_crtp { @@ -1942,7 +2333,7 @@ class closure_3_model : public model_base_crtp { x = 2.0; current_statement__ = 2; - auto bar = closure00__(x); + auto bar = make_closure01__(x); current_statement__ = 6; z = std::numeric_limits::quiet_NaN(); @@ -1977,14 +2368,14 @@ class closure_3_model : public model_base_crtp { try { current_statement__ = 2; - auto bar = closure00__(x); + auto bar = make_closure01__(x); local_scalar_t__ p; current_statement__ = 1; p = in__.scalar(); current_statement__ = 3; - auto baz = closure01__(p); + auto baz = make_closure02__(p); local_scalar_t__ w; current_statement__ = 4; @@ -2021,7 +2412,7 @@ class closure_3_model : public model_base_crtp { try { current_statement__ = 2; - auto bar = closure00__(x); + auto bar = make_closure01__(x); double p; current_statement__ = 1; @@ -2037,7 +2428,7 @@ class closure_3_model : public model_base_crtp { return ; } current_statement__ = 3; - auto baz = closure01__(p); + auto baz = make_closure02__(p); current_statement__ = 4; w = foo(baz, 1.0, pstream__); vars__.push_back(w); @@ -2201,6 +2592,13 @@ stan::model::model_base& new_model( #include namespace eight_schools_ncp_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -2304,8 +2702,6 @@ static const std::vector locations_array__ = {" (found before start of p - - class eight_schools_ncp_model : public model_base_crtp { private: @@ -2726,6 +3122,13 @@ stan::model::model_base& new_model( #include namespace mother_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -3262,362 +3665,16 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'mother.stan', line 291, column 27 to line 294, column 3)", " (in 'mother.stan', line 296, column 4 to column 48)", " (in 'mother.stan', line 297, column 4 to column 26)", - " (in 'mother.stan', line 295, column 27 to line 298, column 3)", - " (in 'mother.stan', line 303, column 4 to column 18)", - " (in 'mother.stan', line 304, column 4 to column 25)", - " (in 'mother.stan', line 305, column 4 to column 25)", - " (in 'mother.stan', line 306, column 4 to column 15)", - " (in 'mother.stan', line 302, column 39 to line 307, column 3)", - " (in 'mother.stan', line 310, column 4 to column 19)", - " (in 'mother.stan', line 311, column 4 to column 18)", - " (in 'mother.stan', line 312, column 4 to column 16)", - " (in 'mother.stan', line 309, column 78 to line 313, column 3)"}; - - -int -foo(const int& n, std::ostream* pstream__) ; - -int -foo(const int& n, std::ostream* pstream__) ; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -template -std::vector::type> -sho(const T0__& t, const std::vector& y, - const std::vector& theta, const std::vector& x, - const std::vector& x_int, std::ostream* pstream__) ; - -double -foo_bar0(std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_bar1(const T0__& x, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_bar2(const T0__& x, const T1__& y, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lpmf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lcdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lccdf(const int& y, const T1__& lambda, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_rng(const T0__& mu, const T1__& sigma, RNG& base_rng__, - std::ostream* pstream__) ; - -template -void -unit_normal_lp(const T0__& u, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -int -foo_1(const int& a, std::ostream* pstream__) ; - -int -foo_2(const int& a, std::ostream* pstream__) ; - -template -std::vector::type> -foo_3(const T0__& t, const int& n, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lp(const T0__& x, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -template -void -foo_4(const T0__& x, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -relative_diff(const T0__& x, const T1__& y, const T2__& max_, - const T3__& min_, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -foo_5(const Eigen::Matrix& shared_params, - const Eigen::Matrix& job_params, - const std::vector& data_r, const std::vector& data_i, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_five_args(const T0__& x1, const T1__& x2, const T2__& x3, const T3__& x4, - const T4__& x5, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type>::type -foo_five_args_lp(const T0__& x1, const T1__& x2, const T2__& x3, - const T3__& x4, const T4__& x5, const T5__& x6, - T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, -1> -covsqrt2corsqrt(const Eigen::Matrix& mat, const int& invert, - std::ostream* pstream__) ; - -template -void -f0(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -int -f1(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector -f2(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector> -f3(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type>::type -f4(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type> -f5(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type>> -f6(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type>::type, -1, 1> -f7(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, 1>> -f8(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, 1>>> -f9(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type>::type, -1, -1> -f10(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, -1>> -f11(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -template -std::vector::type>::type, -1, -1>>> -f12(const int& a1, const std::vector& a2, - const std::vector>& a3, const T3__& a4, - const std::vector& a5, const std::vector>& a6, - const Eigen::Matrix& a7, - const std::vector>& a8, - const std::vector>>& a9, - const Eigen::Matrix& a10, - const std::vector>& a11, - const std::vector>>& a12, - std::ostream* pstream__) ; - -void -foo_6(std::ostream* pstream__) ; - -Eigen::Matrix -matfoo(std::ostream* pstream__) ; - -Eigen::Matrix -vecfoo(std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -vecmufoo(const T0__& mu, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -vecmubar(const T0__& mu, std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -algebra_system(const Eigen::Matrix& x, - const Eigen::Matrix& y, - const std::vector& dat, const std::vector& dat_int, - std::ostream* pstream__) ; - -template -Eigen::Matrix::type, -1, 1> -binomialf(const Eigen::Matrix& phi, - const Eigen::Matrix& theta, - const std::vector& x_r, const std::vector& x_i, - std::ostream* pstream__) ; + " (in 'mother.stan', line 295, column 27 to line 298, column 3)", + " (in 'mother.stan', line 303, column 4 to column 18)", + " (in 'mother.stan', line 304, column 4 to column 25)", + " (in 'mother.stan', line 305, column 4 to column 25)", + " (in 'mother.stan', line 306, column 4 to column 15)", + " (in 'mother.stan', line 302, column 39 to line 307, column 3)", + " (in 'mother.stan', line 310, column 4 to column 19)", + " (in 'mother.stan', line 311, column 4 to column 18)", + " (in 'mother.stan', line 312, column 4 to column 16)", + " (in 'mother.stan', line 309, column 78 to line 313, column 3)"}; @@ -12454,6 +12511,13 @@ Instead supplied arguments of incompatible type: (real, real[], real[], real[], #include namespace optimize_glm_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -12737,8 +12801,6 @@ static const std::vector locations_array__ = {" (found before start of p - - class optimize_glm_model : public model_base_crtp { private: @@ -14132,6 +14194,13 @@ stan::model::model_base& new_model( #include namespace reduce_sum_m1_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -14244,23 +14313,6 @@ static const std::vector locations_array__ = {" (found before start of p struct foo_lpdf_rsfunctor__; struct g_rsfunctor__; struct h_rsfunctor__; -template -typename boost::math::tools::promote_args::type -g(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h(const std::vector& y_slice, const int& start, const int& end, - const std::vector& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -foo_lpdf(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - - template typename boost::math::tools::promote_args::type @@ -14811,6 +14863,13 @@ stan::model::model_base& new_model( #include namespace reduce_sum_m2_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -15053,98 +15112,6 @@ struct h5_rsfunctor__; struct h6_rsfunctor__; struct h7_rsfunctor__; struct h8_rsfunctor__; -template -typename boost::math::tools::promote_args::type -g1(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g2(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g3(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g4(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g5(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g6(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g7(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g8(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h1(const std::vector& y, const int& start, const int& end, - const std::vector& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h2(const std::vector& y, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h3(const std::vector& y, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h4(const std::vector& y, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h5(const std::vector& y, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h6(const std::vector& y, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h7(const std::vector& y, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -h8(const std::vector& y, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - - template typename boost::math::tools::promote_args::type @@ -18058,6 +18025,13 @@ stan::model::model_base& new_model( #include namespace reduce_sum_m3_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -18393,171 +18367,6 @@ struct g7_rsfunctor__; struct g8_rsfunctor__; struct g9_rsfunctor__; struct s_rsfunctor__; -template -typename boost::math::tools::promote_args::type -f1(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f1a(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f2(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f3(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f4(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f5(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f6(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f7(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f8(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -double -f9(const std::vector& y_slice, const int& start, const int& end, - std::ostream* pstream__) ; - -double -f10(const std::vector>& y_slice, const int& start, - const int& end, std::ostream* pstream__) ; - -double -f11(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -f12(const std::vector>>& y_slice, - const int& start, const int& end, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g1(const std::vector& y_slice, const int& start, const int& end, - const T3__& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g2(const std::vector& y_slice, const int& start, const int& end, - const Eigen::Matrix& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g3(const std::vector& y_slice, const int& start, const int& end, - const Eigen::Matrix& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g4(const std::vector& y_slice, const int& start, const int& end, - const Eigen::Matrix& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g5(const std::vector& y_slice, const int& start, const int& end, - const std::vector& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g6(const std::vector& y_slice, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g7(const std::vector& y_slice, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g8(const std::vector& y_slice, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g9(const std::vector& y_slice, const int& start, const int& end, - const std::vector>& a, std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g10(const std::vector& y_slice, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g11(const std::vector& y_slice, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type -g12(const std::vector& y_slice, const int& start, const int& end, - const std::vector>>& a, - std::ostream* pstream__) ; - -template -typename boost::math::tools::promote_args::type>::type>::type -s(const std::vector& y_slice, const int& start, const int& end, - const int& a, const T4__& b, const Eigen::Matrix& c, - const Eigen::Matrix& d, const Eigen::Matrix& e, - const std::vector& f, const std::vector& g, - const std::vector>& h, - const std::vector>& i, - const std::vector>& j, - const std::vector>& k, - const std::vector>& l, - const std::vector>>& m, - const std::vector>>& n, - const std::vector>>& o, - const std::vector>>& p, - const std::vector>>& q, - std::ostream* pstream__) ; - -double -r(std::ostream* pstream__) ; - - template typename boost::math::tools::promote_args::type @@ -22906,6 +22715,13 @@ stan::model::model_base& new_model( #include namespace tilde_block_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -23005,8 +22821,6 @@ static const std::vector locations_array__ = {" (found before start of p - - class tilde_block_model : public model_base_crtp { private: @@ -23299,6 +23113,13 @@ stan::model::model_base& new_model( #include namespace truncate_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -23411,8 +23232,6 @@ static const std::vector locations_array__ = {" (found before start of p - - class truncate_model : public model_base_crtp { private: @@ -23787,6 +23606,13 @@ stan::model::model_base& new_model( #include namespace user_constrain_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -23880,12 +23706,6 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'user_constrain.stan', line 2, column 36 to line 4, column 3)"}; -template -typename boost::math::tools::promote_args::type -lb_constrain(const T0__& x, const T1__& y, std::ostream* pstream__) ; - - template typename boost::math::tools::promote_args namespace optimizations_model_namespace { +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + template std::vector resize_to_match__(std::vector& dst, const std::vector& src) { dst.resize(src.size()); @@ -182,20 +189,6 @@ static const std::vector locations_array__ = {" (found before start of p " (in 'optimizations.stan', line 16, column 8 to column 18)"}; -template -void -nrfun_lp(const T0__& x, const int& y, T_lp__& lp__, T_lp_accum__& lp_accum__, - std::ostream* pstream__) ; - -int -rfun(const int& y, std::ostream* pstream__) ; - -template -int -rfun_lp(T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) ; - - template From 6bc3ef692d319f58d4bb079a232224f43ebe6fdc Mon Sep 17 00:00:00 2001 From: Niko Huurre Date: Fri, 5 Jun 2020 00:01:06 +0300 Subject: [PATCH 9/9] cleanup and restore old ode signature --- src/frontend/Ast_to_Mir.ml | 2 +- src/frontend/Semantic_check.ml | 2 +- src/frontend/parser.mly | 2 +- src/middle/Stan_math_signatures.ml | 33 + src/middle/UnsizedType.ml | 2 +- src/stan_math_backend/Expression_gen.ml | 14 + src/stan_math_backend/Stan_math_code_gen.ml | 41 +- test/integration/bad/ode/adams/stanc.expected | 2 + test/integration/bad/ode/stanc.expected | 34 + test/integration/good/code-gen/cl.expected | 2 +- test/integration/good/code-gen/cpp.expected | 2740 ++++++++++++++--- .../good/compiler-optimizations/cpp.expected | 2 +- .../good/parser-generator/pretty.expected | 18 - test/integration/good/pretty.expected | 36 - .../pretty.expected | 36 - .../signatures/stan_math_sigs.expected | 5 + 16 files changed, 2488 insertions(+), 483 deletions(-) diff --git a/src/frontend/Ast_to_Mir.ml b/src/frontend/Ast_to_Mir.ml index f37978b0d5..1434cdf2cc 100644 --- a/src/frontend/Ast_to_Mir.ml +++ b/src/frontend/Ast_to_Mir.ml @@ -636,7 +636,7 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) = -> let type_ = UnsizedType.UFun - (List.map arguments ~f:(fun (a, t, _) -> (a, t)), returntype, Closure clname) + (List.map arguments ~f:(fun (a, t, _) -> (a, t)), returntype, Closure) in ( match Map.add !closures ~key:clname diff --git a/src/frontend/Semantic_check.ml b/src/frontend/Semantic_check.ml index 8399b3802a..972fbd4f47 100644 --- a/src/frontend/Semantic_check.ml +++ b/src/frontend/Semantic_check.ml @@ -1627,7 +1627,7 @@ and semantic_check_fundef ~loc ~cf return_ty id is_closure args body = (* WARNING: SIDE EFFECTING *) Symbol_table.enter vm id.name ( cf.current_block - , UFun (uarg_types, urt, if is_closure then Closure clname else Function) + , UFun (uarg_types, urt, if is_closure then Closure else Function) ) ; Symbol_table.set_read_only vm id.name ; semantic_check_fundef_suffix ~loc:id.id_loc is_closure id diff --git a/src/frontend/parser.mly b/src/frontend/parser.mly index e3b48bdcfd..f5244934ba 100644 --- a/src/frontend/parser.mly +++ b/src/frontend/parser.mly @@ -225,7 +225,7 @@ unsized_type: let t = reparray size bt in match fa with | None -> t - | Some args -> UnsizedType.UFun (args, UnsizedType.ReturnType t, Template) } + | Some args -> UnsizedType.UFun (args, UnsizedType.ReturnType t, Closure) } basic_type: | INT diff --git a/src/middle/Stan_math_signatures.ml b/src/middle/Stan_math_signatures.ml index 8db87340aa..45bb54240d 100644 --- a/src/middle/Stan_math_signatures.ml +++ b/src/middle/Stan_math_signatures.ml @@ -1052,6 +1052,39 @@ let () = ; (AutoDiffable, UArray UReal) ; (DataOnly, UArray UReal); (DataOnly, UArray UInt); (DataOnly, UReal) ; (DataOnly, UReal); (DataOnly, UReal) ] ) ; + add_qualified + ( "integrate_ode_bdf" + , ReturnType (UArray (UArray UReal)) + , [ ( AutoDiffable + , UFun + ( [ (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UArray UReal) + ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] + , ReturnType (UArray UReal) + , Function ) ) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UArray UReal) + ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] ) ; + add_qualified + ( "integrate_ode_bdf" + , ReturnType (UArray (UArray UReal)) + , [ ( AutoDiffable + , UFun + ( [ (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UArray UReal) + ; (DataOnly, UArray UReal); (DataOnly, UArray UInt) ] + , ReturnType (UArray UReal) + , Function ) ) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UReal) + ; (AutoDiffable, UArray UReal) + ; (AutoDiffable, UArray UReal) + ; (DataOnly, UArray UReal); (DataOnly, UArray UInt); (DataOnly, UReal) + ; (DataOnly, UReal); (DataOnly, UReal) ] ) ; add_qualified ( "integrate_ode_bdf" , ReturnType (UArray UVector) diff --git a/src/middle/UnsizedType.ml b/src/middle/UnsizedType.ml index f4a69819a2..94d4e21ca2 100644 --- a/src/middle/UnsizedType.ml +++ b/src/middle/UnsizedType.ml @@ -11,7 +11,7 @@ type t = | UFun of (autodifftype * t) list * returntype * functiontype | UMathLibraryFunction -and functiontype = Function | Closure of string | Template +and functiontype = Function | Closure and autodifftype = DataOnly | AutoDiffable diff --git a/src/stan_math_backend/Expression_gen.ml b/src/stan_math_backend/Expression_gen.ml index ed23eddd19..68e579b051 100644 --- a/src/stan_math_backend/Expression_gen.ml +++ b/src/stan_math_backend/Expression_gen.ml @@ -306,6 +306,13 @@ and gen_fun_app ppf fname es = (fname, f :: x :: y :: dat :: datint :: msgs :: tl) | true, "integrate_1d", f :: a :: b :: theta :: x_r :: x_i :: tl -> (fname, f :: a :: b :: theta :: x_r :: x_i :: msgs :: tl) + | ( _ + , "integrate_ode_bdf" + , f + :: ({meta= {type_= UArray UReal; _}; _} as y0) + :: t0 :: ts :: theta :: x_r :: x_i :: tl ) -> + ( "integrate_ode_bdf" + , f :: y0 :: t0 :: ts :: theta :: x_r :: x_i :: msgs :: tl ) | _, "integrate_ode_bdf", f :: y0 :: t0 :: ts :: tl -> let args, tols = List.split_n tl (List.length tl - 3) in ("ode_bdf_tol", (f :: y0 :: t0 :: ts :: tols) @ (msgs :: args)) @@ -344,6 +351,13 @@ and pp_constrain_funapp constrain_or_un_str ppf = function and pp_user_defined_fun ppf (f, es) = let extra_args = suffix_args f @ ["pstream__"] in let sep = if List.is_empty es then "" else ", " in + let convert_hof_vars = function + | { Expr.Fixed.pattern= Var name + ; meta= {Expr.Typed.Meta.type_= UFun (_, _, Function); _} } as e -> + {e with pattern= FunApp (StanLib, name ^ functor_suffix_select "", [])} + | e -> e + in + let es = List.map ~f:convert_hof_vars es in pf ppf "@[%s(@,%a%s)@]" (demangle_propto_name true f) (list ~sep:comma pp_expr) es diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 196eb773b7..953c61ffe4 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -206,26 +206,26 @@ let pp_fun_def ppf Program.({fdrt; fdname; fdargs; fdbody; _}) is_closure | _ -> pp_block ppf (pp_body, fdbody) ; if not is_closure then ( - let pp_zeros ppf () = pf ppf "void set_zero_adjoints() const { }" in - let pp_adjoints ppf () = - pf ppf "void accumulate_adjoints(double*) const { }" + let pp_admethods ppf () = + pf ppf + "void set_zero_adjoints() const { }@ void \ + accumulate_adjoints(double*) const { }@ void save_varis(vari**) \ + const { }" in - let pp_varis ppf () = pf ppf "void save_varis(vari**) const { }" in - let pp_valueof ppf () = - pf ppf "using ValueOf__ = %s%s;" fdname functor_suffix - in - let pp_deepcopy ppf () = - pf ppf "using DeepCopy__ = %s%s;" fdname functor_suffix + let pp_subclass ppf () = + pf ppf + "using ValueOf__ = %s%s;@ using DeepCopy__ = ValueOf__;@ using \ + captured_scalar_t__ = double;" + fdname functor_suffix in let pp_ode ppf () = if not (is_dist || is_lp || is_rng || List.length args < 3) then - pf ppf "%a const @,{@,return %a;@,}@,%a@,%a@,%a@,%a@,%a@,%s" - pp_ode_sig "operator()" pp_call_str + pf ppf "%a const @,{@,return %a;@,}@,%a@,%a" pp_ode_sig + "operator()" pp_call_str ( fdname , List.map ~f:(fun (_, name, _) -> name) fdargs @ extra @ ["pstream__"] ) - pp_zeros () pp_varis () pp_adjoints () pp_valueof () pp_deepcopy - () "using captured_scalar_t__ = double;" + pp_admethods () pp_subclass () in pf ppf "@,@,struct %s%s {@,%s@,%a const @,{@,return %a;@,}@,%a};@," fdname functor_suffix "const static int num_vars__ = 0;" pp_sig @@ -485,6 +485,13 @@ let pp_closure_defs ppf closures = ((rt, true), id, captures, args) pp_accumulateadjoints captures pp_valueof (rt, id, captures, args) in + let pp_admethods ppf captures = + pp_zeroadjoints ppf captures ; + cut ppf () ; + pp_accumulateadjoints ppf captures ; + cut ppf () ; + pp_savevaris ppf captures + in let f ~key ~data:Program.({cdrt; cdargs; cdcaptures; cdbody}) = cut ppf () ; pp_fun_def ppf @@ -497,8 +504,7 @@ let pp_closure_defs ppf closures = true String.Set.empty ; pf ppf "@,%a@[class %s__ {@,%a@ public:@ %s@ const int num_vars__;@ %a@ \ - %a@ %a@ %a@ %a@ %a@]@,};@,%a auto make_%s__(%a) {@,return \ - %s__<%a>(%a);@,}" + %a@ %a@ %a@]@,};@,%a auto make_%s__(%a) {@,return %s__<%a>(%a);@,}" pp_template_decorator ( "typename captured_t__" :: List.filter_mapi cdcaptures ~f:(fun i (_, _, ut) -> @@ -510,8 +516,7 @@ let pp_closure_defs ppf closures = ((cdrt, true), key, cdcaptures, cdargs) pp_deepcopy (cdrt, key, cdcaptures, cdargs) - pp_zeroadjoints cdcaptures pp_accumulateadjoints cdcaptures pp_savevaris - cdcaptures pp_template_decorator + pp_admethods cdcaptures pp_template_decorator ( "typename captured_t__" :: List.filter_mapi cdcaptures ~f:(fun i (_, _, ut) -> if UnsizedType.is_fun_type ut then Some (strf "typename F%d__" i) @@ -926,7 +931,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template diff --git a/test/integration/bad/ode/adams/stanc.expected b/test/integration/bad/ode/adams/stanc.expected index c2c303b91b..95692c7e80 100644 --- a/test/integration/bad/ode/adams/stanc.expected +++ b/test/integration/bad/ode/adams/stanc.expected @@ -287,6 +287,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../../install/default/bin/stanc bad_y_type.stan diff --git a/test/integration/bad/ode/stanc.expected b/test/integration/bad/ode/stanc.expected index 0621411d92..8c139ec08e 100644 --- a/test/integration/bad/ode/stanc.expected +++ b/test/integration/bad/ode/stanc.expected @@ -15,6 +15,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real, real[], real, real[], real[], real[], int[], int, int, int. $ ../../../../../install/default/bin/stanc bad_fun_type.stan @@ -50,6 +52,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real[], real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_fun_type_bdf_control.stan @@ -69,6 +73,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real[], real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_fun_type_rk45.stan @@ -138,6 +144,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], matrix, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_t_type_bdf_control.stan @@ -157,6 +165,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], matrix, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_t_type_rk45.stan @@ -226,6 +236,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[,], real[], int[]. $ ../../../../../install/default/bin/stanc bad_theta_type_bdf_control.stan @@ -245,6 +257,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[,], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_theta_type_rk45.stan @@ -314,6 +328,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[,], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_ts_type_bdf_control.stan @@ -333,6 +349,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[,], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_ts_type_rk45.stan @@ -402,6 +420,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[,]. $ ../../../../../install/default/bin/stanc bad_x_int_type_bdf_control.stan @@ -421,6 +441,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[,], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_int_type_rk45.stan @@ -490,6 +512,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], vector[], int[]. $ ../../../../../install/default/bin/stanc bad_x_type_bdf_control.stan @@ -509,6 +533,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], vector[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_type_rk45.stan @@ -578,6 +604,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_x_var_type_bdf_control.stan @@ -597,6 +625,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_x_var_type_rk45.stan @@ -666,6 +696,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[,], real, real[], real[], real[], int[]. $ ../../../../../install/default/bin/stanc bad_y_type_bdf_control.stan @@ -685,6 +717,8 @@ Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatur ((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] ((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] +((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[], data real, data real, data real) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[,], real, real[], real[], real[], int[], real, real, int. $ ../../../../../install/default/bin/stanc bad_y_type_rk45.stan diff --git a/test/integration/good/code-gen/cl.expected b/test/integration/good/code-gen/cl.expected index 0cb48237e2..29bf083428 100644 --- a/test/integration/good/code-gen/cl.expected +++ b/test/integration/good/code-gen/cl.expected @@ -8,7 +8,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template diff --git a/test/integration/good/code-gen/cpp.expected b/test/integration/good/code-gen/cpp.expected index 206c65f594..bcd818a57a 100644 --- a/test/integration/good/code-gen/cpp.expected +++ b/test/integration/good/code-gen/cpp.expected @@ -8,7 +8,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -862,7 +862,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -1822,7 +1822,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -2596,7 +2596,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -3126,7 +3126,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -3775,10 +3775,10 @@ operator()(const T0__& t, const std::vector& y, return sho(t, y, theta, x, x_int, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = sho_functor__; -using DeepCopy__ = sho_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; double @@ -4498,10 +4498,10 @@ operator()(const T0__& x, const T1__& y, std::ostream* pstream__, return relative_diff(x, y, max_, min_, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = relative_diff_functor__; -using DeepCopy__ = relative_diff_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template @@ -4551,10 +4551,10 @@ operator()(const Eigen::Matrix& shared_params, return foo_5(shared_params, job_params, data_r, data_i, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = foo_5_functor__; -using DeepCopy__ = foo_5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f0_functor__; -using DeepCopy__ = f0_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f1_functor__; -using DeepCopy__ = f1_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f2(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f2_functor__; -using DeepCopy__ = f2_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f3(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f3_functor__; -using DeepCopy__ = f3_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f4(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f4_functor__; -using DeepCopy__ = f4_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f5(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f5_functor__; -using DeepCopy__ = f5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f6(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f6_functor__; -using DeepCopy__ = f6_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f7(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f7_functor__; -using DeepCopy__ = f7_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f8(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f8_functor__; -using DeepCopy__ = f8_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f9(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f9_functor__; -using DeepCopy__ = f9_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f10_functor__; -using DeepCopy__ = f10_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f11_functor__; -using DeepCopy__ = f11_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template & a2, return f12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f12_functor__; -using DeepCopy__ = f12_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; void @@ -6048,10 +6048,10 @@ operator()(const Eigen::Matrix& x, return algebra_system(x, y, dat, dat_int, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = algebra_system_functor__; -using DeepCopy__ = algebra_system_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; template @@ -6113,10 +6113,10 @@ operator()(const Eigen::Matrix& phi, return binomialf(phi, theta, x_r, x_i, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = binomialf_functor__; -using DeepCopy__ = binomialf_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -12488,34 +12488,15 @@ get_lp() function is deprecated. It will be removed in a future release. Use tar $ ../../../../../install/default/bin/stanc --print-cpp motherHOF.stan -Semantic error in 'motherHOF.stan', line 90, column 10 to column 65: - ------------------------------------------------- - 88: y_hat = integrate_ode_adams(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8); - 89: - 90: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int); - ^ - 91: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int); - 92: y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int); - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. - - $ ../../../../../install/default/bin/stanc --print-cpp optimize_glm.stan - // Code generated by %%NAME%% %%VERSION%% #include -namespace optimize_glm_model_namespace { +namespace motherHOF_model_namespace { void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -12605,220 +12586,2241 @@ using namespace stan::math; static int current_statement__ = 0; static const std::vector locations_array__ = {" (found before start of program)", - " (in 'optimize_glm.stan', line 26, column 2 to column 20)", - " (in 'optimize_glm.stan', line 27, column 2 to column 17)", - " (in 'optimize_glm.stan', line 28, column 2 to column 17)", - " (in 'optimize_glm.stan', line 29, column 2 to column 22)", - " (in 'optimize_glm.stan', line 30, column 2 to column 13)", - " (in 'optimize_glm.stan', line 31, column 2 to column 11)", - " (in 'optimize_glm.stan', line 32, column 2 to column 19)", - " (in 'optimize_glm.stan', line 33, column 2 to column 22)", - " (in 'optimize_glm.stan', line 34, column 2 to column 23)", - " (in 'optimize_glm.stan', line 38, column 2 to column 64)", - " (in 'optimize_glm.stan', line 39, column 2 to column 49)", - " (in 'optimize_glm.stan', line 41, column 2 to column 64)", - " (in 'optimize_glm.stan', line 42, column 2 to column 49)", - " (in 'optimize_glm.stan', line 44, column 2 to column 63)", - " (in 'optimize_glm.stan', line 45, column 2 to column 48)", - " (in 'optimize_glm.stan', line 47, column 2 to column 63)", - " (in 'optimize_glm.stan', line 48, column 2 to column 48)", - " (in 'optimize_glm.stan', line 50, column 2 to column 66)", - " (in 'optimize_glm.stan', line 51, column 2 to column 51)", - " (in 'optimize_glm.stan', line 53, column 2 to column 66)", - " (in 'optimize_glm.stan', line 54, column 2 to column 51)", - " (in 'optimize_glm.stan', line 56, column 2 to column 70)", - " (in 'optimize_glm.stan', line 57, column 2 to column 55)", - " (in 'optimize_glm.stan', line 59, column 2 to column 67)", - " (in 'optimize_glm.stan', line 60, column 2 to column 52)", - " (in 'optimize_glm.stan', line 62, column 2 to column 69)", - " (in 'optimize_glm.stan', line 63, column 2 to column 54)", - " (in 'optimize_glm.stan', line 65, column 2 to column 66)", - " (in 'optimize_glm.stan', line 66, column 2 to column 51)", - " (in 'optimize_glm.stan', line 68, column 2 to column 72)", - " (in 'optimize_glm.stan', line 69, column 2 to column 57)", - " (in 'optimize_glm.stan', line 71, column 2 to column 69)", - " (in 'optimize_glm.stan', line 72, column 2 to column 54)", - " (in 'optimize_glm.stan', line 74, column 2 to column 63)", - " (in 'optimize_glm.stan', line 75, column 2 to column 49)", - " (in 'optimize_glm.stan', line 77, column 2 to column 63)", - " (in 'optimize_glm.stan', line 78, column 2 to column 49)", - " (in 'optimize_glm.stan', line 80, column 2 to column 66)", - " (in 'optimize_glm.stan', line 81, column 2 to column 52)", - " (in 'optimize_glm.stan', line 83, column 2 to column 66)", - " (in 'optimize_glm.stan', line 84, column 2 to column 52)", - " (in 'optimize_glm.stan', line 86, column 2 to column 62)", - " (in 'optimize_glm.stan', line 87, column 2 to column 48)", - " (in 'optimize_glm.stan', line 89, column 2 to column 62)", - " (in 'optimize_glm.stan', line 90, column 2 to column 48)", - " (in 'optimize_glm.stan', line 92, column 2 to column 69)", - " (in 'optimize_glm.stan', line 93, column 2 to column 55)", - " (in 'optimize_glm.stan', line 95, column 2 to column 66)", - " (in 'optimize_glm.stan', line 96, column 2 to column 52)", - " (in 'optimize_glm.stan', line 98, column 2 to column 72)", - " (in 'optimize_glm.stan', line 99, column 2 to column 58)", - " (in 'optimize_glm.stan', line 101, column 2 to column 69)", - " (in 'optimize_glm.stan', line 102, column 2 to column 55)", - " (in 'optimize_glm.stan', line 104, column 2 to column 68)", - " (in 'optimize_glm.stan', line 105, column 2 to column 54)", - " (in 'optimize_glm.stan', line 107, column 2 to column 65)", - " (in 'optimize_glm.stan', line 108, column 2 to column 51)", - " (in 'optimize_glm.stan', line 110, column 2 to column 59)", - " (in 'optimize_glm.stan', line 111, column 2 to column 45)", - " (in 'optimize_glm.stan', line 113, column 2 to column 59)", - " (in 'optimize_glm.stan', line 114, column 2 to column 45)", - " (in 'optimize_glm.stan', line 116, column 2 to column 58)", - " (in 'optimize_glm.stan', line 117, column 2 to column 44)", - " (in 'optimize_glm.stan', line 119, column 2 to column 58)", - " (in 'optimize_glm.stan', line 120, column 2 to column 44)", - " (in 'optimize_glm.stan', line 122, column 2 to column 62)", - " (in 'optimize_glm.stan', line 123, column 2 to column 48)", - " (in 'optimize_glm.stan', line 125, column 2 to column 62)", - " (in 'optimize_glm.stan', line 126, column 2 to column 48)", - " (in 'optimize_glm.stan', line 128, column 2 to column 65)", - " (in 'optimize_glm.stan', line 129, column 2 to column 51)", - " (in 'optimize_glm.stan', line 131, column 2 to column 62)", - " (in 'optimize_glm.stan', line 132, column 2 to column 48)", - " (in 'optimize_glm.stan', line 134, column 2 to column 64)", - " (in 'optimize_glm.stan', line 135, column 2 to column 50)", - " (in 'optimize_glm.stan', line 137, column 2 to column 61)", - " (in 'optimize_glm.stan', line 138, column 2 to column 47)", - " (in 'optimize_glm.stan', line 140, column 2 to column 68)", - " (in 'optimize_glm.stan', line 141, column 2 to column 54)", - " (in 'optimize_glm.stan', line 143, column 2 to column 65)", - " (in 'optimize_glm.stan', line 144, column 2 to column 51)", - " (in 'optimize_glm.stan', line 146, column 2 to column 71)", - " (in 'optimize_glm.stan', line 147, column 2 to column 57)", - " (in 'optimize_glm.stan', line 149, column 2 to column 71)", - " (in 'optimize_glm.stan', line 150, column 2 to column 57)", - " (in 'optimize_glm.stan', line 152, column 2 to column 70)", - " (in 'optimize_glm.stan', line 153, column 2 to column 56)", - " (in 'optimize_glm.stan', line 155, column 2 to column 70)", - " (in 'optimize_glm.stan', line 156, column 2 to column 56)", - " (in 'optimize_glm.stan', line 158, column 2 to column 74)", - " (in 'optimize_glm.stan', line 159, column 2 to column 60)", - " (in 'optimize_glm.stan', line 161, column 2 to column 74)", - " (in 'optimize_glm.stan', line 162, column 2 to column 60)", - " (in 'optimize_glm.stan', line 164, column 2 to column 77)", - " (in 'optimize_glm.stan', line 165, column 2 to column 63)", - " (in 'optimize_glm.stan', line 167, column 2 to column 74)", - " (in 'optimize_glm.stan', line 168, column 2 to column 60)", - " (in 'optimize_glm.stan', line 170, column 2 to column 76)", - " (in 'optimize_glm.stan', line 171, column 2 to column 62)", - " (in 'optimize_glm.stan', line 173, column 2 to column 73)", - " (in 'optimize_glm.stan', line 174, column 2 to column 59)", - " (in 'optimize_glm.stan', line 176, column 2 to column 80)", - " (in 'optimize_glm.stan', line 177, column 2 to column 66)", - " (in 'optimize_glm.stan', line 179, column 2 to column 77)", - " (in 'optimize_glm.stan', line 180, column 2 to column 63)", - " (in 'optimize_glm.stan', line 182, column 2 to column 62)", - " (in 'optimize_glm.stan', line 183, column 2 to column 48)", - " (in 'optimize_glm.stan', line 185, column 2 to column 62)", - " (in 'optimize_glm.stan', line 186, column 2 to column 48)", - " (in 'optimize_glm.stan', line 188, column 2 to column 68)", - " (in 'optimize_glm.stan', line 189, column 2 to column 54)", - " (in 'optimize_glm.stan', line 191, column 2 to column 65)", - " (in 'optimize_glm.stan', line 192, column 2 to column 51)", - " (in 'optimize_glm.stan', line 194, column 2 to column 62)", - " (in 'optimize_glm.stan', line 195, column 2 to column 48)", - " (in 'optimize_glm.stan', line 197, column 2 to column 62)", - " (in 'optimize_glm.stan', line 198, column 2 to column 48)", - " (in 'optimize_glm.stan', line 200, column 2 to column 68)", - " (in 'optimize_glm.stan', line 201, column 2 to column 54)", - " (in 'optimize_glm.stan', line 203, column 2 to column 65)", - " (in 'optimize_glm.stan', line 204, column 2 to column 51)", - " (in 'optimize_glm.stan', line 206, column 2 to column 65)", - " (in 'optimize_glm.stan', line 207, column 2 to column 51)", - " (in 'optimize_glm.stan', line 209, column 2 to column 65)", - " (in 'optimize_glm.stan', line 210, column 2 to column 51)", - " (in 'optimize_glm.stan', line 212, column 2 to column 63)", - " (in 'optimize_glm.stan', line 213, column 2 to column 49)", - " (in 'optimize_glm.stan', line 215, column 2 to column 63)", - " (in 'optimize_glm.stan', line 216, column 2 to column 49)", - " (in 'optimize_glm.stan', line 218, column 2 to column 69)", - " (in 'optimize_glm.stan', line 219, column 2 to column 55)", - " (in 'optimize_glm.stan', line 221, column 2 to column 66)", - " (in 'optimize_glm.stan', line 222, column 2 to column 53)", - " (in 'optimize_glm.stan', line 224, column 2 to column 66)", - " (in 'optimize_glm.stan', line 225, column 2 to column 52)", - " (in 'optimize_glm.stan', line 227, column 2 to column 66)", - " (in 'optimize_glm.stan', line 228, column 2 to column 52)", - " (in 'optimize_glm.stan', line 230, column 2 to column 68)", - " (in 'optimize_glm.stan', line 231, column 2 to column 54)", - " (in 'optimize_glm.stan', line 233, column 2 to column 68)", - " (in 'optimize_glm.stan', line 234, column 2 to column 54)", - " (in 'optimize_glm.stan', line 236, column 2 to column 74)", - " (in 'optimize_glm.stan', line 237, column 2 to column 60)", - " (in 'optimize_glm.stan', line 239, column 2 to column 71)", - " (in 'optimize_glm.stan', line 240, column 2 to column 57)", - " (in 'optimize_glm.stan', line 242, column 2 to column 71)", - " (in 'optimize_glm.stan', line 243, column 2 to column 57)", - " (in 'optimize_glm.stan', line 245, column 2 to column 71)", - " (in 'optimize_glm.stan', line 246, column 2 to column 57)", - " (in 'optimize_glm.stan', line 248, column 2 to column 77)", - " (in 'optimize_glm.stan', line 249, column 2 to column 63)", - " (in 'optimize_glm.stan', line 251, column 2 to column 74)", - " (in 'optimize_glm.stan', line 252, column 2 to column 60)", - " (in 'optimize_glm.stan', line 254, column 2 to column 69)", - " (in 'optimize_glm.stan', line 255, column 2 to column 55)", - " (in 'optimize_glm.stan', line 257, column 2 to column 69)", - " (in 'optimize_glm.stan', line 258, column 2 to column 55)", - " (in 'optimize_glm.stan', line 260, column 2 to column 75)", - " (in 'optimize_glm.stan', line 261, column 2 to column 61)", - " (in 'optimize_glm.stan', line 263, column 2 to column 72)", - " (in 'optimize_glm.stan', line 264, column 2 to column 58)", - " (in 'optimize_glm.stan', line 266, column 2 to column 72)", - " (in 'optimize_glm.stan', line 267, column 2 to column 58)", - " (in 'optimize_glm.stan', line 269, column 2 to column 72)", - " (in 'optimize_glm.stan', line 270, column 2 to column 58)", - " (in 'optimize_glm.stan', line 272, column 2 to column 78)", - " (in 'optimize_glm.stan', line 273, column 2 to column 64)", - " (in 'optimize_glm.stan', line 275, column 2 to column 75)", - " (in 'optimize_glm.stan', line 276, column 2 to column 61)", - " (in 'optimize_glm.stan', line 278, column 2 to column 73)", - " (in 'optimize_glm.stan', line 279, column 2 to column 59)", - " (in 'optimize_glm.stan', line 281, column 2 to column 76)", - " (in 'optimize_glm.stan', line 282, column 2 to column 62)", - " (in 'optimize_glm.stan', line 2, column 2 to column 17)", - " (in 'optimize_glm.stan', line 3, column 2 to column 17)", - " (in 'optimize_glm.stan', line 4, column 2 to column 19)", - " (in 'optimize_glm.stan', line 5, column 2 to column 18)", - " (in 'optimize_glm.stan', line 6, column 2 to column 23)", - " (in 'optimize_glm.stan', line 7, column 2 to column 16)", - " (in 'optimize_glm.stan', line 8, column 2 to column 17)", - " (in 'optimize_glm.stan', line 9, column 2 to column 12)", - " (in 'optimize_glm.stan', line 10, column 2 to column 13)", - " (in 'optimize_glm.stan', line 14, column 2 to column 20)", - " (in 'optimize_glm.stan', line 15, column 2 to column 20)", - " (in 'optimize_glm.stan', line 16, column 2 to column 22)", - " (in 'optimize_glm.stan', line 17, column 2 to column 21)", - " (in 'optimize_glm.stan', line 18, column 2 to column 26)", - " (in 'optimize_glm.stan', line 19, column 2 to column 19)", - " (in 'optimize_glm.stan', line 20, column 2 to column 20)", - " (in 'optimize_glm.stan', line 21, column 2 to column 15)", - " (in 'optimize_glm.stan', line 22, column 2 to column 16)"}; + " (in 'motherHOF.stan', line 48, column 2 to column 15)", + " (in 'motherHOF.stan', line 49, column 2 to column 18)", + " (in 'motherHOF.stan', line 50, column 2 to column 14)", + " (in 'motherHOF.stan', line 51, column 2 to column 18)", + " (in 'motherHOF.stan', line 52, column 2 to column 28)", + " (in 'motherHOF.stan', line 53, column 2 to column 28)", + " (in 'motherHOF.stan', line 54, column 2 to column 11)", + " (in 'motherHOF.stan', line 57, column 2 to column 18)", + " (in 'motherHOF.stan', line 58, column 2 to column 37)", + " (in 'motherHOF.stan', line 59, column 2 to column 33)", + " (in 'motherHOF.stan', line 60, column 2 to line 61, column 69)", + " (in 'motherHOF.stan', line 62, column 2 to line 63, column 69)", + " (in 'motherHOF.stan', line 64, column 2 to line 65, column 69)", + " (in 'motherHOF.stan', line 66, column 2 to column 23)", + " (in 'motherHOF.stan', line 67, column 2 to column 16)", + " (in 'motherHOF.stan', line 68, column 2 to column 16)", + " (in 'motherHOF.stan', line 69, column 2 to column 16)", + " (in 'motherHOF.stan', line 70, column 2 to column 70)", + " (in 'motherHOF.stan', line 71, column 2 to column 86)", + " (in 'motherHOF.stan', line 72, column 2 to column 86)", + " (in 'motherHOF.stan', line 73, column 2 to column 72)", + " (in 'motherHOF.stan', line 75, column 2 to column 88)", + " (in 'motherHOF.stan', line 76, column 2 to column 72)", + " (in 'motherHOF.stan', line 77, column 2 to column 88)", + " (in 'motherHOF.stan', line 132, column 2 to column 18)", + " (in 'motherHOF.stan', line 133, column 2 to column 68)", + " (in 'motherHOF.stan', line 134, column 2 to column 68)", + " (in 'motherHOF.stan', line 135, column 2 to column 68)", + " (in 'motherHOF.stan', line 136, column 2 to column 68)", + " (in 'motherHOF.stan', line 138, column 2 to column 87)", + " (in 'motherHOF.stan', line 139, column 2 to column 87)", + " (in 'motherHOF.stan', line 140, column 2 to column 87)", + " (in 'motherHOF.stan', line 141, column 2 to column 87)", + " (in 'motherHOF.stan', line 143, column 2 to column 66)", + " (in 'motherHOF.stan', line 144, column 2 to column 66)", + " (in 'motherHOF.stan', line 145, column 2 to column 66)", + " (in 'motherHOF.stan', line 146, column 2 to column 66)", + " (in 'motherHOF.stan', line 148, column 2 to column 85)", + " (in 'motherHOF.stan', line 149, column 2 to column 85)", + " (in 'motherHOF.stan', line 150, column 2 to column 85)", + " (in 'motherHOF.stan', line 151, column 2 to column 85)", + " (in 'motherHOF.stan', line 153, column 2 to column 67)", + " (in 'motherHOF.stan', line 154, column 2 to column 67)", + " (in 'motherHOF.stan', line 155, column 2 to column 67)", + " (in 'motherHOF.stan', line 156, column 2 to column 67)", + " (in 'motherHOF.stan', line 158, column 2 to column 61)", + " (in 'motherHOF.stan', line 159, column 2 to column 58)", + " (in 'motherHOF.stan', line 160, column 2 to column 58)", + " (in 'motherHOF.stan', line 161, column 2 to column 60)", + " (in 'motherHOF.stan', line 163, column 2 to column 67)", + " (in 'motherHOF.stan', line 164, column 2 to column 64)", + " (in 'motherHOF.stan', line 165, column 2 to column 64)", + " (in 'motherHOF.stan', line 166, column 2 to column 66)", + " (in 'motherHOF.stan', line 168, column 2 to column 34)", + " (in 'motherHOF.stan', line 169, column 2 to column 38)", + " (in 'motherHOF.stan', line 170, column 2 to line 171, column 69)", + " (in 'motherHOF.stan', line 81, column 2 to column 18)", + " (in 'motherHOF.stan', line 82, column 2 to column 68)", + " (in 'motherHOF.stan', line 83, column 2 to column 68)", + " (in 'motherHOF.stan', line 84, column 2 to column 68)", + " (in 'motherHOF.stan', line 86, column 2 to column 87)", + " (in 'motherHOF.stan', line 87, column 2 to column 87)", + " (in 'motherHOF.stan', line 88, column 2 to column 87)", + " (in 'motherHOF.stan', line 90, column 2 to column 66)", + " (in 'motherHOF.stan', line 91, column 2 to column 66)", + " (in 'motherHOF.stan', line 92, column 2 to column 66)", + " (in 'motherHOF.stan', line 93, column 2 to column 66)", + " (in 'motherHOF.stan', line 95, column 2 to column 85)", + " (in 'motherHOF.stan', line 96, column 2 to column 85)", + " (in 'motherHOF.stan', line 97, column 2 to column 85)", + " (in 'motherHOF.stan', line 98, column 2 to column 85)", + " (in 'motherHOF.stan', line 100, column 2 to column 67)", + " (in 'motherHOF.stan', line 101, column 2 to column 67)", + " (in 'motherHOF.stan', line 102, column 2 to column 67)", + " (in 'motherHOF.stan', line 103, column 2 to column 67)", + " (in 'motherHOF.stan', line 105, column 2 to column 61)", + " (in 'motherHOF.stan', line 106, column 2 to column 58)", + " (in 'motherHOF.stan', line 107, column 2 to column 58)", + " (in 'motherHOF.stan', line 108, column 2 to column 60)", + " (in 'motherHOF.stan', line 109, column 2 to column 56)", + " (in 'motherHOF.stan', line 110, column 2 to column 58)", + " (in 'motherHOF.stan', line 111, column 2 to column 58)", + " (in 'motherHOF.stan', line 112, column 2 to column 60)", + " (in 'motherHOF.stan', line 113, column 2 to column 62)", + " (in 'motherHOF.stan', line 114, column 2 to column 62)", + " (in 'motherHOF.stan', line 115, column 2 to column 64)", + " (in 'motherHOF.stan', line 117, column 2 to column 67)", + " (in 'motherHOF.stan', line 118, column 2 to column 64)", + " (in 'motherHOF.stan', line 119, column 2 to column 64)", + " (in 'motherHOF.stan', line 120, column 2 to column 66)", + " (in 'motherHOF.stan', line 121, column 2 to column 62)", + " (in 'motherHOF.stan', line 122, column 2 to column 64)", + " (in 'motherHOF.stan', line 123, column 2 to column 64)", + " (in 'motherHOF.stan', line 124, column 2 to column 66)", + " (in 'motherHOF.stan', line 125, column 2 to column 68)", + " (in 'motherHOF.stan', line 126, column 2 to column 68)", + " (in 'motherHOF.stan', line 127, column 2 to column 70)", + " (in 'motherHOF.stan', line 129, column 2 to column 36)", + " (in 'motherHOF.stan', line 33, column 2 to column 17)", + " (in 'motherHOF.stan', line 34, column 2 to column 15)", + " (in 'motherHOF.stan', line 35, column 2 to column 10)", + " (in 'motherHOF.stan', line 36, column 2 to column 13)", + " (in 'motherHOF.stan', line 37, column 2 to column 18)", + " (in 'motherHOF.stan', line 38, column 2 to column 12)", + " (in 'motherHOF.stan', line 39, column 2 to column 15)", + " (in 'motherHOF.stan', line 40, column 2 to column 16)", + " (in 'motherHOF.stan', line 41, column 2 to column 15)", + " (in 'motherHOF.stan', line 42, column 2 to column 28)", + " (in 'motherHOF.stan', line 43, column 2 to column 28)", + " (in 'motherHOF.stan', line 44, column 2 to column 20)", + " (in 'motherHOF.stan', line 45, column 2 to column 19)", + " (in 'motherHOF.stan', line 7, column 4 to column 17)", + " (in 'motherHOF.stan', line 8, column 4 to column 19)", + " (in 'motherHOF.stan', line 9, column 4 to column 38)", + " (in 'motherHOF.stan', line 10, column 4 to column 16)", + " (in 'motherHOF.stan', line 6, column 26 to line 11, column 3)", + " (in 'motherHOF.stan', line 13, column 4 to column 15)", + " (in 'motherHOF.stan', line 12, column 71 to line 14, column 3)", + " (in 'motherHOF.stan', line 17, column 4 to column 22)", + " (in 'motherHOF.stan', line 16, column 42 to line 18, column 3)", + " (in 'motherHOF.stan', line 20, column 4 to column 17)", + " (in 'motherHOF.stan', line 19, column 28 to line 21, column 3)", + " (in 'motherHOF.stan', line 26, column 4 to column 18)", + " (in 'motherHOF.stan', line 27, column 4 to column 25)", + " (in 'motherHOF.stan', line 28, column 4 to column 25)", + " (in 'motherHOF.stan', line 29, column 4 to column 15)", + " (in 'motherHOF.stan', line 25, column 39 to line 30, column 3)"}; - - -class optimize_glm_model : public model_base_crtp { - - private: - int pos__; - int k; - int n; - Eigen::Matrix X_d; - Eigen::Matrix y_v_d; - Eigen::Matrix X_rv_d; - std::vector y_vi_d; - std::vector y2_vi_d; - int y_s_d; - double y_r_d; - int k_td; - int n_td; - Eigen::Matrix X_d_td; - Eigen::Matrix y_v_d_td; - Eigen::Matrix X_rv_d_td; +template +std::vector::type> +sho(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 112; + validate_non_negative_index("dydt", "2", 2); + std::vector dydt; + dydt = std::vector(2, 0); + + current_statement__ = 113; + assign(dydt, cons_list(index_uni(1), nil_index_list()), y[(2 - 1)], + "assigning variable dydt"); + current_statement__ = 114; + assign(dydt, cons_list(index_uni(2), nil_index_list()), + (-y[(1 - 1)] - (theta[(1 - 1)] * y[(2 - 1)])), + "assigning variable dydt"); + current_statement__ = 115; + return dydt; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct sho_functor__ { +const static int num_vars__ = 0; +template +std::vector::type> +operator()(const T0__& t, const std::vector& y, + const std::vector& theta, const std::vector& x, + const std::vector& x_int, std::ostream* pstream__) const +{ +return sho(t, y, theta, x, x_int, pstream__); +} +template +std::vector::type> +operator()(const T0__& t, const std::vector& y, + std::ostream* pstream__, const std::vector& theta, + const std::vector& x, const std::vector& x_int) const +{ +return sho(t, y, theta, x, x_int, pstream__); +} +void set_zero_adjoints() const { } +void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } +using ValueOf__ = sho_functor__; +using DeepCopy__ = ValueOf__; +using captured_scalar_t__ = double;}; + +template +typename boost::math::tools::promote_args::type +integrand(const T0__& x, const T1__& xc, const std::vector& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 117; + return 0.0; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct integrand_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, const T1__& xc, const std::vector& theta, + const std::vector& x_r, const std::vector& x_i, + std::ostream* pstream__) const +{ +return integrand(x, xc, theta, x_r, x_i, pstream__); +} +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, const T1__& xc, std::ostream* pstream__, + const std::vector& theta, const std::vector& x_r, + const std::vector& x_i) const +{ +return integrand(x, xc, theta, x_r, x_i, pstream__); +} +void set_zero_adjoints() const { } +void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } +using ValueOf__ = integrand_functor__; +using DeepCopy__ = ValueOf__; +using captured_scalar_t__ = double;}; + +template +Eigen::Matrix::type, -1, 1> +foo(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 119; + return transpose(stan::math::to_row_vector( + stan::math::array_builder().add(1).add(2).add(3).array())); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct foo_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + const std::vector& data_r, const std::vector& data_i, + std::ostream* pstream__) const +{ +return foo(shared_params, job_params, data_r, data_i, pstream__); +} +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& shared_params, + const Eigen::Matrix& job_params, + std::ostream* pstream__, const std::vector& data_r, + const std::vector& data_i) const +{ +return foo(shared_params, job_params, data_r, data_i, pstream__); +} +void set_zero_adjoints() const { } +void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } +using ValueOf__ = foo_functor__; +using DeepCopy__ = ValueOf__; +using captured_scalar_t__ = double;}; + +template +typename boost::math::tools::promote_args::type +map_rectfake(const T0__& x, std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 121; + return (2 * x); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct map_rectfake_functor__ { +const static int num_vars__ = 0; +template +typename boost::math::tools::promote_args::type +operator()(const T0__& x, std::ostream* pstream__) const +{ +return map_rectfake(x, pstream__); +} +}; + +template +Eigen::Matrix::type, -1, 1> +algebra_system(const Eigen::Matrix& x, + const Eigen::Matrix& y, + const std::vector& dat, const std::vector& dat_int, + std::ostream* pstream__) { + using local_scalar_t__ = typename boost::math::tools::promote_args::type; + const static bool propto__ = true; + (void) propto__; + + try { + current_statement__ = 123; + validate_non_negative_index("f_x", "2", 2); + Eigen::Matrix f_x; + f_x = Eigen::Matrix(2); + + current_statement__ = 123; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 123; + assign(f_x, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable f_x");} + current_statement__ = 124; + assign(f_x, cons_list(index_uni(1), nil_index_list()), + (x[(1 - 1)] - y[(1 - 1)]), "assigning variable f_x"); + current_statement__ = 125; + assign(f_x, cons_list(index_uni(2), nil_index_list()), + (x[(2 - 1)] - y[(2 - 1)]), "assigning variable f_x"); + current_statement__ = 126; + return f_x; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + +} + +struct algebra_system_functor__ { +const static int num_vars__ = 0; +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& x, + const Eigen::Matrix& y, const std::vector& dat, + const std::vector& dat_int, std::ostream* pstream__) const +{ +return algebra_system(x, y, dat, dat_int, pstream__); +} +template +Eigen::Matrix::type, -1, 1> +operator()(const Eigen::Matrix& x, + const Eigen::Matrix& y, std::ostream* pstream__, + const std::vector& dat, const std::vector& dat_int) const +{ +return algebra_system(x, y, dat, dat_int, pstream__); +} +void set_zero_adjoints() const { } +void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } +using ValueOf__ = algebra_system_functor__; +using DeepCopy__ = ValueOf__; +using captured_scalar_t__ = double;}; + + +class motherHOF_model : public model_base_crtp { + + private: + int pos__; + int T; + std::vector y0_d; + double t0; + std::vector ts; + std::vector theta_d; + std::vector x; + std::vector x_int; + std::vector x_d_r; + std::vector x_d_i; + Eigen::Matrix shared_params_d; + std::vector> job_params_d; + std::vector> data_r; + std::vector> data_i; + + public: + ~motherHOF_model() { } + + std::string model_name() const { return "motherHOF_model"; } + + motherHOF_model(stan::io::var_context& context__, + unsigned int random_seed__ = 0, + std::ostream* pstream__ = nullptr) : model_base_crtp(0) { + typedef double local_scalar_t__; + boost::ecuyer1988 base_rng__ = + stan::services::util::create_rng(random_seed__, 0); + (void) base_rng__; // suppress unused var warning + static const char* function__ = "motherHOF_model_namespace::motherHOF_model"; + (void) function__; // suppress unused var warning + + try { + + pos__ = 1; + context__.validate_dims("data initialization","T","int", + context__.to_vec()); + + current_statement__ = 99; + T = context__.vals_i("T")[(1 - 1)]; + current_statement__ = 100; + validate_non_negative_index("y0_d", "2", 2); + context__.validate_dims("data initialization","y0_d","double", + context__.to_vec(2)); + y0_d = std::vector(2, 0); + + current_statement__ = 100; + assign(y0_d, nil_index_list(), context__.vals_r("y0_d"), + "assigning variable y0_d"); + context__.validate_dims("data initialization","t0","double", + context__.to_vec()); + + current_statement__ = 101; + t0 = context__.vals_r("t0")[(1 - 1)]; + current_statement__ = 102; + validate_non_negative_index("ts", "T", T); + context__.validate_dims("data initialization","ts","double", + context__.to_vec(T)); + ts = std::vector(T, 0); + + current_statement__ = 102; + assign(ts, nil_index_list(), context__.vals_r("ts"), + "assigning variable ts"); + current_statement__ = 103; + validate_non_negative_index("theta_d", "1", 1); + context__.validate_dims("data initialization","theta_d","double", + context__.to_vec(1)); + theta_d = std::vector(1, 0); + + current_statement__ = 103; + assign(theta_d, nil_index_list(), context__.vals_r("theta_d"), + "assigning variable theta_d"); + current_statement__ = 104; + validate_non_negative_index("x", "0", 0); + context__.validate_dims("data initialization","x","double", + context__.to_vec(0)); + x = std::vector(0, 0); + + current_statement__ = 104; + assign(x, nil_index_list(), context__.vals_r("x"), + "assigning variable x"); + current_statement__ = 105; + validate_non_negative_index("x_int", "0", 0); + context__.validate_dims("data initialization","x_int","int", + context__.to_vec(0)); + x_int = std::vector(0, 0); + + current_statement__ = 105; + assign(x_int, nil_index_list(), context__.vals_i("x_int"), + "assigning variable x_int"); + current_statement__ = 106; + validate_non_negative_index("x_d_r", "0", 0); + context__.validate_dims("data initialization","x_d_r","double", + context__.to_vec(0)); + x_d_r = std::vector(0, 0); + + current_statement__ = 106; + assign(x_d_r, nil_index_list(), context__.vals_r("x_d_r"), + "assigning variable x_d_r"); + current_statement__ = 107; + validate_non_negative_index("x_d_i", "0", 0); + context__.validate_dims("data initialization","x_d_i","int", + context__.to_vec(0)); + x_d_i = std::vector(0, 0); + + current_statement__ = 107; + assign(x_d_i, nil_index_list(), context__.vals_i("x_d_i"), + "assigning variable x_d_i"); + current_statement__ = 108; + validate_non_negative_index("shared_params_d", "3", 3); + context__.validate_dims("data initialization","shared_params_d", + "double",context__.to_vec(3)); + shared_params_d = Eigen::Matrix(3); + + { + std::vector shared_params_d_flat__; + current_statement__ = 108; + assign(shared_params_d_flat__, nil_index_list(), + context__.vals_r("shared_params_d"), + "assigning variable shared_params_d_flat__"); + current_statement__ = 108; + pos__ = 1; + current_statement__ = 108; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 108; + assign(shared_params_d, + cons_list(index_uni(sym1__), nil_index_list()), + shared_params_d_flat__[(pos__ - 1)], + "assigning variable shared_params_d"); + current_statement__ = 108; + pos__ = (pos__ + 1);} + } + current_statement__ = 109; + validate_non_negative_index("job_params_d", "3", 3); + current_statement__ = 109; + validate_non_negative_index("job_params_d", "3", 3); + context__.validate_dims("data initialization","job_params_d","double", + context__.to_vec(3, 3)); + job_params_d = std::vector>(3, Eigen::Matrix(3)); + + { + std::vector job_params_d_flat__; + current_statement__ = 109; + assign(job_params_d_flat__, nil_index_list(), + context__.vals_r("job_params_d"), + "assigning variable job_params_d_flat__"); + current_statement__ = 109; + pos__ = 1; + current_statement__ = 109; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 109; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 109; + assign(job_params_d, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + job_params_d_flat__[(pos__ - 1)], + "assigning variable job_params_d"); + current_statement__ = 109; + pos__ = (pos__ + 1);}} + } + current_statement__ = 110; + validate_non_negative_index("data_r", "3", 3); + current_statement__ = 110; + validate_non_negative_index("data_r", "3", 3); + context__.validate_dims("data initialization","data_r","double", + context__.to_vec(3, 3)); + data_r = std::vector>(3, std::vector(3, 0)); + + { + std::vector data_r_flat__; + current_statement__ = 110; + assign(data_r_flat__, nil_index_list(), context__.vals_r("data_r"), + "assigning variable data_r_flat__"); + current_statement__ = 110; + pos__ = 1; + current_statement__ = 110; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 110; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 110; + assign(data_r, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + data_r_flat__[(pos__ - 1)], "assigning variable data_r"); + current_statement__ = 110; + pos__ = (pos__ + 1);}} + } + current_statement__ = 111; + validate_non_negative_index("data_i", "3", 3); + current_statement__ = 111; + validate_non_negative_index("data_i", "3", 3); + context__.validate_dims("data initialization","data_i","int", + context__.to_vec(3, 3)); + data_i = std::vector>(3, std::vector(3, 0)); + + { + std::vector data_i_flat__; + current_statement__ = 111; + assign(data_i_flat__, nil_index_list(), context__.vals_i("data_i"), + "assigning variable data_i_flat__"); + current_statement__ = 111; + pos__ = 1; + current_statement__ = 111; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 111; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 111; + assign(data_i, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + data_i_flat__[(pos__ - 1)], "assigning variable data_i"); + current_statement__ = 111; + pos__ = (pos__ + 1);}} + } + current_statement__ = 99; + current_statement__ = 99; + check_greater_or_equal(function__, "T", T, 1); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + num_params_r__ = 0U; + + try { + current_statement__ = 1; + validate_non_negative_index("y0_p", "2", 2); + num_params_r__ += 2; + current_statement__ = 2; + validate_non_negative_index("theta_p", "1", 1); + num_params_r__ += 1; + current_statement__ = 3; + validate_non_negative_index("x_p", "1", 1); + num_params_r__ += 1; + current_statement__ = 4; + validate_non_negative_index("x_p_v", "2", 2); + num_params_r__ += 2; + current_statement__ = 5; + validate_non_negative_index("shared_params_p", "3", 3); + num_params_r__ += 3; + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + num_params_r__ += 3 * 3; + num_params_r__ += 1; + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } + template + T__ log_prob(std::vector& params_r__, std::vector& params_i__, + std::ostream* pstream__ = 0) const { + typedef T__ local_scalar_t__; + T__ lp__(0.0); + stan::math::accumulator lp_accum__; + static const char* function__ = "motherHOF_model_namespace::log_prob"; +(void) function__; // suppress unused var warning + + stan::io::reader in__(params_r__, params_i__); + + try { + current_statement__ = 1; + validate_non_negative_index("y0_p", "2", 2); + std::vector y0_p; + y0_p = std::vector(2, 0); + + current_statement__ = 1; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 1; + assign(y0_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable y0_p");} + current_statement__ = 2; + validate_non_negative_index("theta_p", "1", 1); + std::vector theta_p; + theta_p = std::vector(1, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + current_statement__ = 2; + assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable theta_p");} + current_statement__ = 3; + validate_non_negative_index("x_p", "1", 1); + std::vector x_p; + x_p = std::vector(1, 0); + + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + current_statement__ = 3; + assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable x_p");} + current_statement__ = 4; + validate_non_negative_index("x_p_v", "2", 2); + Eigen::Matrix x_p_v; + x_p_v = Eigen::Matrix(2); + + current_statement__ = 4; + x_p_v = in__.vector(2); + current_statement__ = 5; + validate_non_negative_index("shared_params_p", "3", 3); + Eigen::Matrix shared_params_p; + shared_params_p = Eigen::Matrix(3); + + current_statement__ = 5; + shared_params_p = in__.vector(3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + std::vector> job_params_p; + job_params_p = std::vector>(3, Eigen::Matrix(3)); + + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 6; + assign(job_params_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(3), "assigning variable job_params_p");} + local_scalar_t__ x_r; + + current_statement__ = 7; + x_r = in__.scalar(); + local_scalar_t__ abc1_p; + + current_statement__ = 8; + abc1_p = std::numeric_limits::quiet_NaN(); + current_statement__ = 8; + abc1_p = 3; + local_scalar_t__ abc2_p; + + current_statement__ = 9; + abc2_p = std::numeric_limits::quiet_NaN(); + current_statement__ = 9; + abc2_p = map_rectfake(abc1_p, pstream__); + local_scalar_t__ abc3_p; + + current_statement__ = 10; + abc3_p = std::numeric_limits::quiet_NaN(); + current_statement__ = 10; + abc3_p = map_rectfake(12, pstream__); + current_statement__ = 11; + validate_non_negative_index("y_hat_tp1", "3", 3); + Eigen::Matrix y_hat_tp1; + y_hat_tp1 = Eigen::Matrix(3); + + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 11; + assign(y_hat_tp1, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp1");} + current_statement__ = 11; + assign(y_hat_tp1, nil_index_list(), + map_rect<1, foo_functor__>(shared_params_p, job_params_d, data_r, + data_i, pstream__), "assigning variable y_hat_tp1"); + current_statement__ = 12; + validate_non_negative_index("y_hat_tp2", "3", 3); + Eigen::Matrix y_hat_tp2; + y_hat_tp2 = Eigen::Matrix(3); + + current_statement__ = 12; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 12; + assign(y_hat_tp2, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp2");} + current_statement__ = 12; + assign(y_hat_tp2, nil_index_list(), + map_rect<2, foo_functor__>(shared_params_d, job_params_p, data_r, + data_i, pstream__), "assigning variable y_hat_tp2"); + current_statement__ = 13; + validate_non_negative_index("y_hat_tp3", "3", 3); + Eigen::Matrix y_hat_tp3; + y_hat_tp3 = Eigen::Matrix(3); + + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 13; + assign(y_hat_tp3, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp3");} + current_statement__ = 13; + assign(y_hat_tp3, nil_index_list(), + map_rect<3, foo_functor__>(shared_params_p, job_params_d, data_r, + data_i, pstream__), "assigning variable y_hat_tp3"); + current_statement__ = 14; + validate_non_negative_index("theta_p_as", "2", 2); + Eigen::Matrix theta_p_as; + theta_p_as = Eigen::Matrix(2); + + current_statement__ = 14; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 14; + assign(theta_p_as, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta_p_as");} + current_statement__ = 15; + validate_non_negative_index("x_v", "2", 2); + Eigen::Matrix x_v; + x_v = Eigen::Matrix(2); + + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 15; + assign(x_v, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable x_v"); + } + current_statement__ = 16; + validate_non_negative_index("y_v", "2", 2); + Eigen::Matrix y_v; + y_v = Eigen::Matrix(2); + + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 16; + assign(y_v, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable y_v"); + } + current_statement__ = 17; + validate_non_negative_index("y_p", "2", 2); + Eigen::Matrix y_p; + y_p = Eigen::Matrix(2); + + current_statement__ = 17; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 17; + assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable y_p"); + } + current_statement__ = 18; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 19; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 20; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_p, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 21; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 22; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 23; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 24; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + { + current_statement__ = 57; + validate_non_negative_index("y_hat", "T", T); + current_statement__ = 57; + validate_non_negative_index("y_hat", "2", 2); + std::vector> y_hat; + y_hat = std::vector>(T, std::vector(2, 0)); + + current_statement__ = 58; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 59; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 60; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 61; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, + x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 62; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, + x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 63; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, + x_int, pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 64; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 65; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 66; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 67; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 68; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 69; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 70; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 71; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 72; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_d, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 73; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_p, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 74; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_d, x, + x_int, pstream__), "assigning variable y_hat"); + current_statement__ = 75; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_p, x, + x_int, pstream__), "assigning variable y_hat"); + local_scalar_t__ y_1d; + + current_statement__ = 76; + y_1d = std::numeric_limits::quiet_NaN(); + current_statement__ = 76; + y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 77; + y_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 78; + y_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 79; + y_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 80; + y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 81; + y_1d = integrate_1d(integrand_functor__(), x_r, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 82; + y_1d = integrate_1d(integrand_functor__(), 0, x_r, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 83; + y_1d = integrate_1d(integrand_functor__(), x_r, x_r, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 84; + y_1d = integrate_1d(integrand_functor__(), x_r, 1, x_d_r, x_d_r, + x_d_i, pstream__); + current_statement__ = 85; + y_1d = integrate_1d(integrand_functor__(), 0, x_r, x_d_r, x_d_r, + x_d_i, pstream__); + current_statement__ = 86; + y_1d = integrate_1d(integrand_functor__(), x_r, x_r, x_d_r, x_d_r, + x_d_i, pstream__); + local_scalar_t__ z_1d; + + current_statement__ = 87; + z_1d = std::numeric_limits::quiet_NaN(); + current_statement__ = 87; + z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 88; + z_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 89; + z_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 90; + z_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 91; + z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 92; + z_1d = integrate_1d(integrand_functor__(), x_r, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 93; + z_1d = integrate_1d(integrand_functor__(), 0, x_r, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 94; + z_1d = integrate_1d(integrand_functor__(), x_r, x_r, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 95; + z_1d = integrate_1d(integrand_functor__(), x_r, 1, x_d_r, x_d_r, + x_d_i, pstream__, 1e-8); + current_statement__ = 96; + z_1d = integrate_1d(integrand_functor__(), 0, x_r, x_d_r, x_d_r, + x_d_i, pstream__, 1e-8); + current_statement__ = 97; + z_1d = integrate_1d(integrand_functor__(), x_r, x_r, x_d_r, x_d_r, + x_d_i, pstream__, 1e-8); + local_scalar_t__ abc_m; + + current_statement__ = 98; + abc_m = std::numeric_limits::quiet_NaN(); + current_statement__ = 98; + abc_m = map_rectfake(abc1_p, pstream__); + } + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + lp_accum__.add(lp__); + return lp_accum__.sum(); + } // log_prob() + + template + void write_array(RNG& base_rng__, std::vector& params_r__, + std::vector& params_i__, std::vector& vars__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream__ = 0) const { + typedef double local_scalar_t__; + vars__.resize(0); + stan::io::reader in__(params_r__, params_i__); + static const char* function__ = "motherHOF_model_namespace::write_array"; +(void) function__; // suppress unused var warning + + (void) function__; // suppress unused var warning + + double lp__ = 0.0; + (void) lp__; // dummy to suppress unused var warning + stan::math::accumulator lp_accum__; + + try { + current_statement__ = 1; + validate_non_negative_index("y0_p", "2", 2); + std::vector y0_p; + y0_p = std::vector(2, 0); + + current_statement__ = 1; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 1; + assign(y0_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable y0_p");} + current_statement__ = 2; + validate_non_negative_index("theta_p", "1", 1); + std::vector theta_p; + theta_p = std::vector(1, 0); + + current_statement__ = 2; + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + current_statement__ = 2; + assign(theta_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable theta_p");} + current_statement__ = 3; + validate_non_negative_index("x_p", "1", 1); + std::vector x_p; + x_p = std::vector(1, 0); + + current_statement__ = 3; + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + current_statement__ = 3; + assign(x_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.scalar(), "assigning variable x_p");} + current_statement__ = 4; + validate_non_negative_index("x_p_v", "2", 2); + Eigen::Matrix x_p_v; + x_p_v = Eigen::Matrix(2); + + current_statement__ = 4; + x_p_v = in__.vector(2); + current_statement__ = 5; + validate_non_negative_index("shared_params_p", "3", 3); + Eigen::Matrix shared_params_p; + shared_params_p = Eigen::Matrix(3); + + current_statement__ = 5; + shared_params_p = in__.vector(3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + std::vector> job_params_p; + job_params_p = std::vector>(3, Eigen::Matrix(3)); + + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 6; + assign(job_params_p, cons_list(index_uni(sym1__), nil_index_list()), + in__.vector(3), "assigning variable job_params_p");} + double x_r; + + current_statement__ = 7; + x_r = in__.scalar(); + double abc1_p; + + current_statement__ = 8; + abc1_p = std::numeric_limits::quiet_NaN(); + double abc2_p; + + current_statement__ = 9; + abc2_p = std::numeric_limits::quiet_NaN(); + double abc3_p; + + current_statement__ = 10; + abc3_p = std::numeric_limits::quiet_NaN(); + current_statement__ = 11; + validate_non_negative_index("y_hat_tp1", "3", 3); + Eigen::Matrix y_hat_tp1; + y_hat_tp1 = Eigen::Matrix(3); + + current_statement__ = 11; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 11; + assign(y_hat_tp1, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp1");} + current_statement__ = 12; + validate_non_negative_index("y_hat_tp2", "3", 3); + Eigen::Matrix y_hat_tp2; + y_hat_tp2 = Eigen::Matrix(3); + + current_statement__ = 12; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 12; + assign(y_hat_tp2, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp2");} + current_statement__ = 13; + validate_non_negative_index("y_hat_tp3", "3", 3); + Eigen::Matrix y_hat_tp3; + y_hat_tp3 = Eigen::Matrix(3); + + current_statement__ = 13; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 13; + assign(y_hat_tp3, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_tp3");} + current_statement__ = 14; + validate_non_negative_index("theta_p_as", "2", 2); + Eigen::Matrix theta_p_as; + theta_p_as = Eigen::Matrix(2); + + current_statement__ = 14; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 14; + assign(theta_p_as, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable theta_p_as");} + current_statement__ = 15; + validate_non_negative_index("x_v", "2", 2); + Eigen::Matrix x_v; + x_v = Eigen::Matrix(2); + + current_statement__ = 15; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 15; + assign(x_v, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable x_v"); + } + current_statement__ = 16; + validate_non_negative_index("y_v", "2", 2); + Eigen::Matrix y_v; + y_v = Eigen::Matrix(2); + + current_statement__ = 16; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 16; + assign(y_v, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable y_v"); + } + current_statement__ = 17; + validate_non_negative_index("y_p", "2", 2); + Eigen::Matrix y_p; + y_p = Eigen::Matrix(2); + + current_statement__ = 17; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 17; + assign(y_p, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), "assigning variable y_p"); + } + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y0_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + vars__.push_back(theta_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + vars__.push_back(x_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(x_p_v[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(shared_params_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back(job_params_p[(sym2__ - 1)][(sym1__ - 1)]);}} + vars__.push_back(x_r); + if (logical_negation((primitive_value(emit_transformed_parameters__) || + primitive_value(emit_generated_quantities__)))) { + return ; + } + current_statement__ = 8; + abc1_p = 3; + current_statement__ = 9; + abc2_p = map_rectfake(abc1_p, pstream__); + current_statement__ = 10; + abc3_p = map_rectfake(12, pstream__); + current_statement__ = 11; + assign(y_hat_tp1, nil_index_list(), + map_rect<4, foo_functor__>(shared_params_p, job_params_d, data_r, + data_i, pstream__), "assigning variable y_hat_tp1"); + current_statement__ = 12; + assign(y_hat_tp2, nil_index_list(), + map_rect<5, foo_functor__>(shared_params_d, job_params_p, data_r, + data_i, pstream__), "assigning variable y_hat_tp2"); + current_statement__ = 13; + assign(y_hat_tp3, nil_index_list(), + map_rect<6, foo_functor__>(shared_params_p, job_params_d, data_r, + data_i, pstream__), "assigning variable y_hat_tp3"); + current_statement__ = 18; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 19; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_v, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 20; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_v, y_p, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 21; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 22; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_v, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + current_statement__ = 23; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, + pstream__), "assigning variable theta_p_as"); + current_statement__ = 24; + assign(theta_p_as, nil_index_list(), + algebra_solver(algebra_system_functor__(), x_p_v, y_p, x_d_r, x_d_i, + pstream__, 0.01, 0.01, 10), "assigning variable theta_p_as"); + vars__.push_back(abc1_p); + vars__.push_back(abc2_p); + vars__.push_back(abc3_p); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(y_hat_tp1[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(y_hat_tp2[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(y_hat_tp3[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(theta_p_as[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(x_v[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y_v[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y_p[(sym1__ - 1)]);} + if (logical_negation(emit_generated_quantities__)) { + return ; + } + current_statement__ = 25; + validate_non_negative_index("y_hat", "T", T); + current_statement__ = 25; + validate_non_negative_index("y_hat", "2", 2); + std::vector> y_hat; + y_hat = std::vector>(T, std::vector(2, 0)); + + current_statement__ = 26; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 27; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 28; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 29; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 30; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 31; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 32; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 33; + assign(y_hat, nil_index_list(), + integrate_ode_adams(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 34; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 35; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 36; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 37; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 100000000.), "assigning variable y_hat"); + current_statement__ = 38; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 39; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 40; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 41; + assign(y_hat, nil_index_list(), + integrate_ode_bdf(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__, 1e-10, 1e-10, 1e8), "assigning variable y_hat"); + current_statement__ = 42; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_d, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 43; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_d, t0, ts, theta_p, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 44; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_d, x, x_int, + pstream__), "assigning variable y_hat"); + current_statement__ = 45; + assign(y_hat, nil_index_list(), + integrate_ode_rk45(sho_functor__(), y0_p, t0, ts, theta_p, x, x_int, + pstream__), "assigning variable y_hat"); + double y_1d; + + current_statement__ = 46; + y_1d = std::numeric_limits::quiet_NaN(); + current_statement__ = 46; + y_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 47; + y_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 48; + y_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, + pstream__); + current_statement__ = 49; + y_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, + pstream__); + double z_1d; + + current_statement__ = 50; + z_1d = std::numeric_limits::quiet_NaN(); + current_statement__ = 50; + z_1d = integrate_1d(integrand_functor__(), 0, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 51; + z_1d = integrate_1d(integrand_functor__(), 0.0, 1, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 52; + z_1d = integrate_1d(integrand_functor__(), 0, 1.0, x, x_d_r, x_d_i, + pstream__, 1e-8); + current_statement__ = 53; + z_1d = integrate_1d(integrand_functor__(), 0.0, 1.0, x, x_d_r, x_d_i, + pstream__, 1e-8); + double abc1_gq; + + current_statement__ = 54; + abc1_gq = std::numeric_limits::quiet_NaN(); + current_statement__ = 54; + abc1_gq = map_rectfake(12, pstream__); + double abc2_gq; + + current_statement__ = 55; + abc2_gq = std::numeric_limits::quiet_NaN(); + current_statement__ = 55; + abc2_gq = map_rectfake(abc1_p, pstream__); + current_statement__ = 56; + validate_non_negative_index("y_hat_gq", "3", 3); + Eigen::Matrix y_hat_gq; + y_hat_gq = Eigen::Matrix(3); + + current_statement__ = 56; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 56; + assign(y_hat_gq, cons_list(index_uni(sym1__), nil_index_list()), + std::numeric_limits::quiet_NaN(), + "assigning variable y_hat_gq");} + current_statement__ = 56; + assign(y_hat_gq, nil_index_list(), + map_rect<7, foo_functor__>(shared_params_d, job_params_d, data_r, + data_i, pstream__), "assigning variable y_hat_gq"); + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { + vars__.push_back(y_hat[(sym2__ - 1)][(sym1__ - 1)]);}} + vars__.push_back(y_1d); + vars__.push_back(z_1d); + vars__.push_back(abc1_gq); + vars__.push_back(abc2_gq); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(y_hat_gq[(sym1__ - 1)]);} + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // write_array() + + void transform_inits(const stan::io::var_context& context__, + std::vector& params_i__, + std::vector& vars__, std::ostream* pstream__) const { + typedef double local_scalar_t__; + vars__.resize(0); + vars__.reserve(num_params_r__); + + try { + int pos__; + + pos__ = 1; + current_statement__ = 1; + validate_non_negative_index("y0_p", "2", 2); + std::vector y0_p; + y0_p = std::vector(2, 0); + + current_statement__ = 1; + assign(y0_p, nil_index_list(), context__.vals_r("y0_p"), + "assigning variable y0_p"); + current_statement__ = 2; + validate_non_negative_index("theta_p", "1", 1); + std::vector theta_p; + theta_p = std::vector(1, 0); + + current_statement__ = 2; + assign(theta_p, nil_index_list(), context__.vals_r("theta_p"), + "assigning variable theta_p"); + current_statement__ = 3; + validate_non_negative_index("x_p", "1", 1); + std::vector x_p; + x_p = std::vector(1, 0); + + current_statement__ = 3; + assign(x_p, nil_index_list(), context__.vals_r("x_p"), + "assigning variable x_p"); + current_statement__ = 4; + validate_non_negative_index("x_p_v", "2", 2); + Eigen::Matrix x_p_v; + x_p_v = Eigen::Matrix(2); + + { + std::vector x_p_v_flat__; + current_statement__ = 4; + assign(x_p_v_flat__, nil_index_list(), context__.vals_r("x_p_v"), + "assigning variable x_p_v_flat__"); + current_statement__ = 4; + pos__ = 1; + current_statement__ = 4; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + current_statement__ = 4; + assign(x_p_v, cons_list(index_uni(sym1__), nil_index_list()), + x_p_v_flat__[(pos__ - 1)], "assigning variable x_p_v"); + current_statement__ = 4; + pos__ = (pos__ + 1);} + } + current_statement__ = 5; + validate_non_negative_index("shared_params_p", "3", 3); + Eigen::Matrix shared_params_p; + shared_params_p = Eigen::Matrix(3); + + { + std::vector shared_params_p_flat__; + current_statement__ = 5; + assign(shared_params_p_flat__, nil_index_list(), + context__.vals_r("shared_params_p"), + "assigning variable shared_params_p_flat__"); + current_statement__ = 5; + pos__ = 1; + current_statement__ = 5; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 5; + assign(shared_params_p, + cons_list(index_uni(sym1__), nil_index_list()), + shared_params_p_flat__[(pos__ - 1)], + "assigning variable shared_params_p"); + current_statement__ = 5; + pos__ = (pos__ + 1);} + } + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + current_statement__ = 6; + validate_non_negative_index("job_params_p", "3", 3); + std::vector> job_params_p; + job_params_p = std::vector>(3, Eigen::Matrix(3)); + + { + std::vector job_params_p_flat__; + current_statement__ = 6; + assign(job_params_p_flat__, nil_index_list(), + context__.vals_r("job_params_p"), + "assigning variable job_params_p_flat__"); + current_statement__ = 6; + pos__ = 1; + current_statement__ = 6; + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + current_statement__ = 6; + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + current_statement__ = 6; + assign(job_params_p, + cons_list(index_uni(sym2__), + cons_list(index_uni(sym1__), nil_index_list())), + job_params_p_flat__[(pos__ - 1)], + "assigning variable job_params_p"); + current_statement__ = 6; + pos__ = (pos__ + 1);}} + } + double x_r; + + current_statement__ = 7; + x_r = context__.vals_r("x_r")[(1 - 1)]; + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(y0_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + vars__.push_back(theta_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + vars__.push_back(x_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + vars__.push_back(x_p_v[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + vars__.push_back(shared_params_p[(sym1__ - 1)]);} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + vars__.push_back(job_params_p[(sym2__ - 1)][(sym1__ - 1)]);}} + vars__.push_back(x_r); + } catch (const std::exception& e) { + stan::lang::rethrow_located(e, locations_array__[current_statement__]); + // Next line prevents compiler griping about no return + throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); + } + } // transform_inits() + + void get_param_names(std::vector& names__) const { + + names__.resize(0); + names__.push_back("y0_p"); + names__.push_back("theta_p"); + names__.push_back("x_p"); + names__.push_back("x_p_v"); + names__.push_back("shared_params_p"); + names__.push_back("job_params_p"); + names__.push_back("x_r"); + names__.push_back("abc1_p"); + names__.push_back("abc2_p"); + names__.push_back("abc3_p"); + names__.push_back("y_hat_tp1"); + names__.push_back("y_hat_tp2"); + names__.push_back("y_hat_tp3"); + names__.push_back("theta_p_as"); + names__.push_back("x_v"); + names__.push_back("y_v"); + names__.push_back("y_p"); + names__.push_back("y_hat"); + names__.push_back("y_1d"); + names__.push_back("z_1d"); + names__.push_back("abc1_gq"); + names__.push_back("abc2_gq"); + names__.push_back("y_hat_gq"); + } // get_param_names() + + void get_dims(std::vector>& dimss__) const { + dimss__.resize(0); + std::vector dims__; + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(1); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(1); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(T); + + dims__.push_back(2); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dimss__.push_back(dims__); + dims__.resize(0); + dims__.push_back(3); + dimss__.push_back(dims__); + dims__.resize(0); + + } // get_dims() + + void constrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y0_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + { + param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "x_p_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "shared_params_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + param_names__.push_back(std::string() + "job_params_p" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + param_names__.push_back(std::string() + "x_r"); + if (emit_transformed_parameters__) { + param_names__.push_back(std::string() + "abc1_p"); + param_names__.push_back(std::string() + "abc2_p"); + param_names__.push_back(std::string() + "abc3_p"); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp1" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp2" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp3" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_p_as" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "x_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + }} + } + + if (emit_generated_quantities__) { + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { + { + param_names__.push_back(std::string() + "y_hat" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + param_names__.push_back(std::string() + "y_1d"); + param_names__.push_back(std::string() + "z_1d"); + param_names__.push_back(std::string() + "abc1_gq"); + param_names__.push_back(std::string() + "abc2_gq"); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_gq" + '.' + std::to_string(sym1__)); + }} + } + + } // constrained_param_names() + + void unconstrained_param_names(std::vector& param_names__, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true) const { + + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y0_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 1; ++sym1__) { + { + param_names__.push_back(std::string() + "x_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "x_p_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "shared_params_p" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= 3; ++sym2__) { + { + param_names__.push_back(std::string() + "job_params_p" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + param_names__.push_back(std::string() + "x_r"); + if (emit_transformed_parameters__) { + param_names__.push_back(std::string() + "abc1_p"); + param_names__.push_back(std::string() + "abc2_p"); + param_names__.push_back(std::string() + "abc3_p"); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp1" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp2" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_tp3" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "theta_p_as" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "x_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y_v" + '.' + std::to_string(sym1__)); + }} + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + param_names__.push_back(std::string() + "y_p" + '.' + std::to_string(sym1__)); + }} + } + + if (emit_generated_quantities__) { + for (size_t sym1__ = 1; sym1__ <= 2; ++sym1__) { + { + for (size_t sym2__ = 1; sym2__ <= T; ++sym2__) { + { + param_names__.push_back(std::string() + "y_hat" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__)); + }} + }} + param_names__.push_back(std::string() + "y_1d"); + param_names__.push_back(std::string() + "z_1d"); + param_names__.push_back(std::string() + "abc1_gq"); + param_names__.push_back(std::string() + "abc2_gq"); + for (size_t sym1__ = 1; sym1__ <= 3; ++sym1__) { + { + param_names__.push_back(std::string() + "y_hat_gq" + '.' + std::to_string(sym1__)); + }} + } + + } // unconstrained_param_names() + + std::string get_constrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"y0_p\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"shared_params_p\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"job_params_p\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_r\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"abc1_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc2_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc3_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp1\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp2\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp3\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p_as\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"x_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat\",\"type\":{\"name\":\"array\",\"length\":" << T << ",\"element_type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"},{\"name\":\"y_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"z_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc1_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc2_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"y_hat_gq\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"generated_quantities\"}]"; + return s__.str(); + } // get_constrained_sizedtypes() + + std::string get_unconstrained_sizedtypes() const { + stringstream s__; + s__ << "[{\"name\":\"y0_p\",\"type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"theta_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p\",\"type\":{\"name\":\"array\",\"length\":" << 1 << ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"x_p_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"parameters\"},{\"name\":\"shared_params_p\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"parameters\"},{\"name\":\"job_params_p\",\"type\":{\"name\":\"array\",\"length\":" << 3 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << 3 << "}},\"block\":\"parameters\"},{\"name\":\"x_r\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"abc1_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc2_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"abc3_p\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp1\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp2\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat_tp3\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_p_as\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"x_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_v\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_p\",\"type\":{\"name\":\"vector\",\"length\":" << 2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"y_hat\",\"type\":{\"name\":\"array\",\"length\":" << T << ",\"element_type\":{\"name\":\"array\",\"length\":" << 2 << ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"},{\"name\":\"y_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"z_1d\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc1_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"abc2_gq\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"y_hat_gq\",\"type\":{\"name\":\"vector\",\"length\":" << 3 << "},\"block\":\"generated_quantities\"}]"; + return s__.str(); + } // get_unconstrained_sizedtypes() + + + // Begin method overload boilerplate + template + void write_array(RNG& base_rng__, + Eigen::Matrix& params_r, + Eigen::Matrix& vars, + bool emit_transformed_parameters__ = true, + bool emit_generated_quantities__ = true, + std::ostream* pstream = 0) const { + std::vector params_r_vec(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r_vec[i] = params_r(i); + std::vector vars_vec; + std::vector params_i_vec; + write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, + emit_transformed_parameters__, emit_generated_quantities__, pstream); + vars.resize(vars_vec.size()); + for (int i = 0; i < vars.size(); ++i) + vars(i) = vars_vec[i]; + } + + template + T_ log_prob(Eigen::Matrix& params_r, + std::ostream* pstream = 0) const { + std::vector vec_params_r; + vec_params_r.reserve(params_r.size()); + for (int i = 0; i < params_r.size(); ++i) + vec_params_r.push_back(params_r(i)); + std::vector vec_params_i; + return log_prob(vec_params_r, vec_params_i, pstream); + } + + void transform_inits(const stan::io::var_context& context, + Eigen::Matrix& params_r, + std::ostream* pstream__) const { + std::vector params_r_vec; + std::vector params_i_vec; + transform_inits(context, params_i_vec, params_r_vec, pstream__); + params_r.resize(params_r_vec.size()); + for (int i = 0; i < params_r.size(); ++i) + params_r(i) = params_r_vec[i]; + } + +}; +} +typedef motherHOF_model_namespace::motherHOF_model stan_model; + +#ifndef USING_R + +// Boilerplate +stan::model::model_base& new_model( + stan::io::var_context& data_context, + unsigned int seed, + std::ostream* msg_stream) { + stan_model* m = new stan_model(data_context, seed, msg_stream); + return *m; +} + +#endif + + +STAN_REGISTER_MAP_RECT(1, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(2, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(3, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(4, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(5, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(6, motherHOF_model_namespace::foo_functor__) +STAN_REGISTER_MAP_RECT(7, motherHOF_model_namespace::foo_functor__) + $ ../../../../../install/default/bin/stanc --print-cpp optimize_glm.stan + +// Code generated by %%NAME%% %%VERSION%% +#include +namespace optimize_glm_model_namespace { + +void FnZeroAdjoint__(double) { } +void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } +double FnGetAdjoint__(double) { return 0.0; } +double FnGetAdjoint__(stan::math::var x) { return x.adj(); } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } +stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } + +template +std::vector resize_to_match__(std::vector& dst, const std::vector& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.rows(), src.cols()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} + +template +Eigen::Matrix +resize_to_match__(Eigen::Matrix& dst, const Eigen::Matrix& src) { + dst.resize(src.size()); + return dst; +} +std::vector to_doubles__(std::initializer_list x) { + return x; +} + +std::vector to_vars__(std::initializer_list x) { + return x; +} + +inline void validate_positive_index(const char* var_name, const char* expr, + int val) { + if (val < 1) { + std::stringstream msg; + msg << "Found dimension size less than one in simplex declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + +inline void validate_unit_vector_index(const char* var_name, const char* expr, + int val) { + if (val <= 1) { + std::stringstream msg; + if (val == 1) { + msg << "Found dimension size one in unit vector declaration." + << " One-dimensional unit vector is discrete" + << " but the target distribution must be continuous." + << " variable=" << var_name << "; dimension size expression=" << expr; + } else { + msg << "Found dimension size less than one in unit vector declaration" + << "; variable=" << var_name << "; dimension size expression=" << expr + << "; expression value=" << val; + } + std::string msg_str(msg.str()); + throw std::invalid_argument(msg_str.c_str()); + } +} + + +using std::istream; +using std::string; +using std::stringstream; +using std::vector; +using std::pow; +using stan::io::dump; +using stan::math::lgamma; +using stan::model::model_base_crtp; +using stan::model::rvalue; +using stan::model::cons_list; +using stan::model::index_uni; +using stan::model::index_max; +using stan::model::index_min; +using stan::model::index_min_max; +using stan::model::index_multi; +using stan::model::index_omni; +using stan::model::nil_index_list; +using namespace stan::math; + +static int current_statement__ = 0; +static const std::vector locations_array__ = {" (found before start of program)", + " (in 'optimize_glm.stan', line 26, column 2 to column 20)", + " (in 'optimize_glm.stan', line 27, column 2 to column 17)", + " (in 'optimize_glm.stan', line 28, column 2 to column 17)", + " (in 'optimize_glm.stan', line 29, column 2 to column 22)", + " (in 'optimize_glm.stan', line 30, column 2 to column 13)", + " (in 'optimize_glm.stan', line 31, column 2 to column 11)", + " (in 'optimize_glm.stan', line 32, column 2 to column 19)", + " (in 'optimize_glm.stan', line 33, column 2 to column 22)", + " (in 'optimize_glm.stan', line 34, column 2 to column 23)", + " (in 'optimize_glm.stan', line 38, column 2 to column 64)", + " (in 'optimize_glm.stan', line 39, column 2 to column 49)", + " (in 'optimize_glm.stan', line 41, column 2 to column 64)", + " (in 'optimize_glm.stan', line 42, column 2 to column 49)", + " (in 'optimize_glm.stan', line 44, column 2 to column 63)", + " (in 'optimize_glm.stan', line 45, column 2 to column 48)", + " (in 'optimize_glm.stan', line 47, column 2 to column 63)", + " (in 'optimize_glm.stan', line 48, column 2 to column 48)", + " (in 'optimize_glm.stan', line 50, column 2 to column 66)", + " (in 'optimize_glm.stan', line 51, column 2 to column 51)", + " (in 'optimize_glm.stan', line 53, column 2 to column 66)", + " (in 'optimize_glm.stan', line 54, column 2 to column 51)", + " (in 'optimize_glm.stan', line 56, column 2 to column 70)", + " (in 'optimize_glm.stan', line 57, column 2 to column 55)", + " (in 'optimize_glm.stan', line 59, column 2 to column 67)", + " (in 'optimize_glm.stan', line 60, column 2 to column 52)", + " (in 'optimize_glm.stan', line 62, column 2 to column 69)", + " (in 'optimize_glm.stan', line 63, column 2 to column 54)", + " (in 'optimize_glm.stan', line 65, column 2 to column 66)", + " (in 'optimize_glm.stan', line 66, column 2 to column 51)", + " (in 'optimize_glm.stan', line 68, column 2 to column 72)", + " (in 'optimize_glm.stan', line 69, column 2 to column 57)", + " (in 'optimize_glm.stan', line 71, column 2 to column 69)", + " (in 'optimize_glm.stan', line 72, column 2 to column 54)", + " (in 'optimize_glm.stan', line 74, column 2 to column 63)", + " (in 'optimize_glm.stan', line 75, column 2 to column 49)", + " (in 'optimize_glm.stan', line 77, column 2 to column 63)", + " (in 'optimize_glm.stan', line 78, column 2 to column 49)", + " (in 'optimize_glm.stan', line 80, column 2 to column 66)", + " (in 'optimize_glm.stan', line 81, column 2 to column 52)", + " (in 'optimize_glm.stan', line 83, column 2 to column 66)", + " (in 'optimize_glm.stan', line 84, column 2 to column 52)", + " (in 'optimize_glm.stan', line 86, column 2 to column 62)", + " (in 'optimize_glm.stan', line 87, column 2 to column 48)", + " (in 'optimize_glm.stan', line 89, column 2 to column 62)", + " (in 'optimize_glm.stan', line 90, column 2 to column 48)", + " (in 'optimize_glm.stan', line 92, column 2 to column 69)", + " (in 'optimize_glm.stan', line 93, column 2 to column 55)", + " (in 'optimize_glm.stan', line 95, column 2 to column 66)", + " (in 'optimize_glm.stan', line 96, column 2 to column 52)", + " (in 'optimize_glm.stan', line 98, column 2 to column 72)", + " (in 'optimize_glm.stan', line 99, column 2 to column 58)", + " (in 'optimize_glm.stan', line 101, column 2 to column 69)", + " (in 'optimize_glm.stan', line 102, column 2 to column 55)", + " (in 'optimize_glm.stan', line 104, column 2 to column 68)", + " (in 'optimize_glm.stan', line 105, column 2 to column 54)", + " (in 'optimize_glm.stan', line 107, column 2 to column 65)", + " (in 'optimize_glm.stan', line 108, column 2 to column 51)", + " (in 'optimize_glm.stan', line 110, column 2 to column 59)", + " (in 'optimize_glm.stan', line 111, column 2 to column 45)", + " (in 'optimize_glm.stan', line 113, column 2 to column 59)", + " (in 'optimize_glm.stan', line 114, column 2 to column 45)", + " (in 'optimize_glm.stan', line 116, column 2 to column 58)", + " (in 'optimize_glm.stan', line 117, column 2 to column 44)", + " (in 'optimize_glm.stan', line 119, column 2 to column 58)", + " (in 'optimize_glm.stan', line 120, column 2 to column 44)", + " (in 'optimize_glm.stan', line 122, column 2 to column 62)", + " (in 'optimize_glm.stan', line 123, column 2 to column 48)", + " (in 'optimize_glm.stan', line 125, column 2 to column 62)", + " (in 'optimize_glm.stan', line 126, column 2 to column 48)", + " (in 'optimize_glm.stan', line 128, column 2 to column 65)", + " (in 'optimize_glm.stan', line 129, column 2 to column 51)", + " (in 'optimize_glm.stan', line 131, column 2 to column 62)", + " (in 'optimize_glm.stan', line 132, column 2 to column 48)", + " (in 'optimize_glm.stan', line 134, column 2 to column 64)", + " (in 'optimize_glm.stan', line 135, column 2 to column 50)", + " (in 'optimize_glm.stan', line 137, column 2 to column 61)", + " (in 'optimize_glm.stan', line 138, column 2 to column 47)", + " (in 'optimize_glm.stan', line 140, column 2 to column 68)", + " (in 'optimize_glm.stan', line 141, column 2 to column 54)", + " (in 'optimize_glm.stan', line 143, column 2 to column 65)", + " (in 'optimize_glm.stan', line 144, column 2 to column 51)", + " (in 'optimize_glm.stan', line 146, column 2 to column 71)", + " (in 'optimize_glm.stan', line 147, column 2 to column 57)", + " (in 'optimize_glm.stan', line 149, column 2 to column 71)", + " (in 'optimize_glm.stan', line 150, column 2 to column 57)", + " (in 'optimize_glm.stan', line 152, column 2 to column 70)", + " (in 'optimize_glm.stan', line 153, column 2 to column 56)", + " (in 'optimize_glm.stan', line 155, column 2 to column 70)", + " (in 'optimize_glm.stan', line 156, column 2 to column 56)", + " (in 'optimize_glm.stan', line 158, column 2 to column 74)", + " (in 'optimize_glm.stan', line 159, column 2 to column 60)", + " (in 'optimize_glm.stan', line 161, column 2 to column 74)", + " (in 'optimize_glm.stan', line 162, column 2 to column 60)", + " (in 'optimize_glm.stan', line 164, column 2 to column 77)", + " (in 'optimize_glm.stan', line 165, column 2 to column 63)", + " (in 'optimize_glm.stan', line 167, column 2 to column 74)", + " (in 'optimize_glm.stan', line 168, column 2 to column 60)", + " (in 'optimize_glm.stan', line 170, column 2 to column 76)", + " (in 'optimize_glm.stan', line 171, column 2 to column 62)", + " (in 'optimize_glm.stan', line 173, column 2 to column 73)", + " (in 'optimize_glm.stan', line 174, column 2 to column 59)", + " (in 'optimize_glm.stan', line 176, column 2 to column 80)", + " (in 'optimize_glm.stan', line 177, column 2 to column 66)", + " (in 'optimize_glm.stan', line 179, column 2 to column 77)", + " (in 'optimize_glm.stan', line 180, column 2 to column 63)", + " (in 'optimize_glm.stan', line 182, column 2 to column 62)", + " (in 'optimize_glm.stan', line 183, column 2 to column 48)", + " (in 'optimize_glm.stan', line 185, column 2 to column 62)", + " (in 'optimize_glm.stan', line 186, column 2 to column 48)", + " (in 'optimize_glm.stan', line 188, column 2 to column 68)", + " (in 'optimize_glm.stan', line 189, column 2 to column 54)", + " (in 'optimize_glm.stan', line 191, column 2 to column 65)", + " (in 'optimize_glm.stan', line 192, column 2 to column 51)", + " (in 'optimize_glm.stan', line 194, column 2 to column 62)", + " (in 'optimize_glm.stan', line 195, column 2 to column 48)", + " (in 'optimize_glm.stan', line 197, column 2 to column 62)", + " (in 'optimize_glm.stan', line 198, column 2 to column 48)", + " (in 'optimize_glm.stan', line 200, column 2 to column 68)", + " (in 'optimize_glm.stan', line 201, column 2 to column 54)", + " (in 'optimize_glm.stan', line 203, column 2 to column 65)", + " (in 'optimize_glm.stan', line 204, column 2 to column 51)", + " (in 'optimize_glm.stan', line 206, column 2 to column 65)", + " (in 'optimize_glm.stan', line 207, column 2 to column 51)", + " (in 'optimize_glm.stan', line 209, column 2 to column 65)", + " (in 'optimize_glm.stan', line 210, column 2 to column 51)", + " (in 'optimize_glm.stan', line 212, column 2 to column 63)", + " (in 'optimize_glm.stan', line 213, column 2 to column 49)", + " (in 'optimize_glm.stan', line 215, column 2 to column 63)", + " (in 'optimize_glm.stan', line 216, column 2 to column 49)", + " (in 'optimize_glm.stan', line 218, column 2 to column 69)", + " (in 'optimize_glm.stan', line 219, column 2 to column 55)", + " (in 'optimize_glm.stan', line 221, column 2 to column 66)", + " (in 'optimize_glm.stan', line 222, column 2 to column 53)", + " (in 'optimize_glm.stan', line 224, column 2 to column 66)", + " (in 'optimize_glm.stan', line 225, column 2 to column 52)", + " (in 'optimize_glm.stan', line 227, column 2 to column 66)", + " (in 'optimize_glm.stan', line 228, column 2 to column 52)", + " (in 'optimize_glm.stan', line 230, column 2 to column 68)", + " (in 'optimize_glm.stan', line 231, column 2 to column 54)", + " (in 'optimize_glm.stan', line 233, column 2 to column 68)", + " (in 'optimize_glm.stan', line 234, column 2 to column 54)", + " (in 'optimize_glm.stan', line 236, column 2 to column 74)", + " (in 'optimize_glm.stan', line 237, column 2 to column 60)", + " (in 'optimize_glm.stan', line 239, column 2 to column 71)", + " (in 'optimize_glm.stan', line 240, column 2 to column 57)", + " (in 'optimize_glm.stan', line 242, column 2 to column 71)", + " (in 'optimize_glm.stan', line 243, column 2 to column 57)", + " (in 'optimize_glm.stan', line 245, column 2 to column 71)", + " (in 'optimize_glm.stan', line 246, column 2 to column 57)", + " (in 'optimize_glm.stan', line 248, column 2 to column 77)", + " (in 'optimize_glm.stan', line 249, column 2 to column 63)", + " (in 'optimize_glm.stan', line 251, column 2 to column 74)", + " (in 'optimize_glm.stan', line 252, column 2 to column 60)", + " (in 'optimize_glm.stan', line 254, column 2 to column 69)", + " (in 'optimize_glm.stan', line 255, column 2 to column 55)", + " (in 'optimize_glm.stan', line 257, column 2 to column 69)", + " (in 'optimize_glm.stan', line 258, column 2 to column 55)", + " (in 'optimize_glm.stan', line 260, column 2 to column 75)", + " (in 'optimize_glm.stan', line 261, column 2 to column 61)", + " (in 'optimize_glm.stan', line 263, column 2 to column 72)", + " (in 'optimize_glm.stan', line 264, column 2 to column 58)", + " (in 'optimize_glm.stan', line 266, column 2 to column 72)", + " (in 'optimize_glm.stan', line 267, column 2 to column 58)", + " (in 'optimize_glm.stan', line 269, column 2 to column 72)", + " (in 'optimize_glm.stan', line 270, column 2 to column 58)", + " (in 'optimize_glm.stan', line 272, column 2 to column 78)", + " (in 'optimize_glm.stan', line 273, column 2 to column 64)", + " (in 'optimize_glm.stan', line 275, column 2 to column 75)", + " (in 'optimize_glm.stan', line 276, column 2 to column 61)", + " (in 'optimize_glm.stan', line 278, column 2 to column 73)", + " (in 'optimize_glm.stan', line 279, column 2 to column 59)", + " (in 'optimize_glm.stan', line 281, column 2 to column 76)", + " (in 'optimize_glm.stan', line 282, column 2 to column 62)", + " (in 'optimize_glm.stan', line 2, column 2 to column 17)", + " (in 'optimize_glm.stan', line 3, column 2 to column 17)", + " (in 'optimize_glm.stan', line 4, column 2 to column 19)", + " (in 'optimize_glm.stan', line 5, column 2 to column 18)", + " (in 'optimize_glm.stan', line 6, column 2 to column 23)", + " (in 'optimize_glm.stan', line 7, column 2 to column 16)", + " (in 'optimize_glm.stan', line 8, column 2 to column 17)", + " (in 'optimize_glm.stan', line 9, column 2 to column 12)", + " (in 'optimize_glm.stan', line 10, column 2 to column 13)", + " (in 'optimize_glm.stan', line 14, column 2 to column 20)", + " (in 'optimize_glm.stan', line 15, column 2 to column 20)", + " (in 'optimize_glm.stan', line 16, column 2 to column 22)", + " (in 'optimize_glm.stan', line 17, column 2 to column 21)", + " (in 'optimize_glm.stan', line 18, column 2 to column 26)", + " (in 'optimize_glm.stan', line 19, column 2 to column 19)", + " (in 'optimize_glm.stan', line 20, column 2 to column 20)", + " (in 'optimize_glm.stan', line 21, column 2 to column 15)", + " (in 'optimize_glm.stan', line 22, column 2 to column 16)"}; + + + + + +class optimize_glm_model : public model_base_crtp { + + private: + int pos__; + int k; + int n; + Eigen::Matrix X_d; + Eigen::Matrix y_v_d; + Eigen::Matrix X_rv_d; + std::vector y_vi_d; + std::vector y2_vi_d; + int y_s_d; + double y_r_d; + int k_td; + int n_td; + Eigen::Matrix X_d_td; + Eigen::Matrix y_v_d_td; + Eigen::Matrix X_rv_d_td; std::vector y_vi_d_td; std::vector y2_vi_d_td; int y_s_d_td; @@ -14198,7 +16200,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -14356,10 +16358,10 @@ operator()(const std::vector& y_slice, const int& start, return g(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g_functor__; -using DeepCopy__ = g_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -14423,10 +16425,10 @@ operator()(const std::vector& y_slice, const int& start, return h(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h_functor__; -using DeepCopy__ = h_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -14867,7 +16869,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -15149,10 +17151,10 @@ operator()(const std::vector& y_slice, const int& start, return g1(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g1_functor__; -using DeepCopy__ = g1_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15212,10 +17214,10 @@ operator()(const std::vector>& y_slice, return g2(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g2_functor__; -using DeepCopy__ = g2_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15275,10 +17277,10 @@ operator()(const std::vector>& y_slice, return g3(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g3_functor__; -using DeepCopy__ = g3_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15339,10 +17341,10 @@ operator()(const std::vector>& y_slice, return g4(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g4_functor__; -using DeepCopy__ = g4_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15405,10 +17407,10 @@ operator()(const std::vector>& y_slice, const int& start, return g5(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g5_functor__; -using DeepCopy__ = g5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15472,10 +17474,10 @@ operator()(const std::vector>>& y_slice, return g6(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g6_functor__; -using DeepCopy__ = g6_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15539,10 +17541,10 @@ operator()(const std::vector>>& y_slice, return g7(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g7_functor__; -using DeepCopy__ = g7_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15606,10 +17608,10 @@ operator()(const std::vector>>& y_slice, return g8(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g8_functor__; -using DeepCopy__ = g8_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15667,10 +17669,10 @@ operator()(const std::vector& y, const int& start, return h1(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h1_functor__; -using DeepCopy__ = h1_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15737,10 +17739,10 @@ operator()(const std::vector& y, const int& start, return h2(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h2_functor__; -using DeepCopy__ = h2_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15808,10 +17810,10 @@ operator()(const std::vector& y, const int& start, return h3(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h3_functor__; -using DeepCopy__ = h3_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15880,10 +17882,10 @@ operator()(const std::vector& y, const int& start, return h4(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h4_functor__; -using DeepCopy__ = h4_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -15953,10 +17955,10 @@ operator()(const std::vector& y, const int& start, return h5(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h5_functor__; -using DeepCopy__ = h5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -16028,10 +18030,10 @@ operator()(const std::vector& y, const int& start, return h6(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h6_functor__; -using DeepCopy__ = h6_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -16104,10 +18106,10 @@ operator()(const std::vector& y, const int& start, return h7(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h7_functor__; -using DeepCopy__ = h7_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -16180,10 +18182,10 @@ operator()(const std::vector& y, const int& start, return h8(y, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = h8_functor__; -using DeepCopy__ = h8_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18029,7 +20031,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -18404,10 +20406,10 @@ operator()(const std::vector& y_slice, const int& start, return f1(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f1_functor__; -using DeepCopy__ = f1_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18457,10 +20459,10 @@ operator()(const std::vector& y_slice, const int& start, return f1a(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f1a_functor__; -using DeepCopy__ = f1a_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18510,10 +20512,10 @@ operator()(const std::vector>& y_slice, return f2(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f2_functor__; -using DeepCopy__ = f2_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18563,10 +20565,10 @@ operator()(const std::vector>& y_slice, return f3(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f3_functor__; -using DeepCopy__ = f3_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18616,10 +20618,10 @@ operator()(const std::vector>& y_slice, return f4(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f4_functor__; -using DeepCopy__ = f4_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18669,10 +20671,10 @@ operator()(const std::vector>& y_slice, const int& start, return f5(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f5_functor__; -using DeepCopy__ = f5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18722,10 +20724,10 @@ operator()(const std::vector>>& y_slice, return f6(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f6_functor__; -using DeepCopy__ = f6_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18775,10 +20777,10 @@ operator()(const std::vector>>& y_slice, return f7(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f7_functor__; -using DeepCopy__ = f7_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18828,10 +20830,10 @@ operator()(const std::vector>>& y_slice, return f8(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f8_functor__; -using DeepCopy__ = f8_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18878,10 +20880,10 @@ operator()(const std::vector& y_slice, const int& start, return f9(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f9_functor__; -using DeepCopy__ = f9_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18927,10 +20929,10 @@ operator()(const std::vector>& y_slice, const int& start, return f10(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f10_functor__; -using DeepCopy__ = f10_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -18976,10 +20978,10 @@ operator()(const std::vector>>& y_slice, return f11(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f11_functor__; -using DeepCopy__ = f11_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19028,10 +21030,10 @@ operator()(const std::vector>>& y_slice, return f12(y_slice, start, end, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = f12_functor__; -using DeepCopy__ = f12_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19085,10 +21087,10 @@ operator()(const std::vector& y_slice, const int& start, return g1(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g1_functor__; -using DeepCopy__ = g1_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19145,10 +21147,10 @@ operator()(const std::vector& y_slice, const int& start, return g2(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g2_functor__; -using DeepCopy__ = g2_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19206,10 +21208,10 @@ operator()(const std::vector& y_slice, const int& start, return g3(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g3_functor__; -using DeepCopy__ = g3_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19267,10 +21269,10 @@ operator()(const std::vector& y_slice, const int& start, return g4(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g4_functor__; -using DeepCopy__ = g4_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19328,10 +21330,10 @@ operator()(const std::vector& y_slice, const int& start, return g5(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g5_functor__; -using DeepCopy__ = g5_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19389,10 +21391,10 @@ operator()(const std::vector& y_slice, const int& start, return g6(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g6_functor__; -using DeepCopy__ = g6_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19450,10 +21452,10 @@ operator()(const std::vector& y_slice, const int& start, return g7(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g7_functor__; -using DeepCopy__ = g7_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19511,10 +21513,10 @@ operator()(const std::vector& y_slice, const int& start, return g8(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g8_functor__; -using DeepCopy__ = g8_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19572,10 +21574,10 @@ operator()(const std::vector& y_slice, const int& start, return g9(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g9_functor__; -using DeepCopy__ = g9_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19635,10 +21637,10 @@ operator()(const std::vector& y_slice, const int& start, return g10(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g10_functor__; -using DeepCopy__ = g10_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19698,10 +21700,10 @@ operator()(const std::vector& y_slice, const int& start, return g11(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g11_functor__; -using DeepCopy__ = g11_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19761,10 +21763,10 @@ operator()(const std::vector& y_slice, const int& start, return g12(y_slice, start, end, a, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = g12_functor__; -using DeepCopy__ = g12_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -19890,10 +21892,10 @@ return s(y_slice, start, end, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, pstream__); } void set_zero_adjoints() const { } -void save_varis(vari**) const { } void accumulate_adjoints(double*) const { } +void save_varis(vari**) const { } using ValueOf__ = s_functor__; -using DeepCopy__ = s_functor__; +using DeepCopy__ = ValueOf__; using captured_scalar_t__ = double;}; @@ -22719,7 +24721,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -23117,7 +25119,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template @@ -23610,7 +25612,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template diff --git a/test/integration/good/compiler-optimizations/cpp.expected b/test/integration/good/compiler-optimizations/cpp.expected index 0f0e5f4301..475b1fe14d 100644 --- a/test/integration/good/compiler-optimizations/cpp.expected +++ b/test/integration/good/compiler-optimizations/cpp.expected @@ -8,7 +8,7 @@ void FnZeroAdjoint__(double) { } void FnZeroAdjoint__(stan::math::var x) { x->set_zero_adjoint(); } double FnGetAdjoint__(double) { return 0.0; } double FnGetAdjoint__(stan::math::var x) { return x.adj(); } -stan::math::vari* FnGetVariPtr__(double) { return nullptr; } +stan::math::vari* FnGetVariPtr__(double) { throw new std::runtime_error("value is not autodiffable"); } stan::math::vari* FnGetVariPtr__(stan::math::var x) { return x.vi_; } template diff --git a/test/integration/good/parser-generator/pretty.expected b/test/integration/good/parser-generator/pretty.expected index 3f3ee0f157..07230b4e89 100644 --- a/test/integration/good/parser-generator/pretty.expected +++ b/test/integration/good/parser-generator/pretty.expected @@ -367,24 +367,6 @@ generated quantities { } } - -Semantic error in 'ode_control.stan', line 30, column 10 to line 31, column 47: - ------------------------------------------------- - 28: y_hat = integrate_ode_rk45(sho, y0, t0, ts, theta, x, x_int, - 29: 1e-10, 1e-10, 1e6); - 30: y_hat = integrate_ode_bdf(sho, y0, t0, ts, theta, x, x_int, - ^ - 31: 1e-10, 1e-10, 1e6); - 32: y_hat = integrate_ode_adams(sho, y0, t0, ts, theta, x, x_int, - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[], real, real, real. - $ ../../../../../install/default/bin/stanc --auto-format prim_var_data_block.stan data { int p1; diff --git a/test/integration/good/pretty.expected b/test/integration/good/pretty.expected index 1832c50102..58b45e23ee 100644 --- a/test/integration/good/pretty.expected +++ b/test/integration/good/pretty.expected @@ -3702,24 +3702,6 @@ generated quantities { 1e-10, 1e8); } - -Semantic error in 'integrate_ode_bdf.stan', line 28, column 10 to column 65: - ------------------------------------------------- - 26: model { - 27: real y_hat[T,2]; - 28: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int); - ^ - 29: y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int); - 30: y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int); - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. - $ ../../../../install/default/bin/stanc --auto-format integrate_ode_deprecation.stan functions { real[] sho(real t, real[] y, real[] theta, real[] x, int[] x_int) { @@ -4392,24 +4374,6 @@ model { y[t] ~ normal(y_hat[t], sigma); } - -Semantic error in 'ode_good.stan', line 41, column 10 to line 47, column 35: - ------------------------------------------------- - 39: x, // data - 40: x_int); // integer data - 41: y_hat = integrate_ode_bdf(harm_osc_ode, // system - ^ - 42: y0, // initial state - 43: t0, // initial time - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. - $ ../../../../install/default/bin/stanc --auto-format old-log-funs.stan transformed data { real x; diff --git a/test/integration/good/stat_comp_benchmarks_models/pretty.expected b/test/integration/good/stat_comp_benchmarks_models/pretty.expected index 2a27f00fca..6ddb5f3bd6 100644 --- a/test/integration/good/stat_comp_benchmarks_models/pretty.expected +++ b/test/integration/good/stat_comp_benchmarks_models/pretty.expected @@ -326,24 +326,6 @@ generated quantities { C_ppc[n] = lognormal_rng(log(C[n, 1]), sigma); } - -Semantic error in 'one_comp_mm_elim_abs.stan', line 55, column 8 to column 79: - ------------------------------------------------- - 53: { - 54: real theta[3] = {k_a, K_m, V_m}; - 55: C = integrate_ode_bdf(one_comp_mm_elim_abs, C0, t0, times, theta, x_r, x_i); - ^ - 56: } - 57: } - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. - $ ../../../../../install/default/bin/stanc --auto-format sim_one_comp_mm_elim_abs.stan functions { real[] one_comp_mm_elim_abs(real t, real[] y, real[] theta, real[] x_r, @@ -392,24 +374,6 @@ generated quantities { C_hat[n] = lognormal_rng(log(C[n, 1]), sigma); } - -Semantic error in 'sim_one_comp_mm_elim_abs.stan', line 58, column 6 to column 77: - ------------------------------------------------- - 56: ts[n] = times[n]; - 57: - 58: C = integrate_ode_bdf(one_comp_mm_elim_abs, C0, t0, times, theta, x_r, x_i); - ^ - 59: - 60: for (n in 1:N_t) - ------------------------------------------------- - -Ill-typed arguments supplied to function 'integrate_ode_bdf'. Available signatures: -((real, vector) => vector, vector, real, real[]) => vector[] -((real, vector) => vector, vector, real, real[], data real, data real, data real) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[]) => vector[] -((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], data real[], data int[], data real, data real, data real) => vector[] -Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[]. - $ ../../../../../install/default/bin/stanc --auto-format sir.stan functions { real[] simple_SIR(real t, real[] y, real[] theta, real[] x_r, int[] x_i) { diff --git a/test/integration/signatures/stan_math_sigs.expected b/test/integration/signatures/stan_math_sigs.expected index e860ea0b51..1196889955 100644 --- a/test/integration/signatures/stan_math_sigs.expected +++ b/test/integration/signatures/stan_math_sigs.expected @@ -7733,6 +7733,11 @@ vector[] integrate_ode_bdf((real, vector, real[], data real[], data int[]) => ve vector[] integrate_ode_bdf((real, vector, real[], data real[], data int[]) => vector, vector, real, real[], real[], real[], int[], real, real, real) +real[,] integrate_ode_bdf((real, real[], real[], data real[], data int[]) => real[], + real[], real, real[], real[], real[], int[]) +real[,] integrate_ode_bdf((real, real[], real[], data real[], data int[]) => real[], + real[], real, real[], real[], real[], int[], + real, real, real) real[,] integrate_ode_rk45((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], real[], int[]) real[,] integrate_ode_rk45((real, real[], real[], data real[], data int[]) => real[],