123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #include "arm_math.h"
- void arm_cmplx_mag_q31(
- q31_t * pSrc,
- q31_t * pDst,
- uint32_t numSamples)
- {
- q31_t real, imag;
- q31_t acc0, acc1;
- uint32_t blkCnt;
- #if defined (ARM_MATH_DSP)
-
- q31_t real1, real2, imag1, imag2;
- q31_t out1, out2, out3, out4;
- q63_t mul1, mul2, mul3, mul4;
-
- blkCnt = numSamples >> 2U;
-
- while (blkCnt > 0U)
- {
-
- real1 = pSrc[0];
- imag1 = pSrc[1];
- real2 = pSrc[2];
- imag2 = pSrc[3];
-
- mul1 = (q63_t) real1 *real1;
- mul2 = (q63_t) imag1 *imag1;
- mul3 = (q63_t) real2 *real2;
- mul4 = (q63_t) imag2 *imag2;
-
- out1 = (q31_t) (mul1 >> 33);
- out2 = (q31_t) (mul2 >> 33);
- out3 = (q31_t) (mul3 >> 33);
- out4 = (q31_t) (mul4 >> 33);
-
- out1 = out1 + out2;
- out3 = out3 + out4;
-
- real1 = pSrc[4];
- imag1 = pSrc[5];
- real2 = pSrc[6];
- imag2 = pSrc[7];
-
- arm_sqrt_q31(out1, &pDst[0]);
-
- mul1 = (q63_t) real1 *real1;
-
- arm_sqrt_q31(out3, &pDst[1]);
-
- mul2 = (q63_t) imag1 *imag1;
- mul3 = (q63_t) real2 *real2;
- mul4 = (q63_t) imag2 *imag2;
-
- out1 = (q31_t) (mul1 >> 33);
- out2 = (q31_t) (mul2 >> 33);
- out3 = (q31_t) (mul3 >> 33);
- out4 = (q31_t) (mul4 >> 33);
-
- out1 = out1 + out2;
- out3 = out3 + out4;
-
- arm_sqrt_q31(out1, &pDst[2]);
-
- pSrc += 8U;
-
- arm_sqrt_q31(out3, &pDst[3]);
-
- pDst += 4U;
-
- blkCnt--;
- }
-
- blkCnt = numSamples % 0x4U;
- #else
-
- blkCnt = numSamples;
- #endif
- while (blkCnt > 0U)
- {
-
- real = *pSrc++;
- imag = *pSrc++;
- acc0 = (q31_t) (((q63_t) real * real) >> 33);
- acc1 = (q31_t) (((q63_t) imag * imag) >> 33);
-
- arm_sqrt_q31(acc0 + acc1, pDst++);
-
- blkCnt--;
- }
- }
|