]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/dsp/cmsis_dsp/MatrixFunctions/arm_mat_trans_q31.c
1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
4 * $Date: 17. January 2013
7 * Project: CMSIS DSP Library
8 * Title: arm_mat_trans_q31.c
10 * Description: Q31 matrix transpose.
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * - Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * - Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
23 * - Neither the name of ARM LIMITED nor the names of its contributors
24 * may be used to endorse or promote products derived from this
25 * software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 * -------------------------------------------------------------------- */
44 * @ingroup groupMatrix
48 * @addtogroup MatrixTrans
53 * @brief Q31 matrix transpose.
54 * @param[in] *pSrc points to the input matrix
55 * @param[out] *pDst points to the output matrix
56 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
57 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
60 arm_status
arm_mat_trans_q31(
61 const arm_matrix_instance_q31
* pSrc
,
62 arm_matrix_instance_q31
* pDst
)
64 q31_t
*pIn
= pSrc
->pData
; /* input data matrix pointer */
65 q31_t
*pOut
= pDst
->pData
; /* output data matrix pointer */
66 q31_t
*px
; /* Temporary output data matrix pointer */
67 uint16_t nRows
= pSrc
->numRows
; /* number of nRows */
68 uint16_t nColumns
= pSrc
->numCols
; /* number of nColumns */
70 #ifndef ARM_MATH_CM0_FAMILY
72 /* Run the below code for Cortex-M4 and Cortex-M3 */
74 uint16_t blkCnt
, i
= 0u, row
= nRows
; /* loop counters */
75 arm_status status
; /* status of matrix transpose */
78 #ifdef ARM_MATH_MATRIX_CHECK
81 /* Check for matrix mismatch condition */
82 if((pSrc
->numRows
!= pDst
->numCols
) || (pSrc
->numCols
!= pDst
->numRows
))
84 /* Set status as ARM_MATH_SIZE_MISMATCH */
85 status
= ARM_MATH_SIZE_MISMATCH
;
88 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
91 /* Matrix transpose by exchanging the rows with columns */
95 /* Apply loop unrolling and exchange the columns with row elements */
96 blkCnt
= nColumns
>> 2u;
98 /* The pointer px is set to starting address of the column being processed */
101 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
102 ** a second loop below computes the remaining 1 to 3 samples. */
105 /* Read and store the input element in the destination */
108 /* Update the pointer px to point to the next row of the transposed matrix */
111 /* Read and store the input element in the destination */
114 /* Update the pointer px to point to the next row of the transposed matrix */
117 /* Read and store the input element in the destination */
120 /* Update the pointer px to point to the next row of the transposed matrix */
123 /* Read and store the input element in the destination */
126 /* Update the pointer px to point to the next row of the transposed matrix */
129 /* Decrement the column loop counter */
133 /* Perform matrix transpose for last 3 samples here. */
134 blkCnt
= nColumns
% 0x4u
;
138 /* Read and store the input element in the destination */
141 /* Update the pointer px to point to the next row of the transposed matrix */
144 /* Decrement the column loop counter */
150 /* Run the below code for Cortex-M0 */
152 uint16_t col
, i
= 0u, row
= nRows
; /* loop counters */
153 arm_status status
; /* status of matrix transpose */
156 #ifdef ARM_MATH_MATRIX_CHECK
158 /* Check for matrix mismatch condition */
159 if((pSrc
->numRows
!= pDst
->numCols
) || (pSrc
->numCols
!= pDst
->numRows
))
161 /* Set status as ARM_MATH_SIZE_MISMATCH */
162 status
= ARM_MATH_SIZE_MISMATCH
;
165 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
168 /* Matrix transpose by exchanging the rows with columns */
172 /* The pointer px is set to starting address of the column being processed */
175 /* Initialize column loop counter */
180 /* Read and store the input element in the destination */
183 /* Update the pointer px to point to the next row of the transposed matrix */
186 /* Decrement the column loop counter */
190 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
194 /* Decrement the row loop counter */
198 while(row
> 0u); /* row loop end */
200 /* set status as ARM_MATH_SUCCESS */
201 status
= ARM_MATH_SUCCESS
;
204 /* Return to application */
209 * @} end of MatrixTrans group