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_scale_f32.c 00009 * 00010 * Description: Multiplies a floating-point vector by a scalar. 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 00069 void arm_scale_f32( 00070 float32_t * pSrc, 00071 float32_t scale, 00072 float32_t * pDst, 00073 uint32_t blockSize) 00074 { 00075 uint32_t blkCnt; /* loop counter */ 00076 float32_t in1, in2, in3, in4; /* temporary variabels */ 00077 float32_t in5, in6, in7, in8; /* temporary variabels */ 00078 00079 /*loop Unrolling */ 00080 blkCnt = blockSize >> 3u; 00081 00082 /* First part of the processing with loop unrolling. Compute 8 outputs at a time. 00083 ** a second loop below computes the remaining 1 to 7 samples. */ 00084 while(blkCnt > 0u) 00085 { 00086 /* C = A * scale */ 00087 /* Scale the input and then store the results in the destination buffer. */ 00088 /* read input samples from source */ 00089 in1 = *pSrc; 00090 in2 = *(pSrc + 1); 00091 00092 /* multiply with scaling factor */ 00093 in1 = in1 * scale; 00094 00095 /* read input sample from source */ 00096 in3 = *(pSrc + 2); 00097 00098 /* multiply with scaling factor */ 00099 in2 = in2 * scale; 00100 00101 /* read input sample from source */ 00102 in4 = *(pSrc + 3); 00103 00104 /* multiply with scaling factor */ 00105 in3 = in3 * scale; 00106 00107 /* read input sample from source */ 00108 in5 = *(pSrc + 4); 00109 00110 /* multiply with scaling factor */ 00111 in4 = in4 * scale; 00112 00113 /* read input sample from source */ 00114 in6 = *(pSrc + 5); 00115 00116 /* multiply with scaling factor */ 00117 in5 = in5 * scale; 00118 00119 /* read input sample from source */ 00120 in7 = *(pSrc + 6); 00121 00122 /* multiply with scaling factor */ 00123 in6 = in6 * scale; 00124 00125 /* read input sample from source */ 00126 in8 = *(pSrc + 7); 00127 00128 /* multiply with scaling factor */ 00129 in7 = in7 * scale; 00130 00131 /* store the result to destination */ 00132 *pDst = in1; 00133 00134 /* multiply with scaling factor */ 00135 in8 = in8 * scale; 00136 00137 /* store the result to destination */ 00138 *(pDst + 1) = in2; 00139 *(pDst + 2) = in3; 00140 *(pDst + 3) = in4; 00141 *(pDst + 4) = in5; 00142 *(pDst + 5) = in6; 00143 00144 /* increment source pointer by 8 to process next samples */ 00145 pSrc += 8u; 00146 00147 /* store the result to destination */ 00148 *(pDst + 6) = in7; 00149 *(pDst + 7) = in8; 00150 00151 /* increment destination by 8 */ 00152 pDst += 8u; 00153 00154 /* Decrement the loop counter */ 00155 blkCnt--; 00156 } 00157 00158 /* If the blockSize is not a multiple of 8, compute any remaining output samples here. 00159 ** No loop unrolling is used. */ 00160 blkCnt = blockSize % 0x8u; 00161 00162 while(blkCnt > 0u) 00163 { 00164 /* C = A * scale */ 00165 /* Scale the input and then store the result in the destination buffer. */ 00166 *pDst++ = (*pSrc++) * scale; 00167 00168 /* Decrement the loop counter */ 00169 blkCnt--; 00170 } 00171 } 00172