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

template<class C>
CxMatrixTem< C > CxMatrixTem< C >::klm ( int  newDim  )  const

Karhunen Loeve mapping (PCA) Principal Componant Analysis to reduce matrix to newDim dimensions.

Definition at line 803 of file Matrix.h.

References CxMatrixTem< C >::_nc, CxMatrixTem< C >::_nr, CxMatrixTem< C >::covariance(), CxMatrixTem< C >::CxVector< C >, CxMatrixTem< C >::i(), tqli(), and tred2().

00804 {
00805         if (newDim<1 || newDim>_nc)
00806         {
00807                 printf("klm: new dimensionality is invalid, dimsize is set as 1...\n");
00808                 newDim = 1;
00809         }
00810 
00811         CxMatrixTem<C> newfvec(_nr,newDim);
00812 
00813         CxMatrixTem<C> a = this->covariance() ;
00814 
00815         CxVector<C> d(_nc) ;
00816 
00817         CxVector<C> e(_nc) ;
00818 
00819         tred2(a,d,e);
00820 
00821         tqli(d,e,a);
00822 
00823         // d[k] is an eigenvalue and a[][k] is a corresponding eigenvector
00824 
00825         for (int k=0; k<_nr; k++)
00826                 for (int i=0; i<newDim; i++) {
00827                         double vl = 0.0;
00828                         for (int j=0; j<_nc; j++) vl += ((*this)[k][j]*a[j][i]);
00829                         newfvec[k][i] = vl;
00830                 }
00831 
00832         return newfvec;
00833 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:32:15 2010 for ImpalaSrc by  doxygen 1.5.1