---
title: ?sdot
description: "扩展精度点积，输入为单精度，以双精度计算，sdsdot输出单精度，dsdot输出双精度。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0608.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0608.html
indexId: eb088937bc5a3989c16b8e0d5cbd4a4c847f75a41112fda8f0cb5a8147c8a80b61
---
# ?sdot

扩展精度点积，输入为单精度，以双精度计算，sdsdot输出单精度，dsdot输出双精度。

#### 接口定义

C interface：

float cblas_sdsdot(const BLASINT n, const float alpha, const float *x, const BLASINT incx, const float *y, const BLASINT incy);

double cblas_dsdot(const BLASINT n, const float *x, const BLASINT incx, const float *y, const BLASINT incy);

Fortran interface：

RES = SDSDOT(N, ALPHA, SX, INCX, SY, INCY)

RES = DSDOT(N, SX, INCX, SY, INCY)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| n | 整型数 | 表示x、y向量的元素个数。 | 输入 |
| alpha | 在sdsdot中是单精度类型。 | 单精度标量，加到点积中返回。 | 输入 |
| x | 单精度复数类型 | 向量x，向量规模至少是(1+(n\-1)\*abs(incX))。 | 输入 |
| incx | 整型数 | 表示x中向量元素的增量。 | 输入 |
| y | 单精度复数类型 | 向量y，向量规模至少是(1+(n\-1)\*abs(incy))。 | 输入 |
| incy | 整型数 | 表示y向量增长步长。 | 输入 |


#### 返回值

向量点积的结果。

- 在sdsdot中，返回值是单精度类型。
- 在dsdot中，返回值是双精度复数类型。


#### 依赖

#include "kblas.h"


#### 示例

C interface：

```
int n = 10, 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}; 
 
    double res = cblas_dsdot(n, x, incx, y, incy); 
    /** 
     *    Output:  0.126042 
     */
```

Fortran interface：

```
REAL(8) :: RES
INTEGER :: N=10
INTEGER :: INCX=1
INTEGER :: INCY=1
REAL(4) :: X(10)
DATA X /0.340188, -0.105617, 0.283099, 0.298440, 0.411647,
$        -0.302449, -0.164777, 0.268230, -0.222225, 0.053970/
REAL(4) :: Y(10)
DATA Y /-0.022603, 0.128871, -0.135216, 0.013401, 0.452230,
$        0.416195, 0.135712, 0.217297, -0.358397, 0.106969/
EXTERNAL DSDOT
RES=DSDOT(N,X,INCX,Y,INCY)
*     Output :  0.126042
```
