---
title: v?hypot
description: "计算src1，src2的平方之和再开平方的值，src1和src2以及结果均为向量。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0302.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0302.html
indexId: 69b0c4f06e72aa16c687d4a0490a0f7bb6c6f8fc9addd25be5e4587ba2fdadbc76
---
# v?hypot

计算src1，src2的平方之和再开平方的值，src1和src2以及结果均为向量。

#### 接口定义

C interface：

void vshypot(const int len, const float* src1, const float* src2, float* dst);

void vdhypot(const int len, const double* src1, const double* src2, double* dst);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| len | 整型数 | 表示输入向量的元素个数。 len≤0时会提示len无效并返回。 | 输入 |
| src1 | 在vshypot中是单精度浮点类型。 在vdhypot中是双精度浮点类型。 | 输入向量src1，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| src2 | 在vshypot中是单精度浮点类型。 在vdhypot中是双精度浮点类型。 | 输入向量src2，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| dst | 在vshypot中是单精度浮点类型。 在vdhypot中是双精度浮点类型。 | 输出向量dst，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输出 |


#### 输出结果

计算的值，取值范围为|(-inf, inf)|。| 输入值（src1） | 输入值（src2） | 输出值（dst） |
| --- | --- | --- |
| snan | any | nan |
| any | snan | nan |
| ±inf | !=snan | inf |
| !=snan | ±inf | inf |
| qnan | (\-inf, inf) | nan |
| (\-inf, inf) | qnan | nan |
|  |  | inf |


#### 依赖

C: "kvml.h"


#### 示例

C interface：

```
#define N 4
const float src1[N] = {3.0f, 5.0f, 8.44f, NAN};
const float src2[N] = {-4.0f, 12.0f, -INFINITY, 1.0f};
float dst[N] = {0};
vshypot(N, src1, src2, dst);
printFArr("input1:", N, src1);
printFArr("input2:", N, src2);
printFArr("output:", N, dst);
/**
*  input1:   3.000    5.000    8.440      nan
*  input2:  -4.000   12.000     -inf    1.000
*  output:   5.000   13.000      inf      nan
*/
```
