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, an invalid parameter error is reported and the function returns. |
Input |
src1 |
|
Input vector src1 with length len. If the pointer is null, a null pointer error is reported and the function returns. |
Input |
src2 |
|
Input vector src2 with length len. If the pointer is null, a null pointer error is reported and the function returns. |
Input |
dst |
|
Output vector dst with length len. If the pointer is null, a null pointer error is reported and the function returns. |
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"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 * */ |