Module Math


module Math: sig  end
Aritmetics and Mathematical operators.
See : int
See : bint
See : float
See : the Scalar chapter in the documentation

 'acellof : int -> acell
Conversion into an acell. If the argument is an int, the result is the acell whose uid is equal to the int.
 'acellof : int -> acell
Conversion into an acell.
See : 'acellof
 'max_int : int
The greatest representable integer.
 'min_int : int
The smallest representable integer.
 'zero_bint : bint
The big integer 0.
 'unit_bint : bint
The big integer 1.
 '+ : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> int

float -> float -> float

int -> float -> float

float -> int -> float

any -> string -> string

string -> any -> string

record -> record -> record

posgbf -> posgbf -> posgbf

Numerical sum, record merging and string concatenation.

The operator + is highly overloaded:


 'add : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> int

float -> float -> float

int -> float -> float

float -> int -> float

any -> string -> string

string -> any -> string

record -> record -> record

posgbf -> posgbf -> posgbf

Prefix form of operator +
See : +

 '- : posgbf -> posgbf -> posgbf
bint -> float -> float

float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

float -> int -> float

int -> float -> float

float -> float -> float

int -> int -> int

Computes the substraction of its arguments. In the substraction between:

Between GBF elements |x> - |y> computes |x> + (-1*|y>).
 'sub : posgbf -> posgbf -> posgbf
bint -> float -> float

float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

float -> int -> float

int -> float -> float

float -> float -> float

int -> int -> int

Prefix form of operator -
See : -

 '* : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> int

float -> float -> float

float -> int -> float

int -> float -> float

posgbf -> int -> posgbf

int -> posgbf -> posgbf

Computes the multiplication of its arguments. In the multiplication between:

The multiplication of a GBF element by an integer n computes the n-fold sum, i.e.: n*|x> computes |x> + |x> + ... + |x> (the sum has n terms). If n is negative, i.e. n=-m where m is positive, then n*|x> = -1*(m*|x>). And -1*|x> equal <x| the inverse of the element |x>.

 'mult : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> int

float -> float -> float

float -> int -> float

int -> float -> float

posgbf -> int -> posgbf

int -> posgbf -> posgbf

Prefix form of operator *
See : *

 '/ : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> float -> float

float -> int -> float

float -> float -> float

int -> int -> int

Computes the division of the first argument by the second. In the division between:


 'div : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> float -> float

float -> int -> float

float -> float -> float

int -> int -> int

Prefix form of operator /
See : /

 '** : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> float

float -> float -> float

float -> int -> float

int -> float -> float

Computes the exponentiation of its first argument to the second argument.

 'pow : bint -> float -> float
float -> bint -> float

bint -> int -> bint

int -> bint -> bint

bint -> bint -> bint

int -> int -> float

float -> float -> float

float -> int -> float

int -> float -> float

Computes the exponentiation of its first argument to the second argument.

 '== : any -> any -> bool
The equality predicate. To be equal, the two arguments must have the same type. Provided that the two arguments have the same type, then
 'equal : any -> any -> bool
Prefix form of operator ==
See : ==
 '!= : any -> any -> bool
The not-equal predicate. x != y evaluates to not(x == y). This operator can also be written as <>, ~= and =!=.
 'notequal : any -> any -> bool
Prefix form of operator !=. Other infix forms are <>, ~= and =!=.
See : !=
 '=== : any -> any -> bool
any -> any -> undef

The physical equality predicate. To be physically equal, the arguments must have the same representation (but not necessarilly at the same memory adresse). For example:

  let s1 = iota(10, set:()) 
  and s2 = (iota(5, set:()), (9, set:())), (5,  6, 7, 8, 9, set:()) 
  in (s1 == s2), (s1 === s2), ("abc" === "a"+"b"+"c")
returns (true, false, true):'seq: the set s1 and s2 are equal (they have the same elements) but do not have the same physical representation and the the value computed by expression "a"+"b"+"c" has the same representation as the string "abc".

Beware that the physical comparaison of two funct generally fails and returns an undef value. For instance: (\x.x) === (\y.y) returns true but (\x.x+1) === (\y.1+y) returns <undef: funct comparaison 'equal: functional value'>.

 'pequal : any -> any -> bool
Prefix form of operator ===.
See : ===
 '!=== : any -> any -> bool
The negation of the === operator: x !=== y is the same as not(x === y).
See : ===
 'notpequal : any -> any -> bool
Prefix form of operator !===.
See : !===
 'compare : any -> any -> int
The generic comparison.

This functions coincides with the usual ordering over integers, characters, strings and floating-point numbers, and extend them to a total ordering over all types except funct.

compare(x, y) returns 0 if x == y, a negative integer if x<y, and a positive integer if x>y. The same restrictions as for == apply: i.e., the comparison of two funct is meaningless:

let a = \x.x and b = \y.y*y in compare(a, b), compare(b, a)
returns (1, 1):'seq.
 '< : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Less than predicate. Numerical comparaison between integers, big integers and floats. Lexicographic comparison between strings.

 'lt : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Prefix form of operator <.
See : <

 '<= : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Less or equal predicate. Numerical comparaison between integers, big integers and floats. Lexicographic comparison between strings.

 'leq : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Prefix form of operator <=.
See : <=

 '> : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Greather than predicate. Numerical comparaison between integers, big integers and floats. Lexicographic comparison between strings.

 'gt : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Prefix form of operator >.
See : >

 '>= : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Greather or equal predicate. Numerical comparaison between integers, big integers and floats. Lexicographic comparison between strings.

 'geq : bint -> float -> bool
float -> bint -> bool

bint -> int -> bool

int -> bint -> bool

bint -> bint -> bool

int -> int -> bool

float -> float -> bool

float -> int -> bool

int -> float -> bool

string -> string -> bool

Prefix form of operator >=.
See : >=

 'power : bint -> bint -> bint
int -> bint -> bint

bint -> int -> bint

bint -> float -> float

float -> bint -> float

int -> int -> int

float -> float -> float

int -> float -> float

float -> int -> float

Exponentiation.

 'atan2 : int -> bint -> float
bint -> int -> float

bint -> bint -> float

bint -> float -> float

float -> bint -> float

int -> int -> float

float -> float -> float

int -> float -> float

float -> int -> float

The atan2 function calculates the arc tangent of the two arguments x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result. This function returns the result in radians, which is between -Pi and PI (inclusive).

 'mod : bint -> int -> bint
int -> bint -> bint

bint -> bint -> bint

bint -> float -> float

float -> bint -> float

int -> int -> int

float -> float -> float

int -> float -> float

float -> int -> float

Integer and float remainder.


 'max : bint -> int -> bint
int -> bint -> bint

bint -> bint -> bint

float -> bint -> float

bint -> float -> float

int -> int -> int

float -> float -> float

float -> int -> float

int -> float -> float

string -> string -> string

any -> any -> any

max(a,b) returns a if compare(a, b) > 0.

Gives the usual meaning when the arguments are numerical or strings.

 'min : bint -> int -> bint
int -> bint -> bint

bint -> bint -> bint

float -> bint -> float

bint -> float -> float

int -> int -> int

float -> float -> float

float -> int -> float

int -> float -> float

string -> string -> string

any -> any -> any

min(a,b) returns a if compare(a, b) < 0.

Gives the usual meaning when the arguments are numerical or strings.

 'exp : bint -> float
int -> float

float -> float

Exponential.

 'acos : bint -> float
int -> float

float -> float

The acos trigonometric function. acos(x) calculates the arc cosine of x; that is the value whose cosine is x. If x falls outside the range -1 to 1, acos return nan.

 'asin : bint -> float
int -> float

float -> float

The asin trigonometric function. asin(x) calculates the arc sine of x; that is the value whose sine is x. If x falls outside the range -1 to 1, acos return nan.

 'atan : bint -> float
int -> float

float -> float

The atan trigonometric function. atan(x) calculates the arc tangent of x; that is the value whose tangent is x.

 'cos : bint -> float
int -> float

float -> float

The cos trigonometric function. cos(x) calculates the cosine of x, where x is given in radians.

 'sin : bint -> float
int -> float

float -> float

The sin trigonometric function. sin(x) calculates the sine of x, where x is given in radians.

 'tan : bint -> float
int -> float

float -> float

The tan trigonometric function. tan(x) calculates the tangent of x, where x is given in radians.

 'cosh : bint -> float
int -> float

float -> float

The cosh hyperbolic function. cosh(x) calculates the hyperbolic cosine of x, which is defined mathematically as (exp(x) + exp(-x)) / 2.

 'sinh : bint -> float
int -> float

float -> float

The sinh hyperbolic function. sinh(x) calculates the hyperbolic sine of x, which is defined mathematically as (exp(x) - exp(-x)) / 2.

 'tanh : bint -> float
int -> float

float -> float

The tanh hyperbolic function. tanh(x) calculates the hyperbolic tangent of x, which is defined mathematically as sinh(x) / cosh(x).

 'log : bint -> float
int -> float

float -> float

The natural logarithm. log(0) return -inf and the log of a negative argument returns nan.

 'log10 : bint -> float
int -> float

float -> float

The base-10 logarithm. log10(0) return -inf and the log10 of a negative argument returns nan.

 'sqrt : bint -> float
int -> float

float -> float

The non-negative square root. Returns nan if its argument is strictly negative.

 'ceil : float -> int
Round the given float to an integer value. ceil f returns the least integer value greater than or equal to f. floor f returns the greatest integer value less than or equal to f.
 'floor : float -> int
Round the given float to an integer value. floor f returns the greatest integer value less than or equal to f. ceil f returns the least integer value greater than or equal to f.
 'abs : float -> float
bint -> bint

int -> int

Return the absolute value of the argument.

 'intof : float -> int
string -> int

bint -> int

int -> int

Conversion into an integer.

If the argument is a float, the given floating-point number is truncated into an integer. The result is unspecified if it falls outside the range of representable integers.

If the argument is a bint that is not representable by a standard integer, the result of the conversion is VAL_undef("Scalar: _intof_bint: too big to be cast as an int").

If the argument is a string, the function converts the given string to an integer. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively. Returns <undef: int_of_string failed> if the given string is not a valid representation of an integer.

If the argument is a int, this integer is the returned value.

 'int_of : float -> int
string -> int

bint -> int

int -> int

Conversion into an integer.
See : intof

 'bintof : float -> bint
string -> bint

bint -> bint

int -> bint

Conversion into a big integer.

If the argument is a float, the given floating-point number is truncated into an integer.

If the argument is a bint, this big integer is the returned value.

If the argument is a string, the function converts the given string to a big integer. The string is read in decimal.

 'bint_of : float -> bint
string -> bint

bint -> bint

int -> bint

Conversion into a big integer.
See : bintof

 'floatof : float -> float
string -> float

bint -> float

int -> float

Conversion into a float.

If the argument is an int, it is converted into a float.

If the argument is an bint, it is converted into a float.

If the argument is a string, the function converts the given string to a float. Returns <undef: float_of_string failed> if the given string is not a valid representation of a float.

If the argument is a float, this float is the returned value.

 'float_of : float -> float
string -> float

bint -> float

int -> float

Conversion into a float.
See : floatof

 'what_float : float -> int
Classify IEEE-754 float numbers.

The returned integer is:


 'succ : float -> float
bint -> bint

int -> int

The (numeric) successor function. succ(x) == x+1

 'nCp : bint -> bint -> bint
int -> bint -> bint

bint -> int -> bint

int -> int -> bint

Binomial coefficient and number of different combinations.

nCp(n,p) returns the binomial coefficient "n choose p" or the number of p-combinations of a set with n elements. The result is always a bint.

 'nAp : bint -> bint -> bint
int -> bint -> bint

bint -> int -> bint

int -> int -> bint

Number of different permutations.

nAp(n,p) returns the number of different permutations of p objects, taken from a pool of n objects. The result is always a bint.

 'infinity : float
ieee positive infinite value.
 'neg_infinity : float
ieee negative infinite value
 'nan : float
ieee not a number value.
 'max_float : float
The largest positive finite value of type float.
 'min_float : float
The smallest positive, non-zero, non-denormalized value of type float.
 'epsilon_float : float
The smallest positive float x such that 1.0 +. x <> 1.0.
 'E : float
The float constant e.
 'LOG2E : float
The float constant log2(e) (the logarithm is taken in base 2).
 'LOG10E : float
The float constant log10(e) (the logarithm is taken in base 10).
 'LN2 : float
The float constant loge(2) (the logarithm is taken in base e).
 'LN10 : float
The float constant loge(10) (the logarithm is taken in base e).
 'PI : float
The float constant pi.
 'PI_2 : float
The float constant pi/2.
 'PI_4 : float
The float constant pi/4.
 '1_PI : float
The float constant 1/pi.
 '2_PI : float
The float constant 2/pi.
 '2_SQRT_PI : float
The float constant 2/sqrt(pi).
 'SQRT2 : float
The float constant sqrt(2).
 'SQRT1_2 : float
The float constant 1/sqrt(2).
 'random : int -> int
float -> float

string -> string

bool -> bool

monoidal -> any

returns a random value.

If n is an integer, random(n) returns a random integer between 0 (inclusive) and n (exclusive). n must be more than 0 and less than 230.

If f is an float, random(f) returns a random floating-point number between 0 (inclusive) and f (exclusive). If f is negative, the result is negative. If f is 0, the result is 0.

If s is a string, random(s) returns a random string made with the letters of s. The length of the returned string is between 0 and the value of the system variable lrandom_string (default 11).

If b is a boolean, random(b) returns a random boolean.

If c is a collection, random(c) returns a randomly choosen element in the collection.

 'qrngmake : string -> int
returns a handle (of type int) for producing quasi-random values.

The first argument may be equal to NIEDERREITER2 or to SOBOL. The second argument is the dimension of the generated quasi-random values.


 'qrnginit : int
initializes the generator of quasi-random values.
 'qrngget : int
returns a sequence of quasi-random floating values using always the same storage array.
 'qrngsample : int
returns a sequence of quasi-random floating values using each time a new storage array.
 'qrngname : string
returns the name of the generator used.
 'qrngdimension : int
returns the dimension of the space that is filled by the quasi-random generator.