00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_mat_trans_f32.c 00009 * 00010 * Description: Floating-point matrix transpose. 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * -------------------------------------------------------------------- */ 00024 00033 #include "arm_math.h" 00034 00053 arm_status arm_mat_trans_f32( 00054 const arm_matrix_instance_f32 * pSrc, 00055 arm_matrix_instance_f32 * pDst) 00056 { 00057 float32_t *pIn = pSrc->pData; /* input data matrix pointer */ 00058 float32_t *pOut = pDst->pData; /* output data matrix pointer */ 00059 float32_t *px; /* Temporary output data matrix pointer */ 00060 uint16_t nRows = pSrc->numRows; /* number of rows */ 00061 uint16_t nColumns = pSrc->numCols; /* number of columns */ 00062 uint16_t blkCnt, i = 0u, row = nRows; /* loop counters */ 00063 arm_status status; /* status of matrix transpose */ 00064 float32_t in1, in2, in3, in4; 00065 00066 00067 #ifdef ARM_MATH_MATRIX_CHECK 00068 /* Check for matrix mismatch condition */ 00069 if((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) 00070 { 00071 /* Set status as ARM_MATH_SIZE_MISMATCH */ 00072 status = ARM_MATH_SIZE_MISMATCH; 00073 } 00074 else 00075 #endif 00076 { 00077 /* Matrix transpose by exchanging the rows with columns */ 00078 /* row loop */ 00079 do 00080 { 00081 /* Loop Unrolling */ 00082 blkCnt = nColumns >> 3; 00083 00084 /* The pointer px is set to starting address of the column being processed */ 00085 px = pOut + i; 00086 00087 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00088 ** a second loop below computes the remaining 1 to 3 samples. */ 00089 while(blkCnt > 0u) /* column loop */ 00090 { 00091 /* Read and store the input element in the destination */ 00092 in1 = pIn[0]; 00093 *px = in1; 00094 /* Update the pointer px to point to the next row of the transposed matrix */ 00095 px += nRows; 00096 00097 /* Read and store the input element in the destination */ 00098 in2 = pIn[1]; 00099 *px = in2; 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 in3 = pIn[2]; 00106 *px = in3; 00107 00108 /* Update the pointer px to point to the next row of the transposed matrix */ 00109 px += nRows; 00110 00111 /* Read and store the input element in the destination */ 00112 in4 = pIn[3]; 00113 *px = in4; 00114 00115 /* Update the pointer px to point to the next row of the transposed matrix */ 00116 px += nRows; 00117 00118 /* Read and store the input element in the destination */ 00119 in1 = pIn[4]; 00120 *px = in1; 00121 00122 /* Update the pointer px to point to the next row of the transposed matrix */ 00123 px += nRows; 00124 00125 /* Read and store the input element in the destination */ 00126 in2 = pIn[5]; 00127 *px = in2; 00128 00129 /* Update the pointer px to point to the next row of the transposed matrix */ 00130 px += nRows; 00131 00132 /* Read and store the input element in the destination */ 00133 in3 = pIn[6]; 00134 *px = in3; 00135 00136 /* Update the pointer px to point to the next row of the transposed matrix */ 00137 px += nRows; 00138 00139 /* Read and store the input element in the destination */ 00140 in4 = pIn[7]; 00141 *px = in4; 00142 00143 /* Update the pointer px to point to the next row of the transposed matrix */ 00144 px += nRows; 00145 /* Update the pointer pIn to point to the next column of the matrix */ 00146 pIn += 8u; 00147 00148 /* Decrement the column loop counter */ 00149 blkCnt--; 00150 } 00151 00152 /* Perform matrix transpose for last 3 samples here. */ 00153 blkCnt = nColumns % 0x8u; 00154 00155 while(blkCnt > 0u) 00156 { 00157 /* Read and store the input element in the destination */ 00158 *px = *pIn++; 00159 00160 /* Update the pointer px to point to the next row of the transposed matrix */ 00161 px += nRows; 00162 00163 /* Decrement the column loop counter */ 00164 blkCnt--; 00165 } 00166 00167 i++; 00168 00169 /* Decrement the row loop counter */ 00170 row--; 00171 00172 } while(row > 0u); /* row loop end */ 00173 00174 /* Set status as ARM_MATH_SUCCESS */ 00175 status = ARM_MATH_SUCCESS; 00176 } 00177 00178 /* Return to application */ 00179 return (status); 00180 } 00181