我要评分
获取效率
正确性
完整性
易理解

Powx

Calculates the exponentiation of a constant exponent and each element in a vector.

The function interface declaration is as follows:

HmppResult HMPPS_Powx_32f_A11(const float *src, const float constValue, float *dst, int32_t len);

HmppResult HMPPS_Powx_32f_A21(const float *src, const float constValue, float *dst, int32_t len);

HmppResult HMPPS_Powx_32f_A24(const float *src, const float constValue, float *dst, int32_t len);

HmppResult HMPPS_Powx_64f_A26(const double *src, const double constValue, double *dst, int32_t len);

HmppResult HMPPS_Powx_64f_A50(const double *src, const double constValue, double *dst, int32_t len);

HmppResult HMPPS_Powx_64f_A53(const double *src, const double constValue, double *dst, int32_t len);

HmppResult HMPPS_Powx_32fc_A11(const Hmpp32fc *src, const Hmpp32fc constValue, Hmpp32fc *dst, int32_t len);

HmppResult HMPPS_Powx_32fc_A21(const Hmpp32fc *src, const Hmpp32fc constValue, Hmpp32fc *dst, int32_t len);

HmppResult HMPPS_Powx_32fc_A24(const Hmpp32fc *src, const Hmpp32fc constValue, Hmpp32fc *dst, int32_t len);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the 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

constValue

Exponent of the exponentiation operation

Not limited, depending on the type

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Warning: HMPP_STS_DOMAIN or HMPP_STS_SINGULARITY
  • 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_DOMAIN

Warning. An element less than 0 exists in the vector, and the value of constValue is a decimal.

HMPP_STS_SINGULARITY

Warning. An element equaling to 0 exists in the vector, and the value of the constValue exponent is a negative number.

Example

#define  BUFFER_SIZE_T 5
void PowxExample()
{
    float src[BUFFER_SIZE_T] = {1, 2.5, 3.3, 1, 5};
    float constValue = 2;
    float dst[BUFFER_SIZE_T];
    HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
    HmppResult result = HMPPS_Powx_32f_A11(src, constValue, dst, BUFFER_SIZE_T);
    if (result == HMPP_STS_NO_ERR) {
        printf("dst = ");
        for (int32_t i = 0; i < BUFFER_SIZE_T; i++) {
            printf("%.2f ", dst[i]);
        }
        printf("\n");
    }
}

Output:

dst = 1.00 6.25 10.89 1.00 25.00