Module Middle.Stan_math_signatures

This module stores a table of all signatures from the Stan math C++ library which are exposed to Stan, and some helper functions for dealing with those signatures.

Function arguments are represented by their type an autodiff type. This is AutoDiffable for everything except arguments marked with the data keyword

type signature = UnsizedType.returntype * fun_arg list * Mem_pattern.t

Signatures consist of a return type, a list of arguments, and a flag for whether or not those arguments can be Struct of Arrays objects

val stan_math_signatures : (string, signature list) Core.Hashtbl.t

Mapping from names to signature(s) of functions

val is_stan_math_function_name : string -> bool

Equivalent to Hashtbl.mem stan_math_signatures s

type variadic_signature = {
  1. return_type : UnsizedType.t;
  2. control_args : fun_arg list;
  3. required_fn_rt : UnsizedType.t;
  4. required_fn_args : fun_arg list;
}
val stan_math_variadic_signatures : (string, variadic_signature) Core.Hashtbl.t

Mapping from names to description of a variadic function.

Note that these function names cannot be overloaded, and usually require customized code-gen in the backend.

val is_stan_math_variadic_function_name : string -> bool

Equivalent to Hashtbl.mem stan_math_variadic_signatures s

Pretty printers

val pp_math_sig : signature Fmt.t
val pretty_print_all_math_sigs : unit Fmt.t
val pretty_print_all_math_distributions : unit Fmt.t
type dimensionality
type return_behavior
type fkind = private
  1. | Lpmf
  2. | Lpdf
  3. | Rng
  4. | Cdf
  5. | Ccdf
  6. | UnaryVectorized of return_behavior
val pp_fkind : Ppx_deriving_runtime.Format.formatter -> fkind -> Ppx_deriving_runtime.unit
val show_fkind : fkind -> Ppx_deriving_runtime.string
val distributions : (fkind list * string * dimensionality list * Mem_pattern.t) list

The distribution families exposed by the math library

val dist_name_suffix : (string * 'a) list -> string -> string

Helpers for dealing with operators as signatures

val operator_to_stan_math_fns : Operator.t -> string list
val string_operator_to_stan_math_fns : string -> string
val pretty_print_math_lib_operator_sigs : Operator.t -> string list
val make_assignmentoperator_stan_math_signatures : Operator.t -> signature list

Special functions for the variadic signatures exposed

val is_reduce_sum_fn : string -> bool
val reduce_sum_slice_types : UnsizedType.t list