---
title: i?amax
description: "实数向量返回最大绝对值的索引值，复数向量返回实部绝对值和虚部绝对值之和的最大值索引值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0609.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0609.html
indexId: a00808e739e548034dceed101c684bf96cb1a199535f7fe38ebaf6d9ca1f941261
---
# i?amax

实数向量返回最大绝对值的索引值，复数向量返回实部绝对值和虚部绝对值之和的最大值索引值。

#### 接口定义

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)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| n | 整型数 | 表示x向量的元素个数。 | 输入 |
| x | 在isamax中是双精度浮点类型。 在idamax中是单精度浮点类型。 在icamax中是单精度复数类型。 在izamax中是双精度复数类型。 | 向量x，向量规模至少是(1+(n\-1)\*abs(incX))。 | 输入 |
| incx | 整型数 | 表示x向量增长步长。 | 输入 |


#### 返回值

实数向量返回最大绝对值的索引值，复数向量返回实部绝对值和虚部绝对值之和的最大值索引值。CBLAS_INDEX类型。


#### 依赖

#include "kblas.h"


#### 示例

C interface：

```
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语言中，index是从0开始，在Fortran语言中，index是从1开始，因此在该Fortran用例中最大绝对值是第五个元素，所以会返回最大绝对值的索引值为5。
