PowerSpectr
Calculates the power spectrum of the complex vector. The calculation formula is as follows:
.
The function interface declaration is as follows:
- Operations on integers:
HmppResult HMPPS_PowerSpectr_16s32f(const int16_t* srcRe, const int16_t* srcIm, float* dst, int32_t len);
HmppResult HMPPS_PowerSpectr_16sc32f(const Hmpp16sc* src, float* dst, int32_t len);
- Operations on floating-point numbers:
HmppResult HMPPS_PowerSpectr_32f(const float* srcRe, const float* srcIm, float* dst, int32_t len);
HmppResult HMPPS_PowerSpectr_64f(const double* srcRe, const double* srcIm, double* dst, int32_t len);
HmppResult HMPPS_PowerSpectr_32fc(const Hmpp32fc* src, float* dst, int32_t len);
HmppResult HMPPS_PowerSpectr_64fc(const Hmpp64fc* src, double* dst, int32_tl en);
- Operations on integers with scaling:
HmppResult HMPPS_PowerSpectr_16s_S(const int16_t* srcRe, cons tint16_t* srcIm, int16_t* dst, int32_t len, double scale);
HmppResult HMPPS_PowerSpectr_16sc_S(const Hmpp16sc* src, int16_t* dst, int32_t len, double scale);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
srcRe |
Pointer to the input real part vector |
The value cannot be NULL. |
Input |
srcIm |
Pointer to the input imaginary part vector |
The value cannot be NULL. |
Input |
src |
Pointer to the input complex vector |
The value cannot be NULL. |
Input |
dst |
Pointer to vector containing output power spectral density |
The value cannot be NULL. |
Output |
scale |
Scale factor |
scale = 2^n, where n is an integer. The value is within (0, INF). |
Input |
len |
Vector length |
(0, INT_MAX] |
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 srcRe, srcIm, or src 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. |
Example
#define BUFFER_SIZE_T 5
void PowerSpectrExample(void)
{
float srcRe[BUFFER_SIZE_T] = {0.0, 1.0, 2.0, 4.5, 150.0};
float srcIm[BUFFER_SIZE_T] = {0.5, 1.5, 2.5, 4.0, 150.0};
float dst[BUFFER_SIZE_T];
int32_t i;
HmppResult result = HMPPS_PowerSpectr_32f(srcRe, srcIm, dst, BUFFER_SIZE_T);
printf("result = %d \n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %f ", dst[i]);
}
printf("\n");
}
Output:
result = 0 dst = 0.250000 3.250000 10.250000 36.250000 45000.000000