polynomials.canonical#
This module provides computational routines relevant to polynomials in the canonical basis.
- minterpy.utils.polynomials.canonical.integrate_monomials(exponents, bounds)[source]#
Integrate the monomials in the canonical basis given a set of exponents.
- Parameters:
exponents (
numpy.ndarray) – A set of exponents from a multi-index set that defines the polynomial, an(N, M)array, whereNis the number of exponents (multi-indices) andMis the number of spatial dimensions. The number of exponents corresponds to the number of monomials.bounds (
numpy.ndarray) – The bounds (lower and upper) of the definite integration, an(M, 2)array, whereMis the number of spatial dimensions.
- Returns:
The integrated Canonical monomials, an
(N,)array, whereNis the number of monomials (exponents).- Return type:
- minterpy.utils.polynomials.canonical.eval_polynomials(xx, coeffs, exponents)[source]#
Evaluate polynomial in the canonical basis.
- Parameters:
xx (
numpy.ndarray) – Array of query points in the at which the polynomial(s) is evaluated. The array is of shape(N, m)whereNis the number of points andmis the spatial dimension of the polynomial.coeffs (
numpy.ndarray) – The coefficients of the polynomial in the canonical basis. A single set of coefficients is given as a one-dimensional array while multiple sets are given as a two-dimensional array.exponents (
numpy.ndarray) – The exponents of the polynomial as multi-indices, a two-dimensional positive integer array.
- Returns:
The output of the polynomial evaluation. If the polynomial consists of a single coefficient set, the output array is one-dimensional with a length of
N. If the polynomial consists of multiple coefficients sets, the output array is two-dimensional with a shape of(N, n_poly)wheren_polyis the number of coefficient sets.- Return type:
Notes
This implementation is considered unsafe and may fail spectacularly for polynomials of moderate degrees. Consider a more advanced implementation in the future.