Cubrt
Calculates the cubic root of each element. The formula is
.
For the calculation interface that contains the scale parameter, the formula is
.
The function interface declaration is as follows:
HmppResult HMPPS_Cubrt_32f(const float *src, float *dst, int32_t len);
HmppResult HMPPS_Cubrt_32s16s_S(const int32_t *src, int16_t *dst, int32_t len, double scale);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the calculation result |
The value cannot be NULL. |
Output |
len |
Vector length |
(0, INT_MAX] |
Input |
scale |
Scale factor |
scale = 2^n, where n is an integer. The value is within (0, INF). |
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 src or dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
HMPP_STS_SCALE_ERR |
The value of scale is not within the range (0, INF) or is NaN. |
Note
The value of scale must range from -16 to 16. Otherwise, the calculation result is not defined.
Example
#define BUFFER_SIZE_T 10
int main()
{
float src[BUFFER_SIZE_T] = {1.28, 4.53, 8.79, 4.23, 2.18, 9.69, 5.34, 8.03, 1.90, 8.76};
float dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
HmppResult result = HMPPS_Cubrt_32f(src, dst, BUFFER_SIZE_T);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int32_t i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst[i]);
}
printf("\n");
return 0;
}
Output:
result = 0 dst = 1.09 1.65 2.06 1.62 1.30 2.13 1.75 2.00 1.24 2.06