---
title: v?invsqrt
description: "计算输入向量平方根的倒数。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0064.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0064.html
indexId: e18a3cb67aa1262dc2ab4438d11c37f0e210a0bd93a2f152e438d330eb903c9e67
---
# v?invsqrt

计算输入向量平方根的倒数。

#### 接口定义

C interface：

void vsinvsqrt(const int len, const float *src, float *dst);

void vdinvsqrt(const int len, const double *src, double *dst);


#### 参数

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


#### 输出结果

每一个运算值平方根的倒数。| 输入值（src） | 输出值（dst） |
| --- | --- |
| +0 | +inf |
| \-0 | \-inf |
| +inf | +0 |
| <0 | nan |
| nan | nan |


#### 依赖

C: "kvml.h"


#### 示例

C interface：```
#define N 4
    const float src[N] = {-8.0f, 25.0f, +INFINITY, -0.0f};
    float dst[N] = {0};

    vsinvsqrt(N, src, dst);
    printFArr("input :", N, src);    
    printFArr("output:", N, dst);
 
    /** 
     *  input :  -8.000   25.000      inf   -0.000 
     *  output:     nan    0.200    0.000     -inf
     * 
     */
```
