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

Matrix::Mat* Impala::Application::Precompute::ComputeMatrix ( DistributedAccess *  da,
Feature::FeatureTable *  devel,
Feature::FeatureTable *  test,
String  distanceFunction 
)

Input one or two feature tables and out comes the kernel distance matrix.

If there are two tables then the first is the devel set and the second is the test set. The testset always makes up the rows of the matrix while the devel set makes up the columns of the matrix. So variable horizontal (which stores the part of the develfeatures) loops over the columns. Please note that the function parameters row and column specify the place of this node in the partcount x partcount 'grid' of nodes. So therefore horizontal = GetPartial(f1, column, partcount);

Note:
: this function deletes f and f2

: f and f2 may point to the same table. Therefore care is taken not to delete it twice.

Definition at line 149 of file mainPrecomputeKernelMatrix.cpp.

References Impala::Core::Vector::Apply(), Impala::Core::Vector::Chi2Distance(), Impala::Core::Vector::Chi2DistanceSSE(), Impala::Core::Vector::DotProduct(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::GetColumn2(), GetPartial(), Impala::Core::Vector::HistogramIntersectionDouble(), ILOG_VAR, Impala::Core::Vector::VectorSet< ArrayT >::SetSize(), and Impala::Core::Table::Table::Size().

Referenced by Precompute().

00151 {
00152     ILOG_VAR(Impala.Application.Precompute.ComputeMatrix);
00153     Feature::FeatureTable* horizontal;
00154     Feature::FeatureTable* vertical;
00155     if (da->GetTotalPartCount() == 1)
00156     {
00157         horizontal = devel;
00158         vertical = test;
00159     }
00160     else
00161     {
00162         int myPart = Link::Mpi::MyId();
00163         int column = da->GetColumnPartOfPart(myPart);
00164         int row = da->GetRowPartOfPart(myPart);
00165         horizontal = GetPartial(devel, column, da->GetColumnPartCount());
00166         vertical = GetPartial(test, row, da->GetRowPartCount());
00167         delete devel;
00168         if (test != devel)
00169             delete test;
00170     }
00171 
00172     // fill a matrix with chi2 distance
00173     typedef Feature::FeatureTable::ColumnVectorSet VectorSet;
00174     VectorSet* vectorsH = horizontal->GetColumn2();
00175     VectorSet* vectorsV = vertical->GetColumn2();
00176     vectorsH->SetSize(horizontal->Size());
00177     vectorsV->SetSize(vertical->Size());
00178     Matrix::Mat* distanceMatrix = 0;
00179     if (distanceFunction == "dot")
00180     {
00181         distanceMatrix = Apply(&Vector::DotProduct, vectorsH, vectorsV);
00182     }
00183     else if (distanceFunction == "histogramintersection")
00184     {
00185         distanceMatrix = Apply(&Vector::HistogramIntersectionDouble,
00186                                vectorsH, vectorsV);
00187     }
00188     else
00189     {
00190 #ifdef SSE_USED
00191         distanceMatrix = Apply(&Vector::Chi2DistanceSSE, vectorsH, vectorsV);
00192 #else
00193         distanceMatrix = Apply(&Vector::Chi2Distance, vectorsH, vectorsV);
00194 #endif
00195     }
00196     delete horizontal;
00197     if (horizontal != vertical)
00198         delete vertical;
00199     return distanceMatrix;
00200 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:15:42 2011 for ImpalaSrc by  doxygen 1.5.1