Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "arm_math.h"
00026
00052 arm_status arm_mat_scale_q31(
00053 const arm_matrix_instance_q31 * pSrc,
00054 q31_t scaleFract,
00055 int32_t shift,
00056 arm_matrix_instance_q31 * pDst)
00057 {
00058 q31_t *pIn = pSrc->pData;
00059 q31_t *pOut = pDst->pData;
00060 uint32_t numSamples;
00061 int32_t totShift = shift+1;
00062 uint32_t blkCnt;
00063 arm_status status;
00064 q31_t in1, in2, in3, in4;
00065 q31_t out1, out2, out3, out4;
00066
00067
00068 #ifdef ARM_MATH_MATRIX_CHECK
00069
00070 if((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols))
00071 {
00072
00073 status = ARM_MATH_SIZE_MISMATCH;
00074 }
00075 else
00076 #endif
00077 {
00078
00079 numSamples = (uint32_t) pSrc->numRows * pSrc->numCols;
00080
00081
00082 blkCnt = numSamples >> 3u;
00083
00084
00085
00086 while(blkCnt > 0u)
00087 {
00088
00089
00090 in1 = *pIn;
00091 in2 = *(pIn + 1);
00092 in3 = *(pIn + 2);
00093 in4 = *(pIn + 3);
00094
00095
00096 in1 = ((q63_t) in1 * scaleFract) >> 32;
00097 in2 = ((q63_t) in2 * scaleFract) >> 32;
00098 in3 = ((q63_t) in3 * scaleFract) >> 32;
00099 in4 = ((q63_t) in4 * scaleFract) >> 32;
00100
00101
00102 out1 = in1 << totShift;
00103 out2 = in2 << totShift;
00104
00105
00106 if(in1 != (out1 >> totShift))
00107 out1 = 0x7FFFFFFF ^(in1 >> 31);
00108
00109 if(in2 != (out2 >> totShift))
00110 out2 = 0x7FFFFFFF ^(in2 >> 31);
00111
00112 out3 = in3 << totShift;
00113 out4 = in4 << totShift;
00114
00115 *pOut = out1;
00116 *(pOut + 1) = out2;
00117
00118 if(in3 != (out3 >> totShift))
00119 out3 = 0x7FFFFFFF ^(in3 >> 31);
00120
00121 in1 = *(pIn + 4);
00122 in2 = *(pIn + 5);
00123
00124 if(in4 != (out4 >> totShift))
00125 out4 = 0x7FFFFFFF ^(in4 >> 31);
00126
00127
00128 *(pOut + 2) = out3;
00129 *(pOut + 3) = out4;
00130
00131 in3 = *(pIn + 6);
00132 in4 = *(pIn + 7);
00133
00134
00135 in1 = ((q63_t) in1 * scaleFract) >> 32;
00136 in2 = ((q63_t) in2 * scaleFract) >> 32;
00137 in3 = ((q63_t) in3 * scaleFract) >> 32;
00138 in4 = ((q63_t) in4 * scaleFract) >> 32;
00139
00140
00141 out1 = in1 << totShift;
00142 out2 = in2 << totShift;
00143
00144
00145 if(in1 != (out1 >> totShift))
00146 out1 = 0x7FFFFFFF ^(in1 >> 31);
00147
00148 if(in2 != (out2 >> totShift))
00149 out2 = 0x7FFFFFFF ^(in2 >> 31);
00150
00151 *(pOut + 4) = out1;
00152 out3 = in3 << totShift;
00153 *(pOut + 5) = out2;
00154 out4 = in4 << totShift;
00155
00156 if(in3 != (out3 >> totShift))
00157 out3 = 0x7FFFFFFF ^(in3 >> 31);
00158
00159 if(in4 != (out4 >> totShift))
00160 out4 = 0x7FFFFFFF ^(in4 >> 31);
00161
00162
00163 *(pOut + 6) = out3;
00164 *(pOut + 7) = out4;
00165
00166 pIn += 8u;
00167 pOut += 8u;
00168
00169
00170 blkCnt--;
00171 }
00172
00173
00174
00175 blkCnt = numSamples % 0x8u;
00176
00177 while(blkCnt > 0u)
00178 {
00179
00180
00181 in1 = *pIn++;
00182
00183 in2 = ((q63_t)in1 * scaleFract) >> 32;
00184
00185 out1 = in2 << totShift;
00186
00187 if(in2 != (out1 >> totShift))
00188 out1 = 0x7FFFFFFF ^(in2 >> 31);
00189
00190 *pOut++ = out1;
00191
00192
00193 blkCnt--;
00194 }
00195
00196
00197 status = ARM_MATH_SUCCESS;
00198 }
00199
00200
00201 return (status);
00202 }
00203