package fadbadml

  1. Overview
  2. Docs

Extends TTypeName with comparison operators.

  • parameter T

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

Parameters

module T : sig ... end

Signature

type t
type elt = T.elt

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

type scalar = T.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
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 +=
  1. | CONST
  2. | SCALE of scalar
  3. | TRANS of scalar
  4. | SIN of T.t array
  5. | COS of T.t array
  6. | ADD
  7. | SUB
  8. | MUL
  9. | DIV
  10. | POW
  11. | POS
  12. | NEG
  13. | INV
  14. | SQR
  15. | SQRT
  16. | EXP
  17. | LOG
  18. | TAN
  19. | ASIN
  20. | ACOS
  21. | ATAN
val string_of_op : op -> string

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

val operator : t -> op

operator f retrieves the operator represented by f

val order : t -> int

Current number of coefficients that have been computed

Constructors

val un_op : op -> t -> t

un_op op f builds a node that represents the expression op(f) where op is a unary operator. This is useful to write custom operators

val bin_op : op -> t -> t -> t

bin_op op f1 f2 builds a node that represents the expression op(f1,f2) where op is a binary operator. This is useful to write custom operators

Automatic Taylor Expansion

val set : t -> int -> T.t -> unit

set f i v sets the i-th coefficient of f to v, this is used to set the direction of the expansion. For example, to expand wrt. a variable x, one would call set x 1 1.. This can also be used to change the value of a variable: eg. set x 0 5..

val d : t -> int -> elt

d f i retrieves the coefficient of order i in computation f as an elt. Must be called after eval.

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

deriv f i retrieves the coefficient of order i in computation f. Must be called after eval.

val get_tvalues : t -> elt array

get_tvalues f retrieves the array of taylor coefficients of f. Must be called after eval.

val get_derivatives : t -> elt array

get_derivatives f retrieves the array of derivatives of f. Must be called after eval.

val eval : t -> int -> int

eval f i propagates the first i taylor coefficients of f. The direction of the expansion should have been set using set.

val reset : t -> unit

reset f resets all the arrays of coefficients. It is used to compute a new expansion on the same expression without building a new graph.

OCaml

Innovation. Community. Security.