Pow
Stores the calculation result of the src2 power of each src1 vector to dst.
The calculation formula is as follows:
.
The function interface declaration is as follows:
Operations on floating-point numbers:
HmppResult HMPPS_Pow_32f(const float *src1, const float *src2, float *dst, int32_t len);
HmppResult HMPPS_Pow_64f(const double *src1, const double *src2, double *dst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src1 |
Pointer to the first source vector |
The value cannot be NULL. |
Input |
src2 |
Pointer to the second source vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination vector |
The value cannot be NULL. |
Output |
len |
Vector length |
(0, INT_MAX] |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src1, src2, or dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
HMPP_STS_DOMAIN |
At least one element in the src vector is less than 0. |
Example
#define BUFFER_SIZE_T 10
void PowExample(void)
{
float src1[BUFFER_SIZE_T] = {4.52, 5.92, 5.16, 6.15, 8.17, 9.93, 6.04, 11.17, 2.79, 3.58};
float src2[BUFFER_SIZE_T] = {11.17, 2.79, 3.58, 4.52, 5.92, 5.16, 6.15, 8.17, 9.93, 6.04};
float dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T);
HmppResult result = HMPPS_Pow_32f(src1, src2, dst, BUFFER_SIZE_T);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst[i]);
}
printf("\n");
}
Output:
result = 0 dst = 20792004.00 142.82 355.87 3678.88 251393.86 139398.48 63588.30 365253632.00 26598.05 2215.41