Module Badiff.OrderedBTypeName

Extends BTypeName with comparison operators.

parameter T

module of operators over the underlying type on which we perform automatic differentiation

Parameters

Signature

include Fadbad__.Types.OrderedOpS with type elt = T.elt and type scalar = T.scalar
include Fadbad__.Types.OpS
type t
type elt

Type of values: this is the type that the user should use with make and that will be returned by get

type scalar

Type of scalars

val copy : t -> t
val deepcopy : t -> t

Constructors

val create : unit -> t
val make : elt -> t

Wrap a user-provided value

val integer : int -> t

Wrap an integer

val zero : unit -> t

Construct a fresh value corresponding to 0

val one : unit -> t

Construct a fresh value corresponding to 1

val two : unit -> t

Construct a fresh value corresponding to 2

Destructors

val get : t -> elt

Unwrap a value

val (!!) : t -> elt

Alias for get

val to_string : t -> string
val string_of_scalar : scalar -> string
val string_of_elt : elt -> string

Arithmetic operators

val (~+) : t -> t

unary plus (with copy)

val (~-) : t -> t

unary minus (with copy)

val (+) : t -> t -> t
val (+=) : t -> t -> t
val (-) : t -> t -> t
val (-=) : t -> t -> t
val (*) : t -> t -> t
val (*=) : t -> t -> t
val (/) : t -> t -> t
val (/=) : t -> t -> t
val (**) : t -> t -> t
val inv : t -> t
val sqr : t -> t
val sqrt : t -> t
val log : t -> t
val exp : t -> t
val sin : t -> t
val cos : t -> t
val tan : t -> t
val asin : t -> t
val acos : t -> t
val atan : t -> t

Scalar operators

val scale : t -> scalar -> t

Multiplication between a value and a scalar

val translate : t -> scalar -> t

Addition between a value and a scalar

Comparison operators

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
include Fadbad__.Types.Order with type t := t
type t
val (<) : t -> t -> bool
val (<=) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val min : t -> t -> t
val max : t -> t -> t

Operators

type op = ..
type op += CONST | SCALE of scalar | TRANS of scalar | ADD | SUB | MUL | DIV | POW | POS | NEG | INV | SQR | SQRT | EXP | LOG | SIN | COS | TAN | ASIN | ACOS | ATAN

Additionnal constructors

val lift : T.t -> t

Accessors

val value : t -> T.t

Same as get but returns an T.t instead of an elt

Automatic Differentiation

val diff : t -> int -> int -> unit

diff x i n assigns i as index of variable x out of n

val d : t -> int -> elt

d f i retrieves the derivative of variable of index i in computation f as an elt. Must be called after diff and compute.

val deriv : t -> int -> T.t

Same as d but returns an T.t instead of an elt

val compute : t -> unit

compute f updates the reference counter of the nodes in the sub-graph starting from f so that they are propagated at the right moment. Must be called before d or deriv.

val compute_list : t list -> unit

Same as running compute on each element of the input list.