MPoly
¶
Bases: _PolyBase
flowchart TD
lmlib.polynomial.poly.MPoly[MPoly]
lmlib.polynomial.poly._PolyBase[_PolyBase]
lmlib.polynomial.poly._PolyBase --> lmlib.polynomial.poly.MPoly
click lmlib.polynomial.poly.MPoly href "" "lmlib.polynomial.poly.MPoly"
click lmlib.polynomial.poly._PolyBase href "" "lmlib.polynomial.poly._PolyBase"
Multivariate polynomials \({\tilde{\alpha}}^\mathsf{T} (x^q \otimes y^r)\), or with factorized coefficient vector \((\alpha \otimes \beta )^\mathsf{T} (x^q \otimes y^r)\).
This polynomial class is for multivariate polynomials in vector exponent notation, see [Wildhaber2019], Chapter 6.
Such a multivariate polynomial is in general given by
where \(\tilde{\alpha} \in \mathbb{R}^{Q \times R}\) is the coefficient vectors, \(q \in \mathbb{Z}_{\geq 0}^Q\) and \(r \in \mathbb{Z}_{\geq 0}^R\) the exponent vectors, and \(x \in \mathbb{R}\) and \(y \in \mathbb{R}\) the independent variables.
As a special case, if the coefficient vector is in the form of a Kronecker product, i.e.,
where \(\alpha \in \mathbb{R}^Q\) and \(\beta \in \mathbb{R}^R\) are coefficient vectors, we denote a polynomial as factorized. This form often leads to algebraic simplifications (if it exists).
Example
>>> # Bivariate (x,y) polynomial with factorized coefficients ([.2,.7],[-1.0,2.0,.1]) and terms x^1, x^2, y^1, y^2, y^3, and cross terms
>>> l= MPoly(([.2,.7],[-1.0,2.0,.1]),([1,2],[1,2,3]))
>>> l.coefs # gets coefficients
(array([0.2, 0.7]), array([-1. , 2. , 0.1]))
>>> l.coef_fac # gets factorized coefficients (if available)
array([-0.2 , 0.4 , 0.02, -0.7 , 1.4 , 0.07])
>>> l.eval([.3,.7]) # evaluating polynomial for x=.3 and y=.7
array(0.0386589)
Parameters:
-
coefs(tuple of array_like) –Set of coefficient vector(s)
-
expos(tuple of array_like) –Set of exponent vector(s)
Constructor method
Methods:
-
eval–Evaluates the polynomial for given values (variables)
Attributes:
-
expos–tuple of
ndarray: Exponent vectors -
coefs_fac–tuple of
ndarray, orNone: Factorized coefficient vectors -
coefs–tuple of
ndarray: Coefficient vector (i.e., not factorized) -
variable_count–int : Number of dependent variables
Source code in lmlib/polynomial/poly.py
Methods¶
eval
¶
Evaluates the polynomial for given values (variables)
Parameters:
-
variables(tuple) –Dependent variables of a polynomial. Each element in variables has the same shape which is also the output shape.
Returns:
-
out(ndarray) –Output of evaluated polynomial. Shape is identical as a dependent variable