chaospy.cumsum¶
- chaospy.cumsum(a: 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]], numpoly.baseclass.ndpoly], axis: Optional[int] = 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, out: Optional[numpoly.baseclass.ndpoly] = None) numpoly.baseclass.ndpoly [source]¶
Return the cumulative sum of the elements along a given axis.
- Args:
- a:
Input array.
- axis:
Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.
- dtype:
Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.
- out:
Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary.
- Args:
A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.
- Example:
>>> q0, q1 = numpoly.variable(2) >>> poly = numpoly.polynomial([[1, q0, 3], [4, 5, q1]]) >>> poly polynomial([[1, q0, 3], [4, 5, q1]]) >>> numpoly.cumsum(poly) polynomial([1, q0+1, q0+4, q0+8, q0+13, q1+q0+13]) >>> numpoly.cumsum(poly, dtype=float, axis=1) polynomial([[1.0, q0+1.0, q0+4.0], [4.0, 9.0, q1+9.0]]) >>> numpoly.cumsum(poly, axis=0) polynomial([[1, q0, 3], [5, q0+5, q1+3]])