v?sqrt
计算输入的平方根,输入为向量。
接口定义
C interface:
void vssqrt(const int len, const float* src, float* dst);
void vdsqrt(const int len, const double* src, double* dst);
Fortran interface:
CALL VSSQRT(LEN, SRC, DST);
CALL VDSQRT(LEN, SRC, DST);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
len |
整型数 |
表示输入向量的元素个数。 len≤0时会提示len无效并返回。 |
输入 |
src |
|
输入向量src,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输入 |
dst |
|
输出dst,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
输出结果
- 每一个运算值返回数的平方根,取值范围为[0, +INF)。
- src的值为±0,dst的值返回±0。
- src的值小于+0,dst的值返回nan。
- src的值为+∞,dst的值返回+∞。
- src的值为nan,dst的值返回nan。
依赖
C: "kvml.h"
Fortran: "kvml.f03"
示例
C interface:
int i, len = 4; float src[len] = [0.0f, 0.25f, 16.0f, 1.0f]; float* dst = (float*)malloc(sizeof(float) * len); if (dst == NULL) { printf("Malloc Failed!\n"); return 0; } vssqrt(len, src, dst); /** * Output dst: * 0.0 0.5 4.0 1.0 * */
Fortran interface:
INTEGER :: LEN = 4 REAL(4) SRC(4) REAL(4) DST(4) DATA SRC /1, 2, 3, 4/ CALL VSSQRT(LEN, SRC1, SRC2, DST) ! ! OUTPUT DST: ! 1.000000000, 1.414213538, 1.732050776, 2.000000000 !
父主题: KML_VML库函数说明