Magnitude
计算复数向量的模。
计算公式为:。
函数接口声明如下:
- 浮点数的操作:
HmppResult HMPPS_Magnitude_16s32f(const int16_t *srcRe, const int16_t *srcIm, float *dst, int32_t len);
HmppResult HMPPS_Magnitude_16sc32f(const Hmpp16sc* src, float* dst, int32_t len);
HmppResult HMPPS_Magnitude_32f(const float* srcRe, const float* srcIm, float* dst, int32_t len);
HmppResult HMPPS_Magnitude_64f(const double* srcRe, const double* srcIm, double* dst, int32_t len);
HmppResult HMPPS_Magnitude_32fc(const Hmpp32fc* src, float* dst, int32_t len);
HmppResult HMPPS_Magnitude_64fc(const Hmpp64fc* src, double* dst, int32_t len);
- 有缩放的整型数操作:
HmppResult HMPPS_Magnitude_16sc_S(const Hmpp16sc* src, int16_t* dst, int32_t len, double scale);
HmppResult HMPPS_Magnitude_32sc_S(const Hmpp32sc* src, int32_t* dst, int32_t len, double scale);
HmppResult HMPPS_Magnitude_16s_S(const int16_t *srcRe, const int16_t *srcIm, int16_t *dst, int32_t len, double scale);
参数
参数名 |
描述 |
取值范围 |
输入/输出 |
---|---|---|---|
src |
指向源向量的指针。 |
非空 |
输入 |
srcRe |
指复数实部源向量的指针。 |
非空 |
输入 |
srcIm |
指复数虚部源向量的指针。 |
非空 |
输入 |
dst |
指向目标向量的指针。 |
非空 |
输出 |
len |
向量长度。 |
(0,INF)且输入为2^n |
输入 |
scale |
缩放因数。 |
[INT_MIN, INT_MAX] |
输入 |
返回值
- 成功:返回HMPP_STS_NO_ERR。
- 失败:返回错误码。
错误码
错误码 |
描述 |
---|---|
HMPP_STS_NULL_PTR_ERR |
src、dst这几个入参中存在空指针。 |
HMPP_STS_SIZE_ERR |
len小于或等于0。 |
HMPP_STS_SCALE_ERR |
scale不在(0,INF)范围内或输入为nan。 |
示例
#define BUFFER_SIZE_T 10 void MagnitudeExample(void) { float srcRe[BUFFER_SIZE_T] = {-0.10, 0.47, 11.54, 7.41, 9.14, 6.89, 2.73, 8.15, 9.29, 7.94}; float srcIm[BUFFER_SIZE_T] = {7.10, 3.12, 6.47, 3.87, 9.18, 8.64, 2.00, -1.04, 6.34, 5.19}; float dst[BUFFER_SIZE_T]; int32_t i; HmppResult result = HMPPS_Magnitude_32f(srcRe, srcIm, dst, BUFFER_SIZE_T); printf("result = %d \n", result); if (result != HMPP_STS_NO_ERR) { return; } printf("dst ="); for (i = 0; i < BUFFER_SIZE_T; i++) { printf(" %.2f ", dst[i]); } }
运行结果:
return = 0 dst = 7.10 3.16 13.23 8.36 12.95 11.05 3.38 8.22 11.25 9.49