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

MatSVDLpp.h

Go to the documentation of this file.
00001 
00003 #ifndef Impala_Core_Matrix_MatSVD_LAPACK++_h
00004 #define Impala_Core_Matrix_MatSVD_LAPACK++_h
00005 
00006 #include "Core/Matrix/MatFunc.h"
00007 #include "Core/Matrix/MatMul.h"
00008 //#include "lapackpp/lapackpp.h"
00009 //
00010 //
00011 //#include "lapackpp/lafnames.h"
00012 #include "Link/lapackpp/gmd.h"
00013 #include "Link/lapackpp/lavd.h"
00014 #include "Link/lapackpp/lasvd.h"
00015 
00016 namespace Impala
00017 {
00018 namespace Core
00019 {
00020 namespace Matrix
00021 {
00022 
00023 
00024 template<class ArrayT>
00025 inline void
00026 MatSvdLpp(ArrayT* a, ArrayT*& u, ArrayT*& s, ArrayT*& v)
00027 {
00028     int m = a->H();
00029     int n = a->W();
00030 
00031     /* 
00032      * la::mat(double*v, int m, int n, bool row_ordering=false);->row_ordering is
00033      * true for c type arrays 
00034      * */
00035     
00036     LaGenMatDouble A(a->PB(),m,n,true);
00037     LaGenMatDouble ATmp(A);
00038     LaVectorDouble S(n);
00039     LaGenMatDouble U(m,m);
00040     LaGenMatDouble VT(n,n);
00041     
00042     /*
00043     * void LaSVD_IP(LaGenMatDouble& A, LaVectorDouble &Sigma,
00044     *  LaGenMatDouble& U, LaGenMatDouble& VT );
00045     */
00046     LaSVD_IP(ATmp,S,U,VT);
00047 
00048     //Copy the Results
00049     u=MatCreate<Mat>(m,m);
00050     for(int i=0;i<m;i++)
00051         for(int j=0;j<m;j++)
00052             u->SetValue(U(i,j),j,i);
00053 
00054     s=MatCreate<Mat>(m,n);
00055     for(int i=0;i<m;i++){
00056         for(int j=0;j<n;j++)
00057             s->SetValue(0,j,i);
00058         s->SetValue(S(i),i,i);
00059     }
00060 
00061     v=MatCreate<Mat>(n,n);
00062     for(int i=0;i<n;i++)
00063         for(int j=0;j<n;j++)
00064             v->SetValue(VT(i,j),j,i);
00065 
00066 }
00067 
00068 
00069 } // namespace Matrix
00070 } // namespace Core
00071 } // namespace Impala
00072 
00073 #endif

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