- 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:        29. November 2010
    00005 * $Revision:    V1.0.3
    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
    00013 *
    00014 * Version 1.0.3 2010/11/29
    00015 *    Re-organized the CMSIS folders and updated documentation.
    00016 *
    00017 * Version 1.0.2 2010/11/11
    00018 *    Documentation updated.
    00019 *
    00020 * Version 1.0.1 2010/10/05
    00021 *    Production release and review comments incorporated.
    00022 *
    00023 * Version 1.0.0 2010/09/20
    00024 *    Production release and review comments incorporated.
    00025 *
    00026 * Version 0.0.5  2010/04/26
    00027 *    incorporated review comments and updated with latest CMSIS layer
    00028 *
    00029 * Version 0.0.3  2010/03/10
    00030 *    Initial version
    00031 * -------------------------------------------------------------------- */
    00032
    00041 #include "arm_math.h"
    00042
    00061 arm_status arm_mat_trans_f32(
    00062   const arm_matrix_instance_f32 * pSrc,
    00063   arm_matrix_instance_f32 * pDst)
    00064 {
    00065   float32_t *pIn = pSrc->pData;                  /* input data matrix pointer */
    00066   float32_t *pOut = pDst->pData;                 /* output data matrix pointer */
    00067   float32_t *px;                                 /* Temporary output data matrix pointer */
    00068   uint16_t nRows = pSrc->numRows;                /* number of rows */
    00069   uint16_t nColumns = pSrc->numCols;             /* number of columns */
    00070   uint16_t blkCnt, i = 0u, row = nRows;          /* loop counters */
    00071   arm_status status;                             /* status of matrix transpose  */
    00072
    00073
    00074 #ifdef ARM_MATH_MATRIX_CHECK
    00075   /* Check for matrix mismatch condition */
    00076   if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows))
    00077   {
    00078     /* Set status as ARM_MATH_SIZE_MISMATCH */
    00079     status = ARM_MATH_SIZE_MISMATCH;
    00080   }
    00081   else
    00082 #endif
    00083   {
    00084     /* Matrix transpose by exchanging the rows with columns */
    00085     /* row loop     */
    00086     do
    00087     {
    00088       /* Loop Unrolling */
    00089       blkCnt = nColumns >> 2;
    00090
    00091       /* The pointer px is set to starting address of the column being processed */
    00092       px = pOut + i;
    00093
    00094       /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
    00095        ** a second loop below computes the remaining 1 to 3 samples. */
    00096       while(blkCnt > 0u)        /* column loop */
    00097       {
    00098         /* Read and store the input element in the destination */
    00099         *px = *pIn++;
    00100
    00101         /* Update the pointer px to point to the next row of the transposed matrix */
    00102         px += nRows;
    00103
    00104         /* Read and store the input element in the destination */
    00105         *px = *pIn++;
    00106
    00107         /* Update the pointer px to point to the next row of the transposed matrix */
    00108         px += nRows;
    00109
    00110         /* Read and store the input element in the destination */
    00111         *px = *pIn++;
    00112
    00113         /* Update the pointer px to point to the next row of the transposed matrix */
    00114         px += nRows;
    00115
    00116         /* Read and store the input element in the destination */
    00117         *px = *pIn++;
    00118
    00119         /* Update the pointer px to point to the next row of the transposed matrix */
    00120         px += nRows;
    00121
    00122         /* Decrement the column loop counter */
    00123         blkCnt--;
    00124       }
    00125
    00126       /* Perform matrix transpose for last 3 samples here. */
    00127       blkCnt = nColumns % 0x4u;
    00128
    00129       while(blkCnt > 0u)
    00130       {
    00131         /* Read and store the input element in the destination */
    00132         *px = *pIn++;
    00133
    00134         /* Update the pointer px to point to the next row of the transposed matrix */
    00135         px += nRows;
    00136
    00137         /* Decrement the column loop counter */
    00138         blkCnt--;
    00139       }
    00140
    00141       i++;
    00142
    00143       /* Decrement the row loop counter */
    00144       row--;
    00145
    00146     } while(row > 0u);          /* row loop end  */
    00147
    00148     /* Set status as ARM_MATH_SUCCESS */
    00149     status = ARM_MATH_SUCCESS;
    00150   }
    00151
    00152   /* Return to application */
    00153   return (status);
    00154 }
    00155

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines