[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5476] Tighten tolerance on binary-versus-xml tests
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5476] Tighten tolerance on binary-versus-xml tests |
Date: |
Tue, 29 May 2012 20:28:20 +0000 |
Revision: 5476
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5476
Author: chicares
Date: 2012-05-29 20:28:19 +0000 (Tue, 29 May 2012)
Log Message:
-----------
Tighten tolerance on binary-versus-xml tests
Modified Paths:
--------------
lmi/trunk/actuarial_table.cpp
lmi/trunk/soa_stress_test.cpp
Modified: lmi/trunk/actuarial_table.cpp
===================================================================
--- lmi/trunk/actuarial_table.cpp 2012-05-29 09:35:13 UTC (rev 5475)
+++ lmi/trunk/actuarial_table.cpp 2012-05-29 20:28:19 UTC (rev 5476)
@@ -30,6 +30,7 @@
#include "alert.hpp"
#include "assert_lmi.hpp"
+#include "materially_equal.hpp"
#include "miscellany.hpp"
#include "oecumenic_enumerations.hpp" // methuselah
#include "path_utility.hpp" // fs::path inserter
@@ -47,6 +48,7 @@
#include <algorithm> // std::max(), std::min()
#include <cctype> // std::toupper()
#include <climits> // CHAR_BIT
+#include <iomanip> // std::setprecision()
#include <ios>
#include <istream>
#include <iterator> // std::distance()
@@ -907,11 +909,6 @@
namespace
{
- inline bool almost_equal_doubles(double a, double b)
- {
- return std::abs(a - b) < 0.00000001;
- }
-
bool almost_equal_doubles(std::vector<double> const& a,
std::vector<double> const& b)
{
if(a.size() != b.size())
@@ -920,8 +917,20 @@
size_t const size = a.size();
for(size_t i = 0; i < size; i++)
{
- if(!almost_equal_doubles(a[i], b[i]))
+ if(!materially_equal(a[i], b[i], 2.0E-15L))
+ {
+ warning()
+ << i << " i\n"
+ << value_cast<std::string>(a[i]) << " ... a[i]\n"
+ << value_cast<std::string>(b[i]) << " ... b[i]\n"
+ << std::setprecision(20)
+ << a[i] << " a[i]\n"
+ << b[i] << " b[i]\n"
+ << value_cast<std::string>((b[i] - a[i]) / b[i]) << "
(b[i] - a[i]) / b[i]\n"
+ << LMI_FLUSH
+ ;
return false;
+ }
}
return true;
Modified: lmi/trunk/soa_stress_test.cpp
===================================================================
--- lmi/trunk/soa_stress_test.cpp 2012-05-29 09:35:13 UTC (rev 5475)
+++ lmi/trunk/soa_stress_test.cpp 2012-05-29 20:28:19 UTC (rev 5476)
@@ -30,6 +30,7 @@
#include "actuarial_table.hpp"
#include "assert_lmi.hpp"
+#include "materially_equal.hpp"
#include <cmath>
#include <ios>
@@ -39,7 +40,7 @@
inline bool almost_equal_doubles(double a, double b)
{
- return std::abs(a - b) < 0.00000001;
+ return materially_equal(a, b, 2.0E-15L);
}
inline bool almost_equal_doubles(std::vector<double> const& a,
std::vector<double> const& b)
@@ -68,12 +69,12 @@
% start
<< std::endl;
- std::cerr << boost::format(" \t%|10|\t%|10|") % "xml" % "soa" <<
std::endl;
+ std::cerr << boost::format(" \t%|25|\t%|25|") % "xml" % "soa" <<
std::endl;
for(unsigned int i = 0; i < data_xml.size(); i++)
{
if(!almost_equal_doubles(data_xml[i], data_soa[i]))
{
- std::cerr << boost::format("[%d]\t%|10|\t%|10|")
+ std::cerr << boost::format("[%d]\t%|25.20|\t%|25.20|")
% i
% data_xml[i]
% data_soa[i]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5476] Tighten tolerance on binary-versus-xml tests,
Greg Chicares <=