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