CMSIS DSP library
Dependents: performance_timer Surfboard_ gps2rtty Capstone ... more
Legacy Warning
This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.
cmsis_dsp/MatrixFunctions/arm_mat_cmplx_mult_q15.c@5:3762170b6d4d, 2015-11-20 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Nov 20 08:45:18 2015 +0000
- Revision:
- 5:3762170b6d4d
Synchronized with git revision 2eb940b9a73af188d3004a2575fdfbb05febe62b
Full URL: https://github.com/mbedmicro/mbed/commit/2eb940b9a73af188d3004a2575fdfbb05febe62b/
Added option to build rpc library. closes #1426
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 5:3762170b6d4d | 1 | /* ---------------------------------------------------------------------- |
mbed_official | 5:3762170b6d4d | 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
mbed_official | 5:3762170b6d4d | 3 | * |
mbed_official | 5:3762170b6d4d | 4 | * $Date: 19. March 2015 |
mbed_official | 5:3762170b6d4d | 5 | * $Revision: V.1.4.5 |
mbed_official | 5:3762170b6d4d | 6 | * |
mbed_official | 5:3762170b6d4d | 7 | * Project: CMSIS DSP Library |
mbed_official | 5:3762170b6d4d | 8 | * Title: arm_cmplx_mat_mult_q15.c |
mbed_official | 5:3762170b6d4d | 9 | * |
mbed_official | 5:3762170b6d4d | 10 | * Description: Q15 complex matrix multiplication. |
mbed_official | 5:3762170b6d4d | 11 | * |
mbed_official | 5:3762170b6d4d | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
mbed_official | 5:3762170b6d4d | 13 | * |
mbed_official | 5:3762170b6d4d | 14 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 5:3762170b6d4d | 15 | * modification, are permitted provided that the following conditions |
mbed_official | 5:3762170b6d4d | 16 | * are met: |
mbed_official | 5:3762170b6d4d | 17 | * - Redistributions of source code must retain the above copyright |
mbed_official | 5:3762170b6d4d | 18 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 5:3762170b6d4d | 19 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 5:3762170b6d4d | 20 | * notice, this list of conditions and the following disclaimer in |
mbed_official | 5:3762170b6d4d | 21 | * the documentation and/or other materials provided with the |
mbed_official | 5:3762170b6d4d | 22 | * distribution. |
mbed_official | 5:3762170b6d4d | 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
mbed_official | 5:3762170b6d4d | 24 | * may be used to endorse or promote products derived from this |
mbed_official | 5:3762170b6d4d | 25 | * software without specific prior written permission. |
mbed_official | 5:3762170b6d4d | 26 | * |
mbed_official | 5:3762170b6d4d | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
mbed_official | 5:3762170b6d4d | 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
mbed_official | 5:3762170b6d4d | 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
mbed_official | 5:3762170b6d4d | 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
mbed_official | 5:3762170b6d4d | 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
mbed_official | 5:3762170b6d4d | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
mbed_official | 5:3762170b6d4d | 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
mbed_official | 5:3762170b6d4d | 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 5:3762170b6d4d | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
mbed_official | 5:3762170b6d4d | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
mbed_official | 5:3762170b6d4d | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 5:3762170b6d4d | 38 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 5:3762170b6d4d | 39 | * -------------------------------------------------------------------- */ |
mbed_official | 5:3762170b6d4d | 40 | #include "arm_math.h" |
mbed_official | 5:3762170b6d4d | 41 | |
mbed_official | 5:3762170b6d4d | 42 | /** |
mbed_official | 5:3762170b6d4d | 43 | * @ingroup groupMatrix |
mbed_official | 5:3762170b6d4d | 44 | */ |
mbed_official | 5:3762170b6d4d | 45 | |
mbed_official | 5:3762170b6d4d | 46 | /** |
mbed_official | 5:3762170b6d4d | 47 | * @addtogroup CmplxMatrixMult |
mbed_official | 5:3762170b6d4d | 48 | * @{ |
mbed_official | 5:3762170b6d4d | 49 | */ |
mbed_official | 5:3762170b6d4d | 50 | |
mbed_official | 5:3762170b6d4d | 51 | |
mbed_official | 5:3762170b6d4d | 52 | /** |
mbed_official | 5:3762170b6d4d | 53 | * @brief Q15 Complex matrix multiplication |
mbed_official | 5:3762170b6d4d | 54 | * @param[in] *pSrcA points to the first input complex matrix structure |
mbed_official | 5:3762170b6d4d | 55 | * @param[in] *pSrcB points to the second input complex matrix structure |
mbed_official | 5:3762170b6d4d | 56 | * @param[out] *pDst points to output complex matrix structure |
mbed_official | 5:3762170b6d4d | 57 | * @param[in] *pScratch points to the array for storing intermediate results |
mbed_official | 5:3762170b6d4d | 58 | * @return The function returns either |
mbed_official | 5:3762170b6d4d | 59 | * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. |
mbed_official | 5:3762170b6d4d | 60 | * |
mbed_official | 5:3762170b6d4d | 61 | * \par Conditions for optimum performance |
mbed_official | 5:3762170b6d4d | 62 | * Input, output and state buffers should be aligned by 32-bit |
mbed_official | 5:3762170b6d4d | 63 | * |
mbed_official | 5:3762170b6d4d | 64 | * \par Restrictions |
mbed_official | 5:3762170b6d4d | 65 | * If the silicon does not support unaligned memory access enable the macro UNALIGNED_SUPPORT_DISABLE |
mbed_official | 5:3762170b6d4d | 66 | * In this case input, output, scratch buffers should be aligned by 32-bit |
mbed_official | 5:3762170b6d4d | 67 | * |
mbed_official | 5:3762170b6d4d | 68 | * @details |
mbed_official | 5:3762170b6d4d | 69 | * <b>Scaling and Overflow Behavior:</b> |
mbed_official | 5:3762170b6d4d | 70 | * |
mbed_official | 5:3762170b6d4d | 71 | * \par |
mbed_official | 5:3762170b6d4d | 72 | * The function is implemented using a 64-bit internal accumulator. The inputs to the |
mbed_official | 5:3762170b6d4d | 73 | * multiplications are in 1.15 format and multiplications yield a 2.30 result. |
mbed_official | 5:3762170b6d4d | 74 | * The 2.30 intermediate |
mbed_official | 5:3762170b6d4d | 75 | * results are accumulated in a 64-bit accumulator in 34.30 format. This approach |
mbed_official | 5:3762170b6d4d | 76 | * provides 33 guard bits and there is no risk of overflow. The 34.30 result is then |
mbed_official | 5:3762170b6d4d | 77 | * truncated to 34.15 format by discarding the low 15 bits and then saturated to |
mbed_official | 5:3762170b6d4d | 78 | * 1.15 format. |
mbed_official | 5:3762170b6d4d | 79 | * |
mbed_official | 5:3762170b6d4d | 80 | * \par |
mbed_official | 5:3762170b6d4d | 81 | * Refer to <code>arm_mat_mult_fast_q15()</code> for a faster but less precise version of this function. |
mbed_official | 5:3762170b6d4d | 82 | * |
mbed_official | 5:3762170b6d4d | 83 | */ |
mbed_official | 5:3762170b6d4d | 84 | |
mbed_official | 5:3762170b6d4d | 85 | |
mbed_official | 5:3762170b6d4d | 86 | |
mbed_official | 5:3762170b6d4d | 87 | |
mbed_official | 5:3762170b6d4d | 88 | arm_status arm_mat_cmplx_mult_q15( |
mbed_official | 5:3762170b6d4d | 89 | const arm_matrix_instance_q15 * pSrcA, |
mbed_official | 5:3762170b6d4d | 90 | const arm_matrix_instance_q15 * pSrcB, |
mbed_official | 5:3762170b6d4d | 91 | arm_matrix_instance_q15 * pDst, |
mbed_official | 5:3762170b6d4d | 92 | q15_t * pScratch) |
mbed_official | 5:3762170b6d4d | 93 | { |
mbed_official | 5:3762170b6d4d | 94 | /* accumulator */ |
mbed_official | 5:3762170b6d4d | 95 | q15_t *pSrcBT = pScratch; /* input data matrix pointer for transpose */ |
mbed_official | 5:3762170b6d4d | 96 | q15_t *pInA = pSrcA->pData; /* input data matrix pointer A of Q15 type */ |
mbed_official | 5:3762170b6d4d | 97 | q15_t *pInB = pSrcB->pData; /* input data matrix pointer B of Q15 type */ |
mbed_official | 5:3762170b6d4d | 98 | q15_t *px; /* Temporary output data matrix pointer */ |
mbed_official | 5:3762170b6d4d | 99 | uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ |
mbed_official | 5:3762170b6d4d | 100 | uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ |
mbed_official | 5:3762170b6d4d | 101 | uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ |
mbed_official | 5:3762170b6d4d | 102 | uint16_t numRowsB = pSrcB->numRows; /* number of rows of input matrix A */ |
mbed_official | 5:3762170b6d4d | 103 | uint16_t col, i = 0u, row = numRowsB, colCnt; /* loop counters */ |
mbed_official | 5:3762170b6d4d | 104 | arm_status status; /* status of matrix multiplication */ |
mbed_official | 5:3762170b6d4d | 105 | q63_t sumReal, sumImag; |
mbed_official | 5:3762170b6d4d | 106 | |
mbed_official | 5:3762170b6d4d | 107 | #ifdef UNALIGNED_SUPPORT_DISABLE |
mbed_official | 5:3762170b6d4d | 108 | q15_t in; /* Temporary variable to hold the input value */ |
mbed_official | 5:3762170b6d4d | 109 | q15_t a, b, c, d; |
mbed_official | 5:3762170b6d4d | 110 | #else |
mbed_official | 5:3762170b6d4d | 111 | q31_t in; /* Temporary variable to hold the input value */ |
mbed_official | 5:3762170b6d4d | 112 | q31_t prod1, prod2; |
mbed_official | 5:3762170b6d4d | 113 | q31_t pSourceA, pSourceB; |
mbed_official | 5:3762170b6d4d | 114 | #endif |
mbed_official | 5:3762170b6d4d | 115 | |
mbed_official | 5:3762170b6d4d | 116 | #ifdef ARM_MATH_MATRIX_CHECK |
mbed_official | 5:3762170b6d4d | 117 | /* Check for matrix mismatch condition */ |
mbed_official | 5:3762170b6d4d | 118 | if((pSrcA->numCols != pSrcB->numRows) || |
mbed_official | 5:3762170b6d4d | 119 | (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols)) |
mbed_official | 5:3762170b6d4d | 120 | { |
mbed_official | 5:3762170b6d4d | 121 | /* Set status as ARM_MATH_SIZE_MISMATCH */ |
mbed_official | 5:3762170b6d4d | 122 | status = ARM_MATH_SIZE_MISMATCH; |
mbed_official | 5:3762170b6d4d | 123 | } |
mbed_official | 5:3762170b6d4d | 124 | else |
mbed_official | 5:3762170b6d4d | 125 | #endif |
mbed_official | 5:3762170b6d4d | 126 | { |
mbed_official | 5:3762170b6d4d | 127 | /* Matrix transpose */ |
mbed_official | 5:3762170b6d4d | 128 | do |
mbed_official | 5:3762170b6d4d | 129 | { |
mbed_official | 5:3762170b6d4d | 130 | /* Apply loop unrolling and exchange the columns with row elements */ |
mbed_official | 5:3762170b6d4d | 131 | col = numColsB >> 2; |
mbed_official | 5:3762170b6d4d | 132 | |
mbed_official | 5:3762170b6d4d | 133 | /* The pointer px is set to starting address of the column being processed */ |
mbed_official | 5:3762170b6d4d | 134 | px = pSrcBT + i; |
mbed_official | 5:3762170b6d4d | 135 | |
mbed_official | 5:3762170b6d4d | 136 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. |
mbed_official | 5:3762170b6d4d | 137 | ** a second loop below computes the remaining 1 to 3 samples. */ |
mbed_official | 5:3762170b6d4d | 138 | while(col > 0u) |
mbed_official | 5:3762170b6d4d | 139 | { |
mbed_official | 5:3762170b6d4d | 140 | #ifdef UNALIGNED_SUPPORT_DISABLE |
mbed_official | 5:3762170b6d4d | 141 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 142 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 143 | *px = in; |
mbed_official | 5:3762170b6d4d | 144 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 145 | px[1] = in; |
mbed_official | 5:3762170b6d4d | 146 | |
mbed_official | 5:3762170b6d4d | 147 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 148 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 149 | |
mbed_official | 5:3762170b6d4d | 150 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 151 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 152 | *px = in; |
mbed_official | 5:3762170b6d4d | 153 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 154 | px[1] = in; |
mbed_official | 5:3762170b6d4d | 155 | |
mbed_official | 5:3762170b6d4d | 156 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 157 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 158 | |
mbed_official | 5:3762170b6d4d | 159 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 160 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 161 | *px = in; |
mbed_official | 5:3762170b6d4d | 162 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 163 | px[1] = in; |
mbed_official | 5:3762170b6d4d | 164 | |
mbed_official | 5:3762170b6d4d | 165 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 166 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 167 | |
mbed_official | 5:3762170b6d4d | 168 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 169 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 170 | *px = in; |
mbed_official | 5:3762170b6d4d | 171 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 172 | px[1] = in; |
mbed_official | 5:3762170b6d4d | 173 | |
mbed_official | 5:3762170b6d4d | 174 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 175 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 176 | |
mbed_official | 5:3762170b6d4d | 177 | /* Decrement the column loop counter */ |
mbed_official | 5:3762170b6d4d | 178 | col--; |
mbed_official | 5:3762170b6d4d | 179 | } |
mbed_official | 5:3762170b6d4d | 180 | |
mbed_official | 5:3762170b6d4d | 181 | /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. |
mbed_official | 5:3762170b6d4d | 182 | ** No loop unrolling is used. */ |
mbed_official | 5:3762170b6d4d | 183 | col = numColsB % 0x4u; |
mbed_official | 5:3762170b6d4d | 184 | |
mbed_official | 5:3762170b6d4d | 185 | while(col > 0u) |
mbed_official | 5:3762170b6d4d | 186 | { |
mbed_official | 5:3762170b6d4d | 187 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 188 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 189 | *px = in; |
mbed_official | 5:3762170b6d4d | 190 | in = *pInB++; |
mbed_official | 5:3762170b6d4d | 191 | px[1] = in; |
mbed_official | 5:3762170b6d4d | 192 | #else |
mbed_official | 5:3762170b6d4d | 193 | |
mbed_official | 5:3762170b6d4d | 194 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 195 | in = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 196 | |
mbed_official | 5:3762170b6d4d | 197 | *__SIMD32(px) = in; |
mbed_official | 5:3762170b6d4d | 198 | |
mbed_official | 5:3762170b6d4d | 199 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 200 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 201 | |
mbed_official | 5:3762170b6d4d | 202 | |
mbed_official | 5:3762170b6d4d | 203 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 204 | in = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 205 | |
mbed_official | 5:3762170b6d4d | 206 | *__SIMD32(px) = in; |
mbed_official | 5:3762170b6d4d | 207 | |
mbed_official | 5:3762170b6d4d | 208 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 209 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 210 | |
mbed_official | 5:3762170b6d4d | 211 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 212 | in = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 213 | |
mbed_official | 5:3762170b6d4d | 214 | *__SIMD32(px) = in; |
mbed_official | 5:3762170b6d4d | 215 | |
mbed_official | 5:3762170b6d4d | 216 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 217 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 218 | |
mbed_official | 5:3762170b6d4d | 219 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 220 | in = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 221 | |
mbed_official | 5:3762170b6d4d | 222 | *__SIMD32(px) = in; |
mbed_official | 5:3762170b6d4d | 223 | |
mbed_official | 5:3762170b6d4d | 224 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 225 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 226 | |
mbed_official | 5:3762170b6d4d | 227 | /* Decrement the column loop counter */ |
mbed_official | 5:3762170b6d4d | 228 | col--; |
mbed_official | 5:3762170b6d4d | 229 | } |
mbed_official | 5:3762170b6d4d | 230 | |
mbed_official | 5:3762170b6d4d | 231 | /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. |
mbed_official | 5:3762170b6d4d | 232 | ** No loop unrolling is used. */ |
mbed_official | 5:3762170b6d4d | 233 | col = numColsB % 0x4u; |
mbed_official | 5:3762170b6d4d | 234 | |
mbed_official | 5:3762170b6d4d | 235 | while(col > 0u) |
mbed_official | 5:3762170b6d4d | 236 | { |
mbed_official | 5:3762170b6d4d | 237 | /* Read two elements from the row */ |
mbed_official | 5:3762170b6d4d | 238 | in = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 239 | |
mbed_official | 5:3762170b6d4d | 240 | *__SIMD32(px) = in; |
mbed_official | 5:3762170b6d4d | 241 | #endif |
mbed_official | 5:3762170b6d4d | 242 | |
mbed_official | 5:3762170b6d4d | 243 | /* Update the pointer px to point to the next row of the transposed matrix */ |
mbed_official | 5:3762170b6d4d | 244 | px += numRowsB * 2; |
mbed_official | 5:3762170b6d4d | 245 | |
mbed_official | 5:3762170b6d4d | 246 | /* Decrement the column loop counter */ |
mbed_official | 5:3762170b6d4d | 247 | col--; |
mbed_official | 5:3762170b6d4d | 248 | } |
mbed_official | 5:3762170b6d4d | 249 | |
mbed_official | 5:3762170b6d4d | 250 | i = i + 2u; |
mbed_official | 5:3762170b6d4d | 251 | |
mbed_official | 5:3762170b6d4d | 252 | /* Decrement the row loop counter */ |
mbed_official | 5:3762170b6d4d | 253 | row--; |
mbed_official | 5:3762170b6d4d | 254 | |
mbed_official | 5:3762170b6d4d | 255 | } while(row > 0u); |
mbed_official | 5:3762170b6d4d | 256 | |
mbed_official | 5:3762170b6d4d | 257 | /* Reset the variables for the usage in the following multiplication process */ |
mbed_official | 5:3762170b6d4d | 258 | row = numRowsA; |
mbed_official | 5:3762170b6d4d | 259 | i = 0u; |
mbed_official | 5:3762170b6d4d | 260 | px = pDst->pData; |
mbed_official | 5:3762170b6d4d | 261 | |
mbed_official | 5:3762170b6d4d | 262 | /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ |
mbed_official | 5:3762170b6d4d | 263 | /* row loop */ |
mbed_official | 5:3762170b6d4d | 264 | do |
mbed_official | 5:3762170b6d4d | 265 | { |
mbed_official | 5:3762170b6d4d | 266 | /* For every row wise process, the column loop counter is to be initiated */ |
mbed_official | 5:3762170b6d4d | 267 | col = numColsB; |
mbed_official | 5:3762170b6d4d | 268 | |
mbed_official | 5:3762170b6d4d | 269 | /* For every row wise process, the pIn2 pointer is set |
mbed_official | 5:3762170b6d4d | 270 | ** to the starting address of the transposed pSrcB data */ |
mbed_official | 5:3762170b6d4d | 271 | pInB = pSrcBT; |
mbed_official | 5:3762170b6d4d | 272 | |
mbed_official | 5:3762170b6d4d | 273 | /* column loop */ |
mbed_official | 5:3762170b6d4d | 274 | do |
mbed_official | 5:3762170b6d4d | 275 | { |
mbed_official | 5:3762170b6d4d | 276 | /* Set the variable sum, that acts as accumulator, to zero */ |
mbed_official | 5:3762170b6d4d | 277 | sumReal = 0; |
mbed_official | 5:3762170b6d4d | 278 | sumImag = 0; |
mbed_official | 5:3762170b6d4d | 279 | |
mbed_official | 5:3762170b6d4d | 280 | /* Apply loop unrolling and compute 2 MACs simultaneously. */ |
mbed_official | 5:3762170b6d4d | 281 | colCnt = numColsA >> 1; |
mbed_official | 5:3762170b6d4d | 282 | |
mbed_official | 5:3762170b6d4d | 283 | /* Initiate the pointer pIn1 to point to the starting address of the column being processed */ |
mbed_official | 5:3762170b6d4d | 284 | pInA = pSrcA->pData + i * 2; |
mbed_official | 5:3762170b6d4d | 285 | |
mbed_official | 5:3762170b6d4d | 286 | |
mbed_official | 5:3762170b6d4d | 287 | /* matrix multiplication */ |
mbed_official | 5:3762170b6d4d | 288 | while(colCnt > 0u) |
mbed_official | 5:3762170b6d4d | 289 | { |
mbed_official | 5:3762170b6d4d | 290 | /* c(m,n) = a(1,1)*b(1,1) + a(1,2) * b(2,1) + .... + a(m,p)*b(p,n) */ |
mbed_official | 5:3762170b6d4d | 291 | |
mbed_official | 5:3762170b6d4d | 292 | #ifdef UNALIGNED_SUPPORT_DISABLE |
mbed_official | 5:3762170b6d4d | 293 | |
mbed_official | 5:3762170b6d4d | 294 | /* read real and imag values from pSrcA buffer */ |
mbed_official | 5:3762170b6d4d | 295 | a = *pInA; |
mbed_official | 5:3762170b6d4d | 296 | b = *(pInA + 1u); |
mbed_official | 5:3762170b6d4d | 297 | /* read real and imag values from pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 298 | c = *pInB; |
mbed_official | 5:3762170b6d4d | 299 | d = *(pInB + 1u); |
mbed_official | 5:3762170b6d4d | 300 | |
mbed_official | 5:3762170b6d4d | 301 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 302 | sumReal += (q31_t) a *c; |
mbed_official | 5:3762170b6d4d | 303 | sumImag += (q31_t) a *d; |
mbed_official | 5:3762170b6d4d | 304 | sumReal -= (q31_t) b *d; |
mbed_official | 5:3762170b6d4d | 305 | sumImag += (q31_t) b *c; |
mbed_official | 5:3762170b6d4d | 306 | |
mbed_official | 5:3762170b6d4d | 307 | /* read next real and imag values from pSrcA buffer */ |
mbed_official | 5:3762170b6d4d | 308 | a = *(pInA + 2u); |
mbed_official | 5:3762170b6d4d | 309 | b = *(pInA + 3u); |
mbed_official | 5:3762170b6d4d | 310 | /* read next real and imag values from pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 311 | c = *(pInB + 2u); |
mbed_official | 5:3762170b6d4d | 312 | d = *(pInB + 3u); |
mbed_official | 5:3762170b6d4d | 313 | |
mbed_official | 5:3762170b6d4d | 314 | /* update pointer */ |
mbed_official | 5:3762170b6d4d | 315 | pInA += 4u; |
mbed_official | 5:3762170b6d4d | 316 | |
mbed_official | 5:3762170b6d4d | 317 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 318 | sumReal += (q31_t) a *c; |
mbed_official | 5:3762170b6d4d | 319 | sumImag += (q31_t) a *d; |
mbed_official | 5:3762170b6d4d | 320 | sumReal -= (q31_t) b *d; |
mbed_official | 5:3762170b6d4d | 321 | sumImag += (q31_t) b *c; |
mbed_official | 5:3762170b6d4d | 322 | /* update pointer */ |
mbed_official | 5:3762170b6d4d | 323 | pInB += 4u; |
mbed_official | 5:3762170b6d4d | 324 | #else |
mbed_official | 5:3762170b6d4d | 325 | /* read real and imag values from pSrcA and pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 326 | pSourceA = *__SIMD32(pInA)++; |
mbed_official | 5:3762170b6d4d | 327 | pSourceB = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 328 | |
mbed_official | 5:3762170b6d4d | 329 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 330 | #ifdef ARM_MATH_BIG_ENDIAN |
mbed_official | 5:3762170b6d4d | 331 | prod1 = -__SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 332 | #else |
mbed_official | 5:3762170b6d4d | 333 | prod1 = __SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 334 | #endif |
mbed_official | 5:3762170b6d4d | 335 | prod2 = __SMUADX(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 336 | sumReal += (q63_t) prod1; |
mbed_official | 5:3762170b6d4d | 337 | sumImag += (q63_t) prod2; |
mbed_official | 5:3762170b6d4d | 338 | |
mbed_official | 5:3762170b6d4d | 339 | /* read real and imag values from pSrcA and pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 340 | pSourceA = *__SIMD32(pInA)++; |
mbed_official | 5:3762170b6d4d | 341 | pSourceB = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 342 | |
mbed_official | 5:3762170b6d4d | 343 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 344 | #ifdef ARM_MATH_BIG_ENDIAN |
mbed_official | 5:3762170b6d4d | 345 | prod1 = -__SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 346 | #else |
mbed_official | 5:3762170b6d4d | 347 | prod1 = __SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 348 | #endif |
mbed_official | 5:3762170b6d4d | 349 | prod2 = __SMUADX(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 350 | sumReal += (q63_t) prod1; |
mbed_official | 5:3762170b6d4d | 351 | sumImag += (q63_t) prod2; |
mbed_official | 5:3762170b6d4d | 352 | |
mbed_official | 5:3762170b6d4d | 353 | #endif /* #ifdef UNALIGNED_SUPPORT_DISABLE */ |
mbed_official | 5:3762170b6d4d | 354 | |
mbed_official | 5:3762170b6d4d | 355 | /* Decrement the loop counter */ |
mbed_official | 5:3762170b6d4d | 356 | colCnt--; |
mbed_official | 5:3762170b6d4d | 357 | } |
mbed_official | 5:3762170b6d4d | 358 | |
mbed_official | 5:3762170b6d4d | 359 | /* process odd column samples */ |
mbed_official | 5:3762170b6d4d | 360 | if((numColsA & 0x1u) > 0u) |
mbed_official | 5:3762170b6d4d | 361 | { |
mbed_official | 5:3762170b6d4d | 362 | /* c(m,n) = a(1,1)*b(1,1) + a(1,2) * b(2,1) + .... + a(m,p)*b(p,n) */ |
mbed_official | 5:3762170b6d4d | 363 | |
mbed_official | 5:3762170b6d4d | 364 | #ifdef UNALIGNED_SUPPORT_DISABLE |
mbed_official | 5:3762170b6d4d | 365 | |
mbed_official | 5:3762170b6d4d | 366 | /* read real and imag values from pSrcA and pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 367 | a = *pInA++; |
mbed_official | 5:3762170b6d4d | 368 | b = *pInA++; |
mbed_official | 5:3762170b6d4d | 369 | c = *pInB++; |
mbed_official | 5:3762170b6d4d | 370 | d = *pInB++; |
mbed_official | 5:3762170b6d4d | 371 | |
mbed_official | 5:3762170b6d4d | 372 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 373 | sumReal += (q31_t) a *c; |
mbed_official | 5:3762170b6d4d | 374 | sumImag += (q31_t) a *d; |
mbed_official | 5:3762170b6d4d | 375 | sumReal -= (q31_t) b *d; |
mbed_official | 5:3762170b6d4d | 376 | sumImag += (q31_t) b *c; |
mbed_official | 5:3762170b6d4d | 377 | |
mbed_official | 5:3762170b6d4d | 378 | #else |
mbed_official | 5:3762170b6d4d | 379 | /* read real and imag values from pSrcA and pSrcB buffer */ |
mbed_official | 5:3762170b6d4d | 380 | pSourceA = *__SIMD32(pInA)++; |
mbed_official | 5:3762170b6d4d | 381 | pSourceB = *__SIMD32(pInB)++; |
mbed_official | 5:3762170b6d4d | 382 | |
mbed_official | 5:3762170b6d4d | 383 | /* Multiply and Accumlates */ |
mbed_official | 5:3762170b6d4d | 384 | #ifdef ARM_MATH_BIG_ENDIAN |
mbed_official | 5:3762170b6d4d | 385 | prod1 = -__SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 386 | #else |
mbed_official | 5:3762170b6d4d | 387 | prod1 = __SMUSD(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 388 | #endif |
mbed_official | 5:3762170b6d4d | 389 | prod2 = __SMUADX(pSourceA, pSourceB); |
mbed_official | 5:3762170b6d4d | 390 | sumReal += (q63_t) prod1; |
mbed_official | 5:3762170b6d4d | 391 | sumImag += (q63_t) prod2; |
mbed_official | 5:3762170b6d4d | 392 | |
mbed_official | 5:3762170b6d4d | 393 | #endif /* #ifdef UNALIGNED_SUPPORT_DISABLE */ |
mbed_official | 5:3762170b6d4d | 394 | |
mbed_official | 5:3762170b6d4d | 395 | } |
mbed_official | 5:3762170b6d4d | 396 | |
mbed_official | 5:3762170b6d4d | 397 | /* Saturate and store the result in the destination buffer */ |
mbed_official | 5:3762170b6d4d | 398 | |
mbed_official | 5:3762170b6d4d | 399 | *px++ = (q15_t) (__SSAT(sumReal >> 15, 16)); |
mbed_official | 5:3762170b6d4d | 400 | *px++ = (q15_t) (__SSAT(sumImag >> 15, 16)); |
mbed_official | 5:3762170b6d4d | 401 | |
mbed_official | 5:3762170b6d4d | 402 | /* Decrement the column loop counter */ |
mbed_official | 5:3762170b6d4d | 403 | col--; |
mbed_official | 5:3762170b6d4d | 404 | |
mbed_official | 5:3762170b6d4d | 405 | } while(col > 0u); |
mbed_official | 5:3762170b6d4d | 406 | |
mbed_official | 5:3762170b6d4d | 407 | i = i + numColsA; |
mbed_official | 5:3762170b6d4d | 408 | |
mbed_official | 5:3762170b6d4d | 409 | /* Decrement the row loop counter */ |
mbed_official | 5:3762170b6d4d | 410 | row--; |
mbed_official | 5:3762170b6d4d | 411 | |
mbed_official | 5:3762170b6d4d | 412 | } while(row > 0u); |
mbed_official | 5:3762170b6d4d | 413 | |
mbed_official | 5:3762170b6d4d | 414 | /* set status as ARM_MATH_SUCCESS */ |
mbed_official | 5:3762170b6d4d | 415 | status = ARM_MATH_SUCCESS; |
mbed_official | 5:3762170b6d4d | 416 | } |
mbed_official | 5:3762170b6d4d | 417 | |
mbed_official | 5:3762170b6d4d | 418 | /* Return to application */ |
mbed_official | 5:3762170b6d4d | 419 | return (status); |
mbed_official | 5:3762170b6d4d | 420 | } |
mbed_official | 5:3762170b6d4d | 421 | |
mbed_official | 5:3762170b6d4d | 422 | /** |
mbed_official | 5:3762170b6d4d | 423 | * @} end of MatrixMult group |
mbed_official | 5:3762170b6d4d | 424 | */ |