package osdp
Module Polynomial.FloatSource
Type of coefficients.
Type of polynomials.
Conversion functions.
of_list [(m_1, a_1);..; (m_n, a_n)] builds the polynomial a_1 m_1 + ... + a_n m_n. Duplicates or zeros coefficients are accepted (for instance 2 x_0 + 0 x_1 + 3 x_0 is a valid input for 5 x_0).
Returns a list sorted in increasing order of Monomial.compare without duplicates nor zeros.
A few values.
var ?c ?d i returns c xi^d, this is equivalent to of_list [c, Monomial.var ~d i]. c is Coeff.one and d is 1 by default. i and d must be non negative.
monomial m is equivalent to of_list [m, Coeff.one].
Arithmetic operations.
compose p [q_1;...; q_n] returns the polynomial p' such that p'(x_1,..., x_m) = p(q_1(x_1,..., x_m),..., q_n(x_1,..., x_m)).
derive p i returns the derivative of the polynomial p with respect to variable i (indices starting from 0). i must be non negative.
Various functions.
nb_vars p returns the largest index (starting from 0) of a variable appearing in p plus one (0 if none). For instance, nb_var p returns 5 if p is the polynomial x_2^2 + x_4 (even if variables x_0, x_1 and x_3 don't actually appear in p)
degree_list p returns a list of length nb_vars p with the maximal degree for each variable in p.
is_var p returns Some (c, d, i) if p is a polynomial of the form c xi^d and None otherwise.
is_const p returns Some c if p is the constant polynomial c and None otherwise.
is_monomial p returns Some m if p is a monmial x_0^i_0 ... x_n^i_n and None otherwise.
Prefix and infix operators.
To use this operators, it's convenient to use local opens. For instance to write the polynomial 2.3 x0^3 x2^2 + x1 + 0.5:
let module P = Osdp.Polynomial.Float in
P.(2.3 *. ??0**3 * ??2**2 + ??1 + !0.5)Printing.
See Monomial.pp for details about names.