These subprograms find the position i of the first or last occurrence of a vector element having the minimum absolute value.
You get the position of the first or last occurrence of an element by
specifying positive or negative stride, respectively, for vector
x. Regardless of the stride, the position i is
always relative to the location specified in the calling sequence for vector
x (in argument x).
x | Subprogram |
Short-precision real | ISAMIN |
Long-precision real | IDAMIN |
Fortran | ISAMIN | IDAMIN (n, x, incx) |
C and C++ | isamin | idamin (n, x, incx); |
PL/I | ISAMIN | IDAMIN (n, x, incx); |
If incx >= 0, i is the position of the first occurrence.
If incx < 0, i is the position of the last occurrence.
Returned as: a fullword integer; 0 <= i <= n.
Declare the ISAMIN and IDAMIN functions in your program as returning a fullword integer value.
These subprograms find the first element xk, where k is defined as the smallest index k, such that:
By specifying a positive or negative stride for vector x, the first or last occurrence, respectively, is found in the array. The position i, returned as the value of the function, is always figured relative to the location specified in the calling sequence for vector x (in argument x). Therefore, depending on the stride specified for incx, i has the following values:
See reference [79]. The result is returned as a function value. If n is 0, then 0 is returned as the value of the function.
None
n < 0
This example shows a vector, x, with a stride of 1.
N X INCX | | | IMIN = ISAMIN( 6 , X , 1 ) X = (3.0, 4.0, 1.0, 8.0, 1.0, 3.0)
IMIN = 3
This example shows a vector, x, with a stride greater than 1.
N X INCX | | | IMIN = ISAMIN( 4 , X , 2 ) X = (-3.0, . , -9.0, . , -8.0, . , 3.0)
IMIN = 1
This example shows a vector, x, with a positive stride and two elements with the minimum absolute value. The position of the first occurrence is returned.
N X INCX | | | IMIN = ISAMIN( 4 , X , 2 ) X = (2.0, . , -1.0, . , 4.0, . , 1.0)
IMIN = 2
This example shows a vector, x, with a negative stride and two elements with the minimum absolute value. The position of the last occurrence is returned. Processing begins at element X(7), which is 1.0.
N X INCX | | | IMIN = ISAMIN( 4 , X , -2 ) X = (2.0, . , -1.0, . , 4.0, . , 1.0)
IMIN = 4