lmlib.polynomial.poly¶
This module provides a calculus for uni- and multivariate polynomials using the vector exponent notation from [Wildhaber2019], Chapter 6. This calculus simplifies to use polynomials in (squared error) cost functions, e.g., as localized signal models.
In the text below, return parameters of the functions are highlighted in \(\color{blue}{blue}\).
Classes¶
MPoly— Multivariate polynomials \({\tilde{\alpha}}^\mathsf{T} (x^q \otimes y^r)\), or with factorized coefficientPoly— Univariate polynomial in vector exponent notation: \(\alpha^\mathsf{T} x^q\)
Functions¶
poly_sum— \(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_sum_coef— \(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_sum_coef_Ls— \(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = (\color{blue}{\Lambda_1} \alpha + \dots + \color{blue}{\Lambda_N}\beta)^\mathsf{T} x^{\tilde{q}}\)poly_sum_expo— \(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)poly_sum_expo_Ms— \(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \dots +\color{blue}{M_N} r}\)poly_prod— \(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_prod_coef— \(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_prod_expo_Ms— \(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \color{blue}{M_2} r}\)poly_prod_expo— \(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)poly_square— \((\alpha^\mathsf{T} x^q)^2 = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_square_coef— \(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_square_expo_M— \(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{M} q}\)poly_square_expo— \(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)poly_shift— \(\alpha^\mathsf{T} (x+ \gamma)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_shift_coef— \(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_shift_coef_L— \(\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)poly_shift_expo— \(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)poly_dilation— \(\alpha^\mathsf{T} (\eta x)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^q}\)poly_dilation_coef— \(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^q\)poly_dilation_coef_L— \(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{q}\)poly_int— \(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_int_coef— \(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_int_coef_L— \(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)poly_int_expo— \(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)poly_diff— \(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)poly_diff_coef— \(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)poly_diff_coef_L— \(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)poly_diff_expo— \(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)mpoly_add— Sum of two univariate polynomials different variablesmpoly_add_coefs— Coefficients formpoly_addmpoly_add_expos— Exponents formpoly_addmpoly_multiply— Product of two univariate polynomials different variablesmpoly_prod— Product of univariate polynomials different variablesmpoly_square— Square of multivariate polynomialmpoly_square_coef_L— Coefficient manipulation matrix formpoly_square.mpoly_square_coef— Non-factorized coefficient vector formpoly_squarempoly_square_expos— Exponent vectors formpoly_squarempoly_square_expo_Ms— Exponent manipulation matrices \(M_1, M_2, \dots M_N\) for the square of an N-variate polynomial.mpoly_shift— Polynomial with variable shiftmpoly_shift_coef— Coefficient vector formpoly_shiftmpoly_shift_coef_L— Coefficient manipulation matrix formpoly_shiftmpoly_shift_expos— Exponent vector formpoly_shiftmpoly_int— Integral of a multivariate polynomial with respect to the scalar at a positionmpoly_int_coef— Coefficient vector formpoly_intmpoly_int_coef_L— Coefficient manipulation matrix formpoly_intmpoly_int_expos— Exponent vectors formpoly_intmpoly_diff— Derivative of a multivariate polynomial with respect to the variable at the given position.mpoly_diff_coef— Coefficient vector formpoly_diff.mpoly_diff_coef_L— Coefficient manipulation matrix formpoly_diff.mpoly_diff_expos— Exponent vectors formpoly_diff.mpoly_def_int— Definite integral of a multivariate polynomial with respect to the scalar at a positionmpoly_def_int_coef— Coefficient vector formpoly_def_intmpoly_def_int_coef_L— Coefficient manipulation matrix formpoly_def_intmpoly_def_int_expos— Exponent vectors formpoly_def_intmpoly_substitute— Substituting a variable of a multivariate polynomial by a constantmpoly_substitute_coef— Coefficient vector formpoly_def_intmpoly_substitute_coef_L— Coefficient manipulation matrix formpoly_def_intmpoly_substitute_expos— Exponent vectors formpoly_substitutempoly_dilate_ind— \(\alpha^{mathsf{T}}(xy)^q = (\Delta_Q\alpha)^{mathsf{T}}(x^q \otimes y^q)\)mpoly_dilate_ind_coefs— Coefficient vectros formpoly_dilatempoly_dilate_ind_coef_L— Coefficient manipulation matrix formpoly_dilatempoly_dilate_ind_expos— Exponent vectors formpoly_dilatempoly_dilate— Dilate a multivariate polynomial by a constant etampoly_dilate_coefs— Coefficient vectros formpoly_dilatempoly_dilate_coef_L— Coefficient manipulation matrix formpoly_dilatempoly_dilate_expos— Exponent vectors formpoly_dilatekron_sequence— Kroneker product of a sequence of matricesextend_basis— (DEV) Extending the basis of a uni- or multi-variate polynomial by new variablespermutation_matrix— Returns permutation matrixpermutation_matrix_square— Returns permutation matrix for square matrices A and Bcommutation_matrix— Returns commutation matrixremove_redundancy— Returns the exponent vector without redundancy and the matrix to add up the coefficients of the same exponent.mpoly_remove_redundancy— Returns the tuple of exponent vectors without redundancy andmpoly_transformation_coef_L— transformation of a uniform polynomial into the formmpoly_transformation_exposmpoly_extend_coef_L— Extends the polynomial by additional variables without changing its value.
Sum of Polynomials¶
poly_sum
¶
\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Sum of univariate polynomials Poly(alpha,q),... , Poly(beta,r), all of common variable x
Parameters:
-
polys(tuple of Poly) –(Poly(alpha,q),... , Poly(beta,r)), list of polynomials to be summed
Returns:
-
out(Poly) –Poly(alpha_tilde, q_tilde)
References
[Wildhaber2019] (Eq. 6.4)
Source code in lmlib/polynomial/poly.py
poly_sum_coef
¶
\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector \(\tilde{q}\) to sum of univariate polynomials polys, all of common variable x
Parameters:
-
polys(tuple of Poly) –(Poly(alpha,q),... , Poly(beta,r)), list of polynomials to be summed
Returns:
-
coef(ndarray) –alpha_tilde- Coefficient vector \(\tilde{\alpha}\)
Note
To get \(\tilde{q}\), see poly_sum_expo.
References
[Wildhaber2019] (Eq. 6.4)
Source code in lmlib/polynomial/poly.py
poly_sum_coef_Ls
¶
\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = (\color{blue}{\Lambda_1} \alpha + \dots + \color{blue}{\Lambda_N}\beta)^\mathsf{T} x^{\tilde{q}}\)
Exponent manipulation matrices \(\Lambda_1, ...., Lambda_N\) to sum univariate polynomials polys,
all of common variable x
Parameters:
-
expos(tuple of array_like) –(q, ..., r), list of exponent vectors of polynomials to be summed
Returns:
-
Ls(list of ndarray) –(Lambda_1, ..., Lambda_N), Coefficient manipulation matrices, see alsopoly_sum
Note
To get \(\tilde{q}\), see poly_sum_expo.
References
[Wildhaber2019] (Eq. 6.4)
Source code in lmlib/polynomial/poly.py
poly_sum_expo
¶
\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{1}\) of sum of univariate polynomials with exponent vectors expos, all of common variable x
Parameters:
-
expos(tuple of array_like) –(q, ..., r), list of exponent vectors of polynomials to be summed
Returns:
-
expo(ndarray) –q_tilde, exponent vector \(\tilde{q}\)
Note
To get \(\tilde{\alpha}\), see poly_sum_coef.
References
[Wildhaber2019] (Eq. 6.4)
Source code in lmlib/polynomial/poly.py
poly_sum_expo_Ms
¶
\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \dots +\color{blue}{M_N} r}\)
Exponent manipulation matrices \(M_1, ... , M_N\) to sum univariate polynomials with exponent vectors expos, all of common variable x
Parameters:
-
expos(tuple of array_like) –(q, ..., r), list of exponent vectors of polynomials to be summed
Returns:
-
Ms(list of ndarray) –(M_1, ..., M_N), list of exponent manipulation matrices, see alsopoly_sum.
References
[Wildhaber2019] (Eq. 6.4)
Source code in lmlib/polynomial/poly.py
Product of Polynomials¶
poly_prod
¶
\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Product of two univariate polynomials of common variable x
Parameters:
-
polys(tuple of Poly) –(poly_1, poly_2), two polynomials to be multiplied
Returns:
-
out(Poly) –poly_tilde, product as polynomial \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.14)
Source code in lmlib/polynomial/poly.py
poly_prod_coef
¶
\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector \(\tilde{\alpha}\) of product of two univariate polynomials of common variable x
Parameters:
-
polys(tuple of Poly) –(poly_1, poly_2), two polynomials to be multiplied
Returns:
-
coef [`ndarray`][numpy.ndarray]–alpha_tilde, coefficient vector \(\tilde{\alpha}\) of product polynomial \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\), seepoly_prod
References
[Wildhaber2019] (Eq. 6.12)
Source code in lmlib/polynomial/poly.py
poly_prod_expo_Ms
¶
\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \color{blue}{M_2} r}\)
Exponent manipulation matrices \(M_1, M_2\) of product of two univariate polynomials of common variable x
Parameters:
-
expos(tuple of array_like) –(q, r), exponent vectors
Returns:
-
Ms(list of ndarray) –(M_1, ..., M_N), list of exponent manipulation matrices for the two polynomial exponent vectors, i.e., the new exponent vector results from \(\tilde{q} = M_1 q + M_2 r\). Seepoly_prod.
References
[Wildhaber2019] (Eq. 6.16)
Source code in lmlib/polynomial/poly.py
poly_prod_expo
¶
\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{q}\) of product of two univariate polynomials of common variable x
Parameters:
-
expos(tuple of arraylike) –(q, r), exponent vectors of the two polynomials
Returns:
-
coef [`ndarray`][numpy.ndarray]–q_tilde, exponent vector \(\tilde{q}\) of product polynomial \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\), seepoly_prod
References
[Wildhaber2019] (Eq. 6.16)
Source code in lmlib/polynomial/poly.py
Square of Polynomials¶
poly_square
¶
\((\alpha^\mathsf{T} x^q)^2 = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Square of a univariate polynomial
Parameters:
-
poly(Poly) –poly, polynomial to be squared
Returns:
-
out(Poly) –squared polynomial
References
[Wildhaber2019] (Eq. 6.11)
Source code in lmlib/polynomial/poly.py
poly_square_coef
¶
\(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector \(\tilde{\alpha}\) of squared polynomial, see poly_square
Parameters:
-
poly(Poly) –poly, polynomial to be squared
Returns:
-
coef [`ndarray`][numpy.ndarray],–alpha_tildeCoefficient vector \(\tilde{\alpha}\)
References
[Wildhaber2019] (Eq. 6.12)
Source code in lmlib/polynomial/poly.py
poly_square_expo_M
¶
\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{M} q}\)
Exponent manipulation matrix \(M\) of squared polynomial, see poly_square
Parameters:
-
expo((array_like,)) –q, exponent vector \(q\)
Returns:
-
M((ndarray,)) –M, exponent manipulation matrix \(M\)
References
[Wildhaber2019] (Eq. 6.10, Eq. 6.13)
Source code in lmlib/polynomial/poly.py
poly_square_expo
¶
\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{q}\) of squared polynomial, see poly_square.
Parameters:
-
expo((array_like,)) –q, exponent vector \(q\)
Returns:
-
out [`ndarray`][numpy.ndarray],–q_tilde, exponent vector \(\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.12)
Source code in lmlib/polynomial/poly.py
Shift of Polynomials¶
poly_shift
¶
\(\alpha^\mathsf{T} (x+ \gamma)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Shifting an univariate polynomial by constant value \(\gamma \in \mathbb{R}\)
Parameters:
Returns:
-
out(Poly) –shifted polynomial, \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.28)
Source code in lmlib/polynomial/poly.py
poly_shift_coef
¶
\(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector of shifted polynomial, see poly_shift
Parameters:
Returns:
-
coef(ndarray) –alpha_tildeCoefficient vector \(\tilde{\alpha}\)
References
[Wildhaber2019] (Eq. 6.29)
Source code in lmlib/polynomial/poly.py
poly_shift_coef_L
¶
\(\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)
Coefficient manipulation \(\Lambda\) for shifted polynomial, see poly_shift
Parameters:
-
expo(array_like) –q, Exponent vector \(q\) -
gamma(float) –gamma, shift parameter \(\gamma\)
Returns:
-
L(ndarray) –L, coefficient manipulation matrices \(\Lambda\).
References
[Wildhaber2019] (Eq. 6.32)
Source code in lmlib/polynomial/poly.py
poly_shift_expo
¶
\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{q}\) for shifted polynomial, see poly_shift
Parameters:
-
expo(array_like) –q, Exponent vector \(q\)
Returns:
-
expo(ndarray) –q_tilde, exponent vector \(\tilde{q}\).
References
[Wildhaber2019] (Eq. 6.30)
Source code in lmlib/polynomial/poly.py
Dilation of Polynomials¶
poly_dilation
¶
\(\alpha^\mathsf{T} (\eta x)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^q}\)
Dilation of a polynomial by scaling x by constant value \(\eta \in \mathbb{R}\)
Parameters:
Returns:
-
out(Poly) –dilated polynomial, \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.33)
Source code in lmlib/polynomial/poly.py
poly_dilation_coef
¶
\(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^q\)
Coefficient vector \(\tilde{\alpha}\) of dilated polynomial by scaling x by constant value \(\eta \in \mathbb{R}\), see poly_dilation.
Parameters:
Returns:
-
coef [`ndarray`][numpy.ndarray]–Coefficient vector \(\tilde{\alpha}\)
References
[Wildhaber2019] (Eq. 6.34)
Source code in lmlib/polynomial/poly.py
poly_dilation_coef_L
¶
\(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{q}\)
Coefficient manipulation matrix \(\tilde{\Lambda}\) to dilated polynomial by scaling x by constant value \(\eta \in \mathbb{R}\), see poly_dilation.
Parameters:
-
expo(array_like) –q, Exponent vector \(q\) -
eta(float) –eta, dilation factor \(\eta\)
Returns:
-
L(ndarray) –L, Coefficient Manipulation Matrices \(\Lambda\)
References
[Wildhaber2019] (Eq. 6.35)
Source code in lmlib/polynomial/poly.py
Integration of Polynomials¶
poly_int
¶
\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Indefinite integral of a polynomial
Parameters:
-
poly(Poly) –polynomial to be integrated
Returns:
-
out(Poly) –polynomial, \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.17)
Source code in lmlib/polynomial/poly.py
poly_int_coef
¶
\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector \(\tilde{\alpha}\) of indefinite integral of a polynomial, see poly_int
Parameters:
-
poly(Poly) –polynomial to be integrated
Returns:
-
coef((ndarray,)) –alpha_tilde, Coefficient vector \(\tilde{\alpha}\)
References
[Wildhaber2019] (Eq. 6.18)
Source code in lmlib/polynomial/poly.py
poly_int_coef_L
¶
\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)
Coefficient manipulation matrix \(\Lambda\) of indefinite integral of a polynomial, see poly_int.
Parameters:
-
expo(array_like) –q, Exponent vector \(q\)
Returns:
-
L(ndarray) –L, coefficient Manipulation Matrices \(\Lambda\)
References
[Wildhaber2019] (Eq. 6.20-21)
Source code in lmlib/polynomial/poly.py
poly_int_expo
¶
\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{q}\) of indefinite integral of a polynomial, see poly_int.
Parameters:
-
expo(array_like) –q, exponent vector \(q\)
Returns:
-
expo(ndarray) –q_tilde, exponent vector \(\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.19)
Source code in lmlib/polynomial/poly.py
Differentiation of Polynomials¶
poly_diff
¶
\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)
Derivative of a polynomial
Parameters:
-
poly(Poly) –polynomial to differentiate
Returns:
-
out(Poly) –derivative polynomial \(\tilde{\alpha}^\mathsf{T} x^\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.24)
Source code in lmlib/polynomial/poly.py
poly_diff_coef
¶
\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)
Coefficient vector \(\tilde{\alpha}\) of the derivative of a polynomial; see poly_diff
Parameters:
-
poly(Poly) –polynomial to differentiate
Returns:
-
coef(ndarray) –alpha_tilde, coefficient vector \(\tilde{\alpha}\)
References
[Wildhaber2019] (Eq. 6.25)
Source code in lmlib/polynomial/poly.py
poly_diff_coef_L
¶
\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)
Coefficient manipulation matrix \(\Lambda\) of polynomial derivation, see poly_diff
Parameters:
-
expo(array_like) –Exponent vector \(q\)
Returns:
-
L(ndarray) –L, coefficient manipulation matrices \(\Lambda\)
References
[Wildhaber2019] (Eq. 6.27)
Source code in lmlib/polynomial/poly.py
poly_diff_expo
¶
\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)
Exponent vector \(\tilde{q}\) of polynomial derivation, see poly_diff
Parameters:
-
expo(array_like) –Exponent vector \(q\)
Returns:
-
expo(ndarray) –q_tilde, exponent vector \(\tilde{q}\)
References
[Wildhaber2019] (Eq. 6.26)
Source code in lmlib/polynomial/poly.py
Addition of Multivariate Polynomials¶
mpoly_add
¶
Sum of two univariate polynomials different variables
Parameters:
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.37)
Source code in lmlib/polynomial/poly.py
mpoly_add_coefs
¶
Coefficients for mpoly_add
Parameters:
Returns:
-
out(tuple of ndarray) –Tuple of coefficient vectors
References
[Wildhaber2019] (Eq. 6.38-39)
Source code in lmlib/polynomial/poly.py
mpoly_add_expos
¶
Exponents for mpoly_add
Parameters:
Returns:
-
out(tuple of ndarray) –Tuple of exponent vectors
References
[Wildhaber2019] (Eq. 6.38-39)
Source code in lmlib/polynomial/poly.py
Multiplication of Multivariate Polynomials¶
mpoly_multiply
¶
Product of two univariate polynomials different variables
Parameters:
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.40)
Source code in lmlib/polynomial/poly.py
Product of Multivariate Polynomials¶
mpoly_prod
¶
Product of univariate polynomials different variables
Parameters:
-
polys(list of Poly or MPoly) –
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.40)
Source code in lmlib/polynomial/poly.py
Square of Multivariate Polynomials¶
mpoly_square
¶
Square of multivariate polynomial
Parameters:
-
mpoly(MPoly) –
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.42 - 6.43)
Source code in lmlib/polynomial/poly.py
mpoly_square_coef_L
¶
Coefficient manipulation matrix for mpoly_square.
Parameters:
-
expos(tuple of array_like) –Exponent vectors of the multivariate polynomial.
-
sparse(bool, default:False) –If True, return a sparse matrix. Default: False.
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.44)
Source code in lmlib/polynomial/poly.py
mpoly_square_coef
¶
Non-factorized coefficient vector for mpoly_square
Parameters:
-
mpoly(MPoly) –
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.44)
Source code in lmlib/polynomial/poly.py
mpoly_square_expos
¶
Exponent vectors for mpoly_square
Parameters:
-
expos(tuple of array_like) –
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.45)
Source code in lmlib/polynomial/poly.py
mpoly_square_expo_Ms
¶
Exponent manipulation matrices \(M_1, M_2, \dots M_N\) for the square of an N-variate polynomial.
Parameters:
-
expos(tuple of array_like) –(q, r), exponent vectors
Returns:
-
Ms(list of ndarray) –(M_1, ..., M_N), list of exponent manipulation matrices
References
[Wildhaber2019] (Eq. 6.45)
Source code in lmlib/polynomial/poly.py
Shift of Multivariate Polynomials¶
mpoly_shift
¶
Polynomial with variable shift
Parameters:
-
poly(Poly) –
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.49)
Source code in lmlib/polynomial/poly.py
mpoly_shift_coef
¶
Coefficient vector for mpoly_shift
Parameters:
-
poly(Poly) –
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.50)
Source code in lmlib/polynomial/poly.py
mpoly_shift_coef_L
¶
Coefficient manipulation matrix for mpoly_shift
Parameters:
-
expo(array_like) –
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.52-6.53)
Source code in lmlib/polynomial/poly.py
mpoly_shift_expos
¶
Exponent vector for mpoly_shift
Parameters:
-
expo(array_like) –
Returns:
-
out(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.51)
Source code in lmlib/polynomial/poly.py
Integration of Multivariate Polynomials¶
mpoly_int
¶
Integral of a multivariate polynomial with respect to the scalar at a position
Parameters:
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.60 - 6.61)
Source code in lmlib/polynomial/poly.py
mpoly_int_coef
¶
Coefficient vector for mpoly_int
Parameters:
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.61)
Source code in lmlib/polynomial/poly.py
mpoly_int_coef_L
¶
Coefficient manipulation matrix for mpoly_int
Parameters:
-
expos(tuple of array_like) – -
position(int) –
Returns:
-
L(ndarray) –
References
[Wildhaber2019] (Eq. 6.61)
Source code in lmlib/polynomial/poly.py
mpoly_int_expos
¶
Exponent vectors for mpoly_int
Parameters:
-
expos(tuple of array_like) – -
position(int) –
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.61, Eq.6.19)
Source code in lmlib/polynomial/poly.py
Differentiation of Multivariate Polynomials¶
mpoly_diff
¶
Derivative of a multivariate polynomial with respect to the variable at the given position.
Parameters:
-
mpoly(MPoly) –Multivariate polynomial to differentiate.
-
position(int) –Index of the variable with respect to which the derivative is taken.
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.24, multivariate generalisation)
Source code in lmlib/polynomial/poly.py
mpoly_diff_coef
¶
Coefficient vector for mpoly_diff.
Parameters:
-
mpoly(MPoly) –Multivariate polynomial to differentiate.
-
position(int) –Index of the differentiation variable.
-
sparse(bool, default:False) –If True, use sparse matrix arithmetic. Default: False.
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.25, multivariate generalisation)
Source code in lmlib/polynomial/poly.py
mpoly_diff_coef_L
¶
Coefficient manipulation matrix for mpoly_diff.
Parameters:
-
expos(tuple of array_like) –Exponent vectors of the multivariate polynomial.
-
position(int) –Index of the differentiation variable.
-
sparse(bool, default:False) –If True, return a sparse matrix. Default: False.
Returns:
-
L(ndarray) –
References
[Wildhaber2019] (Eq. 6.27, multivariate generalisation)
Source code in lmlib/polynomial/poly.py
mpoly_diff_expos
¶
Exponent vectors for mpoly_diff.
Parameters:
-
expos(tuple of array_like) –Exponent vectors of the multivariate polynomial.
-
position(int) –Index of the differentiation variable.
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.26, multivariate generalisation)
Source code in lmlib/polynomial/poly.py
Definite Integration of Multivariate Polynomials¶
mpoly_def_int
¶
Definite integral of a multivariate polynomial with respect to the scalar at a position
Parameters:
-
mpoly(MPoly) – -
position(int) – -
a(scalar) –lower integration boundary
-
b(scalar) –upper integration boundary
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.62 - 6.63)
Source code in lmlib/polynomial/poly.py
mpoly_def_int_coef
¶
Coefficient vector for mpoly_def_int
Parameters:
-
mpoly(MPoly) – -
position(int) – -
a(scalar) –lower integration boundary
-
b(scalar) –upper integration boundary
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.61), (Eq. 6.58)
Source code in lmlib/polynomial/poly.py
mpoly_def_int_coef_L
¶
Coefficient manipulation matrix for mpoly_def_int
Parameters:
-
expos(tuple of array_like) – -
position(int) – -
a(scalar) –lower integration boundary
-
b(scalar) –upper integration boundary
Returns:
-
L(ndarray) –
References
[Wildhaber2019] (Eq. 6.61), (Eq. 6.58)
Source code in lmlib/polynomial/poly.py
mpoly_def_int_expos
¶
Exponent vectors for mpoly_def_int
Parameters:
-
expos(tuple of array_like) – -
position(int) –
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.61, Eq.6.19)
Source code in lmlib/polynomial/poly.py
Substitution of Multivariate Polynomials¶
mpoly_substitute
¶
Substituting a variable of a multivariate polynomial by a constant
Parameters:
Returns:
-
out(MPoly) –
References
[Wildhaber2019] (Eq. 6.62 - 6.63)
Source code in lmlib/polynomial/poly.py
mpoly_substitute_coef
¶
Coefficient vector for mpoly_def_int
Parameters:
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.58)
Source code in lmlib/polynomial/poly.py
mpoly_substitute_coef_L
¶
Coefficient manipulation matrix for mpoly_def_int
Parameters:
-
expos(tuple of array_like) – -
position(int) – -
substitute(scalar) –
Returns:
-
L(ndarray) –
References
[Wildhaber2019] (Eq. 6.58)
Source code in lmlib/polynomial/poly.py
mpoly_substitute_expos
¶
Exponent vectors for mpoly_substitute
Parameters:
-
expos(tuple of array_like) – -
position(int) –
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.58)
Source code in lmlib/polynomial/poly.py
Independent Dilation of Multivariate Polynomials¶
mpoly_dilate_ind
¶
\(\alpha^{mathsf{T}}(xy)^q = (\Delta_Q\alpha)^{mathsf{T}}(x^q \otimes y^q)\)
Dilates a univariate polynomial poly by an indeterminate y
Parameters:
-
poly(Poly) –Univariate polynomial
Poly(alpha, q)
Returns:
-
mpoly(MPoly) –Multivariate polynomial
Poly((alpha_tilde,), (q, q))with dilation variable \(y\)
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_ind_coefs
¶
Coefficient vectros for mpoly_dilate
Parameters:
-
poly(Poly) –
Returns:
-
out(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_ind_coef_L
¶
Coefficient manipulation matrix for mpoly_dilate
Parameters:
-
expo(tuple of array_like) –
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.57)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_ind_expos
¶
Exponent vectors for mpoly_dilate
Parameters:
-
expo((array_like,)) –q, exponent vector \(q\)
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
Dilation of Multivariate Polynomials¶
mpoly_dilate
¶
Dilate a multivariate polynomial by a constant eta
Parameters:
Returns:
-
mpoly(MPoly) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_coefs
¶
Coefficient vectros for mpoly_dilate
Parameters:
Returns:
-
out(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_coef_L
¶
Coefficient manipulation matrix for mpoly_dilate
Parameters:
-
expos(tuple of array_like) – -
position(int) – -
eta–
Returns:
-
out(ndarray) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
mpoly_dilate_expos
¶
Exponent vectors for mpoly_dilate
Parameters:
-
expos(tuple of array_like) –
Returns:
-
expos(tuple of ndarray) –
References
[Wildhaber2019] (Eq. 6.55)
Source code in lmlib/polynomial/poly.py
Sequences, Matrices and Basis Utilities¶
kron_sequence
¶
Kroneker product of a sequence of matrices
Parameters:
-
arrays(tuple of array_like, list of array_like) –sequence of matrices
-
sparse(bool, default:False) –if true the result calculated and returned as a sparse matrix
Returns:
-
prod((array_like, int)) –Kronecker product of sequence of matrices
Examples:
>>> a1 = np.array([[2, 3, 4], [0, 1, 4]])
>>> a2 = np.array([[9, 0], [1, 1]])
>>> a3 = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> b = kron_sequence((a1, a2, a3))
>>> print(b)
[[ 0 18 36 0 0 0 0 27 54 0 0 0 0 36 72 0 0 0]
[ 54 72 90 0 0 0 81 108 135 0 0 0 108 144 180 0 0 0]
[108 126 144 0 0 0 162 189 216 0 0 0 216 252 288 0 0 0]
[ 0 2 4 0 2 4 0 3 6 0 3 6 0 4 8 0 4 8]
[ 6 8 10 6 8 10 9 12 15 9 12 15 12 16 20 12 16 20]
[ 12 14 16 12 14 16 18 21 24 18 21 24 24 28 32 24 28 32]
[ 0 0 0 0 0 0 0 9 18 0 0 0 0 36 72 0 0 0]
[ 0 0 0 0 0 0 27 36 45 0 0 0 108 144 180 0 0 0]
[ 0 0 0 0 0 0 54 63 72 0 0 0 216 252 288 0 0 0]
[ 0 0 0 0 0 0 0 1 2 0 1 2 0 4 8 0 4 8]
[ 0 0 0 0 0 0 3 4 5 3 4 5 12 16 20 12 16 20]
[ 0 0 0 0 0 0 6 7 8 6 7 8 24 28 32 24 28 32]]
Source code in lmlib/polynomial/poly.py
extend_basis
¶
(DEV) Extending the basis of a uni- or multi-variate polynomial by new variables
The new basis / variable are appended.
Parameters:
-
mpoly((MPoly, Poly)) –Polynomial to extent the basis (variables) * Each of the new exponent vectors has to contain 1 zero element. **
-
new_expos(tuple of array_like) –Each array in the tuple corresponds to a new variable ** Each of the new exponent vectors has to contain 1 zero element. **
Returns:
-
mpoly(MPoly) –Multivariate polynomial with extended basis (new variales)
References
TODO: Ref
Source code in lmlib/polynomial/poly.py
permutation_matrix
¶
Returns permutation matrix
The permutation is given by
with permutation matrix
and \(A_{\{m,n\}} \in \mathbb{R}\) and \(B_{\{i,j\}} \in \mathbb{R}\)
Parameters:
-
m(int) –Size of first dimension of A
-
n(int) –Size of second dimension of A
-
i(int) –Size of first dimension of B
-
j(int) –Size of second dimension of B
Returns:
-
R(ndarray) –Commutation matrix
References
[Wildhaber2019] (Eq. 6.100-6.102)
See Also
permutation_matrix_square
Source code in lmlib/polynomial/poly.py
permutation_matrix_square
¶
Returns permutation matrix for square matrices A and B
The permutation is given by
with permutation matrix
and \(A_{\{m,m\}} \in \mathbb{R}\) and \(B_{\{i,i\}} \in \mathbb{R}\)
Parameters:
Returns:
-
R(ndarray) –Commutation matrix
References
[Wildhaber2019] (Eq. 6.101-6.103)
See Also
permutation_matrix
Source code in lmlib/polynomial/poly.py
commutation_matrix
¶
Returns commutation matrix
where \(A_{\{m,n\}} \in \mathbb{R}\)
Parameters:
Returns:
-
K(ndarray) –Commutation matrix squared
References
[Wildhaber2019] (Eq. 6.114-6.115)
Source code in lmlib/polynomial/poly.py
remove_redundancy
¶
Returns the exponent vector without redundancy and the matrix to add up the coefficients of the same exponent.
Parameters:
-
expo–Exponent vector with redundant entries
Returns:
-
L(ndarray of shape=(R,Q) of int) –Coefficient matrix
-
r(ndarray of shape=(R,) of int) –Exponent vector
Source code in lmlib/polynomial/poly.py
mpoly_remove_redundancy
¶
Returns the tuple of exponent vectors without redundancy and the matrix to add up the coefficients of the same exponent.
TODO: How to address type of tuple of arrys different sizes
Parameters:
-
expos(tuple of array_like of shape=(Qn,) fo int) –Tuple of exponent vectors with redundant entries
-
sparse(bool, default:False) –If true the Coefficient matrix
Lgets returned as sparse matrix class
Returns:
-
L(ndarray of shape=(Rn,Qn) of int) –Coefficient matrix
-
expos_out(tuple of ndarray of shape=(Rn,) of int) –Tuple of exponent vectors
Source code in lmlib/polynomial/poly.py
mpoly_transformation_coef_L
¶
transformation of a uniform polynomial into the form
for \(s = [0, 1]\)
Parameters:
-
expo((array_like,)) –q, exponent vector \(q\) -
c(scalar, default:0) –x-offset
Source code in lmlib/polynomial/poly.py
mpoly_transformation_expos
¶
mpoly_extend_coef_L
¶
Extends the polynomial by additional variables without changing its value.
Basis expansion:
for \(s = [0, 1]\).