ISAMAX and IDAMAX find the position i of the first or last occurrence of a vector element having the maximum absolute value. ICAMAX and IZAMAX find the position i of the first or last occurrence of a vector element having the largest sum of the absolute values of the real and imaginary parts of the vector elements.
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 | ISAMAX |
Long-precision real | IDAMAX |
Short-precision complex | ICAMAX |
Long-precision complex | IZAMAX |
Fortran | ISAMAX | IDAMAX | ICAMAX | IZAMAX (n, x, incx) |
C and C++ | isamax | idamax | icamax | izamax (n, x, incx); |
PL/I | ISAMAX | IDAMAX | ICAMAX | IZAMAX (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 ISAMAX, IDAMAX, ICAMAX, and IZAMAX functions in your program as returning a fullword integer value.
ISAMAX and IDAMAX find the first element xk, where k is defined as the smallest index k, such that:
ICAMAX and IZAMAX 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 | | | IMAX = ISAMAX( 9 , X , 1 ) X = (1.0, 2.0, 7.0, -8.0, -5.0, -10.0, -9.0, 10.0, 6.0)
IMAX = 6
This example shows a vector, x, with a stride greater than 1.
N X INCX | | | IMAX = ISAMAX( 5 , X , 2 ) X = (1.0, . , 7.0, . , -5.0, . , -9.0, . , 6.0)
IMAX = 4
This example shows a vector, x, with a stride of 0.
N X INCX | | | IMAX = ISAMAX( 9 , X , 0 ) X = (1.0, . , . , . , . , . , . , . , .)
IMAX = 1
This example shows a vector, x, with a negative stride. Processing begins at element X(15), which is 2.0.
N X INCX | | | IMAX = ISAMAX( 8 , X , -2 ) X = (3.0, . , 5.0, . , -8.0, . , 6.0, . , 8.0, . , 4.0, . , 8.0, . , 2.0)
IMAX = 7
This example shows a vector, x, containing complex numbers and having a stride of 1.
N X INCX | | | IMAX = ICAMAX( 5 , X , 1 ) X = ((9.0 , 2.0) , (7.0 , -8.0) , (-5.0 , -10.0) , (-4.0 , 10.0), (6.0 , 3.0))
IMAX = 2