Initial Commit

This commit is contained in:
Jordan Sherer
2018-02-08 21:28:33 -05:00
commit 678c1d3966
14352 changed files with 3176737 additions and 0 deletions
@@ -0,0 +1,166 @@
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
* 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/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/operators.hpp>
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/version.hpp>
#endif
namespace boost{
namespace multi_index{
namespace detail{
/* Iterator class for hashed indices.
*/
struct hashed_index_global_iterator_tag{};
struct hashed_index_local_iterator_tag{};
template<typename Node,typename BucketArray,typename Category>
class hashed_index_iterator:
public forward_iterator_helper<
hashed_index_iterator<Node,BucketArray,Category>,
typename Node::value_type,
std::ptrdiff_t,
const typename Node::value_type*,
const typename Node::value_type&>
{
public:
/* coverity[uninit_ctor]: suppress warning */
hashed_index_iterator(){}
hashed_index_iterator(Node* node_):node(node_){}
const typename Node::value_type& operator*()const
{
return node->value();
}
hashed_index_iterator& operator++()
{
this->increment(Category());
return *this;
}
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* Serialization. As for why the following is public,
* see explanation in safe_mode_iterator notes in safe_mode.hpp.
*/
BOOST_SERIALIZATION_SPLIT_MEMBER()
typedef typename Node::base_type node_base_type;
template<class Archive>
void save(Archive& ar,const unsigned int)const
{
node_base_type* bnode=node;
ar<<serialization::make_nvp("pointer",bnode);
}
template<class Archive>
void load(Archive& ar,const unsigned int version)
{
load(ar,version,Category());
}
template<class Archive>
void load(
Archive& ar,const unsigned int version,hashed_index_global_iterator_tag)
{
node_base_type* bnode;
ar>>serialization::make_nvp("pointer",bnode);
node=static_cast<Node*>(bnode);
if(version<1){
BucketArray* throw_away; /* consume unused ptr */
ar>>serialization::make_nvp("pointer",throw_away);
}
}
template<class Archive>
void load(
Archive& ar,const unsigned int version,hashed_index_local_iterator_tag)
{
node_base_type* bnode;
ar>>serialization::make_nvp("pointer",bnode);
node=static_cast<Node*>(bnode);
if(version<1){
BucketArray* buckets;
ar>>serialization::make_nvp("pointer",buckets);
if(buckets&&node&&node->impl()==buckets->end()->prior()){
/* end local_iterators used to point to end node, now they are null */
node=0;
}
}
}
#endif
/* get_node is not to be used by the user */
typedef Node node_type;
Node* get_node()const{return node;}
private:
void increment(hashed_index_global_iterator_tag)
{
Node::increment(node);
}
void increment(hashed_index_local_iterator_tag)
{
Node::increment_local(node);
}
Node* node;
};
template<typename Node,typename BucketArray,typename Category>
bool operator==(
const hashed_index_iterator<Node,BucketArray,Category>& x,
const hashed_index_iterator<Node,BucketArray,Category>& y)
{
return x.get_node()==y.get_node();
}
} /* namespace multi_index::detail */
} /* namespace multi_index */
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* class version = 1 : hashed_index_iterator does no longer serialize a bucket
* array pointer.
*/
namespace serialization {
template<typename Node,typename BucketArray,typename Category>
struct version<
boost::multi_index::detail::hashed_index_iterator<Node,BucketArray,Category>
>
{
BOOST_STATIC_CONSTANT(int,value=1);
};
} /* namespace serialization */
#endif
} /* namespace boost */
#endif
@@ -0,0 +1,245 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// 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://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_CONTEXT_HPP
#define BOOST_COMPUTE_CONTEXT_HPP
#include <vector>
#include <boost/throw_exception.hpp>
#include <boost/compute/config.hpp>
#include <boost/compute/device.hpp>
#include <boost/compute/exception/opencl_error.hpp>
#include <boost/compute/detail/assert_cl_success.hpp>
namespace boost {
namespace compute {
/// \class context
/// \brief A compute context.
///
/// The context class represents a compute context.
///
/// A context object manages a set of OpenCL resources including memory
/// buffers and program objects. Before allocating memory on the device or
/// executing kernels you must set up a context object.
///
/// To create a context for the default device on the system:
/// \code
/// // get the default compute device
/// boost::compute::device gpu = boost::compute::system::default_device();
///
/// // create a context for the device
/// boost::compute::context context(gpu);
/// \endcode
///
/// Once a context is created, memory can be allocated using the buffer class
/// and kernels can be executed using the command_queue class.
///
/// \see device, command_queue
class context
{
public:
/// Create a null context object.
context()
: m_context(0)
{
}
/// Creates a new context for \p device with \p properties.
///
/// \see_opencl_ref{clCreateContext}
explicit context(const device &device,
const cl_context_properties *properties = 0)
{
BOOST_ASSERT(device.id() != 0);
cl_device_id device_id = device.id();
cl_int error = 0;
m_context = clCreateContext(properties, 1, &device_id, 0, 0, &error);
if(!m_context){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
}
/// Creates a new context for \p devices with \p properties.
///
/// \see_opencl_ref{clCreateContext}
explicit context(const std::vector<device> &devices,
const cl_context_properties *properties = 0)
{
BOOST_ASSERT(!devices.empty());
cl_int error = 0;
m_context = clCreateContext(
properties,
static_cast<cl_uint>(devices.size()),
reinterpret_cast<const cl_device_id *>(&devices[0]),
0,
0,
&error
);
if(!m_context){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
}
/// Creates a new context object for \p context. If \p retain is
/// \c true, the reference count for \p context will be incremented.
explicit context(cl_context context, bool retain = true)
: m_context(context)
{
if(m_context && retain){
clRetainContext(m_context);
}
}
/// Creates a new context object as a copy of \p other.
context(const context &other)
: m_context(other.m_context)
{
if(m_context){
clRetainContext(m_context);
}
}
/// Copies the context object from \p other to \c *this.
context& operator=(const context &other)
{
if(this != &other){
if(m_context){
clReleaseContext(m_context);
}
m_context = other.m_context;
if(m_context){
clRetainContext(m_context);
}
}
return *this;
}
#ifndef BOOST_COMPUTE_NO_RVALUE_REFERENCES
/// Move-constructs a new context object from \p other.
context(context&& other) BOOST_NOEXCEPT
: m_context(other.m_context)
{
other.m_context = 0;
}
/// Move-assigns the context from \p other to \c *this.
context& operator=(context&& other) BOOST_NOEXCEPT
{
if(m_context){
clReleaseContext(m_context);
}
m_context = other.m_context;
other.m_context = 0;
return *this;
}
#endif // BOOST_COMPUTE_NO_RVALUE_REFERENCES
/// Destroys the context object.
~context()
{
if(m_context){
BOOST_COMPUTE_ASSERT_CL_SUCCESS(
clReleaseContext(m_context)
);
}
}
/// Returns the underlying OpenCL context.
cl_context& get() const
{
return const_cast<cl_context &>(m_context);
}
/// Returns the device for the context. If the context contains multiple
/// devices, the first is returned.
device get_device() const
{
std::vector<device> devices = get_devices();
if(devices.empty()) {
return device();
}
return devices.front();
}
/// Returns a vector of devices for the context.
std::vector<device> get_devices() const
{
return get_info<std::vector<device> >(CL_CONTEXT_DEVICES);
}
/// Returns information about the context.
///
/// \see_opencl_ref{clGetContextInfo}
template<class T>
T get_info(cl_context_info info) const
{
return detail::get_object_info<T>(clGetContextInfo, m_context, info);
}
/// \overload
template<int Enum>
typename detail::get_object_info_type<context, Enum>::type
get_info() const;
/// Returns \c true if the context is the same as \p other.
bool operator==(const context &other) const
{
return m_context == other.m_context;
}
/// Returns \c true if the context is different from \p other.
bool operator!=(const context &other) const
{
return m_context != other.m_context;
}
/// \internal_
operator cl_context() const
{
return m_context;
}
private:
cl_context m_context;
};
/// \internal_ define get_info() specializations for context
BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(context,
((cl_uint, CL_CONTEXT_REFERENCE_COUNT))
((std::vector<cl_device_id>, CL_CONTEXT_DEVICES))
((std::vector<cl_context_properties>, CL_CONTEXT_PROPERTIES))
)
#ifdef CL_VERSION_1_1
BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(context,
((cl_uint, CL_CONTEXT_NUM_DEVICES))
)
#endif // CL_VERSION_1_1
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_CONTEXT_HPP
@@ -0,0 +1,139 @@
// (C) Copyright John Maddock 2006.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MATH_SPECIAL_LAGUERRE_HPP
#define BOOST_MATH_SPECIAL_LAGUERRE_HPP
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/tools/config.hpp>
#include <boost/math/policies/error_handling.hpp>
namespace boost{
namespace math{
// Recurrance relation for Laguerre polynomials:
template <class T1, class T2, class T3>
inline typename tools::promote_args<T1, T2, T3>::type
laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1)
{
typedef typename tools::promote_args<T1, T2, T3>::type result_type;
return ((2 * n + 1 - result_type(x)) * result_type(Ln) - n * result_type(Lnm1)) / (n + 1);
}
namespace detail{
// Implement Laguerre polynomials via recurrance:
template <class T>
T laguerre_imp(unsigned n, T x)
{
T p0 = 1;
T p1 = 1 - x;
if(n == 0)
return p0;
unsigned c = 1;
while(c < n)
{
std::swap(p0, p1);
p1 = laguerre_next(c, x, p0, p1);
++c;
}
return p1;
}
template <class T, class Policy>
inline typename tools::promote_args<T>::type
laguerre(unsigned n, T x, const Policy&, const mpl::true_&)
{
typedef typename tools::promote_args<T>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
return policies::checked_narrowing_cast<result_type, Policy>(detail::laguerre_imp(n, static_cast<value_type>(x)), "boost::math::laguerre<%1%>(unsigned, %1%)");
}
template <class T>
inline typename tools::promote_args<T>::type
laguerre(unsigned n, unsigned m, T x, const mpl::false_&)
{
return boost::math::laguerre(n, m, x, policies::policy<>());
}
} // namespace detail
template <class T>
inline typename tools::promote_args<T>::type
laguerre(unsigned n, T x)
{
return laguerre(n, x, policies::policy<>());
}
// Recurrence for associated polynomials:
template <class T1, class T2, class T3>
inline typename tools::promote_args<T1, T2, T3>::type
laguerre_next(unsigned n, unsigned l, T1 x, T2 Pl, T3 Plm1)
{
typedef typename tools::promote_args<T1, T2, T3>::type result_type;
return ((2 * n + l + 1 - result_type(x)) * result_type(Pl) - (n + l) * result_type(Plm1)) / (n+1);
}
namespace detail{
// Laguerre Associated Polynomial:
template <class T, class Policy>
T laguerre_imp(unsigned n, unsigned m, T x, const Policy& pol)
{
// Special cases:
if(m == 0)
return boost::math::laguerre(n, x, pol);
T p0 = 1;
if(n == 0)
return p0;
T p1 = m + 1 - x;
unsigned c = 1;
while(c < n)
{
std::swap(p0, p1);
p1 = laguerre_next(c, m, x, p0, p1);
++c;
}
return p1;
}
}
template <class T, class Policy>
inline typename tools::promote_args<T>::type
laguerre(unsigned n, unsigned m, T x, const Policy& pol)
{
typedef typename tools::promote_args<T>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
return policies::checked_narrowing_cast<result_type, Policy>(detail::laguerre_imp(n, m, static_cast<value_type>(x), pol), "boost::math::laguerre<%1%>(unsigned, unsigned, %1%)");
}
template <class T1, class T2>
inline typename laguerre_result<T1, T2>::type
laguerre(unsigned n, T1 m, T2 x)
{
typedef typename policies::is_policy<T2>::type tag_type;
return detail::laguerre(n, m, x, tag_type());
}
} // namespace math
} // namespace boost
#endif // BOOST_MATH_SPECIAL_LAGUERRE_HPP
@@ -0,0 +1,23 @@
subroutine tweak1(ca,jz,f0,cb)
! Shift frequency of analytic signal ca, with output to cb
complex ca(jz),cb(jz)
real*8 twopi
complex*16 w,wstep
complex w4
data twopi/0.d0/
save twopi
if(twopi.eq.0.d0) twopi=8.d0*atan(1.d0)
w=1.d0
dphi=twopi*f0/12000.d0
wstep=cmplx(cos(dphi),sin(dphi))
do i=1,jz
w=w*wstep
w4=w
cb(i)=w4*ca(i)
enddo
return
end subroutine tweak1
@@ -0,0 +1,46 @@
#ifndef BOOST_MPL_VECTOR_VECTOR40_C_HPP_INCLUDED
#define BOOST_MPL_VECTOR_VECTOR40_C_HPP_INCLUDED
// 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$
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
# include <boost/mpl/vector/vector30_c.hpp>
# include <boost/mpl/vector/vector40.hpp>
#endif
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
# define BOOST_MPL_PREPROCESSED_HEADER vector40_c.hpp
# include <boost/mpl/vector/aux_/include_preprocessed.hpp>
#else
# include <boost/mpl/aux_/config/typeof.hpp>
# include <boost/mpl/aux_/config/ctps.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace mpl {
# define BOOST_PP_ITERATION_PARAMS_1 \
(3,(31, 40, <boost/mpl/vector/aux_/numbered_c.hpp>))
# include BOOST_PP_ITERATE()
}}
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#endif // BOOST_MPL_VECTOR_VECTOR40_C_HPP_INCLUDED
@@ -0,0 +1,107 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp
[begin_description]
algebra_dispatcher specialization for thrust
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
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_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <boost/numeric/odeint/external/thrust/thrust_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
// specializations for the standard thrust containers
namespace boost {
namespace numeric {
namespace odeint {
// specialization for thrust host_vector
template< class T , class A >
struct algebra_dispatcher< thrust::host_vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
// specialization for thrust device_vector
template< class T , class A >
struct algebra_dispatcher< thrust::device_vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
// add support for thrust backend vectors, if available
#include <thrust/version.h>
#if THRUST_VERSION >= 100600
// specialization for thrust cpp vector
#include <thrust/system/cpp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::cpp::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
// specialization for thrust omp vector
#ifdef _OPENMP
#include <thrust/system/omp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::omp::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // _OPENMP
// specialization for thrust tbb vector
#ifdef TBB_VERSION_MAJOR
#include <thrust/system/tbb/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::tbb::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // TBB_VERSION_MAJOR
// specialization for thrust cuda vector
#ifdef __CUDACC__
#include <thrust/system/cuda/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::cuda::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // __CUDACC__
#endif // THRUST_VERSION >= 100600
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED
@@ -0,0 +1,90 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// 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://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_ALGORITHM_REPLACE_HPP
#define BOOST_COMPUTE_ALGORITHM_REPLACE_HPP
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
namespace boost {
namespace compute {
namespace detail {
template<class Iterator, class T>
class replace_kernel : public meta_kernel
{
public:
replace_kernel()
: meta_kernel("replace")
{
m_count = 0;
}
void set_range(Iterator first, Iterator last)
{
m_count = detail::iterator_range_size(first, last);
*this <<
"const uint i = get_global_id(0);\n" <<
"if(" << first[var<cl_uint>("i")] << " == " << var<T>("old_value") << ")\n" <<
" " << first[var<cl_uint>("i")] << '=' << var<T>("new_value") << ";\n";
}
void set_old_value(const T &old_value)
{
add_set_arg<T>("old_value", old_value);
}
void set_new_value(const T &new_value)
{
add_set_arg<T>("new_value", new_value);
}
void exec(command_queue &queue)
{
if(m_count == 0){
// nothing to do
return;
}
exec_1d(queue, 0, m_count);
}
private:
size_t m_count;
};
} // end detail namespace
/// Replaces each instance of \p old_value in the range [\p first,
/// \p last) with \p new_value.
template<class Iterator, class T>
inline void replace(Iterator first,
Iterator last,
const T &old_value,
const T &new_value,
command_queue &queue = system::default_queue())
{
detail::replace_kernel<Iterator, T> kernel;
kernel.set_range(first, last);
kernel.set_old_value(old_value);
kernel.set_new_value(new_value);
kernel.exec(queue);
}
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_ALGORITHM_REPLACE_HPP
@@ -0,0 +1,109 @@
#ifndef _GREGORIAN_TYPES_HPP__
#define _GREGORIAN_TYPES_HPP__
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
/*! @file gregorian_types.hpp
Single file header that defines most of the types for the gregorian
date-time system.
*/
#include "boost/date_time/date.hpp"
#include "boost/date_time/period.hpp"
#include "boost/date_time/gregorian/greg_calendar.hpp"
#include "boost/date_time/gregorian/greg_duration.hpp"
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include "boost/date_time/gregorian/greg_duration_types.hpp"
#endif
#include "boost/date_time/gregorian/greg_date.hpp"
#include "boost/date_time/date_generators.hpp"
#include "boost/date_time/date_clock_device.hpp"
#include "boost/date_time/date_iterator.hpp"
#include "boost/date_time/adjust_functors.hpp"
namespace boost {
//! Gregorian date system based on date_time components
/*! This date system defines a full complement of types including
* a date, date_duration, date_period, day_clock, and a
* day_iterator.
*/
namespace gregorian {
//! Date periods for the gregorian system
/*!\ingroup date_basics
*/
typedef date_time::period<date, date_duration> date_period;
//! A unifying date_generator base type
/*! A unifying date_generator base type for:
* partial_date, nth_day_of_the_week_in_month,
* first_day_of_the_week_in_month, and last_day_of_the_week_in_month
*/
typedef date_time::year_based_generator<date> year_based_generator;
//! A date generation object type
typedef date_time::partial_date<date> partial_date;
typedef date_time::nth_kday_of_month<date> nth_kday_of_month;
typedef nth_kday_of_month nth_day_of_the_week_in_month;
typedef date_time::first_kday_of_month<date> first_kday_of_month;
typedef first_kday_of_month first_day_of_the_week_in_month;
typedef date_time::last_kday_of_month<date> last_kday_of_month;
typedef last_kday_of_month last_day_of_the_week_in_month;
typedef date_time::first_kday_after<date> first_kday_after;
typedef first_kday_after first_day_of_the_week_after;
typedef date_time::first_kday_before<date> first_kday_before;
typedef first_kday_before first_day_of_the_week_before;
//! A clock to get the current day from the local computer
/*!\ingroup date_basics
*/
typedef date_time::day_clock<date> day_clock;
//! Base date_iterator type for gregorian types.
/*!\ingroup date_basics
*/
typedef date_time::date_itr_base<date> date_iterator;
//! A day level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::day_functor<date>,
date> day_iterator;
//! A week level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::week_functor<date>,
date> week_iterator;
//! A month level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::month_functor<date>,
date> month_iterator;
//! A year level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::year_functor<date>,
date> year_iterator;
// bring in these date_generator functions from date_time namespace
using date_time::days_until_weekday;
using date_time::days_before_weekday;
using date_time::next_weekday;
using date_time::previous_weekday;
} } //namespace gregorian
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,100 @@
// Copyright (C) 2007 Peder Holt
// 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_MSVC_TYPEOF_IMPL_HPP_INCLUDED
# define BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
# include <boost/mpl/int.hpp>
namespace boost
{
namespace type_of
{
template<int N> struct encode_counter : encode_counter<N - 1> {};
template<> struct encode_counter<0> {};
char (*encode_index(...))[1];
# define BOOST_TYPEOF_INDEX(T) (sizeof(*boost::type_of::encode_index((boost::type_of::encode_counter<1000>*)0)))
# define BOOST_TYPEOF_NEXT_INDEX(next) friend char (*encode_index(encode_counter<next>*))[next];
//Typeof code
template<typename ID>
struct msvc_extract_type
{
struct id2type;
};
template<typename T, typename ID>
struct msvc_register_type : msvc_extract_type<ID>
{
typedef msvc_extract_type<ID> base_type;
struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature, also works for Digital Mars
{
typedef T type;
};
};
template<int ID>
struct msvc_typeid_wrapper {
typedef typename msvc_extract_type<mpl::int_<ID> >::id2type id2type;
typedef typename id2type::type type;
};
//Tie it all together
template<typename T>
struct encode_type
{
//Get the next available compile time constants index
BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T));
//Instantiate the template
typedef typename msvc_register_type<T,mpl::int_<value> >::id2type type;
//Set the next compile time constants index
BOOST_STATIC_CONSTANT(unsigned,next=value+1);
//Increment the compile time constant (only needed when extensions are not active
BOOST_TYPEOF_NEXT_INDEX(next);
};
template<class T>
struct sizer
{
typedef char(*type)[encode_type<T>::value];
};
template<typename T>
typename sizer<T>::type encode_start(T const&);
template<typename Organizer, typename T>
msvc_register_type<T,Organizer> typeof_register_type(const T&,Organizer* =0);
# define BOOST_TYPEOF(expr) \
boost::type_of::msvc_typeid_wrapper<sizeof(*boost::type_of::encode_start(expr))>::type
# define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr)
# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \
struct name {\
BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr)));\
typedef typename boost::type_of::msvc_extract_type<name>::id2type id2type;\
typedef typename id2type::type type;\
};
# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \
struct name {\
BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type<name>(expr)));\
typedef boost::type_of::msvc_extract_type<name>::id2type id2type;\
typedef id2type::type type;\
};
}
}
#endif//BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED
@@ -0,0 +1,293 @@
// 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)
//
// Preprocessed version of "boost/mpl/aux_/fold_impl.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl { namespace aux {
/// forward declaration
template<
int N
, typename First
, typename Last
, typename State
, typename ForwardOp
>
struct fold_impl;
template< int N >
struct fold_chunk;
template<> struct fold_chunk<0>
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef First iter0;
typedef State state0;
typedef state0 state;
typedef iter0 iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template<> struct fold_chunk<1>
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef First iter0;
typedef State state0;
typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
typedef typename mpl::next<iter0>::type iter1;
typedef state1 state;
typedef iter1 iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template<> struct fold_chunk<2>
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef First iter0;
typedef State state0;
typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
typedef typename mpl::next<iter0>::type iter1;
typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
typedef typename mpl::next<iter1>::type iter2;
typedef state2 state;
typedef iter2 iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template<> struct fold_chunk<3>
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef First iter0;
typedef State state0;
typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
typedef typename mpl::next<iter0>::type iter1;
typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
typedef typename mpl::next<iter1>::type iter2;
typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
typedef typename mpl::next<iter2>::type iter3;
typedef state3 state;
typedef iter3 iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template<> struct fold_chunk<4>
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef First iter0;
typedef State state0;
typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
typedef typename mpl::next<iter0>::type iter1;
typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
typedef typename mpl::next<iter1>::type iter2;
typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
typedef typename mpl::next<iter2>::type iter3;
typedef typename apply2< ForwardOp, state3, typename deref<iter3>::type >::type state4;
typedef typename mpl::next<iter3>::type iter4;
typedef state4 state;
typedef iter4 iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template< int N >
struct fold_chunk
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef fold_impl<
4
, First
, Last
, State
, ForwardOp
> chunk_;
typedef fold_impl<
( (N - 4) < 0 ? 0 : N - 4 )
, typename chunk_::iterator
, Last
, typename chunk_::state
, ForwardOp
> res_;
typedef typename res_::state state;
typedef typename res_::iterator iterator;
};
};
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct fold_step;
template<
typename Last
, typename State
>
struct fold_null_step
{
typedef Last iterator;
typedef State state;
};
template<>
struct fold_chunk< -1 >
{
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct result_
{
typedef typename if_<
typename is_same< First,Last >::type
, fold_null_step< Last,State >
, fold_step< First,Last,State,ForwardOp >
>::type res_;
typedef typename res_::state state;
typedef typename res_::iterator iterator;
};
/// ETI workaround
template<> struct result_< int,int,int,int >
{
typedef int state;
typedef int iterator;
};
};
template<
typename First
, typename Last
, typename State
, typename ForwardOp
>
struct fold_step
{
typedef fold_chunk< -1 >::template result_<
typename mpl::next<First>::type
, Last
, typename apply2<ForwardOp,State, typename deref<First>::type>::type
, ForwardOp
> chunk_;
typedef typename chunk_::state state;
typedef typename chunk_::iterator iterator;
};
template<
int N
, typename First
, typename Last
, typename State
, typename ForwardOp
>
struct fold_impl
: fold_chunk<N>
::template result_< First,Last,State,ForwardOp >
{
};
}}}
@@ -0,0 +1,39 @@
#ifndef BOOST_MPL_AUX_ARITY_HPP_INCLUDED
#define BOOST_MPL_AUX_ARITY_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2001-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/mpl/aux_/config/dtp.hpp>
#if defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
# include <boost/mpl/aux_/nttp_decl.hpp>
# include <boost/mpl/aux_/config/static_constant.hpp>
namespace boost { namespace mpl { namespace aux {
// agurt, 15/mar/02: it's possible to implement the template so that it will
// "just work" and do not require any specialization, but not on the compilers
// that require the arity workaround in the first place
template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
struct arity
{
BOOST_STATIC_CONSTANT(int, value = N);
};
}}}
#endif // BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES
#endif // BOOST_MPL_AUX_ARITY_HPP_INCLUDED
@@ -0,0 +1,214 @@
// (C) Copyright John Maddock 2005.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MATH_COMPLEX_ATANH_INCLUDED
#define BOOST_MATH_COMPLEX_ATANH_INCLUDED
#ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
# include <boost/math/complex/details.hpp>
#endif
#ifndef BOOST_MATH_LOG1P_INCLUDED
# include <boost/math/special_functions/log1p.hpp>
#endif
#include <boost/assert.hpp>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::sqrt; using ::fabs; using ::acos; using ::asin; using ::atan; using ::atan2; }
#endif
namespace boost{ namespace math{
template<class T>
std::complex<T> atanh(const std::complex<T>& z)
{
//
// References:
//
// Eric W. Weisstein. "Inverse Hyperbolic Tangent."
// From MathWorld--A Wolfram Web Resource.
// http://mathworld.wolfram.com/InverseHyperbolicTangent.html
//
// Also: The Wolfram Functions Site,
// http://functions.wolfram.com/ElementaryFunctions/ArcTanh/
//
// Also "Abramowitz and Stegun. Handbook of Mathematical Functions."
// at : http://jove.prohosting.com/~skripty/toc.htm
//
// See also: https://svn.boost.org/trac/boost/ticket/7291
//
static const T pi = boost::math::constants::pi<T>();
static const T half_pi = pi / 2;
static const T one = static_cast<T>(1.0L);
static const T two = static_cast<T>(2.0L);
static const T four = static_cast<T>(4.0L);
static const T zero = static_cast<T>(0);
static const T log_two = boost::math::constants::ln_two<T>();
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127)
#endif
T x = std::fabs(z.real());
T y = std::fabs(z.imag());
T real, imag; // our results
T safe_upper = detail::safe_max(two);
T safe_lower = detail::safe_min(static_cast<T>(2));
//
// Begin by handling the special cases specified in C99:
//
if((boost::math::isnan)(x))
{
if((boost::math::isnan)(y))
return std::complex<T>(x, x);
else if((boost::math::isinf)(y))
return std::complex<T>(0, ((boost::math::signbit)(z.imag()) ? -half_pi : half_pi));
else
return std::complex<T>(x, x);
}
else if((boost::math::isnan)(y))
{
if(x == 0)
return std::complex<T>(x, y);
if((boost::math::isinf)(x))
return std::complex<T>(0, y);
else
return std::complex<T>(y, y);
}
else if((x > safe_lower) && (x < safe_upper) && (y > safe_lower) && (y < safe_upper))
{
T yy = y*y;
T mxm1 = one - x;
///
// The real part is given by:
//
// real(atanh(z)) == log1p(4*x / ((x-1)*(x-1) + y^2))
//
real = boost::math::log1p(four * x / (mxm1*mxm1 + yy));
real /= four;
if((boost::math::signbit)(z.real()))
real = (boost::math::changesign)(real);
imag = std::atan2((y * two), (mxm1*(one+x) - yy));
imag /= two;
if(z.imag() < 0)
imag = (boost::math::changesign)(imag);
}
else
{
//
// This section handles exception cases that would normally cause
// underflow or overflow in the main formulas.
//
// Begin by working out the real part, we need to approximate
// real = boost::math::log1p(4x / ((x-1)^2 + y^2))
// without either overflow or underflow in the squared terms.
//
T mxm1 = one - x;
if(x >= safe_upper)
{
// x-1 = x to machine precision:
if((boost::math::isinf)(x) || (boost::math::isinf)(y))
{
real = 0;
}
else if(y >= safe_upper)
{
// Big x and y: divide through by x*y:
real = boost::math::log1p((four/y) / (x/y + y/x));
}
else if(y > one)
{
// Big x: divide through by x:
real = boost::math::log1p(four / (x + y*y/x));
}
else
{
// Big x small y, as above but neglect y^2/x:
real = boost::math::log1p(four/x);
}
}
else if(y >= safe_upper)
{
if(x > one)
{
// Big y, medium x, divide through by y:
real = boost::math::log1p((four*x/y) / (y + mxm1*mxm1/y));
}
else
{
// Small or medium x, large y:
real = four*x/y/y;
}
}
else if (x != one)
{
// y is small, calculate divisor carefully:
T div = mxm1*mxm1;
if(y > safe_lower)
div += y*y;
real = boost::math::log1p(four*x/div);
}
else
real = boost::math::changesign(two * (std::log(y) - log_two));
real /= four;
if((boost::math::signbit)(z.real()))
real = (boost::math::changesign)(real);
//
// Now handle imaginary part, this is much easier,
// if x or y are large, then the formula:
// atan2(2y, (1-x)*(1+x) - y^2)
// evaluates to +-(PI - theta) where theta is negligible compared to PI.
//
if((x >= safe_upper) || (y >= safe_upper))
{
imag = pi;
}
else if(x <= safe_lower)
{
//
// If both x and y are small then atan(2y),
// otherwise just x^2 is negligible in the divisor:
//
if(y <= safe_lower)
imag = std::atan2(two*y, one);
else
{
if((y == zero) && (x == zero))
imag = 0;
else
imag = std::atan2(two*y, one - y*y);
}
}
else
{
//
// y^2 is negligible:
//
if((y == zero) && (x == one))
imag = 0;
else
imag = std::atan2(two*y, mxm1*(one+x));
}
imag /= two;
if((boost::math::signbit)(z.imag()))
imag = (boost::math::changesign)(imag);
}
return std::complex<T>(real, imag);
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}
} } // namespaces
#endif // BOOST_MATH_COMPLEX_ATANH_INCLUDED
@@ -0,0 +1,105 @@
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
// 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/expr_if.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/cat.hpp>
#if !defined(AUX778076_COUNT_ARGS_PARAM_NAME)
# define AUX778076_COUNT_ARGS_PARAM_NAME T
#endif
#if !defined(AUX778076_COUNT_ARGS_TEMPLATE_PARAM)
# define AUX778076_COUNT_ARGS_TEMPLATE_PARAM typename AUX778076_COUNT_ARGS_PARAM_NAME
#endif
// local macros, #undef-ined at the end of the header
#if !defined(AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES)
# include <boost/mpl/aux_/preprocessor/repeat.hpp>
# include <boost/mpl/aux_/preprocessor/params.hpp>
# define AUX778076_COUNT_ARGS_REPEAT BOOST_MPL_PP_REPEAT
# define AUX778076_COUNT_ARGS_PARAMS(param) \
BOOST_MPL_PP_PARAMS( \
AUX778076_COUNT_ARGS_ARITY \
, param \
) \
/**/
#else
# include <boost/preprocessor/enum_shifted_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/inc.hpp>
# define AUX778076_COUNT_ARGS_REPEAT BOOST_PP_REPEAT
# define AUX778076_COUNT_ARGS_PARAMS(param) \
BOOST_PP_ENUM_SHIFTED_PARAMS( \
BOOST_PP_INC(AUX778076_COUNT_ARGS_ARITY) \
, param \
) \
/**/
#endif // AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
#define AUX778076_IS_ARG_TEMPLATE_NAME \
BOOST_PP_CAT(is_,BOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_arg)) \
/**/
#define AUX778076_COUNT_ARGS_FUNC(unused, i, param) \
BOOST_PP_EXPR_IF(i, +) \
AUX778076_IS_ARG_TEMPLATE_NAME<BOOST_PP_CAT(param,BOOST_PP_INC(i))>::value \
/**/
// is_<xxx>_arg
template< AUX778076_COUNT_ARGS_TEMPLATE_PARAM >
struct AUX778076_IS_ARG_TEMPLATE_NAME
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct AUX778076_IS_ARG_TEMPLATE_NAME<AUX778076_COUNT_ARGS_DEFAULT>
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
// <xxx>_count_args
template<
AUX778076_COUNT_ARGS_PARAMS(AUX778076_COUNT_ARGS_TEMPLATE_PARAM)
>
struct BOOST_PP_CAT(AUX778076_COUNT_ARGS_PREFIX,_count_args)
{
BOOST_STATIC_CONSTANT(int, value = AUX778076_COUNT_ARGS_REPEAT(
AUX778076_COUNT_ARGS_ARITY
, AUX778076_COUNT_ARGS_FUNC
, AUX778076_COUNT_ARGS_PARAM_NAME
));
};
#undef AUX778076_COUNT_ARGS_FUNC
#undef AUX778076_IS_ARG_TEMPLATE_NAME
#undef AUX778076_COUNT_ARGS_PARAMS
#undef AUX778076_COUNT_ARGS_REPEAT
#undef AUX778076_COUNT_ARGS_ARITY
#undef AUX778076_COUNT_ARGS_DEFAULT
#undef AUX778076_COUNT_ARGS_PREFIX
#undef AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
#undef AUX778076_COUNT_ARGS_TEMPLATE_PARAM
#undef AUX778076_COUNT_ARGS_PARAM_NAME
@@ -0,0 +1,634 @@
// Copyright 2014 Marco Guazzone (marco.guazzone@gmail.com)
//
// 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 module implements the Hyper-Exponential distribution.
//
// References:
// - "Queueing Theory in Manufacturing Systems Analysis and Design" by H.T. Papadopolous, C. Heavey and J. Browne (Chapman & Hall/CRC, 1993)
// - http://reference.wolfram.com/language/ref/HyperexponentialDistribution.html
// - http://en.wikipedia.org/wiki/Hyperexponential_distribution
//
#ifndef BOOST_MATH_DISTRIBUTIONS_HYPEREXPONENTIAL_HPP
#define BOOST_MATH_DISTRIBUTIONS_HYPEREXPONENTIAL_HPP
#include <boost/config.hpp>
#include <boost/math/distributions/complement.hpp>
#include <boost/math/distributions/detail/common_error_handling.hpp>
#include <boost/math/distributions/exponential.hpp>
#include <boost/math/policies/policy.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/tools/precision.hpp>
#include <boost/math/tools/roots.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/type_traits/has_pre_increment.hpp>
#include <cstddef>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <vector>
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
# include <initializer_list>
#endif
#ifdef _MSC_VER
# pragma warning (push)
# pragma warning(disable:4127) // conditional expression is constant
# pragma warning(disable:4389) // '==' : signed/unsigned mismatch in test_tools
#endif // _MSC_VER
namespace boost { namespace math {
namespace detail {
template <typename Dist>
typename Dist::value_type generic_quantile(const Dist& dist, const typename Dist::value_type& p, const typename Dist::value_type& guess, bool comp, const char* function);
} // Namespace detail
template <typename RealT, typename PolicyT>
class hyperexponential_distribution;
namespace /*<unnamed>*/ { namespace hyperexp_detail {
template <typename T>
void normalize(std::vector<T>& v)
{
if(!v.size())
return; // Our error handlers will get this later
const T sum = std::accumulate(v.begin(), v.end(), static_cast<T>(0));
T final_sum = 0;
const typename std::vector<T>::iterator end = --v.end();
for (typename std::vector<T>::iterator it = v.begin();
it != end;
++it)
{
*it /= sum;
final_sum += *it;
}
*end = 1 - final_sum; // avoids round off errors, ensures the probs really do sum to 1.
}
template <typename RealT, typename PolicyT>
bool check_probabilities(char const* function, std::vector<RealT> const& probabilities, RealT* presult, PolicyT const& pol)
{
BOOST_MATH_STD_USING
const std::size_t n = probabilities.size();
RealT sum = 0;
for (std::size_t i = 0; i < n; ++i)
{
if (probabilities[i] < 0
|| probabilities[i] > 1
|| !(boost::math::isfinite)(probabilities[i]))
{
*presult = policies::raise_domain_error<RealT>(function,
"The elements of parameter \"probabilities\" must be >= 0 and <= 1, but at least one of them was: %1%.",
probabilities[i],
pol);
return false;
}
sum += probabilities[i];
}
//
// We try to keep phase probabilities correctly normalized in the distribution constructors,
// however in practice we have to allow for a very slight divergence from a sum of exactly 1:
//
if (fabs(sum - 1) > tools::epsilon<RealT>() * 2)
{
*presult = policies::raise_domain_error<RealT>(function,
"The elements of parameter \"probabilities\" must sum to 1, but their sum is: %1%.",
sum,
pol);
return false;
}
return true;
}
template <typename RealT, typename PolicyT>
bool check_rates(char const* function, std::vector<RealT> const& rates, RealT* presult, PolicyT const& pol)
{
const std::size_t n = rates.size();
for (std::size_t i = 0; i < n; ++i)
{
if (rates[i] <= 0
|| !(boost::math::isfinite)(rates[i]))
{
*presult = policies::raise_domain_error<RealT>(function,
"The elements of parameter \"rates\" must be > 0, but at least one of them is: %1%.",
rates[i],
pol);
return false;
}
}
return true;
}
template <typename RealT, typename PolicyT>
bool check_dist(char const* function, std::vector<RealT> const& probabilities, std::vector<RealT> const& rates, RealT* presult, PolicyT const& pol)
{
BOOST_MATH_STD_USING
if (probabilities.size() != rates.size())
{
*presult = policies::raise_domain_error<RealT>(function,
"The parameters \"probabilities\" and \"rates\" must have the same length, but their size differ by: %1%.",
fabs(static_cast<RealT>(probabilities.size())-static_cast<RealT>(rates.size())),
pol);
return false;
}
return check_probabilities(function, probabilities, presult, pol)
&& check_rates(function, rates, presult, pol);
}
template <typename RealT, typename PolicyT>
bool check_x(char const* function, RealT x, RealT* presult, PolicyT const& pol)
{
if (x < 0 || (boost::math::isnan)(x))
{
*presult = policies::raise_domain_error<RealT>(function, "The random variable must be >= 0, but is: %1%.", x, pol);
return false;
}
return true;
}
template <typename RealT, typename PolicyT>
bool check_probability(char const* function, RealT p, RealT* presult, PolicyT const& pol)
{
if (p < 0 || p > 1 || (boost::math::isnan)(p))
{
*presult = policies::raise_domain_error<RealT>(function, "The probability be >= 0 and <= 1, but is: %1%.", p, pol);
return false;
}
return true;
}
template <typename RealT, typename PolicyT>
RealT quantile_impl(hyperexponential_distribution<RealT, PolicyT> const& dist, RealT const& p, bool comp)
{
// Don't have a closed form so try to numerically solve the inverse CDF...
typedef typename policies::evaluation<RealT, PolicyT>::type value_type;
typedef typename policies::normalise<PolicyT,
policies::promote_float<false>,
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
static const char* function = comp ? "boost::math::quantile(const boost::math::complemented2_type<boost::math::hyperexponential_distribution<%1%>, %1%>&)"
: "boost::math::quantile(const boost::math::hyperexponential_distribution<%1%>&, %1%)";
RealT result = 0;
if (!check_probability(function, p, &result, PolicyT()))
{
return result;
}
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
// A possible (but inaccurate) approximation is given below, where the
// quantile is given by the weighted sum of exponential quantiles:
RealT guess = 0;
if (comp)
{
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
guess += probs[i]*quantile(complement(exp, p));
}
}
else
{
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
guess += probs[i]*quantile(exp, p);
}
}
// Fast return in case the Hyper-Exponential is essentially an Exponential
if (n == 1)
{
return guess;
}
value_type q;
q = detail::generic_quantile(hyperexponential_distribution<RealT,forwarding_policy>(probs, rates),
p,
guess,
comp,
function);
result = policies::checked_narrowing_cast<RealT,forwarding_policy>(q, function);
return result;
}
}} // Namespace <unnamed>::hyperexp_detail
template <typename RealT = double, typename PolicyT = policies::policy<> >
class hyperexponential_distribution
{
public: typedef RealT value_type;
public: typedef PolicyT policy_type;
public: hyperexponential_distribution()
: probs_(1, 1),
rates_(1, 1)
{
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
// Four arg constructor: no ambiguity here, the arguments must be two pairs of iterators:
public: template <typename ProbIterT, typename RateIterT>
hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last,
RateIterT rate_first, RateIterT rate_last)
: probs_(prob_first, prob_last),
rates_(rate_first, rate_last)
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
// Two arg constructor from 2 ranges, we SFINAE this out of existance if
// either argument type is incrementable as in that case the type is
// probably an iterator:
public: template <typename ProbRangeT, typename RateRangeT>
hyperexponential_distribution(ProbRangeT const& prob_range,
RateRangeT const& rate_range,
typename boost::disable_if_c<boost::has_pre_increment<ProbRangeT>::value || boost::has_pre_increment<RateRangeT>::value>::type* = 0)
: probs_(boost::begin(prob_range), boost::end(prob_range)),
rates_(boost::begin(rate_range), boost::end(rate_range))
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
// Two arg constructor for a pair of iterators: we SFINAE this out of
// existance if neither argument types are incrementable.
// Note that we allow different argument types here to allow for
// construction from an array plus a pointer into that array.
public: template <typename RateIterT, typename RateIterT2>
hyperexponential_distribution(RateIterT const& rate_first,
RateIterT2 const& rate_last,
typename boost::enable_if_c<boost::has_pre_increment<RateIterT>::value || boost::has_pre_increment<RateIterT2>::value>::type* = 0)
: probs_(std::distance(rate_first, rate_last), 1), // will be normalized below
rates_(rate_first, rate_last)
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
// Initializer list constructor: allows for construction from array literals:
public: hyperexponential_distribution(std::initializer_list<RealT> l1, std::initializer_list<RealT> l2)
: probs_(l1.begin(), l1.end()),
rates_(l2.begin(), l2.end())
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
public: hyperexponential_distribution(std::initializer_list<RealT> l1)
: probs_(l1.size(), 1),
rates_(l1.begin(), l1.end())
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
#endif // !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
// Single argument constructor: argument must be a range.
public: template <typename RateRangeT>
hyperexponential_distribution(RateRangeT const& rate_range)
: probs_(boost::size(rate_range), 1), // will be normalized below
rates_(boost::begin(rate_range), boost::end(rate_range))
{
hyperexp_detail::normalize(probs_);
RealT err;
hyperexp_detail::check_dist("boost::math::hyperexponential_distribution<%1%>::hyperexponential_distribution",
probs_,
rates_,
&err,
PolicyT());
}
public: std::vector<RealT> probabilities() const
{
return probs_;
}
public: std::vector<RealT> rates() const
{
return rates_;
}
public: std::size_t num_phases() const
{
return rates_.size();
}
private: std::vector<RealT> probs_;
private: std::vector<RealT> rates_;
}; // class hyperexponential_distribution
// Convenient type synonym for double.
typedef hyperexponential_distribution<double> hyperexponential;
// Range of permissible values for random variable x
template <typename RealT, typename PolicyT>
std::pair<RealT,RealT> range(hyperexponential_distribution<RealT,PolicyT> const&)
{
if (std::numeric_limits<RealT>::has_infinity)
{
return std::make_pair(static_cast<RealT>(0), std::numeric_limits<RealT>::infinity()); // 0 to +inf.
}
return std::make_pair(static_cast<RealT>(0), tools::max_value<RealT>()); // 0 to +<max value>
}
// 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.
template <typename RealT, typename PolicyT>
std::pair<RealT,RealT> support(hyperexponential_distribution<RealT,PolicyT> const&)
{
return std::make_pair(tools::min_value<RealT>(), tools::max_value<RealT>()); // <min value> to +<max value>.
}
template <typename RealT, typename PolicyT>
RealT pdf(hyperexponential_distribution<RealT, PolicyT> const& dist, RealT const& x)
{
BOOST_MATH_STD_USING
RealT result = 0;
if (!hyperexp_detail::check_x("boost::math::pdf(const boost::math::hyperexponential_distribution<%1%>&, %1%)", x, &result, PolicyT()))
{
return result;
}
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
result += probs[i]*pdf(exp, x);
//result += probs[i]*rates[i]*exp(-rates[i]*x);
}
return result;
}
template <typename RealT, typename PolicyT>
RealT cdf(hyperexponential_distribution<RealT, PolicyT> const& dist, RealT const& x)
{
RealT result = 0;
if (!hyperexp_detail::check_x("boost::math::cdf(const boost::math::hyperexponential_distribution<%1%>&, %1%)", x, &result, PolicyT()))
{
return result;
}
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
result += probs[i]*cdf(exp, x);
}
return result;
}
template <typename RealT, typename PolicyT>
RealT quantile(hyperexponential_distribution<RealT, PolicyT> const& dist, RealT const& p)
{
return hyperexp_detail::quantile_impl(dist, p , false);
}
template <typename RealT, typename PolicyT>
RealT cdf(complemented2_type<hyperexponential_distribution<RealT,PolicyT>, RealT> const& c)
{
RealT const& x = c.param;
hyperexponential_distribution<RealT,PolicyT> const& dist = c.dist;
RealT result = 0;
if (!hyperexp_detail::check_x("boost::math::cdf(boost::math::complemented2_type<const boost::math::hyperexponential_distribution<%1%>&, %1%>)", x, &result, PolicyT()))
{
return result;
}
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
result += probs[i]*cdf(complement(exp, x));
}
return result;
}
template <typename RealT, typename PolicyT>
RealT quantile(complemented2_type<hyperexponential_distribution<RealT, PolicyT>, RealT> const& c)
{
RealT const& p = c.param;
hyperexponential_distribution<RealT,PolicyT> const& dist = c.dist;
return hyperexp_detail::quantile_impl(dist, p , true);
}
template <typename RealT, typename PolicyT>
RealT mean(hyperexponential_distribution<RealT, PolicyT> const& dist)
{
RealT result = 0;
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
for (std::size_t i = 0; i < n; ++i)
{
const exponential_distribution<RealT,PolicyT> exp(rates[i]);
result += probs[i]*mean(exp);
}
return result;
}
template <typename RealT, typename PolicyT>
RealT variance(hyperexponential_distribution<RealT, PolicyT> const& dist)
{
RealT result = 0;
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
for (std::size_t i = 0; i < n; ++i)
{
result += probs[i]/(rates[i]*rates[i]);
}
const RealT mean = boost::math::mean(dist);
result = 2*result-mean*mean;
return result;
}
template <typename RealT, typename PolicyT>
RealT skewness(hyperexponential_distribution<RealT,PolicyT> const& dist)
{
BOOST_MATH_STD_USING
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
RealT s1 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i}
RealT s2 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i^2}
RealT s3 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i^3}
for (std::size_t i = 0; i < n; ++i)
{
const RealT p = probs[i];
const RealT r = rates[i];
const RealT r2 = r*r;
const RealT r3 = r2*r;
s1 += p/r;
s2 += p/r2;
s3 += p/r3;
}
const RealT s1s1 = s1*s1;
const RealT num = (6*s3 - (3*(2*s2 - s1s1) + s1s1)*s1);
const RealT den = (2*s2 - s1s1);
return num / pow(den, static_cast<RealT>(1.5));
}
template <typename RealT, typename PolicyT>
RealT kurtosis(hyperexponential_distribution<RealT,PolicyT> const& dist)
{
const std::size_t n = dist.num_phases();
const std::vector<RealT> probs = dist.probabilities();
const std::vector<RealT> rates = dist.rates();
RealT s1 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i}
RealT s2 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i^2}
RealT s3 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i^3}
RealT s4 = 0; // \sum_{i=1}^n \frac{p_i}{\lambda_i^4}
for (std::size_t i = 0; i < n; ++i)
{
const RealT p = probs[i];
const RealT r = rates[i];
const RealT r2 = r*r;
const RealT r3 = r2*r;
const RealT r4 = r3*r;
s1 += p/r;
s2 += p/r2;
s3 += p/r3;
s4 += p/r4;
}
const RealT s1s1 = s1*s1;
const RealT num = (24*s4 - 24*s3*s1 + 3*(2*(2*s2 - s1s1) + s1s1)*s1s1);
const RealT den = (2*s2 - s1s1);
return num/(den*den);
}
template <typename RealT, typename PolicyT>
RealT kurtosis_excess(hyperexponential_distribution<RealT,PolicyT> const& dist)
{
return kurtosis(dist) - 3;
}
template <typename RealT, typename PolicyT>
RealT mode(hyperexponential_distribution<RealT,PolicyT> const& /*dist*/)
{
return 0;
}
}} // namespace boost::math
#ifdef BOOST_MSVC
#pragma warning (pop)
#endif
// 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>
#include <boost/math/distributions/detail/generic_quantile.hpp>
#endif // BOOST_MATH_DISTRIBUTIONS_HYPEREXPONENTIAL
@@ -0,0 +1,223 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
This is an auto-generated file. Do not edit!
==============================================================================*/
namespace boost { namespace fusion { namespace detail
{
BOOST_FUSION_BARRIER_BEGIN
template <>
struct as_vector<1>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1;
typedef typename fusion::result_of::value_of<I0>::type T0;
typedef vector1<T0> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
return result(*i0);
}
};
template <>
struct as_vector<2>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1;
typedef vector2<T0 , T1> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0);
return result(*i0 , *i1);
}
};
template <>
struct as_vector<3>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2;
typedef vector3<T0 , T1 , T2> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1);
return result(*i0 , *i1 , *i2);
}
};
template <>
struct as_vector<4>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3;
typedef vector4<T0 , T1 , T2 , T3> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2);
return result(*i0 , *i1 , *i2 , *i3);
}
};
template <>
struct as_vector<5>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4;
typedef vector5<T0 , T1 , T2 , T3 , T4> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3);
return result(*i0 , *i1 , *i2 , *i3 , *i4);
}
};
template <>
struct as_vector<6>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5; typedef typename fusion::result_of::next<I5>::type I6;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4; typedef typename fusion::result_of::value_of<I5>::type T5;
typedef vector6<T0 , T1 , T2 , T3 , T4 , T5> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3); typename gen::I5 i5 = fusion::next(i4);
return result(*i0 , *i1 , *i2 , *i3 , *i4 , *i5);
}
};
template <>
struct as_vector<7>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5; typedef typename fusion::result_of::next<I5>::type I6; typedef typename fusion::result_of::next<I6>::type I7;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4; typedef typename fusion::result_of::value_of<I5>::type T5; typedef typename fusion::result_of::value_of<I6>::type T6;
typedef vector7<T0 , T1 , T2 , T3 , T4 , T5 , T6> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3); typename gen::I5 i5 = fusion::next(i4); typename gen::I6 i6 = fusion::next(i5);
return result(*i0 , *i1 , *i2 , *i3 , *i4 , *i5 , *i6);
}
};
template <>
struct as_vector<8>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5; typedef typename fusion::result_of::next<I5>::type I6; typedef typename fusion::result_of::next<I6>::type I7; typedef typename fusion::result_of::next<I7>::type I8;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4; typedef typename fusion::result_of::value_of<I5>::type T5; typedef typename fusion::result_of::value_of<I6>::type T6; typedef typename fusion::result_of::value_of<I7>::type T7;
typedef vector8<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3); typename gen::I5 i5 = fusion::next(i4); typename gen::I6 i6 = fusion::next(i5); typename gen::I7 i7 = fusion::next(i6);
return result(*i0 , *i1 , *i2 , *i3 , *i4 , *i5 , *i6 , *i7);
}
};
template <>
struct as_vector<9>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5; typedef typename fusion::result_of::next<I5>::type I6; typedef typename fusion::result_of::next<I6>::type I7; typedef typename fusion::result_of::next<I7>::type I8; typedef typename fusion::result_of::next<I8>::type I9;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4; typedef typename fusion::result_of::value_of<I5>::type T5; typedef typename fusion::result_of::value_of<I6>::type T6; typedef typename fusion::result_of::value_of<I7>::type T7; typedef typename fusion::result_of::value_of<I8>::type T8;
typedef vector9<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3); typename gen::I5 i5 = fusion::next(i4); typename gen::I6 i6 = fusion::next(i5); typename gen::I7 i7 = fusion::next(i6); typename gen::I8 i8 = fusion::next(i7);
return result(*i0 , *i1 , *i2 , *i3 , *i4 , *i5 , *i6 , *i7 , *i8);
}
};
template <>
struct as_vector<10>
{
template <typename I0>
struct apply
{
typedef typename fusion::result_of::next<I0>::type I1; typedef typename fusion::result_of::next<I1>::type I2; typedef typename fusion::result_of::next<I2>::type I3; typedef typename fusion::result_of::next<I3>::type I4; typedef typename fusion::result_of::next<I4>::type I5; typedef typename fusion::result_of::next<I5>::type I6; typedef typename fusion::result_of::next<I6>::type I7; typedef typename fusion::result_of::next<I7>::type I8; typedef typename fusion::result_of::next<I8>::type I9; typedef typename fusion::result_of::next<I9>::type I10;
typedef typename fusion::result_of::value_of<I0>::type T0; typedef typename fusion::result_of::value_of<I1>::type T1; typedef typename fusion::result_of::value_of<I2>::type T2; typedef typename fusion::result_of::value_of<I3>::type T3; typedef typename fusion::result_of::value_of<I4>::type T4; typedef typename fusion::result_of::value_of<I5>::type T5; typedef typename fusion::result_of::value_of<I6>::type T6; typedef typename fusion::result_of::value_of<I7>::type T7; typedef typename fusion::result_of::value_of<I8>::type T8; typedef typename fusion::result_of::value_of<I9>::type T9;
typedef vector10<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9> type;
};
template <typename Iterator>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static typename apply<Iterator>::type
call(Iterator const& i0)
{
typedef apply<Iterator> gen;
typedef typename gen::type result;
typename gen::I1 i1 = fusion::next(i0); typename gen::I2 i2 = fusion::next(i1); typename gen::I3 i3 = fusion::next(i2); typename gen::I4 i4 = fusion::next(i3); typename gen::I5 i5 = fusion::next(i4); typename gen::I6 i6 = fusion::next(i5); typename gen::I7 i7 = fusion::next(i6); typename gen::I8 i8 = fusion::next(i7); typename gen::I9 i9 = fusion::next(i8);
return result(*i0 , *i1 , *i2 , *i3 , *i4 , *i5 , *i6 , *i7 , *i8 , *i9);
}
};
BOOST_FUSION_BARRIER_END
}}}
@@ -0,0 +1,87 @@
//////////////////////////////////////////////////////////////////////////////
//
// (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_DETAIL_SPIN_MUTEX_HPP
#define BOOST_INTERPROCESS_DETAIL_SPIN_MUTEX_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/detail/posix_time_types_wrk.hpp>
#include <boost/assert.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/cstdint.hpp>
#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <boost/interprocess/sync/detail/common_algorithms.hpp>
namespace boost {
namespace interprocess {
namespace ipcdetail {
class spin_mutex
{
spin_mutex(const spin_mutex &);
spin_mutex &operator=(const spin_mutex &);
public:
spin_mutex();
~spin_mutex();
void lock();
bool try_lock();
bool timed_lock(const boost::posix_time::ptime &abs_time);
void unlock();
void take_ownership(){};
private:
volatile boost::uint32_t m_s;
};
inline spin_mutex::spin_mutex()
: m_s(0)
{
//Note that this class is initialized to zero.
//So zeroed memory can be interpreted as an
//initialized mutex
}
inline spin_mutex::~spin_mutex()
{
//Trivial destructor
}
inline void spin_mutex::lock(void)
{ return ipcdetail::try_based_lock(*this); }
inline bool spin_mutex::try_lock(void)
{
boost::uint32_t prev_s = ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0);
return m_s == 1 && prev_s == 0;
}
inline bool spin_mutex::timed_lock(const boost::posix_time::ptime &abs_time)
{ return ipcdetail::try_based_timed_lock(*this, abs_time); }
inline void spin_mutex::unlock(void)
{ ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 0, 1); }
} //namespace ipcdetail {
} //namespace interprocess {
} //namespace boost {
#include <boost/interprocess/detail/config_end.hpp>
#endif //BOOST_INTERPROCESS_DETAIL_SPIN_MUTEX_HPP
@@ -0,0 +1,194 @@
// scoped_enum.hpp ---------------------------------------------------------//
// Copyright Beman Dawes, 2009
// Copyright (C) 2011-2012 Vicente J. Botet Escriba
// Copyright (C) 2012 Anthony Williams
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_CORE_SCOPED_ENUM_HPP
#define BOOST_CORE_SCOPED_ENUM_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost
{
#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
/**
* Meta-function to get the native enum type associated to an enum class or its emulation.
*/
template <typename EnumType>
struct native_type
{
/**
* The member typedef type names the native enum type associated to the scoped enum,
* which is it self if the compiler supports scoped enums or EnumType::enum_type if it is an emulated scoped enum.
*/
typedef typename EnumType::enum_type type;
};
/**
* Casts a scoped enum to its underlying type.
*
* This function is useful when working with scoped enum classes, which doens't implicitly convert to the underlying type.
* @param v A scoped enum.
* @returns The underlying type.
* @throws No-throws.
*/
template <typename UnderlyingType, typename EnumType>
inline
BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT
{
return v.get_underlying_value_();
}
/**
* Casts a scoped enum to its native enum type.
*
* This function is useful to make programs portable when the scoped enum emulation can not be use where native enums can.
*
* EnumType the scoped enum type
*
* @param v A scoped enum.
* @returns The native enum value.
* @throws No-throws.
*/
template <typename EnumType>
inline
BOOST_CONSTEXPR typename EnumType::enum_type native_value(EnumType e) BOOST_NOEXCEPT
{
return e.get_native_value_();
}
#else // BOOST_NO_CXX11_SCOPED_ENUMS
template <typename EnumType>
struct native_type
{
typedef EnumType type;
};
template <typename UnderlyingType, typename EnumType>
inline
BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT
{
return static_cast<UnderlyingType>(v);
}
template <typename EnumType>
inline
BOOST_CONSTEXPR EnumType native_value(EnumType e) BOOST_NOEXCEPT
{
return e;
}
#endif // BOOST_NO_CXX11_SCOPED_ENUMS
}
#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
explicit BOOST_CONSTEXPR operator underlying_type() const BOOST_NOEXCEPT { return get_underlying_value_(); }
#else
#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR
#endif
/**
* Start a declaration of a scoped enum.
*
* @param EnumType The new scoped enum.
* @param UnderlyingType The underlying type.
*/
#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType, UnderlyingType) \
struct EnumType { \
typedef void is_boost_scoped_enum_tag; \
typedef UnderlyingType underlying_type; \
EnumType() BOOST_NOEXCEPT {} \
explicit BOOST_CONSTEXPR EnumType(underlying_type v) BOOST_NOEXCEPT : v_(v) {} \
BOOST_CONSTEXPR underlying_type get_underlying_value_() const BOOST_NOEXCEPT { return v_; } \
BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
private: \
underlying_type v_; \
typedef EnumType self_type; \
public: \
enum enum_type
#define BOOST_SCOPED_ENUM_DECLARE_END2() \
BOOST_CONSTEXPR enum_type get_native_value_() const BOOST_NOEXCEPT { return enum_type(v_); } \
friend BOOST_CONSTEXPR bool operator ==(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator ==(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==rhs; } \
friend BOOST_CONSTEXPR bool operator ==(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs==enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator !=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator !=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=rhs; } \
friend BOOST_CONSTEXPR bool operator !=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs!=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<rhs; } \
friend BOOST_CONSTEXPR bool operator <(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=rhs; } \
friend BOOST_CONSTEXPR bool operator <=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>rhs; } \
friend BOOST_CONSTEXPR bool operator >(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=rhs; } \
friend BOOST_CONSTEXPR bool operator >=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>=enum_type(rhs.v_); } \
};
#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) \
; \
BOOST_CONSTEXPR EnumType(enum_type v) BOOST_NOEXCEPT : v_(v) {} \
BOOST_SCOPED_ENUM_DECLARE_END2()
/**
* Starts a declaration of a scoped enum with the default int underlying type.
*
* @param EnumType The new scoped enum.
*/
#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) \
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,int)
/**
* Name of the native enum type.
*
* @param EnumType The new scoped enum.
*/
#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType::enum_type
/**
* Forward declares an scoped enum.
*
* @param EnumType The scoped enum.
*/
#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) struct EnumType
#else // BOOST_NO_CXX11_SCOPED_ENUMS
#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,UnderlyingType) enum class EnumType : UnderlyingType
#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) enum class EnumType
#define BOOST_SCOPED_ENUM_DECLARE_END2()
#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) ;
#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType
#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) enum class EnumType
#endif // BOOST_NO_CXX11_SCOPED_ENUMS
// Deprecated macros
#define BOOST_SCOPED_ENUM_START(name) BOOST_SCOPED_ENUM_DECLARE_BEGIN(name)
#define BOOST_SCOPED_ENUM_END BOOST_SCOPED_ENUM_DECLARE_END2()
#define BOOST_SCOPED_ENUM(name) BOOST_SCOPED_ENUM_NATIVE(name)
#endif // BOOST_CORE_SCOPED_ENUM_HPP
@@ -0,0 +1,133 @@
// 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)
//
// Preprocessed version of "boost/mpl/times.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl {
template<
typename Tag1
, typename Tag2
>
struct times_impl
: if_c<
( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
> BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
)
, aux::cast2nd_impl< times_impl< Tag1,Tag1 >,Tag1, Tag2 >
, aux::cast1st_impl< times_impl< Tag2,Tag2 >,Tag1, Tag2 >
>::type
{
};
/// for Digital Mars C++/compilers with no CTPS/TTP support
template<> struct times_impl< na,na >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template<> struct times_impl< na,integral_c_tag >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template<> struct times_impl< integral_c_tag,na >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template< typename T > struct times_tag
{
typedef typename T::tag type;
};
/// forward declaration
template<
typename BOOST_MPL_AUX_NA_PARAM(N1)
, typename BOOST_MPL_AUX_NA_PARAM(N2)
>
struct times2;
template<
typename BOOST_MPL_AUX_NA_PARAM(N1)
, typename BOOST_MPL_AUX_NA_PARAM(N2)
, typename N3 = na, typename N4 = na, typename N5 = na
>
struct times
: if_<
is_na<N3>
, times2< N1,N2 >
, times<
times2< N1,N2 >
, N3, N4, N5
>
>::type
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(
5
, times
, ( N1, N2, N3, N4, N5 )
)
};
template<
typename N1
, typename N2
>
struct times2
: times_impl<
typename times_tag<N1>::type
, typename times_tag<N2>::type
>::template apply< N1,N2 >::type
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, times2, (N1, N2))
};
BOOST_MPL_AUX_NA_SPEC2(2, 5, times)
}}
namespace boost { namespace mpl {
template<>
struct times_impl< integral_c_tag,integral_c_tag >
{
template< typename N1, typename N2 > struct apply
: integral_c<
typename aux::largest_int<
typename N1::value_type
, typename N2::value_type
>::type
, ( BOOST_MPL_AUX_VALUE_WKND(N1)::value
* BOOST_MPL_AUX_VALUE_WKND(N2)::value
)
>
{
};
};
}}
@@ -0,0 +1,278 @@
/*==============================================================================
Copyright (c) 2005-2010 Joel de Guzman
Copyright (c) 2010 Thomas Heller
Copyright (c) 2016 Kohei Takahashi
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 This, typename A0 , typename A1, typename Context>
struct result<This(A0 , A1, Context)>
: result<This(A0 const& , A1 const&, Context)>
{};
template <typename This, typename A0 , typename A1, typename Context>
struct result<This(A0 & , A1 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1>
{};
template <typename A0 , typename A1, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1>::type
operator()(
A0 const& a0 , A1 const& a1
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
);
}
template <typename This, typename A0 , typename A1 , typename A2, typename Context>
struct result<This(A0 , A1 , A2, Context)>
: result<This(A0 const& , A1 const& , A2 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2, typename Context>
struct result<This(A0 & , A1 & , A2 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2>
{};
template <typename A0 , typename A1 , typename A2, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2>::type
operator()(
A0 const& a0 , A1 const& a1 , A2 const& a2
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3, typename Context>
struct result<This(A0 , A1 , A2 , A3, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3>
{};
template <typename A0 , typename A1 , typename A2 , typename A3, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3>::type
operator()(
A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4>
{};
template <typename A0 , typename A1 , typename A2 , typename A3 , typename A4, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4>::type
operator()(
A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4 , A5, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const& , A5 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 & , A5 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5>
{};
template <typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5>::type
operator()(
A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx) , boost::phoenix::eval(a5, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4 , A5 , A6, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const& , A5 const& , A6 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 & , A5 & , A6 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6>
{};
template <typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6>::type
operator()(
A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx) , boost::phoenix::eval(a5, ctx) , boost::phoenix::eval(a6, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const& , A5 const& , A6 const& , A7 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 & , A5 & , A6 & , A7 &, Context)>
: result_of::mem_fun_ptr_eval<Context, 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 Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7>::type
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
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx) , boost::phoenix::eval(a5, ctx) , boost::phoenix::eval(a6, ctx) , boost::phoenix::eval(a7, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const& , A5 const& , A6 const& , A7 const& , A8 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 & , A5 & , A6 & , A7 & , A8 &, Context)>
: result_of::mem_fun_ptr_eval<Context, 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, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8>::type
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
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx) , boost::phoenix::eval(a5, ctx) , boost::phoenix::eval(a6, ctx) , boost::phoenix::eval(a7, ctx) , boost::phoenix::eval(a8, ctx)
);
}
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9, typename Context>
struct result<This(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9, Context)>
: result<This(A0 const& , A1 const& , A2 const& , A3 const& , A4 const& , A5 const& , A6 const& , A7 const& , A8 const& , A9 const&, Context)>
{};
template <typename This, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9, typename Context>
struct result<This(A0 & , A1 & , A2 & , A3 & , A4 & , A5 & , A6 & , A7 & , A8 & , A9 &, Context)>
: result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>
{};
template <typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9, typename Context>
typename result_of::mem_fun_ptr_eval<Context, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>::type
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 , A9 const& a9
, Context const & ctx
) const
{
return
(
get_pointer(boost::phoenix::eval(a0, ctx))
->*boost::phoenix::eval(a1, ctx)
)(
boost::phoenix::eval(a2, ctx) , boost::phoenix::eval(a3, ctx) , boost::phoenix::eval(a4, ctx) , boost::phoenix::eval(a5, ctx) , boost::phoenix::eval(a6, ctx) , boost::phoenix::eval(a7, ctx) , boost::phoenix::eval(a8, ctx) , boost::phoenix::eval(a9, ctx)
);
}
@@ -0,0 +1,110 @@
/* INTIO.C - Routines to read and write integers one byte at a time. */
/* Copyright (c) 1995-2012 by Radford M. Neal.
*
* Permission is granted for anyone to copy, use, modify, and distribute
* these programs and accompanying documents for any purpose, provided
* this copyright notice is retained and prominently displayed, and note
* is made of any changes made to these programs. These programs and
* documents are distributed without any warranty, express or implied.
* As the programs were written for research purposes only, they have not
* been tested to the degree that would be advisable in any important
* application. All use of these programs is entirely at the user's own
* risk.
*/
#include <stdlib.h>
#include <stdio.h>
#include "intio.h"
/* READ AN INTEGER ONE BYTE AT A TIME. Four bytes are read, ordered from
low to high order. These are considered to represent a signed integer,
in two's complement form. The value returned is this integer, converted
to whatever a C "int" is. The conversion should work as long as an "int"
is at least four bytes, even if it's not in two's complement representation
(except for the largest two's complement negative integer).
If an error or eof is encountered, zero is returned. The caller can
check for these events using feof and ferror.
The file read from should have been opened as "binary".
*/
int intio_read
( FILE *f /* File to read from */
)
{
unsigned char b[4];
int top;
int i;
for (i = 0; i<4; i++)
{ if (fread(&b[i],1,1,f) != 1) return 0;
}
top = b[3]>127 ? (int)b[3] - 256 : b[3];
return (top<<24) + (b[2]<<16) + (b[1]<<8) + b[0];
}
/* WRITE AN INTEGER ONE BYTE AT A TIME. Four bytes are written, ordered from
low to high order. These are considered to represent a signed integer,
in two's complement form. This should work as long as the integer passed
can be represented in four bytes, even if a C "int" is longer than this.
The file written to should have been opened as "binary".
*/
void intio_write
( FILE *f, /* File to write to */
int v /* Value to write to file */
)
{
unsigned char b;
int i;
for (i = 0; i<3; i++)
{ b = v&0xff;
fwrite(&b,1,1,f);
v >>= 8;
}
b = v>0 ? v : v+256;
fwrite(&b,1,1,f);
}
/* TEST PROGRAM. */
#ifdef TEST_INTIO
main(void)
{
FILE *f;
f = fopen("test","wb");
intio_write(f,334);
intio_write(f,-40000);
intio_write(f,0x8fffffff);
intio_write(f,-0x8fffffff);
fclose(f);
f = fopen("test","rb");
if (intio_read(f)!=334
|| intio_read(f)!=-40000
|| intio_read(f)!=0x8fffffff
|| intio_read(f)!=-0x8fffffff)
{ fprintf(stderr,"got back bad data\n");
exit(1);
}
if (intio_read(f)!=0 || !feof(f) || ferror(f))
{ fprintf(stderr,"eof not handled correctly\n");
exit(1);
}
fclose(f);
fprintf(stderr,"OK\n");
exit(0);
}
#endif
@@ -0,0 +1,32 @@
JT4 JT9 9+65 JT65 QRA SCAT M144 WSPR Echo
---------------------------------------------------------------------
0. txFirstCheckBox 11 111 1 11 11 11 1
1. TxFreqSpinBox 11 111 1 11 11
2. RxFreqSpinBox 11 111 1 11 11 1
3. sbFtol 1 11 1 11 11 1
4. rptSpinBox 11 111 1 11 11 11 1
5. sbTR 11 1
6. sbCQRxFreq 1
7. cbShMsgs 1 1
8. cbFast9 11
9. cbAutoSeq 1
10. cbTx6 1
11. pbTxMode 1
12. pbR2T 11 11 1 11 11
13. pbT2R 11 11 1 11 11
14. cbTxLock 1 11 1 11 11
15. sbSubMode 1 1 1 11 11
16. syncSpinBox 1 1 1 11 11
17. WSPR_Controls_Widget 1
18. ClrAvgButton 11 1
---------------------------------------------------------------------
19. FastNormalDeep 11 11 1 11 1 1
20. IncludeAveraging 1 1
21. IncludeCorrelation 1 1
22. EchoGraph 1
---------------------------------------------------------------------
For each mode:
Column 1 applies when VHF features is OFF (or col 2 absent)
Column 2 (if present) applies when VHF features is ON
Column 3 (JT9 only) applies for submodes E-H with Fast checked
@@ -0,0 +1,38 @@
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_PARAMS_HPP
# define BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_PARAMS_HPP
#
# include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/repetition/repeat.hpp>
#
# /* BOOST_PP_ENUM_TRAILING_PARAMS */
#
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
# define BOOST_PP_ENUM_TRAILING_PARAMS(count, param) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_TRAILING_PARAMS_M, param)
# else
# define BOOST_PP_ENUM_TRAILING_PARAMS(count, param) BOOST_PP_ENUM_TRAILING_PARAMS_I(count, param)
# define BOOST_PP_ENUM_TRAILING_PARAMS_I(count, param) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_TRAILING_PARAMS_M, param)
# endif
#
# define BOOST_PP_ENUM_TRAILING_PARAMS_M(z, n, param) , param ## n
#
# /* BOOST_PP_ENUM_TRAILING_PARAMS_Z */
#
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
# define BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, count, param) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_TRAILING_PARAMS_M, param)
# else
# define BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, count, param) BOOST_PP_ENUM_TRAILING_PARAMS_Z_I(z, count, param)
# define BOOST_PP_ENUM_TRAILING_PARAMS_Z_I(z, count, param) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_TRAILING_PARAMS_M, param)
# endif
#
# endif
@@ -0,0 +1,45 @@
// np_fwht.h
// Basic implementation of the Fast Walsh-Hadamard Transforms
//
// (c) 2016 - Nico Palermo, IV3NWV - Microtelecom Srl, Italy
// ------------------------------------------------------------------------------
// This file is part of the qracodes project, a Forward Error Control
// encoding/decoding package based on Q-ary RA (repeat and accumulate) LDPC codes.
//
// qracodes 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.
// qracodes 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 qracodes source distribution.
// If not, see <http://www.gnu.org/licenses/>.
#ifndef _npfwht_h_
#define _npfwht_h_
#ifdef __cplusplus
extern "C" {
#endif
void np_fwht(int nlogdim, float *dst, float *src);
// Compute the Walsh-Hadamard transform of the given data up to a
// 64-dimensional transform
//
// Input parameters:
// nlogdim: log2 of the transform size. Must be in the range [0..6]
// src : pointer to the input data buffer.
// dst : pointer to the output data buffer.
//
// src and dst must point to preallocated data buffers of size 2^nlogdim*sizeof(float)
// src and dst buffers can overlap
#ifdef __cplusplus
}
#endif
#endif // _npfwht_
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,207 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2016 Jakub Szuppe <j.szuppe@gmail.com>
//
// 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://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_ON_CPU_HPP
#define BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_ON_CPU_HPP
#include <iterator>
#include <boost/compute/device.hpp>
#include <boost/compute/kernel.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/serial_scan.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/parameter_cache.hpp>
namespace boost {
namespace compute {
namespace detail {
template<class InputIterator, class OutputIterator, class T, class BinaryOperator>
inline OutputIterator scan_on_cpu(InputIterator first,
InputIterator last,
OutputIterator result,
bool exclusive,
T init,
BinaryOperator op,
command_queue &queue)
{
typedef typename
std::iterator_traits<InputIterator>::value_type input_type;
typedef typename
std::iterator_traits<OutputIterator>::value_type output_type;
const context &context = queue.get_context();
const device &device = queue.get_device();
const size_t compute_units = queue.get_device().compute_units();
boost::shared_ptr<parameter_cache> parameters =
detail::parameter_cache::get_global_cache(device);
std::string cache_key =
"__boost_scan_cpu_" + boost::lexical_cast<std::string>(sizeof(T));
// for inputs smaller than serial_scan_threshold
// serial_scan algorithm is used
uint_ serial_scan_threshold =
parameters->get(cache_key, "serial_scan_threshold", 16384 * sizeof(T));
serial_scan_threshold =
(std::max)(serial_scan_threshold, uint_(compute_units));
size_t count = detail::iterator_range_size(first, last);
if(count == 0){
return result;
}
else if(count < serial_scan_threshold) {
return serial_scan(first, last, result, exclusive, init, op, queue);
}
buffer block_partial_sums(context, sizeof(output_type) * compute_units );
// create scan kernel
meta_kernel k("scan_on_cpu_block_scan");
// Arguments
size_t count_arg = k.add_arg<uint_>("count");
size_t init_arg = k.add_arg<output_type>("initial_value");
size_t block_partial_sums_arg =
k.add_arg<output_type *>(memory_object::global_memory, "block_partial_sums");
k <<
"uint block = " <<
"(uint)ceil(((float)count)/(get_global_size(0) + 1));\n" <<
"uint index = get_global_id(0) * block;\n" <<
"uint end = min(count, index + block);\n";
if(!exclusive){
k <<
k.decl<output_type>("sum") << " = " <<
first[k.var<uint_>("index")] << ";\n" <<
result[k.var<uint_>("index")] << " = sum;\n" <<
"index++;\n";
}
else {
k <<
k.decl<output_type>("sum") << ";\n" <<
"if(index == 0){\n" <<
"sum = initial_value;\n" <<
"}\n" <<
"else {\n" <<
"sum = " << first[k.var<uint_>("index")] << ";\n" <<
"index++;\n" <<
"}\n";
}
k <<
"while(index < end){\n" <<
// load next value
k.decl<const input_type>("value") << " = "
<< first[k.var<uint_>("index")] << ";\n";
if(exclusive){
k <<
"if(get_global_id(0) == 0){\n" <<
result[k.var<uint_>("index")] << " = sum;\n" <<
"}\n";
}
k <<
"sum = " << op(k.var<output_type>("sum"),
k.var<output_type>("value")) << ";\n";
if(!exclusive){
k <<
"if(get_global_id(0) == 0){\n" <<
result[k.var<uint_>("index")] << " = sum;\n" <<
"}\n";
}
k <<
"index++;\n" <<
"}\n" << // end while
"block_partial_sums[get_global_id(0)] = sum;\n";
// compile scan kernel
kernel block_scan_kernel = k.compile(context);
// setup kernel arguments
block_scan_kernel.set_arg(count_arg, static_cast<uint_>(count));
block_scan_kernel.set_arg(init_arg, static_cast<output_type>(init));
block_scan_kernel.set_arg(block_partial_sums_arg, block_partial_sums);
// execute the kernel
size_t global_work_size = compute_units;
queue.enqueue_1d_range_kernel(block_scan_kernel, 0, global_work_size, 0);
// scan is done
if(compute_units < 2) {
return result + count;
}
// final scan kernel
meta_kernel l("scan_on_cpu_final_scan");
// Arguments
count_arg = l.add_arg<uint_>("count");
block_partial_sums_arg =
l.add_arg<output_type *>(memory_object::global_memory, "block_partial_sums");
l <<
"uint block = " <<
"(uint)ceil(((float)count)/(get_global_size(0) + 1));\n" <<
"uint index = block + get_global_id(0) * block;\n" <<
"uint end = min(count, index + block);\n" <<
k.decl<output_type>("sum") << " = block_partial_sums[0];\n" <<
"for(uint i = 0; i < get_global_id(0); i++) {\n" <<
"sum = " << op(k.var<output_type>("sum"),
k.var<output_type>("block_partial_sums[i + 1]")) << ";\n" <<
"}\n" <<
"while(index < end){\n";
if(exclusive){
l <<
l.decl<output_type>("value") << " = "
<< first[k.var<uint_>("index")] << ";\n" <<
result[k.var<uint_>("index")] << " = sum;\n" <<
"sum = " << op(k.var<output_type>("sum"),
k.var<output_type>("value")) << ";\n";
}
else {
l <<
"sum = " << op(k.var<output_type>("sum"),
first[k.var<uint_>("index")]) << ";\n" <<
result[k.var<uint_>("index")] << " = sum;\n";
}
l <<
"index++;\n" <<
"}\n";
// compile scan kernel
kernel final_scan_kernel = l.compile(context);
// setup kernel arguments
final_scan_kernel.set_arg(count_arg, static_cast<uint_>(count));
final_scan_kernel.set_arg(block_partial_sums_arg, block_partial_sums);
// execute the kernel
global_work_size = compute_units;
queue.enqueue_1d_range_kernel(final_scan_kernel, 0, global_work_size, 0);
// return iterator pointing to the end of the result range
return result + count;
}
} // end detail namespace
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_ON_CPU_HPP
@@ -0,0 +1,432 @@
// Copyright Peter Dimov 2001
// Copyright Aleksey Gurtovoy 2001-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)
//
// Preprocessed version of "boost/mpl/bind.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl {
namespace aux {
template< bool >
struct resolve_arg_impl
{
template<
typename T, typename U1, typename U2, typename U3
, typename U4, typename U5
>
struct result_
{
typedef T type;
};
};
template<>
struct resolve_arg_impl<true>
{
template<
typename T, typename U1, typename U2, typename U3
, typename U4, typename U5
>
struct result_
{
typedef typename apply_wrap5<
T
, U1, U2, U3, U4, U5
>::type type;
};
};
template< typename T > struct is_bind_template;
template<
typename T, typename U1, typename U2, typename U3, typename U4
, typename U5
>
struct resolve_bind_arg
: resolve_arg_impl< is_bind_template<T>::value >
::template result_< T,U1,U2,U3,U4,U5 >
{
};
template< typename T >
struct replace_unnamed_arg_impl
{
template< typename Arg > struct result_
{
typedef Arg next;
typedef T type;
};
};
template<>
struct replace_unnamed_arg_impl< arg< -1 > >
{
template< typename Arg > struct result_
{
typedef typename next<Arg>::type next;
typedef Arg type;
};
};
template< typename T, typename Arg >
struct replace_unnamed_arg
: replace_unnamed_arg_impl<T>::template result_<Arg>
{
};
template< int arity_ > struct bind_chooser;
aux::no_tag is_bind_helper(...);
template< typename T > aux::no_tag is_bind_helper(protect<T>*);
template< int N >
aux::yes_tag is_bind_helper(arg<N>*);
template< bool is_ref_ = true >
struct is_bind_template_impl
{
template< typename T > struct result_
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template<>
struct is_bind_template_impl<false>
{
template< typename T > struct result_
{
BOOST_STATIC_CONSTANT(bool, value =
sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
};
template< typename T > struct is_bind_template
: is_bind_template_impl< ::boost::detail::is_reference_impl<T>::value >
::template result_<T>
{
};
} // namespace aux
template<
typename F
>
struct bind0
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
public:
typedef typename apply_wrap0<
f_
>::type type;
};
};
namespace aux {
template<
typename F
>
aux::yes_tag
is_bind_helper(bind0<F>*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(1, bind0)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(1, bind0)
template<
typename F, typename T1
>
struct bind1
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
typedef aux::replace_unnamed_arg< T1,n1 > r1;
typedef typename r1::type a1;
typedef typename r1::next n2;
typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
///
public:
typedef typename apply_wrap1<
f_
, typename t1::type
>::type type;
};
};
namespace aux {
template<
typename F, typename T1
>
aux::yes_tag
is_bind_helper(bind1< F,T1 >*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(2, bind1)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(2, bind1)
template<
typename F, typename T1, typename T2
>
struct bind2
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
typedef aux::replace_unnamed_arg< T1,n1 > r1;
typedef typename r1::type a1;
typedef typename r1::next n2;
typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
///
typedef aux::replace_unnamed_arg< T2,n2 > r2;
typedef typename r2::type a2;
typedef typename r2::next n3;
typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
///
public:
typedef typename apply_wrap2<
f_
, typename t1::type, typename t2::type
>::type type;
};
};
namespace aux {
template<
typename F, typename T1, typename T2
>
aux::yes_tag
is_bind_helper(bind2< F,T1,T2 >*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(3, bind2)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(3, bind2)
template<
typename F, typename T1, typename T2, typename T3
>
struct bind3
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
typedef aux::replace_unnamed_arg< T1,n1 > r1;
typedef typename r1::type a1;
typedef typename r1::next n2;
typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
///
typedef aux::replace_unnamed_arg< T2,n2 > r2;
typedef typename r2::type a2;
typedef typename r2::next n3;
typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
///
typedef aux::replace_unnamed_arg< T3,n3 > r3;
typedef typename r3::type a3;
typedef typename r3::next n4;
typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
///
public:
typedef typename apply_wrap3<
f_
, typename t1::type, typename t2::type, typename t3::type
>::type type;
};
};
namespace aux {
template<
typename F, typename T1, typename T2, typename T3
>
aux::yes_tag
is_bind_helper(bind3< F,T1,T2,T3 >*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(4, bind3)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(4, bind3)
template<
typename F, typename T1, typename T2, typename T3, typename T4
>
struct bind4
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
typedef aux::replace_unnamed_arg< T1,n1 > r1;
typedef typename r1::type a1;
typedef typename r1::next n2;
typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
///
typedef aux::replace_unnamed_arg< T2,n2 > r2;
typedef typename r2::type a2;
typedef typename r2::next n3;
typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
///
typedef aux::replace_unnamed_arg< T3,n3 > r3;
typedef typename r3::type a3;
typedef typename r3::next n4;
typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
///
typedef aux::replace_unnamed_arg< T4,n4 > r4;
typedef typename r4::type a4;
typedef typename r4::next n5;
typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4;
///
public:
typedef typename apply_wrap4<
f_
, typename t1::type, typename t2::type, typename t3::type
, typename t4::type
>::type type;
};
};
namespace aux {
template<
typename F, typename T1, typename T2, typename T3, typename T4
>
aux::yes_tag
is_bind_helper(bind4< F,T1,T2,T3,T4 >*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(5, bind4)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(5, bind4)
template<
typename F, typename T1, typename T2, typename T3, typename T4
, typename T5
>
struct bind5
{
template<
typename U1 = na, typename U2 = na, typename U3 = na
, typename U4 = na, typename U5 = na
>
struct apply
{
private:
typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
typedef typename r0::type a0;
typedef typename r0::next n1;
typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
///
typedef aux::replace_unnamed_arg< T1,n1 > r1;
typedef typename r1::type a1;
typedef typename r1::next n2;
typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
///
typedef aux::replace_unnamed_arg< T2,n2 > r2;
typedef typename r2::type a2;
typedef typename r2::next n3;
typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
///
typedef aux::replace_unnamed_arg< T3,n3 > r3;
typedef typename r3::type a3;
typedef typename r3::next n4;
typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
///
typedef aux::replace_unnamed_arg< T4,n4 > r4;
typedef typename r4::type a4;
typedef typename r4::next n5;
typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4;
///
typedef aux::replace_unnamed_arg< T5,n5 > r5;
typedef typename r5::type a5;
typedef typename r5::next n6;
typedef aux::resolve_bind_arg< a5,U1,U2,U3,U4,U5 > t5;
///
public:
typedef typename apply_wrap5<
f_
, typename t1::type, typename t2::type, typename t3::type
, typename t4::type, typename t5::type
>::type type;
};
};
namespace aux {
template<
typename F, typename T1, typename T2, typename T3, typename T4
, typename T5
>
aux::yes_tag
is_bind_helper(bind5< F,T1,T2,T3,T4,T5 >*);
} // namespace aux
BOOST_MPL_AUX_ARITY_SPEC(6, bind5)
BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(6, bind5)
}}
@@ -0,0 +1,82 @@
/*=============================================================================
Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
Copyright (c) 2011 Bryce Lelbach
http://spirit.sourceforge.net/
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_SPIRIT_ACTOR_REF_VALUE_ACTOR_HPP
#define BOOST_SPIRIT_ACTOR_REF_VALUE_ACTOR_HPP
#include <boost/detail/workaround.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif
///////////////////////////////////////////////////////////////////////////
// Summary:
// A semantic action policy holder. This holder stores a reference to ref.
// act methods are feed with ref and the parse result.
//
// (This doc uses convention available in actors.hpp)
//
// Constructor:
// ...(T& ref_);
// where ref_ is stored.
//
// Action calls:
// act(ref, value);
// act(ref, first,last);
//
// () operators: both
//
///////////////////////////////////////////////////////////////////////////
template<
typename T,
typename ActionT
>
class ref_value_actor : public ActionT
{
private:
T& ref;
public:
explicit
ref_value_actor(T& ref_)
: ref(ref_){}
template<typename T2>
void operator()(T2 const& val_) const
{
this->act(ref,val_); // defined in ActionT
}
template<typename IteratorT>
void operator()(
IteratorT const& first_,
IteratorT const& last_
) const
{
this->act(ref,first_,last_); // defined in ActionT
}
};
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
}}
#endif