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

MatSVD.h

Go to the documentation of this file.
00001 
00005 #ifndef Impala_Core_Matrix_MatSVD_h
00006 #define Impala_Core_Matrix_MatSVD_h
00007 
00008 #include "tnt_array2d.h"
00009 #include "jama_svd.h"
00010 
00011 #include "Core/Matrix/MatFunc.h"
00012 #include "Core/Array/PrintData.h"
00013 #include "Core/Matrix/Mat.h"
00014 #include "Core/Matrix/MatFunc.h"
00015 
00016 namespace Impala
00017 {
00018 namespace Core
00019 {
00020 namespace Matrix
00021 {
00022 
00023 using namespace Impala;
00024 
00041 template<class ArrayT>
00042 inline int
00043 MatSVD(ArrayT* a, ArrayT*& u, ArrayT*& s, ArrayT*& v)
00044 {
00045     int rows = a->H();
00046     int cols = a->W();
00047 
00048     //TNT Array Initialization
00049     Array2D<Real64> A(rows,cols,a->PB());
00050     Array2D<Real64> U(0,0);
00051     Array2D<Real64> S(0,0);
00052     Array2D<Real64> V(0,0);
00053     
00054     JAMA::SVD<Real64> svd(A);
00055 
00056     svd.getU(U);
00057     u=MatCreate<Mat>(U.dim1(),U.dim2());
00058     for(int i=0;i<U.dim1();i++)
00059         for(int j=0;j<U.dim2();j++)
00060             u->SetValue(U[i][j],j,i);
00061     
00062     svd.getV(V);
00063     v=MatCreate<Mat>(V.dim2(),V.dim1());
00064     for(int i=0;i<V.dim1();i++)
00065         for(int j=0;j<V.dim2();j++)
00066             v->SetValue(V[i][j],j,i);
00067     
00068     svd.getS(S);
00069     s=MatCreate<Mat>(S.dim1(),S.dim2());
00070     for(int i=0;i<S.dim1();i++)
00071         for(int j=0;j<S.dim2();j++)
00072             s->SetValue(S[i][j],j,i);
00073 
00074     return svd.rank();
00075 
00076 }
00077 
00078 
00079 } // namespace Matrix
00080 } // namespace Core
00081 } // namespace Impala
00082 
00083 #endif

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