# cummax#

ivy.cummax(x, /, *, axis=0, exclusive=False, reverse=False, out=None)[source]#

Return a tuple containing the cumulative maximum of elements of input along the given axis and index location of each maximum value found along the given axis.

Parameters:
• x (Union[Array, NativeArray]) – Input array.

• axis (int) – Axis along which the cumulative maximum is computed. Default is 0. (default: 0)

• exclusive (bool) – Whether to perform cummax exclusively. Default is False. (default: False)

• reverse (bool) – Whether to perform the cummax from last to first element in the selected (default: False) axis. Default is False (from first to last element)

• out (Optional[Array]) – Optional output array, for writing the result to. It must have a shape that the (default: None) inputs broadcast to.

Return type:

Array

Returns:

ret – Array which holds the result of applying cummax at each original array elements along the specified axis.

Examples

With ivy.Array input:

>>> x = ivy.array([-86, -19, 41, 88, -5, 80, 32, 87, -90, -12])
>>> y = ivy.cummax(x, exclusive=False, reverse=False)
>>> print(y)
[ivy.array([-86, -19, 41, 88, 88, 88, 88, 88, 88, 88]),
ivy.array([0, 1, 2, 3, 3, 3, 3, 3, 3, 3])]
>>> x = ivy.array([ 14,  15,  49, -24, -39])
>>> y = ivy.cummax(x, axis=0, exclusive=False, reverse=False)
>>> print(y)
[ivy.array([14, 15, 49, 49, 49]), ivy.array([0, 1, 2, 2, 2])]
>>> x = ivy.array([[ 63,  43, -16,  -4],[ 21,  82,  59,  33]])
>>> ivy.cummax(x, axis=0, reverse=False, dtype='int64', out=x)
>>> print(x)
[ivy.array([[ 63,  43, -16,  -4], [ 63,  82,  59,  33]]),
ivy.array([[0, 0, 0, 0],[0, 1, 1, 1]])]
>>> x = ivy.array([[-36,  83, -81],
...                [ 23,  29,  63],
...                [-83,  85,   2],
...                [ 31,  25, -86],
...                [-10, -52,   0],
...                [ 22,  38,  55],
...                [ 33,  54, -16]])
>>> y = ivy.cummax(x, axis=1, exclusive=True, reverse=False)
>>> print(y)
[ivy.array([[ 0,  0, 83],
[ 0, 23, 29],
[ 0,  0, 85],
[ 0, 31, 31],
[ 0,  0,  0],
[ 0, 22, 38],
[ 0, 33, 54]]), ivy.array([[0, 0, 2],
[0, 1, 2],
[0, 0, 2],
[0, 1, 1],
[0, 0, 0],
[0, 1, 2],
[0, 1, 2]])]
>>> x = ivy.array([73, 15, 47])
>>> ivy.cummax(x, axis=0, reverse=True, exclusive=True)
>>> print(y)
[ivy.array([47, 47,  0]), ivy.array([0, 0, 0])]
>>> x = ivy.array([-47, -14, -67, 15, -23, -45])
>>> ivy.cummax(x, axis=0, reverse=True, exclusive=False)
>>> print(y)
[ivy.array([ 15, 15, 15, 15, -23, -45]), ivy.array([2, 2, 2, 2, 1, 0])]
Array.cummax(self, /, *, axis=0, exclusive=False, reverse=False, out=None)#

ivy.Array instance method variant of ivy.cummax. This method simply wraps the function, and so the docstring for ivy.cummax also applies to this method with minimal changes.

Parameters:
• self (Array) – input array

• axis (int) – int, axis along which to take the cumulative maximum. Default is 0. (default: 0)

• reverse (bool) – Whether to perform the cummax from last to first element in the selected (default: False) axis. Default is False (from first to last element)

• dtype – data type of the returned array. If None, if the default data type corresponding to the data type “kind” (integer or floating-point) of x has a smaller range of values than the data type of x (e.g., x has data type int64 and the default data type is int32, or x has data type uint64 and the default data type is int64), the returned array must have the same data type as x. if x has a floating-point data type, the returned array must have the default floating-point data type. if x has a signed integer data type (e.g., int16), the returned array must have the default integer data type. if x has an unsigned integer data type (e.g., uint16), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is int32, the returned array must have a uint32 data type). If the data type (either specified or resolved) differs from the data type of x, the input array should be cast to the specified data type before computing the product. Default: None.

• out (Optional[Array]) – optional output array, for writing the result to. (default: None)

Return type:

Array

Returns:

• ret – Input array with cumulatively multiplied elements along the specified axis.

• ——–

• >>> x = ivy.array([1, 2, 5, 4, 3])

• >>> y = x.cummax()

• >>> print(y)

• ivy.array([1, 2, 5, 5, 5])

• >>> x = ivy.array([[2, 3], [5, 7], [11, 13]])

• >>> y = ivy.zeros((3, 2), dtype=”int32”)

• >>> x.cummax(axis=1, reverse=True, out=y)

• >>> print(y)

• ivy.array([[ 3, 3], – [ 7, 7], [13, 13]])

Container.cummax(self, /, *, axis=0, exclusive=True, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)#

ivy.Container instance method variant of ivy.cummax. This method simply wraps the function, and so the docstring for ivy.cummax also applies to this method with minimal changes.

Parameters:
• self (Container) – Input container to cummax at leaves.

• axis (int) – Axis along which the cumulative product is computed. Default is 0. (default: 0)

• exclusive (bool) – Whether to exclude the first element of the input array. (default: True) Default is False.

• key_chains (Optional[Union[List[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

• to_apply (bool) – If True, the method will be applied to key_chains, otherwise key_chains (default: True) will be skipped. Default is True.

• prune_unapplied (bool) – Whether to prune key_chains for which the function was not applied. (default: False) Default is False.

• map_sequences (bool) – Whether to also map method to sequences (lists, tuples). (default: False) Default is False.

• dtype (Optional[Union[Dtype, NativeDtype]]) – Data type of the returned array. Default is None. (default: None)

• out (Optional[Container]) – Optional output container. Default is None. (default: None)

Return type:

Container

Returns:

• ret – Containers with arrays cummax at leaves along specified axis.

• ——–

• With one ivy.Container instances

• >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))

• >>> y = x.cummax(axis=0)

• >>> print(y)

• { – a: ivy.array([1, 2, 3]), b: ivy.array([4, 5, 6])

• }

• >>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]), – b=ivy.array([[3, 4], [4, 5], [5, 6]]))

• >>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))

• >>> x.cummax(axis=1, exclusive=True, out=y)

• {

a: ivy.array([[2., 3.],

[5., 7.], [11., 13.]]),

b: ivy.array([[3., 4.],

[4., 5.], [5., 6.]])

• }