Stan_math_backend.CppA set of data types representing the C++ we generate
type identifier = Core.stringval identifier_of_sexp : Sexplib0.Sexp.t -> identifierval sexp_of_identifier : identifier -> Sexplib0.Sexp.tval pp_identifier :
Ppx_deriving_runtime.Format.formatter ->
identifier ->
Ppx_deriving_runtime.unitval show_identifier : identifier -> Ppx_deriving_runtime.stringtype type_ = | Auto| Void| Int| Double| Complex of type_| TemplateType of identifier| StdVector of type_A std::vector. For Eigen Vectors, use Matrix with a row or column size of 1
| Array of type_ * Core.int| Tuple of type_ Core.list| TypeLiteral of identifierUsed for things like Eigen::Index
*)| NonTypeTemplateInt of Core.int| Matrix of type_ * Core.int * Core.int * Middle.Mem_pattern.t| Ref of type_| Const of type_| Pointer of type_| TypeTrait of identifier * type_ Core.liste.g. stan::promote_scalar, stan:base_type
*)C++ types
val type__of_sexp : Sexplib0.Sexp.t -> type_val sexp_of_type_ : type_ -> Sexplib0.Sexp.tval pp_type_ :
Ppx_deriving_runtime.Format.formatter ->
type_ ->
Ppx_deriving_runtime.unitval show_type_ : type_ -> Ppx_deriving_runtime.stringmodule Types : sig ... endHelpers for constructing types
val operator_of_sexp : Sexplib0.Sexp.t -> operatorval sexp_of_operator : operator -> Sexplib0.Sexp.ttype expr = | Literal of Core.stringprinted as-is
*)| Var of identifier| VarRef of identifier| Parens of expr| FunCall of identifier * type_ Core.list * expr Core.list| MethodCall of expr * identifier * type_ Core.list * expr Core.list| StaticMethodCall of type_ * identifier * type_ Core.list * expr Core.list| Constructor of type_ * expr Core.listprinted as type(expr1, expr2, ...)
| InitializerExpr of type_ * expr Core.listprinted as type{expr1, expr2, ...}
| ArrayLiteral of expr Core.list| TernaryIf of expr * expr * expr| Cast of type_ * expr| Subscript of expr * expr| Deref of expr| AllocNew of type_ * expr Core.list| OperatorNew of identifier * type_ * expr Core.list| Assign of expr * exprNB: Not all exprs are valid lvalues!
*)| StreamInsertion of expr * expr Core.listCorresponds to operator<<
| BinOp of expr * operator * expr| PMinus of expr| Increment of exprval expr_of_sexp : Sexplib0.Sexp.t -> exprval sexp_of_expr : expr -> Sexplib0.Sexp.tmodule Exprs : sig ... endSome helper values and functions
val init_of_sexp : Sexplib0.Sexp.t -> initval sexp_of_init : init -> Sexplib0.Sexp.ttype variable_defn = {static : Core.bool;constexpr : Core.bool;type_ : type_;name : identifier;init : init;}val make_variable_defn :
?static:??? ->
?constexpr:??? ->
type_:type_ ->
name:identifier ->
?init:??? ->
unit ->
variable_defnval variable_defn_of_sexp : Sexplib0.Sexp.t -> variable_defnval sexp_of_variable_defn : variable_defn -> Sexplib0.Sexp.ttype stmt = | Expression of expr| VariableDefn of variable_defn| For of variable_defn * expr * expr * stmt| ForEach of type_ * identifier * expr * stmt| While of expr * stmt| IfElse of expr * stmt * stmt Core.option| ConstexprIf of type_ * stmt| TryCatch of stmt Core.list * type_ * identifier * stmt Core.list| Block of stmt Core.list| Return of expr Core.option| Throw of expr| Break| Continue| Using of Core.string * type_ Core.option| Comment of Core.stringval stmt_of_sexp : Sexplib0.Sexp.t -> stmtval sexp_of_stmt : stmt -> Sexplib0.Sexp.tmodule Stmts : sig ... endHelpers for common statement constructs
module Decls : sig ... endDeclarations which get reused often in the generated model
type template_parameter = | Typename of Core.stringA typename, e.g. template <typename Foo>
| Bool of Core.stringA named boolean non-type template parameter
*)| Require of Core.string * Core.string Core.listA straightforward require_...<...> template.
| RequireAllCondition of Core.string * type_ Core.listA C++ type trait (e.g. is_arithmetic) and the template types which need to satisfy that. These are collated into one require_all_t<...>.
val template_parameter_of_sexp : Sexplib0.Sexp.t -> template_parameterval sexp_of_template_parameter : template_parameter -> Sexplib0.Sexp.tval cv_qualifiers_of_sexp : Sexplib0.Sexp.t -> cv_qualifiersval sexp_of_cv_qualifiers : cv_qualifiers -> Sexplib0.Sexp.ttype fun_defn = {templates_init : template_parameter Core.list Core.list * Core.bool;Double list since some functions (mainly reduce_sum functors) need two sets of templates
*)inline : Core.bool;return_type : type_;name : identifier;args : (type_ * Core.string) Core.list;cv_qualifiers : cv_qualifiers Core.list;body : stmt Core.list Core.option;}val make_fun_defn :
?templates_init:??? ->
?inline:??? ->
return_type:type_ ->
name:identifier ->
?args:??? ->
?cv_qualifiers:??? ->
?body:??? ->
unit ->
fun_defnval fun_defn_of_sexp : Sexplib0.Sexp.t -> fun_defnval sexp_of_fun_defn : fun_defn -> Sexplib0.Sexp.ttype constructor = {args : (type_ * Core.string) Core.list;init_list : (identifier * expr Core.list) Core.list;body : stmt Core.list;}val make_constructor :
?args:??? ->
?init_list:??? ->
?body:??? ->
unit ->
constructorval constructor_of_sexp : Sexplib0.Sexp.t -> constructorval sexp_of_constructor : constructor -> Sexplib0.Sexp.ttype directive = | Include of Core.string| IfNDef of Core.string * defn Core.list| MacroApply of Core.string * Core.string Core.listIncomplete list of C++ preprocessor directives
and class_defn = {class_name : identifier;final : Core.bool;public_base : type_;private_members : defn Core.list;public_members : defn Core.list;constructor : constructor;destructor_body : stmt Core.list;}The Stan model class always has a non-default constructor and destructor
and struct_defn = {param : template_parameter Core.option;struct_name : identifier;body : defn Core.list;}and defn = | FunDef of fun_defn| Class of class_defn| Struct of struct_defn| GlobalVariableDefn of variable_defn| GlobalComment of Core.string| GlobalUsing of Core.string * type_ Core.option| Namespace of identifier * defn Core.list| Preprocessor of directiveval directive_of_sexp : Sexplib0.Sexp.t -> directiveval class_defn_of_sexp : Sexplib0.Sexp.t -> class_defnval struct_defn_of_sexp : Sexplib0.Sexp.t -> struct_defnval defn_of_sexp : Sexplib0.Sexp.t -> defnval sexp_of_directive : directive -> Sexplib0.Sexp.tval sexp_of_class_defn : class_defn -> Sexplib0.Sexp.tval sexp_of_struct_defn : struct_defn -> Sexplib0.Sexp.tval sexp_of_defn : defn -> Sexplib0.Sexp.tval make_class_defn :
name:identifier ->
public_base:type_ ->
?final:??? ->
private_members:defn Core.list ->
public_members:defn Core.list ->
constructor:constructor ->
?destructor_body:??? ->
unit ->
class_defnval make_struct_defn :
param:template_parameter Core.option ->
name:identifier ->
body:defn Core.list ->
unit ->
struct_defnmodule DSL : sig ... endA set of operators and helpers to make the OCaml code look more like the resultant C++
val (!//) : Core.string -> defnShorthand for a C++ comment. This one is rather harmless, so it isn't in its own module
Much like in C++, we define a translation unit as a list of definitions
val program_of_sexp : Sexplib0.Sexp.t -> programval sexp_of_program : program -> Sexplib0.Sexp.tmodule Printing : sig ... endPretty-printing of the C++ type
module Tests : sig ... end