Added boost header
This commit is contained in:
491
test/external/boost/math/concepts/distributions.hpp
vendored
Normal file
491
test/external/boost/math/concepts/distributions.hpp
vendored
Normal file
@@ -0,0 +1,491 @@
|
||||
// Copyright John Maddock 2006.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// distributions.hpp provides definitions of the concept of a distribution
|
||||
// and non-member accessor functions that must be implemented by all distributions.
|
||||
// This is used to verify that
|
||||
// all the features of a distributions have been fully implemented.
|
||||
|
||||
#ifndef BOOST_MATH_DISTRIBUTION_CONCEPT_HPP
|
||||
#define BOOST_MATH_DISTRIBUTION_CONCEPT_HPP
|
||||
|
||||
#include <boost/math/distributions/complement.hpp>
|
||||
#include <boost/math/distributions/fwd.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100)
|
||||
#pragma warning(disable: 4510)
|
||||
#pragma warning(disable: 4610)
|
||||
#pragma warning(disable: 4189) // local variable is initialized but not referenced.
|
||||
#endif
|
||||
#include <boost/concept_check.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <utility>
|
||||
|
||||
namespace boost{
|
||||
namespace math{
|
||||
|
||||
namespace concepts
|
||||
{
|
||||
// Begin by defining a concept archetype
|
||||
// for a distribution class:
|
||||
//
|
||||
template <class RealType>
|
||||
class distribution_archetype
|
||||
{
|
||||
public:
|
||||
typedef RealType value_type;
|
||||
|
||||
distribution_archetype(const distribution_archetype&); // Copy constructible.
|
||||
distribution_archetype& operator=(const distribution_archetype&); // Assignable.
|
||||
|
||||
// There is no default constructor,
|
||||
// but we need a way to instantiate the archetype:
|
||||
static distribution_archetype& get_object()
|
||||
{
|
||||
// will never get caled:
|
||||
return *reinterpret_cast<distribution_archetype*>(0);
|
||||
}
|
||||
}; // template <class RealType>class distribution_archetype
|
||||
|
||||
// Non-member accessor functions:
|
||||
// (This list defines the functions that must be implemented by all distributions).
|
||||
|
||||
template <class RealType>
|
||||
RealType pdf(const distribution_archetype<RealType>& dist, const RealType& x);
|
||||
|
||||
template <class RealType>
|
||||
RealType cdf(const distribution_archetype<RealType>& dist, const RealType& x);
|
||||
|
||||
template <class RealType>
|
||||
RealType quantile(const distribution_archetype<RealType>& dist, const RealType& p);
|
||||
|
||||
template <class RealType>
|
||||
RealType cdf(const complemented2_type<distribution_archetype<RealType>, RealType>& c);
|
||||
|
||||
template <class RealType>
|
||||
RealType quantile(const complemented2_type<distribution_archetype<RealType>, RealType>& c);
|
||||
|
||||
template <class RealType>
|
||||
RealType mean(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType standard_deviation(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType variance(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType hazard(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType chf(const distribution_archetype<RealType>& dist);
|
||||
// http://en.wikipedia.org/wiki/Characteristic_function_%28probability_theory%29
|
||||
|
||||
template <class RealType>
|
||||
RealType coefficient_of_variation(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType mode(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType skewness(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType kurtosis_excess(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType kurtosis(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
RealType median(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
std::pair<RealType, RealType> range(const distribution_archetype<RealType>& dist);
|
||||
|
||||
template <class RealType>
|
||||
std::pair<RealType, RealType> support(const distribution_archetype<RealType>& dist);
|
||||
|
||||
//
|
||||
// Next comes the concept checks for verifying that a class
|
||||
// fullfils the requirements of a Distribution:
|
||||
//
|
||||
template <class Distribution>
|
||||
struct DistributionConcept
|
||||
{
|
||||
typedef typename Distribution::value_type value_type;
|
||||
|
||||
void constraints()
|
||||
{
|
||||
function_requires<CopyConstructibleConcept<Distribution> >();
|
||||
function_requires<AssignableConcept<Distribution> >();
|
||||
|
||||
const Distribution& dist = DistributionConcept<Distribution>::get_object();
|
||||
|
||||
value_type x = 0;
|
||||
// The result values are ignored in all these checks.
|
||||
value_type v = cdf(dist, x);
|
||||
v = cdf(complement(dist, x));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, x);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, x);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, x));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = mean(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = mode(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = standard_deviation(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = variance(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, x);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, x);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = coefficient_of_variation(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = skewness(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = kurtosis(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = kurtosis_excess(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = median(dist);
|
||||
suppress_unused_variable_warning(v);
|
||||
std::pair<value_type, value_type> pv;
|
||||
pv = range(dist);
|
||||
suppress_unused_variable_warning(pv);
|
||||
pv = support(dist);
|
||||
suppress_unused_variable_warning(pv);
|
||||
|
||||
float f = 1;
|
||||
v = cdf(dist, f);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = cdf(complement(dist, f));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, f);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, f);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, f));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, f);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, f);
|
||||
suppress_unused_variable_warning(v);
|
||||
double d = 1;
|
||||
v = cdf(dist, d);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = cdf(complement(dist, d));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, d);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, d);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, d));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, d);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, d);
|
||||
suppress_unused_variable_warning(v);
|
||||
#ifndef TEST_MPFR
|
||||
long double ld = 1;
|
||||
v = cdf(dist, ld);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = cdf(complement(dist, ld));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, ld);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, ld);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, ld));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, ld);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, ld);
|
||||
suppress_unused_variable_warning(v);
|
||||
#endif
|
||||
int i = 1;
|
||||
v = cdf(dist, i);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = cdf(complement(dist, i));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, i);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, i);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, i));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, i);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, i);
|
||||
suppress_unused_variable_warning(v);
|
||||
unsigned long li = 1;
|
||||
v = cdf(dist, li);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = cdf(complement(dist, li));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = pdf(dist, li);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(dist, li);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = quantile(complement(dist, li));
|
||||
suppress_unused_variable_warning(v);
|
||||
v = hazard(dist, li);
|
||||
suppress_unused_variable_warning(v);
|
||||
v = chf(dist, li);
|
||||
suppress_unused_variable_warning(v);
|
||||
test_extra_members(dist);
|
||||
}
|
||||
template <class D>
|
||||
static void test_extra_members(const D&)
|
||||
{}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::bernoulli_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.success_fraction();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::beta_distribution<R, P>& d)
|
||||
{
|
||||
value_type r1 = d.alpha();
|
||||
value_type r2 = d.beta();
|
||||
r1 = boost::math::beta_distribution<R, P>::find_alpha(r1, r2);
|
||||
suppress_unused_variable_warning(r1);
|
||||
r1 = boost::math::beta_distribution<R, P>::find_beta(r1, r2);
|
||||
suppress_unused_variable_warning(r1);
|
||||
r1 = boost::math::beta_distribution<R, P>::find_alpha(r1, r2, r1);
|
||||
suppress_unused_variable_warning(r1);
|
||||
r1 = boost::math::beta_distribution<R, P>::find_beta(r1, r2, r1);
|
||||
suppress_unused_variable_warning(r1);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::binomial_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.success_fraction();
|
||||
r = d.trials();
|
||||
r = Distribution::find_lower_bound_on_p(r, r, r);
|
||||
r = Distribution::find_lower_bound_on_p(r, r, r, Distribution::clopper_pearson_exact_interval);
|
||||
r = Distribution::find_lower_bound_on_p(r, r, r, Distribution::jeffreys_prior_interval);
|
||||
r = Distribution::find_upper_bound_on_p(r, r, r);
|
||||
r = Distribution::find_upper_bound_on_p(r, r, r, Distribution::clopper_pearson_exact_interval);
|
||||
r = Distribution::find_upper_bound_on_p(r, r, r, Distribution::jeffreys_prior_interval);
|
||||
r = Distribution::find_minimum_number_of_trials(r, r, r);
|
||||
r = Distribution::find_maximum_number_of_trials(r, r, r);
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::cauchy_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.location();
|
||||
r = d.scale();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::chi_squared_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom();
|
||||
r = Distribution::find_degrees_of_freedom(r, r, r, r);
|
||||
r = Distribution::find_degrees_of_freedom(r, r, r, r, r);
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::exponential_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.lambda();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::extreme_value_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.location();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::fisher_f_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom1();
|
||||
r = d.degrees_of_freedom2();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::gamma_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.shape();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::inverse_chi_squared_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.degrees_of_freedom();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::inverse_gamma_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.shape();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::hypergeometric_distribution<R, P>& d)
|
||||
{
|
||||
unsigned u = d.defective();
|
||||
u = d.sample_count();
|
||||
u = d.total();
|
||||
suppress_unused_variable_warning(u);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::laplace_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.location();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::logistic_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.location();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::lognormal_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.location();
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::negative_binomial_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.success_fraction();
|
||||
r = d.successes();
|
||||
r = Distribution::find_lower_bound_on_p(r, r, r);
|
||||
r = Distribution::find_upper_bound_on_p(r, r, r);
|
||||
r = Distribution::find_minimum_number_of_trials(r, r, r);
|
||||
r = Distribution::find_maximum_number_of_trials(r, r, r);
|
||||
suppress_unused_variable_warning(r);
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::non_central_beta_distribution<R, P>& d)
|
||||
{
|
||||
value_type r1 = d.alpha();
|
||||
value_type r2 = d.beta();
|
||||
r1 = d.non_centrality();
|
||||
(void)r1; // warning suppression
|
||||
(void)r2; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::non_central_chi_squared_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom();
|
||||
r = d.non_centrality();
|
||||
r = Distribution::find_degrees_of_freedom(r, r, r);
|
||||
r = Distribution::find_degrees_of_freedom(boost::math::complement(r, r, r));
|
||||
r = Distribution::find_non_centrality(r, r, r);
|
||||
r = Distribution::find_non_centrality(boost::math::complement(r, r, r));
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::non_central_f_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom1();
|
||||
r = d.degrees_of_freedom2();
|
||||
r = d.non_centrality();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::non_central_t_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom();
|
||||
r = d.non_centrality();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::normal_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.location();
|
||||
r = d.mean();
|
||||
r = d.standard_deviation();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::pareto_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.shape();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::poisson_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.mean();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::rayleigh_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.sigma();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::students_t_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.degrees_of_freedom();
|
||||
r = d.find_degrees_of_freedom(r, r, r, r);
|
||||
r = d.find_degrees_of_freedom(r, r, r, r, r);
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::triangular_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.lower();
|
||||
r = d.mode();
|
||||
r = d.upper();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::weibull_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.scale();
|
||||
r = d.shape();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
template <class R, class P>
|
||||
static void test_extra_members(const boost::math::uniform_distribution<R, P>& d)
|
||||
{
|
||||
value_type r = d.lower();
|
||||
r = d.upper();
|
||||
(void)r; // warning suppression
|
||||
}
|
||||
private:
|
||||
static Distribution* pd;
|
||||
static Distribution& get_object()
|
||||
{
|
||||
// In reality this will never get called:
|
||||
return *pd;
|
||||
}
|
||||
}; // struct DistributionConcept
|
||||
|
||||
template <class Distribution>
|
||||
Distribution* DistributionConcept<Distribution>::pd = 0;
|
||||
|
||||
} // namespace concepts
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTION_CONCEPT_HPP
|
||||
|
||||
441
test/external/boost/math/concepts/real_concept.hpp
vendored
Normal file
441
test/external/boost/math/concepts/real_concept.hpp
vendored
Normal file
@@ -0,0 +1,441 @@
|
||||
// Copyright John Maddock 2006.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Test real concept.
|
||||
|
||||
// real_concept is an archetype for User defined Real types.
|
||||
|
||||
// This file defines the features, constructors, operators, functions...
|
||||
// that are essential to use mathematical and statistical functions.
|
||||
// The template typename "RealType" is used where this type
|
||||
// (as well as the normal built-in types, float, double & long double)
|
||||
// can be used.
|
||||
// That this is the minimum set is confirmed by use as a type
|
||||
// in tests of all functions & distributions, for example:
|
||||
// test_spots(0.F); & test_spots(0.); for float and double, but also
|
||||
// test_spots(boost::math::concepts::real_concept(0.));
|
||||
// NTL quad_float type is an example of a type meeting the requirements,
|
||||
// but note minor additions are needed - see ntl.diff and documentation
|
||||
// "Using With NTL - a High-Precision Floating-Point Library".
|
||||
|
||||
#ifndef BOOST_MATH_REAL_CONCEPT_HPP
|
||||
#define BOOST_MATH_REAL_CONCEPT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp>
|
||||
#include <boost/math/special_functions/modf.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
#include <boost/math/policies/policy.hpp>
|
||||
#if defined(__SGI_STL_PORT)
|
||||
# include <boost/math/tools/real_cast.hpp>
|
||||
#endif
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <math.h> // fmodl
|
||||
|
||||
#if defined(__SGI_STL_PORT) || defined(_RWSTD_VER) || defined(__LIBCOMO__)
|
||||
# include <cstdio>
|
||||
#endif
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
namespace concepts
|
||||
{
|
||||
|
||||
#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
typedef double real_concept_base_type;
|
||||
#else
|
||||
typedef long double real_concept_base_type;
|
||||
#endif
|
||||
|
||||
class real_concept
|
||||
{
|
||||
public:
|
||||
// Constructors:
|
||||
real_concept() : m_value(0){}
|
||||
real_concept(char c) : m_value(c){}
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
real_concept(wchar_t c) : m_value(c){}
|
||||
#endif
|
||||
real_concept(unsigned char c) : m_value(c){}
|
||||
real_concept(signed char c) : m_value(c){}
|
||||
real_concept(unsigned short c) : m_value(c){}
|
||||
real_concept(short c) : m_value(c){}
|
||||
real_concept(unsigned int c) : m_value(c){}
|
||||
real_concept(int c) : m_value(c){}
|
||||
real_concept(unsigned long c) : m_value(c){}
|
||||
real_concept(long c) : m_value(c){}
|
||||
#if defined(__DECCXX) || defined(__SUNPRO_CC)
|
||||
real_concept(unsigned long long c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
real_concept(long long c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
#elif defined(BOOST_HAS_LONG_LONG)
|
||||
real_concept(boost::ulong_long_type c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
real_concept(boost::long_long_type c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
real_concept(unsigned __int64 c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
real_concept(__int64 c) : m_value(static_cast<real_concept_base_type>(c)){}
|
||||
#endif
|
||||
real_concept(float c) : m_value(c){}
|
||||
real_concept(double c) : m_value(c){}
|
||||
real_concept(long double c) : m_value(c){}
|
||||
|
||||
// Assignment:
|
||||
real_concept& operator=(char c) { m_value = c; return *this; }
|
||||
real_concept& operator=(unsigned char c) { m_value = c; return *this; }
|
||||
real_concept& operator=(signed char c) { m_value = c; return *this; }
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
real_concept& operator=(wchar_t c) { m_value = c; return *this; }
|
||||
#endif
|
||||
real_concept& operator=(short c) { m_value = c; return *this; }
|
||||
real_concept& operator=(unsigned short c) { m_value = c; return *this; }
|
||||
real_concept& operator=(int c) { m_value = c; return *this; }
|
||||
real_concept& operator=(unsigned int c) { m_value = c; return *this; }
|
||||
real_concept& operator=(long c) { m_value = c; return *this; }
|
||||
real_concept& operator=(unsigned long c) { m_value = c; return *this; }
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
real_concept& operator=(boost::long_long_type c) { m_value = static_cast<real_concept_base_type>(c); return *this; }
|
||||
real_concept& operator=(boost::ulong_long_type c) { m_value = static_cast<real_concept_base_type>(c); return *this; }
|
||||
#endif
|
||||
real_concept& operator=(float c) { m_value = c; return *this; }
|
||||
real_concept& operator=(double c) { m_value = c; return *this; }
|
||||
real_concept& operator=(long double c) { m_value = c; return *this; }
|
||||
|
||||
// Access:
|
||||
real_concept_base_type value()const{ return m_value; }
|
||||
|
||||
// Member arithmetic:
|
||||
real_concept& operator+=(const real_concept& other)
|
||||
{ m_value += other.value(); return *this; }
|
||||
real_concept& operator-=(const real_concept& other)
|
||||
{ m_value -= other.value(); return *this; }
|
||||
real_concept& operator*=(const real_concept& other)
|
||||
{ m_value *= other.value(); return *this; }
|
||||
real_concept& operator/=(const real_concept& other)
|
||||
{ m_value /= other.value(); return *this; }
|
||||
real_concept operator-()const
|
||||
{ return -m_value; }
|
||||
real_concept const& operator+()const
|
||||
{ return *this; }
|
||||
real_concept& operator++()
|
||||
{ ++m_value; return *this; }
|
||||
real_concept& operator--()
|
||||
{ --m_value; return *this; }
|
||||
|
||||
private:
|
||||
real_concept_base_type m_value;
|
||||
};
|
||||
|
||||
// Non-member arithmetic:
|
||||
inline real_concept operator+(const real_concept& a, const real_concept& b)
|
||||
{
|
||||
real_concept result(a);
|
||||
result += b;
|
||||
return result;
|
||||
}
|
||||
inline real_concept operator-(const real_concept& a, const real_concept& b)
|
||||
{
|
||||
real_concept result(a);
|
||||
result -= b;
|
||||
return result;
|
||||
}
|
||||
inline real_concept operator*(const real_concept& a, const real_concept& b)
|
||||
{
|
||||
real_concept result(a);
|
||||
result *= b;
|
||||
return result;
|
||||
}
|
||||
inline real_concept operator/(const real_concept& a, const real_concept& b)
|
||||
{
|
||||
real_concept result(a);
|
||||
result /= b;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Comparison:
|
||||
inline bool operator == (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() == b.value(); }
|
||||
inline bool operator != (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() != b.value();}
|
||||
inline bool operator < (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() < b.value(); }
|
||||
inline bool operator <= (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() <= b.value(); }
|
||||
inline bool operator > (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() > b.value(); }
|
||||
inline bool operator >= (const real_concept& a, const real_concept& b)
|
||||
{ return a.value() >= b.value(); }
|
||||
|
||||
// Non-member functions:
|
||||
inline real_concept acos(real_concept a)
|
||||
{ return std::acos(a.value()); }
|
||||
inline real_concept cos(real_concept a)
|
||||
{ return std::cos(a.value()); }
|
||||
inline real_concept asin(real_concept a)
|
||||
{ return std::asin(a.value()); }
|
||||
inline real_concept atan(real_concept a)
|
||||
{ return std::atan(a.value()); }
|
||||
inline real_concept atan2(real_concept a, real_concept b)
|
||||
{ return std::atan2(a.value(), b.value()); }
|
||||
inline real_concept ceil(real_concept a)
|
||||
{ return std::ceil(a.value()); }
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
// I've seen std::fmod(long double) crash on some platforms
|
||||
// so use fmodl instead:
|
||||
#ifdef _WIN32_WCE
|
||||
//
|
||||
// Ugly workaround for macro fmodl:
|
||||
//
|
||||
inline long double call_fmodl(long double a, long double b)
|
||||
{ return fmodl(a, b); }
|
||||
inline real_concept fmod(real_concept a, real_concept b)
|
||||
{ return call_fmodl(a.value(), b.value()); }
|
||||
#else
|
||||
inline real_concept fmod(real_concept a, real_concept b)
|
||||
{ return fmodl(a.value(), b.value()); }
|
||||
#endif
|
||||
#endif
|
||||
inline real_concept cosh(real_concept a)
|
||||
{ return std::cosh(a.value()); }
|
||||
inline real_concept exp(real_concept a)
|
||||
{ return std::exp(a.value()); }
|
||||
inline real_concept fabs(real_concept a)
|
||||
{ return std::fabs(a.value()); }
|
||||
inline real_concept abs(real_concept a)
|
||||
{ return std::abs(a.value()); }
|
||||
inline real_concept floor(real_concept a)
|
||||
{ return std::floor(a.value()); }
|
||||
inline real_concept modf(real_concept a, real_concept* ipart)
|
||||
{
|
||||
real_concept_base_type ip;
|
||||
real_concept_base_type result = std::modf(a.value(), &ip);
|
||||
*ipart = ip;
|
||||
return result;
|
||||
}
|
||||
inline real_concept frexp(real_concept a, int* expon)
|
||||
{ return std::frexp(a.value(), expon); }
|
||||
inline real_concept ldexp(real_concept a, int expon)
|
||||
{ return std::ldexp(a.value(), expon); }
|
||||
inline real_concept log(real_concept a)
|
||||
{ return std::log(a.value()); }
|
||||
inline real_concept log10(real_concept a)
|
||||
{ return std::log10(a.value()); }
|
||||
inline real_concept tan(real_concept a)
|
||||
{ return std::tan(a.value()); }
|
||||
inline real_concept pow(real_concept a, real_concept b)
|
||||
{ return std::pow(a.value(), b.value()); }
|
||||
#if !defined(__SUNPRO_CC)
|
||||
inline real_concept pow(real_concept a, int b)
|
||||
{ return std::pow(a.value(), b); }
|
||||
#else
|
||||
inline real_concept pow(real_concept a, int b)
|
||||
{ return std::pow(a.value(), static_cast<real_concept_base_type>(b)); }
|
||||
#endif
|
||||
inline real_concept sin(real_concept a)
|
||||
{ return std::sin(a.value()); }
|
||||
inline real_concept sinh(real_concept a)
|
||||
{ return std::sinh(a.value()); }
|
||||
inline real_concept sqrt(real_concept a)
|
||||
{ return std::sqrt(a.value()); }
|
||||
inline real_concept tanh(real_concept a)
|
||||
{ return std::tanh(a.value()); }
|
||||
|
||||
//
|
||||
// Conversion and truncation routines:
|
||||
//
|
||||
template <class Policy>
|
||||
inline int iround(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::iround(v.value(), pol); }
|
||||
inline int iround(const concepts::real_concept& v)
|
||||
{ return boost::math::iround(v.value(), policies::policy<>()); }
|
||||
template <class Policy>
|
||||
inline long lround(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::lround(v.value(), pol); }
|
||||
inline long lround(const concepts::real_concept& v)
|
||||
{ return boost::math::lround(v.value(), policies::policy<>()); }
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template <class Policy>
|
||||
inline boost::long_long_type llround(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::llround(v.value(), pol); }
|
||||
inline boost::long_long_type llround(const concepts::real_concept& v)
|
||||
{ return boost::math::llround(v.value(), policies::policy<>()); }
|
||||
#endif
|
||||
|
||||
template <class Policy>
|
||||
inline int itrunc(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::itrunc(v.value(), pol); }
|
||||
inline int itrunc(const concepts::real_concept& v)
|
||||
{ return boost::math::itrunc(v.value(), policies::policy<>()); }
|
||||
template <class Policy>
|
||||
inline long ltrunc(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::ltrunc(v.value(), pol); }
|
||||
inline long ltrunc(const concepts::real_concept& v)
|
||||
{ return boost::math::ltrunc(v.value(), policies::policy<>()); }
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
template <class Policy>
|
||||
inline boost::long_long_type lltrunc(const concepts::real_concept& v, const Policy& pol)
|
||||
{ return boost::math::lltrunc(v.value(), pol); }
|
||||
inline boost::long_long_type lltrunc(const concepts::real_concept& v)
|
||||
{ return boost::math::lltrunc(v.value(), policies::policy<>()); }
|
||||
#endif
|
||||
|
||||
// Streaming:
|
||||
template <class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const real_concept& a)
|
||||
{
|
||||
return os << a.value();
|
||||
}
|
||||
template <class charT, class traits>
|
||||
inline std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is, real_concept& a)
|
||||
{
|
||||
#if defined(BOOST_MSVC) && defined(__SGI_STL_PORT)
|
||||
//
|
||||
// STLPort 5.1.4 has a problem reading long doubles from strings,
|
||||
// see http://sourceforge.net/tracker/index.php?func=detail&aid=1811043&group_id=146814&atid=766244
|
||||
//
|
||||
double v;
|
||||
is >> v;
|
||||
a = v;
|
||||
return is;
|
||||
#elif defined(__SGI_STL_PORT) || defined(_RWSTD_VER) || defined(__LIBCOMO__)
|
||||
std::string s;
|
||||
real_concept_base_type d;
|
||||
is >> s;
|
||||
std::sscanf(s.c_str(), "%Lf", &d);
|
||||
a = d;
|
||||
return is;
|
||||
#else
|
||||
real_concept_base_type v;
|
||||
is >> v;
|
||||
a = v;
|
||||
return is;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace concepts
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
template <>
|
||||
inline concepts::real_concept max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
return max_value<concepts::real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::real_concept min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
return min_value<concepts::real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::real_concept log_max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
return log_max_value<concepts::real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::real_concept log_min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
return log_min_value<concepts::real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::real_concept epsilon<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
#ifdef __SUNPRO_CC
|
||||
return std::numeric_limits<concepts::real_concept_base_type>::epsilon();
|
||||
#else
|
||||
return tools::epsilon<concepts::real_concept_base_type>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int digits<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
|
||||
{
|
||||
// Assume number of significand bits is same as real_concept_base_type,
|
||||
// unless std::numeric_limits<T>::is_specialized to provide digits.
|
||||
return tools::digits<concepts::real_concept_base_type>();
|
||||
// Note that if numeric_limits real concept is NOT specialized to provide digits10
|
||||
// (or max_digits10) then the default precision of 6 decimal digits will be used
|
||||
// by Boost test (giving misleading error messages like
|
||||
// "difference between {9.79796} and {9.79796} exceeds 5.42101e-19%"
|
||||
// and by Boost lexical cast and serialization causing loss of accuracy.
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
|
||||
#if defined(__SGI_STL_PORT)
|
||||
//
|
||||
// We shouldn't really need these type casts any more, but there are some
|
||||
// STLport iostream bugs we work around by using them....
|
||||
//
|
||||
namespace tools
|
||||
{
|
||||
// real_cast converts from T to integer and narrower floating-point types.
|
||||
|
||||
// Convert from T to integer types.
|
||||
|
||||
template <>
|
||||
inline unsigned int real_cast<unsigned int, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return static_cast<unsigned int>(r.value());
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int real_cast<int, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return static_cast<int>(r.value());
|
||||
}
|
||||
|
||||
template <>
|
||||
inline long real_cast<long, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return static_cast<long>(r.value());
|
||||
}
|
||||
|
||||
// Converts from T to narrower floating-point types, float, double & long double.
|
||||
|
||||
template <>
|
||||
inline float real_cast<float, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return static_cast<float>(r.value());
|
||||
}
|
||||
template <>
|
||||
inline double real_cast<double, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return static_cast<double>(r.value());
|
||||
}
|
||||
template <>
|
||||
inline long double real_cast<long double, concepts::real_concept>(concepts::real_concept r)
|
||||
{
|
||||
return r.value();
|
||||
}
|
||||
|
||||
} // STLPort
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
//
|
||||
// For some strange reason ADL sometimes fails to find the
|
||||
// correct overloads, unless we bring these declarations into scope:
|
||||
//
|
||||
using concepts::itrunc;
|
||||
using concepts::iround;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MATH_REAL_CONCEPT_HPP
|
||||
|
||||
|
||||
121
test/external/boost/math/concepts/real_type_concept.hpp
vendored
Normal file
121
test/external/boost/math/concepts/real_type_concept.hpp
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
// Copyright John Maddock 2007-8.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_REAL_TYPE_CONCEPT_HPP
|
||||
#define BOOST_MATH_REAL_TYPE_CONCEPT_HPP
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100)
|
||||
#pragma warning(disable: 4510)
|
||||
#pragma warning(disable: 4610)
|
||||
#endif
|
||||
#include <boost/concept_check.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/math/tools/config.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
|
||||
|
||||
namespace boost{ namespace math{ namespace concepts{
|
||||
|
||||
template <class RealType>
|
||||
struct RealTypeConcept
|
||||
{
|
||||
template <class Other>
|
||||
void check_binary_ops(Other o)
|
||||
{
|
||||
RealType r(o);
|
||||
r = o;
|
||||
r -= o;
|
||||
r += o;
|
||||
r *= o;
|
||||
r /= o;
|
||||
r = r - o;
|
||||
r = o - r;
|
||||
r = r + o;
|
||||
r = o + r;
|
||||
r = o * r;
|
||||
r = r * o;
|
||||
r = r / o;
|
||||
r = o / r;
|
||||
bool b;
|
||||
b = r == o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o == r;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = r != o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o != r;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = r <= o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o <= r;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = r >= o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o >= r;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = r < o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o < r;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = r > o;
|
||||
suppress_unused_variable_warning(b);
|
||||
b = o > r;
|
||||
suppress_unused_variable_warning(b);
|
||||
}
|
||||
|
||||
void constraints()
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
RealType r;
|
||||
check_binary_ops(r);
|
||||
check_binary_ops(0.5f);
|
||||
check_binary_ops(0.5);
|
||||
//check_binary_ops(0.5L);
|
||||
check_binary_ops(1);
|
||||
//check_binary_ops(1u);
|
||||
check_binary_ops(1L);
|
||||
//check_binary_ops(1uL);
|
||||
#ifndef BOOST_HAS_LONG_LONG
|
||||
check_binary_ops(1LL);
|
||||
#endif
|
||||
RealType r2 = +r;
|
||||
r2 = -r;
|
||||
|
||||
r2 = fabs(r);
|
||||
r2 = abs(r);
|
||||
r2 = ceil(r);
|
||||
r2 = floor(r);
|
||||
r2 = exp(r);
|
||||
r2 = pow(r, r2);
|
||||
r2 = sqrt(r);
|
||||
r2 = log(r);
|
||||
r2 = cos(r);
|
||||
r2 = sin(r);
|
||||
r2 = tan(r);
|
||||
r2 = asin(r);
|
||||
r2 = acos(r);
|
||||
r2 = atan(r);
|
||||
int i;
|
||||
r2 = ldexp(r, i);
|
||||
r2 = frexp(r, &i);
|
||||
i = boost::math::tools::digits<RealType>();
|
||||
r2 = boost::math::tools::max_value<RealType>();
|
||||
r2 = boost::math::tools::min_value<RealType>();
|
||||
r2 = boost::math::tools::log_max_value<RealType>();
|
||||
r2 = boost::math::tools::log_min_value<RealType>();
|
||||
r2 = boost::math::tools::epsilon<RealType>();
|
||||
}
|
||||
}; // struct DistributionConcept
|
||||
|
||||
|
||||
}}} // namespaces
|
||||
|
||||
#endif
|
||||
|
||||
386
test/external/boost/math/concepts/std_real_concept.hpp
vendored
Normal file
386
test/external/boost/math/concepts/std_real_concept.hpp
vendored
Normal file
@@ -0,0 +1,386 @@
|
||||
// Copyright John Maddock 2006.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// std_real_concept is an archetype for built-in Real types.
|
||||
|
||||
// The main purpose in providing this type is to verify
|
||||
// that std lib functions are found via a using declaration
|
||||
// bringing those functions into the current scope, and not
|
||||
// just because they happen to be in global scope.
|
||||
//
|
||||
// If ::pow is found rather than std::pow say, then the code
|
||||
// will silently compile, but truncation of long doubles to
|
||||
// double will cause a significant loss of precision.
|
||||
// A template instantiated with std_real_concept will *only*
|
||||
// compile if it std::whatever is in scope.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/math/policies/policy.hpp>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <math.h> // fmodl
|
||||
|
||||
#ifndef BOOST_MATH_STD_REAL_CONCEPT_HPP
|
||||
#define BOOST_MATH_STD_REAL_CONCEPT_HPP
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
namespace concepts
|
||||
{
|
||||
|
||||
#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
typedef double std_real_concept_base_type;
|
||||
#else
|
||||
typedef long double std_real_concept_base_type;
|
||||
#endif
|
||||
|
||||
class std_real_concept
|
||||
{
|
||||
public:
|
||||
// Constructors:
|
||||
std_real_concept() : m_value(0){}
|
||||
std_real_concept(char c) : m_value(c){}
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
std_real_concept(wchar_t c) : m_value(c){}
|
||||
#endif
|
||||
std_real_concept(unsigned char c) : m_value(c){}
|
||||
std_real_concept(signed char c) : m_value(c){}
|
||||
std_real_concept(unsigned short c) : m_value(c){}
|
||||
std_real_concept(short c) : m_value(c){}
|
||||
std_real_concept(unsigned int c) : m_value(c){}
|
||||
std_real_concept(int c) : m_value(c){}
|
||||
std_real_concept(unsigned long c) : m_value(c){}
|
||||
std_real_concept(long c) : m_value(c){}
|
||||
#if defined(__DECCXX) || defined(__SUNPRO_CC)
|
||||
std_real_concept(unsigned long long c) : m_value(static_cast<std_real_concept_base_type>(c)){}
|
||||
std_real_concept(long long c) : m_value(static_cast<std_real_concept_base_type>(c)){}
|
||||
#elif defined(BOOST_HAS_LONG_LONG)
|
||||
std_real_concept(boost::ulong_long_type c) : m_value(static_cast<std_real_concept_base_type>(c)){}
|
||||
std_real_concept(boost::long_long_type c) : m_value(static_cast<std_real_concept_base_type>(c)){}
|
||||
#endif
|
||||
std_real_concept(float c) : m_value(c){}
|
||||
std_real_concept(double c) : m_value(c){}
|
||||
std_real_concept(long double c) : m_value(c){}
|
||||
|
||||
// Assignment:
|
||||
std_real_concept& operator=(char c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(unsigned char c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(signed char c) { m_value = c; return *this; }
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
std_real_concept& operator=(wchar_t c) { m_value = c; return *this; }
|
||||
#endif
|
||||
std_real_concept& operator=(short c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(unsigned short c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(int c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(unsigned int c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(long c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(unsigned long c) { m_value = c; return *this; }
|
||||
#if defined(__DECCXX) || defined(__SUNPRO_CC)
|
||||
std_real_concept& operator=(unsigned long long c) { m_value = static_cast<std_real_concept_base_type>(c); return *this; }
|
||||
std_real_concept& operator=(long long c) { m_value = static_cast<std_real_concept_base_type>(c); return *this; }
|
||||
#elif defined(BOOST_HAS_LONG_LONG)
|
||||
std_real_concept& operator=(boost::long_long_type c) { m_value = static_cast<std_real_concept_base_type>(c); return *this; }
|
||||
std_real_concept& operator=(boost::ulong_long_type c) { m_value = static_cast<std_real_concept_base_type>(c); return *this; }
|
||||
#endif
|
||||
std_real_concept& operator=(float c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(double c) { m_value = c; return *this; }
|
||||
std_real_concept& operator=(long double c) { m_value = c; return *this; }
|
||||
|
||||
// Access:
|
||||
std_real_concept_base_type value()const{ return m_value; }
|
||||
|
||||
// Member arithmetic:
|
||||
std_real_concept& operator+=(const std_real_concept& other)
|
||||
{ m_value += other.value(); return *this; }
|
||||
std_real_concept& operator-=(const std_real_concept& other)
|
||||
{ m_value -= other.value(); return *this; }
|
||||
std_real_concept& operator*=(const std_real_concept& other)
|
||||
{ m_value *= other.value(); return *this; }
|
||||
std_real_concept& operator/=(const std_real_concept& other)
|
||||
{ m_value /= other.value(); return *this; }
|
||||
std_real_concept operator-()const
|
||||
{ return -m_value; }
|
||||
std_real_concept const& operator+()const
|
||||
{ return *this; }
|
||||
|
||||
private:
|
||||
std_real_concept_base_type m_value;
|
||||
};
|
||||
|
||||
// Non-member arithmetic:
|
||||
inline std_real_concept operator+(const std_real_concept& a, const std_real_concept& b)
|
||||
{
|
||||
std_real_concept result(a);
|
||||
result += b;
|
||||
return result;
|
||||
}
|
||||
inline std_real_concept operator-(const std_real_concept& a, const std_real_concept& b)
|
||||
{
|
||||
std_real_concept result(a);
|
||||
result -= b;
|
||||
return result;
|
||||
}
|
||||
inline std_real_concept operator*(const std_real_concept& a, const std_real_concept& b)
|
||||
{
|
||||
std_real_concept result(a);
|
||||
result *= b;
|
||||
return result;
|
||||
}
|
||||
inline std_real_concept operator/(const std_real_concept& a, const std_real_concept& b)
|
||||
{
|
||||
std_real_concept result(a);
|
||||
result /= b;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Comparison:
|
||||
inline bool operator == (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() == b.value(); }
|
||||
inline bool operator != (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() != b.value();}
|
||||
inline bool operator < (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() < b.value(); }
|
||||
inline bool operator <= (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() <= b.value(); }
|
||||
inline bool operator > (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() > b.value(); }
|
||||
inline bool operator >= (const std_real_concept& a, const std_real_concept& b)
|
||||
{ return a.value() >= b.value(); }
|
||||
|
||||
} // namespace concepts
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
namespace std{
|
||||
|
||||
// Non-member functions:
|
||||
inline boost::math::concepts::std_real_concept acos(boost::math::concepts::std_real_concept a)
|
||||
{ return std::acos(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept cos(boost::math::concepts::std_real_concept a)
|
||||
{ return std::cos(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept asin(boost::math::concepts::std_real_concept a)
|
||||
{ return std::asin(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept atan(boost::math::concepts::std_real_concept a)
|
||||
{ return std::atan(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept atan2(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
|
||||
{ return std::atan2(a.value(), b.value()); }
|
||||
inline boost::math::concepts::std_real_concept ceil(boost::math::concepts::std_real_concept a)
|
||||
{ return std::ceil(a.value()); }
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
|
||||
{ return fmodl(a.value(), b.value()); }
|
||||
#else
|
||||
inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
|
||||
{ return std::fmod(a.value(), b.value()); }
|
||||
#endif
|
||||
inline boost::math::concepts::std_real_concept cosh(boost::math::concepts::std_real_concept a)
|
||||
{ return std::cosh(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept exp(boost::math::concepts::std_real_concept a)
|
||||
{ return std::exp(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept fabs(boost::math::concepts::std_real_concept a)
|
||||
{ return std::fabs(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept abs(boost::math::concepts::std_real_concept a)
|
||||
{ return std::abs(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept floor(boost::math::concepts::std_real_concept a)
|
||||
{ return std::floor(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept modf(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept* ipart)
|
||||
{
|
||||
boost::math::concepts::std_real_concept_base_type ip;
|
||||
boost::math::concepts::std_real_concept_base_type result = std::modf(a.value(), &ip);
|
||||
*ipart = ip;
|
||||
return result;
|
||||
}
|
||||
inline boost::math::concepts::std_real_concept frexp(boost::math::concepts::std_real_concept a, int* expon)
|
||||
{ return std::frexp(a.value(), expon); }
|
||||
inline boost::math::concepts::std_real_concept ldexp(boost::math::concepts::std_real_concept a, int expon)
|
||||
{ return std::ldexp(a.value(), expon); }
|
||||
inline boost::math::concepts::std_real_concept log(boost::math::concepts::std_real_concept a)
|
||||
{ return std::log(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept log10(boost::math::concepts::std_real_concept a)
|
||||
{ return std::log10(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept tan(boost::math::concepts::std_real_concept a)
|
||||
{ return std::tan(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b)
|
||||
{ return std::pow(a.value(), b.value()); }
|
||||
#if !defined(__SUNPRO_CC)
|
||||
inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, int b)
|
||||
{ return std::pow(a.value(), b); }
|
||||
#else
|
||||
inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, int b)
|
||||
{ return std::pow(a.value(), static_cast<long double>(b)); }
|
||||
#endif
|
||||
inline boost::math::concepts::std_real_concept sin(boost::math::concepts::std_real_concept a)
|
||||
{ return std::sin(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept sinh(boost::math::concepts::std_real_concept a)
|
||||
{ return std::sinh(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept sqrt(boost::math::concepts::std_real_concept a)
|
||||
{ return std::sqrt(a.value()); }
|
||||
inline boost::math::concepts::std_real_concept tanh(boost::math::concepts::std_real_concept a)
|
||||
{ return std::tanh(a.value()); }
|
||||
|
||||
} // namespace std
|
||||
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp>
|
||||
#include <boost/math/special_functions/modf.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
|
||||
namespace boost{ namespace math{ namespace concepts{
|
||||
|
||||
//
|
||||
// Conversion and truncation routines:
|
||||
//
|
||||
template <class Policy>
|
||||
inline int iround(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::iround(v.value(), pol);
|
||||
}
|
||||
inline int iround(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::iround(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
template <class Policy>
|
||||
inline long lround(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::lround(v.value(), pol);
|
||||
}
|
||||
inline long lround(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::lround(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
|
||||
template <class Policy>
|
||||
inline boost::long_long_type llround(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::llround(v.value(), pol);
|
||||
}
|
||||
inline boost::long_long_type llround(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::llround(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <class Policy>
|
||||
inline int itrunc(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::itrunc(v.value(), pol);
|
||||
}
|
||||
inline int itrunc(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::itrunc(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
template <class Policy>
|
||||
inline long ltrunc(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::ltrunc(v.value(), pol);
|
||||
}
|
||||
inline long ltrunc(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::ltrunc(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
|
||||
template <class Policy>
|
||||
inline boost::long_long_type lltrunc(const concepts::std_real_concept& v, const Policy& pol)
|
||||
{
|
||||
return boost::math::lltrunc(v.value(), pol);
|
||||
}
|
||||
inline boost::long_long_type lltrunc(const concepts::std_real_concept& v)
|
||||
{
|
||||
return boost::math::lltrunc(v.value(), policies::policy<>());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Streaming:
|
||||
template <class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const std_real_concept& a)
|
||||
{
|
||||
return os << a.value();
|
||||
}
|
||||
template <class charT, class traits>
|
||||
inline std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is, std_real_concept& a)
|
||||
{
|
||||
std_real_concept_base_type v;
|
||||
is >> v;
|
||||
a = v;
|
||||
return is;
|
||||
}
|
||||
|
||||
} // namespace concepts
|
||||
}}
|
||||
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
|
||||
namespace boost{ namespace math{
|
||||
namespace tools
|
||||
{
|
||||
|
||||
template <>
|
||||
inline concepts::std_real_concept max_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{
|
||||
return max_value<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::std_real_concept min_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{
|
||||
return min_value<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::std_real_concept log_max_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{
|
||||
return log_max_value<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::std_real_concept log_min_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{
|
||||
return log_min_value<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline concepts::std_real_concept epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{
|
||||
return tools::epsilon<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int digits<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
|
||||
{ // Assume number of significand bits is same as std_real_concept_base_type,
|
||||
// unless std::numeric_limits<T>::is_specialized to provide digits.
|
||||
return digits<concepts::std_real_concept_base_type>();
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
using concepts::itrunc;
|
||||
using concepts::ltrunc;
|
||||
using concepts::lltrunc;
|
||||
using concepts::iround;
|
||||
using concepts::lround;
|
||||
using concepts::llround;
|
||||
#endif
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MATH_STD_REAL_CONCEPT_HPP
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user