Rate This Document
Findability
Accuracy
Completeness
Readability

Log10

Calculates the logarithm of each element in src to the base 10, and stores the result to dst.

Real number formula: dst[n] = log10(src[n]), 0 ≤ n < len;

Complex number formula: dst[n] = log10(src[n].re * src[n].re + src[n].im * src[n].im) / 2 + arctan(b / a)i, where 0 ≤ n < len.

The function interface declaration is as follows:

Main function operations:

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

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

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

HmppResult HMPPS_Log10_64fc(const Hmpp64fc* src, Hmpp64fc* 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

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, overLap, window, or nfft is invalid.

HMPP_STS_DOMAIN

Warning. An element whose value is less than 0 exists in the vector.

HMPP_STS_SINGULARITY

Warning. An element whose value is 0 exists in the vector.

Example

#define  BUFFER_SIZE_T 5
void Log10Example()
{
    float src[BUFFER_SIZE_T] = {1, 2.5, 3.3, 1, 5};
    float dst[BUFFER_SIZE_T];
    HMPPS_Zero_32f(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
    HmppResult result = HMPPS_Log10_32f(src, 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 = 0.00 0.40 0.52 0.00 0.70