minterpy.interpolation#
A top-level module with interfaces to conveniently create interpolants.
The main purpose of Minterpy is to interpolate given functions provided as
Python Callables.
This top-level module provides a convenient function named interpolate
,
which outputs a Callable of the type Interpolant
.
This represents the given function as a multidimensional (Newton) polynomial.
Moreover, it is also possible to construct an Interpolator
instance.
This object precomputes and caches all the necessary ingredients
for the interpolation of any functions.
Function / Class |
Description |
---|---|
Interpolate a given function |
|
Class that represents an interpolated function |
|
Class that represents interpolators for given functions |
- class minterpy.interpolation.Interpolator(spatial_dimension, poly_degree, lp_degree)[source]#
The construction class for interpolation.
Data type which contains all relevant parts for interpolation and caches them.
- spatial_dimension#
- Type:
dimension of the domain space.
- poly_degree#
- Type:
degree of the interpolation polynomials
- lp_degree#
- Type:
degree of the \(l_p\) norm used to determine the poly_degree.
- multi_index#
- Type:
lexicographically complete multi index set build from (spatial_dimension, poly_degree, lp_degree).
- grid#
- Type:
Grid
instance build from multi_index.
- class minterpy.interpolation.Interpolant(fct, interpolator)[source]#
Data type representing the result of an interpolation.
Instances of this class can be used as functions, which interpolate a given function. Users who do not want to learn anything about neither polynomial interpolation nor bases in multivariate polynomial bases may use the instances of this class just as an interpolative representant of their function, which they can evaluate. (Other properties are conceivable too)
- Parameters:
fct (Callable)
interpolator (Interpolator)
- fct#
- Type:
Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an
np.ndarray
with shapearr.shape == (N,spatial_dimension)
, the signature needs to befct(arr) -> res
, whereres
is annp.ndarray
with shape(N,)
.
- interpolator#
- Type:
Instance of
Interpolator
, which represents the interpolation scheme to be used.
- classmethod from_degree(fct, spatial_dimension, poly_degree, lp_degree)[source]#
Custom constructor of an interpolant using dimensionality and degree parameter.
- Parameters:
fct (Callable) – Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an
np.ndarray
with shapearr.shape == (N,spatial_dimension)
, the signature needs to befct(arr) -> res
, whereres
is annp.ndarray
with shape(N,)
.spatial_dimension (int) – dimension of the domain space.
poly_degree (int) – degree of the interpolation polynomials
lp_degree (int) – degree of the \(l_p\) norm used to determine the
poly_degree
.
- Returns:
The interpolant of
fct
using the default interpolator build from(spatial_dimension, poly_degree, lp_degree)
.- Return type:
- property spatial_dimension#
Dimension of the domain space the interpolation polynomial lives on.
This is the propagated attribute from
self.interpolator
.- Return type:
- property poly_degree#
Degree of the interpolation polynomial.
This is the propagated attribute from
self.interpolator
.- Return type:
- property lp_degree#
Degree of the \(l_p\) norm.
This is the propagated attribute from
self.interpolator
.- Return type:
- property lagrange_coeffs#
Return the Lagrange coefficients of the interpolating polynomial.
- minterpy.interpolation.interpolate(fct, spatial_dimension, poly_degree, lp_degree=DEFAULT_LP_DEG)[source]#
Interpolate a given function.
Return an interpolant, which represents the given function on the domain \([-1, 1]^d\), where \(d\) is the dimension of the domain space.
- Parameters:
fct (Callable) – Function to be interpolated. Needs to be (numpy) universal function which shall be interpolated. If arr is an
np.ndarray
with shapearr.shape == (N,spatial_dimension)
, the signature needs to befct(arr) -> res
, whereres
is annp.ndarray
with shape(N,)
.spatial_dimension (int) – dimension of the domain space.
poly_degree (int) – degree of the interpolation polynomials
lp_degree (int) – degree of the \(l_p\) norm used to determine the poly_degree.
- Returns:
The interpolant of
fct
using the default interpolator build from(spatial_dimension, poly_degree, lp_degree)
.- Return type: