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