Changeset 1658 for trunk/test/Suite.cc


Ignore:
Timestamp:
Dec 17, 2008, 4:02:00 PM (13 years ago)
Author:
Peter
Message:

Adding functions to use for fix precision comparisons (refs #470)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.cc

    r1574 r1658  
    8989    double last_error_bound = n*std::numeric_limits<double>().epsilon()*
    9090      std::min(std::abs(a), std::abs(b));
     91    return equal_fix(a, b, last_error_bound);
     92  }
     93
     94
     95  bool Suite::equal_fix(double a, double b, double margin)
     96  {
     97    // using the negated comparison to catch NaN problems
    9198    if (!(std::abs(a-b) <= last_error_bound)){
    9299      err() << "Error: Comparing " << a << " and " << b
    93100            << "\n  Difference: " << a - b
    94             << "\n  expected difference to be at most " << last_error_bound
     101            << "\n  expected difference to be at most " << margin
    95102            << std::endl;
    96103      return false;
Note: See TracChangeset for help on using the changeset viewer.