---
title: v?tan
description: "计算输入的正切值，输入为向量。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0108.html
sourcePath: /source/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0108.html
indexId: 47ecaa9fdabb9444a6511d39e7664c61cea9b03b5ba591216ace14716eaa6d2474
---
# v?tan

计算输入的正切值，输入为向量。

#### 接口定义

C interface：

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

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

Fortran interface：

CALL VSTAN(LEN, SRC, DST);

CALL VDTAN(LEN, SRC, DST);


#### 参数

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


#### 输出结果

- 每个运算值返回弧度角x的正切函数值y，y ∈ (-INF, +INF)。
- 输入+0，返回+0。
- 输入-0，返回-0。
- 输入±∞，返回nan。
- 输入nan，返回nan。
- 该函数在π(1/2 + n)处具有数学极点；没有通用的浮点表示能够精确地表示极点处的值，因此极点处会返回值，但不能认为是正确的。


#### 依赖

C: "kvml.h"

Fortran: "kvml.f03"


#### 示例

C interface：

```
int i, len = 4;
float src[len] = {0.0f, 2.0f, inf, nan};
float* dst = (float*)malloc(sizeof(float) * len);
if (dst == NULL) {
printf("Malloc Failed!\n");
return 0;
}
vstan(len, src, dst);
/**
*  Output dst:
*     0.0  -2.185039997100830  nan  nan
*
*/
```

Fortran interface：

```
INTEGER :: LEN = 4
REAL(4) SRC(4)
REAL(4) DST(4)
DATA SRC /1, 2, 3, 4/
CALL VSTAN(LEN, SRC, DST)
!
! OUTPUT DST:
!     1.55740786, -2.18504000, -0.142546535, 1.15782118
!
```
