---
title: kml_sparse_?doti
description: "实数域的点积（欧几里得空间）。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0074.html
sourcePath: /source/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0074.html
indexId: a692555fcf82fa5c3fb033e0d02001640339e9fba0a655fb866673c34116bb5c74
---
# kml_sparse_?doti

实数域的点积（欧几里得空间）。

res = x[0] * y[indx[0]] + x[1] * y[indx[1]] + ... + x[nz-1] * y[indx[nz-1]]

#### 接口定义

C interface：

kml_sparse_status_t kml_sparse_sdoti(const KML_INT nz, const float *x,const KML_INT *indx, const float *y, float *doti);

kml_sparse_status_t kml_sparse_ddoti(const KML_INT nz, const double *x,const KML_INT *indx, const double *y, double *doti);

Fortran interface：

RES = KML_SPARSE_SDOTI(NZ, X, INDX, Y, DOTI);

RES = KML_SPARSE_DDOTI(NZ, X, INDX, Y, DOTI);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| nz | 整型数 | x及indx数组中元素的个数。 | 输入 |
| x | 在sdoti中，x是单精度浮点类型数组。 在ddoti中，x是双精度浮点类型数组。 | 存储非零元素的数组x，大于或等于nz。 | 输入 |
| indx | 整型数组 | indx[i]表示x数组中第i个元素在稠密向量中的序列号，数组大于或等于nz。 | 输入 |
| y | 在sdoti中，y是单精度浮点类型数组。 在ddoti中，y是双精度浮点类型数组。 | 数组y，大于或等于max(indx[i])。 | 输入 |
| doti | 在sdoti中，doti是单精度浮点类型。 在ddoti中，doti是双精度浮点类型。 | x与y的点积。 | 输入/输出 |


#### 返回值

函数执行状态，枚举类型kml_sparse_status_t。


#### 依赖

C: "kspblas.h"

Fortran: "kspblas.f03"


#### 示例

C interface：

```
KML_INT nz = 2;
float doti = 0;
KML_INT indx[2] = {1, 2};
float x[2] = {1, 3};
float y[4] = {-1, 1, 5, 3};
kml_sparse_status_t status = kml_sparse_sdoti(nz, x, indx, y, &doti);
/*
*  Output doti:
*    16.000000
*/
```

Fortran interface：

```
INTEGER(C_INT) :: NZ = 2
REAL(C_FLOAT), TARGET :: DOTI
TYPE(C_PTR) :: PDOTI
INTEGER(C_INT) :: STATUS
INTEGER(C_INT) INDX(2)
REAL(C_FLOAT) X(2)
REAL(C_FLOAT) Y(2)
DATA INDX/1, 2/
DATA X/1, 3/
DATA Y/-1, 1, 5, 3/
PDOTI = C_LOC(DOTI)
STATUS = KML_SPARSE_SDOTI(NZ, X, INDX, Y, PDOTI)
/*
*  OUTPUT DOTI:
*    16.000000
*/
```
