Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00048 void arm_cmplx_mag_q31(
00049 q31_t * pSrc,
00050 q31_t * pDst,
00051 uint32_t numSamples)
00052 {
00053 q31_t real1, real2, imag1, imag2;
00054 q31_t out1, out2, out3, out4;
00055 q63_t mul1, mul2, mul3, mul4;
00056 uint32_t blkCnt;
00057
00058
00059
00060 blkCnt = numSamples >> 2u;
00061
00062
00063
00064 while(blkCnt > 0u)
00065 {
00066
00067 real1 = pSrc[0];
00068 imag1 = pSrc[1];
00069 real2 = pSrc[2];
00070 imag2 = pSrc[3];
00071
00072
00073 mul1 = (q63_t) real1 * real1;
00074 mul2 = (q63_t) imag1 * imag1;
00075 mul3 = (q63_t) real2 * real2;
00076 mul4 = (q63_t) imag2 * imag2;
00077
00078
00079 out1 = (q31_t)(mul1 >> 33);
00080 out2 = (q31_t)(mul2 >> 33);
00081 out3 = (q31_t)(mul3 >> 33);
00082 out4 = (q31_t)(mul4 >> 33);
00083
00084
00085 out1 = out1 + out2;
00086 out3 = out3 + out4;
00087
00088
00089 real1 = pSrc[4];
00090 imag1 = pSrc[5];
00091 real2 = pSrc[6];
00092 imag2 = pSrc[7];
00093
00094
00095 arm_sqrt_q31(out1, &pDst[0]);
00096
00097
00098 mul1 = (q63_t) real1 * real1;
00099
00100
00101 arm_sqrt_q31(out3, &pDst[1]);
00102
00103
00104 mul2 = (q63_t) imag1 * imag1;
00105 mul3 = (q63_t) real2 * real2;
00106 mul4 = (q63_t) imag2 * imag2;
00107
00108
00109 out1 = (q31_t)(mul1 >> 33);
00110 out2 = (q31_t)(mul2 >> 33);
00111 out3 = (q31_t)(mul3 >> 33);
00112 out4 = (q31_t)(mul4 >> 33);
00113
00114
00115 out1 = out1 + out2;
00116 out3 = out3 + out4;
00117
00118
00119 arm_sqrt_q31(out1, &pDst[2]);
00120
00121
00122 pSrc += 8u;
00123
00124
00125 arm_sqrt_q31(out3, &pDst[3]);
00126
00127
00128 pDst += 4u;
00129
00130
00131 blkCnt--;
00132 }
00133
00134
00135
00136 blkCnt = numSamples % 0x4u;
00137
00138 while(blkCnt > 0u)
00139 {
00140
00141 real1 = *pSrc++;
00142 imag1 = *pSrc++;
00143 out1 = (q31_t) (((q63_t) real1 * real1) >> 33);
00144 out2 = (q31_t) (((q63_t) imag1 * imag1) >> 33);
00145
00146 arm_sqrt_q31(out1 + out2, pDst++);
00147
00148
00149 blkCnt--;
00150 }
00151 }
00152