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
00053 arm_status arm_mat_add_q15(
00054 const arm_matrix_instance_q15 * pSrcA,
00055 const arm_matrix_instance_q15 * pSrcB,
00056 arm_matrix_instance_q15 * pDst)
00057 {
00058 q15_t *pInA = pSrcA->pData;
00059 q15_t *pInB = pSrcB->pData;
00060 q15_t *pOut = pDst->pData;
00061 q31_t inA1, inA2, inB1, inB2;
00062 q31_t out1, out2, out3, out4;
00063 uint16_t numSamples;
00064 uint32_t blkCnt;
00065 arm_status status;
00066
00067 #ifdef ARM_MATH_MATRIX_CHECK
00068
00069 if((pSrcA->numRows != pSrcB->numRows) ||
00070 (pSrcA->numCols != pSrcB->numCols) ||
00071 (pSrcA->numRows != pDst->numRows) || (pSrcA->numCols != pDst->numCols))
00072 {
00073
00074 status = ARM_MATH_SIZE_MISMATCH;
00075 }
00076 else
00077 #endif
00078 {
00079
00080 numSamples = (uint16_t) (pSrcA->numRows * pSrcA->numCols);
00081
00082
00083 blkCnt = (uint32_t) numSamples >> 3u;
00084
00085
00086
00087 while(blkCnt > 0u)
00088 {
00089
00090
00091 inA1 = _SIMD32_OFFSET(pInA);
00092
00093
00094 inB1 = _SIMD32_OFFSET(pInB);
00095
00096
00097 inA2 = _SIMD32_OFFSET(pInA + 2);
00098
00099
00100 out1 = __QADD16(inA1, inB1);
00101
00102
00103 inB2 = _SIMD32_OFFSET(pInB + 2);
00104
00105
00106 inA1 = _SIMD32_OFFSET(pInA + 4);
00107
00108
00109 out2 = __QADD16(inA2, inB2);
00110
00111
00112 _SIMD32_OFFSET(pOut) = out1;
00113
00114
00115 inB1 = _SIMD32_OFFSET(pInB + 4);
00116
00117
00118 inA2 = _SIMD32_OFFSET(pInA + 6);
00119
00120
00121 out3 = __QADD16(inA1, inB1);
00122
00123
00124 inB2 = _SIMD32_OFFSET(pInB + 6);
00125
00126
00127 pInA += 8u;
00128
00129
00130 _SIMD32_OFFSET(pOut + 2) = out2;
00131
00132
00133 out4 = __QADD16(inA2, inB2);
00134
00135
00136 _SIMD32_OFFSET(pOut + 4) = out3;
00137
00138
00139 pInB += 8u;
00140
00141
00142 _SIMD32_OFFSET(pOut + 6) = out4;
00143
00144
00145 pOut += 8u;
00146
00147
00148 blkCnt--;
00149 }
00150
00151
00152
00153 blkCnt = (uint32_t) numSamples % 0x8u;
00154
00155
00156
00157 while(blkCnt > 0u)
00158 {
00159
00160
00161 *pOut++ = (q15_t) __QADD16(*pInA++, *pInB++);
00162
00163
00164 blkCnt--;
00165 }
00166
00167
00168 status = ARM_MATH_SUCCESS;
00169 }
00170
00171
00172 return (status);
00173 }
00174