Initial Commit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
#include "init_random_seed.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* basic PRNG to use for improving the basic seed selection */
|
||||
static unsigned lcg (uint64_t seed)
|
||||
{
|
||||
if (0 ==seed)
|
||||
{
|
||||
seed = UINT64_C(104729);
|
||||
}
|
||||
else
|
||||
{
|
||||
seed %= UINT64_C(4294967296);
|
||||
}
|
||||
seed = (seed * UINT64_C(279470273)) % UINT64_C(4294967291);
|
||||
return seed % UINT64_MAX;
|
||||
}
|
||||
|
||||
/* Generate a good PRNG seed value */
|
||||
void init_random_seed(void)
|
||||
{
|
||||
unsigned seed = 0u;
|
||||
int have_seed = 0;
|
||||
|
||||
// try /dev/urandom for an initial seed
|
||||
int random_source;
|
||||
if ((random_source = open ("/dev/urandom", O_RDONLY)) >= 0)
|
||||
{
|
||||
size_t random_data_length = 0;
|
||||
have_seed = -1;
|
||||
while (random_data_length < sizeof seed)
|
||||
{
|
||||
ssize_t result = read (random_source, &seed + random_data_length, (sizeof seed) - random_data_length);
|
||||
if (result < 0)
|
||||
{
|
||||
// error, unable to read /dev/random
|
||||
have_seed = 0;
|
||||
}
|
||||
random_data_length += result;
|
||||
}
|
||||
close (random_source);
|
||||
}
|
||||
if (!have_seed)
|
||||
{
|
||||
// fallback to combining the time and PID in a fairly random way
|
||||
pid_t pid = getpid ();
|
||||
struct timeval tv;
|
||||
gettimeofday (&tv, NULL);
|
||||
seed = (unsigned)(((unsigned)pid << 16)
|
||||
^ (unsigned)pid
|
||||
^ (unsigned)tv.tv_sec
|
||||
^ (unsigned)tv.tv_usec);
|
||||
seed = lcg (seed);
|
||||
}
|
||||
srand (seed);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char * argv[])
|
||||
{
|
||||
init_random_seed ();
|
||||
int i, j;
|
||||
int r[10][4];
|
||||
for (i = 0; i < 10; ++i)
|
||||
{
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
printf ("%10d ", rand ());
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
int igray_(int *n0, int *idir)
|
||||
{
|
||||
int n;
|
||||
unsigned long sh;
|
||||
unsigned long nn;
|
||||
n=*n0;
|
||||
|
||||
if(*idir>0) return (n ^ (n >> 1));
|
||||
|
||||
sh = 1;
|
||||
nn = (n >> sh);
|
||||
while (nn > 0) {
|
||||
n ^= nn;
|
||||
sh <<= 1;
|
||||
nn = (n >> sh);
|
||||
}
|
||||
return (n);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
/*=============================================================================
|
||||
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)
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
|
||||
#define PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
|
||||
|
||||
#include <boost/phoenix/core/limits.hpp>
|
||||
|
||||
#if defined(BOOST_PHOENIX_NO_VARIADIC_BIND)
|
||||
# include <boost/phoenix/bind/detail/cpp03/bind_member_function.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/phoenix/core/expression.hpp>
|
||||
#include <boost/phoenix/core/reference.hpp>
|
||||
#include <boost/phoenix/core/detail/function_eval.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename RT, typename FP>
|
||||
struct member_function_ptr
|
||||
{
|
||||
typedef RT result_type;
|
||||
|
||||
member_function_ptr(FP fp_)
|
||||
: fp(fp_) {}
|
||||
|
||||
template <typename Class, typename... A>
|
||||
result_type operator()(Class& obj, A&... a) const
|
||||
{
|
||||
BOOST_PROTO_USE_GET_POINTER();
|
||||
|
||||
typedef typename proto::detail::class_member_traits<FP>::class_type class_type;
|
||||
return (BOOST_PROTO_GET_POINTER(class_type, obj)->*fp)(a...);
|
||||
}
|
||||
|
||||
template <typename Class, typename... A>
|
||||
result_type operator()(Class* obj, A&... a) const
|
||||
{
|
||||
return (obj->*fp)(a...);
|
||||
}
|
||||
|
||||
bool operator==(member_function_ptr const& rhs) const
|
||||
{
|
||||
return fp == rhs.fp;
|
||||
}
|
||||
|
||||
template <int M, typename RhsRT, typename RhsFP>
|
||||
bool operator==(member_function_ptr<RhsRT, RhsFP> const& /*rhs*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FP fp;
|
||||
};
|
||||
} // namespace boost::phoenix::detail
|
||||
|
||||
template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A>
|
||||
inline
|
||||
typename detail::expression::function_eval<
|
||||
detail::member_function_ptr<RT, RT(ClassT::*)(T...)>
|
||||
, ClassA
|
||||
, A...
|
||||
>::type const
|
||||
bind(RT (ClassT::*f)(T...), ClassA const & obj, A const&... a)
|
||||
{
|
||||
typedef detail::member_function_ptr<RT, RT (ClassT::*)(T...)> fp_type;
|
||||
return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...);
|
||||
}
|
||||
|
||||
template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A>
|
||||
inline
|
||||
typename detail::expression::function_eval<
|
||||
detail::member_function_ptr<RT, RT (ClassT::*)(T...) const>
|
||||
, ClassA
|
||||
, A...
|
||||
>::type const
|
||||
bind(RT (ClassT::*f)(T...) const, ClassA const & obj, A const&... a)
|
||||
{
|
||||
typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type;
|
||||
return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...);
|
||||
}
|
||||
|
||||
template <typename RT, typename ClassT, typename... T, typename... A>
|
||||
inline
|
||||
typename detail::expression::function_eval<
|
||||
detail::member_function_ptr<RT, RT(ClassT::*)(T...)>
|
||||
, ClassT
|
||||
, A...
|
||||
>::type const
|
||||
bind(RT (ClassT::*f)(T...), ClassT & obj, A const&... a)
|
||||
{
|
||||
typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...)> fp_type;
|
||||
return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...);
|
||||
}
|
||||
|
||||
template <typename RT, typename ClassT, typename... T, typename... A>
|
||||
inline
|
||||
typename detail::expression::function_eval<
|
||||
detail::member_function_ptr<RT, RT(ClassT::*)(T...) const>
|
||||
, ClassT
|
||||
, A...
|
||||
>::type const
|
||||
bind(RT (ClassT::*f)(T...) const, ClassT const& obj, A const&... a)
|
||||
{
|
||||
typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type;
|
||||
return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...);
|
||||
}
|
||||
}} // namespace boost::phoenix
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2013-2014 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_UTILITY_EXTENTS_HPP
|
||||
#define BOOST_COMPUTE_UTILITY_EXTENTS_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
#include <boost/compute/config.hpp>
|
||||
|
||||
#ifndef BOOST_COMPUTE_NO_HDR_INITIALIZER_LIST
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
|
||||
/// The extents class contains an array of n-dimensional extents.
|
||||
///
|
||||
/// \see dim()
|
||||
template<size_t N>
|
||||
class extents
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
static const size_type static_size = N;
|
||||
typedef boost::array<size_t, N> array_type;
|
||||
typedef typename array_type::iterator iterator;
|
||||
typedef typename array_type::const_iterator const_iterator;
|
||||
|
||||
/// Creates an extents object with each component set to zero.
|
||||
///
|
||||
/// For example:
|
||||
/// \code
|
||||
/// extents<3> exts(); // (0, 0, 0)
|
||||
/// \endcode
|
||||
extents()
|
||||
{
|
||||
m_extents.fill(0);
|
||||
}
|
||||
|
||||
/// Creates an extents object with each component set to \p value.
|
||||
///
|
||||
/// For example:
|
||||
/// \code
|
||||
/// extents<3> exts(1); // (1, 1, 1)
|
||||
/// \endcode
|
||||
explicit extents(size_t value)
|
||||
{
|
||||
m_extents.fill(value);
|
||||
}
|
||||
|
||||
#ifndef BOOST_COMPUTE_NO_HDR_INITIALIZER_LIST
|
||||
/// Creates an extents object with \p values.
|
||||
extents(std::initializer_list<size_t> values)
|
||||
{
|
||||
BOOST_ASSERT(values.size() == N);
|
||||
|
||||
std::copy(values.begin(), values.end(), m_extents.begin());
|
||||
}
|
||||
#endif // BOOST_COMPUTE_NO_HDR_INITIALIZER_LIST
|
||||
|
||||
/// Returns the size (i.e. dimensionality) of the extents array.
|
||||
size_type size() const
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
/// Returns the linear size of the extents. This is equivalent to the
|
||||
/// product of each extent in each dimension.
|
||||
size_type linear() const
|
||||
{
|
||||
return std::accumulate(
|
||||
m_extents.begin(), m_extents.end(), 1, std::multiplies<size_type>()
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns a pointer to the extents data array.
|
||||
///
|
||||
/// This is useful for passing the extents data to OpenCL APIs which
|
||||
/// expect an array of \c size_t.
|
||||
size_t* data()
|
||||
{
|
||||
return m_extents.data();
|
||||
}
|
||||
|
||||
/// \overload
|
||||
const size_t* data() const
|
||||
{
|
||||
return m_extents.data();
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return m_extents.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return m_extents.begin();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return m_extents.cbegin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return m_extents.end();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return m_extents.end();
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
{
|
||||
return m_extents.cend();
|
||||
}
|
||||
|
||||
/// Returns a reference to the extent at \p index.
|
||||
size_t& operator[](size_t index)
|
||||
{
|
||||
return m_extents[index];
|
||||
}
|
||||
|
||||
/// \overload
|
||||
const size_t& operator[](size_t index) const
|
||||
{
|
||||
return m_extents[index];
|
||||
}
|
||||
|
||||
/// Returns \c true if the extents in \c *this are the same as \p other.
|
||||
bool operator==(const extents &other) const
|
||||
{
|
||||
return m_extents == other.m_extents;
|
||||
}
|
||||
|
||||
/// Returns \c true if the extents in \c *this are not the same as \p other.
|
||||
bool operator!=(const extents &other) const
|
||||
{
|
||||
return m_extents != other.m_extents;
|
||||
}
|
||||
|
||||
private:
|
||||
array_type m_extents;
|
||||
};
|
||||
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_UTILITY_EXTENTS_HPP
|
||||
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
boost/numeric/odeint/iterator/detail/times_iterator_impl.hpp
|
||||
|
||||
[begin_description]
|
||||
tba.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2013 Karsten Ahnert
|
||||
Copyright 2009-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_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
|
||||
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/unit_helper.hpp>
|
||||
#include <boost/numeric/odeint/util/copy.hpp>
|
||||
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
|
||||
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace odeint {
|
||||
|
||||
|
||||
template< class Iterator , class Stepper , class System , class State , class TimeIterator ,
|
||||
typename Tag , typename StepperTag >
|
||||
class times_iterator_impl;
|
||||
|
||||
/*
|
||||
* Specilization for basic steppers
|
||||
*/
|
||||
/**
|
||||
* \brief ODE Iterator with constant step size.
|
||||
*
|
||||
* Implements an ODE iterator with observer calls at predefined times.
|
||||
* Uses controlled steppers. times_iterator is a model of single-pass iterator.
|
||||
*
|
||||
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
|
||||
*
|
||||
* \tparam Stepper The stepper type which should be used during the iteration.
|
||||
* \tparam System The type of the system function (ODE) which should be solved.
|
||||
*/
|
||||
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
|
||||
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , stepper_tag >
|
||||
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
typedef Stepper stepper_type;
|
||||
typedef System system_type;
|
||||
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
|
||||
typedef State state_type;
|
||||
typedef TimeIterator time_iterator_type;
|
||||
typedef typename traits::time_type< stepper_type >::type time_type;
|
||||
typedef typename traits::value_type< stepper_type >::type ode_value_type;
|
||||
#ifndef DOXYGEN_SKIP
|
||||
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration.
|
||||
* \param t_start Iterator to the begin of a sequence of time values.
|
||||
* \param t_end Iterator to the begin of a sequence of time values.
|
||||
* \param dt The (initial) time step.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
|
||||
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
|
||||
: base_type( stepper , sys , *t_start , dt ) ,
|
||||
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
|
||||
{
|
||||
if( t_start == t_end )
|
||||
this->m_at_end = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
|
||||
: base_type( stepper , sys ) , m_state( &s ) { }
|
||||
|
||||
protected:
|
||||
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
void increment()
|
||||
{
|
||||
unwrapped_stepper_type &stepper = this->m_stepper;
|
||||
if( ++m_t_start != m_t_end )
|
||||
{
|
||||
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
|
||||
{
|
||||
const time_type current_dt = detail::min_abs( this->m_dt , static_cast<time_type>(*m_t_start) - this->m_t );
|
||||
stepper.do_step( this->m_system , *( this->m_state ) , this->m_t , current_dt );
|
||||
this->m_t += current_dt;
|
||||
}
|
||||
|
||||
} else {
|
||||
this->m_at_end = true;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
const state_type& get_state() const
|
||||
{
|
||||
return *m_state;
|
||||
}
|
||||
|
||||
private:
|
||||
time_iterator_type m_t_start;
|
||||
time_iterator_type m_t_end;
|
||||
state_type* m_state;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Specilization for controlled steppers
|
||||
*/
|
||||
/**
|
||||
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
|
||||
*
|
||||
* Implements an ODE iterator with observer calls at predefined times.
|
||||
* Uses controlled steppers. times_iterator is a model of single-pass iterator.
|
||||
*
|
||||
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
|
||||
*
|
||||
* \tparam Stepper The stepper type which should be used during the iteration.
|
||||
* \tparam System The type of the system function (ODE) which should be solved.
|
||||
*/
|
||||
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
|
||||
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , controlled_stepper_tag >
|
||||
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
typedef Stepper stepper_type;
|
||||
typedef System system_type;
|
||||
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
|
||||
typedef State state_type;
|
||||
typedef TimeIterator time_iterator_type;
|
||||
typedef typename traits::time_type< stepper_type >::type time_type;
|
||||
typedef typename traits::value_type< stepper_type >::type ode_value_type;
|
||||
#ifndef DOXYGEN_SKIP
|
||||
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration.
|
||||
* \param t_start Iterator to the begin of a sequence of time values.
|
||||
* \param t_end Iterator to the begin of a sequence of time values.
|
||||
* \param dt The (initial) time step.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
|
||||
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
|
||||
: base_type( stepper , sys , *t_start , dt ) ,
|
||||
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
|
||||
{
|
||||
if( t_start == t_end )
|
||||
this->m_at_end = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
|
||||
: base_type( stepper , sys ) , m_state( &s ) { }
|
||||
|
||||
protected:
|
||||
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
void increment()
|
||||
{
|
||||
if( ++m_t_start != m_t_end )
|
||||
{
|
||||
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
|
||||
{
|
||||
if( detail::less_with_sign( static_cast<time_type>(*m_t_start) - this->m_t , this->m_dt , this->m_dt ) )
|
||||
{
|
||||
// we want to end exactly at the time point
|
||||
time_type current_dt = static_cast<time_type>(*m_t_start) - this->m_t;
|
||||
step_loop( current_dt );
|
||||
} else {
|
||||
step_loop( this->m_dt );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this->m_at_end = true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void step_loop( time_type &dt )
|
||||
{
|
||||
unwrapped_stepper_type &stepper = this->m_stepper;
|
||||
const size_t max_attempts = 1000;
|
||||
size_t trials = 0;
|
||||
controlled_step_result res = success;
|
||||
do
|
||||
{
|
||||
res = stepper.try_step( this->m_system , *( this->m_state ) , this->m_t , dt );
|
||||
++trials;
|
||||
}
|
||||
while( ( res == fail ) && ( trials < max_attempts ) );
|
||||
if( trials == max_attempts )
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ) );
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
const state_type& get_state() const
|
||||
{
|
||||
return *m_state;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
time_iterator_type m_t_start;
|
||||
time_iterator_type m_t_end;
|
||||
state_type* m_state;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Specilization for dense outputer steppers
|
||||
*/
|
||||
/**
|
||||
* \brief ODE Iterator with step size control and dense output.
|
||||
* Implements an ODE iterator with adaptive step size control. Uses dense-output steppers.
|
||||
* times_iterator is a model of single-pass iterator.
|
||||
*
|
||||
* \tparam Stepper The stepper type which should be used during the iteration.
|
||||
* \tparam System The type of the system function (ODE) which should be solved.
|
||||
*/
|
||||
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
|
||||
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , dense_output_stepper_tag >
|
||||
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
typedef Stepper stepper_type;
|
||||
typedef System system_type;
|
||||
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
|
||||
typedef State state_type;
|
||||
typedef TimeIterator time_iterator_type;
|
||||
typedef typename traits::time_type< stepper_type >::type time_type;
|
||||
typedef typename traits::value_type< stepper_type >::type ode_value_type;
|
||||
#ifndef DOXYGEN_SKIP
|
||||
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state.
|
||||
* \param t_start Iterator to the begin of a sequence of time values.
|
||||
* \param t_end Iterator to the begin of a sequence of time values.
|
||||
* \param dt The (initial) time step.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
|
||||
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
|
||||
: base_type( stepper , sys , *t_start , dt ) ,
|
||||
m_t_start( t_start ) , m_t_end( t_end ) , m_final_time( *(t_end-1) ) ,
|
||||
m_state( &s )
|
||||
{
|
||||
if( t_start != t_end )
|
||||
{
|
||||
unwrapped_stepper_type &st = this->m_stepper;
|
||||
st.initialize( *( this->m_state ) , this->m_t , this->m_dt );
|
||||
} else {
|
||||
this->m_at_end = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Constructs a times_iterator. This constructor should be used to construct the end iterator.
|
||||
*
|
||||
* \param stepper The stepper to use during the iteration.
|
||||
* \param sys The system function (ODE) to solve.
|
||||
* \param s The initial state.
|
||||
*/
|
||||
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
|
||||
: base_type( stepper , sys ) , m_state( &s ) { }
|
||||
|
||||
protected:
|
||||
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
void increment()
|
||||
{
|
||||
unwrapped_stepper_type &st = this->m_stepper;
|
||||
if( ++m_t_start != m_t_end )
|
||||
{
|
||||
this->m_t = static_cast<time_type>(*m_t_start);
|
||||
while( detail::less_with_sign( st.current_time() , this->m_t , this->m_dt ) )
|
||||
{
|
||||
// make sure we don't go beyond the last point
|
||||
if( detail::less_with_sign( m_final_time-st.current_time() , st.current_time_step() , st.current_time_step() ) )
|
||||
{
|
||||
st.initialize( st.current_state() , st.current_time() , m_final_time-st.current_time() );
|
||||
}
|
||||
st.do_step( this->m_system );
|
||||
}
|
||||
st.calc_state( this->m_t , *( this->m_state ) );
|
||||
} else {
|
||||
this->m_at_end = true;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
const state_type& get_state() const
|
||||
{
|
||||
return *m_state;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
time_iterator_type m_t_start;
|
||||
time_iterator_type m_t_end;
|
||||
time_type m_final_time;
|
||||
state_type* m_state;
|
||||
};
|
||||
|
||||
} // namespace odeint
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
|
||||
@@ -0,0 +1,136 @@
|
||||
|
||||
// (C) Copyright Tobias Schwinger
|
||||
//
|
||||
// Use modification and distribution are subject to the boost Software License,
|
||||
// Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// no include guards, this file is intended for multiple inclusions
|
||||
|
||||
#ifdef __WAVE__
|
||||
// this file has been generated from the master.hpp file in the same directory
|
||||
# pragma wave option(preserve: 0)
|
||||
#endif
|
||||
|
||||
|
||||
#if !BOOST_PP_IS_ITERATING
|
||||
|
||||
# ifndef BOOST_FT_DETAIL_CC_LOOP_MASTER_HPP_INCLUDED
|
||||
# define BOOST_FT_DETAIL_CC_LOOP_MASTER_HPP_INCLUDED
|
||||
# include <boost/function_types/config/cc_names.hpp>
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/seq/size.hpp>
|
||||
# include <boost/preprocessor/seq/elem.hpp>
|
||||
# include <boost/preprocessor/tuple/elem.hpp>
|
||||
# include <boost/preprocessor/iteration/iterate.hpp>
|
||||
# include <boost/preprocessor/facilities/expand.hpp>
|
||||
# include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
# endif
|
||||
|
||||
# include <boost/function_types/detail/encoding/def.hpp>
|
||||
# include <boost/function_types/detail/encoding/aliases_def.hpp>
|
||||
|
||||
# define BOOST_PP_FILENAME_1 \
|
||||
<boost/function_types/detail/pp_cc_loop/master.hpp>
|
||||
# define BOOST_PP_ITERATION_LIMITS \
|
||||
(0,BOOST_PP_SEQ_SIZE(BOOST_FT_CC_NAMES_SEQ)-1)
|
||||
# include BOOST_PP_ITERATE()
|
||||
# if !defined(BOOST_FT_config_valid) && BOOST_FT_CC_PREPROCESSING
|
||||
# define BOOST_FT_cc_id 1
|
||||
# define BOOST_FT_cc_name implicit_cc
|
||||
# define BOOST_FT_cc BOOST_PP_EMPTY
|
||||
# define BOOST_FT_cond callable_builtin
|
||||
# include BOOST_FT_cc_file
|
||||
# undef BOOST_FT_cond
|
||||
# undef BOOST_FT_cc_name
|
||||
# undef BOOST_FT_cc
|
||||
# undef BOOST_FT_cc_id
|
||||
# elif !defined(BOOST_FT_config_valid) // and generating preprocessed file
|
||||
BOOST_PP_EXPAND(#) ifndef BOOST_FT_config_valid
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cc_id 1
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cc_name implicit_cc
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cc BOOST_PP_EMPTY
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cond callable_builtin
|
||||
#define _()
|
||||
BOOST_PP_EXPAND(#) include BOOST_FT_cc_file
|
||||
#undef _
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cond
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc_name
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc_id
|
||||
BOOST_PP_EXPAND(#) else
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_config_valid
|
||||
BOOST_PP_EXPAND(#) endif
|
||||
|
||||
# else
|
||||
# undef BOOST_FT_config_valid
|
||||
# endif
|
||||
|
||||
# include <boost/function_types/detail/encoding/aliases_undef.hpp>
|
||||
# include <boost/function_types/detail/encoding/undef.hpp>
|
||||
|
||||
#elif BOOST_FT_CC_PREPROCESSING
|
||||
|
||||
# define BOOST_FT_cc_id BOOST_PP_INC(BOOST_PP_FRAME_ITERATION(1))
|
||||
# define BOOST_FT_cc_inf \
|
||||
BOOST_PP_SEQ_ELEM(BOOST_PP_FRAME_ITERATION(1),BOOST_FT_CC_NAMES_SEQ)
|
||||
|
||||
# define BOOST_FT_cc_pp_name BOOST_PP_TUPLE_ELEM(3,0,BOOST_FT_cc_inf)
|
||||
# define BOOST_FT_cc_name BOOST_PP_TUPLE_ELEM(3,1,BOOST_FT_cc_inf)
|
||||
# define BOOST_FT_cc BOOST_PP_TUPLE_ELEM(3,2,BOOST_FT_cc_inf)
|
||||
|
||||
# define BOOST_FT_cond BOOST_PP_CAT(BOOST_FT_CC_,BOOST_FT_cc_pp_name)
|
||||
|
||||
# if BOOST_FT_cond
|
||||
# define BOOST_FT_config_valid 1
|
||||
# include BOOST_FT_cc_file
|
||||
# endif
|
||||
|
||||
# undef BOOST_FT_cond
|
||||
|
||||
# undef BOOST_FT_cc_pp_name
|
||||
# undef BOOST_FT_cc_name
|
||||
# undef BOOST_FT_cc
|
||||
|
||||
# undef BOOST_FT_cc_id
|
||||
# undef BOOST_FT_cc_inf
|
||||
|
||||
#else // if generating preprocessed file
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cc_id BOOST_PP_INC(BOOST_PP_ITERATION())
|
||||
|
||||
# define BOOST_FT_cc_inf \
|
||||
BOOST_PP_SEQ_ELEM(BOOST_PP_ITERATION(),BOOST_FT_CC_NAMES_SEQ)
|
||||
|
||||
# define BOOST_FT_cc_pp_name BOOST_PP_TUPLE_ELEM(3,0,BOOST_FT_cc_inf)
|
||||
|
||||
# define BOOST_FT_CC_DEF(name,index) \
|
||||
name BOOST_PP_TUPLE_ELEM(3,index,BOOST_FT_cc_inf)
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_CC_DEF(BOOST_FT_cc_name,1)
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_CC_DEF(BOOST_FT_cc,2)
|
||||
# undef BOOST_FT_CC_DEF
|
||||
|
||||
# define BOOST_FT_cc_cond_v BOOST_PP_CAT(BOOST_FT_CC_,BOOST_FT_cc_pp_name)
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_cond BOOST_FT_cc_cond_v
|
||||
# undef BOOST_FT_cc_cond_v
|
||||
|
||||
# undef BOOST_FT_cc_pp_name
|
||||
# undef BOOST_FT_cc_inf
|
||||
|
||||
BOOST_PP_EXPAND(#) if BOOST_FT_cond
|
||||
BOOST_PP_EXPAND(#) define BOOST_FT_config_valid 1
|
||||
#define _()
|
||||
BOOST_PP_EXPAND(#) include BOOST_FT_cc_file
|
||||
#undef _
|
||||
BOOST_PP_EXPAND(#) endif
|
||||
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cond
|
||||
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc_name
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc
|
||||
|
||||
BOOST_PP_EXPAND(#) undef BOOST_FT_cc_id
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
#ifndef BOOST_MPL_LIST_LIST50_HPP_INCLUDED
|
||||
#define BOOST_MPL_LIST_LIST50_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/list/list40.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 list50.hpp
|
||||
# include <boost/mpl/list/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(41, 50, <boost/mpl/list/aux_/numbered.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
|
||||
#endif // BOOST_MPL_LIST_LIST50_HPP_INCLUDED
|
||||
@@ -0,0 +1,52 @@
|
||||
// -*- Mode: C++ -*-
|
||||
#ifndef SOUNDIN_H__
|
||||
#define SOUNDIN_H__
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QScopedPointer>
|
||||
#include <QPointer>
|
||||
#include <QAudioInput>
|
||||
|
||||
#include "AudioDevice.hpp"
|
||||
|
||||
class QAudioDeviceInfo;
|
||||
class QAudioInput;
|
||||
|
||||
// Gets audio data from sound sample source and passes it to a sink device
|
||||
class SoundInput
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
SoundInput (QObject * parent = nullptr)
|
||||
: QObject {parent}
|
||||
, m_sink {nullptr}
|
||||
{
|
||||
}
|
||||
|
||||
~SoundInput ();
|
||||
|
||||
// sink must exist from the start call until the next start call or
|
||||
// stop call
|
||||
Q_SLOT void start(QAudioDeviceInfo const&, int framesPerBuffer, AudioDevice * sink, unsigned downSampleFactor, AudioDevice::Channel = AudioDevice::Mono);
|
||||
Q_SLOT void suspend ();
|
||||
Q_SLOT void resume ();
|
||||
Q_SLOT void stop ();
|
||||
|
||||
Q_SIGNAL void error (QString message) const;
|
||||
Q_SIGNAL void status (QString message) const;
|
||||
|
||||
private:
|
||||
// used internally
|
||||
Q_SLOT void handleStateChanged (QAudio::State) const;
|
||||
|
||||
bool audioError () const;
|
||||
|
||||
QScopedPointer<QAudioInput> m_stream;
|
||||
QPointer<AudioDevice> m_sink;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,163 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2015-2015. 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/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/detail/mpl.hpp>
|
||||
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
|
||||
//Needed to support smart references to value types
|
||||
template <class From, class ValuePtr>
|
||||
struct disable_if_smartref_to
|
||||
: detail::disable_if_c
|
||||
< detail::is_same
|
||||
<From, typename pointer_traits
|
||||
<ValuePtr>
|
||||
::reference>::value
|
||||
|| detail::is_same
|
||||
<From, typename pointer_traits
|
||||
< typename pointer_rebind
|
||||
<ValuePtr, const typename pointer_element<ValuePtr>::type>::type>
|
||||
::reference>::value
|
||||
>
|
||||
{};
|
||||
|
||||
//This function object takes a KeyCompare function object
|
||||
//and compares values that contains keys using KeyOfValue
|
||||
template< class ValuePtr, class KeyCompare, class KeyOfValue
|
||||
, bool = boost::intrusive::detail::is_same<typename pointer_element<ValuePtr>::type, typename KeyOfValue::type>::value >
|
||||
struct tree_value_compare
|
||||
: public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
|
||||
{
|
||||
typedef typename pointer_element<ValuePtr>::type value_type;
|
||||
typedef KeyCompare key_compare;
|
||||
typedef KeyOfValue key_of_value;
|
||||
typedef typename KeyOfValue::type key_type;
|
||||
|
||||
typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
|
||||
: base_t()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
|
||||
: base_t(kcomp)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
|
||||
: base_t(x.base_t::get())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
|
||||
{ this->base_t::get() = x.base_t::get(); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
|
||||
{ this->base_t::get() = x; return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
|
||||
{ return static_cast<const key_compare &>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const key_type &key2) const
|
||||
{ return this->key_comp()(key1, key2); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const value_type &value1, const value_type &value2) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), KeyOfValue()(value2)); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const value_type &value2) const
|
||||
{ return this->key_comp()(key1, KeyOfValue()(value2)); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const value_type &value1, const key_type &key2) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const key_type &key1, const U &nonkey2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(key1, nonkey2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const U &nonkey1, const key_type &key2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonkey1, key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const value_type &value1, const U &nonvalue2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(KeyOfValue()(value1), nonvalue2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const U &nonvalue1, const value_type &value2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonvalue1, KeyOfValue()(value2)); }
|
||||
};
|
||||
|
||||
template<class ValuePtr, class KeyCompare, class KeyOfValue>
|
||||
struct tree_value_compare<ValuePtr, KeyCompare, KeyOfValue, true>
|
||||
: public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
|
||||
{
|
||||
typedef typename pointer_element<ValuePtr>::type value_type;
|
||||
typedef KeyCompare key_compare;
|
||||
typedef KeyOfValue key_of_value;
|
||||
typedef typename KeyOfValue::type key_type;
|
||||
|
||||
typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
|
||||
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
|
||||
: base_t()
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
|
||||
: base_t(kcomp)
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
|
||||
: base_t(x.base_t::get())
|
||||
{}
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
|
||||
{ this->base_t::get() = x.base_t::get(); return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
|
||||
{ this->base_t::get() = x; return *this; }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
|
||||
{ return static_cast<const key_compare &>(*this); }
|
||||
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const key_type &key1, const key_type &key2) const
|
||||
{ return this->key_comp()(key1, key2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()( const key_type &key1, const U &nonkey2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(key1, nonkey2); }
|
||||
|
||||
template<class U>
|
||||
BOOST_INTRUSIVE_FORCEINLINE bool operator()(const U &nonkey1, const key_type &key2
|
||||
, typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
|
||||
{ return this->key_comp()(nonkey1, key2); }
|
||||
};
|
||||
|
||||
} //namespace intrusive{
|
||||
} //namespace boost{
|
||||
|
||||
#endif //#ifdef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
#ifndef BOOST_MPL_LIST_AUX_CLEAR_HPP_INCLUDED
|
||||
#define BOOST_MPL_LIST_AUX_CLEAR_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$
|
||||
|
||||
#include <boost/mpl/clear_fwd.hpp>
|
||||
#include <boost/mpl/list/aux_/item.hpp>
|
||||
#include <boost/mpl/list/aux_/tag.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct clear_impl< aux::list_tag >
|
||||
{
|
||||
template< typename List > struct apply
|
||||
{
|
||||
typedef l_end type;
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_LIST_AUX_CLEAR_HPP_INCLUDED
|
||||
@@ -0,0 +1,253 @@
|
||||
#ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
|
||||
#define BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// weak_ptr.hpp
|
||||
//
|
||||
// Copyright (c) 2001, 2002, 2003 Peter Dimov
|
||||
//
|
||||
// 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/smart_ptr/weak_ptr.htm for documentation.
|
||||
//
|
||||
|
||||
#include <memory> // boost.TR1 include order fix
|
||||
#include <boost/smart_ptr/detail/shared_count.hpp>
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> class weak_ptr
|
||||
{
|
||||
private:
|
||||
|
||||
// Borland 5.5.1 specific workarounds
|
||||
typedef weak_ptr<T> this_type;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename boost::detail::sp_element< T >::type element_type;
|
||||
|
||||
weak_ptr() BOOST_NOEXCEPT : px(0), pn() // never throws in 1.30+
|
||||
{
|
||||
}
|
||||
|
||||
// generated copy constructor, assignment, destructor are fine...
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
// ... except in C++0x, move disables the implicit copy
|
||||
|
||||
weak_ptr( weak_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
|
||||
{
|
||||
}
|
||||
|
||||
weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT
|
||||
{
|
||||
px = r.px;
|
||||
pn = r.pn;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// The "obvious" converting constructor implementation:
|
||||
//
|
||||
// template<class Y>
|
||||
// weak_ptr(weak_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// has a serious problem.
|
||||
//
|
||||
// r.px may already have been invalidated. The px(r.px)
|
||||
// conversion may require access to *r.px (virtual inheritance).
|
||||
//
|
||||
// It is not possible to avoid spurious access violations since
|
||||
// in multithreaded programs r.px may be invalidated at any point.
|
||||
//
|
||||
|
||||
template<class Y>
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
weak_ptr( weak_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
|
||||
|
||||
#else
|
||||
|
||||
weak_ptr( weak_ptr<Y> const & r )
|
||||
|
||||
#endif
|
||||
BOOST_NOEXCEPT : px(r.lock().get()), pn(r.pn)
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class Y>
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
weak_ptr( weak_ptr<Y> && r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
|
||||
|
||||
#else
|
||||
|
||||
weak_ptr( weak_ptr<Y> && r )
|
||||
|
||||
#endif
|
||||
BOOST_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
r.px = 0;
|
||||
}
|
||||
|
||||
// for better efficiency in the T == Y case
|
||||
weak_ptr( weak_ptr && r )
|
||||
BOOST_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
|
||||
{
|
||||
r.px = 0;
|
||||
}
|
||||
|
||||
// for better efficiency in the T == Y case
|
||||
weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT
|
||||
{
|
||||
this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
template<class Y>
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
weak_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
|
||||
|
||||
#else
|
||||
|
||||
weak_ptr( shared_ptr<Y> const & r )
|
||||
|
||||
#endif
|
||||
BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
|
||||
|
||||
template<class Y>
|
||||
weak_ptr & operator=( weak_ptr<Y> const & r ) BOOST_NOEXCEPT
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
|
||||
px = r.lock().get();
|
||||
pn = r.pn;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class Y>
|
||||
weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_NOEXCEPT
|
||||
{
|
||||
this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class Y>
|
||||
weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_NOEXCEPT
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
|
||||
px = r.px;
|
||||
pn = r.pn;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
shared_ptr<T> lock() const BOOST_NOEXCEPT
|
||||
{
|
||||
return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() );
|
||||
}
|
||||
|
||||
long use_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return pn.use_count();
|
||||
}
|
||||
|
||||
bool expired() const BOOST_NOEXCEPT
|
||||
{
|
||||
return pn.use_count() == 0;
|
||||
}
|
||||
|
||||
bool _empty() const // extension, not in std::weak_ptr
|
||||
{
|
||||
return pn.empty();
|
||||
}
|
||||
|
||||
void reset() BOOST_NOEXCEPT // never throws in 1.30+
|
||||
{
|
||||
this_type().swap(*this);
|
||||
}
|
||||
|
||||
void swap(this_type & other) BOOST_NOEXCEPT
|
||||
{
|
||||
std::swap(px, other.px);
|
||||
pn.swap(other.pn);
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2)
|
||||
{
|
||||
px = px2;
|
||||
pn = r.pn;
|
||||
}
|
||||
|
||||
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return pn < rhs.pn;
|
||||
}
|
||||
|
||||
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return pn < rhs.pn;
|
||||
}
|
||||
|
||||
// Tasteless as this may seem, making all members public allows member templates
|
||||
// to work in the absence of member template friends. (Matthew Langston)
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
|
||||
private:
|
||||
|
||||
template<class Y> friend class weak_ptr;
|
||||
template<class Y> friend class shared_ptr;
|
||||
|
||||
#endif
|
||||
|
||||
element_type * px; // contained pointer
|
||||
boost::detail::weak_count pn; // reference counter
|
||||
|
||||
}; // weak_ptr
|
||||
|
||||
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_NOEXCEPT
|
||||
{
|
||||
return a.owner_before( b );
|
||||
}
|
||||
|
||||
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_NOEXCEPT
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
|
||||
@@ -0,0 +1,79 @@
|
||||
subroutine astro0(nyear,month,nday,uth8,freq8,mygrid,hisgrid, &
|
||||
AzSun8,ElSun8,AzMoon8,ElMoon8,AzMoonB8,ElMoonB8,ntsky,ndop,ndop00, &
|
||||
dbMoon8,RAMoon8,DecMoon8,HA8,Dgrd8,sd8,poloffset8,xnr8,dfdt,dfdt0, &
|
||||
width1,width2,xlst8,techo8)
|
||||
|
||||
parameter (DEGS=57.2957795130823d0)
|
||||
character*6 mygrid,hisgrid
|
||||
real*8 AzSun8,ElSun8,AzMoon8,ElMoon8,AzMoonB8,ElMoonB8
|
||||
real*8 dbMoon8,RAMoon8,DecMoon8,HA8,Dgrd8,xnr8,dfdt,dfdt0,dt
|
||||
real*8 sd8,poloffset8,width1,width2,xlst8
|
||||
real*8 uth8,techo8,freq8
|
||||
real*8 xl,b
|
||||
common/librcom/xl(2),b(2)
|
||||
data uth8z/0.d0/
|
||||
save
|
||||
|
||||
uth=uth8
|
||||
call astro(nyear,month,nday,uth,freq8,hisgrid,2,1, &
|
||||
AzSun,ElSun,AzMoon,ElMoon,ntsky,doppler00,doppler, &
|
||||
dbMoon,RAMoon,DecMoon,HA,Dgrd,sd,poloffset,xnr, &
|
||||
day,xlon2,xlat2,xlst,techo)
|
||||
AzMoonB8=AzMoon
|
||||
ElMoonB8=ElMoon
|
||||
xl2=xl(1)
|
||||
xl2a=xl(2)
|
||||
b2=b(1)
|
||||
b2a=b(2)
|
||||
call astro(nyear,month,nday,uth,freq8,mygrid,1,1, &
|
||||
AzSun,ElSun,AzMoon,ElMoon,ntsky,doppler00,doppler, &
|
||||
dbMoon,RAMoon,DecMoon,HA,Dgrd,sd,poloffset,xnr, &
|
||||
day,xlon1,xlat1,xlst,techo)
|
||||
xl1=xl(1)
|
||||
xl1a=xl(2)
|
||||
b1=b(1)
|
||||
b1a=b(2)
|
||||
techo8=techo
|
||||
|
||||
fghz=1.d-9*freq8
|
||||
dldt1=DEGS*(xl1a-xl1)
|
||||
dbdt1=DEGS*(b1a-b1)
|
||||
dldt2=DEGS*(xl2a-xl2)
|
||||
dbdt2=DEGS*(b2a-b2)
|
||||
rate1=2.0*sqrt(dldt1**2 + dbdt1**2)
|
||||
width1=0.5*6741*fghz*rate1
|
||||
rate2=sqrt((dldt1+dldt2)**2 + (dbdt1+dbdt2)**2)
|
||||
width2=0.5*6741*fghz*rate2
|
||||
|
||||
AzSun8=AzSun
|
||||
ElSun8=ElSun
|
||||
AzMoon8=AzMoon
|
||||
ElMoon8=ElMoon
|
||||
dbMoon8=dbMoon
|
||||
RAMoon8=RAMoon/15.0
|
||||
DecMoon8=DecMoon
|
||||
HA8=HA
|
||||
xlst8=xlst
|
||||
Dgrd8=Dgrd
|
||||
sd8=sd
|
||||
poloffset8=poloffset
|
||||
xnr8=xnr
|
||||
ndop=nint(doppler)
|
||||
ndop00=nint(doppler00)
|
||||
|
||||
if(uth8z.eq.0.d0) then
|
||||
uth8z=uth8-1.d0/3600.d0
|
||||
dopplerz=doppler
|
||||
doppler00z=doppler00
|
||||
endif
|
||||
|
||||
dt=60.0*(uth8-uth8z)
|
||||
if(dt.le.0) dt=1.d0/60.d0
|
||||
dfdt=(doppler-dopplerz)/dt
|
||||
dfdt0=(doppler00-doppler00z)/dt
|
||||
uth8z=uth8
|
||||
dopplerz=doppler
|
||||
doppler00z=doppler00
|
||||
|
||||
return
|
||||
end subroutine astro0
|
||||
@@ -0,0 +1,238 @@
|
||||
program ldpcsim174
|
||||
! End to end test of the (174,75)/crc12 encoder and decoder.
|
||||
use crc
|
||||
use packjt
|
||||
|
||||
parameter(NRECENT=10)
|
||||
character*12 recent_calls(NRECENT)
|
||||
character*22 msg,msgsent,msgreceived
|
||||
character*8 arg
|
||||
integer*1, allocatable :: codeword(:), decoded(:), message(:)
|
||||
integer*1, target:: i1Msg8BitBytes(11)
|
||||
integer*1 msgbits(87)
|
||||
integer*1 apmask(174), cw(174)
|
||||
integer*2 checksum
|
||||
integer*4 i4Msg6BitWords(13)
|
||||
integer colorder(174)
|
||||
integer nerrtot(174),nerrdec(174),nmpcbad(87)
|
||||
logical checksumok,fsk,bpsk
|
||||
real*8, allocatable :: rxdata(:)
|
||||
real, allocatable :: llr(:)
|
||||
|
||||
data colorder/ &
|
||||
0, 1, 2, 3, 30, 4, 5, 6, 7, 8, 9, 10, 11, 32, 12, 40, 13, 14, 15, 16,&
|
||||
17, 18, 37, 45, 29, 19, 20, 21, 41, 22, 42, 31, 33, 34, 44, 35, 47, 51, 50, 43,&
|
||||
36, 52, 63, 46, 25, 55, 27, 24, 23, 53, 39, 49, 59, 38, 48, 61, 60, 57, 28, 62,&
|
||||
56, 58, 65, 66, 26, 70, 64, 69, 68, 67, 74, 71, 54, 76, 72, 75, 78, 77, 80, 79,&
|
||||
73, 83, 84, 81, 82, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,&
|
||||
100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,&
|
||||
120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,&
|
||||
140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,&
|
||||
160,161,162,163,164,165,166,167,168,169,170,171,172,173/
|
||||
|
||||
do i=1,NRECENT
|
||||
recent_calls(i)=' '
|
||||
enddo
|
||||
nerrtot=0
|
||||
nerrdec=0
|
||||
nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword
|
||||
|
||||
nargs=iargc()
|
||||
if(nargs.ne.4) then
|
||||
print*,'Usage: ldpcsim niter ndepth #trials s '
|
||||
print*,'eg: ldpcsim 10 2 1000 0.84'
|
||||
print*,'belief propagation iterations: niter, ordered-statistics depth: ndepth'
|
||||
print*,'If s is negative, then value is ignored and sigma is calculated from SNR.'
|
||||
return
|
||||
endif
|
||||
call getarg(1,arg)
|
||||
read(arg,*) max_iterations
|
||||
call getarg(2,arg)
|
||||
read(arg,*) ndepth
|
||||
call getarg(3,arg)
|
||||
read(arg,*) ntrials
|
||||
call getarg(4,arg)
|
||||
read(arg,*) s
|
||||
|
||||
fsk=.false.
|
||||
bpsk=.true.
|
||||
|
||||
! don't count crc bits as data bits
|
||||
N=174
|
||||
K=87
|
||||
! scale Eb/No for a (174,87) code
|
||||
rate=real(K)/real(N)
|
||||
|
||||
write(*,*) "rate: ",rate
|
||||
write(*,*) "niter= ",max_iterations," s= ",s
|
||||
|
||||
allocate ( codeword(N), decoded(K), message(K) )
|
||||
allocate ( rxdata(N), llr(N) )
|
||||
|
||||
msg="K1JT K9AN EN50"
|
||||
! msg="G4WJS K9AN EN50"
|
||||
call packmsg(msg,i4Msg6BitWords,itype) !Pack into 12 6-bit bytes
|
||||
call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent
|
||||
write(*,*) "message sent ",msgsent
|
||||
|
||||
i4=0
|
||||
ik=0
|
||||
im=0
|
||||
do i=1,12
|
||||
nn=i4Msg6BitWords(i)
|
||||
do j=1, 6
|
||||
ik=ik+1
|
||||
i4=i4+i4+iand(1,ishft(nn,j-6))
|
||||
i4=iand(i4,255)
|
||||
if(ik.eq.8) then
|
||||
im=im+1
|
||||
! if(i4.gt.127) i4=i4-256
|
||||
i1Msg8BitBytes(im)=i4
|
||||
ik=0
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
|
||||
i1Msg8BitBytes(10:11)=0
|
||||
checksum = crc12 (c_loc (i1Msg8BitBytes), 11)
|
||||
! For reference, the next 3 lines show how to check the CRC
|
||||
i1Msg8BitBytes(10)=checksum/256
|
||||
i1Msg8BitBytes(11)=iand (checksum,255)
|
||||
checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11)
|
||||
if( checksumok ) write(*,*) 'Good checksum'
|
||||
|
||||
! K=87, For now:
|
||||
! msgbits(1:72) JT message bits
|
||||
! msgbits(73:75) 3 free message bits (set to 0)
|
||||
! msgbits(76:87) CRC12
|
||||
mbit=0
|
||||
do i=1, 9
|
||||
i1=i1Msg8BitBytes(i)
|
||||
do ibit=1,8
|
||||
mbit=mbit+1
|
||||
msgbits(mbit)=iand(1,ishft(i1,ibit-8))
|
||||
enddo
|
||||
enddo
|
||||
msgbits(73:75)=0 ! the three extra message bits go here
|
||||
i1=i1Msg8BitBytes(10) ! First 4 bits of crc12 are LSB of this byte
|
||||
do ibit=1,4
|
||||
msgbits(75+ibit)=iand(1,ishft(i1,ibit-4))
|
||||
enddo
|
||||
i1=i1Msg8BitBytes(11) ! Now shift in last 8 bits of the CRC
|
||||
do ibit=1,8
|
||||
msgbits(79+ibit)=iand(1,ishft(i1,ibit-8))
|
||||
enddo
|
||||
|
||||
write(*,*) 'message'
|
||||
write(*,'(11(8i1,1x))') msgbits
|
||||
|
||||
call encode174(msgbits,codeword)
|
||||
call init_random_seed()
|
||||
! call sgran()
|
||||
|
||||
write(*,*) 'codeword'
|
||||
write(*,'(22(8i1,1x))') codeword
|
||||
|
||||
write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma"
|
||||
do idb = 20,-10,-1
|
||||
!do idb = -3,-3,-1
|
||||
db=idb/2.0-1.0
|
||||
sigma=1/sqrt( 2*(10**(db/10.0)) )
|
||||
ngood=0
|
||||
nue=0
|
||||
nbadcrc=0
|
||||
nberr=0
|
||||
do itrial=1, ntrials
|
||||
! Create a realization of a noisy received word
|
||||
do i=1,N
|
||||
if( bpsk ) then
|
||||
rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
|
||||
elseif( fsk ) then
|
||||
if( codeword(i) .eq. 1 ) then
|
||||
r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2
|
||||
r2=(sigma*gran())**2 + (sigma*gran())**2
|
||||
elseif( codeword(i) .eq. 0 ) then
|
||||
r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2
|
||||
r1=(sigma*gran())**2 + (sigma*gran())**2
|
||||
endif
|
||||
! rxdata(i)=0.35*(sqrt(r1)-sqrt(r2))
|
||||
! rxdata(i)=0.35*(exp(r1)-exp(r2))
|
||||
rxdata(i)=0.12*(log(r1)-log(r2))
|
||||
endif
|
||||
enddo
|
||||
nerr=0
|
||||
do i=1,N
|
||||
if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
|
||||
enddo
|
||||
nerrtot(nerr)=nerrtot(nerr)+1
|
||||
nberr=nberr+nerr
|
||||
|
||||
! Correct signal normalization is important for this decoder.
|
||||
rxav=sum(rxdata)/N
|
||||
rx2av=sum(rxdata*rxdata)/N
|
||||
rxsig=sqrt(rx2av-rxav*rxav)
|
||||
rxdata=rxdata/rxsig
|
||||
! To match the metric to the channel, s should be set to the noise standard deviation.
|
||||
! For now, set s to the value that optimizes decode probability near threshold.
|
||||
! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
|
||||
! magnitude in UER
|
||||
if( s .lt. 0 ) then
|
||||
ss=sigma
|
||||
else
|
||||
ss=s
|
||||
endif
|
||||
|
||||
llr=2.0*rxdata/(ss*ss)
|
||||
nap=0 ! number of AP bits
|
||||
llr(colorder(174-87+1:174-87+nap)+1)=5*(2.0*msgbits(1:nap)-1.0)
|
||||
apmask=0
|
||||
apmask(colorder(174-87+1:174-87+nap)+1)=1
|
||||
|
||||
! max_iterations is max number of belief propagation iterations
|
||||
call bpdecode174(llr, apmask, max_iterations, decoded, cw, nharderrors,niterations)
|
||||
if( ndepth .ge. 0 .and. nharderrors .lt. 0 ) call osd174(llr, apmask, ndepth, decoded, cw, nharderrors, dmin)
|
||||
! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
|
||||
if( nharderrors .ge. 0 ) then
|
||||
call extractmessage174(decoded,msgreceived,ncrcflag,recent_calls,nrecent)
|
||||
if( ncrcflag .ne. 1 ) then
|
||||
nbadcrc=nbadcrc+1
|
||||
endif
|
||||
|
||||
nueflag=0
|
||||
nerrmpc=0
|
||||
do i=1,K ! find number of errors in message+crc part of codeword
|
||||
if( msgbits(i) .ne. decoded(i) ) then
|
||||
nueflag=1
|
||||
nerrmpc=nerrmpc+1
|
||||
endif
|
||||
enddo
|
||||
nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1
|
||||
if( ncrcflag .eq. 1 ) then
|
||||
if( nueflag .eq. 0 ) then
|
||||
ngood=ngood+1
|
||||
nerrdec(nerr)=nerrdec(nerr)+1
|
||||
else if( nueflag .eq. 1 ) then
|
||||
nue=nue+1;
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
baud=12000/1920
|
||||
snr2500=db+10.0*log10((baud/2500.0))
|
||||
pberr=real(nberr)/(real(ntrials*N))
|
||||
write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
|
||||
|
||||
enddo
|
||||
|
||||
open(unit=23,file='nerrhisto.dat',status='unknown')
|
||||
do i=1,174
|
||||
write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
|
||||
enddo
|
||||
close(23)
|
||||
open(unit=25,file='nmpcbad.dat',status='unknown')
|
||||
do i=1,87
|
||||
write(25,'(i4,2x,i10)') i,nmpcbad(i)
|
||||
enddo
|
||||
close(25)
|
||||
|
||||
end program ldpcsim174
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for electric potential : L^2 M T^-3 I^-1
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-1>::type electric_potential_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_ELECTRIC_POTENTIAL_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,401 @@
|
||||
subroutine bpdecode174(llr,apmask,maxiterations,decoded,cw,nharderror,iter)
|
||||
!
|
||||
! A log-domain belief propagation decoder for the (174,87) code.
|
||||
!
|
||||
integer, parameter:: N=174, K=87, M=N-K
|
||||
integer*1 codeword(N),cw(N),apmask(N)
|
||||
integer colorder(N)
|
||||
integer*1 decoded(K)
|
||||
integer Nm(7,M) ! 5, 6, or 7 bits per check
|
||||
integer Mn(3,N) ! 3 checks per bit
|
||||
integer synd(M)
|
||||
real tov(3,N)
|
||||
real toc(7,M)
|
||||
real tanhtoc(7,M)
|
||||
real zn(N)
|
||||
real llr(N)
|
||||
real Tmn
|
||||
integer nrw(M)
|
||||
|
||||
data colorder/ &
|
||||
0, 1, 2, 3, 30, 4, 5, 6, 7, 8, 9, 10, 11, 32, 12, 40, 13, 14, 15, 16,&
|
||||
17, 18, 37, 45, 29, 19, 20, 21, 41, 22, 42, 31, 33, 34, 44, 35, 47, 51, 50, 43,&
|
||||
36, 52, 63, 46, 25, 55, 27, 24, 23, 53, 39, 49, 59, 38, 48, 61, 60, 57, 28, 62,&
|
||||
56, 58, 65, 66, 26, 70, 64, 69, 68, 67, 74, 71, 54, 76, 72, 75, 78, 77, 80, 79,&
|
||||
73, 83, 84, 81, 82, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,&
|
||||
100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,&
|
||||
120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,&
|
||||
140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,&
|
||||
160,161,162,163,164,165,166,167,168,169,170,171,172,173/
|
||||
|
||||
data Mn/ &
|
||||
1, 25, 69, &
|
||||
2, 5, 73, &
|
||||
3, 32, 68, &
|
||||
4, 51, 61, &
|
||||
6, 63, 70, &
|
||||
7, 33, 79, &
|
||||
8, 50, 86, &
|
||||
9, 37, 43, &
|
||||
10, 41, 65, &
|
||||
11, 14, 64, &
|
||||
12, 75, 77, &
|
||||
13, 23, 81, &
|
||||
15, 16, 82, &
|
||||
17, 56, 66, &
|
||||
18, 53, 60, &
|
||||
19, 31, 52, &
|
||||
20, 67, 84, &
|
||||
21, 29, 72, &
|
||||
22, 24, 44, &
|
||||
26, 35, 76, &
|
||||
27, 36, 38, &
|
||||
28, 40, 42, &
|
||||
30, 54, 55, &
|
||||
34, 49, 87, &
|
||||
39, 57, 58, &
|
||||
45, 74, 83, &
|
||||
46, 62, 80, &
|
||||
47, 48, 85, &
|
||||
59, 71, 78, &
|
||||
1, 50, 53, &
|
||||
2, 47, 84, &
|
||||
3, 25, 79, &
|
||||
4, 6, 14, &
|
||||
5, 7, 80, &
|
||||
8, 34, 55, &
|
||||
9, 36, 69, &
|
||||
10, 43, 83, &
|
||||
11, 23, 74, &
|
||||
12, 17, 44, &
|
||||
13, 57, 76, &
|
||||
15, 27, 56, &
|
||||
16, 28, 29, &
|
||||
18, 19, 59, &
|
||||
20, 40, 63, &
|
||||
21, 35, 52, &
|
||||
22, 54, 64, &
|
||||
24, 62, 78, &
|
||||
26, 32, 77, &
|
||||
30, 72, 85, &
|
||||
31, 65, 87, &
|
||||
33, 39, 51, &
|
||||
37, 48, 75, &
|
||||
38, 70, 71, &
|
||||
41, 42, 68, &
|
||||
45, 67, 86, &
|
||||
46, 81, 82, &
|
||||
49, 66, 73, &
|
||||
58, 60, 66, &
|
||||
61, 65, 85, &
|
||||
1, 14, 21, &
|
||||
2, 13, 59, &
|
||||
3, 67, 82, &
|
||||
4, 32, 73, &
|
||||
5, 36, 54, &
|
||||
6, 43, 46, &
|
||||
7, 28, 75, &
|
||||
8, 33, 71, &
|
||||
9, 49, 76, &
|
||||
10, 58, 64, &
|
||||
11, 48, 68, &
|
||||
12, 19, 45, &
|
||||
15, 50, 61, &
|
||||
16, 22, 26, &
|
||||
17, 72, 80, &
|
||||
18, 40, 55, &
|
||||
20, 35, 51, &
|
||||
23, 25, 34, &
|
||||
24, 63, 87, &
|
||||
27, 39, 74, &
|
||||
29, 78, 83, &
|
||||
30, 70, 77, &
|
||||
31, 69, 84, &
|
||||
22, 37, 86, &
|
||||
38, 41, 81, &
|
||||
42, 44, 57, &
|
||||
47, 53, 62, &
|
||||
52, 56, 79, &
|
||||
60, 75, 81, &
|
||||
1, 39, 77, &
|
||||
2, 16, 41, &
|
||||
3, 31, 54, &
|
||||
4, 36, 78, &
|
||||
5, 45, 65, &
|
||||
6, 57, 85, &
|
||||
7, 14, 49, &
|
||||
8, 21, 46, &
|
||||
9, 15, 72, &
|
||||
10, 20, 62, &
|
||||
11, 17, 71, &
|
||||
12, 34, 47, &
|
||||
13, 68, 86, &
|
||||
18, 23, 43, &
|
||||
19, 64, 73, &
|
||||
24, 48, 79, &
|
||||
25, 70, 83, &
|
||||
26, 80, 87, &
|
||||
27, 32, 40, &
|
||||
28, 56, 69, &
|
||||
29, 63, 66, &
|
||||
30, 42, 50, &
|
||||
33, 37, 82, &
|
||||
35, 60, 74, &
|
||||
38, 55, 84, &
|
||||
44, 52, 61, &
|
||||
51, 53, 72, &
|
||||
58, 59, 67, &
|
||||
47, 56, 76, &
|
||||
1, 19, 37, &
|
||||
2, 61, 75, &
|
||||
3, 8, 66, &
|
||||
4, 60, 84, &
|
||||
5, 34, 39, &
|
||||
6, 26, 53, &
|
||||
7, 32, 57, &
|
||||
9, 52, 67, &
|
||||
10, 12, 15, &
|
||||
11, 51, 69, &
|
||||
13, 14, 65, &
|
||||
16, 31, 43, &
|
||||
17, 20, 36, &
|
||||
18, 80, 86, &
|
||||
21, 48, 59, &
|
||||
22, 40, 46, &
|
||||
23, 33, 62, &
|
||||
24, 30, 74, &
|
||||
25, 42, 64, &
|
||||
27, 49, 85, &
|
||||
28, 38, 73, &
|
||||
29, 44, 81, &
|
||||
35, 68, 70, &
|
||||
41, 63, 76, &
|
||||
45, 49, 71, &
|
||||
50, 58, 87, &
|
||||
48, 54, 83, &
|
||||
13, 55, 79, &
|
||||
77, 78, 82, &
|
||||
1, 2, 24, &
|
||||
3, 6, 75, &
|
||||
4, 56, 87, &
|
||||
5, 44, 53, &
|
||||
7, 50, 83, &
|
||||
8, 10, 28, &
|
||||
9, 55, 62, &
|
||||
11, 29, 67, &
|
||||
12, 33, 40, &
|
||||
14, 16, 20, &
|
||||
15, 35, 73, &
|
||||
17, 31, 39, &
|
||||
18, 36, 57, &
|
||||
19, 46, 76, &
|
||||
21, 42, 84, &
|
||||
22, 34, 59, &
|
||||
23, 26, 61, &
|
||||
25, 60, 65, &
|
||||
27, 64, 80, &
|
||||
30, 37, 66, &
|
||||
32, 45, 72, &
|
||||
38, 51, 86, &
|
||||
41, 77, 79, &
|
||||
43, 56, 68, &
|
||||
47, 74, 82, &
|
||||
40, 52, 78, &
|
||||
54, 61, 71, &
|
||||
46, 58, 69/
|
||||
|
||||
data Nm/ &
|
||||
1, 30, 60, 89, 118, 147, 0, &
|
||||
2, 31, 61, 90, 119, 147, 0, &
|
||||
3, 32, 62, 91, 120, 148, 0, &
|
||||
4, 33, 63, 92, 121, 149, 0, &
|
||||
2, 34, 64, 93, 122, 150, 0, &
|
||||
5, 33, 65, 94, 123, 148, 0, &
|
||||
6, 34, 66, 95, 124, 151, 0, &
|
||||
7, 35, 67, 96, 120, 152, 0, &
|
||||
8, 36, 68, 97, 125, 153, 0, &
|
||||
9, 37, 69, 98, 126, 152, 0, &
|
||||
10, 38, 70, 99, 127, 154, 0, &
|
||||
11, 39, 71, 100, 126, 155, 0, &
|
||||
12, 40, 61, 101, 128, 145, 0, &
|
||||
10, 33, 60, 95, 128, 156, 0, &
|
||||
13, 41, 72, 97, 126, 157, 0, &
|
||||
13, 42, 73, 90, 129, 156, 0, &
|
||||
14, 39, 74, 99, 130, 158, 0, &
|
||||
15, 43, 75, 102, 131, 159, 0, &
|
||||
16, 43, 71, 103, 118, 160, 0, &
|
||||
17, 44, 76, 98, 130, 156, 0, &
|
||||
18, 45, 60, 96, 132, 161, 0, &
|
||||
19, 46, 73, 83, 133, 162, 0, &
|
||||
12, 38, 77, 102, 134, 163, 0, &
|
||||
19, 47, 78, 104, 135, 147, 0, &
|
||||
1, 32, 77, 105, 136, 164, 0, &
|
||||
20, 48, 73, 106, 123, 163, 0, &
|
||||
21, 41, 79, 107, 137, 165, 0, &
|
||||
22, 42, 66, 108, 138, 152, 0, &
|
||||
18, 42, 80, 109, 139, 154, 0, &
|
||||
23, 49, 81, 110, 135, 166, 0, &
|
||||
16, 50, 82, 91, 129, 158, 0, &
|
||||
3, 48, 63, 107, 124, 167, 0, &
|
||||
6, 51, 67, 111, 134, 155, 0, &
|
||||
24, 35, 77, 100, 122, 162, 0, &
|
||||
20, 45, 76, 112, 140, 157, 0, &
|
||||
21, 36, 64, 92, 130, 159, 0, &
|
||||
8, 52, 83, 111, 118, 166, 0, &
|
||||
21, 53, 84, 113, 138, 168, 0, &
|
||||
25, 51, 79, 89, 122, 158, 0, &
|
||||
22, 44, 75, 107, 133, 155, 172, &
|
||||
9, 54, 84, 90, 141, 169, 0, &
|
||||
22, 54, 85, 110, 136, 161, 0, &
|
||||
8, 37, 65, 102, 129, 170, 0, &
|
||||
19, 39, 85, 114, 139, 150, 0, &
|
||||
26, 55, 71, 93, 142, 167, 0, &
|
||||
27, 56, 65, 96, 133, 160, 174, &
|
||||
28, 31, 86, 100, 117, 171, 0, &
|
||||
28, 52, 70, 104, 132, 144, 0, &
|
||||
24, 57, 68, 95, 137, 142, 0, &
|
||||
7, 30, 72, 110, 143, 151, 0, &
|
||||
4, 51, 76, 115, 127, 168, 0, &
|
||||
16, 45, 87, 114, 125, 172, 0, &
|
||||
15, 30, 86, 115, 123, 150, 0, &
|
||||
23, 46, 64, 91, 144, 173, 0, &
|
||||
23, 35, 75, 113, 145, 153, 0, &
|
||||
14, 41, 87, 108, 117, 149, 170, &
|
||||
25, 40, 85, 94, 124, 159, 0, &
|
||||
25, 58, 69, 116, 143, 174, 0, &
|
||||
29, 43, 61, 116, 132, 162, 0, &
|
||||
15, 58, 88, 112, 121, 164, 0, &
|
||||
4, 59, 72, 114, 119, 163, 173, &
|
||||
27, 47, 86, 98, 134, 153, 0, &
|
||||
5, 44, 78, 109, 141, 0, 0, &
|
||||
10, 46, 69, 103, 136, 165, 0, &
|
||||
9, 50, 59, 93, 128, 164, 0, &
|
||||
14, 57, 58, 109, 120, 166, 0, &
|
||||
17, 55, 62, 116, 125, 154, 0, &
|
||||
3, 54, 70, 101, 140, 170, 0, &
|
||||
1, 36, 82, 108, 127, 174, 0, &
|
||||
5, 53, 81, 105, 140, 0, 0, &
|
||||
29, 53, 67, 99, 142, 173, 0, &
|
||||
18, 49, 74, 97, 115, 167, 0, &
|
||||
2, 57, 63, 103, 138, 157, 0, &
|
||||
26, 38, 79, 112, 135, 171, 0, &
|
||||
11, 52, 66, 88, 119, 148, 0, &
|
||||
20, 40, 68, 117, 141, 160, 0, &
|
||||
11, 48, 81, 89, 146, 169, 0, &
|
||||
29, 47, 80, 92, 146, 172, 0, &
|
||||
6, 32, 87, 104, 145, 169, 0, &
|
||||
27, 34, 74, 106, 131, 165, 0, &
|
||||
12, 56, 84, 88, 139, 0, 0, &
|
||||
13, 56, 62, 111, 146, 171, 0, &
|
||||
26, 37, 80, 105, 144, 151, 0, &
|
||||
17, 31, 82, 113, 121, 161, 0, &
|
||||
28, 49, 59, 94, 137, 0, 0, &
|
||||
7, 55, 83, 101, 131, 168, 0, &
|
||||
24, 50, 78, 106, 143, 149, 0/
|
||||
|
||||
data nrw/ &
|
||||
6,6,6,6,6,6,6,6,6,6, &
|
||||
6,6,6,6,6,6,6,6,6,6, &
|
||||
6,6,6,6,6,6,6,6,6,6, &
|
||||
6,6,6,6,6,6,6,6,6,7, &
|
||||
6,6,6,6,6,7,6,6,6,6, &
|
||||
6,6,6,6,6,7,6,6,6,6, &
|
||||
7,6,5,6,6,6,6,6,6,5, &
|
||||
6,6,6,6,6,6,6,6,6,6, &
|
||||
5,6,6,6,5,6,6/
|
||||
|
||||
ncw=3
|
||||
|
||||
decoded=0
|
||||
toc=0
|
||||
tov=0
|
||||
tanhtoc=0
|
||||
! initialize messages to checks
|
||||
do j=1,M
|
||||
do i=1,nrw(j)
|
||||
toc(i,j)=llr((Nm(i,j)))
|
||||
enddo
|
||||
enddo
|
||||
|
||||
ncnt=0
|
||||
|
||||
do iter=0,maxiterations
|
||||
|
||||
! Update bit log likelihood ratios (tov=0 in iteration 0).
|
||||
do i=1,N
|
||||
if( apmask(i) .ne. 1 ) then
|
||||
zn(i)=llr(i)+sum(tov(1:ncw,i))
|
||||
else
|
||||
zn(i)=llr(i)
|
||||
endif
|
||||
enddo
|
||||
|
||||
! Check to see if we have a codeword (check before we do any iteration).
|
||||
cw=0
|
||||
where( zn .gt. 0. ) cw=1
|
||||
ncheck=0
|
||||
do i=1,M
|
||||
synd(i)=sum(cw(Nm(1:nrw(i),i)))
|
||||
if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1
|
||||
! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
|
||||
enddo
|
||||
! write(*,*) 'number of unsatisfied parity checks ',ncheck
|
||||
if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it
|
||||
codeword=cw(colorder+1)
|
||||
decoded=codeword(M+1:N)
|
||||
nerr=0
|
||||
do i=1,N
|
||||
if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1
|
||||
enddo
|
||||
nharderror=nerr
|
||||
return
|
||||
endif
|
||||
|
||||
if( iter.gt.0 ) then ! this code block implements an early stopping criterion
|
||||
! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion
|
||||
nd=ncheck-nclast
|
||||
if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased
|
||||
ncnt=0 ! reset counter
|
||||
else
|
||||
ncnt=ncnt+1
|
||||
endif
|
||||
! write(*,*) iter,ncheck,nd,ncnt
|
||||
if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then
|
||||
nharderror=-1
|
||||
return
|
||||
endif
|
||||
endif
|
||||
nclast=ncheck
|
||||
|
||||
! Send messages from bits to check nodes
|
||||
do j=1,M
|
||||
do i=1,nrw(j)
|
||||
ibj=Nm(i,j)
|
||||
toc(i,j)=zn(ibj)
|
||||
do kk=1,ncw ! subtract off what the bit had received from the check
|
||||
if( Mn(kk,ibj) .eq. j ) then
|
||||
toc(i,j)=toc(i,j)-tov(kk,ibj)
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! send messages from check nodes to variable nodes
|
||||
do i=1,M
|
||||
tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2)
|
||||
enddo
|
||||
|
||||
do j=1,N
|
||||
do i=1,ncw
|
||||
ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j
|
||||
Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j)
|
||||
call platanh(-Tmn,y)
|
||||
! y=atanh(-Tmn)
|
||||
tov(i,j)=2*y
|
||||
enddo
|
||||
enddo
|
||||
|
||||
enddo
|
||||
nharderror=-1
|
||||
return
|
||||
end subroutine bpdecode174
|
||||
@@ -0,0 +1,51 @@
|
||||
#if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
|
||||
|
||||
#include <boost/proto/detail/preprocessed/class_member_traits.hpp>
|
||||
|
||||
#elif !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/class_member_traits.hpp")
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class_member_traits.hpp
|
||||
// Contains specializations of the class_member_traits\<\> class template.
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 1)
|
||||
#endif
|
||||
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/class_member_traits.hpp>))
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(output: null)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
|
||||
struct class_member_traits<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A))>
|
||||
{
|
||||
typedef U class_type;
|
||||
typedef T result_type;
|
||||
};
|
||||
|
||||
template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
|
||||
struct class_member_traits<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A)) const>
|
||||
{
|
||||
typedef U class_type;
|
||||
typedef T result_type;
|
||||
};
|
||||
|
||||
#undef N
|
||||
|
||||
#endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES
|
||||
@@ -0,0 +1,46 @@
|
||||
subroutine encode_msk40(message,codeword)
|
||||
! Encode a 16-bit message and return a 32-bit codeword.
|
||||
! The code is a (32,16) regular ldpc code with column weight 3.
|
||||
! The code was generated using the PEG algorithm.
|
||||
! After creating the codeword, the columns are re-ordered according to
|
||||
! "colorder" to make the codeword compatible with the parity-check
|
||||
! matrix stored in Radford Neal's "pchk" format.
|
||||
!
|
||||
integer*1 codeword(32)
|
||||
integer*1 colorder(32)
|
||||
integer g(16)
|
||||
integer*1 gen40(16,16)
|
||||
integer*1 itmp(32)
|
||||
integer*1 message(16)
|
||||
integer*1 pchecks(16)
|
||||
logical first
|
||||
data first/.true./
|
||||
data g/Z'4428',Z'5a6b',Z'1b04',Z'2c12',Z'60c4',Z'1071',Z'be6a',Z'36dd', &
|
||||
Z'c580',Z'ad9a',Z'eca2',Z'7843',Z'332e',Z'a685',Z'5906',Z'1efe'/
|
||||
data colorder/4,1,2,3,0,8,6,10,13,28,20,23,17,15,27,25, &
|
||||
16,12,18,19,7,21,22,11,24,5,26,14,9,29,30,31/
|
||||
save first,gen40
|
||||
|
||||
if( first ) then ! fill the generator matrix
|
||||
gen40=0
|
||||
do i=1,16
|
||||
do j=1,16
|
||||
if( btest(g(i),16-j) ) gen40(i,j)=1
|
||||
enddo
|
||||
enddo
|
||||
first=.false.
|
||||
endif
|
||||
|
||||
do i=1,16
|
||||
nsum=0
|
||||
do j=1,16
|
||||
nsum=nsum+message(j)*gen40(i,j)
|
||||
enddo
|
||||
pchecks(i)=mod(nsum,2)
|
||||
enddo
|
||||
itmp(1:16)=pchecks
|
||||
itmp(17:32)=message(1:16)
|
||||
codeword(colorder+1)=itmp(1:32)
|
||||
|
||||
return
|
||||
end subroutine encode_msk40
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright Rene Rivera 2008-2015
|
||||
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_PREDEF_ARCHITECTURE_PPC_H
|
||||
#define BOOST_PREDEF_ARCHITECTURE_PPC_H
|
||||
|
||||
#include <boost/predef/version_number.h>
|
||||
#include <boost/predef/make.h>
|
||||
|
||||
/*`
|
||||
[heading `BOOST_ARCH_PPC`]
|
||||
|
||||
[@http://en.wikipedia.org/wiki/PowerPC PowerPC] architecture.
|
||||
|
||||
[table
|
||||
[[__predef_symbol__] [__predef_version__]]
|
||||
|
||||
[[`__powerpc`] [__predef_detection__]]
|
||||
[[`__powerpc__`] [__predef_detection__]]
|
||||
[[`__POWERPC__`] [__predef_detection__]]
|
||||
[[`__ppc__`] [__predef_detection__]]
|
||||
[[`_M_PPC`] [__predef_detection__]]
|
||||
[[`_ARCH_PPC`] [__predef_detection__]]
|
||||
[[`__PPCGECKO__`] [__predef_detection__]]
|
||||
[[`__PPCBROADWAY__`] [__predef_detection__]]
|
||||
[[`_XENON`] [__predef_detection__]]
|
||||
|
||||
[[`__ppc601__`] [6.1.0]]
|
||||
[[`_ARCH_601`] [6.1.0]]
|
||||
[[`__ppc603__`] [6.3.0]]
|
||||
[[`_ARCH_603`] [6.3.0]]
|
||||
[[`__ppc604__`] [6.4.0]]
|
||||
[[`__ppc604__`] [6.4.0]]
|
||||
]
|
||||
*/
|
||||
|
||||
#define BOOST_ARCH_PPC BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||
|
||||
#if defined(__powerpc) || defined(__powerpc__) || \
|
||||
defined(__POWERPC__) || defined(__ppc__) || \
|
||||
defined(_M_PPC) || defined(_ARCH_PPC) || \
|
||||
defined(__PPCGECKO__) || defined(__PPCBROADWAY__) || \
|
||||
defined(_XENON)
|
||||
# undef BOOST_ARCH_PPC
|
||||
# if !defined (BOOST_ARCH_PPC) && (defined(__ppc601__) || defined(_ARCH_601))
|
||||
# define BOOST_ARCH_PPC BOOST_VERSION_NUMBER(6,1,0)
|
||||
# endif
|
||||
# if !defined (BOOST_ARCH_PPC) && (defined(__ppc603__) || defined(_ARCH_603))
|
||||
# define BOOST_ARCH_PPC BOOST_VERSION_NUMBER(6,3,0)
|
||||
# endif
|
||||
# if !defined (BOOST_ARCH_PPC) && (defined(__ppc604__) || defined(__ppc604__))
|
||||
# define BOOST_ARCH_PPC BOOST_VERSION_NUMBER(6,4,0)
|
||||
# endif
|
||||
# if !defined (BOOST_ARCH_PPC)
|
||||
# define BOOST_ARCH_PPC BOOST_VERSION_NUMBER_AVAILABLE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if BOOST_ARCH_PPC
|
||||
# define BOOST_ARCH_PPC_AVAILABLE
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCH_PPC_NAME "PowerPC"
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_PPC,BOOST_ARCH_PPC_NAME)
|
||||
@@ -0,0 +1,483 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef OBJECT_CORE_DWA2002615_HPP
|
||||
# define OBJECT_CORE_DWA2002615_HPP
|
||||
|
||||
# define BOOST_PYTHON_OBJECT_HAS_IS_NONE // added 2010-03-15 by rwgk
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/type.hpp>
|
||||
|
||||
# include <boost/python/call.hpp>
|
||||
# include <boost/python/handle_fwd.hpp>
|
||||
# include <boost/python/errors.hpp>
|
||||
# include <boost/python/refcount.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
# include <boost/python/tag.hpp>
|
||||
# include <boost/python/def_visitor.hpp>
|
||||
|
||||
# include <boost/python/detail/raw_pyobject.hpp>
|
||||
# include <boost/python/detail/dependent.hpp>
|
||||
|
||||
# include <boost/python/object/forward.hpp>
|
||||
# include <boost/python/object/add_to_namespace.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/debug/line.hpp>
|
||||
|
||||
# include <boost/python/detail/is_xxx.hpp>
|
||||
# include <boost/python/detail/string_literal.hpp>
|
||||
# include <boost/python/detail/def_helper_fwd.hpp>
|
||||
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
# include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
class kwds_proxy;
|
||||
class args_proxy;
|
||||
}
|
||||
|
||||
namespace converter
|
||||
{
|
||||
template <class T> struct arg_to_python;
|
||||
}
|
||||
|
||||
// Put this in an inner namespace so that the generalized operators won't take over
|
||||
namespace api
|
||||
{
|
||||
|
||||
// This file contains the definition of the object class and enough to
|
||||
// construct/copy it, but not enough to do operations like
|
||||
// attribute/item access or addition.
|
||||
|
||||
template <class Policies> class proxy;
|
||||
|
||||
struct const_attribute_policies;
|
||||
struct attribute_policies;
|
||||
struct const_objattribute_policies;
|
||||
struct objattribute_policies;
|
||||
struct const_item_policies;
|
||||
struct item_policies;
|
||||
struct const_slice_policies;
|
||||
struct slice_policies;
|
||||
class slice_nil;
|
||||
|
||||
typedef proxy<const_attribute_policies> const_object_attribute;
|
||||
typedef proxy<attribute_policies> object_attribute;
|
||||
typedef proxy<const_objattribute_policies> const_object_objattribute;
|
||||
typedef proxy<objattribute_policies> object_objattribute;
|
||||
typedef proxy<const_item_policies> const_object_item;
|
||||
typedef proxy<item_policies> object_item;
|
||||
typedef proxy<const_slice_policies> const_object_slice;
|
||||
typedef proxy<slice_policies> object_slice;
|
||||
|
||||
//
|
||||
// is_proxy -- proxy type detection
|
||||
//
|
||||
BOOST_PYTHON_IS_XXX_DEF(proxy, boost::python::api::proxy, 1)
|
||||
|
||||
template <class T> struct object_initializer;
|
||||
|
||||
class object;
|
||||
typedef PyObject* (object::*bool_type)() const;
|
||||
|
||||
template <class U>
|
||||
class object_operators : public def_visitor<U>
|
||||
{
|
||||
protected:
|
||||
typedef object const& object_cref;
|
||||
public:
|
||||
// function call
|
||||
//
|
||||
object operator()() const;
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/object_call.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
detail::args_proxy operator* () const;
|
||||
object operator()(detail::args_proxy const &args) const;
|
||||
object operator()(detail::args_proxy const &args,
|
||||
detail::kwds_proxy const &kwds) const;
|
||||
|
||||
// truth value testing
|
||||
//
|
||||
operator bool_type() const;
|
||||
bool operator!() const; // needed for vc6
|
||||
|
||||
// Attribute access
|
||||
//
|
||||
const_object_attribute attr(char const*) const;
|
||||
object_attribute attr(char const*);
|
||||
const_object_objattribute attr(object const&) const;
|
||||
object_objattribute attr(object const&);
|
||||
|
||||
// Wrap 'in' operator (aka. __contains__)
|
||||
template <class T>
|
||||
object contains(T const& key) const;
|
||||
|
||||
// item access
|
||||
//
|
||||
const_object_item operator[](object_cref) const;
|
||||
object_item operator[](object_cref);
|
||||
|
||||
template <class T>
|
||||
const_object_item
|
||||
operator[](T const& key) const;
|
||||
|
||||
template <class T>
|
||||
object_item
|
||||
operator[](T const& key);
|
||||
|
||||
// slicing
|
||||
//
|
||||
const_object_slice slice(object_cref, object_cref) const;
|
||||
object_slice slice(object_cref, object_cref);
|
||||
|
||||
const_object_slice slice(slice_nil, object_cref) const;
|
||||
object_slice slice(slice_nil, object_cref);
|
||||
|
||||
const_object_slice slice(object_cref, slice_nil) const;
|
||||
object_slice slice(object_cref, slice_nil);
|
||||
|
||||
const_object_slice slice(slice_nil, slice_nil) const;
|
||||
object_slice slice(slice_nil, slice_nil);
|
||||
|
||||
template <class T, class V>
|
||||
const_object_slice
|
||||
slice(T const& start, V const& end) const;
|
||||
|
||||
template <class T, class V>
|
||||
object_slice
|
||||
slice(T const& start, V const& end);
|
||||
|
||||
private: // def visitation for adding callable objects as class methods
|
||||
|
||||
template <class ClassT, class DocStringT>
|
||||
void visit(ClassT& cl, char const* name, python::detail::def_helper<DocStringT> const& helper) const
|
||||
{
|
||||
// It's too late to specify anything other than docstrings if
|
||||
// the callable object is already wrapped.
|
||||
BOOST_STATIC_ASSERT(
|
||||
(is_same<char const*,DocStringT>::value
|
||||
|| detail::is_string_literal<DocStringT const>::value));
|
||||
|
||||
objects::add_to_namespace(cl, name, this->derived_visitor(), helper.doc());
|
||||
}
|
||||
|
||||
friend class python::def_visitor_access;
|
||||
|
||||
private:
|
||||
// there is a confirmed CWPro8 codegen bug here. We prevent the
|
||||
// early destruction of a temporary by binding a named object
|
||||
// instead.
|
||||
# if __MWERKS__ < 0x3000 || __MWERKS__ > 0x3003
|
||||
typedef object const& object_cref2;
|
||||
# else
|
||||
typedef object const object_cref2;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
// VC6 and VC7 require this base class in order to generate the
|
||||
// correct copy constructor for object. We can't define it there
|
||||
// explicitly or it will complain of ambiguity.
|
||||
struct object_base : object_operators<object>
|
||||
{
|
||||
// copy constructor without NULL checking, for efficiency.
|
||||
inline object_base(object_base const&);
|
||||
inline object_base(PyObject* ptr);
|
||||
|
||||
inline object_base& operator=(object_base const& rhs);
|
||||
inline ~object_base();
|
||||
|
||||
// Underlying object access -- returns a borrowed reference
|
||||
inline PyObject* ptr() const;
|
||||
|
||||
inline bool is_none() const;
|
||||
|
||||
private:
|
||||
PyObject* m_ptr;
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
struct is_derived
|
||||
: is_convertible<
|
||||
typename remove_reference<T>::type*
|
||||
, U const*
|
||||
>
|
||||
{};
|
||||
|
||||
template <class T>
|
||||
typename objects::unforward_cref<T>::type do_unforward_cref(T const& x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
class object;
|
||||
|
||||
template <class T>
|
||||
PyObject* object_base_initializer(T const& x)
|
||||
{
|
||||
typedef typename is_derived<
|
||||
BOOST_DEDUCED_TYPENAME objects::unforward_cref<T>::type
|
||||
, object
|
||||
>::type is_obj;
|
||||
|
||||
return object_initializer<
|
||||
BOOST_DEDUCED_TYPENAME unwrap_reference<T>::type
|
||||
>::get(
|
||||
x
|
||||
, is_obj()
|
||||
);
|
||||
}
|
||||
|
||||
class object : public object_base
|
||||
{
|
||||
public:
|
||||
// default constructor creates a None object
|
||||
object();
|
||||
|
||||
// explicit conversion from any C++ object to Python
|
||||
template <class T>
|
||||
explicit object(T const& x)
|
||||
: object_base(object_base_initializer(x))
|
||||
{
|
||||
}
|
||||
|
||||
// Throw error_already_set() if the handle is null.
|
||||
BOOST_PYTHON_DECL explicit object(handle<> const&);
|
||||
private:
|
||||
|
||||
public: // implementation detail -- for internal use only
|
||||
explicit object(detail::borrowed_reference);
|
||||
explicit object(detail::new_reference);
|
||||
explicit object(detail::new_non_null_reference);
|
||||
};
|
||||
|
||||
// Macros for forwarding constructors in classes derived from
|
||||
// object. Derived classes will usually want these as an
|
||||
// implementation detail
|
||||
# define BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(derived, base) \
|
||||
inline explicit derived(::boost::python::detail::borrowed_reference p) \
|
||||
: base(p) {} \
|
||||
inline explicit derived(::boost::python::detail::new_reference p) \
|
||||
: base(p) {} \
|
||||
inline explicit derived(::boost::python::detail::new_non_null_reference p) \
|
||||
: base(p) {}
|
||||
|
||||
//
|
||||
// object_initializer -- get the handle to construct the object with,
|
||||
// based on whether T is a proxy or derived from object
|
||||
//
|
||||
template <bool is_proxy = false, bool is_object_manager = false>
|
||||
struct object_initializer_impl
|
||||
{
|
||||
static PyObject*
|
||||
get(object const& x, mpl::true_)
|
||||
{
|
||||
return python::incref(x.ptr());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static PyObject*
|
||||
get(T const& x, mpl::false_)
|
||||
{
|
||||
return python::incref(converter::arg_to_python<T>(x).get());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct object_initializer_impl<true, false>
|
||||
{
|
||||
template <class Policies>
|
||||
static PyObject*
|
||||
get(proxy<Policies> const& x, mpl::false_)
|
||||
{
|
||||
return python::incref(x.operator object().ptr());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct object_initializer_impl<false, true>
|
||||
{
|
||||
template <class T, class U>
|
||||
static PyObject*
|
||||
get(T const& x, U)
|
||||
{
|
||||
return python::incref(get_managed_object(x, boost::python::tag));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct object_initializer_impl<true, true>
|
||||
{}; // empty implementation should cause an error
|
||||
|
||||
template <class T>
|
||||
struct object_initializer : object_initializer_impl<
|
||||
is_proxy<T>::value
|
||||
, converter::is_object_manager<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
}
|
||||
using api::object;
|
||||
template <class T> struct extract;
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class call_proxy
|
||||
{
|
||||
public:
|
||||
call_proxy(object target) : m_target(target) {}
|
||||
operator object() const { return m_target;}
|
||||
|
||||
private:
|
||||
object m_target;
|
||||
};
|
||||
|
||||
class kwds_proxy : public call_proxy
|
||||
{
|
||||
public:
|
||||
kwds_proxy(object o = object()) : call_proxy(o) {}
|
||||
};
|
||||
class args_proxy : public call_proxy
|
||||
{
|
||||
public:
|
||||
args_proxy(object o) : call_proxy(o) {}
|
||||
kwds_proxy operator* () const { return kwds_proxy(*this);}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
detail::args_proxy api::object_operators<U>::operator* () const
|
||||
{
|
||||
object_cref2 x = *static_cast<U const*>(this);
|
||||
return boost::python::detail::args_proxy(x);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
object api::object_operators<U>::operator()(detail::args_proxy const &args) const
|
||||
{
|
||||
U const& self = *static_cast<U const*>(this);
|
||||
PyObject *result = PyObject_Call(get_managed_object(self, boost::python::tag),
|
||||
args.operator object().ptr(),
|
||||
0);
|
||||
return object(boost::python::detail::new_reference(result));
|
||||
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
object api::object_operators<U>::operator()(detail::args_proxy const &args,
|
||||
detail::kwds_proxy const &kwds) const
|
||||
{
|
||||
U const& self = *static_cast<U const*>(this);
|
||||
PyObject *result = PyObject_Call(get_managed_object(self, boost::python::tag),
|
||||
args.operator object().ptr(),
|
||||
kwds.operator object().ptr());
|
||||
return object(boost::python::detail::new_reference(result));
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename U>
|
||||
template <class T>
|
||||
object api::object_operators<U>::contains(T const& key) const
|
||||
{
|
||||
return this->attr("__contains__")(object(key));
|
||||
}
|
||||
|
||||
|
||||
inline object::object()
|
||||
: object_base(python::incref(Py_None))
|
||||
{}
|
||||
|
||||
// copy constructor without NULL checking, for efficiency
|
||||
inline api::object_base::object_base(object_base const& rhs)
|
||||
: m_ptr(python::incref(rhs.m_ptr))
|
||||
{}
|
||||
|
||||
inline api::object_base::object_base(PyObject* p)
|
||||
: m_ptr(p)
|
||||
{}
|
||||
|
||||
inline api::object_base& api::object_base::operator=(api::object_base const& rhs)
|
||||
{
|
||||
Py_INCREF(rhs.m_ptr);
|
||||
Py_DECREF(this->m_ptr);
|
||||
this->m_ptr = rhs.m_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline api::object_base::~object_base()
|
||||
{
|
||||
assert( Py_REFCNT(m_ptr) > 0 );
|
||||
Py_DECREF(m_ptr);
|
||||
}
|
||||
|
||||
inline object::object(detail::borrowed_reference p)
|
||||
: object_base(python::incref((PyObject*)p))
|
||||
{}
|
||||
|
||||
inline object::object(detail::new_reference p)
|
||||
: object_base(expect_non_null((PyObject*)p))
|
||||
{}
|
||||
|
||||
inline object::object(detail::new_non_null_reference p)
|
||||
: object_base((PyObject*)p)
|
||||
{}
|
||||
|
||||
inline PyObject* api::object_base::ptr() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
inline bool api::object_base::is_none() const
|
||||
{
|
||||
return (m_ptr == Py_None);
|
||||
}
|
||||
|
||||
//
|
||||
// Converter specialization implementations
|
||||
//
|
||||
namespace converter
|
||||
{
|
||||
template <class T> struct object_manager_traits;
|
||||
|
||||
template <>
|
||||
struct object_manager_traits<object>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
static bool check(PyObject*) { return true; }
|
||||
|
||||
static python::detail::new_non_null_reference adopt(PyObject* x)
|
||||
{
|
||||
return python::detail::new_non_null_reference(x);
|
||||
}
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
static PyTypeObject const *get_pytype() {return 0;}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
inline PyObject* get_managed_object(object const& x, tag_t)
|
||||
{
|
||||
return x.ptr();
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
# include <boost/python/slice_nil.hpp>
|
||||
|
||||
#endif // OBJECT_CORE_DWA2002615_HPP
|
||||
@@ -0,0 +1,279 @@
|
||||
#include "astro.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QCloseEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#include "commons.h"
|
||||
#include "MessageBox.hpp"
|
||||
#include "Configuration.hpp"
|
||||
#include "SettingsGroup.hpp"
|
||||
#include "qt_helpers.hpp"
|
||||
|
||||
#include "ui_astro.h"
|
||||
#include "moc_astro.cpp"
|
||||
|
||||
|
||||
extern "C" {
|
||||
void astrosub_(int* nyear, int* month, int* nday, double* uth, double* freqMoon,
|
||||
const char* mygrid, const char* hisgrid, double* azsun,
|
||||
double* elsun, double* azmoon, double* elmoon, double* azmoondx,
|
||||
double* elmoondx, int* ntsky, int* ndop, int* ndop00,
|
||||
double* ramoon, double* decmoon, double* dgrd, double* poloffset,
|
||||
double* xnr, double* techo, double* width1, double* width2,
|
||||
bool* bTx, const char* AzElFileName, const char* jpleph,
|
||||
int len1, int len2, int len3, int len4);
|
||||
}
|
||||
|
||||
Astro::Astro(QSettings * settings, Configuration const * configuration, QWidget * parent)
|
||||
: QDialog {parent, Qt::WindowTitleHint}
|
||||
, settings_ {settings}
|
||||
, configuration_ {configuration}
|
||||
, ui_ {new Ui::Astro}
|
||||
, m_DopplerMethod {0}
|
||||
{
|
||||
ui_->setupUi (this);
|
||||
setWindowTitle (QApplication::applicationName () + " - " + tr ("Astronomical Data"));
|
||||
setStyleSheet ("QWidget {background: white;}");
|
||||
connect (ui_->cbDopplerTracking, &QAbstractButton::toggled, ui_->doppler_widget, &QWidget::setVisible);
|
||||
read_settings ();
|
||||
ui_->text_label->clear ();
|
||||
}
|
||||
|
||||
Astro::~Astro ()
|
||||
{
|
||||
ui_->cbDopplerTracking->setChecked (false);
|
||||
Q_EMIT tracking_update ();
|
||||
if (isVisible ()) write_settings ();
|
||||
}
|
||||
|
||||
void Astro::closeEvent (QCloseEvent * e)
|
||||
{
|
||||
write_settings ();
|
||||
e->ignore (); // do not allow closure by the window system
|
||||
}
|
||||
|
||||
void Astro::read_settings ()
|
||||
{
|
||||
SettingsGroup g (settings_, "Astro");
|
||||
ui_->doppler_widget->setVisible (ui_->cbDopplerTracking->isChecked ());
|
||||
m_DopplerMethod=settings_->value("DopplerMethod",0).toInt();
|
||||
switch (m_DopplerMethod)
|
||||
{
|
||||
case 0: ui_->rbNoDoppler->setChecked (true); break;
|
||||
case 1: ui_->rbFullTrack->setChecked (true); break;
|
||||
case 2: ui_->rbConstFreqOnMoon->setChecked (true); break;
|
||||
case 3: ui_->rbRxOnly->setChecked (true); break;
|
||||
}
|
||||
move (settings_->value ("window/pos", pos ()).toPoint ());
|
||||
}
|
||||
|
||||
void Astro::write_settings ()
|
||||
{
|
||||
SettingsGroup g (settings_, "Astro");
|
||||
//settings_->setValue ("DopplerTracking", ui_->cbDopplerTracking->isChecked ());
|
||||
settings_->setValue ("DopplerMethod",m_DopplerMethod);
|
||||
settings_->setValue ("window/pos", pos ());
|
||||
}
|
||||
|
||||
auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const& hisgrid, Frequency freq,
|
||||
bool dx_is_self, bool bTx, bool no_tx_QSY, int TR_period) -> Correction
|
||||
{
|
||||
Frequency freq_moon {freq};
|
||||
double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx;
|
||||
double ramoon,decmoon,dgrd,poloffset,xnr,techo,width1,width2;
|
||||
int ntsky;
|
||||
QString date {t.date().toString("yyyy MMM dd").trimmed ()};
|
||||
QString utc {t.time().toString().trimmed ()};
|
||||
int nyear {t.date().year()};
|
||||
int month {t.date().month()};
|
||||
int nday {t.date().day()};
|
||||
int nhr {t.time().hour()};
|
||||
int nmin {t.time().minute()};
|
||||
double sec {t.time().second() + 0.001*t.time().msec()};
|
||||
double uth {nhr + nmin/60.0 + sec/3600.0};
|
||||
if(freq_moon < 1) freq_moon = 144000000;
|
||||
int nfreq {static_cast<int> (freq_moon / 1000000u)};
|
||||
double freq8 {static_cast<double> (freq_moon)};
|
||||
auto const& AzElFileName = QDir::toNativeSeparators (configuration_->azel_directory ().absoluteFilePath ("azel.dat"));
|
||||
auto const& jpleph = configuration_->data_dir ().absoluteFilePath ("JPLEPH");
|
||||
int ndop;
|
||||
int ndop00;
|
||||
|
||||
QString mygrid_padded {(mygrid + " ").left (6)};
|
||||
QString hisgrid_padded {(hisgrid + " ").left (6)};
|
||||
astrosub_(&nyear, &month, &nday, &uth, &freq8, mygrid_padded.toLatin1().constData(),
|
||||
hisgrid_padded.toLatin1().constData(), &azsun, &elsun, &azmoon, &elmoon,
|
||||
&azmoondx, &elmoondx, &ntsky, &ndop, &ndop00, &ramoon, &decmoon,
|
||||
&dgrd, &poloffset, &xnr, &techo, &width1, &width2, &bTx,
|
||||
AzElFileName.toLatin1().constData(), jpleph.toLatin1().constData(), 6, 6,
|
||||
AzElFileName.length(), jpleph.length());
|
||||
|
||||
if(hisgrid_padded==" ") {
|
||||
azmoondx=0.0;
|
||||
elmoondx=0.0;
|
||||
ndop=0;
|
||||
width2=0.0;
|
||||
}
|
||||
QString message;
|
||||
{
|
||||
QTextStream out {&message};
|
||||
out << " " << date << "\n"
|
||||
"UTC: " << utc << "\n"
|
||||
<< fixed
|
||||
<< qSetFieldWidth (6)
|
||||
<< qSetRealNumberPrecision (1)
|
||||
<< "Az: " << azmoon << "\n"
|
||||
"El: " << elmoon << "\n"
|
||||
"SelfDop:" << ndop00 << "\n"
|
||||
"Width: " << int(width1) << "\n"
|
||||
<< qSetRealNumberPrecision (2)
|
||||
<< "Delay: " << techo << "\n"
|
||||
<< qSetRealNumberPrecision (1)
|
||||
<< "DxAz: " << azmoondx << "\n"
|
||||
"DxEl: " << elmoondx << "\n"
|
||||
"DxDop: " << ndop << "\n"
|
||||
"DxWid: " << int(width2) << "\n"
|
||||
"Dec: " << decmoon << "\n"
|
||||
"SunAz: " << azsun << "\n"
|
||||
"SunEl: " << elsun << "\n"
|
||||
"Freq: " << nfreq << "\n";
|
||||
if(nfreq>=50) { //Suppress data not relevant below VHF
|
||||
out << "Tsky: " << ntsky << "\n"
|
||||
"Dpol: " << poloffset << "\n"
|
||||
"MNR: " << xnr << "\n"
|
||||
"Dgrd: " << dgrd;
|
||||
}
|
||||
}
|
||||
ui_->text_label->setText(message);
|
||||
|
||||
Correction correction;
|
||||
if (ui_->cbDopplerTracking->isChecked ()) {
|
||||
switch (m_DopplerMethod)
|
||||
{
|
||||
case 1: // All Doppler correction done here; DX station stays at nominal dial frequency.
|
||||
case 3: // Both stations do full correction on Rx and none on Tx
|
||||
correction.rx = dx_is_self ? ndop00 : ndop;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Doppler correction to constant frequency on Moon
|
||||
correction.rx = ndop00 / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (3 != m_DopplerMethod) correction.tx = -correction.rx;
|
||||
if(dx_is_self && m_DopplerMethod == 1) correction.rx = 0;
|
||||
|
||||
if (no_tx_QSY && 3 != m_DopplerMethod && 0 != m_DopplerMethod)
|
||||
{
|
||||
// calculate a single correction for transmit half way through
|
||||
// the period as a compromise for rigs that can't CAT QSY
|
||||
// while transmitting
|
||||
//
|
||||
// use a base time of (secs-since-epoch + 2) so as to be sure
|
||||
// we do the next period if we calculate just before it starts
|
||||
auto sec_since_epoch = t.toMSecsSinceEpoch () / 1000 + 2;
|
||||
auto target_sec = sec_since_epoch - sec_since_epoch % TR_period + TR_period / 2;
|
||||
auto target_date_time = QDateTime::fromMSecsSinceEpoch (target_sec * 1000);
|
||||
QString date {target_date_time.date().toString("yyyy MMM dd").trimmed ()};
|
||||
QString utc {target_date_time.time().toString().trimmed ()};
|
||||
int nyear {target_date_time.date().year()};
|
||||
int month {target_date_time.date().month()};
|
||||
int nday {target_date_time.date().day()};
|
||||
int nhr {target_date_time.time().hour()};
|
||||
int nmin {target_date_time.time().minute()};
|
||||
double sec {target_date_time.time().second() + 0.001*target_date_time.time().msec()};
|
||||
double uth {nhr + nmin/60.0 + sec/3600.0};
|
||||
astrosub_(&nyear, &month, &nday, &uth, &freq8, mygrid_padded.toLatin1().constData(),
|
||||
hisgrid_padded.toLatin1().constData(), &azsun, &elsun, &azmoon, &elmoon,
|
||||
&azmoondx, &elmoondx, &ntsky, &ndop, &ndop00, &ramoon, &decmoon,
|
||||
&dgrd, &poloffset, &xnr, &techo, &width1, &width2, &bTx,
|
||||
"", jpleph.toLatin1().constData(), 6, 6,
|
||||
0, jpleph.length());
|
||||
FrequencyDelta offset {0};
|
||||
switch (m_DopplerMethod)
|
||||
{
|
||||
case 1:
|
||||
// All Doppler correction done here; DX station stays at nominal dial frequency.
|
||||
offset = dx_is_self ? ndop00 : ndop;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Doppler correction to constant frequency on Moon
|
||||
offset = ndop00 / 2;
|
||||
break;
|
||||
}
|
||||
correction.tx = -offset;
|
||||
}
|
||||
}
|
||||
return correction;
|
||||
}
|
||||
|
||||
void Astro::check_split ()
|
||||
{
|
||||
if (doppler_tracking () && !configuration_->split_mode ())
|
||||
{
|
||||
MessageBox::warning_message (this, tr ("Doppler Tracking Error"),
|
||||
tr ("Split operating is required for Doppler tracking"),
|
||||
tr ("Go to \"Menu->File->Settings->Radio\" to enable split operation"));
|
||||
ui_->rbNoDoppler->click ();
|
||||
}
|
||||
}
|
||||
|
||||
void Astro::on_rbFullTrack_clicked()
|
||||
{
|
||||
m_DopplerMethod = 1;
|
||||
check_split ();
|
||||
Q_EMIT tracking_update ();
|
||||
}
|
||||
|
||||
void Astro::on_rbRxOnly_clicked()
|
||||
{
|
||||
m_DopplerMethod = 3;
|
||||
check_split ();
|
||||
Q_EMIT tracking_update ();
|
||||
}
|
||||
|
||||
void Astro::on_rbConstFreqOnMoon_clicked()
|
||||
{
|
||||
m_DopplerMethod = 2;
|
||||
check_split ();
|
||||
Q_EMIT tracking_update ();
|
||||
}
|
||||
|
||||
void Astro::on_rbNoDoppler_clicked()
|
||||
{
|
||||
m_DopplerMethod = 0;
|
||||
Q_EMIT tracking_update ();
|
||||
}
|
||||
|
||||
bool Astro::doppler_tracking () const
|
||||
{
|
||||
return ui_->cbDopplerTracking->isChecked () && m_DopplerMethod;
|
||||
}
|
||||
|
||||
void Astro::on_cbDopplerTracking_toggled(bool)
|
||||
{
|
||||
check_split ();
|
||||
Q_EMIT tracking_update ();
|
||||
}
|
||||
|
||||
void Astro::nominal_frequency (Frequency rx, Frequency tx)
|
||||
{
|
||||
ui_->sked_frequency_label->setText (Radio::pretty_frequency_MHz_string (rx));
|
||||
ui_->sked_tx_frequency_label->setText (Radio::pretty_frequency_MHz_string (tx));
|
||||
}
|
||||
|
||||
void Astro::hideEvent (QHideEvent * e)
|
||||
{
|
||||
Q_EMIT tracking_update ();
|
||||
QWidget::hideEvent (e);
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
// Copyright John Maddock 2006, 2007.
|
||||
// Copyright Paul A. Bristow 2008, 2010.
|
||||
|
||||
// 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_DISTRIBUTIONS_CHI_SQUARED_HPP
|
||||
#define BOOST_MATH_DISTRIBUTIONS_CHI_SQUARED_HPP
|
||||
|
||||
#include <boost/math/distributions/fwd.hpp>
|
||||
#include <boost/math/special_functions/gamma.hpp> // for incomplete beta.
|
||||
#include <boost/math/distributions/complement.hpp> // complements
|
||||
#include <boost/math/distributions/detail/common_error_handling.hpp> // error checks
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
template <class RealType = double, class Policy = policies::policy<> >
|
||||
class chi_squared_distribution
|
||||
{
|
||||
public:
|
||||
typedef RealType value_type;
|
||||
typedef Policy policy_type;
|
||||
|
||||
chi_squared_distribution(RealType i) : m_df(i)
|
||||
{
|
||||
RealType result;
|
||||
detail::check_df(
|
||||
"boost::math::chi_squared_distribution<%1%>::chi_squared_distribution", m_df, &result, Policy());
|
||||
} // chi_squared_distribution
|
||||
|
||||
RealType degrees_of_freedom()const
|
||||
{
|
||||
return m_df;
|
||||
}
|
||||
|
||||
// Parameter estimation:
|
||||
static RealType find_degrees_of_freedom(
|
||||
RealType difference_from_variance,
|
||||
RealType alpha,
|
||||
RealType beta,
|
||||
RealType variance,
|
||||
RealType hint = 100);
|
||||
|
||||
private:
|
||||
//
|
||||
// Data member:
|
||||
//
|
||||
RealType m_df; // degrees of freedom is a positive real number.
|
||||
}; // class chi_squared_distribution
|
||||
|
||||
typedef chi_squared_distribution<double> chi_squared;
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const chi_squared_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
if (std::numeric_limits<RealType>::has_infinity)
|
||||
{
|
||||
return std::pair<RealType, RealType>(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()); // 0 to + infinity.
|
||||
}
|
||||
else
|
||||
{
|
||||
using boost::math::tools::max_value;
|
||||
return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>()); // 0 to + max.
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> support(const chi_squared_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of supported values for random variable x.
|
||||
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
|
||||
return std::pair<RealType, RealType>(static_cast<RealType>(0), tools::max_value<RealType>()); // 0 to + infinity.
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
RealType pdf(const chi_squared_distribution<RealType, Policy>& dist, const RealType& chi_square)
|
||||
{
|
||||
BOOST_MATH_STD_USING // for ADL of std functions
|
||||
RealType degrees_of_freedom = dist.degrees_of_freedom();
|
||||
// Error check:
|
||||
RealType error_result;
|
||||
|
||||
static const char* function = "boost::math::pdf(const chi_squared_distribution<%1%>&, %1%)";
|
||||
|
||||
if(false == detail::check_df(
|
||||
function, degrees_of_freedom, &error_result, Policy()))
|
||||
return error_result;
|
||||
|
||||
if((chi_square < 0) || !(boost::math::isfinite)(chi_square))
|
||||
{
|
||||
return policies::raise_domain_error<RealType>(
|
||||
function, "Chi Square parameter was %1%, but must be > 0 !", chi_square, Policy());
|
||||
}
|
||||
|
||||
if(chi_square == 0)
|
||||
{
|
||||
// Handle special cases:
|
||||
if(degrees_of_freedom < 2)
|
||||
{
|
||||
return policies::raise_overflow_error<RealType>(
|
||||
function, 0, Policy());
|
||||
}
|
||||
else if(degrees_of_freedom == 2)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return gamma_p_derivative(degrees_of_freedom / 2, chi_square / 2, Policy()) / 2;
|
||||
} // pdf
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const chi_squared_distribution<RealType, Policy>& dist, const RealType& chi_square)
|
||||
{
|
||||
RealType degrees_of_freedom = dist.degrees_of_freedom();
|
||||
// Error check:
|
||||
RealType error_result;
|
||||
static const char* function = "boost::math::cdf(const chi_squared_distribution<%1%>&, %1%)";
|
||||
|
||||
if(false == detail::check_df(
|
||||
function, degrees_of_freedom, &error_result, Policy()))
|
||||
return error_result;
|
||||
|
||||
if((chi_square < 0) || !(boost::math::isfinite)(chi_square))
|
||||
{
|
||||
return policies::raise_domain_error<RealType>(
|
||||
function, "Chi Square parameter was %1%, but must be > 0 !", chi_square, Policy());
|
||||
}
|
||||
|
||||
return boost::math::gamma_p(degrees_of_freedom / 2, chi_square / 2, Policy());
|
||||
} // cdf
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const chi_squared_distribution<RealType, Policy>& dist, const RealType& p)
|
||||
{
|
||||
RealType degrees_of_freedom = dist.degrees_of_freedom();
|
||||
static const char* function = "boost::math::quantile(const chi_squared_distribution<%1%>&, %1%)";
|
||||
// Error check:
|
||||
RealType error_result;
|
||||
if(false ==
|
||||
(
|
||||
detail::check_df(function, degrees_of_freedom, &error_result, Policy())
|
||||
&& detail::check_probability(function, p, &error_result, Policy()))
|
||||
)
|
||||
return error_result;
|
||||
|
||||
return 2 * boost::math::gamma_p_inv(degrees_of_freedom / 2, p, Policy());
|
||||
} // quantile
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const complemented2_type<chi_squared_distribution<RealType, Policy>, RealType>& c)
|
||||
{
|
||||
RealType const& degrees_of_freedom = c.dist.degrees_of_freedom();
|
||||
RealType const& chi_square = c.param;
|
||||
static const char* function = "boost::math::cdf(const chi_squared_distribution<%1%>&, %1%)";
|
||||
// Error check:
|
||||
RealType error_result;
|
||||
if(false == detail::check_df(
|
||||
function, degrees_of_freedom, &error_result, Policy()))
|
||||
return error_result;
|
||||
|
||||
if((chi_square < 0) || !(boost::math::isfinite)(chi_square))
|
||||
{
|
||||
return policies::raise_domain_error<RealType>(
|
||||
function, "Chi Square parameter was %1%, but must be > 0 !", chi_square, Policy());
|
||||
}
|
||||
|
||||
return boost::math::gamma_q(degrees_of_freedom / 2, chi_square / 2, Policy());
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const complemented2_type<chi_squared_distribution<RealType, Policy>, RealType>& c)
|
||||
{
|
||||
RealType const& degrees_of_freedom = c.dist.degrees_of_freedom();
|
||||
RealType const& q = c.param;
|
||||
static const char* function = "boost::math::quantile(const chi_squared_distribution<%1%>&, %1%)";
|
||||
// Error check:
|
||||
RealType error_result;
|
||||
if(false == (
|
||||
detail::check_df(function, degrees_of_freedom, &error_result, Policy())
|
||||
&& detail::check_probability(function, q, &error_result, Policy()))
|
||||
)
|
||||
return error_result;
|
||||
|
||||
return 2 * boost::math::gamma_q_inv(degrees_of_freedom / 2, q, Policy());
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mean(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{ // Mean of Chi-Squared distribution = v.
|
||||
return dist.degrees_of_freedom();
|
||||
} // mean
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType variance(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{ // Variance of Chi-Squared distribution = 2v.
|
||||
return 2 * dist.degrees_of_freedom();
|
||||
} // variance
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mode(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType df = dist.degrees_of_freedom();
|
||||
static const char* function = "boost::math::mode(const chi_squared_distribution<%1%>&)";
|
||||
// Most sources only define mode for df >= 2,
|
||||
// but for 0 <= df <= 2, the pdf maximum actually occurs at random variate = 0;
|
||||
// So one could extend the definition of mode thus:
|
||||
//if(df < 0)
|
||||
//{
|
||||
// return policies::raise_domain_error<RealType>(
|
||||
// function,
|
||||
// "Chi-Squared distribution only has a mode for degrees of freedom >= 0, but got degrees of freedom = %1%.",
|
||||
// df, Policy());
|
||||
//}
|
||||
//return (df <= 2) ? 0 : df - 2;
|
||||
|
||||
if(df < 2)
|
||||
return policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Chi-Squared distribution only has a mode for degrees of freedom >= 2, but got degrees of freedom = %1%.",
|
||||
df, Policy());
|
||||
return df - 2;
|
||||
}
|
||||
|
||||
//template <class RealType, class Policy>
|
||||
//inline RealType median(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
//{ // Median is given by Quantile[dist, 1/2]
|
||||
// RealType df = dist.degrees_of_freedom();
|
||||
// if(df <= 1)
|
||||
// return tools::domain_error<RealType>(
|
||||
// BOOST_CURRENT_FUNCTION,
|
||||
// "The Chi-Squared distribution only has a mode for degrees of freedom >= 2, but got degrees of freedom = %1%.",
|
||||
// df);
|
||||
// return df - RealType(2)/3;
|
||||
//}
|
||||
// Now implemented via quantile(half) in derived accessors.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType skewness(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
BOOST_MATH_STD_USING // For ADL
|
||||
RealType df = dist.degrees_of_freedom();
|
||||
return sqrt (8 / df); // == 2 * sqrt(2 / df);
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType df = dist.degrees_of_freedom();
|
||||
return 3 + 12 / df;
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis_excess(const chi_squared_distribution<RealType, Policy>& dist)
|
||||
{
|
||||
RealType df = dist.degrees_of_freedom();
|
||||
return 12 / df;
|
||||
}
|
||||
|
||||
//
|
||||
// Parameter estimation comes last:
|
||||
//
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <class RealType, class Policy>
|
||||
struct df_estimator
|
||||
{
|
||||
df_estimator(RealType a, RealType b, RealType variance, RealType delta)
|
||||
: alpha(a), beta(b), ratio(delta/variance)
|
||||
{ // Constructor
|
||||
}
|
||||
|
||||
RealType operator()(const RealType& df)
|
||||
{
|
||||
if(df <= tools::min_value<RealType>())
|
||||
return 1;
|
||||
chi_squared_distribution<RealType, Policy> cs(df);
|
||||
|
||||
RealType result;
|
||||
if(ratio > 0)
|
||||
{
|
||||
RealType r = 1 + ratio;
|
||||
result = cdf(cs, quantile(complement(cs, alpha)) / r) - beta;
|
||||
}
|
||||
else
|
||||
{ // ratio <= 0
|
||||
RealType r = 1 + ratio;
|
||||
result = cdf(complement(cs, quantile(cs, alpha) / r)) - beta;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
RealType alpha;
|
||||
RealType beta;
|
||||
RealType ratio; // Difference from variance / variance, so fractional.
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class RealType, class Policy>
|
||||
RealType chi_squared_distribution<RealType, Policy>::find_degrees_of_freedom(
|
||||
RealType difference_from_variance,
|
||||
RealType alpha,
|
||||
RealType beta,
|
||||
RealType variance,
|
||||
RealType hint)
|
||||
{
|
||||
static const char* function = "boost::math::chi_squared_distribution<%1%>::find_degrees_of_freedom(%1%,%1%,%1%,%1%,%1%)";
|
||||
// Check for domain errors:
|
||||
RealType error_result;
|
||||
if(false ==
|
||||
detail::check_probability(function, alpha, &error_result, Policy())
|
||||
&& detail::check_probability(function, beta, &error_result, Policy()))
|
||||
{ // Either probability is outside 0 to 1.
|
||||
return error_result;
|
||||
}
|
||||
|
||||
if(hint <= 0)
|
||||
{ // No hint given, so guess df = 1.
|
||||
hint = 1;
|
||||
}
|
||||
|
||||
detail::df_estimator<RealType, Policy> f(alpha, beta, variance, difference_from_variance);
|
||||
tools::eps_tolerance<RealType> tol(policies::digits<RealType, Policy>());
|
||||
boost::uintmax_t max_iter = policies::get_max_root_iterations<Policy>();
|
||||
std::pair<RealType, RealType> r =
|
||||
tools::bracket_and_solve_root(f, hint, RealType(2), false, tol, max_iter, Policy());
|
||||
RealType result = r.first + (r.second - r.first) / 2;
|
||||
if(max_iter >= policies::get_max_root_iterations<Policy>())
|
||||
{
|
||||
policies::raise_evaluation_error<RealType>(function, "Unable to locate solution in a reasonable time:"
|
||||
" either there is no answer to how many degrees of freedom are required"
|
||||
" or the answer is infinite. Current best guess is %1%", result, Policy());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
// This include must be at the end, *after* the accessors
|
||||
// for this distribution have been defined, in order to
|
||||
// keep compilers that support two-phase lookup happy.
|
||||
#include <boost/math/distributions/detail/derived_accessors.hpp>
|
||||
|
||||
#endif // BOOST_MATH_DISTRIBUTIONS_CHI_SQUARED_HPP
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
boost/numeric/odeint/integrate/observer_collection.hpp
|
||||
|
||||
[begin_description]
|
||||
Collection of observers, which are all called during the evolution of the ODE.
|
||||
[end_description]
|
||||
|
||||
Copyright 2011-2012 Karsten Ahnert
|
||||
Copyright 2011-2012 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_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
|
||||
#define BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace odeint {
|
||||
|
||||
template< class State , class Time >
|
||||
class observer_collection
|
||||
{
|
||||
public:
|
||||
|
||||
typedef boost::function< void( const State& , const Time& ) > observer_type;
|
||||
typedef std::vector< observer_type > collection_type;
|
||||
|
||||
void operator()( const State& x , Time t )
|
||||
{
|
||||
for( size_t i=0 ; i<m_observers.size() ; ++i )
|
||||
m_observers[i]( x , t );
|
||||
}
|
||||
|
||||
collection_type& observers( void ) { return m_observers; }
|
||||
const collection_type& observers( void ) const { return m_observers; }
|
||||
|
||||
private:
|
||||
|
||||
collection_type m_observers;
|
||||
};
|
||||
|
||||
} // namespace odeint
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
|
||||
@@ -0,0 +1,55 @@
|
||||
=== New in Version 1.8
|
||||
|
||||
For quick reference, here's a short list of features and capabilities
|
||||
added to _WSJT-X_ since Version 1.7.0:
|
||||
|
||||
- New mode *FT8* designed for fast QSOs
|
||||
|
||||
- New tool *FreqCal* for accurate frequency calibration of your radio
|
||||
|
||||
- Improved decoding performance for JT65, QRA64, and MSK144
|
||||
|
||||
- *SWL* option for third-party decoding short-format MSK144 messages
|
||||
|
||||
- Experimental amplitude and phase equalization for MSK144
|
||||
|
||||
- Options to minimize screen space used by *Main* and *Wide Graph*
|
||||
windows
|
||||
|
||||
- New set of suggested default frequencies specific to the three IARU
|
||||
regions
|
||||
|
||||
- Enhanced scheme for managing table of suggested default operating
|
||||
frequencies
|
||||
|
||||
- Improved CAT control for many radios, including those controlled
|
||||
through Commander or OmniRig
|
||||
|
||||
- Bug fixes and minor tweaks to user interface
|
||||
|
||||
=== Documentation Conventions
|
||||
|
||||
In this manual the following icons call attention to particular types
|
||||
of information:
|
||||
|
||||
NOTE: *Notes* containing information that may be of interest to
|
||||
particuar classes of users.
|
||||
|
||||
TIP: *Tips* on program features or capabilities that might otherwise be
|
||||
overlooked.
|
||||
|
||||
IMPORTANT: *Warnings* about usage that could lead to undesired
|
||||
consequences.
|
||||
|
||||
=== How You Can Contribute
|
||||
|
||||
_WSJT-X_ is part of an open-source project released under the
|
||||
{gnu_gpl} (GPL). If you have programming or documentation skills or
|
||||
would like to contribute to the project in other ways, please make
|
||||
your interests known to the development team. The project's
|
||||
source-code repository can be found at {devsvn}, and most
|
||||
communication among the developers takes place on the email reflector
|
||||
{devmail}. Bug reports and suggestions for new features, improvements
|
||||
to the _WSJT-X_ User Guide, etc., may also be sent to the
|
||||
{wsjt_yahoo_group} email reflector. You must join the relevant group
|
||||
before posting to either email list.
|
||||
@@ -0,0 +1,316 @@
|
||||
#ifndef _DATE_TIME_DATE_PARSING_HPP___
|
||||
#define _DATE_TIME_DATE_PARSING_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 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$
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/parse_format_base.hpp>
|
||||
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
#include <cctype> // ::tolower(int)
|
||||
#else
|
||||
#include <locale> // std::tolower(char, locale)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! A function to replace the std::transform( , , ,tolower) construct
|
||||
/*! This function simply takes a string, and changes all the characters
|
||||
* in that string to lowercase (according to the default system locale).
|
||||
* In the event that a compiler does not support locales, the old
|
||||
* C style tolower() is used.
|
||||
*/
|
||||
inline
|
||||
std::string
|
||||
convert_to_lower(std::string inp)
|
||||
{
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
const std::locale loc(std::locale::classic());
|
||||
#endif
|
||||
std::string::size_type i = 0, n = inp.length();
|
||||
for (; i < n; ++i) {
|
||||
inp[i] =
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
static_cast<char>(std::tolower(inp[i]));
|
||||
#else
|
||||
// tolower and others were brought in to std for borland >= v564
|
||||
// in compiler_config.hpp
|
||||
std::tolower(inp[i], loc);
|
||||
#endif
|
||||
}
|
||||
return inp;
|
||||
}
|
||||
|
||||
//! Helper function for parse_date.
|
||||
/* Used by-value parameter because we change the string and may
|
||||
* want to preserve the original argument */
|
||||
template<class month_type>
|
||||
inline unsigned short
|
||||
month_str_to_ushort(std::string const& s) {
|
||||
if((s.at(0) >= '0') && (s.at(0) <= '9')) {
|
||||
return boost::lexical_cast<unsigned short>(s);
|
||||
}
|
||||
else {
|
||||
std::string str = convert_to_lower(s);
|
||||
typename month_type::month_map_ptr_type ptr = month_type::get_month_map_ptr();
|
||||
typename month_type::month_map_type::iterator iter = ptr->find(str);
|
||||
if(iter != ptr->end()) { // required for STLport
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
return 13; // intentionally out of range - name not found
|
||||
}
|
||||
|
||||
//! Find index of a string in either of 2 arrays
|
||||
/*! find_match searches both arrays for a match to 's'. Both arrays
|
||||
* must contain 'size' elements. The index of the match is returned.
|
||||
* If no match is found, 'size' is returned.
|
||||
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
|
||||
* 'size' can be sent in with: (greg_month::max)() (which 12),
|
||||
* (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues */
|
||||
template<class charT>
|
||||
short find_match(const charT* const* short_names,
|
||||
const charT* const* long_names,
|
||||
short size,
|
||||
const std::basic_string<charT>& s) {
|
||||
for(short i = 0; i < size; ++i){
|
||||
if(short_names[i] == s || long_names[i] == s){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return size; // not-found, return a value out of range
|
||||
}
|
||||
|
||||
//! Generic function to parse a delimited date (eg: 2002-02-10)
|
||||
/*! Accepted formats are: "2003-02-10" or " 2003-Feb-10" or
|
||||
* "2003-Feburary-10"
|
||||
* The order in which the Month, Day, & Year appear in the argument
|
||||
* string can be accomodated by passing in the appropriate ymd_order_spec
|
||||
*/
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_date(const std::string& s, int order_spec = ymd_order_iso) {
|
||||
std::string spec_str;
|
||||
if(order_spec == ymd_order_iso) {
|
||||
spec_str = "ymd";
|
||||
}
|
||||
else if(order_spec == ymd_order_dmy) {
|
||||
spec_str = "dmy";
|
||||
}
|
||||
else { // (order_spec == ymd_order_us)
|
||||
spec_str = "mdy";
|
||||
}
|
||||
|
||||
typedef typename date_type::month_type month_type;
|
||||
unsigned pos = 0;
|
||||
unsigned short year(0), month(0), day(0);
|
||||
typedef typename std::basic_string<char>::traits_type traits_type;
|
||||
typedef boost::char_separator<char, traits_type> char_separator_type;
|
||||
typedef boost::tokenizer<char_separator_type,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> > tokenizer;
|
||||
typedef boost::tokenizer<char_separator_type,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> >::iterator tokenizer_iterator;
|
||||
// may need more delimiters, these work for the regression tests
|
||||
const char sep_char[] = {',','-','.',' ','/','\0'};
|
||||
char_separator_type sep(sep_char);
|
||||
tokenizer tok(s,sep);
|
||||
for(tokenizer_iterator beg=tok.begin();
|
||||
beg!=tok.end() && pos < spec_str.size();
|
||||
++beg, ++pos) {
|
||||
switch(spec_str.at(pos)) {
|
||||
case 'y':
|
||||
{
|
||||
year = boost::lexical_cast<unsigned short>(*beg);
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
month = month_str_to_ushort<month_type>(*beg);
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
{
|
||||
day = boost::lexical_cast<unsigned short>(*beg);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
} //switch
|
||||
}
|
||||
return date_type(year, month, day);
|
||||
}
|
||||
|
||||
//! Generic function to parse undelimited date (eg: 20020201)
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_undelimited_date(const std::string& s) {
|
||||
int offsets[] = {4,2,2};
|
||||
int pos = 0;
|
||||
//typename date_type::ymd_type ymd((year_type::min)(),1,1);
|
||||
unsigned short y = 0, m = 0, d = 0;
|
||||
|
||||
/* The two bool arguments state that parsing will not wrap
|
||||
* (only the first 8 characters will be parsed) and partial
|
||||
* strings will not be parsed.
|
||||
* Ex:
|
||||
* "2005121" will parse 2005 & 12, but not the "1" */
|
||||
boost::offset_separator osf(offsets, offsets+3, false, false);
|
||||
|
||||
typedef typename boost::tokenizer<boost::offset_separator,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> > tokenizer_type;
|
||||
tokenizer_type tok(s, osf);
|
||||
for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) {
|
||||
unsigned short i = boost::lexical_cast<unsigned short>(*ti);
|
||||
switch(pos) {
|
||||
case 0: y = i; break;
|
||||
case 1: m = i; break;
|
||||
case 2: d = i; break;
|
||||
default: break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return date_type(y,m,d);
|
||||
}
|
||||
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the iterators that reference the
|
||||
* begining & end of a char[] or string. All elements are
|
||||
* used in output string */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& end,
|
||||
char)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
while(beg != end) {
|
||||
ss << *beg++;
|
||||
}
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Returns the first string found in the stream referenced by the
|
||||
* begining & end iterators */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& /* end */,
|
||||
std::string const&)
|
||||
{
|
||||
return parse_date<date_type>(*beg);
|
||||
}
|
||||
|
||||
/* I believe the wchar stuff would be best elsewhere, perhaps in
|
||||
* parse_date<>()? In the mean time this gets us started... */
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the iterators that reference the
|
||||
* begining & end of a wstring. All elements are
|
||||
* used in output string */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type from_stream_type(iterator_type& beg,
|
||||
iterator_type const& end,
|
||||
wchar_t)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::locale loc;
|
||||
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
while(beg != end) {
|
||||
ss << fac.narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
|
||||
}
|
||||
#else
|
||||
while(beg != end) {
|
||||
char c = 'X'; // 'X' will cause exception to be thrown
|
||||
const wchar_t wc = *beg++;
|
||||
if (wc >= 0 && wc <= 127)
|
||||
c = static_cast< char >(wc);
|
||||
ss << c;
|
||||
}
|
||||
#endif
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the first wstring found in the stream
|
||||
* referenced by the begining & end iterators */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& /* end */,
|
||||
std::wstring const&) {
|
||||
std::wstring ws = *beg;
|
||||
std::ostringstream ss;
|
||||
std::wstring::iterator wsb = ws.begin(), wse = ws.end();
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::locale loc;
|
||||
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
while(wsb != wse) {
|
||||
ss << fac.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
|
||||
}
|
||||
#else
|
||||
while(wsb != wse) {
|
||||
char c = 'X'; // 'X' will cause exception to be thrown
|
||||
const wchar_t wc = *wsb++;
|
||||
if (wc >= 0 && wc <= 127)
|
||||
c = static_cast< char >(wc);
|
||||
ss << c;
|
||||
}
|
||||
#endif
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
#endif // BOOST_NO_STD_WSTRING
|
||||
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
|
||||
// This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
|
||||
#else
|
||||
//! function called by wrapper functions: date_period_from_(w)string()
|
||||
template<class date_type, class charT>
|
||||
period<date_type, typename date_type::duration_type>
|
||||
from_simple_string_type(const std::basic_string<charT>& s){
|
||||
typedef typename std::basic_string<charT>::traits_type traits_type;
|
||||
typedef typename boost::char_separator<charT, traits_type> char_separator;
|
||||
typedef typename boost::tokenizer<char_separator,
|
||||
typename std::basic_string<charT>::const_iterator,
|
||||
std::basic_string<charT> > tokenizer;
|
||||
const charT sep_list[4] = {'[','/',']','\0'};
|
||||
char_separator sep(sep_list);
|
||||
tokenizer tokens(s, sep);
|
||||
typename tokenizer::iterator tok_it = tokens.begin();
|
||||
std::basic_string<charT> date_string = *tok_it;
|
||||
// get 2 string iterators and generate a date from them
|
||||
typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
|
||||
date_string_end = date_string.end();
|
||||
typedef typename std::iterator_traits<typename std::basic_string<charT>::iterator>::value_type value_type;
|
||||
date_type d1 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
|
||||
date_string = *(++tok_it); // next token
|
||||
date_string_start = date_string.begin(), date_string_end = date_string.end();
|
||||
date_type d2 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
|
||||
return period<date_type, typename date_type::duration_type>(d1, d2);
|
||||
}
|
||||
#endif
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user