polynomials_on_simplices.polynomial.polynomials_simplex_base module¶
Abstract base class and basic functionality for polynomials defined on a simplex.
-
class
PolynomialSimplexBase
(coeff, vertices, r=None)[source]¶ Bases:
polynomials_on_simplices.polynomial.polynomials_base.PolynomialBase
,abc.ABC
Abstract base class for a polynomial defined on an m-dimensional simplex T.
Parameters: - coeff – Coefficients for the polynomial in the chosen basis for \(\mathcal{P}_r (T)\)
(see
basis()
). If p is expressed in the chosen basis \(\{ b_{\nu, r} \}\) as \(p(x) = \sum_{\nu} a_{\nu} b_{\nu, r}(x)\) then \(\text{coeff}[i] = a_{\nu(i)}\), where \(\nu(i)\) is the i:th multi-index in the sequence of all multi-indices of dimension m with norm \(\leq r\) (seepolynomials_on_simplices.algebra.multiindex.generate()
function). Array of scalars for a scalar valued polynomial (n = 1) and array of n-dimensional vectors for a vector valued polynomial (\(n \geq 2\)). - vertices – Vertices of the simplex T ((m + 1) x m matrix where row i contains the i:th vertex of the simplex).
- r (int) – Degree of the polynomial space. Optional, will be inferred from the number of polynomial coefficients if not specified.
-
multiply_with_constant
(c)[source]¶ Multiplication of this polynomial with a constant scalar or a vector (only for a scalar valued polynomial), self * c.
Parameters: c (Union[float, Numpy array
]) – Scalar or vector we should multiply this polynomial with.Returns: Product of this polynomial with the constant. Return type: Instance of self.__class__
- coeff – Coefficients for the polynomial in the chosen basis for \(\mathcal{P}_r (T)\)
(see
-
polynomials_equal_on_simplex
(p1, p2, r, vertices, rel_tol=1e-09, abs_tol=1e-07)[source]¶ Check if two polynomials p1 and p2 are approximately equal by comparing their values on a given n-dimensional simplex T.
For scalar valued polynomials, the two polynomials are considered equal if
math.isclose(p1(xi), p2(xi), rel_tol=rel_tol, abs_tol=abs_tol)
is true for a set of random points \(\{ x_i \}_{i = 0}^{d - 1}\) in the given n-dimensional simplex T, where \(d\) is the dimension of the polynomial space p1 and p2 belongs to (as given by the
get_dimension()
function).For vector valued polynomials the same check is done component wise.
Parameters: - p1 (Callable p1(x)) – First polynomial.
- p2 (Callable p2(x)) – Second polynomial.
- r (int) – Degree of the polynomials.
- vertices – Vertices of the simplex T ((n + 1) x n matrix where row i contains the i:th vertex of the simplex).
- rel_tol (float) – Tolerance for the relative error. See
math.isclose
for details. - abs_tol (float) – Tolerance for the absolute error. See
math.isclose
for details.
Returns: Whether or not the two polynomials are approximately equal.
Return type: