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
00071 arm_status arm_mat_mult_q15(
00072 const arm_matrix_instance_q15 * pSrcA,
00073 const arm_matrix_instance_q15 * pSrcB,
00074 arm_matrix_instance_q15 * pDst,
00075 q15_t *pScratch)
00076 {
00077 q63_t sum;
00078 q31_t in;
00079 q15_t *pSrcBT = pScratch;
00080 q15_t *pInA = pSrcA->pData;
00081 q15_t *pInB = pSrcB->pData;
00082 q15_t *px;
00083 uint16_t numRowsA = pSrcA->numRows;
00084 uint16_t numColsB = pSrcB->numCols;
00085 uint16_t numColsA = pSrcA->numCols;
00086 uint16_t numRowsB = pSrcB->numRows;
00087 uint16_t col, i = 0u, row = numRowsB, colCnt;
00088 arm_status status;
00089
00090 #ifdef UNALIGNED_SUPPORT_DISABLE
00091
00092 q15_t inA1, inB1, inA2, inB2;
00093
00094 #else
00095
00096 q31_t pSourceA1, pSourceB1, pSourceA2, pSourceB2;
00097
00098 #endif
00099
00100 #ifdef ARM_MATH_MATRIX_CHECK
00101
00102 if((pSrcA->numCols != pSrcB->numRows) ||
00103 (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols))
00104 {
00105
00106 status = ARM_MATH_SIZE_MISMATCH;
00107 }
00108 else
00109 #endif
00110 {
00111
00112 do
00113 {
00114
00115 col = numColsB >> 2;
00116
00117
00118 px = pSrcBT + i;
00119
00120
00121
00122 while(col > 0u)
00123 {
00124
00125 in = *__SIMD32(pInB)++;
00126
00127
00128 #ifndef ARM_MATH_BIG_ENDIAN
00129
00130 *px = (q15_t) in;
00131
00132 #else
00133
00134 *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16);
00135
00136 #endif
00137
00138
00139 px += numRowsB;
00140
00141
00142 #ifndef ARM_MATH_BIG_ENDIAN
00143
00144 *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16);
00145
00146 #else
00147
00148 *px = (q15_t) in;
00149
00150 #endif
00151
00152
00153 px += numRowsB;
00154
00155
00156 in = *__SIMD32(pInB)++;
00157
00158
00159 #ifndef ARM_MATH_BIG_ENDIAN
00160
00161 *px = (q15_t) in;
00162
00163 #else
00164
00165 *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16);
00166
00167 #endif
00168
00169
00170 px += numRowsB;
00171
00172
00173
00174 #ifndef ARM_MATH_BIG_ENDIAN
00175
00176 *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16);
00177
00178 #else
00179
00180 *px = (q15_t) in;
00181
00182 #endif
00183
00184
00185 px += numRowsB;
00186
00187
00188 col--;
00189 }
00190
00191
00192
00193 col = numColsB % 0x4u;
00194
00195 while(col > 0u)
00196 {
00197
00198 *px = *pInB++;
00199
00200
00201 px += numRowsB;
00202
00203
00204 col--;
00205 }
00206
00207 i++;
00208
00209
00210 row--;
00211
00212 } while(row > 0u);
00213
00214
00215 row = numRowsA;
00216 i = 0u;
00217 px = pDst->pData;
00218
00219
00220
00221 do
00222 {
00223
00224 col = numColsB;
00225
00226
00227
00228 pInB = pSrcBT;
00229
00230
00231 do
00232 {
00233
00234 sum = 0;
00235
00236
00237 colCnt = numColsA >> 2;
00238
00239
00240 pInA = pSrcA->pData + i;
00241
00242
00243
00244 while(colCnt > 0u)
00245 {
00246
00247 #ifdef UNALIGNED_SUPPORT_DISABLE
00248
00249
00250 inA1 = *pInA++;
00251 inB1 = *pInB++;
00252 inA2 = *pInA++;
00253
00254 sum += inA1 * inB1;
00255 inB2 = *pInB++;
00256
00257 inA1 = *pInA++;
00258 inB1 = *pInB++;
00259
00260 sum += inA2 * inB2;
00261 inA2 = *pInA++;
00262 inB2 = *pInB++;
00263
00264
00265 sum += inA1 * inB1;
00266 sum += inA2 * inB2;
00267
00268 #else
00269
00270 pSourceA1 = *__SIMD32(pInA)++;
00271 pSourceB1 = *__SIMD32(pInB)++;
00272
00273 pSourceA2 = *__SIMD32(pInA)++;
00274 pSourceB2 = *__SIMD32(pInB)++;
00275
00276
00277 sum = __SMLALD(pSourceA1, pSourceB1, sum);
00278 sum = __SMLALD(pSourceA2, pSourceB2, sum);
00279
00280 #endif // #ifdef UNALIGNED_SUPPORT_ENABLE
00281
00282
00283 colCnt--;
00284 }
00285
00286
00287 colCnt = numColsA & 3u;
00288
00289 while(colCnt > 0u)
00290 {
00291
00292 sum += *pInA++ * *pInB++;
00293
00294
00295 colCnt--;
00296 }
00297
00298
00299 #ifdef CCS
00300 *px = (q15_t) (__SSATA(sum, 15, 16));
00301 #else
00302 *px = (q15_t) (__SSAT((sum >> 15), 16));
00303 #endif
00304 px++;
00305
00306
00307 col--;
00308
00309 } while(col > 0u);
00310
00311 i = i + numColsA;
00312
00313
00314 row--;
00315
00316 } while(row > 0u);
00317
00318
00319 status = ARM_MATH_SUCCESS;
00320 }
00321
00322
00323 return (status);
00324 }
00325