v?modf
矢量计算输入值的整数和小数部分,输入为向量。
接口定义
C interface:
void vsmodf(const int len, const float* src, float* dst1, float* dst2);
void vdmodf(const int len, const double* src, double* dst1, double* dst2);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
len |
整型数 |
表示输入向量的元素个数。 len≤0时会提示len无效并返回。 |
输入 |
src |
|
输入向量src,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输入 |
dst1 |
|
输出dst1,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
dst2 |
|
输出dst2,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
输出结果
- 每个运算值返回x的整数和小数部分,分别保存在dst1和dst2指向的内存中。
- 其他特殊值参考如下说明。
输入值(src)
输出值(dst1)
输出值(dst2)
±0
±0
±0
+inf
+inf
+0
-inf
-inf
-0
nan
nan
nan
依赖
C: "kvml.h"
示例
C interface:
int i, len = 8; float src[8] = {-1.5f, -0.0f, 0.0f, 1.0f, 1.5f, -INFINITY, INFINITY, NAN}; float* dst1 = (float*)malloc(sizeof(float) * len); if (dst1 == NULL) { printf("Malloc Failed!\n"); return 0; } float* dst2 = (float*)malloc(sizeof(float) * len); if (dst2 == NULL) { printf("Malloc Failed!\n"); return 0; } vsmodf(len, src, dst1, dst2); /** * Output dst: * (-1.000000 -0.500000)(-0.000000 -0.000000)(0.000000 0.000000)(1.000000 0.000000)(1.000000 0.500000)(-inf -0.000000)(inf 0.000000)(nan nan) */
父主题: 函数定义