module Math: sig end
Scalar
chapter in the documentation 'acellof : int -> acell
int
, the result is the acell
whose uid is
equal to the int
. 'acellof : int -> acell
'max_int : int
'min_int : int
'zero_bint : bint
'unit_bint : bint
'+ : 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:
int -> int -> int
is the numerical addition of integers.
bint -> bint -> bint
is the numerical addition of big integers.
float -> float -> float
is the numerical addition of floats
(IEEE 754 compliant).
int -> bint -> bint
and bint -> int -> bint
computes the numerical addition of big integers
after the conversion of the integer argument into a big interger.
int -> float -> float
and float -> int -> float
computes the numerical addition of floats
after the conversion of the integer argument into a float.
bint -> float -> float
and float -> bint -> float
computes the numerical addition of floats
after the conversion of the big integer argument into a float.
string -> string -> string
is the concatenation of
strings. Similarly, any -> string -> string
andstring -> any -> string
computes the concatenation of the
string and of the string representation of the other argument. For
instance,
"pi/2 = " + ('PI/2.0)
returns the string "pi/2 = 1.570796"
. Another example: the string
corresponding to the ascii representation written on the standard
output when a value v
is displayed, can be simply computed as
""+v
.
posgbf -> posgbf -> posgbf
computes the result of the sum of the elements of the abelian group
underlying the GBF. The result is given as an element of the
isomorphic Smith normal form of the group. For example, let a GBF
G
be defined by
gbf G = <a; 33*a = 0>
then
(13*|a> + 20*|a>)
returns
G:|0>
rec -> rec -> rec
represents the asymetric merge of two records. That is, the result
combines the fields of the two record arguments. If a field f
appears in the two arguments, the value of f
in the result is the
value in the right argument. For example:
{a=1, b=true} + {b=false, c="xyz"}
evaluates to
{a=1, b=false, c="xyz"}
'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:
|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
undef
values are always equal, whatever are the associated
comments: <undef> == <undef: a comment>
returns true
.
funct
are always differents. Even if the arguments are
physically the same. For example:
let f = \x.x+1 in (f==f), (f==\y.1+y)
returns (false, false):'seq
'equal : any -> any -> bool
'!= : any -> any -> bool
x != y
evaluates to not(x == y)
.
This operator can also be written as <>
, ~=
and =!=
. 'notequal : any -> any -> bool
'=== : 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
'!=== : any -> any -> bool
'notpequal : any -> any -> bool
'compare : any -> any -> int
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.
y
is not zero, the result of x mod y
satisfies the following properties: x == (x / y) * y + x mod y
and
abs(x mod y) < abs(y)
. If y == 0
, x mod y
raises
Division_by_zero
. Notice that x mod y
is negative if x < 0
.
mod(a, b)
the returned value is a -. n *. b
, where n
is the quotient a / b
rounded towards zero to an integer. If b ==
0
then 'nan
is returned.
'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
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
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
'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
'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
'what_float : float -> int
The returned integer is:
`ieee_zero
: number is 0.0 or -0.0`ieee_subnormal
: number very close to 0.0, has reduced precision`ieee_infinity
: number is positive or negative infinity`ieee_nan
: not a number (result of an undefined operation)`ieee_normal
: normal number, none of the other case '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
'neg_infinity : float
'nan : float
'max_float : float
float
. 'min_float : float
float
. 'epsilon_float : float
x
such that 1.0 +. x <> 1.0
. 'E : float
'LOG2E : float
'LOG10E : float
'LN2 : float
'LN10 : float
'PI : float
'PI_2 : float
'PI_4 : float
'1_PI : float
'2_PI : float
'2_SQRT_PI : float
'SQRT2 : float
'SQRT1_2 : float
'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
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.
NIEDERREITER2
then the dimension can be up to 12 and the sequences of floating values
will be produced following the algorithm described in
Bratley, Fox, Niederreiter, ACM Trans. Model. Comp. Sim. 2, 195 (1992)
.SOBOL
then the dimension can be up to 40 and the sequences
of floating values will be produced following the algorithm described in
Antonov, Saleev, USSR Comput. Maths. Math. Phys. 19, 252 (1980)
. 'qrnginit : int
'qrngget : int
'qrngsample : int
'qrngname : string
'qrngdimension : int