Set blackbox file handler to NULL after closing file
[inav.git] / lib / main / CMSIS / DSP / Source / MatrixFunctions / arm_mat_trans_q31.c
blob6f698e0e1e2fc8d7204e035a502103591d3e115b
1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_mat_trans_q31.c
4 * Description: Q31 matrix transpose
6 * $Date: 27. January 2017
7 * $Revision: V.1.5.1
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
29 #include "arm_math.h"
31 /**
32 * @ingroup groupMatrix
35 /**
36 * @addtogroup MatrixTrans
37 * @{
41 * @brief Q31 matrix transpose.
42 * @param[in] *pSrc points to the input matrix
43 * @param[out] *pDst points to the output matrix
44 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
45 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
48 arm_status arm_mat_trans_q31(
49 const arm_matrix_instance_q31 * pSrc,
50 arm_matrix_instance_q31 * pDst)
52 q31_t *pIn = pSrc->pData; /* input data matrix pointer */
53 q31_t *pOut = pDst->pData; /* output data matrix pointer */
54 q31_t *px; /* Temporary output data matrix pointer */
55 uint16_t nRows = pSrc->numRows; /* number of nRows */
56 uint16_t nColumns = pSrc->numCols; /* number of nColumns */
58 #if defined (ARM_MATH_DSP)
60 /* Run the below code for Cortex-M4 and Cortex-M3 */
62 uint16_t blkCnt, i = 0U, row = nRows; /* loop counters */
63 arm_status status; /* status of matrix transpose */
66 #ifdef ARM_MATH_MATRIX_CHECK
69 /* Check for matrix mismatch condition */
70 if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
72 /* Set status as ARM_MATH_SIZE_MISMATCH */
73 status = ARM_MATH_SIZE_MISMATCH;
75 else
76 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
79 /* Matrix transpose by exchanging the rows with columns */
80 /* row loop */
83 /* Apply loop unrolling and exchange the columns with row elements */
84 blkCnt = nColumns >> 2U;
86 /* The pointer px is set to starting address of the column being processed */
87 px = pOut + i;
89 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
90 ** a second loop below computes the remaining 1 to 3 samples. */
91 while (blkCnt > 0U)
93 /* Read and store the input element in the destination */
94 *px = *pIn++;
96 /* Update the pointer px to point to the next row of the transposed matrix */
97 px += nRows;
99 /* Read and store the input element in the destination */
100 *px = *pIn++;
102 /* Update the pointer px to point to the next row of the transposed matrix */
103 px += nRows;
105 /* Read and store the input element in the destination */
106 *px = *pIn++;
108 /* Update the pointer px to point to the next row of the transposed matrix */
109 px += nRows;
111 /* Read and store the input element in the destination */
112 *px = *pIn++;
114 /* Update the pointer px to point to the next row of the transposed matrix */
115 px += nRows;
117 /* Decrement the column loop counter */
118 blkCnt--;
121 /* Perform matrix transpose for last 3 samples here. */
122 blkCnt = nColumns % 0x4U;
124 while (blkCnt > 0U)
126 /* Read and store the input element in the destination */
127 *px = *pIn++;
129 /* Update the pointer px to point to the next row of the transposed matrix */
130 px += nRows;
132 /* Decrement the column loop counter */
133 blkCnt--;
136 #else
138 /* Run the below code for Cortex-M0 */
140 uint16_t col, i = 0U, row = nRows; /* loop counters */
141 arm_status status; /* status of matrix transpose */
144 #ifdef ARM_MATH_MATRIX_CHECK
146 /* Check for matrix mismatch condition */
147 if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
149 /* Set status as ARM_MATH_SIZE_MISMATCH */
150 status = ARM_MATH_SIZE_MISMATCH;
152 else
153 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
156 /* Matrix transpose by exchanging the rows with columns */
157 /* row loop */
160 /* The pointer px is set to starting address of the column being processed */
161 px = pOut + i;
163 /* Initialize column loop counter */
164 col = nColumns;
166 while (col > 0U)
168 /* Read and store the input element in the destination */
169 *px = *pIn++;
171 /* Update the pointer px to point to the next row of the transposed matrix */
172 px += nRows;
174 /* Decrement the column loop counter */
175 col--;
178 #endif /* #if defined (ARM_MATH_DSP) */
180 i++;
182 /* Decrement the row loop counter */
183 row--;
186 while (row > 0U); /* row loop end */
188 /* set status as ARM_MATH_SUCCESS */
189 status = ARM_MATH_SUCCESS;
192 /* Return to application */
193 return (status);
197 * @} end of MatrixTrans group