Ejemplo n.º 1
0
void print_test_result(const boost::math::tools::test_result<T>& result,
                       const Seq& worst, int row, const char* name, const char* test)
{
   using namespace std; // To aid selection of the right pow.
   T eps = boost::math::tools::epsilon<T>();
   std::cout << std::setprecision(4);

   T max_error_found = (result.max)()/eps;
   T mean_error_found = result.rms()/eps;
   //
   // Begin by printing the main tag line with the results:
   //
   std::cout << test << "(" << name << ") Max = " << max_error_found
      << " RMS Mean=" << mean_error_found;
   //
   // If the max error is non-zero, give the row of the table that
   // produced the worst error:
   //
   if((result.max)() != 0)
   {
      std::cout << "\n    worst case at row: "
         << row << "\n    { ";
      for(unsigned i = 0; i < worst.size(); ++i)
      {
         if(i)
            std::cout << ", ";
         std::cout << worst[i];
      }
      std::cout << " }";
   }
   std::cout << std::endl;
}
Ejemplo n.º 2
0
void handle_test_result(const boost::math::tools::test_result<T>& result,
                       const Seq& worst, int row, 
                       const char* type_name, 
                       const char* test_name, 
                       const char* group_name)
{
   T eps = boost::math::tools::epsilon<T>();
   T max_error_found = (result.max)() / eps;
   T mean_error_found = result.rms() / eps;

   std::string cell_name = sanitize_string(BOOST_COMPILER) + "_" + sanitize_string(BOOST_PLATFORM) + "_" + sanitize_string(type_name) 
      + "_" + sanitize_string(test_name) + "_" + sanitize_string(TEST_LIBRARY_NAME) + "_" + sanitize_string(group_name);

   std::stringstream ss;
   ss << std::setprecision(3);
   if(std::string(TEST_LIBRARY_NAME) != "boost")
      ss << "(['" << TEST_LIBRARY_NAME << ":] ";
   else
      ss << "[role blue ";

   if((result.max)() > std::sqrt(eps))
      ss << "[role red ";


   ss << "Max = ";
   if((boost::math::isfinite)(max_error_found))
      ss << max_error_found;
   else
      ss << "+INF";
   ss << "[epsilon] (Mean = ";
   if((boost::math::isfinite)(mean_error_found))
      ss << mean_error_found;
   else
      ss << "+INF";
   ss << "[epsilon])";

   //
   // Now check for error output from gross errors or unexpected exceptions:
   //
   std::stringbuf* pbuf = dynamic_cast<std::stringbuf*>(std::cerr.rdbuf());
   bool have_errors = false;
   std::string error_id = "errors_" + cell_name;
   if(pbuf)
   {
      std::string err_s = pbuf->str();
      if(err_s.size())
      {
         if(err_s.size() > 4096)
         {
            std::string::size_type pos = err_s.find("\n", 4096);
            if(pos != std::string::npos)
            {
               err_s.erase(pos);
               err_s += "\n*** FURTHER CONTENT HAS BEEN TRUNCATED FOR BREVITY ***\n";
            }
         }
         std::string::size_type pos = err_s.find("\n");
         while(pos != std::string::npos)
         {
            err_s.replace(pos, 1, "[br]");
            pos = err_s.find("\n");
         }
         err_s = "[h4 Error Output For " + std::string(test_name) + std::string(" with compiler ") + std::string(BOOST_COMPILER)
            + std::string(" and library ") + std::string(TEST_LIBRARY_NAME) + " and test data "
            + std::string(group_name) + "]\n\n[#" + error_id + "]\n" + err_s + std::string("\n\n\n");
         ss << "  [link " << error_id << " And other failures.]";
         pbuf->str("");
         set_error_content(error_id, err_s);
         have_errors = true;
      }
   }
   if(!have_errors)
      remove_error_content(error_id);


   if(std::string(TEST_LIBRARY_NAME) != "boost")
      ss << ")";
   else
      ss << "]";

   if((result.max)() > std::sqrt(eps))
      ss << "]";

   std::string cell_content = ss.str();

   set_result(cell_name, cell_content, test_name, group_name, type_name);
}
Ejemplo n.º 3
0
void handle_test_result(const boost::math::tools::test_result<T>& result,
                       const Seq& worst, int row, 
                       const char* type_name, 
                       const char* test_name, 
                       const char* group_name)
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127)
#endif
   using namespace std; // To aid selection of the right pow.
   T eps = boost::math::tools::epsilon<T>();
   std::cout << std::setprecision(4);

   T max_error_found = (result.max)()/eps;
   T mean_error_found = result.rms()/eps;
   //
   // Begin by printing the main tag line with the results:
   //
   std::cout << test_name << "<" << type_name << "> Max = " << max_error_found
      << " RMS Mean=" << mean_error_found;
   //
   // If the max error is non-zero, give the row of the table that
   // produced the worst error:
   //
   if((result.max)() != 0)
   {
      std::cout << "\n    worst case at row: "
         << row << "\n    { ";
      if(std::numeric_limits<T>::digits10)
      {
         std::cout << std::setprecision(std::numeric_limits<T>::digits10 + 2);
      }
      else
      {
         std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 2);
      }
      for(unsigned i = 0; i < worst.size(); ++i)
      {
         if(i)
            std::cout << ", ";
#if defined(__SGI_STL_PORT)
         std::cout << boost::math::tools::real_cast<double>(worst[i]);
#else
         std::cout << worst[i];
#endif
      }
      std::cout << " }";
   }
   std::cout << std::endl;
   //
   // Now verify that the results are within our expected bounds:
   //
   std::pair<boost::uintmax_t, boost::uintmax_t> const& bounds = get_max_errors(type_name, test_name, group_name);
   if(bounds.first < max_error_found)
   {
      std::cerr << "Peak error greater than expected value of " << bounds.first << std::endl;
      BOOST_CHECK(bounds.first >= max_error_found);
   }
   if(bounds.second < mean_error_found)
   {
      std::cerr << "Mean error greater than expected value of " << bounds.second << std::endl;
      BOOST_CHECK(bounds.second >= mean_error_found);
   }
   std::cout << std::endl;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}