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

template<class C1, class C2>
bool Impala::Core::Column::Equals ( const C1 *  t1,
const C2 *  t2,
int  nrElem,
double  tolerance 
) [inline]

Versions with tolerance.

test returns true is the difference between values in t1 and t2 are below the tolerance this can be used for floating point numbers. FYI EPSILON and FLT_EPSILON are the smallest double and float (resp.) that can be added to 1. (and 1.f resp.) that result in a different number. These are 2.2204460492503131e-016 and 1.192092896e-07F (resp.) Of course the best value for tolerance can be a lot bigger/smaller than EPSILON depending on the number of operations and the size of the used values.

Definition at line 60 of file Equals.h.

References ILOG_DEBUG, ILOG_ERROR, and ILOG_VAR.

00061 {
00062     ILOG_VAR(Impala.Core.Column.Equals);
00063     if (nrElem > t2->Capacity())
00064     {
00065         ILOG_ERROR("incompatible t2 range");
00066         return false;
00067     }
00068     if (nrElem > t1->Capacity())
00069     {
00070         ILOG_ERROR("incompatible t1 range");
00071         return false;
00072     }
00073 
00074     double maxdiff = 0;
00075     for (int i=0 ; i<nrElem ; i++)
00076     {
00077         double diff = abs((double)t1->Get(i) - t2->Get(i));
00078         if(diff > tolerance)
00079         {
00080             ILOG_DEBUG(std::setiosflags(std::ios_base::scientific) <<
00081                        diff << " > " << tolerance <<
00082                        std::resetiosflags(std::ios_base::scientific));
00083             return false;
00084         }
00085     }
00086 
00087     return true;
00088 }


Generated on Thu Jan 13 09:18:47 2011 for ImpalaSrc by  doxygen 1.5.1