Rate This Document
Findability
Accuracy
Completeness
Readability

Exp

Uses each element in a vector as an exponent to calculate the power of the base e.

The function interface declaration is as follows:

  • Operations on floating-point numbers:

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

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

  • In-place operations on floating-point numbers:

    HmppResult HMPPS_Exp_32f_I(float* srcDst, int32_t len);

    HmppResult HMPPS_Exp_64f_I(double* srcDst, int32_t len);

  • Operations on integers with scaling:

    HmppResult HMPPS_Exp_16s_S(const int16_t* src, int16_t* dst, int32_t len, double scale);

    HmppResult HMPPS_Exp_32s_S(const int32_t* src, int32_t* dst, int32_t len, double scale);

  • In-place operations on integers with scaling:

    HmppResult HMPPS_Exp_16s_IS(int16_t* srcDst, int32_t len, double scale);

    HmppResult HMPPS_Exp_32s_IS(int32_t* srcDst, 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 destination vector

The value cannot be NULL.

Output

srcDst

Pointer to the source vector for in-place operations

The value cannot be NULL.

Input/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, dst, or srcDst 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.

HMPP_STS_OVERFLOW

The calculation result of dst exceeds the positive maximum value.

HMPP_STS_UNDERFLOW

The calculation result of dst is less than the positive minimum value.

Example

#define BUFFER_SIZE_T 10

void ExpExample(void)  
{
    float src[BUFFER_SIZE_T] = {1.30, 5.34, 4.93, 10.08, 8.64, -0.86, -0.05, 5.63, 2.90, 4.43};
    float dst[BUFFER_SIZE_T];
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
    HmppResult result = HMPPS_Exp_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");
} 

Output:

result = 0
dst = 3.67 208.51 138.38 23860.98 5653.33 0.42 0.95 278.66 18.17 83.93