numpoly.polynomial_from_attributes#

numpoly.polynomial_from_attributes(exponents: ArrayLike, coefficients: Sequence[ArrayLike], names: None | str | Tuple[str, ...] | ndpoly = None, dtype: DTypeLike | None = None, allocation: int | None = None, retain_coefficients: bool | None = None, retain_names: bool | None = None) ndpoly[source]#

Construct polynomial from polynomial attributes.

Args:
exponents:

The exponents in an integer array with shape (N, D), where N is the number of terms in the polynomial sum and D is the number of dimensions.

coefficients:

The polynomial coefficients. Must correspond to exponents by having the same length N.

names:

The indeterminant names, either as string names or as simple polynomials. Must correspond to the exponents by having length D.

dtype:

The data type of the polynomial. If omitted, extract from coefficients.

allocation:

The maximum number of polynomial exponents. If omitted, use length of exponents for allocation.

retain_coefficients:

Do not remove redundant coefficients. If omitted use global defaults.

retain_names:

Do not remove redundant names. If omitted use global defaults.

Return:

Polynomial array with attributes determined by the input.

Example:
>>> numpoly.ndpoly.from_attributes(
...     exponents=[(0,), (1,)],
...     coefficients=[[1, 0], [0, 1]],
...     names="q4",
... )
polynomial([1, q4])
>>> numpoly.ndpoly.from_attributes(
...     exponents=[(0, 0, 0), (1, 1, 2)],
...     coefficients=[4, -1],
...     names=("q2", "q4", "q10"),
... )
polynomial(-q2*q4*q10**2+4)
>>> numpoly.ndpoly.from_attributes(
...     exponents=[(0,)],
...     coefficients=[0],
... )
polynomial(0)