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

template<class ArrayT>
ArrayT* Impala::Core::Matrix::MatMul ( ArrayT *  m,
ArrayT *  a 
) [inline]

Definition at line 93 of file MatMul.h.

References DGEMM, ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_VAR, ILOG_WARN, MatE(), MatNrCol(), MatNrRow(), MatTranspose(), Impala::Core::Array::PixSum(), Impala::Core::Array::PrintData(), and Impala::Core::Array::Sub().

Referenced by Impala::Core::Training::Fisher::ApplyMapping(), Impala::Core::Training::Fisher::CNormC(), Impala::Core::Feature::MarkovStationaryFeature(), MatNorm2DistInternal(), MatPInv(), MatPseudoInverse(), MatReplicateMatrixOneRow(), Impala::Core::Feature::InterestPointFeature::ProjectHardIndex(), Impala::Core::Feature::InterestPointFeature::ProjectHardMatrix(), Impala::Core::Feature::InterestPointFeature::ProjectUNC(), Impala::Core::Array::Rotate(), Impala::Core::Training::LogisticRegression::Train(), Impala::Core::Training::Fisher::Train(), and Impala::Core::Tracking::Classifier::UpdateClassifiers().

00094 {
00095     ArrayT* res;
00096     ILOG_VAR(Core.Matrix.MatMul);
00097 
00098 #ifdef ENABLE_PERFORMANCE_TIMING
00099     timeval start,end,dur;
00100     gettimeofday(&start,NULL);
00101 #endif
00102 
00103     if (MatNrCol(m) != MatNrRow(a))
00104     {
00105         ILOG_ERROR("nonconformant MatMul operands.");
00106         return 0;
00107     }
00108     res = MatCreate<ArrayT>(MatNrRow(m), MatNrCol(a));
00109 
00110 #ifdef BASE_CBLAS
00111     Mat* aa = MatTranspose(a);
00112     for (int i=0 ; i<MatNrRow(m) ; i++)
00113     {
00114         double* rowM = MatE(m, i, 0);
00115         for (int j=0 ; j<MatNrCol(a) ; j++)
00116         {
00117             double* rowAA = MatE(aa, j, 0);
00118             MatStorType sum = 0;
00119             for (int k=0 ; k<MatNrCol(m) ; k++)
00120             {
00121                 sum += rowM[k] * rowAA[k];
00122             }
00123             *MatE(res, i, j) = sum;
00124         }
00125     }
00126     delete aa;
00127 #else
00128     DGEMM(CblasNoTrans, CblasNoTrans,
00129           MatNrRow(m), MatNrCol(a), MatNrRow(a),
00130           1.0, m->PB(), MatNrCol(m),
00131           a->PB(), MatNrCol(a),
00132           0.0, res->PB(), MatNrCol(res));
00133 #ifdef ENABLE_PRECISION_TEST
00134     ArrayT* res2;
00135     res2 = MatCreate<ArrayT>(MatNrRow(m), MatNrCol(a));
00136     Mat* aa = MatTranspose(a);
00137     for (int i=0 ; i<MatNrRow(m) ; i++)
00138     {
00139         double* rowM = MatE(m, i, 0);
00140         for (int j=0 ; j<MatNrCol(a) ; j++)
00141         {
00142             double* rowAA = MatE(aa, j, 0);
00143             MatStorType sum = 0;
00144             for (int k=0 ; k<MatNrCol(m) ; k++)
00145             {
00146                 sum += rowM[k] * rowAA[k];
00147             }
00148             *MatE(res2, i, j) = sum;
00149         }
00150     }
00151     delete aa;
00152     ArrayT* r=0;
00153     Sub(r,res,res2);
00154     Impala::Real64 diff=PixSum(r);
00155     if(diff!=0){
00156         ILOG_WARN("The Arrays are different!");
00157         PrintData(r);
00158         
00159     }
00160     else{
00161         ILOG_INFO("Arrays are same!");
00162     }
00163 #endif
00164 
00165 #endif
00166 
00167 #ifdef ENABLE_PERFORMANCE_TIMING
00168     gettimeofday(&end,NULL);
00169     long long int sec = end.tv_sec - start.tv_sec;
00170     long long int usec= end.tv_usec - start.tv_usec;
00171 
00172     ILOG_DEBUG("MatMul : "<<sec*1000000+usec<<" usec");
00173 #endif
00174 
00175     return res;
00176 
00177 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:16:03 2010 for ImpalaSrc by  doxygen 1.5.1