---
title: i?amax
description: "实数向量返回最大绝对值的索引值，复数向量返回实部绝对值和虚部绝对值之和的最大值索引值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0023.html
sourcePath: /source/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0023.html
indexId: 3b590176f3c2eba75c7225cb7e57f2f59b22b28185f157c4b62e099ea1ee7dd476
---
# 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 : 4
```
