v?pow
计算变量的幂函数,变量和幂次以及结果均为向量。
接口定义
C interface:
void vspow(const int len, const float* src1, const float* src2, float* dst);
void vdpow(const int len, const double* src1, const double* src2, double* dst);
Fortran interface:
CALL VSPOW(LEN, SRC1, SRC2, DST);
CALL VDPOW(LEN, SRC1, SRC2, DST);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
len |
整型数 |
表示输入向量的元素个数。 len≤0时会提示len无效并返回。 |
输入 |
src1 |
|
输入向量src1,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输入 |
src2 |
|
输入向量src2,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输入 |
dst |
|
输出向量dst,向量长度为len。 若为空指针,会提示空指针错误并返回。 |
输出 |
输出结果
- src1的值大于0且src2的值为小数,返回幂指数的结果,取值范围dst的值 ∈ (-INF, +INF)。
- src1的值为-0,src2的值为负的奇数,dst的值则返回-∞;其他src1的值为±0,src2的值为负数,dst的值返回+∞。
- src1的值为±0,src2的值为正的奇数,dst的值则返回±0;其他src1的值为±0,src2的值为正数,dst的值返回+0。
- src1的值为±1,src2的值为任意值,dst的值则返回+1。
- src1的值为任意值,src2的值为±0,dst的值则返回+1。
- src1的值小于+0,src2的值为小数,dst的值则返回nan。
- |src1的值|小于1,src2的值为-∞,dst的值则返回+∞;|src1的值|大于1,src2的值为-∞,dst的值则返回+0。
- |src1的值|小于1,src2的值为+∞,dst的值则返回+0;|src1的值|大于1,src2的值为+∞,dst的值则返回+∞。
- src1的值为-∞,src2的值为负奇数,dst的值则返回-0;其他src1的值为-∞,src2的值为负数,dst的值则返回+0。
- src1的值为-∞,src2的值为正奇数,dst的值则返回-∞;其他src1的值为-∞,src2的值为正数,dst的值则返回+∞。
- src1的值为+∞,src2的值小于+0,dst的值则返回+0;其他src1的值为+∞,dst的值则返回+∞。
- src1的值为大的有限数,且src2的值为大的有限数,dst的值则返回±∞。
- src1的值为nan,且src2的值为nan,dst的值则返回nan。
依赖
C: "kvml.h"
Fortran: "kvml.f03"
示例
C interface:
int i, len = 4; float src1[len] = {1.0f, 0.0f, 16.0f, 2.0f}; float src2[len] = {0.0f, 0.0f, 0.5f, 3.0f}; float* dst = (float*)malloc(sizeof(float) * len); if (dst == NULL) { printf("Malloc Failed!\n"); return 0; } vspow(len, src1, src2, dst); /** * Output dst: * 1.0 1.0 4.0 8.0 * */
Fortran interface:
INTEGER :: LEN = 4 REAL(4) SRC1(4) REAL(4) SRC2(4) REAL(4) DST(4) DATA SRC1 /1.2, 2.5, 2.4, 3.6/ DATA SRC2 /8.6, -2.5, 1.7, 1.3/ CALL VSPOW(LEN, SRC1, SRC2, DST) ! ! OUTPUT DST: ! 4.79688072, 0.101192884, 4.42954540, 5.28680420 !
父主题: 函数定义