Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

MatTranspose.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Matrix_MatTranspose_h
00002 #define Impala_Core_Matrix_MatTranspose_h
00003 
00004 #include "Core/Matrix/MatFunc.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Matrix
00011 {
00012 
00013 
00014 template<class ArrayT>
00015 inline ArrayT*
00016 MatTranspose(ArrayT* m)
00017 {
00018     ArrayT* res = MatCreate<ArrayT>(MatNrCol(m), MatNrRow(m));
00019     for (int i=0 ; i<MatNrRow(m) ; i++)
00020         for (int j=0 ; j<MatNrCol(m) ; j++)
00021             *MatE(res, j, i) = *MatE(m, i, j);
00022     return res;
00023 }
00024 
00025 template<class ArrayT>
00026 inline void
00027 MatTransposeInplace(ArrayT* m)
00028 {
00029     ILOG_VAR(Core.Matrix.MatTransposeInplace);
00030     if(MatNrRow(m) != MatNrCol(m))
00031         ILOG_ERROR("only works for square matrices!");
00032     for (int i=0 ; i<MatNrRow(m) ; i++)
00033         for (int j=i+1 ; j<MatNrCol(m) ; j++)
00034         {
00035             typename ArrayT::ArithType temp;
00036             temp = *MatE(m, j, i);
00037             *MatE(m, j, i) = *MatE(m, i, j);
00038             *MatE(m, i, j) = temp;
00039         }
00040 }
00041 
00042 } // namespace Matrix
00043 } // namespace Core
00044 } // namespace Impala
00045 
00046 #endif

Generated on Fri Mar 19 09:31:17 2010 for ImpalaSrc by  doxygen 1.5.1