Add a few non-member functions for real-valued types.

Add minimal docs.

[SVN r73608]
This commit is contained in:
John Maddock
2011-08-08 12:27:46 +00:00
parent 0abdf2aa36
commit 136e7b67af
42 changed files with 2053 additions and 0 deletions

View File

@@ -60,6 +60,25 @@ void test_integer_ops(const boost::mpl::true_&)
BOOST_TEST(a == -20 % -7);
}
template <class Real>
void test_real_ops(const boost::mpl::false_&){}
template <class Real>
void test_real_ops(const boost::mpl::true_&)
{
std::cout << "Root2 = " << sqrt(Real(2)) << std::endl;
BOOST_TEST(abs(Real(2)) == 2);
BOOST_TEST(abs(Real(-2)) == 2);
BOOST_TEST(fabs(Real(2)) == 2);
BOOST_TEST(fabs(Real(-2)) == 2);
BOOST_TEST(floor(Real(5) / 2) == 2);
BOOST_TEST(ceil(Real(5) / 2) == 3);
BOOST_TEST(floor(Real(-5) / 2) == -3);
BOOST_TEST(ceil(Real(-5) / 2) == -2);
BOOST_TEST(trunc(Real(5) / 2) == 2);
BOOST_TEST(trunc(Real(-5) / 2) == -2);
}
template <class Real, class Num>
void test_negative_mixed(boost::mpl::true_ const&)
{
@@ -209,6 +228,10 @@ void test()
//
test_integer_ops<Real>(boost::math::is_extended_integer<Real>());
//
// Real number only functions:
//
test_real_ops<Real>(boost::mpl::bool_<false == boost::math::is_extended_integer<Real>::value >());
//
// Test basic arithmetic:
//
Real a(8);