1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
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 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
29 * Version 0.0.5 2010/04/26
30 * incorporated review comments and updated with latest CMSIS layer
32 * Version 0.0.3 2010/03/10
34 * -------------------------------------------------------------------- */
39 * @ingroup groupMatrix
43 * @addtogroup MatrixTrans
48 * @brief Q31 matrix transpose.
49 * @param[in] *pSrc points to the input matrix
50 * @param[out] *pDst points to the output matrix
51 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
52 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
55 arm_status arm_mat_trans_q31(
56 const arm_matrix_instance_q31 * pSrc,
57 arm_matrix_instance_q31 * pDst)
59 q31_t *pIn = pSrc->pData; /* input data matrix pointer */
60 q31_t *pOut = pDst->pData; /* output data matrix pointer */
61 q31_t *px; /* Temporary output data matrix pointer */
62 uint16_t nRows = pSrc->numRows; /* number of nRows */
63 uint16_t nColumns = pSrc->numCols; /* number of nColumns */
67 /* Run the below code for Cortex-M4 and Cortex-M3 */
69 uint16_t blkCnt, i = 0u, row = nRows; /* loop counters */
70 arm_status status; /* status of matrix transpose */
73 #ifdef ARM_MATH_MATRIX_CHECK
76 /* Check for matrix mismatch condition */
77 if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
79 /* Set status as ARM_MATH_SIZE_MISMATCH */
80 status = ARM_MATH_SIZE_MISMATCH;
83 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
86 /* Matrix transpose by exchanging the rows with columns */
90 /* Apply loop unrolling and exchange the columns with row elements */
91 blkCnt = nColumns >> 2u;
93 /* The pointer px is set to starting address of the column being processed */
96 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
97 ** a second loop below computes the remaining 1 to 3 samples. */
100 /* Read and store the input element in the destination */
103 /* Update the pointer px to point to the next row of the transposed matrix */
106 /* Read and store the input element in the destination */
109 /* Update the pointer px to point to the next row of the transposed matrix */
112 /* Read and store the input element in the destination */
115 /* Update the pointer px to point to the next row of the transposed matrix */
118 /* Read and store the input element in the destination */
121 /* Update the pointer px to point to the next row of the transposed matrix */
124 /* Decrement the column loop counter */
128 /* Perform matrix transpose for last 3 samples here. */
129 blkCnt = nColumns % 0x4u;
133 /* Read and store the input element in the destination */
136 /* Update the pointer px to point to the next row of the transposed matrix */
139 /* Decrement the column loop counter */
145 /* Run the below code for Cortex-M0 */
147 uint16_t col, i = 0u, row = nRows; /* loop counters */
148 arm_status status; /* status of matrix transpose */
151 #ifdef ARM_MATH_MATRIX_CHECK
153 /* Check for matrix mismatch condition */
154 if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
156 /* Set status as ARM_MATH_SIZE_MISMATCH */
157 status = ARM_MATH_SIZE_MISMATCH;
160 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
163 /* Matrix transpose by exchanging the rows with columns */
167 /* The pointer px is set to starting address of the column being processed */
170 /* Initialize column loop counter */
175 /* Read and store the input element in the destination */
178 /* Update the pointer px to point to the next row of the transposed matrix */
181 /* Decrement the column loop counter */
185 #endif /* #ifndef ARM_MATH_CM0 */
189 /* Decrement the row loop counter */
193 while(row > 0u); /* row loop end */
195 /* set status as ARM_MATH_SUCCESS */
196 status = ARM_MATH_SUCCESS;
199 /* Return to application */
204 * @} end of MatrixTrans group