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

GetDiagonal.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Matrix_GetDiagonal_h
00002 #define Impala_Core_Matrix_GetDiagonal_h
00003 
00004 #include "Basis/ILog.h"
00005 #include "Core/Matrix/MatFunc.h"
00006 #include "Core/Vector/VectorTem.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Matrix
00013 {
00014 
00015 template<class MatT>
00016 inline Vector::VectorTem<double>
00017 GetDiagonal(MatT* m)
00018 {
00019     ILOG_VAR(Impala.Core.Matrix.GetDiagonal);
00020     if (MatNrRow(m) != MatNrCol(m))
00021     {
00022         ILOG_ERROR("only works for square matrices!");
00023         return Vector::VectorTem<double>(0);
00024     }
00025     Vector::VectorTem<double> v(MatNrRow(m));
00026     for (int i=0 ; i<MatNrRow(m) ; i++)
00027         v[i] = *MatE(m, i, i);
00028     return v;
00029 }
00030 
00031 } // namespace Matrix
00032 } // namespace Core
00033 } // namespace Impala
00034 
00035 #endif

Generated on Thu Jan 13 09:04:32 2011 for ImpalaSrc by  doxygen 1.5.1