arm_mat_cmplx_trans_f16.c 3.9 KB

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