numpoly.ndpoly.from_attributes¶
- static ndpoly.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, ...], 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) → ndpoly[source]¶
Construct polynomial from polynomial attributes.
- Args:
- exponents:
The exponents in an integer array with shape
(N, D)
, whereN
is the number of terms in the polynomial sum andD
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, usenumpoly.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])