multivariate_polynomial_abstract#

This module contains the abstract base classes for all polynomial base classes.

All concrete implementations of polynomial bases must inherit from the abstract base class. This ensures a consistent interface across all polynomials. As a result, additional features can be developed without needing to reference specific polynomial classes, while allowing each concrete class to manage its own implementation details.

See e.g. PEP 3119 for further explanations on the topic.


class minterpy.core.ABC.multivariate_polynomial_abstract.MultivariatePolynomialABC[source]#

the most general abstract base class for multivariate polynomials.

Every data type which needs to behave like abstract polynomial(s) should subclass this class and implement all the abstract methods.

Properties

coeffs

Abstract container which stores the coefficients of the polynomial.

num_active_monomials

Abstract container for the number of monomials of the polynomial(s).

spatial_dimension

Abstract container for the dimension of space where the polynomial(s) live on.

unisolvent_nodes

Abstract container for unisolvent nodes the polynomial(s) is(are) defined on.

abstract property coeffs: ndarray#

Abstract container which stores the coefficients of the polynomial.

This is a placeholder of the ABC, which is overwritten by the concrete implementation.

abstract property num_active_monomials#

Abstract container for the number of monomials of the polynomial(s).

Notes

This is a placeholder of the ABC, which is overwritten by the concrete implementation.

abstract property spatial_dimension#

Abstract container for the dimension of space where the polynomial(s) live on.

Notes

This is a placeholder of the ABC, which is overwritten by the concrete implementation.

abstract property unisolvent_nodes#

Abstract container for unisolvent nodes the polynomial(s) is(are) defined on.

Notes

This is a placeholder of the ABC, which is overwritten by the concrete implementation.

abstract static _eval(poly, xx, **kwargs)[source]#

Abstract method to the polynomial evaluation function.

Parameters:
  • poly (MultivariatePolynomialABC) – A concrete instance of a polynomial class that can be evaluated on a set of query points.

  • xx (numpy.ndarray) – The set of query points to evaluate as a two-dimensional array of shape (k, m) where k is the number of query points and m is the spatial dimension of the polynomial.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying evaluation (see the concrete implementation).

Returns:

The values of the polynomial evaluated at query points.

  • If there is only a single polynomial (i.e., a single set of coefficients), then a one-dimensional array of length k is returned.

  • If there are multiple polynomials (i.e., multiple sets of coefficients), then a two-dimensional array of shape (k, np) is returned where np is the number of coefficient sets.

Return type:

numpy.ndarray

Notes

  • This is a placeholder of the ABC, which is overwritten by the concrete implementation.

See also

__call__

The dunder method as a syntactic sugar to evaluate the polynomial(s) instance on a set of query points.

eval_on_internal(xx, *, truncate_cols=False, **kwargs)[source]#

Evaluate polynomial at points in the internal domain.

This method evaluates the polynomial at points assumed to already be in the internal domain used by the polynomial’s algorithms. It skips coordinate transformation to avoid unnecessary floating-point error accumulation.

Parameters:
  • xx (numpy.ndarray) – Query points in the internal domain. It should be a two-dimensional array of shape (k, m) where k is the number of query points and m is the spatial dimension.

  • truncate_cols (bool, optional) – If True, then the last columns of xx are truncated to match the spatial dimension of the polynomial; otherwise all provided columns are attempted to be evaluated. The default is False.

  • **kwargs – Additional keyword-only arguments passed to the underlying evaluation method (see concrete implementation).

Returns:

The values of the polynomial evaluated at query points.

  • If there is only a single polynomial (i.e., a single set of coefficients), then a one-dimensional array of length k is returned.

  • If there are multiple polynomials (i.e., multiple sets of coefficients), then a two-dimensional array of shape (k, np) is returned where np is the number of coefficient sets.

Return type:

numpy.ndarray

Notes

  • Use this method when: (1) Points are already in the internal domain (e.g., unisolvent nodes) (2) Avoiding unnecessary coordinate transformations that incur floating-point errors.

  • Coordinate transformations are not free numerically. While they are affine, round-trip transformations over many interation may accumulate floating-point errors.

Notes

  • The function calls the concrete implementation of the static method _eval().

See also

_eval

The underlying static method to evaluate the polynomial(s) instance on a set of query points.

__weakref__#

list of weak references to the object (if defined)

class minterpy.core.ABC.multivariate_polynomial_abstract.MultivariatePolynomialSingleABC(multi_index, coeffs=None, grid=None, domain=None)[source]#

Bases: MultivariatePolynomialABC

Abstract base class for “single instance” multivariate polynomials

Parameters:
  • multi_index (MultiIndexSet) – The multi-index set of the multivariate polynomial.

  • coeffs (np.ndarray, optional) – Coefficients of the polynomial. If None, the polynomial is uninitialized. Either a one-dimensional array of length equal to the number of monomials or a two-dimensional array of shape (num_monomials, num_polynomials) for multiple polynomials sharing the same multi-index set.

  • grid (Grid, optional) – The underlying grid on which the (interpolating) polynomial is defined. If not given, the default Grid instance will be constructed.

  • domain (Domain, optional) – The domain of the underlying grid. If not given, the domain will be derived from the default Grid instance.

Notes

  • The multi-index set associated with grid may be different from multi_index. All indices from multi_index must be contained in grid.multi_index.

Properties

coeffs

The coefficients of the polynomial(s).

domain

The domain associated with the Grid of the polynomial(s).

grid

The underlying grid of the polynomial(s).

num_active_monomials

The number of active monomials of the polynomial(s).

spatial_dimension

The spatial dimension of the polynomial(s).

unisolvent_nodes

Unisolvent nodes on which the interpolating polynomial lives.

Methods

add_points(exponents)

Extend grid and multi_index

diff(order, **kwargs)

Return the partial derivative poly.

eval_on_internal(xx, *[, truncate_cols])

Evaluate polynomial at points in the internal domain.

expand_dim(target_dimension)

Expand the spatial dimension of the polynomial instance.

from_degree(spatial_dimension, poly_degree, ...)

Create a polynomial from polynomial degree specifications.

from_grid(grid[, coeffs])

Create an instance of polynomial with a Grid instance.

from_poly(polynomial[, new_coeffs])

Create a new polynomial instance based on an existing polynomial.

integrate_over([bounds])

Compute the definite integral of the polynomial over the bounds.

make_complete()

returns a possibly new polynomial instance with a complete multi index set.

partial_diff(dim[, order])

Differentiate the polynomial with respect to a given dimension.

abstract static _diff(poly, order, diff_factor, **kwargs)[source]#

Abstract method for diff. poly. on given orders w.r.t each dim.

Parameters:
  • poly (MultivariatePolynomialABC) – The instance of polynomial to differentiate.

  • order (numpy.ndarray) – A one-dimensional integer array specifying the orders of derivative along each dimension. The length of the array must be m where m is the spatial dimension of the polynomial.

  • diff_factor (float) – Differentiation scaling factor taking into account the user domain.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying differentiation (see the concrete implementation).

Returns:

A new polynomial instance that represents the partial derivative of the original polynomial of the specified orders of derivative along each dimension.

Return type:

MultivariatePolynomialSingleABC

Notes

  • The concrete implementation of this static method is called when the public method diff() is called on an instance.

See also

diff

The public method to differentiate the polynomial instance on the given orders of derivative along each dimension.

abstract static _integrate_over(poly, bounds, **kwargs)[source]#

Abstract method for definite integration.

Parameters:
  • poly (MultivariatePolynomialABC) – The instance of polynomial to integrate.

  • bounds (numpy.ndarray) – The limits of the integration, an (m, 2) array where m is the number of spatial dimensions. Each row corresponds to the limits [lower, upper] for a given dimension. If None, then the bounds of the internal domain associated with the polynomial are used instead.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying integration (see the respective concrete implementations).

Returns:

The integral value of the polynomial over the given bounds. If only one polynomial is available, the return value is of a float type. For multiple polynomials, an array of values is returned.

Return type:

Union[float, numpy.ndarray]

Notes

  • The concrete implementation of this static method is called when the public method integrate_over() is called on an instance.

  • Bounds are assumed to be in the internal domain (already transformed from the user domain by the public method).

See also

integrate_over

The public method to integrate the polynomial instance over the given bounds.

__init__(multi_index, coeffs=None, grid=None, domain=None)[source]#
Parameters:
classmethod from_degree(spatial_dimension, poly_degree, lp_degree, coeffs=None, grid=None, domain=None)[source]#

Create a polynomial from polynomial degree specifications.

This factory method constructs a polynomial with a complete multi-index set \(\mathcal{M}_{m, n, p}\) defined by the spatial dimension \(m\), polynomial degree \(n\), and \(l_p\) degree \(p\).

Parameters:
  • spatial_dimension (int) – Spatial dimension of the multi-index set (\(m\)); the value of spatial_dimension must be a positive integer (\(m > 0\)).

  • poly_degree (int) – Polynomial degree of the multi-index set (\(n\)); the value of poly_degree must be a non-negative integer (\(n \geq 0\)).

  • lp_degree (float) – \(p\) of the \(l_p\)-norm (i.e., the \(l_p\)-degree) that is used to define the multi-index set. The value of lp_degree must be a positive float (\(p > 0\)).

  • coeffs (np.ndarray, optional) – Coefficients of the polynomial. If None, the polynomial is uninitialized. Either one-dimensional array of length equal to the number of monomials, or two-dimensional array of shape (num_monomials, num_polynomials) for multiple polynomials sharing the same multi-index set.

  • grid (Grid, optional) – The underlying grid on which the polynomial is defined. If not given, a default Grid instance will be constructed.

  • domain (Domain, optional) – The domain of the underlying grid. If not given, the domain will be derived from the Grid instance (either provided or constructed).

Returns:

A new polynomial instance with the specified parameters of the complete multi-index set.

Return type:

MultivariatePolynomialSingleABC

classmethod from_poly(polynomial, new_coeffs=None)[source]#

Create a new polynomial instance based on an existing polynomial.

This factory method constructs a new polynomial by copying the structure (multi-index set, grid) from an existing polynomial, optionally with new coefficients. Useful for converting between polynomial types or creating polynomials with the same structure but different coefficients.

Parameters:
  • polynomial (MultivariatePolynomialSingleABC) – Input polynomial instance defining the properties to be reused (multi-index set and grid).

  • new_coeffs (np.ndarray, optional) – The coefficients the new polynomial should have. If None, uses a copy of polynomial.coeffs.

Returns:

A new polynomial instance with the same structure as the input polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • The coefficients can also be assigned later if the polynomial is created uninitialized.

classmethod from_grid(grid, coeffs=None)[source]#

Create an instance of polynomial with a Grid instance.

Parameters:
  • grid (Grid) – The grid on which the polynomial is defined.

  • coeffs (numpy.ndarray, optional) – The coefficients of the polynomial(s); a one-dimensional array with the same length as the length of the multi-index set or a two-dimensional array with each column corresponds to the coefficients of a single polynomial on the same grid. This parameter is optional, if not specified the polynomial is considered “uninitialized”.

Returns:

An instance of polynomial defined on the given grid.

Return type:

MultivariatePolynomialSingleABC

property coeffs: ndarray#

The coefficients of the polynomial(s).

Returns:

One- or two-dimensional array that contains the polynomial coefficients. Coefficients of multiple polynomials having common structure are stored in a two-dimensional array of shape (N, P) where N is the number of monomials and P is the number of polynomials.

Return type:

numpy.ndarray

Raises:

ValueError – If the coefficients of an uninitialized polynomial are accessed.

Notes

  • coeffs may be assigned with None to indicate an uninitialized

    polynomial. Accessing such coefficients, however, raises an exception. Many operations involving polynomial instances, require the instance to be initialized and raising the exception here provides a common single point of failure.

property grid: Grid#

The underlying grid of the polynomial(s).

Returns:

The underlying grid of the polynomial(s). Interpolating polynomials live on a Grid.

Return type:

Grid

property domain: Domain#

The domain associated with the Grid of the polynomial(s).

The domain represents the rectangular bounds of the Grid.

Returns:

The domain of the interpolation grid.

Return type:

Domain

property spatial_dimension: int#

The spatial dimension of the polynomial(s).

Returns:

The spatial dimension of the polynomial(s). This dimension may be less than the spatial dimension of the underlying grid.

Return type:

int

Notes

  • The value is propagated from the underlying multi_index.

property unisolvent_nodes: ndarray#

Unisolvent nodes on which the interpolating polynomial lives.

Returns:

A two-dimensional array of shape (N, m) where N is the number of the multi-index set exponents and m is the spatial dimension.

Return type:

np.ndarray

Notes

  • The value is propagated from the underlying grid.

property num_active_monomials: int#

The number of active monomials of the polynomial(s).

The multi-index set that directly defines a polynomial and the grid (where the polynomial lives) may differ. Active monomials are the monomials that are defined by the multi-index set not by the one in the grid.

Returns:

The number of active monomials.

Return type:

int

__eq__(other)[source]#

Compare two concrete polynomial instances for exact equality.

Two polynomial instances are equal if and only if:

  • both are of the same concrete class, and

  • the underlying multi-index sets are equal, and

  • the underlying grid instances are equal (including the underlying domains and multi-index sets), and

  • the coefficients of the polynomials are equal.

Parameters:

other (MultivariatePolynomialSingleABC) – Another instance of concrete implementation of MultivariatePolynomialSingleABC to compare with

Returns:

True if the current instance is equal to the other instance, False otherwise.

Return type:

bool

__neg__()[source]#

Negate the polynomial(s) instance.

This function is called when a polynomial is negated via the - operator, e.g., -P.

Returns:

New polynomial(s) instance with negated coefficients.

Return type:

MultivariatePolynomialSingleABC

Notes

  • The resulting polynomial is a deep copy of the original polynomial.

  • -P is not the same as -1 * P, the latter of which is a scalar multiplication. In this case, however, the result is the same; it returns a new instance with negated coefficients.

__pos__()[source]#

Plus sign the polynomial(s) instance.

This function is called when a polynomial is plus signed via the + operator, e.g., +P.

Returns:

The same polynomial

Return type:

MultivariatePolynomialSingleABC

Notes

  • +P is not the same as 1 * P, the latter of which is a scalar multiplication. In this case, the result actually differs because the scalar multiplication 1 * P returns a new instance of polynomial even though the coefficients are not altered.

__add__(other)[source]#

Add the polynomial(s) with another polynomial(s) or a real scalar.

This function is called when:

  • two polynomials are added: P1 + P2, where P1 (i.e., self) and P2 (other) are both instances of a concrete polynomial class.

  • a polynomial is added with a real scalar number: P1 + a, where a (other) is a real scalar number.

Polynomials are closed under scalar addition, meaning that the result of the addition is also a polynomial with the same underlying multi-index set; only the coefficients are altered.

Parameters:

other (Union[MultivariatePolynomialSingleABC, SCALAR]) – The right operand, either an instance of polynomial (of the same concrete class as the left operand) or a real scalar number.

Returns:

The result of the addition, an instance of summed polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • The concrete implementation of polynomial-polynomial and polynomial- scalar addition is delegated to the respective polynomial concrete class.

__sub__(other)[source]#

Subtract the polynomial(s) with another poly. or a real scalar.

This function is called when:

  • two polynomials are subtracted: P1 - P2, where P1 and P2 are both instances of a concrete polynomial class.

  • a polynomial is added with a real scalar number: P1 - a, where a is a real scalar number.

Polynomials are closed under scalar subtraction, meaning that the result of the subtraction is also a polynomial with the same underlying multi-index set; only the coefficients are altered.

Parameters:

other (Union[MultivariatePolynomialSingleABC, SCALAR]) – The right operand, either an instance of polynomial (of the same concrete class as the right operand) or a real scalar number.

Returns:

The result of the subtraction, an instance of subtracted polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • Under the hood subtraction is an addition operation with a negated operand on the right; no separate concrete implementation is used.

__mul__(other)[source]#

Multiply the polynomial(s) with another polynomial or a real scalar.

This function is called when:

  • two polynomials are multiplied: P1 * P2, where P1 and P2 are both instances of a concrete polynomial class.

  • a polynomial is multiplied with a real scalar number: P1 * a, where a is a real scalar number.

Polynomials are closed under scalar multiplication, meaning that the result of the multiplication is also a polynomial with the same underlying multi-index set; only the coefficients are altered.

Parameters:

other (Union[MultivariatePolynomialSingleABC, SCALAR]) – The right operand, either an instance of polynomial (of the same concrete class as the right operand) or a real scalar number.

Returns:

The result of the multiplication, an instance of multiplied polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • The concrete implementation of polynomial-polynomial multiplication is delegated to the respective polynomial concrete class.

__truediv__(other)[source]#

Divide an instance of polynomial with a real scalar number (/).

Parameters:

other (Union[MultivariatePolynomialSingleABC, SCALAR]) – The right operand of the (true) division expression, a real scalar number.

Returns:

An instance of polynomial, the result of (true) scalar division of a polynomial.

Return type:

MultivariatePolynomialSingleABC

__floordiv__(other)[source]#

Divide an instance of polynomial with a real scalar number (//).

Parameters:

other (Union[MultivariatePolynomialSingleABC, SCALAR]) – The right operand of the (floor) division expression, a real scalar number.

Returns:

An instance of polynomial, the result of (floor) scalar division of a polynomial.

Return type:

MultivariatePolynomialSingleABC

__pow__(power)[source]#

Take the polynomial instance to the given power.

Parameters:

power (int) – The power in the exponentiation expression; the value must be a non-negative real scalar whole number. The value may not strictly be an integer as long as it is a whole number (e.g., \(2.0\) is acceptable).

Returns:

The result of exponentiation, an instance of a concrete polynomial class.

Return type:

MultivariatePolynomialSingleABC

Notes

  • Exponentiation by zero returns a constant polynomial whose coefficients are zero except for the constant term with respect to the multi-index set which is given a value of \(1.0\). In the case of polynomials in the Lagrange basis whose no constant term with respect to the multi-index set, all coefficients are set to \(1.0\).

__radd__(other)[source]#

Right-sided addition of the polynomial(s) with a real scalar number.

This function is called for the expression a + P where a and P is a real scalar number and an instance of polynomial, respectively.

Parameters:

other (SCALAR) – A real scalar number (the left operand) to be added to the polynomial.

Returns:

The result of adding the scalar value to the polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • If the left operand is not a real scalar number, the right-sided addition is not explicitly supported, and it will rely on the __add__() method of the left operand.

__rsub__(other)[source]#

Right-sided subtraction of the polynomial(s) with a real scalar.

This function is called for the expression a - P where a and P is a real scalar number and an instance of polynomial, respectively.

Parameters:

other (SCALAR) – A real scalar number (the left operand) to be substracted by the polynomial.

Returns:

The result of subtracting a scalar value by the polynomial.

Return type:

MultivariatePolynomialSingleABC

Notes

  • If the left operand is not a real scalar number, the right-sided subtraction is not explicitly supported, and it will rely on the __add__() method of the left operand.

  • This operation relies on the negation of a polynomial and scalar addition

__rmul__(other)[source]#

Right sided multiplication of the polynomial(s) with a real scalar.

This function is called if a real scalar number is multiplied with a polynomial like a * P where a and P are a scalar and a polynomial instance, respectively.

Parameters:

other (SCALAR) – The left operand, a real scalar number.

Returns:

The result of the multiplication, an instance of multiplied polynomial.

Return type:

MultivariatePolynomialSingleABC

__copy__()[source]#

Creates of a shallow copy.

This function is called, if one uses the top-level function copy() on an instance of this class.

Returns:

The copy of the current instance.

Return type:

MultivariatePolynomialSingleABC

See also

copy.copy

copy operator form the python standard library.

__deepcopy__(mem)[source]#

Creates of a deepcopy.

This function is called, if one uses the top-level function deepcopy() on an instance of this class.

Returns:

The deepcopy of the current instance.

Return type:

MultivariatePolynomialSingleABC

See also

copy.deepcopy

copy operator form the python standard library.

__len__()[source]#

Return the number of polynomials in the instance.

Returns:

The number of polynomials in the instance. A single instance of polynomial may contain multiple polynomials with different coefficient values but sharing the same underlying multi-index set and grid.

Return type:

int

__call__(xx, *, truncate_cols=False, **kwargs)[source]#

Evaluate the polynomial on a set of query points.

The function is called when an instance of a polynomial is called with a set of query points, i.e., \(p(\mathbf{X})\) where \(\mathbf{X}\) is a matrix of values with \(k\) rows and each row is of length \(m\) (i.e., a point in \(m\)-dimensional space).

Parameters:
  • xx (array_like) – Query points to evaluate. Can be a scalar, list, or numpy array. The points will be standardized to a two-dimensional array of shape (k, m) where k is the number of query points and m is the spatial dimension of the polynomial.

  • truncate_cols (bool, optional) – If True, then the last columns of xx are truncated to match the spatial dimension of the polynomial; otherwise all provided columns are attempted to be evaluated. The default is False.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying evaluation (see the concrete implementation).

Returns:

The values of the polynomial evaluated at query points.

Return type:

numpy.ndarray

_new_instance_if_necessary(new_grid, new_indices=None)[source]#

Constructs a new instance only if the multi indices have changed.

Parameters:
  • new_grid (Grid) – Grid instance the polynomial is defined on.

  • new_indices (MultiIndexSet, optional) – MultiIndexSet instance for the polynomial(s), needs to be a subset of the current multi_index. Default is None.

Returns:

Same polynomial instance if grid and multi_index stay the same, otherwise new polynomial instance with the new grid and multi_index.

Return type:

MultivariatePolynomialSingleABC

make_complete()[source]#

returns a possibly new polynomial instance with a complete multi index set.

Returns:

completed polynomial, where additional coefficients setted to zero.

Return type:

MultivariatePolynomialSingleABC

Notes

  • the active monomials stay equal. only the grid (“basis”) changes

  • in the case of a Lagrange polynomial this could be done by evaluating the polynomial on the complete grid

add_points(exponents)[source]#

Extend grid and multi_index

Adds points grid and exponents to multi_index related to a given set of additional exponents.

Parameters:

exponents (np.ndarray) – Array of exponents added.

Returns:

New polynomial with the added exponents.

Return type:

MultivariatePolynomialSingleABC

expand_dim(target_dimension)[source]#

Expand the spatial dimension of the polynomial instance.

Parameters:

target_dimension (int) – The new spatial dimension. It must be larger than or equal to the current spatial dimension of the polynomial.

Returns:

The new instance of polynomial with expanded dimension.

Return type:

MultivariatePolynomialSingleABC

partial_diff(dim, order=1, **kwargs)[source]#

Differentiate the polynomial with respect to a given dimension.

Parameters:
  • dim (int) – Spatial dimension with respect to which the differentiation is taken. The dimension starts at 0 (i.e., the first dimension).

  • order (int) – Order of partial derivative; the default is 1.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying differentiation (see the respective concrete implementations).

Returns:

A new polynomial instance that represents the partial derivative of the original polynomial of the specified order of derivative and with respect to the specified dimension.

Return type:

MultivariatePolynomialSingleABC

Notes

  • This method is a syntactic sugar to diff() to differentiate with respect to a particular dimension.

diff(order, **kwargs)[source]#

Return the partial derivative poly. of given orders along each dim.

Parameters:
  • order (numpy.ndarray) – A one-dimensional integer array specifying the orders of derivative along each dimension. The length of the array must be m where m is the spatial dimension of the polynomial.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying differentiation (see the respective concrete implementations).

Returns:

A new polynomial instance that represents the partial derivative of the original polynomial of the specified orders of derivative along each dimension.

Return type:

MultivariatePolynomialSingleABC

Notes

  • This method calls the concrete implementation of the abstract method _diff() after input validation.

  • For zero-order derivative (identity operation), returns a copy of the polynomial.

See also

_diff

The underlying static method to differentiate the polynomial of specified orders of derivative along each dimension.

integrate_over(bounds=None, **kwargs)[source]#

Compute the definite integral of the polynomial over the bounds.

Parameters:
  • bounds (np.ndarray, optional) – The integral bounds or the limits of integration, an array of shape (m, 2) where m is the number of spatial dimensions. Each row corresponds to the limits [lower, upper] for a given dimension. If not given, the integral is computed over the entire domain (i.e., self.domain.bounds).

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying integration (see the respective concrete implementations).

Returns:

The integral value of the polynomial over the given bounds. If only one polynomial is available, a single value of float type is returned. For multiple polynomials, an array of values is returned.

Return type:

Union[float, numpy.ndarray]

Raises:

ValueError – If the bounds are of inconsistent shape.

Notes

  • Bounds are specified in the user domain. Internally, they are transformed to the internal domain.

  • The concrete implementation of the abstract method _integrate_over() assumes the domain is internal.

  • Integration outside the domain bounds is allowed but involves extrapolation.

See also

_integrate_over

The underlying static method to integrate the polynomial instance over the given bounds.

__hash__ = None#
__weakref__#

list of weak references to the object (if defined)

abstract static _eval(poly, xx, **kwargs)#

Abstract method to the polynomial evaluation function.

Parameters:
  • poly (MultivariatePolynomialABC) – A concrete instance of a polynomial class that can be evaluated on a set of query points.

  • xx (numpy.ndarray) – The set of query points to evaluate as a two-dimensional array of shape (k, m) where k is the number of query points and m is the spatial dimension of the polynomial.

  • **kwargs – Additional keyword-only arguments that change the behavior of the underlying evaluation (see the concrete implementation).

Returns:

The values of the polynomial evaluated at query points.

  • If there is only a single polynomial (i.e., a single set of coefficients), then a one-dimensional array of length k is returned.

  • If there are multiple polynomials (i.e., multiple sets of coefficients), then a two-dimensional array of shape (k, np) is returned where np is the number of coefficient sets.

Return type:

numpy.ndarray

Notes

  • This is a placeholder of the ABC, which is overwritten by the concrete implementation.

See also

__call__

The dunder method as a syntactic sugar to evaluate the polynomial(s) instance on a set of query points.

_verify_operands(other)[source]#

Verify the operands are valid before moving on.

Parameters:

other (MultivariatePolynomialSingleABC)

Return type:

Tuple[MultivariatePolynomialSingleABC, MultivariatePolynomialSingleABC]

eval_on_internal(xx, *, truncate_cols=False, **kwargs)#

Evaluate polynomial at points in the internal domain.

This method evaluates the polynomial at points assumed to already be in the internal domain used by the polynomial’s algorithms. It skips coordinate transformation to avoid unnecessary floating-point error accumulation.

Parameters:
  • xx (numpy.ndarray) – Query points in the internal domain. It should be a two-dimensional array of shape (k, m) where k is the number of query points and m is the spatial dimension.

  • truncate_cols (bool, optional) – If True, then the last columns of xx are truncated to match the spatial dimension of the polynomial; otherwise all provided columns are attempted to be evaluated. The default is False.

  • **kwargs – Additional keyword-only arguments passed to the underlying evaluation method (see concrete implementation).

Returns:

The values of the polynomial evaluated at query points.

  • If there is only a single polynomial (i.e., a single set of coefficients), then a one-dimensional array of length k is returned.

  • If there are multiple polynomials (i.e., multiple sets of coefficients), then a two-dimensional array of shape (k, np) is returned where np is the number of coefficient sets.

Return type:

numpy.ndarray

Notes

  • Use this method when: (1) Points are already in the internal domain (e.g., unisolvent nodes) (2) Avoiding unnecessary coordinate transformations that incur floating-point errors.

  • Coordinate transformations are not free numerically. While they are affine, round-trip transformations over many interation may accumulate floating-point errors.

Notes

  • The function calls the concrete implementation of the static method _eval().

See also

_eval

The underlying static method to evaluate the polynomial(s) instance on a set of query points.