特别说明:完整45期数字信号处理教程,原创高性能示波器代码全开源地址:链接
+ Z8 m6 y% j9 r3 \第18章 ComplexMathFunctions的使用(二)
1 j1 j/ N; e. Q/ e5 j# ~& X9 E, ^# Y 本期教程主要讲解复数运算中的模平方,复数乘法和复数乘实数的求解。 18.1 复数模平方 ComplexMagSquared 18.2 复数乘法 ComplexMultComplex 18.3 复数乘实数 ComplexMultComplex 18.4 总结
$ K u3 C1 s d1 X% k$ e18.1 复数模平方 ComplexMagSquared18.1.1 arm_cmplx_mag_squared_f32公式描述: for(n=0; n<numSamples; n++) { pDst[n] = pSrc[(2*n)+0]^2 + pSrc[(2*n)+1]^2; } 函数定义如下: void arm_cmplx_mag_squared_f32(float32_t * pSrc, float32_t * pDst, uint32_t numSamples) 参数定义: [in] *pSrc points to the complex input vector [out] *pDst points to the real output vector [in] numSamples number of complex samples in the input vector 注意事项: 1. 数组pSrc和pDst中存储的数据格式是(实部,虚部,实部,虚部……………) 5 J/ N) T/ T& _1 C7 |3 ]
18.1.2 arm_cmplx_mag_squared_q31公式描述: for(n=0; n<numSamples; n++) { pDst[n] = pSrc[(2*n)+0]^2 + pSrc[(2*n)+1]^2; } 函数定义如下: void arm_cmplx_mag_squared_q31(q31_t * pSrc, q31_t * pDst, uint32_t numSamples) 参数定义: [in] *pSrc points to the complex input vector [out] *pDst points to the real output vector [in] numSamples number of complex samples in the input vector 注意事项: 1. 数组pSrc和pDst中存储的数据格式是(实部,虚部,实部,虚部……………) " n" o6 k) J0 n" H! _* h4 f
18.1.3 arm_cmplx_mag_squared_q15公式描述: for(n=0; n<numSamples; n++) { pDst[n] = pSrc[(2*n)+0]^2 + pSrc[(2*n)+1]^2; } 函数定义如下: void arm_cmplx_mag_squared_q15(q15_t * pSrc, q15_t * pDst, uint32_t numSamples) 参数定义: [in] *pSrc points to the complex input vector [out] *pDst points to the real output vector [in] numSamples number of complex samples in the input vector 注意事项: 1. 数组pSrc和pDst中存储的数据格式是(实部,虚部,实部,虚部……………) . |! k3 @3 Z* y0 Q4 ?$ b
18.1.4 实例讲解实验目的: 1. 学习ComplexMathFunctions中模平方的求解 实验内容: 1. 按下按键K1, 串口打印函数DSP_MagSquared的输出结果 实验现象: 通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下: 程序设计: - /*
# B9 K" ]6 h- o' b2 M, p% G - *********************************************************************************************************
" N, b6 ]( ?4 y& A0 [/ K - * 函 数 名: DSP_MagSquared$ ]6 q* W% y3 y; u7 z
- * 功能说明: 复数模的平方
# Y" ~ Z0 }" X/ o1 u2 z - * 形 参:无( ^7 O, g7 ]" e- C1 P
- * 返 回 值: 无
/ t6 F* r& `! x3 A - *********************************************************************************************************
- A% \7 P5 p/ \- |9 ] - */. N6 P" n* E; N3 X6 f
- static void DSP_MagSquared(void). k8 I; U! Y2 a* w6 {! w% q4 V
- {
* o, `- D k/ H; T- }& ~ a - uint8_t i;
& A: I$ K0 \2 p1 S: V3 q' L - float32_t pSrc[10] = {1.1f, 1.1f, 2.1f, 2.1f, 3.1f, 3.1f, 4.1f, 4.1f, 5.1f, 5.1f};
5 u% a d7 C: m! h" m6 ^ - float32_t pDst[10];
8 O% L7 x. D6 O: [3 m# f, @! W( U - q31_t pSrc1[10] = {1*268435456, 1*268435456, 2*268435456, 2*268435456, 3*268435456, 3*268435456, 5 j1 C, v4 S, n$ R: A& w% `* D! K9 @
- 4*268435456, 4*268435456, 5*268435456, 5*268435456};
6 Y1 a' E6 x h! U3 _ - q31_t pDst1[10];7 F2 U: d3 E5 S' j) l
-
5 O8 F& |3 D y$ @8 f% I - q15_t pSrc2[10] = {5000, 10000, 15000, 20000, 25000, 5000, 10000, 15000, 20000, 25000};
% n+ w v5 U k, D" c2 L8 N - q15_t pDst2[10];
) E3 j: W5 |- n& y1 I9 ` - /***浮点数模平方*******************************************************************************/
; [5 Q$ g2 \0 o& e6 u - arm_cmplx_mag_squared_f32(pSrc, pDst, 5);
5 a$ B P, p3 S6 k6 K- d @9 E - for(i = 0; i < 5; i++)
. r1 M, f7 O8 `$ n- H2 d - {
6 L+ B$ X4 | U - printf("pDst[%d] = %f\r\n", i, pDst[i]);
; E! t! X% Q5 ?9 Q O1 |6 [ - }
/ L$ P. s$ n2 S* S2 c; O - /***定点数模平方Q31*******************************************************************************/9 B/ x' w5 K7 U& K9 h; d6 z
- arm_cmplx_mag_squared_q31(pSrc1, pDst1, 5);
$ F+ u0 n; C! i% V0 k2 _ - for(i = 0; i < 5; i++)
* R1 t# t' x! N - {
/ k. W6 ]3 _# M2 }8 b; e! o - printf("pDst1[%d] = %d\r\n", i, pDst1[i]);: o- G" c% u( _ _# P2 w
- } f" R/ [5 j0 g- o ]! b
- /***定点数模平方Q15*******************************************************************************/
4 U# `0 h# U4 A: w. o4 z4 Y - arm_cmplx_mag_squared_q15(pSrc2, pDst2, 5); u0 m- v% ?! X3 Y- W5 P1 t' B$ a
- for(i = 0; i < 5; i++)
, C2 E! C- n4 @ - {
' U+ ~- z+ O% \) s& a - printf("pDst2[%d] = %d\r\n", i, pDst2[i]);1 D1 c9 U) J: G( U9 R) C5 O
- }
0 G: q: a4 x6 V$ } - }
复制代码 u, t# i% B0 K' H- C# [
|
/ g; @- L9 X9 J
18.2.1 arm_cmplx_mult_cmplx_f32
18.2.2 arm_ cmplx_mult_cmplx_q31
18.2.3 arm_cmplx_mult_cmplx_q15
7 [7 q$ l6 l# s
18.2.4 实例讲解
* t2 q2 _" O, M' J! B4 d
2 V& R. h. M' p! d
18.3.1 arm_cmplx_mult_cmplx_f32
18.3.2 arm_ cmplx_mult_cmplx_q31
18.3.3 arm_cmplx_mult_cmplx_q15
18.3.4 实例讲解
18.4 总结
% d7 V: n9 t. c. J3 I- f5 S