CMSIS DSP Software Library: arm_mat_trans_f32.c Source File

- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# arm_mat_trans_f32.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------
    00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
    00003 *
    00004 * $Date:        15. July 2011
    00005 * $Revision:    V1.0.10
    00006 *
    00007 * Project:      CMSIS DSP Library
    00008 * Title:        arm_mat_trans_f32.c
    00009 *
    00010 * Description:  Floating-point matrix transpose.
    00011 *
    00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
    00013 *
    00014 * Version 1.0.10 2011/7/15
    00015 *    Big Endian support added and Merged M0 and M3/M4 Source code.
    00016 *
    00017 * Version 1.0.3 2010/11/29
    00018 *    Re-organized the CMSIS folders and updated documentation.
    00019 *
    00020 * Version 1.0.2 2010/11/11
    00021 *    Documentation updated.
    00022 *
    00023 * Version 1.0.1 2010/10/05
    00024 *    Production release and review comments incorporated.
    00025 *
    00026 * Version 1.0.0 2010/09/20
    00027 *    Production release and review comments incorporated.
    00028 *
    00029 * Version 0.0.5  2010/04/26
    00030 *    incorporated review comments and updated with latest CMSIS layer
    00031 *
    00032 * Version 0.0.3  2010/03/10
    00033 *    Initial version
    00034 * -------------------------------------------------------------------- */
    00035
    00044 #include "arm_math.h"
    00045
    00064 arm_status arm_mat_trans_f32(
    00065   const arm_matrix_instance_f32 * pSrc,
    00066   arm_matrix_instance_f32 * pDst)
    00067 {
    00068   float32_t *pIn = pSrc->pData;                  /* input data matrix pointer */
    00069   float32_t *pOut = pDst->pData;                 /* output data matrix pointer */
    00070   float32_t *px;                                 /* Temporary output data matrix pointer */
    00071   uint16_t nRows = pSrc->numRows;                /* number of rows */
    00072   uint16_t nColumns = pSrc->numCols;             /* number of columns */
    00073
    00074 #ifndef ARM_MATH_CM0
    00075
    00076   /* Run the below code for Cortex-M4 and Cortex-M3 */
    00077
    00078   uint16_t blkCnt, i = 0u, row = nRows;          /* loop counters */
    00079   arm_status status;                             /* status of matrix transpose  */
    00080
    00081
    00082 #ifdef ARM_MATH_MATRIX_CHECK
    00083
    00084
    00085   /* Check for matrix mismatch condition */
    00086   if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
    00087   {
    00088     /* Set status as ARM_MATH_SIZE_MISMATCH */
    00089     status = ARM_MATH_SIZE_MISMATCH;
    00090   }
    00091   else
    00092 #endif /*    #ifdef ARM_MATH_MATRIX_CHECK    */
    00093
    00094   {
    00095     /* Matrix transpose by exchanging the rows with columns */
    00096     /* row loop     */
    00097     do
    00098     {
    00099       /* Loop Unrolling */
    00100       blkCnt = nColumns >> 2;
    00101
    00102       /* The pointer px is set to starting address of the column being processed */
    00103       px = pOut + i;
    00104
    00105       /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
    00106        ** a second loop below computes the remaining 1 to 3 samples. */
    00107       while(blkCnt > 0u)        /* column loop */
    00108       {
    00109         /* Read and store the input element in the destination */
    00110         *px = *pIn++;
    00111
    00112         /* Update the pointer px to point to the next row of the transposed matrix */
    00113         px += nRows;
    00114
    00115         /* Read and store the input element in the destination */
    00116         *px = *pIn++;
    00117
    00118         /* Update the pointer px to point to the next row of the transposed matrix */
    00119         px += nRows;
    00120
    00121         /* Read and store the input element in the destination */
    00122         *px = *pIn++;
    00123
    00124         /* Update the pointer px to point to the next row of the transposed matrix */
    00125         px += nRows;
    00126
    00127         /* Read and store the input element in the destination */
    00128         *px = *pIn++;
    00129
    00130         /* Update the pointer px to point to the next row of the transposed matrix */
    00131         px += nRows;
    00132
    00133         /* Decrement the column loop counter */
    00134         blkCnt--;
    00135       }
    00136
    00137       /* Perform matrix transpose for last 3 samples here. */
    00138       blkCnt = nColumns % 0x4u;
    00139
    00140       while(blkCnt > 0u)
    00141       {
    00142         /* Read and store the input element in the destination */
    00143         *px = *pIn++;
    00144
    00145         /* Update the pointer px to point to the next row of the transposed matrix */
    00146         px += nRows;
    00147
    00148         /* Decrement the column loop counter */
    00149         blkCnt--;
    00150       }
    00151
    00152 #else
    00153
    00154   /* Run the below code for Cortex-M0 */
    00155
    00156   uint16_t col, i = 0u, row = nRows;             /* loop counters */
    00157   arm_status status;                             /* status of matrix transpose  */
    00158
    00159
    00160 #ifdef ARM_MATH_MATRIX_CHECK
    00161
    00162   /* Check for matrix mismatch condition */
    00163   if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
    00164   {
    00165     /* Set status as ARM_MATH_SIZE_MISMATCH */
    00166     status = ARM_MATH_SIZE_MISMATCH;
    00167   }
    00168   else
    00169 #endif /*      #ifdef ARM_MATH_MATRIX_CHECK    */
    00170
    00171   {
    00172     /* Matrix transpose by exchanging the rows with columns */
    00173     /* row loop     */
    00174     do
    00175     {
    00176       /* The pointer px is set to starting address of the column being processed */
    00177       px = pOut + i;
    00178
    00179       /* Initialize column loop counter */
    00180       col = nColumns;
    00181
    00182       while(col > 0u)
    00183       {
    00184         /* Read and store the input element in the destination */
    00185         *px = *pIn++;
    00186
    00187         /* Update the pointer px to point to the next row of the transposed matrix */
    00188         px += nRows;
    00189
    00190         /* Decrement the column loop counter */
    00191         col--;
    00192       }
    00193
    00194 #endif /* #ifndef ARM_MATH_CM0 */
    00195
    00196       i++;
    00197
    00198       /* Decrement the row loop counter */
    00199       row--;
    00200
    00201     } while(row > 0u);          /* row loop end  */
    00202
    00203     /* Set status as ARM_MATH_SUCCESS */
    00204     status = ARM_MATH_SUCCESS;
    00205   }
    00206
    00207   /* Return to application */
    00208   return (status);
    00209 }
    00210

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines