xspline.poly#

xspline.poly.poly_val(params, x)[source]#

Polynomial value function.

Parameters:
  • params (tuple[float, ...]) – Polynomial coefficients.

  • x (ndarray[Any, dtype[_ScalarType_co]]) – Data points.

Returns:

Polynomial function values.

Return type:

describe

xspline.poly.poly_der(params, x, order)[source]#

Polynomial derivative function.

Parameters:
  • params (tuple[float, ...]) – Polynomial coefficients.

  • x (ndarray[Any, dtype[_ScalarType_co]]) – Data points.

  • order (int) – Order of differentiation.

Returns:

Polynomial derivative values.

Return type:

describe

xspline.poly.poly_int(params, x, order)[source]#

Polynomial definite integral function.

Parameters:
  • params (tuple[float, ...]) – Polynomial coefficients.

  • x (ndarray[Any, dtype[_ScalarType_co]]) – Data points.

  • order (int) – Order of integration. Here we use negative integer.

Returns:

Polynomial definite integral values.

Return type:

describe

class xspline.poly.Poly(params)[source]#

Bases: BundleXFunction

Polynomial function. A simple wrapper for the numpy poly functions.

Parameters:

params (tuple[float, ...]) – This a tuple contains coefficients for the terms in polynomial.

Example

>>> poly = Poly((1.0, 0.0))
>>> poly([0.0, 1.0])
array([0.0, 1.0])
>>> poly([0.0, 1.0], order=1)
array([1.0, 1.0])
>>> poly([0.0, 1.0], order=2)
array([0.0, 0.0])
>>> poly([0.0, 1.0]], order=-1)
array([0.0, 0.5])
xspline.poly.get_poly_params(fun, x, degree)[source]#

Solve polynomial (taylor) coefficients provided the XFunction.

Parameters:
  • fun (XFunction) – Provided XFunction to be approximated.

  • x (float) – The point where we want to approximate XFunction by the polynomial.

  • degree (int) – Degree of the approximation polynomial.

Returns:

The approximation polynomial coefficients.

Return type:

describe

xspline.poly.get_poly_fun(fun, x, degree)[source]#

Get the approximation polynomial function.

Parameters:
  • fun (XFunction) – Provided XFunction to be approximated.

  • x (float) – The point where we want to approximate XFunction by the polynomial.

  • degree (int) – Degree of the approximation polynomial.

Returns:

Instance of the Poly class to approximate provided XFunction.

Return type:

describe