arm_mat_cmplx_trans_q31.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #include "dsp/matrix_functions.h"
  29. /**
  30. @ingroup groupMatrix
  31. */
  32. /**
  33. @addtogroup MatrixComplexTrans
  34. @{
  35. */
  36. /**
  37. @brief Q31 complex matrix transpose.
  38. @param[in] pSrc points to input matrix
  39. @param[out] pDst points to output matrix
  40. @return execution status
  41. - \ref ARM_MATH_SUCCESS : Operation successful
  42. - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed
  43. */
  44. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  45. #include "arm_helium_utils.h"
  46. arm_status arm_mat_cmplx_trans_q31(const arm_matrix_instance_q31 * pSrc, arm_matrix_instance_q31 * pDst)
  47. {
  48. return arm_mat_cmplx_trans_32bit(pSrc->numRows, pSrc->numCols, (uint32_t *) pSrc->pData,
  49. pDst->numRows, pDst->numCols, (uint32_t *) pDst->pData);
  50. }
  51. #else
  52. arm_status arm_mat_cmplx_trans_q31(
  53. const arm_matrix_instance_q31 * pSrc,
  54. arm_matrix_instance_q31 * pDst)
  55. {
  56. q31_t *pIn = pSrc->pData; /* input data matrix pointer */
  57. q31_t *pOut = pDst->pData; /* output data matrix pointer */
  58. q31_t *px; /* Temporary output data matrix pointer */
  59. uint16_t nRows = pSrc->numRows; /* number of nRows */
  60. uint16_t nColumns = pSrc->numCols; /* number of nColumns */
  61. uint16_t col, i = 0U, row = nRows; /* loop counters */
  62. arm_status status; /* status of matrix transpose */
  63. #ifdef ARM_MATH_MATRIX_CHECK
  64. /* Check for matrix mismatch condition */
  65. if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
  66. {
  67. /* Set status as ARM_MATH_SIZE_MISMATCH */
  68. status = ARM_MATH_SIZE_MISMATCH;
  69. }
  70. else
  71. #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
  72. {
  73. /* Matrix transpose by exchanging the rows with columns */
  74. /* row loop */
  75. do
  76. {
  77. /* The pointer px is set to starting address of the column being processed */
  78. px = pOut + CMPLX_DIM * i;
  79. /* Initialize column loop counter */
  80. col = nColumns;
  81. while (col > 0U)
  82. {
  83. /* Read and store the input element in the destination */
  84. px[0] = *pIn++; // real
  85. px[1] = *pIn++; // imag
  86. /* Update the pointer px to point to the next row of the transposed matrix */
  87. px += CMPLX_DIM * nRows;
  88. /* Decrement the column loop counter */
  89. col--;
  90. }
  91. i++;
  92. /* Decrement the row loop counter */
  93. row--;
  94. }
  95. while (row > 0U); /* row loop end */
  96. /* set status as ARM_MATH_SUCCESS */
  97. status = ARM_MATH_SUCCESS;
  98. }
  99. /* Return to application */
  100. return (status);
  101. }
  102. #endif /* defined(ARM_MATH_MVEI) */
  103. /**
  104. * @} end of MatrixTrans group
  105. */