i?amax
Return the index of the maximum absolute value of a real number vector, and return the index of the maximum sum of the absolute values of the real part and the imaginary part of a complex number vector.
Interface Definition
C interface:
CBLAS_INDEX cblas_isamax(const BLASINT n, const float *x, const BLASINT incx);
CBLAS_INDEX cblas_idamax(const BLASINT n, const double *x, const BLASINT incx);
CBLAS_INDEX cblas_icamax(const BLASINT n, const void *x, const BLASINT incx);
CBLAS_INDEX cblas_izamax(const BLASINT n, const void *x, const BLASINT incx);
Fortran interface:
INDEX = ISAMAX(N, X, INCX)
INDEX = IDAMAX(N, X, INCX)
INDEX = ICAMAX(N, X, INCX)
INDEX = IZAMAX(N, X, INCX)
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
n |
Integer |
Number of elements in the x vector. |
Input |
x |
|
Vector x. The vector size is at least (1+(n-1)*abs(incX)). |
Input |
incx |
Integer |
Increment for the elements of vector x. |
Input |
Return Value
For a real number vector, the index of the maximum absolute value is returned. For a complex number vector, the index of the maximum sum of the absolute values of the real part and the imaginary part is returned. It is of the CBLAS_INDEX type.
Dependency
#include "kblas.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 | int n = 5, incx = 1; int res; /** * X: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647 */ float x[5] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647}; res = cblas_isamax(n, x, incx); /** * Output: 4 */ |
Fortran interface:
INTEGER :: N=5
INTEGER :: INCX=1
INTEGER :: INDEX
REAL(4) :: X(5)
DATA X/0.340188, -0.105617, 0.283099, 0.298440, 0.411647/
EXTERNAL ISAMAX
INDEX=ISAMAX(N, X, INCX)
* Output : 5
C uses 0-based indexing, but Fortran uses 1-based indexing. In this Fortran example, the maximum absolute value is the fifth element, so the returned index is 5.