1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_mat_cmplx_trans_q31.c
4 * Description: Q31 complex matrix transpose
5 *
6 * $Date: 23 April 2021
7 * $Revision: V1.9.0
8 *
9 * Target Processor: Cortex-M and Cortex-A cores
10 * -------------------------------------------------------------------- */
11 /*
12 * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
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
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
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.
27 */
28
29 #include "dsp/matrix_functions.h"
30
31 /**
32 @ingroup groupMatrix
33 */
34
35
36
37 /**
38 @addtogroup MatrixComplexTrans
39 @{
40 */
41
42 /**
43 @brief Q31 complex matrix transpose.
44 @param[in] pSrc points to input matrix
45 @param[out] pDst points to output matrix
46 @return execution status
47 - \ref ARM_MATH_SUCCESS : Operation successful
48 - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed
49 */
50 #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
51
52 #include "arm_helium_utils.h"
53
54
arm_mat_cmplx_trans_q31(const arm_matrix_instance_q31 * pSrc,arm_matrix_instance_q31 * pDst)55 arm_status arm_mat_cmplx_trans_q31(const arm_matrix_instance_q31 * pSrc, arm_matrix_instance_q31 * pDst)
56 {
57 return arm_mat_cmplx_trans_32bit(pSrc->numRows, pSrc->numCols, (uint32_t *) pSrc->pData,
58 pDst->numRows, pDst->numCols, (uint32_t *) pDst->pData);
59 }
60
61
62 #else
arm_mat_cmplx_trans_q31(const arm_matrix_instance_q31 * pSrc,arm_matrix_instance_q31 * pDst)63 arm_status arm_mat_cmplx_trans_q31(
64 const arm_matrix_instance_q31 * pSrc,
65 arm_matrix_instance_q31 * pDst)
66 {
67 q31_t *pIn = pSrc->pData; /* input data matrix pointer */
68 q31_t *pOut = pDst->pData; /* output data matrix pointer */
69 q31_t *px; /* Temporary output data matrix pointer */
70 uint16_t nRows = pSrc->numRows; /* number of nRows */
71 uint16_t nColumns = pSrc->numCols; /* number of nColumns */
72 uint16_t col, i = 0U, row = nRows; /* loop counters */
73 arm_status status; /* status of matrix transpose */
74
75
76 #ifdef ARM_MATH_MATRIX_CHECK
77
78 /* Check for matrix mismatch condition */
79 if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
80 {
81 /* Set status as ARM_MATH_SIZE_MISMATCH */
82 status = ARM_MATH_SIZE_MISMATCH;
83 }
84 else
85 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
86
87 {
88 /* Matrix transpose by exchanging the rows with columns */
89 /* row loop */
90 do
91 {
92 /* The pointer px is set to starting address of the column being processed */
93 px = pOut + CMPLX_DIM * i;
94
95 /* Initialize column loop counter */
96 col = nColumns;
97
98 while (col > 0U)
99 {
100 /* Read and store the input element in the destination */
101 px[0] = *pIn++; // real
102 px[1] = *pIn++; // imag
103
104 /* Update the pointer px to point to the next row of the transposed matrix */
105 px += CMPLX_DIM * nRows;
106
107 /* Decrement the column loop counter */
108 col--;
109 }
110
111 i++;
112
113 /* Decrement the row loop counter */
114 row--;
115
116 }
117 while (row > 0U); /* row loop end */
118
119 /* set status as ARM_MATH_SUCCESS */
120 status = ARM_MATH_SUCCESS;
121 }
122 /* Return to application */
123 return (status);
124 }
125 #endif /* defined(ARM_MATH_MVEI) */
126
127 /**
128 * @} end of MatrixTrans group
129 */
130