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_f32.c 00009 * 00010 * Description: Floating-point complex magnitude. 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 00073 void arm_cmplx_mag_f32( 00074 float32_t * pSrc, 00075 float32_t * pDst, 00076 uint32_t numSamples) 00077 { 00078 float32_t realIn, imagIn; /* Temporary variables to hold input values */ 00079 00080 #ifndef ARM_MATH_CM0 00081 00082 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00083 uint32_t blkCnt; /* loop counter */ 00084 00085 /*loop Unrolling */ 00086 blkCnt = numSamples >> 2u; 00087 00088 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00089 ** a second loop below computes the remaining 1 to 3 samples. */ 00090 while(blkCnt > 0u) 00091 { 00092 00093 /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ 00094 realIn = *pSrc++; 00095 imagIn = *pSrc++; 00096 /* store the result in the destination buffer. */ 00097 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00098 00099 realIn = *pSrc++; 00100 imagIn = *pSrc++; 00101 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00102 00103 realIn = *pSrc++; 00104 imagIn = *pSrc++; 00105 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00106 00107 realIn = *pSrc++; 00108 imagIn = *pSrc++; 00109 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00110 00111 00112 /* Decrement the loop counter */ 00113 blkCnt--; 00114 } 00115 00116 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00117 ** No loop unrolling is used. */ 00118 blkCnt = numSamples % 0x4u; 00119 00120 while(blkCnt > 0u) 00121 { 00122 /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ 00123 realIn = *pSrc++; 00124 imagIn = *pSrc++; 00125 /* store the result in the destination buffer. */ 00126 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00127 00128 /* Decrement the loop counter */ 00129 blkCnt--; 00130 } 00131 00132 #else 00133 00134 /* Run the below code for Cortex-M0 */ 00135 00136 while(numSamples > 0u) 00137 { 00138 /* out = sqrt((real * real) + (imag * imag)) */ 00139 realIn = *pSrc++; 00140 imagIn = *pSrc++; 00141 /* store the result in the destination buffer. */ 00142 arm_sqrt_f32((realIn * realIn) + (imagIn * imagIn), pDst++); 00143 00144 /* Decrement the loop counter */ 00145 numSamples--; 00146 } 00147 00148 #endif /* #ifndef ARM_MATH_CM0 */ 00149 00150 } 00151