This class represents a mutivariate polynomial
with a Numpy N-dimensional array, a numpy.ndarray.
The array holds the coefficients of the polynomial in
the natural, little-endian [1] fashion.
The get-index method which returns the coefficients of the
polynomial by their (zero-based) indices. For the polynomial
\(p(x,y) = 2x^2 + y + 3\) we would access the coefficient of
\(x^2\) with p[2] or p[2,0] or p[2,0,0] …
(trailing zeros are ignored), the coefficient of
\(y\) with p[0,1], p[0,1,0], … and the constant
term with p[()], p[0], p[0,0], … (Note that p[]
is a Python syntax error). Indices outside the shape of the
underlying NumPy array will return zero (without changing shape of
the array).
Note that slice indexing will not work here, p[1:3] will
result in an error: instead use the
coef()
method to access the underlying array, p.coef[1:3].
Return the maximal degree of each of the variables of
the polynomial as a tuple of integers. For a constant
(including a zero) polynomial, returns the empty tuple.
The (total, homogeneous) degree, the maximal sum of the
monomial degrees of monomials with nonzero coefficients.
Returns \(-1\) for the zero polynomial, \(0\) for
a constant polynomial.
Evaluate the polynomial at the points given by args.
There should be as many arguments as the polynomial
has variables. The argument can be numbers, or arrays
(all of the same shape).
Differentiate polynomial. The integer arguments
should indicate the number to times to differentiate
with respect to the corresponding polynomial variable,
hence p.diff(0,1,1) would correspond to
\(\partial^2 p / \partial y \partial z\).
Indefinite integral of polynomial. The arguments are as for
diff(),
but an optional dtype keyword argument can be appended to
specify the dtype of the output polynomial.
Maximum modulus of the polynomial on the unit ball, this
method is only available if the maxmodnb package
is installed (and that is in an early stage of development).
Returns a list of 2-element tuples, for each the first
being a (monomial) index, the second the corresponding
coefficient. The indices have trailing zeros, so the return
value for the polynomial
\(p(x,y) = 2 + 3x + 4y\) would be
[((0,0),2),((1,0),3),((0,1),4)].
Create a polynomial from a polynomial of any subclass; this is
used internally by the
__init__() constructor, but
may be useful for direct application.
Returns the
Lehmer polynomial
(univariate of degree 10), notable as the polynomial
whose Mahler measure is the smallest known measure larger than
1 of a polynomial with integer coefficients.
Returns the n-th
Rudin-Shapiro polynomial
(univariate, of degree \(2^n-1\)). These dense polynomials have
coefficients which are \(\pm1\) and have a small
maximum modulus on the unit disk.
The k-th Wendland polynomial \(p_{d, k}(r)\) for dimension
d, this univariate polynomial of degree
\(\lfloor d/2 \rfloor + 3k + 1\) is used to define a compactly
supported radial basis function with continuous derivatives up to
order \(2k\). The calculation of the coefficients uses the
recursive method described by Wendland in [2].
Library code for the serious work on the arrays is to be found
in the module mvpoly.utils.cube, it is not expected
that these functions will be called directly.
Integrate the multivatiate polynomial whose coefficients
are given by the numpy.array argument p and as
many times as given by the non-negative tuple d. The
final argument, dtype, specifies the data-type of the
output; if this is an integer type then the results may
be incorrect (due to integer division) so a warning will
be issued.
Differentiate the multivatiate polynomial whose coefficients
are given by the numpy.array argument p and as
many times as given by the non-negative tuple d.
Given a shape tuple shp = (s1, s2, … sm), a
specified dimension n and a vector v with sn elements,
this function returns a numpy.ndarry which has
v replicated in the n-th dimension. Thus it it rather
like the n-th return value of numpy.meshgrid(), but
without constructing the other return values.
Add the numpy.ndarry arguments which may be of
differing dimensions and sizes, return a numpy.ndarray.
This code is largely based on this Bi Rico’s answer to this
Stack Exchange question.
The keyword argument dtype is required, the summands are cast
to this type.
Evaluate polynomial with coefficients array p at
all of the points given by the equal-sized arrays
args = X, Y, …, (as many as the dimension
of p). Returns a numpy.ndarray of the same size.