numpoly.ediff1d¶
- numpoly.ediff1d(ary: numpoly.typing.PolyLike, to_end: Optional[numpoly.typing.PolyLike] = None, to_begin: Optional[numpoly.typing.PolyLike] = None) → numpoly.baseclass.ndpoly[source]¶
Difference between consecutive elements of an array.
- Args:
- ary:
If necessary, will be flattened before the differences are taken.
- to_end:
Polynomial(s) to append at the end of the returned differences.
- to_begin:
Polynomial(s) to prepend at the beginning of the returned differences.
- Return:
The differences. Loosely, this is
ary.flat[1:] - ary.flat[:-1]
.- Example:
>>> poly = numpoly.monomial(4) >>> poly polynomial([1, q0, q0**2, q0**3]) >>> numpoly.ediff1d(poly) polynomial([q0-1, q0**2-q0, q0**3-q0**2]) >>> q0, q1 = numpoly.variable(2) >>> numpoly.ediff1d(poly, to_begin=q0, to_end=[1, q1]) polynomial([q0, q0-1, q0**2-q0, q0**3-q0**2, 1, q1])