larray.minimum
- larray.minimum(x1, x2, out=None, dtype=None)
Element-wise minimum of array elements.
Compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.
- Parameters
- x1, x2Array
The arrays holding the elements to be compared.
- outArray, optional
An array into which the result is stored.
- dtypedata-type, optional
Overrides the dtype of the output array.
- Returns
- yArray or scalar
The minimum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
See also
maximum
Element-wise maximum of two arrays, propagates NaNs.
Notes
The minimum is equivalent to
where(x1 <= x2, x1, x2)
when neither x1 nor x2 are NaNs, but it is faster.Examples
>>> from larray import Array >>> arr1 = Array([[10, 7, 5, 9], ... [5, 8, 3, 7]], "a=a0,a1;b=b0..b3") >>> arr2 = Array([[6, 2, 9, 0], ... [9, 10, 5, 6]], "a=a0,a1;b=b0..b3") >>> arr1 a\b b0 b1 b2 b3 a0 10 7 5 9 a1 5 8 3 7 >>> arr2 a\b b0 b1 b2 b3 a0 6 2 9 0 a1 9 10 5 6
>>> minimum(arr1, arr2) a\b b0 b1 b2 b3 a0 6 2 5 0 a1 5 8 3 6
With broadcasting
>>> arr2['a0'] b b0 b1 b2 b3 6 2 9 0 >>> minimum(arr1, arr2['a0']) a\b b0 b1 b2 b3 a0 6 2 5 0 a1 5 2 3 0