00001 #ifndef Impala_Core_Matrix_MatEye_h
00002 #define Impala_Core_Matrix_MatEye_h
00003
00004 #include "Core/Matrix/MatFunc.h"
00005
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Matrix
00011 {
00012
00013 template<class ArrayT>
00014 inline ArrayT*
00015 MatEye(int n)
00016 {
00017 ArrayT* res = MatCreate<ArrayT>(n, n);
00018 for(int i = 0; i < n; i++)
00019 {
00020 for(int j = 0; j < n; j++)
00021 {
00022 if(i == j)
00023 *MatE(res, i, j) = 1.0;
00024 else
00025 *MatE(res, i, j) = 0.0;
00026 }
00027 }
00028 return res;
00029 }
00030
00031 }
00032 }
00033 }
00034
00035 #endif