generate_test_values.cpp 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // (C) Copyright John Maddock 2005.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef NTL_STD_CXX
  6. # define NTL_STD_CXX
  7. #endif
  8. #include <iostream>
  9. #include <iomanip>
  10. #include "mp_t.hpp"
  11. mp_t log1p(mp_t arg)
  12. {
  13. return log(arg + 1);
  14. }
  15. mp_t expm1(mp_t arg)
  16. {
  17. return exp(arg) - 1;
  18. }
  19. int main()
  20. {
  21. mp_t r, root_two;
  22. r = 1.0;
  23. root_two = 2.0;
  24. root_two = sqrt(root_two);
  25. r /= root_two;
  26. mp_t lim = pow(mp_t(2), mp_t(-128));
  27. std::cout << std::scientific << std::setprecision(40);
  28. while(r > lim)
  29. {
  30. std::cout << " { " << r << "L, " << log1p(r) << "L, " << expm1(r) << "L, }, \n";
  31. std::cout << " { " << -r << "L, " << log1p(-r) << "L, " << expm1(-r) << "L, }, \n";
  32. r /= root_two;
  33. }
  34. return 0;
  35. }