Initial Commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under 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)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief suppress some warnings
|
||||
// ***************************************************************************
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4511) // copy constructor can't not be generated
|
||||
# pragma warning(disable: 4512) // assignment operator can't not be generated
|
||||
# pragma warning(disable: 4100) // unreferenced formal parameter
|
||||
# pragma warning(disable: 4996) // <symbol> was declared deprecated
|
||||
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
||||
# pragma warning(disable: 4706) // assignment within conditional expression
|
||||
# pragma warning(disable: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
|
||||
# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
|
||||
# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ...
|
||||
# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
|
||||
#endif
|
||||
|
||||
#if BOOST_CLANG
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wvariadic-macros"
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC) && (BOOST_GCC >= 4 * 10000 + 6 * 100)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/interprocess for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTERPROCESS_POSIX_TIMES_WRK_HPP
|
||||
#define BOOST_INTERPROCESS_POSIX_TIMES_WRK_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
#
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//workaround to avoid winsock redefines when using date-time
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define BOOST_INTERPROCESS_WIN32_LEAN_AND_MEAN
|
||||
#endif //#ifndef WIN32_LEAN_AND_MEAN
|
||||
#endif //#ifdef _WIN32
|
||||
|
||||
#include <boost/date_time/microsec_time_clock.hpp>
|
||||
#include <boost/date_time/posix_time/ptime.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_duration.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
|
||||
typedef boost::date_time::microsec_clock<boost::posix_time::ptime> microsec_clock;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef BOOST_INTERPROCESS_WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#undef BOOST_INTERPROCESS_WIN32_LEAN_AND_MEAN
|
||||
#endif //#ifdef BOOST_INTERPROCESS_WIN32_LEAN_AND_MEAN
|
||||
#endif //#ifdef _WIN32
|
||||
|
||||
#endif //#ifndef BOOST_INTERPROCESS_POSIX_TIMES_WRK_HPP
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range
|
||||
{
|
||||
|
||||
/// \brief template function lexicographic_compare
|
||||
///
|
||||
/// range-based version of the lexicographic_compare std algorithm
|
||||
///
|
||||
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
|
||||
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||
return std::lexicographical_compare(
|
||||
boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), boost::end(rng2));
|
||||
}
|
||||
|
||||
/// \overload
|
||||
template<class SinglePassRange1, class SinglePassRange2,
|
||||
class BinaryPredicate>
|
||||
inline bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||
return std::lexicographical_compare(
|
||||
boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), boost::end(rng2), pred);
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
using range::lexicographical_compare;
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,166 @@
|
||||
// Copyright (C) 2005 Arkadiy Vertleyb
|
||||
// Copyright (C) 2005 Peder Holt
|
||||
//
|
||||
// Copyright (C) 2006 Tobias Schwinger
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_TYPEOF_VECTOR_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/preprocessor/iteration/self.hpp>
|
||||
|
||||
#ifndef BOOST_TYPEOF_LIMIT_SIZE
|
||||
# define BOOST_TYPEOF_LIMIT_SIZE 50
|
||||
#endif
|
||||
|
||||
//
|
||||
// To recreate the preprocessed versions of this file preprocess and run
|
||||
//
|
||||
// $(BOOST_ROOT)/libs/typeof/tools/preprocess.pl
|
||||
//
|
||||
|
||||
#if defined(BOOST_TYPEOF_PP_INCLUDE_EXTERNAL)
|
||||
|
||||
# undef BOOST_TYPEOF_PP_INCLUDE_EXTERNAL
|
||||
|
||||
#elif !defined(BOOST_TYPEOF_PREPROCESSING_MODE) && !BOOST_PP_IS_SELFISH
|
||||
|
||||
# define BOOST_PP_INDIRECT_SELF <boost/typeof/vector.hpp>
|
||||
# if BOOST_TYPEOF_LIMIT_SIZE < 50
|
||||
# include BOOST_PP_INCLUDE_SELF()
|
||||
# elif BOOST_TYPEOF_LIMIT_SIZE < 100
|
||||
# include <boost/typeof/vector50.hpp>
|
||||
# define BOOST_TYPEOF_PP_START_SIZE 51
|
||||
# include BOOST_PP_INCLUDE_SELF()
|
||||
# elif BOOST_TYPEOF_LIMIT_SIZE < 150
|
||||
# include <boost/typeof/vector100.hpp>
|
||||
# define BOOST_TYPEOF_PP_START_SIZE 101
|
||||
# include BOOST_PP_INCLUDE_SELF()
|
||||
# elif BOOST_TYPEOF_LIMIT_SIZE < 200
|
||||
# include <boost/typeof/vector150.hpp>
|
||||
# define BOOST_TYPEOF_PP_START_SIZE 151
|
||||
# include BOOST_PP_INCLUDE_SELF()
|
||||
# elif BOOST_TYPEOF_LIMIT_SIZE <= 250
|
||||
# include <boost/typeof/vector200.hpp>
|
||||
# define BOOST_TYPEOF_PP_START_SIZE 201
|
||||
# include BOOST_PP_INCLUDE_SELF()
|
||||
# else
|
||||
# error "BOOST_TYPEOF_LIMIT_SIZE too high"
|
||||
# endif
|
||||
|
||||
#else// defined(BOOST_TYPEOF_PREPROCESSING_MODE) || BOOST_PP_IS_SELFISH
|
||||
|
||||
# ifndef BOOST_TYPEOF_PP_NEXT_SIZE
|
||||
# define BOOST_TYPEOF_PP_NEXT_SIZE BOOST_TYPEOF_LIMIT_SIZE
|
||||
# endif
|
||||
# ifndef BOOST_TYPEOF_PP_START_SIZE
|
||||
# define BOOST_TYPEOF_PP_START_SIZE 0
|
||||
# endif
|
||||
|
||||
# if BOOST_TYPEOF_PP_START_SIZE <= BOOST_TYPEOF_LIMIT_SIZE
|
||||
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/repeat_from_to.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/inc.hpp>
|
||||
# include <boost/preprocessor/dec.hpp>
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/iteration/local.hpp>
|
||||
# include <boost/preprocessor/control/expr_iif.hpp>
|
||||
# include <boost/preprocessor/logical/not.hpp>
|
||||
|
||||
// iterator
|
||||
|
||||
# define BOOST_TYPEOF_spec_iter(n)\
|
||||
template<class V>\
|
||||
struct v_iter<V, mpl::int_<n> >\
|
||||
{\
|
||||
typedef typename V::item ## n type;\
|
||||
typedef v_iter<V, mpl::int_<n + 1> > next;\
|
||||
};
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
template<class V, class Increase_BOOST_TYPEOF_LIMIT_SIZE> struct v_iter; // not defined
|
||||
# define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_iter
|
||||
# define BOOST_PP_LOCAL_LIMITS \
|
||||
(BOOST_PP_DEC(BOOST_TYPEOF_PP_START_SIZE), \
|
||||
BOOST_PP_DEC(BOOST_TYPEOF_LIMIT_SIZE))
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
# undef BOOST_TYPEOF_spec_iter
|
||||
|
||||
// vector
|
||||
|
||||
# define BOOST_TYPEOF_typedef_item(z, n, _)\
|
||||
typedef P ## n item ## n;
|
||||
|
||||
# define BOOST_TYPEOF_typedef_fake_item(z, n, _)\
|
||||
typedef mpl::int_<1> item ## n;
|
||||
|
||||
# define BOOST_TYPEOF_define_vector(n)\
|
||||
template<BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IIF(BOOST_PP_NOT(n), class T = void)>\
|
||||
struct vector ## n\
|
||||
{\
|
||||
typedef v_iter<vector ## n<BOOST_PP_ENUM_PARAMS(n,P)>, boost::mpl::int_<0> > begin;\
|
||||
BOOST_PP_REPEAT(n, BOOST_TYPEOF_typedef_item, ~)\
|
||||
BOOST_PP_REPEAT_FROM_TO(n, BOOST_TYPEOF_PP_NEXT_SIZE, BOOST_TYPEOF_typedef_fake_item, ~)\
|
||||
};
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
# define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_define_vector
|
||||
# define BOOST_PP_LOCAL_LIMITS \
|
||||
(BOOST_TYPEOF_PP_START_SIZE,BOOST_TYPEOF_LIMIT_SIZE)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
# undef BOOST_TYPEOF_typedef_item
|
||||
# undef BOOST_TYPEOF_typedef_fake_item
|
||||
# undef BOOST_TYPEOF_define_vector
|
||||
|
||||
// push_back
|
||||
|
||||
# define BOOST_TYPEOF_spec_push_back(n)\
|
||||
template<BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_COMMA_IF(n) class T>\
|
||||
struct push_back<BOOST_PP_CAT(boost::type_of::vector, n)<BOOST_PP_ENUM_PARAMS(n, P)>, T>\
|
||||
{\
|
||||
typedef BOOST_PP_CAT(boost::type_of::vector, BOOST_PP_INC(n))<\
|
||||
BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_COMMA_IF(n) T\
|
||||
> type;\
|
||||
};
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
# if BOOST_TYPEOF_LIMIT_SIZE < 50
|
||||
template<class V, class T> struct push_back {
|
||||
typedef V type;
|
||||
};
|
||||
# endif
|
||||
//default behaviour is to let push_back ignore T, and return the input vector.
|
||||
//This is to let BOOST_TYPEOF_NESTED_TYPEDEF work properly with the default vector.
|
||||
# define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_push_back
|
||||
# define BOOST_PP_LOCAL_LIMITS \
|
||||
(BOOST_PP_DEC(BOOST_TYPEOF_PP_START_SIZE), \
|
||||
BOOST_PP_DEC(BOOST_TYPEOF_LIMIT_SIZE))
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
# undef BOOST_TYPEOF_spec_push_back
|
||||
|
||||
# endif//BOOST_TYPEOF_PP_START_SIZE<=BOOST_TYPEOF_LIMIT_SIZE
|
||||
# undef BOOST_TYPEOF_PP_START_SIZE
|
||||
# undef BOOST_TYPEOF_PP_NEXT_SIZE
|
||||
|
||||
#endif//BOOST_TYPEOF_PREPROCESSING_MODE || BOOST_PP_IS_SELFISH
|
||||
|
||||
#define BOOST_TYPEOF_VECTOR_HPP_INCLUDED
|
||||
#endif//BOOST_TYPEOF_VECTOR_HPP_INCLUDED
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// 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)
|
||||
//
|
||||
// This file is machine generated, do not edit by hand
|
||||
|
||||
// Polynomial evaluation using second order Horners rule
|
||||
#ifndef BOOST_MATH_TOOLS_RAT_EVAL_10_HPP
|
||||
#define BOOST_MATH_TOOLS_RAT_EVAL_10_HPP
|
||||
|
||||
namespace boost{ namespace math{ namespace tools{ namespace detail{
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(0);
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(a[0]) / static_cast<V>(b[0]);
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x) / ((b[4] * x2 + b[2]) * x2 + b[0] + (b[3] * x2 + b[1]) * x));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>(((a[0] * z2 + a[2]) * z2 + a[4] + (a[1] * z2 + a[3]) * z) / ((b[0] * z2 + b[2]) * z2 + b[4] + (b[1] * z2 + b[3]) * z));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]) / (((b[5] * x2 + b[3]) * x2 + b[1]) * x + (b[4] * x2 + b[2]) * x2 + b[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>((((a[0] * z2 + a[2]) * z2 + a[4]) * z + (a[1] * z2 + a[3]) * z2 + a[5]) / (((b[0] * z2 + b[2]) * z2 + b[4]) * z + (b[1] * z2 + b[3]) * z2 + b[5]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x) / (((b[6] * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + ((b[5] * x2 + b[3]) * x2 + b[1]) * x));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6] + ((a[1] * z2 + a[3]) * z2 + a[5]) * z) / (((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6] + ((b[1] * z2 + b[3]) * z2 + b[5]) * z));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / ((((b[7] * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + ((b[6] * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>(((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z + ((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) / ((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z + ((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x) / ((((b[8] * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + (((b[7] * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>(((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8] + (((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z) / ((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8] + (((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / (((((b[9] * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + (((b[8] * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
V z2 = 1 / (x * x);
|
||||
return static_cast<V>((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z + (((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) / (((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z + (((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}}} // namespaces
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
|
||||
#define BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// dataflow_exception.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is 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)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#include <exception>
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace iterators {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// exceptions thrown by dataflows
|
||||
//
|
||||
class dataflow_exception : public std::exception
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
invalid_6_bitcode,
|
||||
invalid_base64_character,
|
||||
invalid_xml_escape_sequence,
|
||||
comparison_not_permitted,
|
||||
invalid_conversion,
|
||||
other_exception
|
||||
} exception_code;
|
||||
exception_code code;
|
||||
|
||||
dataflow_exception(exception_code c = other_exception) : code(c)
|
||||
{}
|
||||
|
||||
virtual const char *what( ) const throw( )
|
||||
{
|
||||
const char *msg = "unknown exception code";
|
||||
switch(code){
|
||||
case invalid_6_bitcode:
|
||||
msg = "attempt to encode a value > 6 bits";
|
||||
break;
|
||||
case invalid_base64_character:
|
||||
msg = "attempt to decode a value not in base64 char set";
|
||||
break;
|
||||
case invalid_xml_escape_sequence:
|
||||
msg = "invalid xml escape_sequence";
|
||||
break;
|
||||
case comparison_not_permitted:
|
||||
msg = "cannot invoke iterator comparison now";
|
||||
break;
|
||||
case invalid_conversion:
|
||||
msg = "invalid multbyte/wide char conversion";
|
||||
break;
|
||||
default:
|
||||
BOOST_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace iterators
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
This file is part of program wsprd, a detector/demodulator/decoder
|
||||
for the Weak Signal Propagation Reporter (WSPR) mode.
|
||||
|
||||
File name: wsprd_utils.c
|
||||
|
||||
Copyright 2001-2015, Joe Taylor, K1JT
|
||||
|
||||
Most of the code is based on work by Steven Franke, K9AN, which
|
||||
in turn was based on earlier work by K1JT.
|
||||
|
||||
Copyright 2014-2015, Steven Franke, K9AN
|
||||
|
||||
License: GNU GPL v3
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "wsprd_utils.h"
|
||||
|
||||
#ifndef int32_t
|
||||
#define int32_t int
|
||||
#endif
|
||||
|
||||
void unpack50( signed char *dat, int32_t *n1, int32_t *n2 )
|
||||
{
|
||||
int32_t i,i4;
|
||||
|
||||
i=dat[0];
|
||||
i4=i&255;
|
||||
*n1=i4<<20;
|
||||
|
||||
i=dat[1];
|
||||
i4=i&255;
|
||||
*n1=*n1+(i4<<12);
|
||||
|
||||
i=dat[2];
|
||||
i4=i&255;
|
||||
*n1=*n1+(i4<<4);
|
||||
|
||||
i=dat[3];
|
||||
i4=i&255;
|
||||
*n1=*n1+((i4>>4)&15);
|
||||
*n2=(i4&15)<<18;
|
||||
|
||||
i=dat[4];
|
||||
i4=i&255;
|
||||
*n2=*n2+(i4<<10);
|
||||
|
||||
i=dat[5];
|
||||
i4=i&255;
|
||||
*n2=*n2+(i4<<2);
|
||||
|
||||
i=dat[6];
|
||||
i4=i&255;
|
||||
*n2=*n2+((i4>>6)&3);
|
||||
}
|
||||
|
||||
int unpackcall( int32_t ncall, char *call )
|
||||
{
|
||||
char c[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E',
|
||||
'F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',
|
||||
'U','V','W','X','Y','Z',' '};
|
||||
int32_t n;
|
||||
int i;
|
||||
char tmp[7];
|
||||
|
||||
n=ncall;
|
||||
strcpy(call,"......");
|
||||
if (n < 262177560 ) {
|
||||
i=n%27+10;
|
||||
tmp[5]=c[i];
|
||||
n=n/27;
|
||||
i=n%27+10;
|
||||
tmp[4]=c[i];
|
||||
n=n/27;
|
||||
i=n%27+10;
|
||||
tmp[3]=c[i];
|
||||
n=n/27;
|
||||
i=n%10;
|
||||
tmp[2]=c[i];
|
||||
n=n/10;
|
||||
i=n%36;
|
||||
tmp[1]=c[i];
|
||||
n=n/36;
|
||||
i=n;
|
||||
tmp[0]=c[i];
|
||||
tmp[6]='\0';
|
||||
// remove leading whitespace
|
||||
for(i=0; i<5; i++) {
|
||||
if( tmp[i] != c[36] )
|
||||
break;
|
||||
}
|
||||
sprintf(call,"%-6s",&tmp[i]);
|
||||
// remove trailing whitespace
|
||||
for(i=0; i<6; i++) {
|
||||
if( call[i] == c[36] ) {
|
||||
call[i]='\0';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unpackgrid( int32_t ngrid, char *grid)
|
||||
{
|
||||
char c[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E',
|
||||
'F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',
|
||||
'U','V','W','X','Y','Z',' '};
|
||||
int dlat, dlong;
|
||||
|
||||
ngrid=ngrid>>7;
|
||||
if( ngrid < 32400 ) {
|
||||
dlat=(ngrid%180)-90;
|
||||
dlong=(ngrid/180)*2 - 180 + 2;
|
||||
if( dlong < -180 )
|
||||
dlong=dlong+360;
|
||||
if( dlong > 180 )
|
||||
dlong=dlong+360;
|
||||
int nlong = 60.0*(180.0-dlong)/5.0;
|
||||
int n1 = nlong/240;
|
||||
int n2 = (nlong - 240*n1)/24;
|
||||
grid[0] = c[10+n1];
|
||||
grid[2]= c[n2];
|
||||
|
||||
int nlat = 60.0*(dlat+90)/2.5;
|
||||
n1 = nlat/240;
|
||||
n2 = (nlat-240*n1)/24;
|
||||
grid[1]=c[10+n1];
|
||||
grid[3]=c[n2];
|
||||
} else {
|
||||
strcpy(grid,"XXXX");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unpackpfx( int32_t nprefix, char *call)
|
||||
{
|
||||
char nc, pfx[4]={'\0'}, tmpcall[7];
|
||||
int i;
|
||||
int32_t n;
|
||||
|
||||
strcpy(tmpcall,call);
|
||||
if( nprefix < 60000 ) {
|
||||
// add a prefix of 1 to 3 characters
|
||||
n=nprefix;
|
||||
for (i=2; i>=0; i--) {
|
||||
nc=n%37;
|
||||
if( (nc >= 0) & (nc <= 9) ) {
|
||||
pfx[i]=nc+48;
|
||||
}
|
||||
else if( (nc >= 10) & (nc <= 35) ) {
|
||||
pfx[i]=nc+55;
|
||||
}
|
||||
else {
|
||||
pfx[i]=' ';
|
||||
}
|
||||
n=n/37;
|
||||
}
|
||||
|
||||
char * p = strrchr(pfx,' ');
|
||||
strcpy(call, p ? p + 1 : pfx);
|
||||
strncat(call,"/",1);
|
||||
strncat(call,tmpcall,strlen(tmpcall));
|
||||
|
||||
} else {
|
||||
// add a suffix of 1 or 2 characters
|
||||
nc=nprefix-60000;
|
||||
if( (nc >= 0) & (nc <= 9) ) {
|
||||
pfx[0]=nc+48;
|
||||
strcpy(call,tmpcall);
|
||||
strncat(call,"/",1);
|
||||
strncat(call,pfx,1);
|
||||
}
|
||||
else if( (nc >= 10) & (nc <= 35) ) {
|
||||
pfx[0]=nc+55;
|
||||
strcpy(call,tmpcall);
|
||||
strncat(call,"/",1);
|
||||
strncat(call,pfx,1);
|
||||
}
|
||||
else if( (nc >= 36) & (nc <= 125) ) {
|
||||
pfx[0]=(nc-26)/10+48;
|
||||
pfx[1]=(nc-26)%10+48;
|
||||
strcpy(call,tmpcall);
|
||||
strncat(call,"/",1);
|
||||
strncat(call,pfx,2);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void deinterleave(unsigned char *sym)
|
||||
{
|
||||
unsigned char tmp[162];
|
||||
unsigned char p, i, j;
|
||||
|
||||
p=0;
|
||||
i=0;
|
||||
while (p<162) {
|
||||
j=((i * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
|
||||
if (j < 162 ) {
|
||||
tmp[p]=sym[j];
|
||||
p=p+1;
|
||||
}
|
||||
i=i+1;
|
||||
}
|
||||
for (i=0; i<162; i++) {
|
||||
sym[i]=tmp[i];
|
||||
}
|
||||
}
|
||||
|
||||
// used by qsort
|
||||
int doublecomp(const void* elem1, const void* elem2)
|
||||
{
|
||||
if(*(const double*)elem1 < *(const double*)elem2)
|
||||
return -1;
|
||||
return *(const double*)elem1 > *(const double*)elem2;
|
||||
}
|
||||
|
||||
int floatcomp(const void* elem1, const void* elem2)
|
||||
{
|
||||
if(*(const float*)elem1 < *(const float*)elem2)
|
||||
return -1;
|
||||
return *(const float*)elem1 > *(const float*)elem2;
|
||||
}
|
||||
|
||||
int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsign)
|
||||
{
|
||||
int n1,n2,n3,ndbm,ihash,nadd,noprint=0;
|
||||
char grid[5],grid6[7],cdbm[3];
|
||||
|
||||
unpack50(message,&n1,&n2);
|
||||
if( !unpackcall(n1,callsign) ) return 1;
|
||||
if( !unpackgrid(n2, grid) ) return 1;
|
||||
int ntype = (n2&127) - 64;
|
||||
callsign[12]=0;
|
||||
grid[4]=0;
|
||||
|
||||
/*
|
||||
Based on the value of ntype, decide whether this is a Type 1, 2, or
|
||||
3 message.
|
||||
|
||||
* Type 1: 6 digit call, grid, power - ntype is positive and is a member
|
||||
of the set {0,3,7,10,13,17,20...60}
|
||||
|
||||
* Type 2: extended callsign, power - ntype is positive but not
|
||||
a member of the set of allowed powers
|
||||
|
||||
* Type 3: hash, 6 digit grid, power - ntype is negative.
|
||||
*/
|
||||
|
||||
if( (ntype >= 0) && (ntype <= 62) ) {
|
||||
int nu=ntype%10;
|
||||
if( nu == 0 || nu == 3 || nu == 7 ) {
|
||||
ndbm=ntype;
|
||||
memset(call_loc_pow,0,sizeof(char)*23);
|
||||
sprintf(cdbm,"%2d",ndbm);
|
||||
strncat(call_loc_pow,callsign,strlen(callsign));
|
||||
strncat(call_loc_pow," ",1);
|
||||
strncat(call_loc_pow,grid,4);
|
||||
strncat(call_loc_pow," ",1);
|
||||
strncat(call_loc_pow,cdbm,2);
|
||||
strncat(call_loc_pow,"\0",1);
|
||||
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
|
||||
strcpy(hashtab+ihash*13,callsign);
|
||||
} else {
|
||||
nadd=nu;
|
||||
if( nu > 3 ) nadd=nu-3;
|
||||
if( nu > 7 ) nadd=nu-7;
|
||||
n3=n2/128+32768*(nadd-1);
|
||||
if( !unpackpfx(n3,callsign) ) return 1;
|
||||
ndbm=ntype-nadd;
|
||||
memset(call_loc_pow,0,sizeof(char)*23);
|
||||
sprintf(cdbm,"%2d",ndbm);
|
||||
strncat(call_loc_pow,callsign,strlen(callsign));
|
||||
strncat(call_loc_pow," ",1);
|
||||
strncat(call_loc_pow,cdbm,2);
|
||||
strncat(call_loc_pow,"\0",1);
|
||||
int nu=ndbm%10;
|
||||
if( nu == 0 || nu == 3 || nu == 7 || nu == 10 ) { //make sure power is OK
|
||||
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
|
||||
strcpy(hashtab+ihash*13,callsign);
|
||||
} else noprint=1;
|
||||
}
|
||||
} else if ( ntype < 0 ) {
|
||||
ndbm=-(ntype+1);
|
||||
memset(grid6,0,sizeof(char)*7);
|
||||
// size_t len=strlen(callsign);
|
||||
size_t len=6;
|
||||
strncat(grid6,callsign+len-1,1);
|
||||
strncat(grid6,callsign,len-1);
|
||||
int nu=ndbm%10;
|
||||
if ((nu != 0 && nu != 3 && nu != 7 && nu != 10) ||
|
||||
!isalpha(grid6[0]) || !isalpha(grid6[1]) ||
|
||||
!isdigit(grid6[2]) || !isdigit(grid6[3])) {
|
||||
// not testing 4'th and 5'th chars because of this case: <PA0SKT/2> JO33 40
|
||||
// grid is only 4 chars even though this is a hashed callsign...
|
||||
// isalpha(grid6[4]) && isalpha(grid6[5]) ) ) {
|
||||
noprint=1;
|
||||
}
|
||||
|
||||
ihash=(n2-ntype-64)/128;
|
||||
if( strncmp(hashtab+ihash*13,"\0",1) != 0 ) {
|
||||
sprintf(callsign,"<%s>",hashtab+ihash*13);
|
||||
} else {
|
||||
sprintf(callsign,"%5s","<...>");
|
||||
}
|
||||
|
||||
memset(call_loc_pow,0,sizeof(char)*23);
|
||||
sprintf(cdbm,"%2d",ndbm);
|
||||
strncat(call_loc_pow,callsign,strlen(callsign));
|
||||
strncat(call_loc_pow," ",1);
|
||||
strncat(call_loc_pow,grid6,strlen(grid6));
|
||||
strncat(call_loc_pow," ",1);
|
||||
strncat(call_loc_pow,cdbm,2);
|
||||
strncat(call_loc_pow,"\0",1);
|
||||
|
||||
|
||||
// I don't know what to do with these... They show up as "A000AA" grids.
|
||||
if( ntype == -64 ) noprint=1;
|
||||
}
|
||||
return noprint;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
Distributed under 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_END_IMPL_07172005_0828)
|
||||
#define FUSION_END_IMPL_07172005_0828
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct nil_;
|
||||
|
||||
struct cons_tag;
|
||||
|
||||
template <typename Car, typename Cdr>
|
||||
struct cons;
|
||||
|
||||
template <typename Cons>
|
||||
struct cons_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template <>
|
||||
struct end_impl<cons_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef cons_iterator<
|
||||
typename mpl::if_<is_const<Sequence>, nil_ const, nil_>::type>
|
||||
type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static type
|
||||
call(Sequence&)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,382 @@
|
||||
// Copyright John Maddock 2006.
|
||||
// Copyright Paul A. Bristow 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)
|
||||
|
||||
// TODO deal with infinity as special better - or remove.
|
||||
//
|
||||
|
||||
#ifndef BOOST_STATS_UNIFORM_HPP
|
||||
#define BOOST_STATS_UNIFORM_HPP
|
||||
|
||||
// http://www.itl.nist.gov/div898/handbook/eda/section3/eda3668.htm
|
||||
// http://mathworld.wolfram.com/UniformDistribution.html
|
||||
// http://documents.wolfram.com/calculationcenter/v2/Functions/ListsMatrices/Statistics/UniformDistribution.html
|
||||
// http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29
|
||||
|
||||
#include <boost/math/distributions/fwd.hpp>
|
||||
#include <boost/math/distributions/detail/common_error_handling.hpp>
|
||||
#include <boost/math/distributions/complement.hpp>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost{ namespace math
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_uniform_lower(
|
||||
const char* function,
|
||||
RealType lower,
|
||||
RealType* result, const Policy& pol)
|
||||
{
|
||||
if((boost::math::isfinite)(lower))
|
||||
{ // any finite value is OK.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // Not finite.
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Lower parameter is %1%, but must be finite!", lower, pol);
|
||||
return false;
|
||||
}
|
||||
} // bool check_uniform_lower(
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_uniform_upper(
|
||||
const char* function,
|
||||
RealType upper,
|
||||
RealType* result, const Policy& pol)
|
||||
{
|
||||
if((boost::math::isfinite)(upper))
|
||||
{ // Any finite value is OK.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // Not finite.
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Upper parameter is %1%, but must be finite!", upper, pol);
|
||||
return false;
|
||||
}
|
||||
} // bool check_uniform_upper(
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_uniform_x(
|
||||
const char* function,
|
||||
RealType const& x,
|
||||
RealType* result, const Policy& pol)
|
||||
{
|
||||
if((boost::math::isfinite)(x))
|
||||
{ // Any finite value is OK
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // Not finite..
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"x parameter is %1%, but must be finite!", x, pol);
|
||||
return false;
|
||||
}
|
||||
} // bool check_uniform_x
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_uniform(
|
||||
const char* function,
|
||||
RealType lower,
|
||||
RealType upper,
|
||||
RealType* result, const Policy& pol)
|
||||
{
|
||||
if((check_uniform_lower(function, lower, result, pol) == false)
|
||||
|| (check_uniform_upper(function, upper, result, pol) == false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (lower >= upper) // If lower == upper then 1 / (upper-lower) = 1/0 = +infinity!
|
||||
{ // upper and lower have been checked before, so must be lower >= upper.
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"lower parameter is %1%, but must be less than upper!", lower, pol);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{ // All OK,
|
||||
return true;
|
||||
}
|
||||
} // bool check_uniform(
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class RealType = double, class Policy = policies::policy<> >
|
||||
class uniform_distribution
|
||||
{
|
||||
public:
|
||||
typedef RealType value_type;
|
||||
typedef Policy policy_type;
|
||||
|
||||
uniform_distribution(RealType l_lower = 0, RealType l_upper = 1) // Constructor.
|
||||
: m_lower(l_lower), m_upper(l_upper) // Default is standard uniform distribution.
|
||||
{
|
||||
RealType result;
|
||||
detail::check_uniform("boost::math::uniform_distribution<%1%>::uniform_distribution", l_lower, l_upper, &result, Policy());
|
||||
}
|
||||
// Accessor functions.
|
||||
RealType lower()const
|
||||
{
|
||||
return m_lower;
|
||||
}
|
||||
|
||||
RealType upper()const
|
||||
{
|
||||
return m_upper;
|
||||
}
|
||||
private:
|
||||
// Data members:
|
||||
RealType m_lower; // distribution lower aka a.
|
||||
RealType m_upper; // distribution upper aka b.
|
||||
}; // class uniform_distribution
|
||||
|
||||
typedef uniform_distribution<double> uniform;
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const uniform_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
using boost::math::tools::max_value;
|
||||
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + 'infinity'.
|
||||
// Note RealType infinity is NOT permitted, only max_value.
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> support(const uniform_distribution<RealType, Policy>& dist)
|
||||
{ // Range of supported values for random variable x.
|
||||
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
|
||||
using boost::math::tools::max_value;
|
||||
return std::pair<RealType, RealType>(dist.lower(), dist.upper());
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType pdf(const uniform_distribution<RealType, Policy>& dist, const RealType& x)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::pdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(false == detail::check_uniform_x("boost::math::pdf(const uniform_distribution<%1%>&, %1%)", x, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if((x < lower) || (x > upper) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1 / (upper - lower);
|
||||
}
|
||||
} // RealType pdf(const uniform_distribution<RealType, Policy>& dist, const RealType& x)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const uniform_distribution<RealType, Policy>& dist, const RealType& x)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(false == detail::check_uniform_x("boost::math::cdf(const uniform_distribution<%1%>&, %1%)", x, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (x < lower)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x > upper)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return (x - lower) / (upper - lower); // lower <= x <= upper
|
||||
} // RealType cdf(const uniform_distribution<RealType, Policy>& dist, const RealType& x)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const uniform_distribution<RealType, Policy>& dist, const RealType& p)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks
|
||||
if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(false == detail::check_probability("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", p, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(p == 0)
|
||||
{
|
||||
return lower;
|
||||
}
|
||||
if(p == 1)
|
||||
{
|
||||
return upper;
|
||||
}
|
||||
return p * (upper - lower) + lower;
|
||||
} // RealType quantile(const uniform_distribution<RealType, Policy>& dist, const RealType& p)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const complemented2_type<uniform_distribution<RealType, Policy>, RealType>& c)
|
||||
{
|
||||
RealType lower = c.dist.lower();
|
||||
RealType upper = c.dist.upper();
|
||||
RealType x = c.param;
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(false == detail::check_uniform_x("boost::math::cdf(const uniform_distribution<%1%>&, %1%)", x, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (x < lower)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x > upper)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return (upper - x) / (upper - lower);
|
||||
} // RealType cdf(const complemented2_type<uniform_distribution<RealType, Policy>, RealType>& c)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const complemented2_type<uniform_distribution<RealType, Policy>, RealType>& c)
|
||||
{
|
||||
RealType lower = c.dist.lower();
|
||||
RealType upper = c.dist.upper();
|
||||
RealType q = c.param;
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(false == detail::check_probability("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", q, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(q == 0)
|
||||
{
|
||||
return upper;
|
||||
}
|
||||
if(q == 1)
|
||||
{
|
||||
return lower;
|
||||
}
|
||||
return -q * (upper - lower) + upper;
|
||||
} // RealType quantile(const complemented2_type<uniform_distribution<RealType, Policy>, RealType>& c)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mean(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::mean(const uniform_distribution<%1%>&)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return (lower + upper ) / 2;
|
||||
} // RealType mean(const uniform_distribution<RealType, Policy>& dist)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType variance(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::variance(const uniform_distribution<%1%>&)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return (upper - lower) * ( upper - lower) / 12;
|
||||
// for standard uniform = 0.833333333333333333333333333333333333333333;
|
||||
} // RealType variance(const uniform_distribution<RealType, Policy>& dist)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mode(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::mode(const uniform_distribution<%1%>&)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = lower; // Any value [lower, upper] but arbitrarily choose lower.
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType median(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::median(const uniform_distribution<%1%>&)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return (lower + upper) / 2; //
|
||||
}
|
||||
template <class RealType, class Policy>
|
||||
inline RealType skewness(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::skewness(const uniform_distribution<%1%>&)",lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
} // RealType skewness(const uniform_distribution<RealType, Policy>& dist)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis_excess(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType lower = dist.lower();
|
||||
RealType upper = dist.upper();
|
||||
RealType result = 0; // of checks.
|
||||
if(false == detail::check_uniform("boost::math::kurtosis_execess(const uniform_distribution<%1%>&)", lower, upper, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return static_cast<RealType>(-6)/5; // -6/5 = -1.2;
|
||||
} // RealType kurtosis_excess(const uniform_distribution<RealType, Policy>& dist)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis(const uniform_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
return kurtosis_excess(dist) + 3;
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
// This include must be at the end, *after* the accessors
|
||||
// for this distribution have been defined, in order to
|
||||
// keep compilers that support two-phase lookup happy.
|
||||
#include <boost/math/distributions/detail/derived_accessors.hpp>
|
||||
|
||||
#endif // BOOST_STATS_UNIFORM_HPP
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Distributed under 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)
|
||||
*
|
||||
* Copyright (c) 2014 Andrey Semashev
|
||||
*/
|
||||
/*!
|
||||
* \file atomic/detail/ops_cas_based.hpp
|
||||
*
|
||||
* This header contains CAS-based implementation of the \c operations template.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_
|
||||
#define BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_
|
||||
|
||||
#include <boost/memory_order.hpp>
|
||||
#include <boost/atomic/detail/config.hpp>
|
||||
#include <boost/atomic/detail/storage_type.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace atomics {
|
||||
namespace detail {
|
||||
|
||||
template< typename Base >
|
||||
struct cas_based_exchange :
|
||||
public Base
|
||||
{
|
||||
typedef typename Base::storage_type storage_type;
|
||||
|
||||
static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Base >
|
||||
struct cas_based_operations :
|
||||
public Base
|
||||
{
|
||||
typedef typename Base::storage_type storage_type;
|
||||
|
||||
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, old_val + v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, old_val - v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, old_val & v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, old_val | v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
storage_type old_val;
|
||||
atomics::detail::non_atomic_load(storage, old_val);
|
||||
while (!Base::compare_exchange_weak(storage, old_val, old_val ^ v, order, memory_order_relaxed)) {}
|
||||
return old_val;
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
return !!Base::exchange(storage, (storage_type)1, order);
|
||||
}
|
||||
|
||||
static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
|
||||
{
|
||||
Base::store(storage, (storage_type)0, order);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace atomics
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_
|
||||
@@ -0,0 +1,461 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2008
|
||||
//
|
||||
// Distributed under 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)
|
||||
//
|
||||
|
||||
// *Preprocessed* version of the main "apply_wrap.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
int N, typename F
|
||||
>
|
||||
struct apply_wrap_impl0;
|
||||
|
||||
template< typename F, bool F_has_apply >
|
||||
struct apply_wrap_impl0_bcb {
|
||||
typedef typename F::template apply<na> type;
|
||||
};
|
||||
|
||||
template< typename F >
|
||||
struct apply_wrap_impl0_bcb< F,true > {
|
||||
typedef typename F::apply type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
0
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef apply_wrap_impl0_bcb< F, aux::has_apply<F>::value >::type type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
1
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
|
||||
na
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
2
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
|
||||
na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
3
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
|
||||
na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
4
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
|
||||
na, na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap_impl0<
|
||||
5
|
||||
, F
|
||||
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
|
||||
na, na, na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct apply_wrap0
|
||||
: apply_wrap_impl0<
|
||||
::boost::mpl::aux::arity< F,0 >::value
|
||||
, F
|
||||
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
int N, typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1;
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1<
|
||||
1
|
||||
, F
|
||||
, T1
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1<
|
||||
2
|
||||
, F
|
||||
, T1
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1
|
||||
, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1<
|
||||
3
|
||||
, F
|
||||
, T1
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1
|
||||
, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1<
|
||||
4
|
||||
, F
|
||||
, T1
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1
|
||||
, na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap_impl1<
|
||||
5
|
||||
, F
|
||||
, T1
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1
|
||||
, na, na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct apply_wrap1
|
||||
: apply_wrap_impl1<
|
||||
::boost::mpl::aux::arity< F,1 >::value
|
||||
, F
|
||||
, T1
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
int N, typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap_impl2;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap_impl2<
|
||||
2
|
||||
, F
|
||||
, T1, T2
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap_impl2<
|
||||
3
|
||||
, F
|
||||
, T1, T2
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2
|
||||
|
||||
, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap_impl2<
|
||||
4
|
||||
, F
|
||||
, T1, T2
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2
|
||||
|
||||
, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap_impl2<
|
||||
5
|
||||
, F
|
||||
, T1, T2
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2
|
||||
|
||||
, na, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct apply_wrap2
|
||||
: apply_wrap_impl2<
|
||||
::boost::mpl::aux::arity< F,2 >::value
|
||||
, F
|
||||
, T1, T2
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
int N, typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct apply_wrap_impl3;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct apply_wrap_impl3<
|
||||
3
|
||||
, F
|
||||
, T1, T2, T3
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct apply_wrap_impl3<
|
||||
4
|
||||
, F
|
||||
, T1, T2, T3
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3
|
||||
|
||||
, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct apply_wrap_impl3<
|
||||
5
|
||||
, F
|
||||
, T1, T2, T3
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3
|
||||
|
||||
, na, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct apply_wrap3
|
||||
: apply_wrap_impl3<
|
||||
::boost::mpl::aux::arity< F,3 >::value
|
||||
, F
|
||||
, T1, T2, T3
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
int N, typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct apply_wrap_impl4;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct apply_wrap_impl4<
|
||||
4
|
||||
, F
|
||||
, T1, T2, T3, T4
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3, T4
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct apply_wrap_impl4<
|
||||
5
|
||||
, F
|
||||
, T1, T2, T3, T4
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3, T4
|
||||
|
||||
, na
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct apply_wrap4
|
||||
: apply_wrap_impl4<
|
||||
::boost::mpl::aux::arity< F,4 >::value
|
||||
, F
|
||||
, T1, T2, T3, T4
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
int N, typename F, typename T1, typename T2, typename T3, typename T4
|
||||
, typename T5
|
||||
>
|
||||
struct apply_wrap_impl5;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
, typename T5
|
||||
>
|
||||
struct apply_wrap_impl5<
|
||||
5
|
||||
, F
|
||||
, T1, T2, T3, T4, T5
|
||||
>
|
||||
{
|
||||
typedef typename F::template apply<
|
||||
T1, T2, T3, T4, T5
|
||||
|
||||
> type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
, typename T5
|
||||
>
|
||||
struct apply_wrap5
|
||||
: apply_wrap_impl5<
|
||||
::boost::mpl::aux::arity< F,5 >::value
|
||||
, F
|
||||
, T1, T2, T3, T4, T5
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// 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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
|
||||
#define BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
//
|
||||
// We can't filter out rvalue_references at the same level as
|
||||
// references or we get ambiguities from msvc:
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
struct add_reference_impl
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
struct add_reference_impl<T&&>
|
||||
{
|
||||
typedef T&& type;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T> struct add_reference
|
||||
{
|
||||
typedef typename boost::detail::add_reference_impl<T>::type type;
|
||||
};
|
||||
template <class T> struct add_reference<T&>
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
// these full specialisations are always required:
|
||||
template <> struct add_reference<void> { typedef void type; };
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <> struct add_reference<const void> { typedef const void type; };
|
||||
template <> struct add_reference<const volatile void> { typedef const volatile void type; };
|
||||
template <> struct add_reference<volatile void> { typedef volatile void type; };
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
|
||||
@@ -0,0 +1,18 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file extends_funop.hpp
|
||||
/// Definitions for extends\<\>::operator()
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under 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)
|
||||
template<typename Sig> struct result { typedef typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop< Sig , proto_derived_expr , proto_domain >::type ) >::type const type; };
|
||||
BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop0< proto_derived_expr const , proto_domain >::type ) >::type const operator ()() const { typedef boost::proto::result_of::funop0< proto_derived_expr const , proto_domain > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) ) ); } BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop0< proto_derived_expr , proto_domain >::type ) >::type const operator ()() { typedef boost::proto::result_of::funop0< proto_derived_expr , proto_domain > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) ) ); }
|
||||
template<typename A0> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop1< proto_derived_expr const , proto_domain , const A0 >::type ) >::type const operator ()(A0 const &a0) const { typedef boost::proto::result_of::funop1< proto_derived_expr const , proto_domain , const A0 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 ) ); } template<typename A0> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop1< proto_derived_expr , proto_domain , const A0 >::type ) >::type const operator ()(A0 const &a0) { typedef boost::proto::result_of::funop1< proto_derived_expr , proto_domain , const A0 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 ) ); }
|
||||
template<typename A0 , typename A1> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop2< proto_derived_expr const , proto_domain , const A0 , const A1 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1) const { typedef boost::proto::result_of::funop2< proto_derived_expr const , proto_domain , const A0 , const A1 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 ) ); } template<typename A0 , typename A1> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop2< proto_derived_expr , proto_domain , const A0 , const A1 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1) { typedef boost::proto::result_of::funop2< proto_derived_expr , proto_domain , const A0 , const A1 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop3< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2) const { typedef boost::proto::result_of::funop3< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 ) ); } template<typename A0 , typename A1 , typename A2> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop3< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2) { typedef boost::proto::result_of::funop3< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop4< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3) const { typedef boost::proto::result_of::funop4< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop4< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3) { typedef boost::proto::result_of::funop4< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop5< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4) const { typedef boost::proto::result_of::funop5< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 , a4 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop5< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4) { typedef boost::proto::result_of::funop5< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 , a4 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop6< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5) const { typedef boost::proto::result_of::funop6< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 , a4 , a5 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop6< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5) { typedef boost::proto::result_of::funop6< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 , a4 , a5 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop7< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6) const { typedef boost::proto::result_of::funop7< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop7< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6) { typedef boost::proto::result_of::funop7< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop8< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6 , A7 const &a7) const { typedef boost::proto::result_of::funop8< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop8< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6 , A7 const &a7) { typedef boost::proto::result_of::funop8< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 ) ); }
|
||||
template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop9< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6 , A7 const &a7 , A8 const &a8) const { typedef boost::proto::result_of::funop9< proto_derived_expr const , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr const *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 ) ); } template<typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> BOOST_FORCEINLINE typename BOOST_PROTO_RESULT_OF< proto_generator( typename boost::proto::result_of::funop9< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 >::type ) >::type const operator ()(A0 const &a0 , A1 const &a1 , A2 const &a2 , A3 const &a3 , A4 const &a4 , A5 const &a5 , A6 const &a6 , A7 const &a7 , A8 const &a8) { typedef boost::proto::result_of::funop9< proto_derived_expr , proto_domain , const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 > funop; return proto_generator()( funop::call( *static_cast<proto_derived_expr *>(this) , a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 ) ); }
|
||||
@@ -0,0 +1,126 @@
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// 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)
|
||||
//
|
||||
// This file is machine generated, do not edit by hand
|
||||
|
||||
// Polynomial evaluation using Horners rule
|
||||
#ifndef BOOST_MATH_TOOLS_POLY_RAT_9_HPP
|
||||
#define BOOST_MATH_TOOLS_POLY_RAT_9_HPP
|
||||
|
||||
namespace boost{ namespace math{ namespace tools{ namespace detail{
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(0);
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(a[0]) / static_cast<V>(b[0]);
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>((a[0] * z + a[1]) / (b[0] * z + b[1]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>(((a[0] * z + a[1]) * z + a[2]) / ((b[0] * z + b[1]) * z + b[2]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) / (((b[0] * z + b[1]) * z + b[2]) * z + b[3]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>(((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) * z + a[4]) / ((((b[0] * z + b[1]) * z + b[2]) * z + b[3]) * z + b[4]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>((((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) * z + a[4]) * z + a[5]) / (((((b[0] * z + b[1]) * z + b[2]) * z + b[3]) * z + b[4]) * z + b[5]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>(((((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) * z + a[4]) * z + a[5]) * z + a[6]) / ((((((b[0] * z + b[1]) * z + b[2]) * z + b[3]) * z + b[4]) * z + b[5]) * z + b[6]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>((((((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) * z + a[4]) * z + a[5]) * z + a[6]) * z + a[7]) / (((((((b[0] * z + b[1]) * z + b[2]) * z + b[3]) * z + b[4]) * z + b[5]) * z + b[6]) * z + b[7]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U, class V>
|
||||
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
if(x <= 1)
|
||||
return static_cast<V>(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0]));
|
||||
else
|
||||
{
|
||||
V z = 1 / x;
|
||||
return static_cast<V>(((((((((a[0] * z + a[1]) * z + a[2]) * z + a[3]) * z + a[4]) * z + a[5]) * z + a[6]) * z + a[7]) * z + a[8]) / ((((((((b[0] * z + b[1]) * z + b[2]) * z + b[3]) * z + b[4]) * z + b[5]) * z + b[6]) * z + b[7]) * z + b[8]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}}} // namespaces
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under 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 BY_VALUE_DWA20021015_HPP
|
||||
# define BY_VALUE_DWA20021015_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/to_python_value.hpp>
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
# include <boost/type_traits/add_const.hpp>
|
||||
|
||||
# include <boost/python/detail/value_arg.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
struct return_by_value
|
||||
{
|
||||
template <class R>
|
||||
struct apply
|
||||
{
|
||||
typedef to_python_value<
|
||||
typename detail::value_arg<R>::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // BY_VALUE_DWA20021015_HPP
|
||||
@@ -0,0 +1,331 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file make_expr.hpp
|
||||
/// Contains overloads of make_expr() free function.
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under 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)
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1
|
||||
>()(a0 , a1);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1
|
||||
>()(c0 , c1);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2
|
||||
>()(a0 , a1 , a2);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2
|
||||
>()(c0 , c1 , c2);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3
|
||||
>()(a0 , a1 , a2 , a3);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3
|
||||
>()(c0 , c1 , c2 , c3);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4
|
||||
>()(a0 , a1 , a2 , a3 , a4);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4
|
||||
>()(c0 , c1 , c2 , c3 , c4);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4 , const A5 &a5)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5
|
||||
>()(a0 , a1 , a2 , a3 , a4 , a5);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4 , typename C5>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4 , const C5 &c5)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5
|
||||
>()(c0 , c1 , c2 , c3 , c4 , c5);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4 , const A5 &a5 , const A6 &a6)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6
|
||||
>()(a0 , a1 , a2 , a3 , a4 , a5 , a6);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4 , typename C5 , typename C6>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4 , const C5 &c5 , const C6 &c6)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6
|
||||
>()(c0 , c1 , c2 , c3 , c4 , c5 , c6);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4 , const A5 &a5 , const A6 &a6 , const A7 &a7)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7
|
||||
>()(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4 , typename C5 , typename C6 , typename C7>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4 , const C5 &c5 , const C6 &c6 , const C7 &c7)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7
|
||||
>()(c0 , c1 , c2 , c3 , c4 , c5 , c6 , c7);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4 , const A5 &a5 , const A6 &a6 , const A7 &a7 , const A8 &a8)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8
|
||||
>()(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4 , typename C5 , typename C6 , typename C7 , typename C8>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7 , const C8
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4 , const C5 &c5 , const C6 &c6 , const C7 &c7 , const C8 &c8)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7 , const C8
|
||||
>()(c0 , c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9>
|
||||
BOOST_FORCEINLINE
|
||||
typename lazy_disable_if<
|
||||
is_domain<A0>
|
||||
, result_of::make_expr<
|
||||
Tag
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 , const A9
|
||||
>
|
||||
>::type const
|
||||
make_expr(const A0 &a0 , const A1 &a1 , const A2 &a2 , const A3 &a3 , const A4 &a4 , const A5 &a5 , const A6 &a6 , const A7 &a7 , const A8 &a8 , const A9 &a9)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, deduce_domain
|
||||
, const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 , const A9
|
||||
>()(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9);
|
||||
}
|
||||
|
||||
|
||||
template<typename Tag, typename Domain , typename C0 , typename C1 , typename C2 , typename C3 , typename C4 , typename C5 , typename C6 , typename C7 , typename C8 , typename C9>
|
||||
BOOST_FORCEINLINE
|
||||
typename result_of::make_expr<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7 , const C8 , const C9
|
||||
>::type const
|
||||
make_expr(const C0 &c0 , const C1 &c1 , const C2 &c2 , const C3 &c3 , const C4 &c4 , const C5 &c5 , const C6 &c6 , const C7 &c7 , const C8 &c8 , const C9 &c9)
|
||||
{
|
||||
return proto::detail::make_expr_<
|
||||
Tag
|
||||
, Domain
|
||||
, const C0 , const C1 , const C2 , const C3 , const C4 , const C5 , const C6 , const C7 , const C8 , const C9
|
||||
>()(c0 , c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8 , c9);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
This file is part of wsprd.
|
||||
|
||||
File name: fano.h
|
||||
|
||||
Description: Header file for sequential Fano decoder.
|
||||
|
||||
Copyright 1994, Phil Karn, KA9Q
|
||||
Minor modifications by Joe Taylor, K1JT
|
||||
*/
|
||||
|
||||
#ifndef FANO_H
|
||||
#define FANO_H
|
||||
|
||||
int fano(unsigned int *metric, unsigned int *cycles, unsigned int *maxnp,
|
||||
unsigned char *data,unsigned char *symbols, unsigned int nbits,
|
||||
int mettab[2][256],int delta,unsigned int maxcycles);
|
||||
|
||||
int encode(unsigned char *symbols,unsigned char *data,unsigned int nbytes);
|
||||
|
||||
extern unsigned char Partab[];
|
||||
|
||||
/* Convolutional encoder macro. Takes the encoder state, generates
|
||||
* a rate 1/2 symbol pair and stores it in 'sym'. The symbol generated from
|
||||
* POLY1 goes into the 2-bit of sym, and the symbol generated from POLY2
|
||||
* goes into the 1-bit.
|
||||
*/
|
||||
#define ENCODE(sym,encstate){\
|
||||
unsigned long _tmp;\
|
||||
\
|
||||
_tmp = (encstate) & POLY1;\
|
||||
_tmp ^= _tmp >> 16;\
|
||||
(sym) = Partab[(_tmp ^ (_tmp >> 8)) & 0xff] << 1;\
|
||||
_tmp = (encstate) & POLY2;\
|
||||
_tmp ^= _tmp >> 16;\
|
||||
(sym) |= Partab[(_tmp ^ (_tmp >> 8)) & 0xff];\
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file static_const.hpp
|
||||
/// Contains definition of static_const for declaring static constants that
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under 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_PROTO_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012
|
||||
#define BOOST_PROTO_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012
|
||||
|
||||
namespace boost { namespace proto
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename T>
|
||||
struct static_const
|
||||
{
|
||||
static T const value;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
T const static_const<T>::value = {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright David Abrahams 2004. Distributed under 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 WRAPPER_DWA2004720_HPP
|
||||
# define WRAPPER_DWA2004720_HPP
|
||||
|
||||
# include <boost/python/detail/wrapper_base.hpp>
|
||||
# include <boost/python/override.hpp>
|
||||
# include <boost/python/converter/registered.hpp>
|
||||
# include <boost/python/detail/sfinae.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <class T>
|
||||
class wrapper : public detail::wrapper_base
|
||||
{
|
||||
public:
|
||||
// Do not touch this implementation detail!
|
||||
typedef T _wrapper_wrapped_type_;
|
||||
|
||||
protected:
|
||||
override get_override(char const* name) const
|
||||
{
|
||||
typedef detail::wrapper_base base;
|
||||
converter::registration const& r
|
||||
= converter::registered<T>::converters;
|
||||
PyTypeObject* type = r.get_class_object();
|
||||
|
||||
return this->base::get_override(name, type);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // WRAPPER_DWA2004720_HPP
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright Vladimir Prus 2004.
|
||||
// Distributed under 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_CONVERT_HPP_VP_2004_04_28
|
||||
#define BOOST_CONVERT_HPP_VP_2004_04_28
|
||||
|
||||
#include <boost/program_options/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <locale>
|
||||
// for mbstate_t
|
||||
#include <cwchar>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
#include <wchar.h>
|
||||
namespace std
|
||||
{
|
||||
using ::mbstate_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
/** Converts from local 8 bit encoding into wchar_t string using
|
||||
the specified locale facet. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::wstring
|
||||
from_8_bit(const std::string& s,
|
||||
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt);
|
||||
|
||||
/** Converts from wchar_t string into local 8 bit encoding into using
|
||||
the specified locale facet. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string
|
||||
to_8_bit(const std::wstring& s,
|
||||
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt);
|
||||
|
||||
|
||||
/** Converts 's', which is assumed to be in UTF8 encoding, into wide
|
||||
string. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::wstring
|
||||
from_utf8(const std::string& s);
|
||||
|
||||
/** Converts wide string 's' into string in UTF8 encoding. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string
|
||||
to_utf8(const std::wstring& s);
|
||||
|
||||
/** Converts wide string 's' into local 8 bit encoding determined by
|
||||
the current locale. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string
|
||||
to_local_8_bit(const std::wstring& s);
|
||||
|
||||
/** Converts 's', which is assumed to be in local 8 bit encoding, into wide
|
||||
string. */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::wstring
|
||||
from_local_8_bit(const std::string& s);
|
||||
|
||||
namespace program_options
|
||||
{
|
||||
/** Convert the input string into internal encoding used by
|
||||
program_options. Presence of this function allows to avoid
|
||||
specializing all methods which access input on wchar_t.
|
||||
*/
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&);
|
||||
/** @overload */
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::wstring&);
|
||||
|
||||
template<class T>
|
||||
std::vector<std::string> to_internal(const std::vector<T>& s)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
for (unsigned i = 0; i < s.size(); ++i)
|
||||
result.push_back(to_internal(s[i]));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
#include <vector>
|
||||
#include <string>
|
||||
namespace boost{
|
||||
namespace program_options{
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&);
|
||||
|
||||
template<class T>
|
||||
std::vector<std::string> to_internal(const std::vector<T>& s)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
for (unsigned i = 0; i < s.size(); ++i)
|
||||
result.push_back(to_internal(s[i]));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,281 @@
|
||||
#include "ClientWidget.hpp"
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QColor>
|
||||
|
||||
namespace
|
||||
{
|
||||
//QRegExp message_alphabet {"[- A-Za-z0-9+./?]*"};
|
||||
QRegExp message_alphabet {"[- @A-Za-z0-9+./?#<>]*"};
|
||||
QRegularExpression cq_re {"(CQ|CQDX|QRZ)[^A-Z0-9/]+"};
|
||||
|
||||
void update_dynamic_property (QWidget * widget, char const * property, QVariant const& value)
|
||||
{
|
||||
widget->setProperty (property, value);
|
||||
widget->style ()->unpolish (widget);
|
||||
widget->style ()->polish (widget);
|
||||
widget->update ();
|
||||
}
|
||||
}
|
||||
|
||||
ClientWidget::IdFilterModel::IdFilterModel (QString const& client_id)
|
||||
: client_id_ {client_id}
|
||||
, rx_df_ (-1)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ClientWidget::IdFilterModel::data (QModelIndex const& proxy_index, int role) const
|
||||
{
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
switch (proxy_index.column ())
|
||||
{
|
||||
case 8: // message
|
||||
{
|
||||
auto message = QSortFilterProxyModel::data (proxy_index).toString ();
|
||||
if (base_call_re_.pattern ().size ()
|
||||
&& message.contains (base_call_re_))
|
||||
{
|
||||
return QColor {255,200,200};
|
||||
}
|
||||
if (message.contains (cq_re))
|
||||
{
|
||||
return QColor {200, 255, 200};
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: // DF
|
||||
if (qAbs (QSortFilterProxyModel::data (proxy_index).toInt () - rx_df_) <= 10)
|
||||
{
|
||||
return QColor {255, 200, 200};
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QSortFilterProxyModel::data (proxy_index, role);
|
||||
}
|
||||
|
||||
bool ClientWidget::IdFilterModel::filterAcceptsRow (int source_row
|
||||
, QModelIndex const& source_parent) const
|
||||
{
|
||||
auto source_index_col0 = sourceModel ()->index (source_row, 0, source_parent);
|
||||
return sourceModel ()->data (source_index_col0).toString () == client_id_;
|
||||
}
|
||||
|
||||
void ClientWidget::IdFilterModel::de_call (QString const& call)
|
||||
{
|
||||
if (call != call_)
|
||||
{
|
||||
beginResetModel ();
|
||||
if (call.size ())
|
||||
{
|
||||
base_call_re_.setPattern ("[^A-Z0-9]*" + Radio::base_callsign (call) + "[^A-Z0-9]*");
|
||||
}
|
||||
else
|
||||
{
|
||||
base_call_re_.setPattern (QString {});
|
||||
}
|
||||
call_ = call;
|
||||
endResetModel ();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientWidget::IdFilterModel::rx_df (int df)
|
||||
{
|
||||
if (df != rx_df_)
|
||||
{
|
||||
beginResetModel ();
|
||||
rx_df_ = df;
|
||||
endResetModel ();
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
QString make_title (QString const& id, QString const& version, QString const& revision)
|
||||
{
|
||||
QString title {id};
|
||||
if (version.size ())
|
||||
{
|
||||
title += QString {" v%1"}.arg (version);
|
||||
}
|
||||
if (revision.size ())
|
||||
{
|
||||
title += QString {" (%1)"}.arg (revision);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemModel * beacons_model
|
||||
, QString const& id, QString const& version, QString const& revision
|
||||
, QWidget * parent)
|
||||
: QDockWidget {make_title (id, version, revision), parent}
|
||||
, id_ {id}
|
||||
, decodes_proxy_model_ {id_}
|
||||
, decodes_table_view_ {new QTableView}
|
||||
, beacons_table_view_ {new QTableView}
|
||||
, message_line_edit_ {new QLineEdit}
|
||||
, decodes_stack_ {new QStackedLayout}
|
||||
, auto_off_button_ {new QPushButton {tr ("&Auto Off")}}
|
||||
, halt_tx_button_ {new QPushButton {tr ("&Halt Tx")}}
|
||||
, mode_label_ {new QLabel}
|
||||
, fast_mode_ {false}
|
||||
, frequency_label_ {new QLabel}
|
||||
, dx_label_ {new QLabel}
|
||||
, rx_df_label_ {new QLabel}
|
||||
, tx_df_label_ {new QLabel}
|
||||
, report_label_ {new QLabel}
|
||||
, columns_resized_ {false}
|
||||
{
|
||||
// set up widgets
|
||||
decodes_proxy_model_.setSourceModel (decodes_model);
|
||||
decodes_table_view_->setModel (&decodes_proxy_model_);
|
||||
decodes_table_view_->verticalHeader ()->hide ();
|
||||
decodes_table_view_->hideColumn (0);
|
||||
decodes_table_view_->horizontalHeader ()->setStretchLastSection (true);
|
||||
|
||||
auto form_layout = new QFormLayout;
|
||||
form_layout->addRow (tr ("Free text:"), message_line_edit_);
|
||||
message_line_edit_->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||
connect (message_line_edit_, &QLineEdit::textEdited, [this] (QString const& text) {
|
||||
Q_EMIT do_free_text (id_, text, false);
|
||||
});
|
||||
connect (message_line_edit_, &QLineEdit::editingFinished, [this] () {
|
||||
Q_EMIT do_free_text (id_, message_line_edit_->text (), true);
|
||||
});
|
||||
|
||||
auto decodes_page = new QWidget;
|
||||
auto decodes_layout = new QVBoxLayout {decodes_page};
|
||||
decodes_layout->setContentsMargins (QMargins {2, 2, 2, 2});
|
||||
decodes_layout->addWidget (decodes_table_view_);
|
||||
decodes_layout->addLayout (form_layout);
|
||||
|
||||
auto beacons_proxy_model = new IdFilterModel {id_};
|
||||
beacons_proxy_model->setSourceModel (beacons_model);
|
||||
beacons_table_view_->setModel (beacons_proxy_model);
|
||||
beacons_table_view_->verticalHeader ()->hide ();
|
||||
beacons_table_view_->hideColumn (0);
|
||||
beacons_table_view_->horizontalHeader ()->setStretchLastSection (true);
|
||||
|
||||
auto beacons_page = new QWidget;
|
||||
auto beacons_layout = new QVBoxLayout {beacons_page};
|
||||
beacons_layout->setContentsMargins (QMargins {2, 2, 2, 2});
|
||||
beacons_layout->addWidget (beacons_table_view_);
|
||||
|
||||
decodes_stack_->addWidget (decodes_page);
|
||||
decodes_stack_->addWidget (beacons_page);
|
||||
|
||||
// stack alternative views
|
||||
auto content_layout = new QVBoxLayout;
|
||||
content_layout->setContentsMargins (QMargins {2, 2, 2, 2});
|
||||
content_layout->addLayout (decodes_stack_);
|
||||
|
||||
// set up controls
|
||||
auto control_button_box = new QDialogButtonBox;
|
||||
control_button_box->addButton (auto_off_button_, QDialogButtonBox::ActionRole);
|
||||
control_button_box->addButton (halt_tx_button_, QDialogButtonBox::ActionRole);
|
||||
connect (auto_off_button_, &QAbstractButton::clicked, [this] (bool /* checked */) {
|
||||
Q_EMIT do_halt_tx (id_, true);
|
||||
});
|
||||
connect (halt_tx_button_, &QAbstractButton::clicked, [this] (bool /* checked */) {
|
||||
Q_EMIT do_halt_tx (id_, false);
|
||||
});
|
||||
content_layout->addWidget (control_button_box);
|
||||
|
||||
// set up status area
|
||||
auto status_bar = new QStatusBar;
|
||||
status_bar->addPermanentWidget (mode_label_);
|
||||
status_bar->addPermanentWidget (frequency_label_);
|
||||
status_bar->addPermanentWidget (dx_label_);
|
||||
status_bar->addPermanentWidget (rx_df_label_);
|
||||
status_bar->addPermanentWidget (tx_df_label_);
|
||||
status_bar->addPermanentWidget (report_label_);
|
||||
content_layout->addWidget (status_bar);
|
||||
connect (this, &ClientWidget::topLevelChanged, status_bar, &QStatusBar::setSizeGripEnabled);
|
||||
|
||||
// set up central widget
|
||||
auto content_widget = new QFrame;
|
||||
content_widget->setFrameStyle (QFrame::StyledPanel | QFrame::Sunken);
|
||||
content_widget->setLayout (content_layout);
|
||||
setWidget (content_widget);
|
||||
// setMinimumSize (QSize {550, 0});
|
||||
setFeatures (DockWidgetMovable | DockWidgetFloatable);
|
||||
setAllowedAreas (Qt::BottomDockWidgetArea);
|
||||
|
||||
// connect up table view signals
|
||||
connect (decodes_table_view_, &QTableView::doubleClicked, this, [this] (QModelIndex const& index) {
|
||||
Q_EMIT do_reply (decodes_proxy_model_.mapToSource (index), QApplication::keyboardModifiers () >> 24);
|
||||
});
|
||||
}
|
||||
|
||||
void ClientWidget::update_status (QString const& id, Frequency f, QString const& mode, QString const& dx_call
|
||||
, QString const& report, QString const& tx_mode, bool tx_enabled
|
||||
, bool transmitting, bool decoding, qint32 rx_df, qint32 tx_df
|
||||
, QString const& de_call, QString const& /*de_grid*/, QString const& dx_grid
|
||||
, bool watchdog_timeout, QString const& sub_mode, bool fast_mode)
|
||||
{
|
||||
if (id == id_)
|
||||
{
|
||||
fast_mode_ = fast_mode;
|
||||
decodes_proxy_model_.de_call (de_call);
|
||||
decodes_proxy_model_.rx_df (rx_df);
|
||||
mode_label_->setText (QString {"Mode: %1%2%3%4"}
|
||||
.arg (mode)
|
||||
.arg (sub_mode)
|
||||
.arg (fast_mode && !mode.contains (QRegularExpression {R"(ISCAT|MSK144)"}) ? "fast" : "")
|
||||
.arg (tx_mode.isEmpty () || tx_mode == mode ? "" : '(' + tx_mode + ')'));
|
||||
frequency_label_->setText ("QRG: " + Radio::pretty_frequency_MHz_string (f));
|
||||
dx_label_->setText (dx_call.size () >= 0 ? QString {"DX: %1%2"}.arg (dx_call)
|
||||
.arg (dx_grid.size () ? '(' + dx_grid + ')' : QString {}) : QString {});
|
||||
rx_df_label_->setText (rx_df >= 0 ? QString {"Rx: %1"}.arg (rx_df) : "");
|
||||
tx_df_label_->setText (tx_df >= 0 ? QString {"Tx: %1"}.arg (tx_df) : "");
|
||||
report_label_->setText ("SNR: " + report);
|
||||
update_dynamic_property (frequency_label_, "transmitting", transmitting);
|
||||
auto_off_button_->setEnabled (tx_enabled);
|
||||
halt_tx_button_->setEnabled (transmitting);
|
||||
update_dynamic_property (mode_label_, "decoding", decoding);
|
||||
update_dynamic_property (tx_df_label_, "watchdog_timeout", watchdog_timeout);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientWidget::decode_added (bool /*is_new*/, QString const& client_id, QTime /*time*/, qint32 /*snr*/
|
||||
, float /*delta_time*/, quint32 /*delta_frequency*/, QString const& /*mode*/
|
||||
, QString const& /*message*/, bool /*low_confidence*/, bool /*off_air*/)
|
||||
{
|
||||
if (client_id == id_ && !columns_resized_)
|
||||
{
|
||||
decodes_stack_->setCurrentIndex (0);
|
||||
decodes_table_view_->resizeColumnsToContents ();
|
||||
columns_resized_ = true;
|
||||
}
|
||||
decodes_table_view_->scrollToBottom ();
|
||||
}
|
||||
|
||||
void ClientWidget::beacon_spot_added (bool /*is_new*/, QString const& client_id, QTime /*time*/, qint32 /*snr*/
|
||||
, float /*delta_time*/, Frequency /*delta_frequency*/, qint32 /*drift*/
|
||||
, QString const& /*callsign*/, QString const& /*grid*/, qint32 /*power*/
|
||||
, bool /*off_air*/)
|
||||
{
|
||||
if (client_id == id_ && !columns_resized_)
|
||||
{
|
||||
decodes_stack_->setCurrentIndex (1);
|
||||
beacons_table_view_->resizeColumnsToContents ();
|
||||
columns_resized_ = true;
|
||||
}
|
||||
beacons_table_view_->scrollToBottom ();
|
||||
}
|
||||
|
||||
void ClientWidget::clear_decodes (QString const& client_id)
|
||||
{
|
||||
if (client_id == id_)
|
||||
{
|
||||
columns_resized_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_ClientWidget.cpp"
|
||||
@@ -0,0 +1,12 @@
|
||||
// Boost.Function library
|
||||
|
||||
// Copyright Douglas Gregor 2002-2003. Use, modification and
|
||||
// distribution is 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)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#define BOOST_FUNCTION_NUM_ARGS 2
|
||||
#include <boost/function/detail/maybe_include.hpp>
|
||||
#undef BOOST_FUNCTION_NUM_ARGS
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2006
|
||||
//
|
||||
// Distributed under 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/config/compiler.hpp>
|
||||
#include <boost/mpl/aux_/config/preprocessor.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
|
||||
#if !defined(BOOST_NEEDS_TOKEN_PASTING_OP_FOR_TOKENS_JUXTAPOSING)
|
||||
# define AUX778076_PREPROCESSED_HEADER \
|
||||
BOOST_MPL_CFG_COMPILER_DIR/BOOST_MPL_PREPROCESSED_HEADER \
|
||||
/**/
|
||||
#else
|
||||
# define AUX778076_PREPROCESSED_HEADER \
|
||||
BOOST_PP_CAT(BOOST_MPL_CFG_COMPILER_DIR,/)##BOOST_MPL_PREPROCESSED_HEADER \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(700))
|
||||
# define AUX778076_INCLUDE_STRING BOOST_PP_STRINGIZE(boost/mpl/aux_/preprocessed/AUX778076_PREPROCESSED_HEADER)
|
||||
# include AUX778076_INCLUDE_STRING
|
||||
# undef AUX778076_INCLUDE_STRING
|
||||
#else
|
||||
# include BOOST_PP_STRINGIZE(boost/mpl/aux_/preprocessed/AUX778076_PREPROCESSED_HEADER)
|
||||
#endif
|
||||
|
||||
# undef AUX778076_PREPROCESSED_HEADER
|
||||
|
||||
#undef BOOST_MPL_PREPROCESSED_HEADER
|
||||
@@ -0,0 +1,110 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Jaap Suter 2003
|
||||
//
|
||||
// Distributed under 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)
|
||||
//
|
||||
|
||||
// Preprocessed version of "boost/mpl/shift_left.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Tag1
|
||||
, typename Tag2
|
||||
>
|
||||
struct shift_left_impl
|
||||
: if_c<
|
||||
( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
|
||||
> BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
|
||||
)
|
||||
|
||||
, aux::cast2nd_impl< shift_left_impl< Tag1,Tag1 >,Tag1, Tag2 >
|
||||
, aux::cast1st_impl< shift_left_impl< Tag2,Tag2 >,Tag1, Tag2 >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
/// for Digital Mars C++/compilers with no CTPS/TTP support
|
||||
template<> struct shift_left_impl< na,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct shift_left_impl< na,Tag >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct shift_left_impl< Tag,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct shift_left_tag
|
||||
{
|
||||
typedef typename T::tag type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(N1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N2)
|
||||
>
|
||||
struct shift_left
|
||||
|
||||
: shift_left_impl<
|
||||
typename shift_left_tag<N1>::type
|
||||
, typename shift_left_tag<N2>::type
|
||||
>::template apply< N1,N2 >::type
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, shift_left, (N1, N2))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(2, 2, shift_left)
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
template< typename T, typename Shift, T n, Shift s >
|
||||
struct shift_left_wknd
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(T, value = (n << s));
|
||||
typedef integral_c< T,value > type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct shift_left_impl< integral_c_tag,integral_c_tag >
|
||||
{
|
||||
template< typename N, typename S > struct apply
|
||||
: aux::shift_left_wknd<
|
||||
typename N::value_type
|
||||
, typename S::value_type
|
||||
, N::value
|
||||
, S::value
|
||||
>::type
|
||||
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,617 @@
|
||||
// Copyright (c) 2013 Christopher Kormanyos
|
||||
// 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)
|
||||
//
|
||||
// This work is based on an earlier work:
|
||||
// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
|
||||
// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
|
||||
//
|
||||
// This header contains implementation details for estimating the zeros
|
||||
// of cylindrical Bessel and Neumann functions on the positive real axis.
|
||||
// Support is included for both positive as well as negative order.
|
||||
// Various methods are used to estimate the roots. These include
|
||||
// empirical curve fitting and McMahon's asymptotic approximation
|
||||
// for small order, uniform asymptotic expansion for large order,
|
||||
// and iteration and root interlacing for negative order.
|
||||
//
|
||||
#ifndef _BESSEL_JY_ZERO_2013_01_18_HPP_
|
||||
#define _BESSEL_JY_ZERO_2013_01_18_HPP_
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/cbrt.hpp>
|
||||
#include <boost/math/special_functions/detail/airy_ai_bi_zero.hpp>
|
||||
|
||||
namespace boost { namespace math {
|
||||
namespace detail
|
||||
{
|
||||
namespace bessel_zero
|
||||
{
|
||||
template<class T>
|
||||
T equation_nist_10_21_19(const T& v, const T& a)
|
||||
{
|
||||
// Get the initial estimate of the m'th root of Jv or Yv.
|
||||
// This subroutine is used for the order m with m > 1.
|
||||
// The order m has been used to create the input parameter a.
|
||||
|
||||
// This is Eq. 10.21.19 in the NIST Handbook.
|
||||
const T mu = (v * v) * 4U;
|
||||
const T mu_minus_one = mu - T(1);
|
||||
const T eight_a_inv = T(1) / (a * 8U);
|
||||
const T eight_a_inv_squared = eight_a_inv * eight_a_inv;
|
||||
|
||||
const T term3 = ((mu_minus_one * 4U) * ((mu * 7U) - T(31U) )) / 3U;
|
||||
const T term5 = ((mu_minus_one * 32U) * ((((mu * 83U) - T(982U) ) * mu) + T(3779U) )) / 15U;
|
||||
const T term7 = ((mu_minus_one * 64U) * ((((((mu * 6949U) - T(153855UL)) * mu) + T(1585743UL)) * mu) - T(6277237UL))) / 105U;
|
||||
|
||||
return a + (((( - term7
|
||||
* eight_a_inv_squared - term5)
|
||||
* eight_a_inv_squared - term3)
|
||||
* eight_a_inv_squared - mu_minus_one)
|
||||
* eight_a_inv);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class equation_as_9_3_39_and_its_derivative
|
||||
{
|
||||
public:
|
||||
equation_as_9_3_39_and_its_derivative(const T& zt) : zeta(zt) { }
|
||||
|
||||
boost::math::tuple<T, T> operator()(const T& z) const
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for acos, sqrt.
|
||||
|
||||
// Return the function of zeta that is implicitly defined
|
||||
// in A&S Eq. 9.3.39 as a function of z. The function is
|
||||
// returned along with its derivative with respect to z.
|
||||
|
||||
const T zsq_minus_one_sqrt = sqrt((z * z) - T(1));
|
||||
|
||||
const T the_function(
|
||||
zsq_minus_one_sqrt
|
||||
- ( acos(T(1) / z) + ((T(2) / 3U) * (zeta * sqrt(zeta)))));
|
||||
|
||||
const T its_derivative(zsq_minus_one_sqrt / z);
|
||||
|
||||
return boost::math::tuple<T, T>(the_function, its_derivative);
|
||||
}
|
||||
|
||||
private:
|
||||
const equation_as_9_3_39_and_its_derivative& operator=(const equation_as_9_3_39_and_its_derivative&);
|
||||
const T zeta;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static T equation_as_9_5_26(const T& v, const T& ai_bi_root)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for log, sqrt.
|
||||
|
||||
// Obtain the estimate of the m'th zero of Jv or Yv.
|
||||
// The order m has been used to create the input parameter ai_bi_root.
|
||||
// Here, v is larger than about 2.2. The estimate is computed
|
||||
// from Abramowitz and Stegun Eqs. 9.5.22 and 9.5.26, page 371.
|
||||
//
|
||||
// The inversion of z as a function of zeta is mentioned in the text
|
||||
// following A&S Eq. 9.5.26. Here, we accomplish the inversion by
|
||||
// performing a Taylor expansion of Eq. 9.3.39 for large z to order 2
|
||||
// and solving the resulting quadratic equation, thereby taking
|
||||
// the positive root of the quadratic.
|
||||
// In other words: (2/3)(-zeta)^(3/2) approx = z + 1/(2z) - pi/2.
|
||||
// This leads to: z^2 - [(2/3)(-zeta)^(3/2) + pi/2]z + 1/2 = 0.
|
||||
//
|
||||
// With this initial estimate, Newton-Raphson iteration is used
|
||||
// to refine the value of the estimate of the root of z
|
||||
// as a function of zeta.
|
||||
|
||||
const T v_pow_third(boost::math::cbrt(v));
|
||||
const T v_pow_minus_two_thirds(T(1) / (v_pow_third * v_pow_third));
|
||||
|
||||
// Obtain zeta using the order v combined with the m'th root of
|
||||
// an airy function, as shown in A&S Eq. 9.5.22.
|
||||
const T zeta = v_pow_minus_two_thirds * (-ai_bi_root);
|
||||
|
||||
const T zeta_sqrt = sqrt(zeta);
|
||||
|
||||
// Set up a quadratic equation based on the Taylor series
|
||||
// expansion mentioned above.
|
||||
const T b = -((((zeta * zeta_sqrt) * 2U) / 3U) + boost::math::constants::half_pi<T>());
|
||||
|
||||
// Solve the quadratic equation, taking the positive root.
|
||||
const T z_estimate = (-b + sqrt((b * b) - T(2))) / 2U;
|
||||
|
||||
// Establish the range, the digits, and the iteration limit
|
||||
// for the upcoming root-finding.
|
||||
const T range_zmin = (std::max<T>)(z_estimate - T(1), T(1));
|
||||
const T range_zmax = z_estimate + T(1);
|
||||
|
||||
const int my_digits10 = static_cast<int>(static_cast<float>(boost::math::tools::digits<T>() * 0.301F));
|
||||
|
||||
// Select the maximum allowed iterations based on the number
|
||||
// of decimal digits in the numeric type T, being at least 12.
|
||||
const boost::uintmax_t iterations_allowed = static_cast<boost::uintmax_t>((std::max)(12, my_digits10 * 2));
|
||||
|
||||
boost::uintmax_t iterations_used = iterations_allowed;
|
||||
|
||||
// Calculate the root of z as a function of zeta.
|
||||
const T z = boost::math::tools::newton_raphson_iterate(
|
||||
boost::math::detail::bessel_zero::equation_as_9_3_39_and_its_derivative<T>(zeta),
|
||||
z_estimate,
|
||||
range_zmin,
|
||||
range_zmax,
|
||||
(std::min)(boost::math::tools::digits<T>(), boost::math::tools::digits<float>()),
|
||||
iterations_used);
|
||||
|
||||
static_cast<void>(iterations_used);
|
||||
|
||||
// Continue with the implementation of A&S Eq. 9.3.39.
|
||||
const T zsq_minus_one = (z * z) - T(1);
|
||||
const T zsq_minus_one_sqrt = sqrt(zsq_minus_one);
|
||||
|
||||
// This is A&S Eq. 9.3.42.
|
||||
const T b0_term_5_24 = T(5) / ((zsq_minus_one * zsq_minus_one_sqrt) * 24U);
|
||||
const T b0_term_1_8 = T(1) / ( zsq_minus_one_sqrt * 8U);
|
||||
const T b0_term_5_48 = T(5) / ((zeta * zeta) * 48U);
|
||||
|
||||
const T b0 = -b0_term_5_48 + ((b0_term_5_24 + b0_term_1_8) / zeta_sqrt);
|
||||
|
||||
// This is the second line of A&S Eq. 9.5.26 for f_k with k = 1.
|
||||
const T f1 = ((z * zeta_sqrt) * b0) / zsq_minus_one_sqrt;
|
||||
|
||||
// This is A&S Eq. 9.5.22 expanded to k = 1 (i.e., one term in the series).
|
||||
return (v * z) + (f1 / v);
|
||||
}
|
||||
|
||||
namespace cyl_bessel_j_zero_detail
|
||||
{
|
||||
template<class T>
|
||||
T equation_nist_10_21_40_a(const T& v)
|
||||
{
|
||||
const T v_pow_third(boost::math::cbrt(v));
|
||||
const T v_pow_minus_two_thirds(T(1) / (v_pow_third * v_pow_third));
|
||||
|
||||
return v * ((((( + T(0.043)
|
||||
* v_pow_minus_two_thirds - T(0.0908))
|
||||
* v_pow_minus_two_thirds - T(0.00397))
|
||||
* v_pow_minus_two_thirds + T(1.033150))
|
||||
* v_pow_minus_two_thirds + T(1.8557571))
|
||||
* v_pow_minus_two_thirds + T(1));
|
||||
}
|
||||
|
||||
template<class T, class Policy>
|
||||
class function_object_jv
|
||||
{
|
||||
public:
|
||||
function_object_jv(const T& v,
|
||||
const Policy& pol) : my_v(v),
|
||||
my_pol(pol) { }
|
||||
|
||||
T operator()(const T& x) const
|
||||
{
|
||||
return boost::math::cyl_bessel_j(my_v, x, my_pol);
|
||||
}
|
||||
|
||||
private:
|
||||
const T my_v;
|
||||
const Policy& my_pol;
|
||||
const function_object_jv& operator=(const function_object_jv&);
|
||||
};
|
||||
|
||||
template<class T, class Policy>
|
||||
class function_object_jv_and_jv_prime
|
||||
{
|
||||
public:
|
||||
function_object_jv_and_jv_prime(const T& v,
|
||||
const bool order_is_zero,
|
||||
const Policy& pol) : my_v(v),
|
||||
my_order_is_zero(order_is_zero),
|
||||
my_pol(pol) { }
|
||||
|
||||
boost::math::tuple<T, T> operator()(const T& x) const
|
||||
{
|
||||
// Obtain Jv(x) and Jv'(x).
|
||||
// Chris's original code called the Bessel function implementation layer direct,
|
||||
// but that circumvented optimizations for integer-orders. Call the documented
|
||||
// top level functions instead, and let them sort out which implementation to use.
|
||||
T j_v;
|
||||
T j_v_prime;
|
||||
|
||||
if(my_order_is_zero)
|
||||
{
|
||||
j_v = boost::math::cyl_bessel_j(0, x, my_pol);
|
||||
j_v_prime = -boost::math::cyl_bessel_j(1, x, my_pol);
|
||||
}
|
||||
else
|
||||
{
|
||||
j_v = boost::math::cyl_bessel_j( my_v, x, my_pol);
|
||||
const T j_v_m1 (boost::math::cyl_bessel_j(T(my_v - 1), x, my_pol));
|
||||
j_v_prime = j_v_m1 - ((my_v * j_v) / x);
|
||||
}
|
||||
|
||||
// Return a tuple containing both Jv(x) and Jv'(x).
|
||||
return boost::math::make_tuple(j_v, j_v_prime);
|
||||
}
|
||||
|
||||
private:
|
||||
const T my_v;
|
||||
const bool my_order_is_zero;
|
||||
const Policy& my_pol;
|
||||
const function_object_jv_and_jv_prime& operator=(const function_object_jv_and_jv_prime&);
|
||||
};
|
||||
|
||||
template<class T> bool my_bisection_unreachable_tolerance(const T&, const T&) { return false; }
|
||||
|
||||
template<class T, class Policy>
|
||||
T initial_guess(const T& v, const int m, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for floor.
|
||||
|
||||
// Compute an estimate of the m'th root of cyl_bessel_j.
|
||||
|
||||
T guess;
|
||||
|
||||
// There is special handling for negative order.
|
||||
if(v < 0)
|
||||
{
|
||||
if((m == 1) && (v > -0.5F))
|
||||
{
|
||||
// For small, negative v, use the results of empirical curve fitting.
|
||||
// Mathematica(R) session for the coefficients:
|
||||
// Table[{n, BesselJZero[n, 1]}, {n, -(1/2), 0, 1/10}]
|
||||
// N[%, 20]
|
||||
// Fit[%, {n^0, n^1, n^2, n^3, n^4, n^5, n^6}, n]
|
||||
guess = ((((( - T(0.2321156900729)
|
||||
* v - T(0.1493247777488))
|
||||
* v - T(0.15205419167239))
|
||||
* v + T(0.07814930561249))
|
||||
* v - T(0.17757573537688))
|
||||
* v + T(1.542805677045663))
|
||||
* v + T(2.40482555769577277);
|
||||
|
||||
return guess;
|
||||
}
|
||||
|
||||
// Create the positive order and extract its positive floor integer part.
|
||||
const T vv(-v);
|
||||
const T vv_floor(floor(vv));
|
||||
|
||||
// The to-be-found root is bracketed by the roots of the
|
||||
// Bessel function whose reflected, positive integer order
|
||||
// is less than, but nearest to vv.
|
||||
|
||||
T root_hi = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::initial_guess(vv_floor, m, pol);
|
||||
T root_lo;
|
||||
|
||||
if(m == 1)
|
||||
{
|
||||
// The estimate of the first root for negative order is found using
|
||||
// an adaptive range-searching algorithm.
|
||||
root_lo = T(root_hi - 0.1F);
|
||||
|
||||
const bool hi_end_of_bracket_is_negative = (boost::math::cyl_bessel_j(v, root_hi, pol) < 0);
|
||||
|
||||
while((root_lo > boost::math::tools::epsilon<T>()))
|
||||
{
|
||||
const bool lo_end_of_bracket_is_negative = (boost::math::cyl_bessel_j(v, root_lo, pol) < 0);
|
||||
|
||||
if(hi_end_of_bracket_is_negative != lo_end_of_bracket_is_negative)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
root_hi = root_lo;
|
||||
|
||||
// Decrease the lower end of the bracket using an adaptive algorithm.
|
||||
if(root_lo > 0.5F)
|
||||
{
|
||||
root_lo -= 0.5F;
|
||||
}
|
||||
else
|
||||
{
|
||||
root_lo *= 0.75F;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
root_lo = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::initial_guess(vv_floor, m - 1, pol);
|
||||
}
|
||||
|
||||
// Perform several steps of bisection iteration to refine the guess.
|
||||
boost::uintmax_t number_of_iterations(12U);
|
||||
|
||||
// Do the bisection iteration.
|
||||
const boost::math::tuple<T, T> guess_pair =
|
||||
boost::math::tools::bisect(
|
||||
boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::function_object_jv<T, Policy>(v, pol),
|
||||
root_lo,
|
||||
root_hi,
|
||||
boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::my_bisection_unreachable_tolerance<T>,
|
||||
number_of_iterations);
|
||||
|
||||
return (boost::math::get<0>(guess_pair) + boost::math::get<1>(guess_pair)) / 2U;
|
||||
}
|
||||
|
||||
if(m == 1U)
|
||||
{
|
||||
// Get the initial estimate of the first root.
|
||||
|
||||
if(v < 2.2F)
|
||||
{
|
||||
// For small v, use the results of empirical curve fitting.
|
||||
// Mathematica(R) session for the coefficients:
|
||||
// Table[{n, BesselJZero[n, 1]}, {n, 0, 22/10, 1/10}]
|
||||
// N[%, 20]
|
||||
// Fit[%, {n^0, n^1, n^2, n^3, n^4, n^5, n^6}, n]
|
||||
guess = ((((( - T(0.0008342379046010)
|
||||
* v + T(0.007590035637410))
|
||||
* v - T(0.030640914772013))
|
||||
* v + T(0.078232088020106))
|
||||
* v - T(0.169668712590620))
|
||||
* v + T(1.542187960073750))
|
||||
* v + T(2.4048359915254634);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For larger v, use the first line of Eqs. 10.21.40 in the NIST Handbook.
|
||||
guess = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::equation_nist_10_21_40_a(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(v < 2.2F)
|
||||
{
|
||||
// Use Eq. 10.21.19 in the NIST Handbook.
|
||||
const T a(((v + T(m * 2U)) - T(0.5)) * boost::math::constants::half_pi<T>());
|
||||
|
||||
guess = boost::math::detail::bessel_zero::equation_nist_10_21_19(v, a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get an estimate of the m'th root of airy_ai.
|
||||
const T airy_ai_root(boost::math::detail::airy_zero::airy_ai_zero_detail::initial_guess<T>(m));
|
||||
|
||||
// Use Eq. 9.5.26 in the A&S Handbook.
|
||||
guess = boost::math::detail::bessel_zero::equation_as_9_5_26(v, airy_ai_root);
|
||||
}
|
||||
}
|
||||
|
||||
return guess;
|
||||
}
|
||||
} // namespace cyl_bessel_j_zero_detail
|
||||
|
||||
namespace cyl_neumann_zero_detail
|
||||
{
|
||||
template<class T>
|
||||
T equation_nist_10_21_40_b(const T& v)
|
||||
{
|
||||
const T v_pow_third(boost::math::cbrt(v));
|
||||
const T v_pow_minus_two_thirds(T(1) / (v_pow_third * v_pow_third));
|
||||
|
||||
return v * ((((( - T(0.001)
|
||||
* v_pow_minus_two_thirds - T(0.0060))
|
||||
* v_pow_minus_two_thirds + T(0.01198))
|
||||
* v_pow_minus_two_thirds + T(0.260351))
|
||||
* v_pow_minus_two_thirds + T(0.9315768))
|
||||
* v_pow_minus_two_thirds + T(1));
|
||||
}
|
||||
|
||||
template<class T, class Policy>
|
||||
class function_object_yv
|
||||
{
|
||||
public:
|
||||
function_object_yv(const T& v,
|
||||
const Policy& pol) : my_v(v),
|
||||
my_pol(pol) { }
|
||||
|
||||
T operator()(const T& x) const
|
||||
{
|
||||
return boost::math::cyl_neumann(my_v, x, my_pol);
|
||||
}
|
||||
|
||||
private:
|
||||
const T my_v;
|
||||
const Policy& my_pol;
|
||||
const function_object_yv& operator=(const function_object_yv&);
|
||||
};
|
||||
|
||||
template<class T, class Policy>
|
||||
class function_object_yv_and_yv_prime
|
||||
{
|
||||
public:
|
||||
function_object_yv_and_yv_prime(const T& v,
|
||||
const Policy& pol) : my_v(v),
|
||||
my_pol(pol) { }
|
||||
|
||||
boost::math::tuple<T, T> operator()(const T& x) const
|
||||
{
|
||||
const T half_epsilon(boost::math::tools::epsilon<T>() / 2U);
|
||||
|
||||
const bool order_is_zero = ((my_v > -half_epsilon) && (my_v < +half_epsilon));
|
||||
|
||||
// Obtain Yv(x) and Yv'(x).
|
||||
// Chris's original code called the Bessel function implementation layer direct,
|
||||
// but that circumvented optimizations for integer-orders. Call the documented
|
||||
// top level functions instead, and let them sort out which implementation to use.
|
||||
T y_v;
|
||||
T y_v_prime;
|
||||
|
||||
if(order_is_zero)
|
||||
{
|
||||
y_v = boost::math::cyl_neumann(0, x, my_pol);
|
||||
y_v_prime = -boost::math::cyl_neumann(1, x, my_pol);
|
||||
}
|
||||
else
|
||||
{
|
||||
y_v = boost::math::cyl_neumann( my_v, x, my_pol);
|
||||
const T y_v_m1 (boost::math::cyl_neumann(T(my_v - 1), x, my_pol));
|
||||
y_v_prime = y_v_m1 - ((my_v * y_v) / x);
|
||||
}
|
||||
|
||||
// Return a tuple containing both Yv(x) and Yv'(x).
|
||||
return boost::math::make_tuple(y_v, y_v_prime);
|
||||
}
|
||||
|
||||
private:
|
||||
const T my_v;
|
||||
const Policy& my_pol;
|
||||
const function_object_yv_and_yv_prime& operator=(const function_object_yv_and_yv_prime&);
|
||||
};
|
||||
|
||||
template<class T> bool my_bisection_unreachable_tolerance(const T&, const T&) { return false; }
|
||||
|
||||
template<class T, class Policy>
|
||||
T initial_guess(const T& v, const int m, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for floor.
|
||||
|
||||
// Compute an estimate of the m'th root of cyl_neumann.
|
||||
|
||||
T guess;
|
||||
|
||||
// There is special handling for negative order.
|
||||
if(v < 0)
|
||||
{
|
||||
// Create the positive order and extract its positive floor and ceiling integer parts.
|
||||
const T vv(-v);
|
||||
const T vv_floor(floor(vv));
|
||||
|
||||
// The to-be-found root is bracketed by the roots of the
|
||||
// Bessel function whose reflected, positive integer order
|
||||
// is less than, but nearest to vv.
|
||||
|
||||
// The special case of negative, half-integer order uses
|
||||
// the relation between Yv and spherical Bessel functions
|
||||
// in order to obtain the bracket for the root.
|
||||
// In these special cases, cyl_neumann(-n/2, x) = sph_bessel_j(+n/2, x)
|
||||
// for v = -n/2.
|
||||
|
||||
T root_hi;
|
||||
T root_lo;
|
||||
|
||||
if(m == 1)
|
||||
{
|
||||
// The estimate of the first root for negative order is found using
|
||||
// an adaptive range-searching algorithm.
|
||||
// Take special precautions for the discontinuity at negative,
|
||||
// half-integer orders and use different brackets above and below these.
|
||||
if(T(vv - vv_floor) < 0.5F)
|
||||
{
|
||||
root_hi = boost::math::detail::bessel_zero::cyl_neumann_zero_detail::initial_guess(vv_floor, m, pol);
|
||||
}
|
||||
else
|
||||
{
|
||||
root_hi = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::initial_guess(T(vv_floor + 0.5F), m, pol);
|
||||
}
|
||||
|
||||
root_lo = T(root_hi - 0.1F);
|
||||
|
||||
const bool hi_end_of_bracket_is_negative = (boost::math::cyl_neumann(v, root_hi, pol) < 0);
|
||||
|
||||
while((root_lo > boost::math::tools::epsilon<T>()))
|
||||
{
|
||||
const bool lo_end_of_bracket_is_negative = (boost::math::cyl_neumann(v, root_lo, pol) < 0);
|
||||
|
||||
if(hi_end_of_bracket_is_negative != lo_end_of_bracket_is_negative)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
root_hi = root_lo;
|
||||
|
||||
// Decrease the lower end of the bracket using an adaptive algorithm.
|
||||
if(root_lo > 0.5F)
|
||||
{
|
||||
root_lo -= 0.5F;
|
||||
}
|
||||
else
|
||||
{
|
||||
root_lo *= 0.75F;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(T(vv - vv_floor) < 0.5F)
|
||||
{
|
||||
root_lo = boost::math::detail::bessel_zero::cyl_neumann_zero_detail::initial_guess(vv_floor, m - 1, pol);
|
||||
root_hi = boost::math::detail::bessel_zero::cyl_neumann_zero_detail::initial_guess(vv_floor, m, pol);
|
||||
root_lo += 0.01F;
|
||||
root_hi += 0.01F;
|
||||
}
|
||||
else
|
||||
{
|
||||
root_lo = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::initial_guess(T(vv_floor + 0.5F), m - 1, pol);
|
||||
root_hi = boost::math::detail::bessel_zero::cyl_bessel_j_zero_detail::initial_guess(T(vv_floor + 0.5F), m, pol);
|
||||
root_lo += 0.01F;
|
||||
root_hi += 0.01F;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform several steps of bisection iteration to refine the guess.
|
||||
boost::uintmax_t number_of_iterations(12U);
|
||||
|
||||
// Do the bisection iteration.
|
||||
const boost::math::tuple<T, T> guess_pair =
|
||||
boost::math::tools::bisect(
|
||||
boost::math::detail::bessel_zero::cyl_neumann_zero_detail::function_object_yv<T, Policy>(v, pol),
|
||||
root_lo,
|
||||
root_hi,
|
||||
boost::math::detail::bessel_zero::cyl_neumann_zero_detail::my_bisection_unreachable_tolerance<T>,
|
||||
number_of_iterations);
|
||||
|
||||
return (boost::math::get<0>(guess_pair) + boost::math::get<1>(guess_pair)) / 2U;
|
||||
}
|
||||
|
||||
if(m == 1U)
|
||||
{
|
||||
// Get the initial estimate of the first root.
|
||||
|
||||
if(v < 2.2F)
|
||||
{
|
||||
// For small v, use the results of empirical curve fitting.
|
||||
// Mathematica(R) session for the coefficients:
|
||||
// Table[{n, BesselYZero[n, 1]}, {n, 0, 22/10, 1/10}]
|
||||
// N[%, 20]
|
||||
// Fit[%, {n^0, n^1, n^2, n^3, n^4, n^5, n^6}, n]
|
||||
guess = ((((( - T(0.0025095909235652)
|
||||
* v + T(0.021291887049053))
|
||||
* v - T(0.076487785486526))
|
||||
* v + T(0.159110268115362))
|
||||
* v - T(0.241681668765196))
|
||||
* v + T(1.4437846310885244))
|
||||
* v + T(0.89362115190200490);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For larger v, use the second line of Eqs. 10.21.40 in the NIST Handbook.
|
||||
guess = boost::math::detail::bessel_zero::cyl_neumann_zero_detail::equation_nist_10_21_40_b(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(v < 2.2F)
|
||||
{
|
||||
// Use Eq. 10.21.19 in the NIST Handbook.
|
||||
const T a(((v + T(m * 2U)) - T(1.5)) * boost::math::constants::half_pi<T>());
|
||||
|
||||
guess = boost::math::detail::bessel_zero::equation_nist_10_21_19(v, a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get an estimate of the m'th root of airy_bi.
|
||||
const T airy_bi_root(boost::math::detail::airy_zero::airy_bi_zero_detail::initial_guess<T>(m));
|
||||
|
||||
// Use Eq. 9.5.26 in the A&S Handbook.
|
||||
guess = boost::math::detail::bessel_zero::equation_as_9_5_26(v, airy_bi_root);
|
||||
}
|
||||
}
|
||||
|
||||
return guess;
|
||||
}
|
||||
} // namespace cyl_neumann_zero_detail
|
||||
} // namespace bessel_zero
|
||||
} } } // namespace boost::math::detail
|
||||
|
||||
#endif // _BESSEL_JY_ZERO_2013_01_18_HPP_
|
||||
@@ -0,0 +1,30 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under 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_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for dose equivalent : L^2 T^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
time_base_dimension,-2>::type dose_equivalent_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_DOSE_EQUIVALENT_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,359 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file arg.hpp
|
||||
/// Contains definition of the argN transforms.
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under 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_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
|
||||
#define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/proto/proto_fwd.hpp>
|
||||
#include <boost/proto/traits.hpp>
|
||||
#include <boost/proto/transform/impl.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/proto/transform/env.hpp>
|
||||
|
||||
namespace boost { namespace proto
|
||||
{
|
||||
|
||||
/// \brief A PrimitiveTransform that returns the current expression
|
||||
/// unmodified
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// proto::terminal<int>::type & j = proto::_expr()(i);
|
||||
/// assert( boost::addressof(i) == boost::addressof(j) );
|
||||
/// \endcode
|
||||
struct _expr : transform<_expr>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef Expr result_type;
|
||||
|
||||
/// Returns the current expression.
|
||||
/// \param e The current expression.
|
||||
/// \return \c e
|
||||
/// \throw nothrow
|
||||
BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param)
|
||||
operator()(
|
||||
typename impl::expr_param e
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// \brief A PrimitiveTransform that returns the current state
|
||||
/// unmodified
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// char ch = proto::_state()(i, 'a');
|
||||
/// assert( ch == 'a' );
|
||||
/// \endcode
|
||||
struct _state : transform<_state>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef State result_type;
|
||||
|
||||
/// Returns the current state.
|
||||
/// \param s The current state.
|
||||
/// \return \c s
|
||||
/// \throw nothrow
|
||||
BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::state_param)
|
||||
operator ()(
|
||||
typename impl::expr_param
|
||||
, typename impl::state_param s
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// \brief A PrimitiveTransform that returns the current data
|
||||
/// unmodified
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// std::string str("hello");
|
||||
/// std::string & data = proto::_data()(i, 'a', str);
|
||||
/// assert( &str == &data );
|
||||
/// \endcode
|
||||
struct _data : transform<_data>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl
|
||||
: mpl::if_c<
|
||||
is_env<Data>::value
|
||||
, _env_var<data_type>
|
||||
, _env
|
||||
>::type::template impl<Expr, State, Data>
|
||||
{};
|
||||
};
|
||||
|
||||
/// \brief A PrimitiveTransform that returns N-th child of the current
|
||||
/// expression.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// proto::terminal<int>::type & j = proto::_child_c<0>()(-i);
|
||||
/// assert( boost::addressof(i) == boost::addressof(j) );
|
||||
/// \endcode
|
||||
template<int N>
|
||||
struct _child_c : transform<_child_c<N> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename result_of::child_c<Expr, N>::type
|
||||
result_type;
|
||||
|
||||
/// Returns the N-th child of \c e
|
||||
/// \pre <tt>arity_of\<Expr\>::value \> N</tt>
|
||||
/// \param e The current expression.
|
||||
/// \return <tt>proto::child_c\<N\>(e)</tt>
|
||||
/// \throw nothrow
|
||||
#ifdef BOOST_PROTO_STRICT_RESULT_OF
|
||||
result_type
|
||||
#else
|
||||
typename result_of::child_c<typename impl::expr_param, N>::type
|
||||
#endif
|
||||
operator ()(
|
||||
typename impl::expr_param e
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
return proto::child_c<N>(e);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// \brief A PrimitiveTransform that returns the value of the
|
||||
/// current terminal expression.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// int j = proto::_value()(i);
|
||||
/// assert( 42 == j );
|
||||
/// \endcode
|
||||
struct _value : transform<_value>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename result_of::value<Expr>::type
|
||||
result_type;
|
||||
|
||||
/// Returns the value of the specified terminal expression.
|
||||
/// \pre <tt>arity_of\<Expr\>::value == 0</tt>.
|
||||
/// \param e The current expression.
|
||||
/// \return <tt>proto::value(e)</tt>
|
||||
/// \throw nothrow
|
||||
#ifdef BOOST_PROTO_STRICT_RESULT_OF
|
||||
typename mpl::if_c<is_array<result_type>::value, result_type &, result_type>::type
|
||||
#else
|
||||
typename result_of::value<typename impl::expr_param>::type
|
||||
#endif
|
||||
operator ()(
|
||||
typename impl::expr_param e
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
return proto::value(e);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// \brief A PrimitiveTransform that does nothing
|
||||
/// and returns void.
|
||||
struct _void : transform<_void>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef void result_type;
|
||||
|
||||
/// Does nothing and returns void
|
||||
void operator ()(
|
||||
typename impl::expr_param
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{}
|
||||
};
|
||||
};
|
||||
|
||||
/// \brief A unary CallableTransform that wraps its argument
|
||||
/// in a \c boost::reference_wrapper\<\>.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// boost::reference_wrapper<proto::terminal<int>::type> j
|
||||
/// = proto::when<_, proto::_byref(_)>()(i);
|
||||
/// assert( boost::addressof(i) == boost::addressof(j.get()) );
|
||||
/// \endcode
|
||||
struct _byref : callable
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename This, typename T>
|
||||
struct result<This(T)>
|
||||
{
|
||||
typedef boost::reference_wrapper<T const> const type;
|
||||
};
|
||||
|
||||
template<typename This, typename T>
|
||||
struct result<This(T &)>
|
||||
{
|
||||
typedef boost::reference_wrapper<T> const type;
|
||||
};
|
||||
|
||||
/// Wrap the parameter \c t in a \c boost::reference_wrapper\<\>
|
||||
/// \param t The object to wrap
|
||||
/// \return <tt>boost::ref(t)</tt>
|
||||
/// \throw nothrow
|
||||
template<typename T>
|
||||
boost::reference_wrapper<T> const operator ()(T &t) const
|
||||
{
|
||||
return boost::reference_wrapper<T>(t);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
///
|
||||
template<typename T>
|
||||
boost::reference_wrapper<T const> const operator ()(T const &t) const
|
||||
{
|
||||
return boost::reference_wrapper<T const>(t);
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief A unary CallableTransform that strips references
|
||||
/// and \c boost::reference_wrapper\<\> from its argument.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// \code
|
||||
/// proto::terminal<int>::type i = {42};
|
||||
/// int j = 67;
|
||||
/// int k = proto::when<_, proto::_byval(proto::_state)>()(i, boost::ref(j));
|
||||
/// assert( 67 == k );
|
||||
/// \endcode
|
||||
struct _byval : callable
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename This, typename T>
|
||||
struct result<This(T)>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename This, typename T>
|
||||
struct result<This(T &)>
|
||||
: result<This(T)>
|
||||
{};
|
||||
|
||||
template<typename This, typename T>
|
||||
struct result<This(boost::reference_wrapper<T>)>
|
||||
: result<This(T)>
|
||||
{};
|
||||
|
||||
/// \param t The object to unref
|
||||
/// \return <tt>t</tt>
|
||||
/// \throw nothrow
|
||||
template<typename T>
|
||||
T operator ()(T const &t) const
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
/// \overload
|
||||
///
|
||||
template<typename T>
|
||||
T operator ()(boost::reference_wrapper<T> const &t) const
|
||||
{
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_expr>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_state>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_data>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<int N>
|
||||
struct is_callable<_child_c<N> >
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_value>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_byref>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
template<>
|
||||
struct is_callable<_byval>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
// boost/io/quoted_manip.hpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// Library home page http://www.boost.org/libs/io
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_IO_QUOTED_MANIP
|
||||
#define BOOST_IO_QUOTED_MANIP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <ios>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <boost/io/ios_state.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
namespace detail { template <class String, class Char> struct quoted_proxy; }
|
||||
|
||||
// ------------ public interface ------------------------------------------------//
|
||||
|
||||
// manipulator for const std::basic_string&
|
||||
template <class Char, class Traits, class Alloc>
|
||||
detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>
|
||||
quoted(const std::basic_string<Char, Traits, Alloc>& s,
|
||||
Char escape='\\', Char delim='\"');
|
||||
|
||||
// manipulator for non-const std::basic_string&
|
||||
template <class Char, class Traits, class Alloc>
|
||||
detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> &, Char>
|
||||
quoted(std::basic_string<Char, Traits, Alloc>& s,
|
||||
Char escape='\\', Char delim='\"');
|
||||
|
||||
// manipulator for const C-string*
|
||||
template <class Char>
|
||||
detail::quoted_proxy<const Char*, Char>
|
||||
quoted(const Char* s, Char escape='\\', Char delim='\"');
|
||||
|
||||
// ----------- implementation details -------------------------------------------//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// proxy used as an argument pack
|
||||
template <class String, class Char>
|
||||
struct quoted_proxy
|
||||
{
|
||||
String string;
|
||||
Char escape;
|
||||
Char delim;
|
||||
|
||||
quoted_proxy(String s_, Char escape_, Char delim_)
|
||||
: string(s_), escape(escape_), delim(delim_) {}
|
||||
private:
|
||||
// String may be a const type, so disable the assignment operator
|
||||
quoted_proxy& operator=(const quoted_proxy&); // = deleted
|
||||
};
|
||||
|
||||
// abstract away difference between proxies with const or non-const basic_strings
|
||||
template <class Char, class Traits, class Alloc>
|
||||
std::basic_ostream<Char, Traits>&
|
||||
basic_string_inserter_imp(std::basic_ostream<Char, Traits>& os,
|
||||
std::basic_string<Char, Traits, Alloc> const & string, Char escape, Char delim)
|
||||
{
|
||||
os << delim;
|
||||
typename std::basic_string<Char, Traits, Alloc>::const_iterator
|
||||
end_it = string.end();
|
||||
for (typename std::basic_string<Char, Traits, Alloc>::const_iterator
|
||||
it = string.begin();
|
||||
it != end_it;
|
||||
++it )
|
||||
{
|
||||
if (*it == delim || *it == escape)
|
||||
os << escape;
|
||||
os << *it;
|
||||
}
|
||||
os << delim;
|
||||
return os;
|
||||
}
|
||||
|
||||
// inserter for const std::basic_string& proxies
|
||||
template <class Char, class Traits, class Alloc>
|
||||
inline
|
||||
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>& proxy)
|
||||
{
|
||||
return basic_string_inserter_imp(os, proxy.string, proxy.escape, proxy.delim);
|
||||
}
|
||||
|
||||
// inserter for non-const std::basic_string& proxies
|
||||
template <class Char, class Traits, class Alloc>
|
||||
inline
|
||||
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>& proxy)
|
||||
{
|
||||
return basic_string_inserter_imp(os, proxy.string, proxy.escape, proxy.delim);
|
||||
}
|
||||
|
||||
// inserter for const C-string* proxies
|
||||
template <class Char, class Traits>
|
||||
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,
|
||||
const quoted_proxy<const Char*, Char>& proxy)
|
||||
{
|
||||
os << proxy.delim;
|
||||
for (const Char* it = proxy.string;
|
||||
*it;
|
||||
++it )
|
||||
{
|
||||
if (*it == proxy.delim || *it == proxy.escape)
|
||||
os << proxy.escape;
|
||||
os << *it;
|
||||
}
|
||||
os << proxy.delim;
|
||||
return os;
|
||||
}
|
||||
|
||||
// extractor for non-const std::basic_string& proxies
|
||||
template <class Char, class Traits, class Alloc>
|
||||
std::basic_istream<Char, Traits>& operator>>(std::basic_istream<Char, Traits>& is,
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>& proxy)
|
||||
{
|
||||
proxy.string.clear();
|
||||
Char c;
|
||||
is >> c;
|
||||
if (c != proxy.delim)
|
||||
{
|
||||
is.unget();
|
||||
is >> proxy.string;
|
||||
return is;
|
||||
}
|
||||
{
|
||||
boost::io::ios_flags_saver ifs(is);
|
||||
is >> std::noskipws;
|
||||
for (;;)
|
||||
{
|
||||
is >> c;
|
||||
if (!is.good()) // cope with I/O errors or end-of-file
|
||||
break;
|
||||
if (c == proxy.escape)
|
||||
{
|
||||
is >> c;
|
||||
if (!is.good()) // cope with I/O errors or end-of-file
|
||||
break;
|
||||
}
|
||||
else if (c == proxy.delim)
|
||||
break;
|
||||
proxy.string += c;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// manipulator implementation for const std::basic_string&
|
||||
template <class Char, class Traits, class Alloc>
|
||||
inline detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>
|
||||
quoted(const std::basic_string<Char, Traits, Alloc>& s, Char escape, Char delim)
|
||||
{
|
||||
return detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>
|
||||
(s, escape, delim);
|
||||
}
|
||||
|
||||
// manipulator implementation for non-const std::basic_string&
|
||||
template <class Char, class Traits, class Alloc>
|
||||
inline detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> &, Char>
|
||||
quoted(std::basic_string<Char, Traits, Alloc>& s, Char escape, Char delim)
|
||||
{
|
||||
return detail::quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>
|
||||
(s, escape, delim);
|
||||
}
|
||||
|
||||
// manipulator implementation for const C-string*
|
||||
template <class Char>
|
||||
inline detail::quoted_proxy<const Char*, Char>
|
||||
quoted(const Char* s, Char escape, Char delim)
|
||||
{
|
||||
return detail::quoted_proxy<const Char*, Char> (s, escape, delim);
|
||||
}
|
||||
|
||||
} // namespace io
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_IO_QUOTED_MANIP
|
||||
@@ -0,0 +1,218 @@
|
||||
|
||||
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
|
||||
|
||||
#if defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/preprocessor/enum_params.hpp>
|
||||
#include <boost/preprocessor/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/comma_if.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
#include <boost/preprocessor/dec.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
|
||||
#define i_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
|
||||
|
||||
# define AUX778076_VECTOR_TAIL(vector, i_, T) \
|
||||
BOOST_PP_CAT(vector,i_)< \
|
||||
BOOST_PP_ENUM_PARAMS(i_, T) \
|
||||
> \
|
||||
/**/
|
||||
|
||||
#if i_ > 0
|
||||
template<
|
||||
BOOST_PP_ENUM_PARAMS(i_, typename T)
|
||||
>
|
||||
struct BOOST_PP_CAT(vector,i_)
|
||||
: v_item<
|
||||
BOOST_PP_CAT(T,BOOST_PP_DEC(i_))
|
||||
, AUX778076_VECTOR_TAIL(vector,BOOST_PP_DEC(i_),T)
|
||||
>
|
||||
{
|
||||
typedef BOOST_PP_CAT(vector,i_) type;
|
||||
};
|
||||
#endif
|
||||
|
||||
# undef AUX778076_VECTOR_TAIL
|
||||
|
||||
#else // "brute force" implementation
|
||||
|
||||
# if i_ > 0
|
||||
|
||||
template<
|
||||
BOOST_PP_ENUM_PARAMS(i_, typename T)
|
||||
>
|
||||
struct BOOST_PP_CAT(vector,i_)
|
||||
{
|
||||
typedef aux::vector_tag<i_> tag;
|
||||
typedef BOOST_PP_CAT(vector,i_) type;
|
||||
|
||||
# define AUX778076_VECTOR_ITEM(unused, i_, unused2) \
|
||||
typedef BOOST_PP_CAT(T,i_) BOOST_PP_CAT(item,i_); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(i_, AUX778076_VECTOR_ITEM, unused)
|
||||
# undef AUX778076_VECTOR_ITEM
|
||||
typedef void_ BOOST_PP_CAT(item,i_);
|
||||
typedef BOOST_PP_CAT(T,BOOST_PP_DEC(i_)) back;
|
||||
|
||||
// Borland forces us to use 'type' here (instead of the class name)
|
||||
typedef v_iter<type,0> begin;
|
||||
typedef v_iter<type,i_> end;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct push_front_impl< aux::vector_tag<BOOST_PP_DEC(i_)> >
|
||||
{
|
||||
template< typename Vector, typename T > struct apply
|
||||
{
|
||||
typedef BOOST_PP_CAT(vector,i_)<
|
||||
T
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i_))
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct pop_front_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
{
|
||||
typedef BOOST_PP_CAT(vector,BOOST_PP_DEC(i_))<
|
||||
BOOST_PP_ENUM_SHIFTED_PARAMS(i_, typename Vector::item)
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct push_back_impl< aux::vector_tag<BOOST_PP_DEC(i_)> >
|
||||
{
|
||||
template< typename Vector, typename T > struct apply
|
||||
{
|
||||
typedef BOOST_PP_CAT(vector,i_)<
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i_))
|
||||
T
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct pop_back_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
{
|
||||
typedef BOOST_PP_CAT(vector,BOOST_PP_DEC(i_))<
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
# endif // i_ > 0
|
||||
|
||||
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
|
||||
|
||||
template< typename V >
|
||||
struct v_at<V,i_>
|
||||
{
|
||||
typedef typename V::BOOST_PP_CAT(item,i_) type;
|
||||
};
|
||||
|
||||
# else
|
||||
|
||||
namespace aux {
|
||||
template<> struct v_at_impl<i_>
|
||||
{
|
||||
template< typename V_ > struct result_
|
||||
{
|
||||
typedef typename V_::BOOST_PP_CAT(item,i_) type;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
struct at_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename V_, typename N > struct apply
|
||||
{
|
||||
typedef typename aux::v_at_impl<BOOST_MPL_AUX_VALUE_WKND(N)::value>
|
||||
::template result_<V_>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
#if i_ > 0
|
||||
template<>
|
||||
struct front_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
{
|
||||
typedef typename Vector::item0 type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct back_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
{
|
||||
typedef typename Vector::back type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct empty_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
: false_
|
||||
{
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct size_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
: long_<i_>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct O1_size_impl< aux::vector_tag<i_> >
|
||||
: size_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct clear_impl< aux::vector_tag<i_> >
|
||||
{
|
||||
template< typename Vector > struct apply
|
||||
{
|
||||
typedef vector0<> type;
|
||||
};
|
||||
};
|
||||
|
||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
|
||||
|
||||
#undef i_
|
||||
|
||||
#endif // BOOST_PP_IS_ITERATING
|
||||
Reference in New Issue
Block a user