numpoly.ndpoly.from_attributes#

static ndpoly.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 indeterminants names, either as string names or as simple polynomials. Must correspond to the exponents by having length 1 or D. If omitted, use numpoly.get_options()["default_varname"].

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:

Polynomials with attributes defined by input.

Example:
>>> numpoly.ndpoly.from_attributes(
...     exponents=[[0]], coefficients=[4])
polynomial(4)
>>> numpoly.ndpoly.from_attributes(
...     exponents=[[1]], coefficients=[[1, 2, 3]])
polynomial([q0, 2*q0, 3*q0])
>>> numpoly.ndpoly.from_attributes(
...     exponents=[[0], [1]], coefficients=[[0, 1], [1, 1]])
polynomial([q0, q0+1])
>>> numpoly.ndpoly.from_attributes(
...     exponents=[[0, 1], [1, 1]], coefficients=[[0, 1], [1, 1]])
polynomial([q0*q1, q0*q1+q1])