arm_mat_cmplx_trans_q15.c 3.7 KB

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