Verified Commit 64a759c8 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

math: use cpp_dec_float

This feature is common to all boost versions (1.54)
parent b0d0c8f4
......@@ -5,7 +5,7 @@
#include "pinocchio/algorithm/joint-configuration.hpp"
#include "pinocchio/algorithm/rnea.hpp"
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <iostream>
......@@ -29,7 +29,7 @@ int main(int argc, char ** argv)
Data data(model);
// Define Model and Data for multiprecision types
typedef boost::multiprecision::cpp_bin_float_100 float_100;
typedef boost::multiprecision::cpp_dec_float_100 float_100;
typedef ModelTpl<float_100> ModelMulti;
typedef DataTpl<float_100> DataMulti;
......
......@@ -14,7 +14,7 @@
#include "pinocchio/math/multiprecision.hpp"
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <iostream>
......@@ -29,11 +29,11 @@ BOOST_AUTO_TEST_CASE(test_basic)
using namespace boost::multiprecision;
// Operations at fixed precision and full numeric_limits support:
cpp_bin_float_100 b = 2;
std::cout << std::numeric_limits<cpp_bin_float_100>::digits << std::endl;
std::cout << std::numeric_limits<cpp_bin_float_100>::digits10 << std::endl;
cpp_dec_float_100 b = 2;
std::cout << std::numeric_limits<cpp_dec_float_100>::digits << std::endl;
std::cout << std::numeric_limits<cpp_dec_float_100>::digits10 << std::endl;
// We can use any C++ std lib function, lets print all the digits as well:
std::cout << std::setprecision(std::numeric_limits<cpp_bin_float_100>::max_digits10)
std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_100>::max_digits10)
<< log(b) << std::endl; // print log(2)
// We can also use any function from Boost.Math:
std::cout << boost::math::tgamma(b) << std::endl;
......@@ -41,12 +41,12 @@ BOOST_AUTO_TEST_CASE(test_basic)
std::cout << boost::math::tgamma(b * b) << std::endl;
// And since we have an extended exponent range we can generate some really large
// numbers here (4.0238726007709377354370243e+2564):
std::cout << boost::math::tgamma(cpp_bin_float_100(1000)) << std::endl;
std::cout << boost::math::tgamma(cpp_dec_float_100(1000)) << std::endl;
}
BOOST_AUTO_TEST_CASE(test_cast)
{
typedef boost::multiprecision::cpp_bin_float_100 float_100;
typedef boost::multiprecision::cpp_dec_float_100 float_100;
// Test Scalar cast
double initial_value = boost::math::constants::pi<double>();
......@@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(test_mutliprecision)
model.lowerPositionLimit.head<3>().fill(-1.);
model.upperPositionLimit.head<3>().fill( 1.);
typedef boost::multiprecision::cpp_bin_float_100 float_100;
typedef boost::multiprecision::cpp_dec_float_100 float_100;
typedef ModelTpl<float_100> ModelMulti;
typedef DataTpl<float_100> DataMulti;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment