00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. July 2011 00005 * $Revision: V1.0.10 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_cmplx_mag_squared_f32.c 00009 * 00010 * Description: Floating-point complex magnitude squared. 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00013 * 00014 * Version 1.0.10 2011/7/15 00015 * Big Endian support added and Merged M0 and M3/M4 Source code. 00016 * 00017 * Version 1.0.3 2010/11/29 00018 * Re-organized the CMSIS folders and updated documentation. 00019 * 00020 * Version 1.0.2 2010/11/11 00021 * Documentation updated. 00022 * 00023 * Version 1.0.1 2010/10/05 00024 * Production release and review comments incorporated. 00025 * 00026 * Version 1.0.0 2010/09/20 00027 * Production release and review comments incorporated. 00028 * ---------------------------------------------------------------------------- */ 00029 00030 #include "arm_math.h" 00031 00074 void arm_cmplx_mag_squared_f32( 00075 float32_t * pSrc, 00076 float32_t * pDst, 00077 uint32_t numSamples) 00078 { 00079 float32_t real, imag; /* Temporary variables to store real and imaginary values */ 00080 00081 #ifndef ARM_MATH_CM0 00082 00083 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00084 uint32_t blkCnt; /* loop counter */ 00085 00086 /*loop Unrolling */ 00087 blkCnt = numSamples >> 2u; 00088 00089 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00090 ** a second loop below computes the remaining 1 to 3 samples. */ 00091 while(blkCnt > 0u) 00092 { 00093 /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ 00094 real = *pSrc++; 00095 imag = *pSrc++; 00096 /* store the result in the destination buffer. */ 00097 *pDst++ = (real * real) + (imag * imag); 00098 00099 real = *pSrc++; 00100 imag = *pSrc++; 00101 *pDst++ = (real * real) + (imag * imag); 00102 00103 real = *pSrc++; 00104 imag = *pSrc++; 00105 *pDst++ = (real * real) + (imag * imag); 00106 00107 real = *pSrc++; 00108 imag = *pSrc++; 00109 *pDst++ = (real * real) + (imag * imag); 00110 00111 /* Decrement the loop counter */ 00112 blkCnt--; 00113 } 00114 00115 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00116 ** No loop unrolling is used. */ 00117 blkCnt = numSamples % 0x4u; 00118 00119 while(blkCnt > 0u) 00120 { 00121 /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ 00122 real = *pSrc++; 00123 imag = *pSrc++; 00124 /* store the result in the destination buffer. */ 00125 *pDst++ = (real * real) + (imag * imag); 00126 00127 /* Decrement the loop counter */ 00128 blkCnt--; 00129 } 00130 00131 #else 00132 00133 /* Run the below code for Cortex-M0 */ 00134 00135 while(numSamples > 0u) 00136 { 00137 /* reading real and imaginary values */ 00138 real = *pSrc++; 00139 imag = *pSrc++; 00140 00141 /* out = (real * real) + (imag * imag) */ 00142 /* store the result in the destination buffer. */ 00143 *pDst++ = (real * real) + (imag * imag); 00144 00145 /* Decrement the loop counter */ 00146 numSamples--; 00147 } 00148 00149 #endif /* #ifndef ARM_MATH_CM0 */ 00150 00151 } 00152