| #include "edge-impulse-sdk/dsp/config.hpp" |
| #if EIDSP_LOAD_CMSIS_DSP_SOURCES |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/complex_math_functions.h" |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) |
|
|
| #include "edge-impulse-sdk/CMSIS/DSP/Include/arm_helium_utils.h" |
|
|
| void arm_cmplx_mag_q31( |
| const q31_t * pSrc, |
| q31_t * pDst, |
| uint32_t numSamples) |
| { |
| int32_t blockSize = numSamples; |
| uint32_t blkCnt; |
|
|
| q31x4x2_t vecSrc; |
| q31x4_t sum; |
|
|
| q31_t real, imag; |
| q31_t acc0, acc1; |
|
|
| |
| blkCnt = blockSize >> 2; |
| while (blkCnt > 0U) |
| { |
| vecSrc = vld2q(pSrc); |
|
|
| sum = vqaddq(vmulhq(vecSrc.val[0], vecSrc.val[0]), |
| vmulhq(vecSrc.val[1], vecSrc.val[1])); |
|
|
| sum = vshrq(sum, 1); |
|
|
| |
| |
| |
| |
| |
| |
| |
| sum = FAST_VSQRT_Q31(sum); |
|
|
| vst1q(pDst, sum); |
|
|
| |
| |
| |
| blkCnt--; |
| pSrc += 8; |
| pDst += 4; |
| } |
|
|
| |
| |
| |
| blkCnt = blockSize & 3; |
| 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--; |
| } |
| } |
|
|
| #else |
| void arm_cmplx_mag_q31( |
| const q31_t * pSrc, |
| q31_t * pDst, |
| uint32_t numSamples) |
| { |
| uint32_t blkCnt; |
| q31_t real, imag; |
| q31_t acc0, acc1; |
|
|
| #if defined (ARM_MATH_LOOPUNROLL) |
|
|
| |
| blkCnt = numSamples >> 2U; |
|
|
| 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++); |
|
|
| 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++); |
|
|
| 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++); |
|
|
| 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--; |
| } |
|
|
| |
| 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--; |
| } |
|
|
| } |
| #endif |
|
|
| |
| |
| |
|
|
| #endif |
|
|