package osdp
Module Osdp.MonomialSource
Monomials of multiple variables (e.g., x^2 y z^3).
Type of monomials.
Conversion functions.
of_list l produces the monomial corresponding to list l. For instance, considering the variables x0, x1, x2 and x3, of_list[3; 4; 0; 1] gives the monomial x0^3 x x1^4 x x3. All elements of the list must be non negative.
The returned list contains only non negative values and its last element is non zero (or the list is empty).
A few values.
var ?d i returns xi^d, this is equivalent to of_list [0;...; O; d] with i zeros. d is 1 by default. i and d must be non negative. var ~d:0 i is equivalent to one.
Arithmetic operations.
mult m1 m2 multiplies the two monomials m1 and m2. If one of them is defined on less variables, the undefined exponents are considered as 0 (for instance mult (of_list [1; 2]) (of_list [3; 4; 5]) returns m such that to_list m = [4; 6; 5]).
lcm m1 m2 returns the Least Common Multiple of m1 and m2 (i.e., the maximum of degrees for each variable).
gcd m1 m2 returns the Greatest Common Divisor of m1 and m2 (i.e., the minimum of degrees for each variable).
divide m1 m2 returns true iff m1 divides m2 (i.e., when lcm m1 m2 = m2 or equivalently gcd m1 m2 = m1). This can be seen as a pointwise less or equal on degrees.
derive m i returns j_i, x_0^{j_0} ... x_i^{j_i - 1} ... x_n^{j_n}) if the degree j_i of variable i is positive in the monomial m and 0, one otherwise. i must be non negative.
Various functions.
nb_vars m returns the largest index (starting from 0) of a variable appearing in m plus one (0 if none). For instance, nb_var m returns 4 if m is the monomial x_0 x_3^2 (even if variables x_1 and x_2 don't actually appear in m)
is_var m returns Some (d, i) if m is the monomial xi^d and None otherwise.
Sets of monomials.
list_eq n d provides the list of all monomials with n variables of degree equal d (for instance, list_eq 3 2 can return [x0^2; x0 x1; x0 x2; x1^2; x1 x2; x2^2]). n and d must be non negative.
list_le n d provides the list of all monomials with n variables of degree less or equal d (for instance, list_le 3 2 can return [1; x0; x1; x2; x0^2; x0 x1; x0 x2; x1^2; x1 x2; x2^2]). n and d must be non negative.
Printing.
Pretty printing. Variables will be printed as x0, x1,...
Pretty printing. If names is to short, variables will be printed as x0, x1,... Providing a too short names list is not advisable however, as the generated names may collide with the provided ones.