newton_diff#
A module for compiled code for polynomial differentiation in the Newton basis.
Notes
The most “fine-grained” functions must be defined first in order for Numba to properly infer the function types.
- minterpy.jit_compiled.newton.diff.create_lut_difference(x, generating_points)[source]#
Create a look-up table containing the differences between a query point and the generating points in each dimension.
The table (matrix) contains \((x_j - p_{i, j})\) where \(p_{i, j}\) is the \(i\)-th generating point of the \(j\)-th dimension.
- Parameters:
x (
numpy.ndarray
) – The query point, a one-dimensional array of lengthm
, wherem
is the spatial dimension of the polynomial.generating_points (
numpy.ndarray
) – Interpolation points for each dimension given as a two-dimensional array of shape(n + 1, m)
, wheren
is the maximum polynomial degree in all dimensions.
- Returns:
A look-up table (LUT) of shape
(n, m)
containing the difference between the query point and the generating points (sizen
) in each dimension (sizem
).- Return type:
Notes
This function is compiled (NJIT-ted) with the help of Numba.
- minterpy.jit_compiled.newton.diff.create_lua_differentiated(combinations, lua_difference, prev_lua_prod, lua_prod)[source]#
Create a differentiated product look-up array (LUA) in one-dimension for a single query point, a given monomial degree, and order of derivative.
Due to chain rule, the differentiated one-dimensional Newton monomials evaluated at a query point consists of sum of products of difference between the query point and the generating points.
The products that appears in the sum of a given degree may be recycled in the computation of the products of the next higher degree to avoid the re-computations from scratch.
Therefore, this function both returns the sum of products of a given degree and modifies in-place the product array to be re-used.
- Parameters:
combinations (
numpy.ndarray
) – The combination of terms to multiply, the information regarding the degree of monomials and the order of derivative is encoded here and does not appear explicitly in this function.lua_difference (
numpy.ndarray
) – The one-dimensional array containing the difference between a query point and the generating points in one dimension.prev_lua_prod (
numpy.ndarray
) – The products of difference from previous computation (degree).lua_prod (
numpy.ndarray
) – The products of difference for the current computation; it is passed to avoid reinitialization.
- Returns:
The sum of products of difference between the query point and the generating points for a differentiated one-dimensional Newton monomial of a given degree and a given order of derivative.
- Return type:
Notes
At the end of the computation, the current products are stored in the previous products array to be used in the next call.
The parameter (array)
lua_prod
is not actually used in the subsequent computation but is passed to avoid re-initialization of the array.This function is compiled (NJIT-ted) with the help of Numba.
- minterpy.jit_compiled.newton.diff.create_lut_differentiated(x, max_exponents, generating_points, derivative_order_along, products_placeholder)[source]#
Create a look-up table of one-dimensional Newton monomials derivatives evaluated on a single query point for all dimensions.
The following symbols are used in the following as shortcuts:
m
: spatial dimensionn
: polynomial degreen_max
: maximum exponent in all dimension
- Parameters:
x (
numpy.ndarray
) – A single query point at which the derivative is evaluated; the values are given in a one-dimensional array of lengthm
.max_exponents (
numpy.ndarray
) – The maximum exponents in the multi-index set for each dimension given as one-dimensional non-negative integer array of lengthm
.generating_points (
numpy.ndarray
) – Interpolation points for each dimension given as a two-dimensional array of shape(m, n + 1)
.derivative_order_along (
numpy.ndarray
) – Specification of the orders of derivative along each dimension given as a one-dimensional non-negative integer array of lengthm
. For example, the arraynp.array([2, 3, 1])
specifies the 2nd-order, 3rd-order, and 1st-order derivatives along the 1st, 2nd, and 3rd dimension, respectively.products_placeholder (
numpy.ndarray
) – A placeholder for a look-up table containing differentiated Newton monomials per dimension; the differentiated monomials are products of difference terms.
- Returns:
The look-up table (LUT) of shape
(n_max, m)
where each column consists of the derivative value of one-dimensional Newton monomials at the (single) query point.- Return type:
Notes
This function is compiled (NJIT-ted) with the help of Numba.
See also
minterpy.jit_compiled.newton.diff.compute_from_lut
Based on the look-up table (LUT) created by the current function, compute the multi-dimensional differentiated Newton monomials on a single query point for all elements in the multi-index set.
- minterpy.jit_compiled.newton.diff.compute_monomials_from_lut(exponents, lut_diff, derivative_order_along, monomials_placeholder)[source]#
Evaluate the derivatives of multi-dimensional Newton monomials evaluated on a query point from a look-up table of differentiated monomial terms.
The following symbols are used in the following as shortcuts:
m
: spatial dimensionN
: number of coefficients or the cardinality of the multi-index setn_max
: maximum exponent in all dimension
- Parameters:
exponents (
numpy.ndarray
) – Set of exponents given as a two-dimensional non-negative integer array of shape(N, m)
.lut_diff (
numpy.ndarray
) – A look-up table that consists of the one-dimensional differentiated Newton monomials evaluated on a single query point. The table is a two-dimensional array of shape(n_max, m)
.derivative_order_along (
numpy.ndarray
) – Specification of the orders of derivative along each dimension given as a one-dimensional non-negative integer array of lengthm
. For example, the arraynp.array([2, 3, 1])
specifies the 2nd-order, 3rd-order, and 1st-order derivatives along the 1st, 2nd, and 3rd dimension, respectively.monomials_placeholder (
numpy.ndarray
) – The placeholder for all the differentiated monomials values evaluated at a single query point. The placeholder is a one-dimensional array of lengthN
.
Notes
This function is compiled (NJIT-ted) with the help of Numba.
- minterpy.jit_compiled.newton.diff.eval_monomials_single_query(x, exponents, max_exponents, generating_points, derivative_order_along, products_placeholder, monomials_placeholder)[source]#
Evaluate the derivative of a Newton poly(s) on a single query point.
The following symbols are used in the subsequent description as shortcuts:
m
: spatial dimensionn
: polynomial degreeN
: number of coefficients or the cardinality of the multi-index setnp
: number of polynomials (i.e., number of coefficient sets)
- Parameters:
x (
numpy.ndarray
) – A single query point at which the derivative is evaluated; the values are given in a one-dimensional array of lengthm
.exponents (
numpy.ndarray
) – Set of exponents given as a two-dimensional non-negative integer array of shape(N, m)
.max_exponents (
numpy.ndarray
) – The maximum exponent values in each dimension as a one-dimensional array of lengthm
; this is to avoid re-computation.generating_points (
numpy.ndarray
) – Interpolation points for each dimension given as a two-dimensional array of shape(m, n + 1)
.derivative_order_along (
numpy.ndarray
) – Specification of the orders of derivative along each dimension given as a one-dimensional non-negative integer array of lengthm
. For example, the arraynp.array([2, 3, 1])
specifies the 2nd-order, 3rd-order, and 1st-order derivatives along the 1st, 2nd, and 3rd dimension, respectively.products_placeholder (
numpy.ndarray
) – A placeholder for a look-up table containing differentiated Newton monomials per dimension; the differentiated monomials are products of difference terms.monomials_placeholder (
numpy.ndarray
) – The differentiated Newton monomials evaluated on a single query point. The array is of shapeN
.
- Returns:
The value of the derivative at the query point given as a one-dimensional array of length
np
.- Return type:
Notes
This is a direct differentiation and evaluation of Newton monomials on a single query point via chain rule without any transformation to another (e.g., canonical) basis.
This function is compiled (NJIT-ted) with the help of Numba.
See also
minterpy.jit_compiled.newton.diff.eval_multiple_query
Evaluation of the derivative of polynomial(s) in the Newton basis for multiple query points.
- minterpy.jit_compiled.newton.diff.eval_multiple_query(xx, coefficients, exponents, generating_points, derivative_order_along)[source]#
Evaluate the derivative of Newton poly(s) on multiple query points.
The following symbols are used in the subsequent description as shortcuts:
k
: number of query pointsm
: spatial dimensionn
: polynomial degreeN
: number of coefficients or the cardinality of the multi-index setnp
: number of polynomials (i.e., number of coefficient sets)
- Parameters:
xx (
numpy.ndarray
) – The set of query points at which the derivative is evaluated; the values are given in a two-dimensional array of shape(k, m)
.coefficients (
numpy.ndarray
) – The coefficients of the Newton polynomial; the values are given in a two-dimensional array of shape(N, np)
.exponents (
numpy.ndarray
) – Set of exponents given as a two-dimensional non-negative integer array of shape(N, m)
.generating_points (
numpy.ndarray
) – Interpolation points for each dimension given as a two-dimensional array of shape(m, n + 1)
.derivative_order_along (
numpy.ndarray
) – Specification of the orders of derivative along each dimension given as a one-dimensional non-negative integer array of lengthm
. For example, the arraynp.array([2, 3, 1])
specifies the 2nd-order, 3rd-order, and 1st-order derivatives along the 1st, 2nd, and 3rd dimension, respectively.
- Returns:
The value of the derivative at the query point given as a two-dimensional array of shape
(k, np)
.- Return type:
Notes
This is a direct differentiation and evaluation of polynomial(s) in the Newton basis on multiple query points via chain rule without any transformation to another (e.g., canonical) basis.
This function is compiled (NJIT-ted) with the help of Numba.
See also
minterpy.jit_compiled.newton.diff.eval_monomials_single_query
Evaluation of the derivative of monomials in the Newton form for a single query point.
- minterpy.jit_compiled.newton.diff.eval_multiple_query_par(xx, coefficients, exponents, generating_points, derivative_order_along)[source]#
Evaluate the derivative of Newton polynomial(s) on multiple query points in parallel.
The following symbols are used in the subsequent description as shortcuts:
k
: number of query pointsm
: spatial dimensionn
: polynomial degreeN
: number of coefficients or the cardinality of the multi-index setnp
: number of polynomials (i.e., number of coefficient sets)
- Parameters:
xx (
numpy.ndarray
) – The set of query points at which the derivative is evaluated; the values are given in a two-dimensional array of shape(k, m)
.coefficients (
numpy.ndarray
) – The coefficients of the Newton polynomial; the values are given in a two-dimensional array of shape(N, np)
.exponents (
numpy.ndarray
) – Set of exponents given as a two-dimensional non-negative integer array of shape(N, m)
.generating_points (
numpy.ndarray
) – Interpolation points for each dimension given as a two-dimensional array of shape(m, n + 1)
.derivative_order_along (
numpy.ndarray
) – Specification of the orders of derivative along each dimension given as a one-dimensional non-negative integer array of lengthm
. For example, the arraynp.array([2, 3, 1])
specifies the 2nd-order, 3rd-order, and 1st-order derivatives along the 1st, 2nd, and 3rd dimension, respectively.
- Returns:
The value of the derivative at the query point given as a two-dimensional array of shape
(k, np)
.- Return type:
Notes
This is a direct differentiation and evaluation of polynomial in the Newton basis via chain rule without any transformation to another (e.g., canonical) basis.
This function is compiled (NJIT-ted) and executed in parallel with the help of Numba.
See also
minterpy.jit_compiled.newton.diff.eval_monomials_single_query
Evaluation of the derivative of monomials in the Newton form for a single query point.
minterpy.jit_compiled.newton.diff.eval_multiple_query
Evaluation of the derivative of polynomial(s) in the Newton basis for multiple query points on a single CPU.