MultiPower


MultiPower Class

class yroots.polynomial.MultiPower(coeff, clean_zeros=True)

Coefficient tensor representation of a power basis polynomial.

Using this class instead of a Python callable function to represent a power basis polynomial can lead to faster function evaluations during approximation.

Examples

To represent 3x^6 + 5.5x^2 -4:

>>> f = yroots.MultiPower([-4,0,5.5,0,0,0,3])
>>> print(f)
[-4.   0.   5.5  0.   0.   0.   3. ]

To represent 0.62x^3*y - 0.11x*y + 1.03y^2 - 0.58:

>>> f = yroots.MultiPower(np.array([[-0.58,0,1.03],[0,-0.11,0],[0,0,0],[0,0.62,0]]))
>>> print(f)
[[-0.58  0.    1.03]
 [ 0.   -0.11  0.  ]
 [ 0.    0.    0.  ]
 [ 0.    0.62  0.  ]]
Parameters:
  • coeff (list or numpy array) – An array containing the coefficients of the polynomial. If the polynomial is n-dimensional, the (i,j,…,n) index represents the term of degree i in dimension 0, degree j in dimension 1, and so forth.

  • clean_zeros (bool) – Whether or not to remove all extra rows or columns containing only zeros. Defaults to True.