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