---
title: ?dotu
description: "计算两个复数向量的点积。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0021.html
sourcePath: /source/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0021.html
indexId: f7d961f5fb2e92246087f282d80300d2b3a5596c5f11c9b3f458854b2c5d1aed76
---
# ?dotu

计算两个复数向量的点积。

#### 接口定义

C interface：

float _Complex cblas_cdotu(const BLASINT n, const void *x, const BLASINT incx, const void *y, const BLASINT incy);

void cblas_cdotu_sub(const BLASINT n, const void *x, const BLASINT incx, const void *y, const BLASINT incy, void *ret);

double _Complex cblas_zdotu(const BLASINT n, const void *x, const BLASINT incx, const void *y, const BLASINT incy)；

void cblas_zdotu_sub(const BLASINT n, const void *x, const BLASINT incx, const void *y, const BLASINT incy, void *ret);

Fortran interface：

RES = CDOTU(N, CX, INCX, CY, INCY)

RES = ZDOTU(N, CX, INCX, CY, INCY)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| n | 整型数。 | 表示x、y向量的元素个数。 | 输入 |
| x | 在cdotu中是单精度复数类型。 在zdotu中是双精度复数类型。 | 向量x，向量规模至少是(1+(n\-1)\*abs(incX))。 | 输入 |
| incx | 整型数。 | 表示x中向量元素的增量。 | 输入 |
| y | 在cdotu中是单精度复数类型。 在zdotu中是双精度复数类型。 | 向量y，向量规模至少是(1+(n\-1)\*abs(incy))。 | 输入 |
| incy | 整型数 | 表示y向量增长步长。 | 输入 |
| ret | 在cdotc中是单精度复数类型。 在zdotc中是双精度复数类型。 | 计算结果。 | 输出 |


#### 依赖

#include "kblas.h"


#### 示例

C interface：

```
int n = 5, incx = 1, incy = 1;
/**
*    X:
*      0.340188, -0.105617, 0.283099, 0.298440, 0.411647,
*      -0.302449, -0.164777, 0.268230, -0.222225, 0.053970
*    Y:
*      -0.022603, 0.128871, -0.135216, 0.013401, 0.452230,
*      0.416195, 0.135712, 0.217297, -0.358397, 0.106969
*/
float x[10] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647,
-0.302449, -0.164777, 0.268230, -0.222225, 0.053970};
float y[10] = {-0.022603, 0.128871, -0.135216, 0.013401, 0.452230,
0.416195, 0.135712, 0.217297, -0.358397, 0.106969};
float _Complex res = cblas_cdotu(n, x, incx, y, incy);
/**
*    Output:  0.268904 0.001699
*
*/
```

Fortran interface：

```
COMPLEX(4) :: RES
INTEGER :: N=5
INTEGER :: INCX=1
INTEGER :: INCY=1
COMPLEX(4) :: X(5)
DATA CX/(0.340188, -0.105617), (0.283099, 0.298440),
$        (0.411647, -0.302449), (-0.164777, 0.268230),
$        (-0.222225, 0.053970)/
COMPLEX(4) :: Y(5)
DATA CY/(-0.022603, 0.128871), (-0.135216, 0.013401),
$        (0.452230, 0.416195), (0.135712, 0.217297),
$        (-0.358397, 0.106969)/
EXTERNAL CDOTU
RES=CDOTU(N, CX, INCX, CY, INCY)
*     Output : (0.268904 0.001699)
```
