v?pow
Compute a vector raised to a specified power element-wise. The specified power and result are also vectors.
Interface Definition
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);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
len |
Integer |
Number of elements in the input vector. If len ≤ 0, the system displays a message indicating that the value of len is invalid. |
Input |
src1 |
|
Input vector src1 with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
src2 |
|
Input vector src2 with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
dst |
|
Output vector dst with length len. If the pointer is null, the system prompts a null pointer error. |
Output |
Return Value
- If the value of src1 is greater than 0 and the value of src2 is a decimal, the value range of dst is ∈ (-INF, +INF).
- If the value of src1 is -0 and the value of src2 is a negative odd number, then the value of dst is -∞. If the value of src1 is ±0 and the value of src2 is a negative number, then the value of dst is +∞.
- If the value of src1 is ±0 and the value of src2 is a positive odd number, then the value of dst is ±0. If the value of src1 is ±0 and the value of src2 is a positive number, then the value of dst is +0.
- If the value of src1 is ±1 and the value of src2 is any value, the value of dst is +1.
- If the value of src1 is any value and the value of src2 is ±0, the value of dst is +1.
- If the value of src1 is less than +0 and the value of src2 is a decimal, the value of dst is NaN.
- If the value of src1 is less than 1 and the value of src2 is -∞, then the value of dst is +∞. If the value of src1 is greater than 1 and the value of src2 is -∞, then the value of dst is +0.
- If the value of src1 is less than 1 and the value of src2 is +∞, then the value of dst is +0. If the value of src1 is greater than 1 and the value of src2 is +∞, then the value of dst is +∞.
- If the value of src1 is -∞ and the value of src2 is a negative odd number, then the value of dst is -0. If the value of src1 is -∞ and the value of src2 is a negative number, then the value of dst is +0.
- If the value of src1 is -∞ and the value of src2 is a positive odd number, then the value of dst is -∞. If the value of src1 is -∞ and the value of src2 is a positive number, then the value of dst is +∞.
- If the value of src1 is +∞ and the value of src2 is less than +0, the value of dst is +0. If the value of src1 is +∞ and the value of src2 is greater than or equal to +0, the value of dst is +∞.
- If the values of src1 and src2 are both large finite numbers, the value of dst is ±∞.
- If the values of src1 and src2 are both NaN, the value of dst is NaN.
Dependencies
C: "kvml.h"
Fortran: "kvml.f03"
Examples
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
!