diff options
Diffstat (limited to 'Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c')
-rw-r--r-- | Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c | 146 |
1 files changed, 47 insertions, 99 deletions
diff --git a/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c b/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c index 6f698e0e1..5d0b5e2f5 100644 --- a/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c +++ b/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q31.c @@ -3,13 +3,13 @@ * Title: arm_mat_trans_q31.c * Description: Q31 matrix transpose * - * $Date: 27. January 2017 - * $Revision: V.1.5.1 + * $Date: 18. March 2019 + * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* - * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. + * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -29,163 +29,111 @@ #include "arm_math.h" /** - * @ingroup groupMatrix + @ingroup groupMatrix */ /** - * @addtogroup MatrixTrans - * @{ + @addtogroup MatrixTrans + @{ */ -/* - * @brief Q31 matrix transpose. - * @param[in] *pSrc points to the input matrix - * @param[out] *pDst points to the output matrix - * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> - * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. +/** + @brief Q31 matrix transpose. + @param[in] pSrc points to input matrix + @param[out] pDst points to output matrix + @return execution status + - \ref ARM_MATH_SUCCESS : Operation successful + - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ arm_status arm_mat_trans_q31( const arm_matrix_instance_q31 * pSrc, - arm_matrix_instance_q31 * pDst) + arm_matrix_instance_q31 * pDst) { - q31_t *pIn = pSrc->pData; /* input data matrix pointer */ - q31_t *pOut = pDst->pData; /* output data matrix pointer */ + q31_t *pIn = pSrc->pData; /* input data matrix pointer */ + q31_t *pOut = pDst->pData; /* output data matrix pointer */ q31_t *px; /* Temporary output data matrix pointer */ - uint16_t nRows = pSrc->numRows; /* number of nRows */ - uint16_t nColumns = pSrc->numCols; /* number of nColumns */ - -#if defined (ARM_MATH_DSP) - - /* Run the below code for Cortex-M4 and Cortex-M3 */ - - uint16_t blkCnt, i = 0U, row = nRows; /* loop counters */ + uint16_t nRows = pSrc->numRows; /* number of rows */ + uint16_t nCols = pSrc->numCols; /* number of columns */ + uint32_t col, row = nRows, i = 0U; /* Loop counters */ arm_status status; /* status of matrix transpose */ - #ifdef ARM_MATH_MATRIX_CHECK - /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) + if ((pSrc->numRows != pDst->numCols) || + (pSrc->numCols != pDst->numRows) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else -#endif /* #ifdef ARM_MATH_MATRIX_CHECK */ + +#endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose by exchanging the rows with columns */ - /* row loop */ + /* row loop */ do { - /* Apply loop unrolling and exchange the columns with row elements */ - blkCnt = nColumns >> 2U; - - /* The pointer px is set to starting address of the column being processed */ + /* Pointer px is set to starting address of column being processed */ px = pOut + i; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - /* Read and store the input element in the destination */ - *px = *pIn++; +#if defined (ARM_MATH_LOOPUNROLL) - /* Update the pointer px to point to the next row of the transposed matrix */ - px += nRows; + /* Loop unrolling: Compute 4 outputs at a time */ + col = nCols >> 2U; - /* Read and store the input element in the destination */ + while (col > 0U) /* column loop */ + { + /* Read and store input element in destination */ *px = *pIn++; - - /* Update the pointer px to point to the next row of the transposed matrix */ + /* Update pointer px to point to next row of transposed matrix */ px += nRows; - /* Read and store the input element in the destination */ *px = *pIn++; - - /* Update the pointer px to point to the next row of the transposed matrix */ px += nRows; - /* Read and store the input element in the destination */ *px = *pIn++; - - /* Update the pointer px to point to the next row of the transposed matrix */ px += nRows; - /* Decrement the column loop counter */ - blkCnt--; - } - - /* Perform matrix transpose for last 3 samples here. */ - blkCnt = nColumns % 0x4U; - - while (blkCnt > 0U) - { - /* Read and store the input element in the destination */ *px = *pIn++; - - /* Update the pointer px to point to the next row of the transposed matrix */ px += nRows; - /* Decrement the column loop counter */ - blkCnt--; + /* Decrement column loop counter */ + col--; } -#else - - /* Run the below code for Cortex-M0 */ - - uint16_t col, i = 0U, row = nRows; /* loop counters */ - arm_status status; /* status of matrix transpose */ - + /* Loop unrolling: Compute remaining outputs */ + col = nCols % 0x4U; -#ifdef ARM_MATH_MATRIX_CHECK - - /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) - { - /* Set status as ARM_MATH_SIZE_MISMATCH */ - status = ARM_MATH_SIZE_MISMATCH; - } - else -#endif /* #ifdef ARM_MATH_MATRIX_CHECK */ +#else - { - /* Matrix transpose by exchanging the rows with columns */ - /* row loop */ - do - { - /* The pointer px is set to starting address of the column being processed */ - px = pOut + i; + /* Initialize col with number of samples */ + col = nCols; - /* Initialize column loop counter */ - col = nColumns; +#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (col > 0U) { - /* Read and store the input element in the destination */ + /* Read and store input element in destination */ *px = *pIn++; - /* Update the pointer px to point to the next row of the transposed matrix */ + /* Update pointer px to point to next row of transposed matrix */ px += nRows; - /* Decrement the column loop counter */ + /* Decrement column loop counter */ col--; } -#endif /* #if defined (ARM_MATH_DSP) */ - i++; - /* Decrement the row loop counter */ + /* Decrement row loop counter */ row--; - } - while (row > 0U); /* row loop end */ + } while (row > 0U); /* row loop end */ - /* set status as ARM_MATH_SUCCESS */ + /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } @@ -194,5 +142,5 @@ arm_status arm_mat_trans_q31( } /** - * @} end of MatrixTrans group + @} end of MatrixTrans group */ |