The CMSIS DSP 5 library

Dependents:   Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more

Committer:
xorjoep
Date:
Thu Jun 21 11:56:27 2018 +0000
Revision:
3:4098b9d3d571
Parent:
1:24714b45cd1b
headers is a folder not a library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xorjoep 1:24714b45cd1b 1 /* ----------------------------------------------------------------------
xorjoep 1:24714b45cd1b 2 * Project: CMSIS DSP Library
xorjoep 1:24714b45cd1b 3 * Title: arm_mat_mult_fast_q31.c
xorjoep 1:24714b45cd1b 4 * Description: Q31 matrix multiplication (fast variant)
xorjoep 1:24714b45cd1b 5 *
xorjoep 1:24714b45cd1b 6 * $Date: 27. January 2017
xorjoep 1:24714b45cd1b 7 * $Revision: V.1.5.1
xorjoep 1:24714b45cd1b 8 *
xorjoep 1:24714b45cd1b 9 * Target Processor: Cortex-M cores
xorjoep 1:24714b45cd1b 10 * -------------------------------------------------------------------- */
xorjoep 1:24714b45cd1b 11 /*
xorjoep 1:24714b45cd1b 12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
xorjoep 1:24714b45cd1b 13 *
xorjoep 1:24714b45cd1b 14 * SPDX-License-Identifier: Apache-2.0
xorjoep 1:24714b45cd1b 15 *
xorjoep 1:24714b45cd1b 16 * Licensed under the Apache License, Version 2.0 (the License); you may
xorjoep 1:24714b45cd1b 17 * not use this file except in compliance with the License.
xorjoep 1:24714b45cd1b 18 * You may obtain a copy of the License at
xorjoep 1:24714b45cd1b 19 *
xorjoep 1:24714b45cd1b 20 * www.apache.org/licenses/LICENSE-2.0
xorjoep 1:24714b45cd1b 21 *
xorjoep 1:24714b45cd1b 22 * Unless required by applicable law or agreed to in writing, software
xorjoep 1:24714b45cd1b 23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
xorjoep 1:24714b45cd1b 24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
xorjoep 1:24714b45cd1b 25 * See the License for the specific language governing permissions and
xorjoep 1:24714b45cd1b 26 * limitations under the License.
xorjoep 1:24714b45cd1b 27 */
xorjoep 1:24714b45cd1b 28
xorjoep 1:24714b45cd1b 29 #include "arm_math.h"
xorjoep 1:24714b45cd1b 30
xorjoep 1:24714b45cd1b 31 /**
xorjoep 1:24714b45cd1b 32 * @ingroup groupMatrix
xorjoep 1:24714b45cd1b 33 */
xorjoep 1:24714b45cd1b 34
xorjoep 1:24714b45cd1b 35 /**
xorjoep 1:24714b45cd1b 36 * @addtogroup MatrixMult
xorjoep 1:24714b45cd1b 37 * @{
xorjoep 1:24714b45cd1b 38 */
xorjoep 1:24714b45cd1b 39
xorjoep 1:24714b45cd1b 40 /**
xorjoep 1:24714b45cd1b 41 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
xorjoep 1:24714b45cd1b 42 * @param[in] *pSrcA points to the first input matrix structure
xorjoep 1:24714b45cd1b 43 * @param[in] *pSrcB points to the second input matrix structure
xorjoep 1:24714b45cd1b 44 * @param[out] *pDst points to output matrix structure
xorjoep 1:24714b45cd1b 45 * @return The function returns either
xorjoep 1:24714b45cd1b 46 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
xorjoep 1:24714b45cd1b 47 *
xorjoep 1:24714b45cd1b 48 * @details
xorjoep 1:24714b45cd1b 49 * <b>Scaling and Overflow Behavior:</b>
xorjoep 1:24714b45cd1b 50 *
xorjoep 1:24714b45cd1b 51 * \par
xorjoep 1:24714b45cd1b 52 * The difference between the function arm_mat_mult_q31() and this fast variant is that
xorjoep 1:24714b45cd1b 53 * the fast variant use a 32-bit rather than a 64-bit accumulator.
xorjoep 1:24714b45cd1b 54 * The result of each 1.31 x 1.31 multiplication is truncated to
xorjoep 1:24714b45cd1b 55 * 2.30 format. These intermediate results are accumulated in a 32-bit register in 2.30
xorjoep 1:24714b45cd1b 56 * format. Finally, the accumulator is saturated and converted to a 1.31 result.
xorjoep 1:24714b45cd1b 57 *
xorjoep 1:24714b45cd1b 58 * \par
xorjoep 1:24714b45cd1b 59 * The fast version has the same overflow behavior as the standard version but provides
xorjoep 1:24714b45cd1b 60 * less precision since it discards the low 32 bits of each multiplication result.
xorjoep 1:24714b45cd1b 61 * In order to avoid overflows completely the input signals must be scaled down.
xorjoep 1:24714b45cd1b 62 * Scale down one of the input matrices by log2(numColsA) bits to
xorjoep 1:24714b45cd1b 63 * avoid overflows, as a total of numColsA additions are computed internally for each
xorjoep 1:24714b45cd1b 64 * output element.
xorjoep 1:24714b45cd1b 65 *
xorjoep 1:24714b45cd1b 66 * \par
xorjoep 1:24714b45cd1b 67 * See <code>arm_mat_mult_q31()</code> for a slower implementation of this function
xorjoep 1:24714b45cd1b 68 * which uses 64-bit accumulation to provide higher precision.
xorjoep 1:24714b45cd1b 69 */
xorjoep 1:24714b45cd1b 70
xorjoep 1:24714b45cd1b 71 arm_status arm_mat_mult_fast_q31(
xorjoep 1:24714b45cd1b 72 const arm_matrix_instance_q31 * pSrcA,
xorjoep 1:24714b45cd1b 73 const arm_matrix_instance_q31 * pSrcB,
xorjoep 1:24714b45cd1b 74 arm_matrix_instance_q31 * pDst)
xorjoep 1:24714b45cd1b 75 {
xorjoep 1:24714b45cd1b 76 q31_t *pInA = pSrcA->pData; /* input data matrix pointer A */
xorjoep 1:24714b45cd1b 77 q31_t *pInB = pSrcB->pData; /* input data matrix pointer B */
xorjoep 1:24714b45cd1b 78 q31_t *px; /* Temporary output data matrix pointer */
xorjoep 1:24714b45cd1b 79 q31_t sum; /* Accumulator */
xorjoep 1:24714b45cd1b 80 uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */
xorjoep 1:24714b45cd1b 81 uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */
xorjoep 1:24714b45cd1b 82 uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */
xorjoep 1:24714b45cd1b 83 uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* loop counters */
xorjoep 1:24714b45cd1b 84 arm_status status; /* status of matrix multiplication */
xorjoep 1:24714b45cd1b 85 q31_t inA1, inB1;
xorjoep 1:24714b45cd1b 86
xorjoep 1:24714b45cd1b 87 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 88
xorjoep 1:24714b45cd1b 89 q31_t sum2, sum3, sum4;
xorjoep 1:24714b45cd1b 90 q31_t inA2, inB2;
xorjoep 1:24714b45cd1b 91 q31_t *pInA2;
xorjoep 1:24714b45cd1b 92 q31_t *px2;
xorjoep 1:24714b45cd1b 93
xorjoep 1:24714b45cd1b 94 #endif
xorjoep 1:24714b45cd1b 95
xorjoep 1:24714b45cd1b 96 #ifdef ARM_MATH_MATRIX_CHECK
xorjoep 1:24714b45cd1b 97
xorjoep 1:24714b45cd1b 98 /* Check for matrix mismatch condition */
xorjoep 1:24714b45cd1b 99 if ((pSrcA->numCols != pSrcB->numRows) ||
xorjoep 1:24714b45cd1b 100 (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols))
xorjoep 1:24714b45cd1b 101 {
xorjoep 1:24714b45cd1b 102 /* Set status as ARM_MATH_SIZE_MISMATCH */
xorjoep 1:24714b45cd1b 103 status = ARM_MATH_SIZE_MISMATCH;
xorjoep 1:24714b45cd1b 104 }
xorjoep 1:24714b45cd1b 105 else
xorjoep 1:24714b45cd1b 106 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
xorjoep 1:24714b45cd1b 107
xorjoep 1:24714b45cd1b 108 {
xorjoep 1:24714b45cd1b 109
xorjoep 1:24714b45cd1b 110 px = pDst->pData;
xorjoep 1:24714b45cd1b 111
xorjoep 1:24714b45cd1b 112 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 113 row = row >> 1;
xorjoep 1:24714b45cd1b 114 px2 = px + numColsB;
xorjoep 1:24714b45cd1b 115 #endif
xorjoep 1:24714b45cd1b 116
xorjoep 1:24714b45cd1b 117 /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */
xorjoep 1:24714b45cd1b 118 /* row loop */
xorjoep 1:24714b45cd1b 119 while (row > 0U)
xorjoep 1:24714b45cd1b 120 {
xorjoep 1:24714b45cd1b 121
xorjoep 1:24714b45cd1b 122 /* For every row wise process, the column loop counter is to be initiated */
xorjoep 1:24714b45cd1b 123 col = numColsB;
xorjoep 1:24714b45cd1b 124
xorjoep 1:24714b45cd1b 125 /* For every row wise process, the pIn2 pointer is set
xorjoep 1:24714b45cd1b 126 ** to the starting address of the pSrcB data */
xorjoep 1:24714b45cd1b 127 pInB = pSrcB->pData;
xorjoep 1:24714b45cd1b 128
xorjoep 1:24714b45cd1b 129 j = 0U;
xorjoep 1:24714b45cd1b 130
xorjoep 1:24714b45cd1b 131 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 132 col = col >> 1;
xorjoep 1:24714b45cd1b 133 #endif
xorjoep 1:24714b45cd1b 134
xorjoep 1:24714b45cd1b 135 /* column loop */
xorjoep 1:24714b45cd1b 136 while (col > 0U)
xorjoep 1:24714b45cd1b 137 {
xorjoep 1:24714b45cd1b 138 /* Set the variable sum, that acts as accumulator, to zero */
xorjoep 1:24714b45cd1b 139 sum = 0;
xorjoep 1:24714b45cd1b 140
xorjoep 1:24714b45cd1b 141 /* Initiate data pointers */
xorjoep 1:24714b45cd1b 142 pInA = pSrcA->pData + i;
xorjoep 1:24714b45cd1b 143 pInB = pSrcB->pData + j;
xorjoep 1:24714b45cd1b 144
xorjoep 1:24714b45cd1b 145 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 146 sum2 = 0;
xorjoep 1:24714b45cd1b 147 sum3 = 0;
xorjoep 1:24714b45cd1b 148 sum4 = 0;
xorjoep 1:24714b45cd1b 149 pInA2 = pInA + numColsA;
xorjoep 1:24714b45cd1b 150 colCnt = numColsA;
xorjoep 1:24714b45cd1b 151 #else
xorjoep 1:24714b45cd1b 152 colCnt = numColsA >> 2;
xorjoep 1:24714b45cd1b 153 #endif
xorjoep 1:24714b45cd1b 154
xorjoep 1:24714b45cd1b 155 /* matrix multiplication */
xorjoep 1:24714b45cd1b 156 while (colCnt > 0U)
xorjoep 1:24714b45cd1b 157 {
xorjoep 1:24714b45cd1b 158
xorjoep 1:24714b45cd1b 159 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 160 inA1 = *pInA++;
xorjoep 1:24714b45cd1b 161 inB1 = pInB[0];
xorjoep 1:24714b45cd1b 162 inA2 = *pInA2++;
xorjoep 1:24714b45cd1b 163 inB2 = pInB[1];
xorjoep 1:24714b45cd1b 164 pInB += numColsB;
xorjoep 1:24714b45cd1b 165
xorjoep 1:24714b45cd1b 166 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 167 sum2 = __SMMLA(inA1, inB2, sum2);
xorjoep 1:24714b45cd1b 168 sum3 = __SMMLA(inA2, inB1, sum3);
xorjoep 1:24714b45cd1b 169 sum4 = __SMMLA(inA2, inB2, sum4);
xorjoep 1:24714b45cd1b 170 #else
xorjoep 1:24714b45cd1b 171 /* c(m,n) = a(1,1)*b(1,1) + a(1,2) * b(2,1) + .... + a(m,p)*b(p,n) */
xorjoep 1:24714b45cd1b 172 /* Perform the multiply-accumulates */
xorjoep 1:24714b45cd1b 173 inB1 = *pInB;
xorjoep 1:24714b45cd1b 174 pInB += numColsB;
xorjoep 1:24714b45cd1b 175 inA1 = pInA[0];
xorjoep 1:24714b45cd1b 176 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 177
xorjoep 1:24714b45cd1b 178 inB1 = *pInB;
xorjoep 1:24714b45cd1b 179 pInB += numColsB;
xorjoep 1:24714b45cd1b 180 inA1 = pInA[1];
xorjoep 1:24714b45cd1b 181 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 182
xorjoep 1:24714b45cd1b 183 inB1 = *pInB;
xorjoep 1:24714b45cd1b 184 pInB += numColsB;
xorjoep 1:24714b45cd1b 185 inA1 = pInA[2];
xorjoep 1:24714b45cd1b 186 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 187
xorjoep 1:24714b45cd1b 188 inB1 = *pInB;
xorjoep 1:24714b45cd1b 189 pInB += numColsB;
xorjoep 1:24714b45cd1b 190 inA1 = pInA[3];
xorjoep 1:24714b45cd1b 191 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 192
xorjoep 1:24714b45cd1b 193 pInA += 4U;
xorjoep 1:24714b45cd1b 194 #endif
xorjoep 1:24714b45cd1b 195
xorjoep 1:24714b45cd1b 196 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 197 colCnt--;
xorjoep 1:24714b45cd1b 198 }
xorjoep 1:24714b45cd1b 199
xorjoep 1:24714b45cd1b 200 #ifdef ARM_MATH_CM0_FAMILY
xorjoep 1:24714b45cd1b 201 /* If the columns of pSrcA is not a multiple of 4, compute any remaining output samples here. */
xorjoep 1:24714b45cd1b 202 colCnt = numColsA % 0x4U;
xorjoep 1:24714b45cd1b 203 while (colCnt > 0U)
xorjoep 1:24714b45cd1b 204 {
xorjoep 1:24714b45cd1b 205 sum = __SMMLA(*pInA++, *pInB, sum);
xorjoep 1:24714b45cd1b 206 pInB += numColsB;
xorjoep 1:24714b45cd1b 207 colCnt--;
xorjoep 1:24714b45cd1b 208 }
xorjoep 1:24714b45cd1b 209 j++;
xorjoep 1:24714b45cd1b 210 #endif
xorjoep 1:24714b45cd1b 211
xorjoep 1:24714b45cd1b 212 /* Convert the result from 2.30 to 1.31 format and store in destination buffer */
xorjoep 1:24714b45cd1b 213 *px++ = sum << 1;
xorjoep 1:24714b45cd1b 214
xorjoep 1:24714b45cd1b 215 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 216 *px++ = sum2 << 1;
xorjoep 1:24714b45cd1b 217 *px2++ = sum3 << 1;
xorjoep 1:24714b45cd1b 218 *px2++ = sum4 << 1;
xorjoep 1:24714b45cd1b 219 j += 2;
xorjoep 1:24714b45cd1b 220 #endif
xorjoep 1:24714b45cd1b 221
xorjoep 1:24714b45cd1b 222 /* Decrement the column loop counter */
xorjoep 1:24714b45cd1b 223 col--;
xorjoep 1:24714b45cd1b 224
xorjoep 1:24714b45cd1b 225 }
xorjoep 1:24714b45cd1b 226
xorjoep 1:24714b45cd1b 227 i = i + numColsA;
xorjoep 1:24714b45cd1b 228
xorjoep 1:24714b45cd1b 229 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 230 i = i + numColsA;
xorjoep 1:24714b45cd1b 231 px = px2 + (numColsB & 1U);
xorjoep 1:24714b45cd1b 232 px2 = px + numColsB;
xorjoep 1:24714b45cd1b 233 #endif
xorjoep 1:24714b45cd1b 234
xorjoep 1:24714b45cd1b 235 /* Decrement the row loop counter */
xorjoep 1:24714b45cd1b 236 row--;
xorjoep 1:24714b45cd1b 237
xorjoep 1:24714b45cd1b 238 }
xorjoep 1:24714b45cd1b 239
xorjoep 1:24714b45cd1b 240 /* Compute any remaining odd row/column below */
xorjoep 1:24714b45cd1b 241
xorjoep 1:24714b45cd1b 242 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 243
xorjoep 1:24714b45cd1b 244 /* Compute remaining output column */
xorjoep 1:24714b45cd1b 245 if (numColsB & 1U) {
xorjoep 1:24714b45cd1b 246
xorjoep 1:24714b45cd1b 247 /* Avoid redundant computation of last element */
xorjoep 1:24714b45cd1b 248 row = numRowsA & (~0x1);
xorjoep 1:24714b45cd1b 249
xorjoep 1:24714b45cd1b 250 /* Point to remaining unfilled column in output matrix */
xorjoep 1:24714b45cd1b 251 px = pDst->pData+numColsB-1;
xorjoep 1:24714b45cd1b 252 pInA = pSrcA->pData;
xorjoep 1:24714b45cd1b 253
xorjoep 1:24714b45cd1b 254 /* row loop */
xorjoep 1:24714b45cd1b 255 while (row > 0)
xorjoep 1:24714b45cd1b 256 {
xorjoep 1:24714b45cd1b 257
xorjoep 1:24714b45cd1b 258 /* point to last column in matrix B */
xorjoep 1:24714b45cd1b 259 pInB = pSrcB->pData + numColsB-1;
xorjoep 1:24714b45cd1b 260
xorjoep 1:24714b45cd1b 261 /* Set the variable sum, that acts as accumulator, to zero */
xorjoep 1:24714b45cd1b 262 sum = 0;
xorjoep 1:24714b45cd1b 263
xorjoep 1:24714b45cd1b 264 /* Compute 4 columns at once */
xorjoep 1:24714b45cd1b 265 colCnt = numColsA >> 2;
xorjoep 1:24714b45cd1b 266
xorjoep 1:24714b45cd1b 267 /* matrix multiplication */
xorjoep 1:24714b45cd1b 268 while (colCnt > 0U)
xorjoep 1:24714b45cd1b 269 {
xorjoep 1:24714b45cd1b 270 inA1 = *pInA++;
xorjoep 1:24714b45cd1b 271 inA2 = *pInA++;
xorjoep 1:24714b45cd1b 272 inB1 = *pInB;
xorjoep 1:24714b45cd1b 273 pInB += numColsB;
xorjoep 1:24714b45cd1b 274 inB2 = *pInB;
xorjoep 1:24714b45cd1b 275 pInB += numColsB;
xorjoep 1:24714b45cd1b 276 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 277 sum = __SMMLA(inA2, inB2, sum);
xorjoep 1:24714b45cd1b 278
xorjoep 1:24714b45cd1b 279 inA1 = *pInA++;
xorjoep 1:24714b45cd1b 280 inA2 = *pInA++;
xorjoep 1:24714b45cd1b 281 inB1 = *pInB;
xorjoep 1:24714b45cd1b 282 pInB += numColsB;
xorjoep 1:24714b45cd1b 283 inB2 = *pInB;
xorjoep 1:24714b45cd1b 284 pInB += numColsB;
xorjoep 1:24714b45cd1b 285 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 286 sum = __SMMLA(inA2, inB2, sum);
xorjoep 1:24714b45cd1b 287
xorjoep 1:24714b45cd1b 288 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 289 colCnt--;
xorjoep 1:24714b45cd1b 290 }
xorjoep 1:24714b45cd1b 291
xorjoep 1:24714b45cd1b 292 colCnt = numColsA & 3U;
xorjoep 1:24714b45cd1b 293 while (colCnt > 0U) {
xorjoep 1:24714b45cd1b 294 sum = __SMMLA(*pInA++, *pInB, sum);
xorjoep 1:24714b45cd1b 295 pInB += numColsB;
xorjoep 1:24714b45cd1b 296 colCnt--;
xorjoep 1:24714b45cd1b 297 }
xorjoep 1:24714b45cd1b 298
xorjoep 1:24714b45cd1b 299 /* Convert the result from 2.30 to 1.31 format and store in destination buffer */
xorjoep 1:24714b45cd1b 300 *px = sum << 1;
xorjoep 1:24714b45cd1b 301 px += numColsB;
xorjoep 1:24714b45cd1b 302
xorjoep 1:24714b45cd1b 303 /* Decrement the row loop counter */
xorjoep 1:24714b45cd1b 304 row--;
xorjoep 1:24714b45cd1b 305 }
xorjoep 1:24714b45cd1b 306 }
xorjoep 1:24714b45cd1b 307
xorjoep 1:24714b45cd1b 308 /* Compute remaining output row */
xorjoep 1:24714b45cd1b 309 if (numRowsA & 1U) {
xorjoep 1:24714b45cd1b 310
xorjoep 1:24714b45cd1b 311 /* point to last row in output matrix */
xorjoep 1:24714b45cd1b 312 px = pDst->pData+(numColsB)*(numRowsA-1);
xorjoep 1:24714b45cd1b 313
xorjoep 1:24714b45cd1b 314 col = numColsB;
xorjoep 1:24714b45cd1b 315 i = 0U;
xorjoep 1:24714b45cd1b 316
xorjoep 1:24714b45cd1b 317 /* col loop */
xorjoep 1:24714b45cd1b 318 while (col > 0)
xorjoep 1:24714b45cd1b 319 {
xorjoep 1:24714b45cd1b 320
xorjoep 1:24714b45cd1b 321 /* point to last row in matrix A */
xorjoep 1:24714b45cd1b 322 pInA = pSrcA->pData + (numRowsA-1)*numColsA;
xorjoep 1:24714b45cd1b 323 pInB = pSrcB->pData + i;
xorjoep 1:24714b45cd1b 324
xorjoep 1:24714b45cd1b 325 /* Set the variable sum, that acts as accumulator, to zero */
xorjoep 1:24714b45cd1b 326 sum = 0;
xorjoep 1:24714b45cd1b 327
xorjoep 1:24714b45cd1b 328 /* Compute 4 columns at once */
xorjoep 1:24714b45cd1b 329 colCnt = numColsA >> 2;
xorjoep 1:24714b45cd1b 330
xorjoep 1:24714b45cd1b 331 /* matrix multiplication */
xorjoep 1:24714b45cd1b 332 while (colCnt > 0U)
xorjoep 1:24714b45cd1b 333 {
xorjoep 1:24714b45cd1b 334 inA1 = *pInA++;
xorjoep 1:24714b45cd1b 335 inA2 = *pInA++;
xorjoep 1:24714b45cd1b 336 inB1 = *pInB;
xorjoep 1:24714b45cd1b 337 pInB += numColsB;
xorjoep 1:24714b45cd1b 338 inB2 = *pInB;
xorjoep 1:24714b45cd1b 339 pInB += numColsB;
xorjoep 1:24714b45cd1b 340 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 341 sum = __SMMLA(inA2, inB2, sum);
xorjoep 1:24714b45cd1b 342
xorjoep 1:24714b45cd1b 343 inA1 = *pInA++;
xorjoep 1:24714b45cd1b 344 inA2 = *pInA++;
xorjoep 1:24714b45cd1b 345 inB1 = *pInB;
xorjoep 1:24714b45cd1b 346 pInB += numColsB;
xorjoep 1:24714b45cd1b 347 inB2 = *pInB;
xorjoep 1:24714b45cd1b 348 pInB += numColsB;
xorjoep 1:24714b45cd1b 349 sum = __SMMLA(inA1, inB1, sum);
xorjoep 1:24714b45cd1b 350 sum = __SMMLA(inA2, inB2, sum);
xorjoep 1:24714b45cd1b 351
xorjoep 1:24714b45cd1b 352 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 353 colCnt--;
xorjoep 1:24714b45cd1b 354 }
xorjoep 1:24714b45cd1b 355
xorjoep 1:24714b45cd1b 356 colCnt = numColsA & 3U;
xorjoep 1:24714b45cd1b 357 while (colCnt > 0U) {
xorjoep 1:24714b45cd1b 358 sum = __SMMLA(*pInA++, *pInB, sum);
xorjoep 1:24714b45cd1b 359 pInB += numColsB;
xorjoep 1:24714b45cd1b 360 colCnt--;
xorjoep 1:24714b45cd1b 361 }
xorjoep 1:24714b45cd1b 362
xorjoep 1:24714b45cd1b 363 /* Saturate and store the result in the destination buffer */
xorjoep 1:24714b45cd1b 364 *px++ = sum << 1;
xorjoep 1:24714b45cd1b 365 i++;
xorjoep 1:24714b45cd1b 366
xorjoep 1:24714b45cd1b 367 /* Decrement the col loop counter */
xorjoep 1:24714b45cd1b 368 col--;
xorjoep 1:24714b45cd1b 369 }
xorjoep 1:24714b45cd1b 370 }
xorjoep 1:24714b45cd1b 371
xorjoep 1:24714b45cd1b 372 #endif /* #if defined (ARM_MATH_DSP) */
xorjoep 1:24714b45cd1b 373
xorjoep 1:24714b45cd1b 374 /* set status as ARM_MATH_SUCCESS */
xorjoep 1:24714b45cd1b 375 status = ARM_MATH_SUCCESS;
xorjoep 1:24714b45cd1b 376 }
xorjoep 1:24714b45cd1b 377
xorjoep 1:24714b45cd1b 378 /* Return to application */
xorjoep 1:24714b45cd1b 379 return (status);
xorjoep 1:24714b45cd1b 380 }
xorjoep 1:24714b45cd1b 381
xorjoep 1:24714b45cd1b 382 /**
xorjoep 1:24714b45cd1b 383 * @} end of MatrixMult group
xorjoep 1:24714b45cd1b 384 */