v?sincos
计算输入的正弦值和余弦值,输入为向量。
接口定义
C interface:
void vssincos(const int len, const float* src, float* sindst, float* cosdst);
void vdsincos(const int len, const double* src, double* sindst, double* cosdst);
Fortran interface:
CALL VSSINCOS(LEN, SRC, SINDST, COSDST);
CALL VDSINCOS(LEN, SRC, SINDST, COSDST);
参数
参数名 |
类型 |
描述 |
输入/输出 |
|---|---|---|---|
len |
整型数 |
表示输入向量的元素个数。 len≤0时会提示len无效并返回。 |
输入 |
src |
|
输入向量src,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输入 |
sindst |
|
输出sindst,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
cosdst |
|
输出cosdst,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
输出结果
- 每一个运算值返回弧度角 x 的正选数值sinx和余弦函数值cosx,sinx ∈ [-1, +1],cosx ∈ [-1, +1]。
- 输入+0,返回正弦值+0和余弦值+1。
- 输入-0,返回正弦值-0和余弦值+1。
- 输入±∞,均返回nan。
- 输入nan,均返回nan。
依赖
C: "kvml.h"
Fortran: "kvml.f03"
示例
C interface:
int i, len = 4;
float src[len] = [0.0f, 2.0f, inf, nan];
float* sindst = (float*)malloc(sizeof(float) * len);
float* cosdst = (float*)malloc(sizeof(float) * len);
if (sindst == NULL || cosdst == NULL) {
printf("Malloc Failed!\n");
return 0;
}
vssin(len, src, sindst, cosdst);
/**
* Output sindst:
* 0.0 0.909297406673431 nan nan
* Output cosdst:
* 1.0 -0.416146814823151 nan nan
*
*/
Fortran interface:
INTEGER :: LEN = 4
REAL(4) SRC(4)
REAL(4) COSDST(4)
REAL(4) SINDST(4)
DATA SRC /1, 2, 3, 4/
CALL VSSINCOS(LEN, SRC, SINDST, COSDST)
!
! OUTPUT SINDST:
! 0.841470957, 0.909297407, 0.141120002, -0.756802440
! OUTPUT COSDST:
! 0.540302277, -0.416146815, -0.989992499, -0.653643608
!
父主题: KML_VML库函数说明