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

virtual void Impala::Core::Test::TestMatNorm2Dist::Run (  )  [inline, virtual]

Reimplemented from Impala::Core::Test::TestBase.

Definition at line 35 of file TestMatNorm2Dist.h.

References Impala::Core::Array::Abs(), Impala::Core::Test::TestBase::AddReport(), Impala::Util::Database::GetInstance(), Impala::MakeString(), Impala::Core::Matrix::MatE(), Impala::Core::Matrix::MatNorm2Dist(), Impala::Core::Matrix::MatNorm2DistTransposed(), Impala::Core::Matrix::MatTranspose(), mTestIndex, Impala::Core::Array::PixSum(), Impala::Core::Array::ReadRaw(), Impala::Core::Test::TestBase::SetFailure(), Impala::Timer::SplitTimeStr(), and Impala::Core::Array::Sub().

00036     {
00037         Mat* a = 0;
00038         Mat* b = 0;
00039         Mat* c = 0;
00040         if(mTestIndex == 0) {
00041             /*
00042 >> distance2([1,2,3,4,5; 4 3 2 9 0], [2.5 5 3; 0.9 0.4 3])
00043 
00044 ans =
00045 
00046     3.4438    5.3814    2.2361
00047     2.1587    3.9699    1.0000
00048     1.2083    2.5612    1.0000
00049     8.2377    8.6579    6.0828
00050     2.6571    0.4000    3.6056*/
00051 
00052             a = MatCreate<Mat>(2, 5);
00053             *MatE(a, 0, 0) = 1;
00054             *MatE(a, 0, 1) = 2;
00055             *MatE(a, 0, 2) = 3;
00056             *MatE(a, 0, 3) = 4;
00057             *MatE(a, 0, 4) = 5;
00058             *MatE(a, 1, 0) = 4;
00059             *MatE(a, 1, 1) = 3;
00060             *MatE(a, 1, 2) = 2;
00061             *MatE(a, 1, 3) = 9;
00062             *MatE(a, 1, 4) = 0;
00063             b = MatCreate<Mat>(2, 3);
00064             *MatE(b, 0, 0) = 2.5;
00065             *MatE(b, 0, 1) = 5;
00066             *MatE(b, 0, 2) = 3;
00067             *MatE(b, 1, 0) = 0.9;
00068             *MatE(b, 1, 1) = 0.4;
00069             *MatE(b, 1, 2) = 3;
00070             c = MatCreate<Mat>(5, 3);
00071             *MatE(c, 0, 0) = 3.4438;
00072             *MatE(c, 0, 1) = 5.3814;
00073             *MatE(c, 0, 2) = 2.2361;
00074             *MatE(c, 1, 0) = 2.1587;
00075             *MatE(c, 1, 1) = 3.9699;
00076             *MatE(c, 1, 2) = 1.0;
00077             *MatE(c, 2, 0) = 1.2083;
00078             *MatE(c, 2, 1) = 2.5612;
00079             *MatE(c, 2, 2) = 1.0;
00080             *MatE(c, 3, 0) = 8.2377;
00081             *MatE(c, 3, 1) = 8.6579;
00082             *MatE(c, 3, 2) = 6.0828;
00083             *MatE(c, 4, 0) = 2.6571;
00084             *MatE(c, 4, 1) = 0.4000;
00085             *MatE(c, 4, 2) = 3.6056;
00086         } else if((mTestIndex == 1) || (mTestIndex == 2))
00087         {
00088             ReadRaw(a, "norm2dist_a.raw", &Util::Database::GetInstance());
00089             ReadRaw(b, "norm2dist_b.raw", &Util::Database::GetInstance());
00090             ReadRaw(c, "norm2dist_c.raw", &Util::Database::GetInstance());
00091             if(mTestIndex == 2)
00092             {
00093                 Mat* temp1 = MatTranspose(a);
00094                 Mat* temp2 = MatTranspose(b);
00095                 delete a;
00096                 delete b;
00097                 a = temp1;
00098                 b = temp2;
00099             }
00100         }
00101         Mat* result = 0;
00102         Timer speedTimer;
00103         if(mTestIndex <= 1) result = MatNorm2Dist(a,b);
00104         if(mTestIndex > 1) result = MatNorm2DistTransposed(a,b);
00105         std::cout << "Speed of " << mTestIndex << " " << speedTimer.SplitTimeStr() << std::endl;
00106         //PrintData(result);
00107         Sub(result, result, c);
00108         Abs(result, result);
00109         //PrintData(result);
00110         //PrintData(c);
00111         Real64 diff = PixSum(result);
00112         AddReport("Difference:" + MakeString(diff));
00113         std::cout << "Difference:" + MakeString(diff) << std::endl;
00114         if(diff > 0.0005) {
00115             // require small difference
00116             SetFailure("MatNorm2Dist too much difference failure!");
00117         }
00118         delete a;
00119         delete b;
00120         delete c;
00121         delete result;
00122     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:21:00 2011 for ImpalaSrc by  doxygen 1.5.1