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

Hilbert

Computes a complex analytic signal dst, which contains the original real signal src as its real part, and computed Hilbert transform as its imaginary part. The Hilbert transform is performed according to the spec specification parameters: the number of samples len and hint. The input data is zero-padded or truncated to the size of len.

The Hilbert function calling process is as follows:

  1. Initialize the HmppsHilbertPolicy_32f structure by calling Init.
  2. Call the main function.
  3. Call Release to release the memory contained in the HmppsHilbertPolicy_32f function.

The function interface declaration is as follows:

  • Initialization:

    HmppResult HMPPS_HilbertInit_32f32fc(int32_t len, HmppsHilbertPolicy_32f32fc **policy);

  • Main functions:

    HmppResult HMPPS_Hilbert_32f32fc(const float *src, Hmpp32fc *dst, int32_t len, HmppsHilbertPolicy_32f32fc *policy);

  • Memory release:

    HmppResult HMPPS_HilbertRelease_32f32fc(HmppsHilbertPolicy_32f32fc *policy);

Parameters

Parameter

Description

Value Range

Input/Output

src

Source vector

The value cannot be NULL.

Input

dst

Destination vector

The value cannot be NULL.

Output

len

Vector length

(0, INT_MAX]

Input

policy

(in the Init function)

Double pointer to HmppsHilbertPolicy

The value cannot be NULL.

Output

policy

(in the main and release functions)

Pointer to the HmppsHilbertPolicy structure

The value cannot be NULL.

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NO_ERR

No error occurs.

HMPP_STS_NULL_PTR_ERR

Any of the specified pointers is NULL.

HMPP_STS_SIZE_ERR

The value of len is less than or equal to 0.

HMPP_STS_MALLOC_FAILED

The Init function failed to allocate the memory required by the algorithm model.

HMPP_STS_MISMATCH

The size of the problem that the Init function applies for memory does not match the size of the problem that is actually calculated in the main function.

Note

  • Before this interface is called for calculation, the Init interface must be called to initialize the HmppsHilbertPolicy_32f standard structure.
  • The initialization of the HmppsHilbertPolicy_32f structure needs to be applied for in the Init function. You cannot apply for and define this structure by yourself.

Example

void Hilbert_Example()
{
    const int len = 10;
    float src[len];
    Hmpp32fc dst[len];
    HmppsHilbertPolicy_32f32fc *policy = NULL;

    for (int i = 0; i < 10; ++i){
        src[i] = i / 10.0;
    }
    HmppResult result = HMPPS_HilbertInit_32f32fc(len, &policy);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    result = HMPPS_Hilbert_32f32fc(src, dst, len, policy);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    result = HMPPS_HilbertRelease_32f32fc(policy);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    for (int i = 0; i < len; ++i) {
        printf("%.2f + %.6fi ", dst[i].re, dst[i].im);
    }

}

Output:

0 + 0.550553i, 0.1 + -0.0649839i, 0.2 + -0.0649839i, 0.3 + -0.210292i, 0.4 + -0.210292i, 0.5 + -0.210292i, 0.6 + -0.210292i, 0.7 + -0.0649839i, 0.8 + -0.0649839i, 0.9 + 0.550553i,