numpoly.polynomial_from_attributes

numpoly.polynomial_from_attributes(exponents: Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], coefficients: Sequence[Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]], names: Union[None, str, Tuple[str, ...], numpoly.baseclass.ndpoly] = None, dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None, allocation: Optional[int] = None, retain_coefficients: Optional[bool] = None, retain_names: Optional[bool] = None)numpoly.baseclass.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)