Skip to content

Poly

Poly(coef, expo)

Bases: _PolyBase


              flowchart TD
              lmlib.polynomial.poly.Poly[Poly]
              lmlib.polynomial.poly._PolyBase[_PolyBase]

                              lmlib.polynomial.poly._PolyBase --> lmlib.polynomial.poly.Poly
                


              click lmlib.polynomial.poly.Poly href "" "lmlib.polynomial.poly.Poly"
              click lmlib.polynomial.poly._PolyBase href "" "lmlib.polynomial.poly._PolyBase"
            

Univariate polynomial in vector exponent notation: \(\alpha^\mathsf{T} x^q\)

Polynomial class for univariate polynomials in vector exponent notation; see [Wildhaber2019], Chapter 6.

Such a polynomial p(x) in x is defined as

\[ \begin{aligned} p(x) &= \alpha^\mathsf{T}x^q = \begin{bmatrix}a_0& a_1& \cdots& a_{Q-1}\end{bmatrix} \begin{bmatrix}x^{q_0}\\ x^{q_1}\\ \vdots\\ x^{q_{Q-1}}\end{bmatrix}\\ &= a_0 x^{q_0} + a_1 x^{q_1}+ \dots + a_{Q-1} x^{q_{Q-1}} \ , \end{aligned} \]

with coefficient vector \(\alpha \in \mathbb{R}^Q\), exponent vector \(q \in \mathbb{Z}_{\geq 0}^Q\), and function variable \(x \in \mathbb{R}\).

Parameters:

  • coef (array_like, shape=(Q)) –

    Coefficient vector

  • expo (array_like, shape=(Q)) –

    Exponent vector

Example
>>> import lmlib as lm
>>> p = Poly([0, 0.2, 3], [0, 1, 2])
>>> print(p)

Constructor method

Methods:

  • eval

    Evaluates the polynomial

Attributes:

  • coef

    ndarray : Coefficient vector \(\alpha\)

  • expo

    ndarray : Exponent vector \(q\)

  • Q

    int : Number of elements in exponent vector \(Q\)

  • expos

    tuple of ndarray : Exponent vectors

  • coefs_fac

    tuple of ndarray, or None : 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
def __init__(self, coef, expo):
    """
    Constructor method
    """
    coefs = (np.asarray(coef),)
    expos = (np.asarray(expo),)
    super(Poly, self).__init__(coefs, expos)

Methods

eval

eval(variable)

Evaluates the polynomial

Parameters:

  • variable ((array_like, scalar)) –

    Dependent variables of a polynomial.

Returns:

  • out ( ndarray ) –

    Output of evaluated polynomial. Shape is identical as a dependent variable

Source code in lmlib/polynomial/poly.py
def eval(self, variable):
    r"""
    Evaluates the polynomial

    Parameters
    ----------
    variable : array_like, scalar
        Dependent variables of a polynomial.

    Returns
    -------
    out : ndarray
        Output of evaluated polynomial.
        Shape is identical as a dependent variable
    """
    #return super(Poly, self).eval(np.asarray(variable))
    #return super(Poly, self).eval((np.asarray(variable),))
    return super(Poly, self).eval((np.asarray(variable, dtype=float),))