v?powr
Compute a variable raised to a power. The variable, power, and result are vectors, and the variable ≥ 0.
Interface Definition
C interface:
void vspowr(const int len, const float* src1, const float* src2, float* dst);
void vdpowr(const int len, const double* src1, const double* src2, double* 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
Return the calculation result of a^b. For details about special values, see the following table.
Input Value 1 (src1) |
Input Value 2 (src2) |
Output Value (dst) |
|---|---|---|
x < 0 |
Any value |
NaN |
0 < x < inf |
±0 |
1 |
±0 |
-inf < y < 0 |
+inf |
±0 |
-inf |
+inf |
±0 |
y > 0 |
+0 |
1 |
-inf < y < +inf |
1 |
±0 |
±0 |
1 |
+inf |
±0 |
1 |
1 |
+inf |
1 |
x ≥ 0 |
NaN |
NaN |
NaN |
Any value |
NaN |
0 < x < 1 |
-inf |
+inf |
x > 1 |
-inf |
+0 |
0 ≤ x < 1 |
+inf |
+0 |
x > 1 |
+inf |
+inf |
+inf |
x < 0 |
+0 |
+inf |
x > 0 |
+inf |
Any value |
NaN |
NaN |
For other special values, see v?pow.
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;
}
vspowr(len, src1, src2, dst);
/**
* Output dst:
* nan 1.0 4.0 8.0
*
*/