numpoly.polynomial#
- numpoly.polynomial(poly_like: numpoly.typing.PolyLike = 0, names: None | str | Tuple[str, ...] | ndpoly = None, dtype: DTypeLike | None = None, allocation: int | None = None) ndpoly[source]#
Attempt to cast an object into a polynomial array.
Supports various casting options:
dictKeys are tuples that represent polynomial exponents, and values are numpy arrays that represents polynomial coefficients.
numpoly.ndpolyCopy of the polynomial.
numpy.ndarrayConstant term polynomial.
sympy.PolyConvert polynomial from
sympytonumpoly, if possible.IterableMultivariate 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)