00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_abs_f32.c 00009 * 00010 * Description: Vector absolute value. 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * ---------------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 #include <math.h> 00026 00057 void arm_abs_f32( 00058 float32_t * pSrc, 00059 float32_t * pDst, 00060 uint32_t blockSize) 00061 { 00062 uint32_t blkCnt; /* loop counter */ 00063 float32_t in1, in2, in3, in4; /* temporary variables */ 00064 00065 /*loop Unrolling */ 00066 blkCnt = blockSize >> 3u; 00067 00068 /* First part of the processing with loop unrolling. Compute 8 outputs at a time. 00069 ** a second loop below computes the remaining 1 to 7 samples. */ 00070 while(blkCnt > 0u) 00071 { 00072 /* C = |A| */ 00073 /* Calculate absolute and then store the results in the destination buffer. */ 00074 /* read sample from source */ 00075 in1 = *pSrc; 00076 in2 = *(pSrc + 1); 00077 in3 = *(pSrc + 2); 00078 00079 /* find absolute value */ 00080 in1 = fabsf(in1); 00081 00082 /* read sample from source */ 00083 in4 = *(pSrc + 3); 00084 00085 /* find absolute value */ 00086 in2 = fabsf(in2); 00087 00088 /* read sample from source */ 00089 *pDst = in1; 00090 00091 /* find absolute value */ 00092 in3 = fabsf(in3); 00093 00094 /* read sample from source */ 00095 in1 = *(pSrc + 4); 00096 00097 /* find absolute value */ 00098 in4 = fabsf(in4); 00099 00100 /* store result to destination */ 00101 *(pDst + 1) = in2; 00102 00103 /* read sample from source */ 00104 in2 = *(pSrc + 5); 00105 00106 /* find absolute value */ 00107 in1 = fabsf(in1); 00108 00109 /* store result to destination */ 00110 *(pDst + 2) = in3; 00111 00112 /* read sample from source */ 00113 in3 = *(pSrc + 6); 00114 00115 /* find absolute value */ 00116 in2 = fabsf(in2); 00117 00118 /* store result to destination */ 00119 *(pDst + 3) = in4; 00120 00121 /* read sample from source */ 00122 in4 = *(pSrc + 7); 00123 00124 /* find absolute value */ 00125 in3 = fabsf(in3); 00126 00127 /* store result to destination */ 00128 *(pDst + 4) = in1; 00129 00130 /* find absolute value */ 00131 in4 = fabsf(in4); 00132 00133 /* store result to destination */ 00134 *(pDst + 5) = in2; 00135 *(pDst + 6) = in3; 00136 00137 /* Update source pointer to process next sampels */ 00138 pSrc += 8u; 00139 00140 /* store result to destination */ 00141 *(pDst + 7) = in4; 00142 00143 /* Update destination pointer to process next sampels */ 00144 pDst += 8u; 00145 00146 /* Decrement the loop counter */ 00147 blkCnt--; 00148 } 00149 00150 /* If the blockSize is not a multiple of 8, compute any remaining output samples here. 00151 ** No loop unrolling is used. */ 00152 blkCnt = blockSize % 0x8u; 00153 00154 while(blkCnt > 0u) 00155 { 00156 /* C = |A| */ 00157 /* Calculate absolute and then store the results in the destination buffer. */ 00158 *pDst++ = fabsf(*pSrc++); 00159 00160 /* Decrement the loop counter */ 00161 blkCnt--; 00162 } 00163 } 00164