• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_mat_cmplx_trans_f32.c
4  * Description:  Floating-point 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   @defgroup MatrixComplexTrans Complex Matrix Transpose
37 
38   Tranposes a complex matrix.
39 
40   Transposing an <code>M x N</code> matrix flips it around the center diagonal and results in an <code>N x M</code> matrix.
41   \image html MatrixTranspose.gif "Transpose of a 3 x 3 matrix"
42  */
43 
44 /**
45   @addtogroup MatrixComplexTrans
46   @{
47  */
48 
49 /**
50   @brief         Floating-point matrix transpose.
51   @param[in]     pSrc      points to input matrix
52   @param[out]    pDst      points to output matrix
53   @return        execution status
54                    - \ref ARM_MATH_SUCCESS       : Operation successful
55                    - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed
56  */
57 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
58 
59 #include "arm_helium_utils.h"
60 
arm_mat_cmplx_trans_f32(const arm_matrix_instance_f32 * pSrc,arm_matrix_instance_f32 * pDst)61 arm_status arm_mat_cmplx_trans_f32(const arm_matrix_instance_f32 * pSrc, arm_matrix_instance_f32 * pDst)
62 {
63     return arm_mat_cmplx_trans_32bit(pSrc->numRows, pSrc->numCols, (uint32_t *) pSrc->pData,
64                                    pDst->numRows, pDst->numCols, (uint32_t *) pDst->pData);
65 }
66 
67 #else
arm_mat_cmplx_trans_f32(const arm_matrix_instance_f32 * pSrc,arm_matrix_instance_f32 * pDst)68 arm_status arm_mat_cmplx_trans_f32(
69   const arm_matrix_instance_f32 * pSrc,
70   arm_matrix_instance_f32 * pDst)
71 {
72   float32_t *pIn = pSrc->pData;                  /* input data matrix pointer */
73   float32_t *pOut = pDst->pData;                 /* output data matrix pointer */
74   float32_t *px;                                 /* Temporary output data matrix pointer */
75   uint16_t nRows = pSrc->numRows;                /* number of rows */
76   uint16_t nColumns = pSrc->numCols;             /* number of columns */
77   uint16_t col, i = 0U, row = nRows;             /* loop counters */
78   arm_status status;                             /* status of matrix transpose  */
79 
80 
81 #ifdef ARM_MATH_MATRIX_CHECK
82 
83   /* Check for matrix mismatch condition */
84   if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
85   {
86     /* Set status as ARM_MATH_SIZE_MISMATCH */
87     status = ARM_MATH_SIZE_MISMATCH;
88   }
89   else
90 #endif /*      #ifdef ARM_MATH_MATRIX_CHECK    */
91 
92   {
93     /* Matrix transpose by exchanging the rows with columns */
94     /* row loop     */
95     do
96     {
97       /* The pointer px is set to starting address of the column being processed */
98       px = pOut + CMPLX_DIM * i;
99 
100       /* Initialize column loop counter */
101       col = nColumns;
102 
103       while (col > 0U)
104       {
105         /* Read and store the input element in the destination */
106         px[0] = *pIn++; // real
107         px[1] = *pIn++; // imag
108 
109         /* Update the pointer px to point to the next row of the transposed matrix */
110         px += CMPLX_DIM * nRows;
111 
112         /* Decrement the column loop counter */
113         col--;
114       }
115       i++;
116 
117       /* Decrement the row loop counter */
118       row--;
119 
120     } while (row > 0U);          /* row loop end  */
121 
122     /* Set status as ARM_MATH_SUCCESS */
123     status = ARM_MATH_SUCCESS;
124   }
125 
126   /* Return to application */
127   return (status);
128 }
129 #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
130 
131 /**
132  * @} end of MatrixTrans group
133  */
134