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

template<class ArrayT>
ArrayT* Impala::Core::Matrix::MatKLM ( ArrayT *  m,
int  newDim 
) [inline]

Definition at line 217 of file MatKLM.h.

References MatCovariance(), MatE(), MatNrCol(), MatNrRow(), Tqli(), and Tred2().

Referenced by Impala::Core::Array::ColorSegmentation().

00218 {
00219     typedef ArrayT Mat;
00220     typedef ArrayT Vec;
00221 
00222     int nr = MatNrRow(m);
00223     int nc = MatNrCol(m);
00224 
00225     if (newDim<1 || newDim>nc)
00226     {
00227         std::cout << "MatKLM: new dimensionality invalid, set to 1..." << std::endl;
00228         newDim = 1;
00229     }
00230 
00231     Mat* newfvec = MatCreate<Mat>(nr, newDim);
00232     Mat* a = MatCovariance(m, (Mat*) 0);
00233     Vec* d = VecCreate<Vec>(nc);
00234     Vec* e = VecCreate<Vec>(nc);
00235 
00236     Tred2(a, d, e);
00237     Tqli(d, e, a);
00238 
00239     // d[k] is an eigenvalue and a[][k] is a corresponding eigenvector
00240 
00241     for (int k=0; k<nr; k++)
00242     {
00243         for (int i=0; i<newDim; i++)
00244         {
00245             double vl = 0.0;
00246             for (int j=0; j<nc; j++)
00247                 vl += *MatE(m, k, j) * *MatE(a, j, i);
00248             *MatE(newfvec, k, i) = vl;
00249         }
00250     }
00251     delete a;
00252     delete d;
00253     delete e;
00254     return newfvec;
00255 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:20:12 2011 for ImpalaSrc by  doxygen 1.5.1