Add serialization support to float128 and adaptor backends.

Use __float128 via typedefs so recent Intel compilers don't complain.

[SVN r85241]
This commit is contained in:
John Maddock
2013-08-08 17:43:54 +00:00
parent 16f091f3cd
commit c5e7d59a73
9 changed files with 338 additions and 67 deletions

View File

@@ -12,64 +12,7 @@
#endif
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/timer.hpp>
#include "test.hpp"
#include <iostream>
#include <iomanip>
#include <sstream>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
template <class T>
T generate_random(unsigned bits_wanted)
{
typedef typename T::backend_type::exponent_type e_type;
static boost::random::mt19937 gen;
T val = gen();
T prev_val = -1;
while(val != prev_val)
{
val *= (gen.max)();
prev_val = val;
val += gen();
}
e_type e;
val = frexp(val, &e);
static boost::random::uniform_int_distribution<e_type> ui(std::numeric_limits<T>::min_exponent + 1, std::numeric_limits<T>::max_exponent - 1);
return ldexp(val, ui(gen));
}
template <class T>
void test()
{
boost::timer tim;
while(true)
{
T val = generate_random<T>(boost::math::tools::digits<T>());
std::stringstream ss;
boost::archive::text_oarchive oa(ss);
oa << static_cast<const T&>(val);
boost::archive::text_iarchive ia(ss);
T val2;
ia >> val2;
BOOST_CHECK_EQUAL(val, val2);
//
// Check to see if test is taking too long.
// Tests run on the compiler farm time out after 300 seconds,
// so don't get too close to that:
//
if(tim.elapsed() > 150)
{
std::cout << "Timeout reached, aborting tests now....\n";
break;
}
}
}
#include "test_float_serial.hpp"
#if !defined(TEST1) && !defined(TEST2)
# define TEST1