numpoly.polynomial¶
- numpoly.polynomial(poly_like: numpoly.typing.PolyLike = 0, 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) → numpoly.baseclass.ndpoly[source]¶
Attempt to cast an object into a polynomial array.
Supports various casting options:
dict
Keys are tuples that represent polynomial exponents, and values are numpy arrays that represents polynomial coefficients.
numpoly.ndpoly
Copy of the polynomial.
numpy.ndarray
Constant term polynomial.
sympy.Poly
Convert polynomial from
sympy
tonumpoly
, if possible.Iterable
Multivariate array construction.
structured array
Assumes that the input are raw polynomial core and can be used to construct a polynomial without changing the data. Used for developer convenience.
- Args:
- poly_like:
Input to be converted to a numpoly.ndpoly polynomial type.
- names:
Name of the indeterminant variables. If possible to infer from
poly_like
, this argument will be ignored.- dtype:
Data type used for the polynomial coefficients.
- allocation:
The maximum number of polynomial exponents. If omitted, use length of exponents for allocation.
- Return:
Polynomial based on input
poly_like
.- Example:
>>> numpoly.polynomial({(1,): 1}) polynomial(q0) >>> q0, q1 = numpoly.variable(2) >>> q0**2+q0*q1+2 polynomial(q0*q1+q0**2+2) >>> -3*q0+q0**2+q1 polynomial(q0**2+q1-3*q0) >>> numpoly.polynomial([q0*q1, q0, q1]) polynomial([q0*q1, q0, q1]) >>> numpoly.polynomial([1, 2, 3]) polynomial([1, 2, 3]) >>> import sympy >>> q0_, q1_ = sympy.symbols("q0, q1") >>> numpoly.polynomial(3*q0_*q1_-4+q0_**5) polynomial(q0**5+3*q0*q1-4)