fmax#
- ivy.fmax(x1, x2, /, *, out=None)[source]#
Compute the element-wise maximums of two arrays. Differs from ivy.maximum in the case where one of the elements is NaN. ivy.maximum returns the NaN element while ivy.fmax returns the non-NaN element.
- Parameters:
- Return type:
Union
[Array
,NativeArray
]- Returns:
ret – Array with element-wise maximums.
Examples
>>> x1 = ivy.array([2, 3, 4]) >>> x2 = ivy.array([1, 5, 2]) >>> ivy.fmax(x1, x2) ivy.array([ 2., 5., 4.])
>>> x1 = ivy.array([ivy.nan, 0, ivy.nan]) >>> x2 = ivy.array([0, ivy.nan, ivy.nan]) >>> ivy.fmax(x1, x2) ivy.array([ 0., 0., nan])
- Array.fmax(self, x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.fmax. This method simply wraps the function, and so the docstring for ivy.fmax also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.x2 (
Array
) – Second input arrayout (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
Array
- Returns:
ret – Array with element-wise maximums.
Examples
>>> x1 = ivy.array([2, 3, 4]) >>> x2 = ivy.array([1, 5, 2]) >>> ivy.fmax(x1, x2) ivy.array([ 2., 5., 4.])
>>> x1 = ivy.array([ivy.nan, 0, ivy.nan]) >>> x2 = ivy.array([0, ivy.nan, ivy.nan]) >>> x1.fmax(x2) ivy.array([ 0, 0, nan])
- Container.fmax(self, x2, /, *, out=None)[source]#
ivy.Container instance method variant of ivy.fmax. This method simply wraps the function, and so the docstring for ivy.fmax also applies to this method with minimal changes.
- Parameters:
self (
Container
) – container with the first input arrays.x2 (
Container
) – container with the second input arraysout (
Optional
[Container
], default:None
) – optional output container, for writing the result to.
- Return type:
Container
- Returns:
ret – Container including arrays with element-wise maximums.
Examples
>>> x1 = ivy.Container(a=ivy.array([2, 3, 4]), b=ivy.array([ivy.nan, 0, ivy.nan])) >>> x2 = ivy.Container(a=ivy.array([1, 5, 2]), b=ivy.array([0, ivy.nan, ivy.nan])) >>> x1.fmax(x2) { a: ivy.array([ 2., 5., 4.]) b: ivy.array([ 0, 0, nan]) }