Initial Commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
|
||||
#define BOOST_SHARED_ARRAY_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// shared_array.hpp
|
||||
//
|
||||
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
|
||||
// Copyright (c) 2001, 2002 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/shared_array.htm for documentation.
|
||||
//
|
||||
|
||||
#include <boost/smart_ptr/shared_array.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_RANGE_C_SIZE_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_RANGE_C_SIZE_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/size_fwd.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <boost/mpl/aux_/range_c/tag.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct size_impl< aux::half_open_range_tag >
|
||||
{
|
||||
template< typename Range > struct apply
|
||||
: minus<
|
||||
typename Range::finish
|
||||
, typename Range::start
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_RANGE_C_SIZE_HPP_INCLUDED
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Preprocessed version of "boost/mpl/and.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
|
||||
template< bool C_, typename T1, typename T2, typename T3, typename T4 >
|
||||
struct and_impl
|
||||
: false_
|
||||
{
|
||||
};
|
||||
|
||||
template< typename T1, typename T2, typename T3, typename T4 >
|
||||
struct and_impl< true,T1,T2,T3,T4 >
|
||||
: and_impl<
|
||||
BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
|
||||
, T2, T3, T4
|
||||
, true_
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct and_impl<
|
||||
true
|
||||
, true_, true_, true_, true_
|
||||
>
|
||||
: true_
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(T1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(T2)
|
||||
, typename T3 = true_, typename T4 = true_, typename T5 = true_
|
||||
>
|
||||
struct and_
|
||||
|
||||
: aux::and_impl<
|
||||
BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
|
||||
, T2, T3, T4, T5
|
||||
>
|
||||
|
||||
{
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(
|
||||
2
|
||||
, 5
|
||||
, and_
|
||||
)
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_pointer_oserializer.hpp: extenstion of type_info required for
|
||||
// serialization.
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/archive/detail/basic_serializer.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4511 4512)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
class basic_oarchive;
|
||||
class basic_oserializer;
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE basic_pointer_oserializer :
|
||||
public basic_serializer
|
||||
{
|
||||
protected:
|
||||
explicit BOOST_ARCHIVE_DECL basic_pointer_oserializer(
|
||||
const boost::serialization::extended_type_info & type_
|
||||
);
|
||||
public:
|
||||
virtual BOOST_ARCHIVE_DECL ~basic_pointer_oserializer();
|
||||
virtual const basic_oserializer & get_basic_serializer() const = 0;
|
||||
virtual void save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
const void * x
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright David Abrahams 2006. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/concept/detail/backward_compatibility.hpp>
|
||||
|
||||
namespace boost { namespace concepts {
|
||||
|
||||
template <class ModelFnPtr>
|
||||
struct require;
|
||||
|
||||
template <class Model>
|
||||
struct require<void(*)(Model)>
|
||||
{
|
||||
enum { instantiate = sizeof((((Model*)0)->~Model()), 3) };
|
||||
};
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
boost::concepts::require<ModelFnPtr>::instantiate \
|
||||
}
|
||||
|
||||
}} // namespace boost::concept
|
||||
|
||||
#endif // BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
||||
@@ -0,0 +1,140 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://boostorg.github.com/compute for more information.
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_SEARCH_N_HPP
|
||||
#define BOOST_COMPUTE_ALGORITHM_DETAIL_SEARCH_N_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/compute/algorithm/find.hpp>
|
||||
#include <boost/compute/container/vector.hpp>
|
||||
#include <boost/compute/detail/iterator_range_size.hpp>
|
||||
#include <boost/compute/detail/meta_kernel.hpp>
|
||||
#include <boost/compute/system.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
namespace detail {
|
||||
|
||||
///
|
||||
/// \brief Search kernel class
|
||||
///
|
||||
/// Subclass of meta_kernel which is capable of performing search_n
|
||||
///
|
||||
template<class TextIterator, class OutputIterator>
|
||||
class search_n_kernel : public meta_kernel
|
||||
{
|
||||
public:
|
||||
typedef typename std::iterator_traits<TextIterator>::value_type value_type;
|
||||
|
||||
search_n_kernel() : meta_kernel("search_n")
|
||||
{}
|
||||
|
||||
void set_range(TextIterator t_first,
|
||||
TextIterator t_last,
|
||||
value_type value,
|
||||
size_t n,
|
||||
OutputIterator result)
|
||||
{
|
||||
m_n = n;
|
||||
m_n_arg = add_arg<uint_>("n");
|
||||
|
||||
m_value = value;
|
||||
m_value_arg = add_arg<value_type>("value");
|
||||
|
||||
m_count = iterator_range_size(t_first, t_last);
|
||||
m_count = m_count + 1 - m_n;
|
||||
|
||||
*this <<
|
||||
"uint i = get_global_id(0);\n" <<
|
||||
"uint i1 = i;\n" <<
|
||||
"uint j;\n" <<
|
||||
"for(j = 0; j<n; j++,i++)\n" <<
|
||||
"{\n" <<
|
||||
" if(value != " << t_first[expr<uint_>("i")] << ")\n" <<
|
||||
" j = n + 1;\n" <<
|
||||
"}\n" <<
|
||||
"if(j == n)\n" <<
|
||||
result[expr<uint_>("i1")] << " = 1;\n" <<
|
||||
"else\n" <<
|
||||
result[expr<uint_>("i1")] << " = 0;\n";
|
||||
}
|
||||
|
||||
event exec(command_queue &queue)
|
||||
{
|
||||
if(m_count == 0) {
|
||||
return event();
|
||||
}
|
||||
|
||||
set_arg(m_n_arg, uint_(m_n));
|
||||
set_arg(m_value_arg, m_value);
|
||||
|
||||
return exec_1d(queue, 0, m_count);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_n;
|
||||
size_t m_n_arg;
|
||||
size_t m_count;
|
||||
value_type m_value;
|
||||
size_t m_value_arg;
|
||||
};
|
||||
|
||||
} //end detail namespace
|
||||
|
||||
///
|
||||
/// \brief Substring matching algorithm
|
||||
///
|
||||
/// Searches for the first occurrence of n consecutive occurrences of
|
||||
/// value in text [t_first, t_last).
|
||||
/// \return Iterator pointing to beginning of first occurrence
|
||||
///
|
||||
/// \param t_first Iterator pointing to start of text
|
||||
/// \param t_last Iterator pointing to end of text
|
||||
/// \param n Number of times value repeats
|
||||
/// \param value Value which repeats
|
||||
/// \param queue Queue on which to execute
|
||||
///
|
||||
template<class TextIterator, class ValueType>
|
||||
inline TextIterator search_n(TextIterator t_first,
|
||||
TextIterator t_last,
|
||||
size_t n,
|
||||
ValueType value,
|
||||
command_queue &queue = system::default_queue())
|
||||
{
|
||||
// there is no need to check if pattern starts at last n - 1 indices
|
||||
vector<uint_> matching_indices(
|
||||
detail::iterator_range_size(t_first, t_last) + 1 - n,
|
||||
queue.get_context()
|
||||
);
|
||||
|
||||
// search_n_kernel puts value 1 at every index in vector where pattern
|
||||
// of n values starts at
|
||||
detail::search_n_kernel<TextIterator,
|
||||
vector<uint_>::iterator> kernel;
|
||||
|
||||
kernel.set_range(t_first, t_last, value, n, matching_indices.begin());
|
||||
kernel.exec(queue);
|
||||
|
||||
vector<uint_>::iterator index = ::boost::compute::find(
|
||||
matching_indices.begin(), matching_indices.end(), uint_(1), queue
|
||||
);
|
||||
|
||||
// pattern was not found
|
||||
if(index == matching_indices.end())
|
||||
return t_last;
|
||||
|
||||
return t_first + detail::iterator_range_size(matching_indices.begin(), index);
|
||||
}
|
||||
|
||||
} //end compute namespace
|
||||
} //end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_ALGORITHM_DETAIL_SEARCH_N_HPP
|
||||
@@ -0,0 +1,342 @@
|
||||
<HTML><HEAD>
|
||||
|
||||
<TITLE> Decoding Received Blocks </TITLE>
|
||||
|
||||
|
||||
</HEAD><BODY>
|
||||
|
||||
<H1> Decoding Received Blocks </H1>
|
||||
|
||||
Transmitted codewords are decoded from the received data on the basis
|
||||
of the <I>likelihood</I> of the possible codewords, which is the
|
||||
probability of receiving the data that was actually received if the
|
||||
codeword is question were the one that was sent. This software
|
||||
presently deals only with memoryless channels, in which the noise is
|
||||
independent from bit to bit. For such a channel, the likelihood
|
||||
factorizes into a product of likelihoods for each bit.
|
||||
|
||||
For decoding purposes, all that matters is the relative likelihood
|
||||
for a bit to be 1 versus 0. This is captured by the <I>likelihood
|
||||
ratio</I> in favour of a 1, which is P(data | bit is 1) / P(data |
|
||||
bit is 0).
|
||||
|
||||
<P>For a Binary Symmetric Channel with error probability <I>p</I>,
|
||||
the likelihood ratio in favour of a 1 bit is as follows:
|
||||
<BLOCKQUOTE>
|
||||
If the received data was +1: (1-<I>p</I>) / <I>p</I><BR>
|
||||
If the received data was -1: <I>p</I> / (1-<I>p</I>)
|
||||
</BLOCKQUOTE>
|
||||
For an Additive White Gaussian Noise channel, with signals of +1 for a 1 bit
|
||||
and or -1 for a 0 bit, and with noise standard deviation <I>s</I>, the
|
||||
likelihood ratio in favour of a 1 bit when data <I>y</I> was received is
|
||||
<BLOCKQUOTE>
|
||||
exp ( 2y / s<SUP><SMALL>2</SMALL></SUP> )
|
||||
</BLOCKQUOTE>
|
||||
For an Additive White Logistic Noise channel, the corresponding
|
||||
likelihood ratio is
|
||||
<I>d</I><SUB><SMALL>1</SMALL></SUB>/<I>d</I><SUB><SMALL>0</SMALL></SUB>,
|
||||
where
|
||||
<I>d</I><SUB><SMALL>1</SMALL></SUB>=<I>e</I><SUB><SMALL>1</SMALL></SUB>
|
||||
/ (1+<I>e</I><SUB><SMALL>1</SMALL></SUB>)<SUP><SMALL>2</SMALL></SUP> and
|
||||
<I>d</I><SUB><SMALL>0</SMALL></SUB>=<I>e</I><SUB><SMALL>0</SMALL></SUB>
|
||||
/ (1+<I>e</I><SUB><SMALL>0</SMALL></SUB>)<SUP><SMALL>2</SMALL></SUP>,
|
||||
with <I>e</I><SUB><SMALL>1</SMALL></SUB>=exp(-(<I>y</I>-1)/<I>w</I>) and
|
||||
<I>e</I><SUB><SMALL>0</SMALL></SUB>=exp(-(<I>y</I>+1)/<I>w</I>).
|
||||
<BLOCKQUOTE> </BLOCKQUOTE>
|
||||
|
||||
<P>It is usual to consider codewords to be equally likely <I>a
|
||||
priori</I>. This is reasonable if the source messages are all equally
|
||||
likely (any source redundancy being ignored, or remove by a
|
||||
preliminary data compression stage), provided that the mapping from
|
||||
source messages to codewords is onto. Decoding can then be done using
|
||||
only the parity check matrix defining the codewords, without reference
|
||||
to the generator matrix defining the mapping from source messages to
|
||||
codewords. Note that the condition that this mapping be onto isn't
|
||||
true with this software in the atypical case where the code is defined
|
||||
by a parity check matrix with redundant rows; see the discussion of <A
|
||||
HREF="dep-H.html">linear dependence in parity check matrices</A>.
|
||||
This minor complication is mostly ignored here, except by the exhaustive
|
||||
enumeration decoding methods.
|
||||
|
||||
<P>Assuming equal <I>a priori</I> probabilities for codewords, the
|
||||
probability of correctly decoding an entire codeword is minimized by
|
||||
picking the codeword with the highest likelihood. One might instead
|
||||
wish to decode each bit to the value that is most probable. This
|
||||
minimizes the bit error rate, but is not in general guaranteed to lead
|
||||
a decoding for each block to the most probable complete codeword;
|
||||
indeed, the decoding may not be a codeword at all. Minimizing the bit
|
||||
error rate seems nevertheless to be the most sensible objective,
|
||||
unless block boundaries have some significance in a wider context.
|
||||
|
||||
<P>Optimal decoding by either criterion is infeasible for general
|
||||
linear codes when messages are more than about 20 or 30 bits in
|
||||
length. The fundamental advantage of Low Density Parity Check codes
|
||||
is that good (though not optimal) decodings can be obtained by methods
|
||||
such as probability propagation, described next.
|
||||
|
||||
<A NAME="prprp"><H2>Decoding by probability propagation</H2></A>
|
||||
|
||||
<P>The probability propagation algorithm was originally devised by
|
||||
Robert Gallager in the early 1960's and later reinvented by David
|
||||
MacKay and myself. It can be seen as an instance of the sum-product
|
||||
algorithm for inference on factor graphs, and as an instance of belief
|
||||
propagation in probabilistic networks. See the <A
|
||||
HREF="refs.html">references</A> for details. Below, I give a fairly
|
||||
intuitive description of the algorithm.
|
||||
|
||||
<P>The algorithm uses only the parity check matrix for the code, whose
|
||||
columns correspond to codeword bits, and whose rows correspond to
|
||||
parity checks, and the likelihood ratios for the bits derived from the
|
||||
data. It aims to find the probability of each bit of the transmitted
|
||||
codeword being 1, though the results of the algorithm are in general
|
||||
only approximate.
|
||||
|
||||
<P>The begin, information about each bit of the codeword derived from
|
||||
the received data for that bit alone is expressed as a <I>probability
|
||||
ratio</I>, the probability of the bit being 1 divided by the
|
||||
probability of the bit being 0. This probability ratio is equal to
|
||||
the likelihood ratio (see above) for that bit, since 0 and 1 are
|
||||
assumed to be equally likely <I>a priori</I>. As the algorithm
|
||||
progresses, these probability ratios will be modified to take account
|
||||
of information obtained from other bits, in conjunction with the
|
||||
requirement that the parity checks be satisfied. To avoid double
|
||||
counting of information, for every bit, the algorithm maintains a
|
||||
separate probability ratio for each parity check that that bit
|
||||
participates in, giving the probability for that bit to be 1 versus 0
|
||||
based only on information derived from <I>other</I> parity checks,
|
||||
along with the data received for the bit.
|
||||
|
||||
<P>For each parity check, the algorithm maintains separate
|
||||
<I>likelihood ratios</I> (analogous to, but distinct from, the
|
||||
likelihood ratios based on received data), for every bit that
|
||||
participates in that parity check. These ratios give the probability
|
||||
of that parity check being satisfied if the bit in question is 1
|
||||
divided by the probability of the check being satisfied if the bit is
|
||||
0, taking account of the probabilities of each of the <I>other</I>
|
||||
bits participating in this check being 1, as derived from the
|
||||
probability ratios for these bits with respect to this check.
|
||||
|
||||
<P>The algorithm alternates between recalculating the likelihood
|
||||
ratios for each check, which are stored in the <B>lr</B> fields of the
|
||||
parity check matrix entries, and recalculating the probability ratios
|
||||
for each bit, which are stored in the <B>pr</B> fields of the entries
|
||||
in the sparse matrix representation of the parity check matrix. (See
|
||||
the documentation on <A HREF="mod2sparse.html#rep">representation of
|
||||
sparse matrices</A> for details on these entries.)
|
||||
|
||||
<P>Recalculating the likelihood ratio for a check with respect to some
|
||||
bit may appear time consuming, requiring that all possible
|
||||
combinations of values for the other bits participating in the check
|
||||
be considered. Fortunately, there is a short cut. One can calculate
|
||||
<BLOCKQUOTE>
|
||||
<I>t</I>
|
||||
= product of [ 1 / (1+<I>p<SUB><SMALL>i</SMALL></SUB></I>)
|
||||
- <I>p<SUB><SMALL>i</SMALL></SUB></I> /
|
||||
(1+<I>p<SUB><SMALL>i</SMALL></SUB></I>) ]
|
||||
= product of [ 2 / (1+<I>p<SUB><SMALL>i</SMALL></SUB></I>) - 1 ]
|
||||
</BLOCKQUOTE>
|
||||
where the product is over the probability ratios
|
||||
<I>p<SUB><SMALL>i</SMALL></SUB></I> for the other bits participating
|
||||
in this check. Factor <I>i</I> in this product is equal to probability
|
||||
of bit <I>i</I> being 0 minus the probability that it is 1. The terms
|
||||
in the expansion of this product (in the first form above) correspond to
|
||||
possible combinations of values for the other bits, with the result that
|
||||
<I>t</I> will be the probability of the check being satisfied if the bit
|
||||
in question is 0 minus the probability if the bit in question is 1. The
|
||||
likelihood ratio for this check with respect to the bit in question can then
|
||||
be calculated as (1-<I>t</I>)/(1+<I>t</I>).
|
||||
|
||||
<P>For a particular check, the product above differs for different
|
||||
bits, with respect to which we wish to calculate a likelihood ratio,
|
||||
only in that for each bit the factor corresponding to that bit is left
|
||||
out. We can calculate all these products easily by ordering the bits
|
||||
arbitrarily, computing running products of the factor for the first
|
||||
bit, the factors for the first two bits, etc., and also running
|
||||
products of the factor for the last bit, the factors for the last two
|
||||
bits, etc. Multiplying the running product of the factors up to
|
||||
<I>i</I>-1 by the running product of the factors from <I>i</I>+1 on
|
||||
gives the product needed for bit <I>i</I>. The second form of the
|
||||
factors above is used, as it requires less computation, and is still
|
||||
well defined even if some ratios are infinite.
|
||||
|
||||
<P>To recalculate the probability ratio for a bit with respect to a
|
||||
check, all that is need is to multiply together the likelihood ratio
|
||||
for this bit derived from the received data (see above), and the
|
||||
current values of the likelihood ratios for all the <I>other</I>
|
||||
checks that this bit participates in, with respect to this bit. To
|
||||
save time, these products are computed by combining forward and
|
||||
backward products, similarly to the method used for likelihood ratios.
|
||||
|
||||
<P>By including likelihood ratios from all checks, a similar
|
||||
calculation produces the current probability ratio for the bit to be 1
|
||||
versus 0 based on all information that has propagated to the bit so
|
||||
far. This ratio can be thresholded at one to produce the current best
|
||||
guess as to whether this bit is a 1 or a 0.
|
||||
|
||||
<P>The hope is that this algorithm will eventually converge to a state
|
||||
where these bit probabilities give a near-optimal decoding. This is
|
||||
does not always occur, but the algorithm behaves well enough to
|
||||
produce very good results at rates approaching (though not yet
|
||||
reaching) the theoretical Shannon limit.
|
||||
|
||||
|
||||
<P><A NAME="decode"><HR><B>decode</B>: Decode blocks of received data
|
||||
into codewords.
|
||||
|
||||
<BLOCKQUOTE><PRE>
|
||||
decode [ -f ] [ -t | -T ] <I>pchk-file received-file decoded-file</I> [ <I>bp-file</I> ] <I>channel method</I>
|
||||
</PRE>
|
||||
<BLOCKQUOTE>
|
||||
where <TT><I>channel</I></TT> is one of:
|
||||
<BLOCKQUOTE><PRE>
|
||||
bsc <I>error-probability</I>
|
||||
|
||||
awgn <I>standard-deviation</I>
|
||||
|
||||
awln <I>width</I>
|
||||
</PRE></BLOCKQUOTE>
|
||||
and <TT><I>method</I></TT> is one of:
|
||||
<BLOCKQUOTE><PRE>
|
||||
enum-block <TT><I>gen-file</I></TT>
|
||||
|
||||
enum-bit <TT><I>gen-file</I></TT>
|
||||
|
||||
prprp <TT>[-]<I>max-iterations</I></TT>
|
||||
</PRE></BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>Decodes the blocks in <TT><I>received-file</I></TT>, which are
|
||||
assumed to be have been received through the specified channel. The
|
||||
results written to <TT><I>decoded-file</I></TT> are the specified
|
||||
decoding method's guesses as to what bits were sent through the
|
||||
channel, given what was received. The probability of each bit being a
|
||||
1, as judged by the decoding method being used, is written to
|
||||
<TT><I>bp-file</I></TT>, if given.
|
||||
|
||||
<P>A newline is output at the end of each block written to
|
||||
<TT><I>decoded-file</I></TT> and <TT><I>bp-file</I></TT>. Newlines in
|
||||
<TT><I>received-file</I></TT> are ignored. A warning is displayed on
|
||||
standard error if the number of bits in <TT><I>received-file</I></TT>
|
||||
is not a multiple of the block length.
|
||||
|
||||
<P>A summary is displayed on standard error, giving the total number
|
||||
of blocks decoded, the number of blocks that decoded to valid
|
||||
codewords, the average number of iterations of the decoding algorithm
|
||||
used, and the percent of bits that were changed from the values one
|
||||
would guess for them based just on their individual likelihood ratios.
|
||||
|
||||
<P>If the <B>-t</B> option is given, a line of information regarding each block
|
||||
decoded is written to standard output, preceded by a line of headers.
|
||||
The information for each block is as follows:
|
||||
<BLOCKQUOTE>
|
||||
<TABLE>
|
||||
<tr align="left" valign="top">
|
||||
<td> <B>block</B> </td>
|
||||
<td>The number of the block, from zero</td></tr>
|
||||
<tr align="left" valign="top">
|
||||
<td> <B>iterations</B> </td>
|
||||
<td>The number of "iterations" used in decoding. What exactly an iteration
|
||||
is depends on the decoding method used (see
|
||||
<A HREF="decode-detail.html">here</A>).</td></tr>
|
||||
<tr align="left" valign="top">
|
||||
<td> <B>valid</B> </td>
|
||||
<td>Has the value 1 if the decoding is a valid codeword, 0 if not.</td></tr>
|
||||
<tr align="left" valign="top">
|
||||
<td> <B>changed</B> </td>
|
||||
<td>The number of bits in the decoding that differ from the bit that would
|
||||
be chosen based just on the likelihood ratio for that bit. Bits whose
|
||||
likelihood ratios are exactly one contribute 0.5 to this count.</td></tr>
|
||||
</TABLE>
|
||||
</BLOCKQUOTE>
|
||||
The file produced is is suitable for
|
||||
reading into the S-Plus or R statistics packages, with a command such as
|
||||
<BLOCKQUOTE><PRE>
|
||||
data <- read.table(<I>file</I>,header=T)
|
||||
</PRE></BLOCKQUOTE>
|
||||
|
||||
<P>If instead the <B>-T</B> option is given, detailed information on
|
||||
the process of decoding each block will be written to standard output.
|
||||
For a description, see the <A HREF="decode-detail.html">documentation
|
||||
on detailed decoding trace information</A>.
|
||||
|
||||
<P>The type of channel that is assumed is specified after the file
|
||||
name arguments. This may currently be either <TT>bsc</TT> (or
|
||||
<TT>BSC</TT>) for the Binary Symmetric Channel, or <TT>awgn</TT> (or
|
||||
<TT>AWGN</TT>) for the Additive White Gaussian Noise channel, or
|
||||
<TT>awln</TT> (or <TT>AWLN</TT>) for the Additive White Logistic Noise
|
||||
channel. The channel type is followed by an argument specifying the
|
||||
assumed characteristics of the channel, as follows:
|
||||
<BLOCKQUOTE>
|
||||
<P>BSC: The probability that a bit will be flipped by noise - ie, the
|
||||
probability that the bit received is an error.
|
||||
|
||||
<P>AWGN: The standard deviation of the Gaussian noise added to the
|
||||
encodings of the bits.
|
||||
|
||||
<P>AWLN: The width parameter of the logistic distribution for the noise
|
||||
that is added to the encodings of the bits.
|
||||
</BLOCKQUOTE>
|
||||
See the description of <A HREF="channel.html">channel transmission</A>
|
||||
for more about these channels.
|
||||
|
||||
<P>Following the channel specification is a specification of the
|
||||
decoding method to use. The <TT>enum-block</TT> and <TT>enum-bit</TT>
|
||||
methods find the optimal decoding by exhaustive enumeration of
|
||||
codewords derived from all possible source messages. They differ in
|
||||
that <TT>enum-block</TT> decodes to the most likely codeword, whereas
|
||||
<TT>enum-bit</TT> decodes to the bits that are individually most
|
||||
probable. These methods require that a file containing a
|
||||
representation of a generator matrix be given, to allow enumeration of
|
||||
codewords. If the parity check matrix has no redundant rows, any
|
||||
valid generator matrix will give the same decoding (except perhaps if
|
||||
there is a tie). If redundant rows exist, the generator matrix should
|
||||
specify the same set of message bits as the generator matrix that was
|
||||
used for the actual encoding, since the redundancy will lead to some
|
||||
codeword bits being fixed at zero (see <A HREF="dep-H.html">linear
|
||||
dependence in parity check matrices</A>).
|
||||
|
||||
<P>The <TT>prprp</TT> decoding method decodes using <A
|
||||
HREF="#prprp">probability propagation</A>. The maximum number of
|
||||
iterations of probability propagation to do is given following
|
||||
<TT>prprp</TT>. If a minus sign precedes this number, the maximum
|
||||
number of iterations is always done. If no minus sign is present, the
|
||||
algorithm stops once the tentative decoding, based on bit-by-bit
|
||||
probabilities, is a valid codeword. Note that continuing to the
|
||||
maximum number of iterations will usually result in
|
||||
at least slightly different bit probabilities (written to
|
||||
<TT><I>bp-file</I></TT> if specified), and could conceivably change
|
||||
the decoding compared to stopping at the first valid codeword, or
|
||||
result in a failure to decode to a valid codeword even though one was
|
||||
found earlier.
|
||||
|
||||
<P>If the <B>-f</B> option is given, output to <TT><I>decoded-file</I></TT>
|
||||
is flushed after each block. This allows one to use decode as a server,
|
||||
reading blocks to decode from a named pipe, and writing the decoded block
|
||||
to another named pipe.
|
||||
|
||||
|
||||
<P><A NAME="extract"><HR><B>extract</B>: Extract the message bits from a block.
|
||||
|
||||
<BLOCKQUOTE><PRE>
|
||||
extract <I>gen-file decoded-file extracted-file</I>
|
||||
</PRE></BLOCKQUOTE>
|
||||
|
||||
<P>Given a file of codewords in <TT><I>decoded-file</I></TT> (usually,
|
||||
decoded blocks output by <A HREF="#decode"><TT>decode</TT></A>), and a
|
||||
generator matrix from <TT><I>gen-file</I></TT> (needed only to
|
||||
determine where the message bits are located in a codeword), this
|
||||
program writes the message bits extracted from these codewords to the
|
||||
file <TT><I>extracted-file</I></TT>.
|
||||
|
||||
<P>A newline is output at the end of each block written to
|
||||
<TT><I>extracted-file</I></TT>. Newlines in
|
||||
<TT><I>decoded-file</I></TT> are ignored. A warning is displayed on
|
||||
standard error if the number of bits in <TT><I>decoded-file</I></TT>
|
||||
is not a multiple of the block length.
|
||||
|
||||
<HR>
|
||||
|
||||
<A HREF="index.html">Back to index for LDPC software</A>
|
||||
|
||||
</BODY></HTML>
|
||||
@@ -0,0 +1,81 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/interprocess for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP
|
||||
#define BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
#
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/interprocess/creation_tags.hpp>
|
||||
#include <boost/interprocess/detail/type_traits.hpp>
|
||||
#include <boost/interprocess/detail/mpl.hpp>
|
||||
#include <boost/container/detail/placement_new.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
namespace ipcdetail {
|
||||
|
||||
struct named_creation_functor_no_arg{};
|
||||
|
||||
template <class T, class Arg = named_creation_functor_no_arg>
|
||||
class named_creation_functor
|
||||
{
|
||||
typedef named_creation_functor_no_arg no_arg_t;
|
||||
public:
|
||||
named_creation_functor(create_enum_t type, Arg arg = Arg())
|
||||
: m_creation_type(type), m_arg(arg){}
|
||||
|
||||
template<class ArgType>
|
||||
void construct(void *address, typename enable_if_c<is_same<ArgType, no_arg_t>::value>::type * = 0) const
|
||||
{ ::new(address, boost_container_new_t())T; }
|
||||
|
||||
template<class ArgType>
|
||||
void construct(void *address, typename enable_if_c<!is_same<ArgType, no_arg_t>::value>::type * = 0) const
|
||||
{ ::new(address, boost_container_new_t())T(m_arg); }
|
||||
|
||||
bool operator()(void *address, std::size_t, bool created) const
|
||||
{
|
||||
switch(m_creation_type){
|
||||
case DoOpen:
|
||||
return true;
|
||||
break;
|
||||
case DoCreate:
|
||||
case DoOpenOrCreate:
|
||||
if(created){
|
||||
construct<Arg>(address);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static std::size_t get_min_size()
|
||||
{ return sizeof(T); }
|
||||
|
||||
private:
|
||||
create_enum_t m_creation_type;
|
||||
Arg m_arg;
|
||||
};
|
||||
|
||||
} //namespace ipcdetail {
|
||||
} //namespace interprocess {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP
|
||||
@@ -0,0 +1,226 @@
|
||||
=== Frequency Calibration
|
||||
|
||||
Many _WSJT-X_ capabilities depend on signal-detection bandwidths no
|
||||
more than a few Hz. Frequency accuracy and stability are therefore
|
||||
unusually important. We provide tools to enable accurate frequency
|
||||
calibration of your radio, as well as precise frequency measurement of
|
||||
on-the-air signals. The calibration procedure works by automatically
|
||||
cycling your CAT-controlled radio through a series of preset
|
||||
frequencies of carrier-based signals at reliably known frequencies,
|
||||
measuring the error in dial frequency for each signal.
|
||||
|
||||
You will probably find it convenient to define and use a special
|
||||
<<CONFIG-MENU,Configuration>> dedicated to frequency calibration.
|
||||
Then complete the following steps, as appropriate for your system.
|
||||
|
||||
- Switch to FreqCal mode
|
||||
|
||||
- In the _Working Frequencies_ box on the *Settings -> Frequencies*
|
||||
tab, delete any default frequencies for *FreqCal* mode that are not
|
||||
relevant for your location. You may want to replace some of them with
|
||||
reliably known frequencies receivable at your location.
|
||||
|
||||
TIP: We find major-city AM broadcast stations generally serve well as
|
||||
frequency calibrators at the low frequency end of the spectrum. In
|
||||
North America we also use the standard time-and-frequency broadcasts
|
||||
of WWV at 2.500, 5.000, 10.000, 15.000, and 20.000 MHz, and CHU at
|
||||
3.330, 7.850, and 14.670 MHz. Similar shortwave signals are available
|
||||
in other parts of the world.
|
||||
|
||||
- In most cases you will want to start by deleting any existing file
|
||||
`fmt.all` in the directory where your log files are kept.
|
||||
|
||||
- To cycle automatically through your chosen list of calibration
|
||||
frequencies, check *Execute frequency calibration cycle* on the
|
||||
*Tools* menu. _WSJT-X_ will spend 30 seconds at each
|
||||
frequency. Initially no measurement data is saved to the `fmt.all`
|
||||
file although it is displayed on screen, this allows you to check you
|
||||
current calibration parameters.
|
||||
|
||||
- During the calibration procedure, the radio's USB dial frequency is
|
||||
offset 1500 Hz below each *FreqCal* entry in the default frequencies
|
||||
list. As shown in the screen shot below, detected signal carriers
|
||||
therefore appear at about 1500 Hz in the _WSJT-X_ waterfall.
|
||||
|
||||
- To start a measurement session check the *Measure* option and let
|
||||
the calibration cycle run for at least one complete sequence. Note
|
||||
that, while measuring, any existing calibration parameters are
|
||||
automatically disabled so you may have to increase the *FTol* range if
|
||||
your rig is off freqeuncy by more than a few Hertz in order to capture
|
||||
valid measurements.
|
||||
|
||||
image::FreqCal.png[align="left",alt="FreqCal"]
|
||||
|
||||
With modern synthesized radios, small measured offsets from 1500 Hz
|
||||
will exhibit a straight-line dependence on frequency. You can
|
||||
approximate the calibration of your radio by simply dividing the
|
||||
measured frequency offset (in Hz) at the highest reliable frequency by
|
||||
the nominal frequency itself (in MHz). For example, the 20 MHz
|
||||
measurement for WWV shown above produced a measured tone offset of
|
||||
24.6 Hz, displayed in the _WSJT-X_ decoded text window. The resulting
|
||||
calibration constant is 24.6/20=1.23 parts per million. This number
|
||||
may be entered as *Slope* on the *settings -> Frequencies* tab.
|
||||
|
||||
A more precise calibration can be effected by fitting the intercept
|
||||
and slope of a straight line to the whole sequence of calibration
|
||||
measurements, as shown for these measurements in the graph plotted
|
||||
below. Software tools for completing this task are included with the
|
||||
_WSJT-X_ installation, and detailed instructions for their use are
|
||||
available at https://physics.princeton.edu/pulsar/k1jt/FMT_User.pdf.
|
||||
|
||||
Using these tools and no specialized hardware beyond your
|
||||
CAT-interfaced radio, you can calibrate the radio to better than 1 Hz
|
||||
and compete very effectively in the ARRL's periodic Frequency
|
||||
Measuring Tests.
|
||||
|
||||
image::FreqCal_Graph.png[align="left",alt="FreqCal_Graph"]
|
||||
|
||||
After running *Execute frequency calibration cycle* at least once with
|
||||
good results, check and edit the file `fmt.all` in the log directory
|
||||
and delete any spurious or outlier measurements. The line-fitting
|
||||
procedure can then be carried out automatically by clicking *Solve for
|
||||
calibration parameters* on the *Tools* menu. The results will be
|
||||
displayed as in the following screen shot. Estimated uncertainties
|
||||
are included for slope and intercept; `N` is the number of averaged
|
||||
frequency measurements included in the fit, and `StdDev` is the root
|
||||
mean square deviation of averaged measurements from the fitted
|
||||
straight line. If the solution seems valid you will be offered an
|
||||
*Apply* button to push that will automatically set the calibration
|
||||
parameters in *Settings -> Frequencies -> Frequency Calibration*.
|
||||
|
||||
image::FreqCal_Results.png[align="center",alt="FreqCal_Results"]
|
||||
|
||||
For a quick visual check of the resulting calibration, stay in
|
||||
*FreqCal* mode with the *Measure* option cleared. _WSJT-X_ will show
|
||||
the adjusted results directly on the waterfall and the displayed
|
||||
records.
|
||||
|
||||
=== Reference Spectrum
|
||||
|
||||
_WSJT-X_ provides a tool that can be used to determine the detailed
|
||||
shape of your receiver's passband. Disconnect your antenna or tune to
|
||||
a quiet frequency with no signals. With _WSJT-X_ running in one of
|
||||
the slow modes, select *Measure reference spectrum* from the *Tools*
|
||||
menu. Wait for about a minute and then hit the *Stop* button. A file
|
||||
named `refspec.dat` will appear in your log directory.
|
||||
|
||||
[ ... more to come ... ]
|
||||
|
||||
=== Phase Equalization
|
||||
|
||||
*Measure phase response* under the *Tools* menu is for advanced MSK144
|
||||
users. Phase equalization is used to compensate for group-delay
|
||||
variation across your receiver passband. Careful application of this
|
||||
facility can reduce intersymbol interference, resulting in improved
|
||||
decoding sensitivity. If you use a software-defined receiver with
|
||||
linear-phase filters there is no need to apply phase equalization.
|
||||
|
||||
After a frame of received data has been decoded, *Measure phase
|
||||
response* generates an undistorted audio waveform equal to the one
|
||||
generated by the transmitting station. Its Fourier transform is then
|
||||
used as a frequency-dependent phase reference to compare with the
|
||||
phase of the received frame's Fourier coefficients. Phase differences
|
||||
between the reference spectrum and received spectrum will include
|
||||
contributions from the originating station's transmit filter, the
|
||||
propagation channel, and filters in the receiver. If the received
|
||||
frame originates from a station known to transmit signals having
|
||||
little phase distortion (say, a station known to use a properly
|
||||
adjusted software-defined-transceiver) and if the received signal is
|
||||
relatively free from multipath distortion so that the channel phase is
|
||||
close to linear, the measured phase differences will be representative
|
||||
of the local receiver's phase response.
|
||||
|
||||
Complete the following steps to generate a phase equalization curve:
|
||||
|
||||
- Record a number of wav files that contain decodable signals from
|
||||
your chosen reference station. Best results will be obtained when the
|
||||
signal-to-noise ratio of the reference signals is 10 dB or greater.
|
||||
|
||||
- Enter the callsign of the reference station in the DX Call box.
|
||||
|
||||
- Select *Measure phase response* from the *Tools* menu, and open each
|
||||
of the wav files in turn. The mode character on decoded text lines
|
||||
will change from `&` to `^` while _WSJT-X_ is measuring the phase
|
||||
response, and it will change back to `&` after the measurement is
|
||||
completed. The program needs to average a number of high-SNR frames to
|
||||
accurately estimate the phase, so it may be necessary to process
|
||||
several wav files. The measurement can be aborted at any time by
|
||||
selecting *Measure phase response* again to toggle the phase
|
||||
measurement off.
|
||||
|
||||
+
|
||||
|
||||
When the measurement is complete _WSJT-X_ will save the measured
|
||||
phase response in the *Log directory*, in a file with suffix
|
||||
".pcoeff". The filename will contain the callsign of the reference
|
||||
station and a timestamp, for example `K0TPP_170923_112027.pcoeff`.
|
||||
|
||||
- Select *Equalization tools ...* under the *Tools* menu and click the
|
||||
*Phase ...* button to view the contents of the *Log directory*. Select
|
||||
the desired pcoeff file. The measured phase values will be plotted as
|
||||
filled circles along with a fitted red curve labeled "Proposed". This is
|
||||
the proposed phase equalization curve. It's a good idea to repeat the
|
||||
phase measurement several times, using different wav files for each
|
||||
measurement, to ensure that your measurements are repeatable.
|
||||
|
||||
- Once you are satisfied with a fitted curve, push the *Apply* button
|
||||
to save the proposed response. The red curve will be replaced with a
|
||||
light green curve labeled "Current" to indicate that the phase
|
||||
equalization curve is now being applied to the received data. Another
|
||||
curve labeled "Group Delay" will appear. The "Group Delay" curve shows
|
||||
the group delay variation across the passband, in ms. Click the
|
||||
*Discard* button to remove the captured data, leaving only the applied
|
||||
phase equalization curve and corresponding group delay curve.
|
||||
|
||||
- To revert to no phase equalization, push the *Restore Defaults*
|
||||
button followed by the *Apply* button.
|
||||
|
||||
The three numbers printed at the end of each MSK144 decode line can be
|
||||
used to assess the improvement provided by equalization. These numbers
|
||||
are: `N` = Number of frames averaged, `H` = Number of hard bit errors
|
||||
corrected, `E` = Size of MSK eye diagram opening.
|
||||
|
||||
Here is a decode of K0TPP obtained while *Measure phase response* was measuring
|
||||
the phase response:
|
||||
|
||||
103900 17 6.5 1493 ^ WA8CLT K0TPP +07 1 0 1.2
|
||||
|
||||
The "^" symbol indicates that a phase measurement is being accumulated
|
||||
but is not yet finished. The three numbers at the end of the line
|
||||
indicate that one frame was used to obtain the decode, there were no
|
||||
hard bit errors, and the eye-opening was 1.2 on a -2 to +2
|
||||
scale. Here's how the same decode looks after phase equalization:
|
||||
|
||||
103900 17 6.5 1493 & WA8CLT K0TPP +07 1 0 1.6
|
||||
|
||||
In this case, equalization has increased the eye opening from 1.2 to
|
||||
1.6. Larger positive eye openings are associated with reduced
|
||||
likelihood of bit errors and higher likelihood that a frame will be
|
||||
successfully decoded. In this case, the larger eye-opening tells us
|
||||
that phase equalization was successful, but it is important to note
|
||||
that this test does not by itself tell us whether the applied phase
|
||||
equalization curve is going to improve decoding of signals other than
|
||||
those from the reference station, K0TPP.
|
||||
|
||||
It's a good idea to carry out before and after comparisons using a
|
||||
large number of saved wav files with signals from many different
|
||||
stations, to help decide whether your equalization curve improves
|
||||
decoding for most signals. When doing such comparisons, keep in mind
|
||||
that equalization may cause _WSJT-X_ to successfully decode a frame
|
||||
that was not decoded before equalization was applied. For this
|
||||
reason, be sure that the time "T" of the two decodes are the same
|
||||
before comparing their end-of-line quality numbers.
|
||||
|
||||
When comparing before and after decodes having the same "T", keep in
|
||||
mind that a smaller first number means that decoding has improved,
|
||||
even if the second and third numbers appear to be "worse". For
|
||||
example, suppose that the end-of-line quality numbers before
|
||||
equalization are `2 0 0.2` and after equalization `1 5 -0.5`. These
|
||||
numbers show improved decoding because the decode was obtained using
|
||||
only a single frame after equalization whereas a 2-frame average was
|
||||
needed before equalization. This implies that shorter and/or weaker
|
||||
pings could be decodable.
|
||||
|
||||
NOTE: Further details on phase equalization and examples of fitted
|
||||
phase curves and eye diagrams can be found in the article on MSK144 by
|
||||
K9AN and K1JT published in {msk144}.
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright Gottfried Ganßauge 2003.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# ifndef BOOST_PYTHON_DETAIL_DEALLOC_HPP_
|
||||
# define BOOST_PYTHON_DETAIL_DEALLOC_HPP_
|
||||
namespace boost { namespace python { namespace detail {
|
||||
extern "C"
|
||||
{
|
||||
inline void dealloc(PyObject* self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
}
|
||||
}}} // namespace boost::python::detail
|
||||
# endif // BOOST_PYTHON_DETAIL_DEALLOC_HPP_
|
||||
@@ -0,0 +1,137 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP
|
||||
#define BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP
|
||||
|
||||
#include <boost/range/adaptor/argument_fwd.hpp>
|
||||
#include <boost/range/detail/default_constructible_unary_fn.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
// A type generator to produce the transform_iterator type conditionally
|
||||
// including a wrapped predicate as appropriate.
|
||||
template<typename P, typename It>
|
||||
struct transform_iterator_gen
|
||||
{
|
||||
typedef transform_iterator<
|
||||
typename default_constructible_unary_fn_gen<
|
||||
P,
|
||||
typename transform_iterator<P, It>::reference
|
||||
>::type,
|
||||
It
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class F, class R >
|
||||
struct transformed_range :
|
||||
public boost::iterator_range<
|
||||
typename transform_iterator_gen<
|
||||
F, typename range_iterator<R>::type>::type>
|
||||
{
|
||||
private:
|
||||
typedef typename transform_iterator_gen<
|
||||
F, typename range_iterator<R>::type>::type transform_iter_t;
|
||||
|
||||
typedef boost::iterator_range<transform_iter_t> base;
|
||||
|
||||
public:
|
||||
typedef typename default_constructible_unary_fn_gen<
|
||||
F,
|
||||
typename transform_iterator<
|
||||
F,
|
||||
typename range_iterator<R>::type
|
||||
>::reference
|
||||
>::type transform_fn_type;
|
||||
|
||||
typedef R source_range_type;
|
||||
|
||||
transformed_range(transform_fn_type f, R& r)
|
||||
: base(transform_iter_t(boost::begin(r), f),
|
||||
transform_iter_t(boost::end(r), f))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct transform_holder : holder<T>
|
||||
{
|
||||
transform_holder( T r ) : holder<T>(r)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template< class SinglePassRange, class UnaryFunction >
|
||||
inline transformed_range<UnaryFunction,SinglePassRange>
|
||||
operator|( SinglePassRange& r,
|
||||
const transform_holder<UnaryFunction>& f )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<SinglePassRange>));
|
||||
|
||||
return transformed_range<UnaryFunction,SinglePassRange>( f.val, r );
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class UnaryFunction >
|
||||
inline transformed_range<UnaryFunction, const SinglePassRange>
|
||||
operator|( const SinglePassRange& r,
|
||||
const transform_holder<UnaryFunction>& f )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return transformed_range<UnaryFunction, const SinglePassRange>(
|
||||
f.val, r);
|
||||
}
|
||||
|
||||
} // 'range_detail'
|
||||
|
||||
using range_detail::transformed_range;
|
||||
|
||||
namespace adaptors
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const range_detail::forwarder<range_detail::transform_holder>
|
||||
transformed =
|
||||
range_detail::forwarder<range_detail::transform_holder>();
|
||||
}
|
||||
|
||||
template<class UnaryFunction, class SinglePassRange>
|
||||
inline transformed_range<UnaryFunction, SinglePassRange>
|
||||
transform(SinglePassRange& rng, UnaryFunction fn)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<SinglePassRange>));
|
||||
|
||||
return transformed_range<UnaryFunction, SinglePassRange>(fn, rng);
|
||||
}
|
||||
|
||||
template<class UnaryFunction, class SinglePassRange>
|
||||
inline transformed_range<UnaryFunction, const SinglePassRange>
|
||||
transform(const SinglePassRange& rng, UnaryFunction fn)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return transformed_range<UnaryFunction, const SinglePassRange>(
|
||||
fn, rng);
|
||||
}
|
||||
} // 'adaptors'
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://boostorg.github.com/compute for more information.
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_COMPUTE_ASYNC_HPP
|
||||
#define BOOST_COMPUTE_ASYNC_HPP
|
||||
|
||||
/// \file
|
||||
///
|
||||
/// Meta-header to include all Boost.Compute async headers.
|
||||
|
||||
#include <boost/compute/async/future.hpp>
|
||||
#include <boost/compute/async/wait_guard.hpp>
|
||||
|
||||
#endif // BOOST_COMPUTE_ASYNC_HPP
|
||||
@@ -0,0 +1,277 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file matches_.hpp
|
||||
/// Definitions of matches_ specializations
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1> >
|
||||
: or_2<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1> >
|
||||
: detail::and_2<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 2>, proto::basic_expr<Tag, Args2, 2> >
|
||||
: and_2<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 2>, proto::basic_expr<proto::_, Args2, 2> >
|
||||
: and_2<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2> >
|
||||
: or_3<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2> >
|
||||
: detail::and_3<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 3>, proto::basic_expr<Tag, Args2, 3> >
|
||||
: and_3<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 3>, proto::basic_expr<proto::_, Args2, 3> >
|
||||
: and_3<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3> >
|
||||
: or_4<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3> >
|
||||
: detail::and_4<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 4>, proto::basic_expr<Tag, Args2, 4> >
|
||||
: and_4<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 4>, proto::basic_expr<proto::_, Args2, 4> >
|
||||
: and_4<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4> >
|
||||
: or_5<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4> >
|
||||
: detail::and_5<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 5>, proto::basic_expr<Tag, Args2, 5> >
|
||||
: and_5<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 5>, proto::basic_expr<proto::_, Args2, 5> >
|
||||
: and_5<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4 , G5> >
|
||||
: or_6<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4 , G5
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4 , G5> >
|
||||
: detail::and_6<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar > , matches_< Expr , BasicExpr , typename G5::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 6>, proto::basic_expr<Tag, Args2, 6> >
|
||||
: and_6<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 6>, proto::basic_expr<proto::_, Args2, 6> >
|
||||
: and_6<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4 , G5 , G6> >
|
||||
: or_7<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4 , G5 , G6
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4 , G5 , G6> >
|
||||
: detail::and_7<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar > , matches_< Expr , BasicExpr , typename G5::proto_grammar > , matches_< Expr , BasicExpr , typename G6::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 7>, proto::basic_expr<Tag, Args2, 7> >
|
||||
: and_7<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 7>, proto::basic_expr<proto::_, Args2, 7> >
|
||||
: and_7<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7> >
|
||||
: or_8<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7> >
|
||||
: detail::and_8<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar > , matches_< Expr , BasicExpr , typename G5::proto_grammar > , matches_< Expr , BasicExpr , typename G6::proto_grammar > , matches_< Expr , BasicExpr , typename G7::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 8>, proto::basic_expr<Tag, Args2, 8> >
|
||||
: and_8<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 8>, proto::basic_expr<proto::_, Args2, 8> >
|
||||
: and_8<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7 , typename G8>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8> >
|
||||
: or_9<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7 , typename G8>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8> >
|
||||
: detail::and_9<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar > , matches_< Expr , BasicExpr , typename G5::proto_grammar > , matches_< Expr , BasicExpr , typename G6::proto_grammar > , matches_< Expr , BasicExpr , typename G7::proto_grammar > , matches_< Expr , BasicExpr , typename G8::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 9>, proto::basic_expr<Tag, Args2, 9> >
|
||||
: and_9<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child8>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child8>::value_type::proto_grammar , typename Args2::child8::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 9>, proto::basic_expr<proto::_, Args2, 9> >
|
||||
: and_9<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child8>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child8>::value_type::proto_grammar , typename Args2::child8::proto_grammar >
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr , typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7 , typename G8 , typename G9>
|
||||
struct matches_<Expr, BasicExpr, proto::or_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8 , G9> >
|
||||
: or_10<
|
||||
matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
|
||||
Expr, BasicExpr , G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8 , G9
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Expr, typename BasicExpr, typename G0 , typename G1 , typename G2 , typename G3 , typename G4 , typename G5 , typename G6 , typename G7 , typename G8 , typename G9>
|
||||
struct matches_<Expr, BasicExpr, proto::and_<G0 , G1 , G2 , G3 , G4 , G5 , G6 , G7 , G8 , G9> >
|
||||
: detail::and_10<
|
||||
matches_< Expr , BasicExpr , typename G0::proto_grammar >::value,
|
||||
matches_< Expr , BasicExpr , typename G1::proto_grammar > , matches_< Expr , BasicExpr , typename G2::proto_grammar > , matches_< Expr , BasicExpr , typename G3::proto_grammar > , matches_< Expr , BasicExpr , typename G4::proto_grammar > , matches_< Expr , BasicExpr , typename G5::proto_grammar > , matches_< Expr , BasicExpr , typename G6::proto_grammar > , matches_< Expr , BasicExpr , typename G7::proto_grammar > , matches_< Expr , BasicExpr , typename G8::proto_grammar > , matches_< Expr , BasicExpr , typename G9::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 10>, proto::basic_expr<Tag, Args2, 10> >
|
||||
: and_10<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child8>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child8>::value_type::proto_grammar , typename Args2::child8::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child9>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child9>::value_type::proto_grammar , typename Args2::child9::proto_grammar >
|
||||
>
|
||||
{};
|
||||
template<typename Expr, typename Tag, typename Args1, typename Args2>
|
||||
struct matches_< Expr, proto::basic_expr<Tag, Args1, 10>, proto::basic_expr<proto::_, Args2, 10> >
|
||||
: and_10<
|
||||
matches_< typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar , typename Args2::child0::proto_grammar >::value,
|
||||
matches_< typename detail::expr_traits<typename Args1::child1>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child1>::value_type::proto_grammar , typename Args2::child1::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child2>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child2>::value_type::proto_grammar , typename Args2::child2::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child3>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child3>::value_type::proto_grammar , typename Args2::child3::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child4>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child4>::value_type::proto_grammar , typename Args2::child4::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child5>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child5>::value_type::proto_grammar , typename Args2::child5::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child6>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child6>::value_type::proto_grammar , typename Args2::child6::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child7>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child7>::value_type::proto_grammar , typename Args2::child7::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child8>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child8>::value_type::proto_grammar , typename Args2::child8::proto_grammar > , matches_< typename detail::expr_traits<typename Args1::child9>::value_type::proto_derived_expr , typename detail::expr_traits<typename Args1::child9>::value_type::proto_grammar , typename Args2::child9::proto_grammar >
|
||||
>
|
||||
{};
|
||||
@@ -0,0 +1,104 @@
|
||||
// boost asinh.hpp header file
|
||||
|
||||
// (C) Copyright Eric Ford 2001 & Hubert Holin.
|
||||
// (C) Copyright John Maddock 2008.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_ACOSH_HPP
|
||||
#define BOOST_ACOSH_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
#include <boost/math/policies/error_handling.hpp>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/log1p.hpp>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
// This is the inverse of the hyperbolic cosine function.
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename T, typename Policy>
|
||||
inline T acosh_imp(const T x, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
if(x < 1)
|
||||
{
|
||||
return policies::raise_domain_error<T>(
|
||||
"boost::math::acosh<%1%>(%1%)",
|
||||
"acosh requires x >= 1, but got x = %1%.", x, pol);
|
||||
}
|
||||
else if ((x - 1) >= tools::root_epsilon<T>())
|
||||
{
|
||||
if (x > 1 / tools::root_epsilon<T>())
|
||||
{
|
||||
// http://functions.wolfram.com/ElementaryFunctions/ArcCosh/06/01/06/01/0001/
|
||||
// approximation by laurent series in 1/x at 0+ order from -1 to 0
|
||||
return log(x) + constants::ln_two<T>();
|
||||
}
|
||||
else if(x < 1.5f)
|
||||
{
|
||||
// This is just a rearrangement of the standard form below
|
||||
// devised to minimse loss of precision when x ~ 1:
|
||||
T y = x - 1;
|
||||
return boost::math::log1p(y + sqrt(y * y + 2 * y), pol);
|
||||
}
|
||||
else
|
||||
{
|
||||
// http://functions.wolfram.com/ElementaryFunctions/ArcCosh/02/
|
||||
return( log( x + sqrt(x * x - 1) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// see http://functions.wolfram.com/ElementaryFunctions/ArcCosh/06/01/04/01/0001/
|
||||
T y = x - 1;
|
||||
|
||||
// approximation by taylor series in y at 0 up to order 2
|
||||
T result = sqrt(2 * y) * (1 - y /12 + 3 * y * y / 160);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename Policy>
|
||||
inline typename tools::promote_args<T>::type acosh(T x, const Policy&)
|
||||
{
|
||||
typedef typename tools::promote_args<T>::type result_type;
|
||||
typedef typename policies::evaluation<result_type, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
|
||||
detail::acosh_imp(static_cast<value_type>(x), forwarding_policy()),
|
||||
"boost::math::acosh<%1%>(%1%)");
|
||||
}
|
||||
template<typename T>
|
||||
inline typename tools::promote_args<T>::type acosh(T x)
|
||||
{
|
||||
return boost::math::acosh(x, policies::policy<>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BOOST_ACOSH_HPP */
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2006 Tobias Schwinger
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_PAIR_07222005_1203)
|
||||
#define FUSION_PAIR_07222005_1203
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
|
||||
#if defined (BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
# pragma warning (disable: 4512) // assignment operator could not be generated.
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
// A half runtime pair where the first type does not have data
|
||||
template <typename First, typename Second>
|
||||
struct pair
|
||||
{
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair()
|
||||
: second() {}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair const& rhs)
|
||||
: second(rhs.second) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair&& rhs)
|
||||
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
|
||||
#endif
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(typename detail::call_param<Second>::type val)
|
||||
: second(val) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Second2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
pair(Second2&& val
|
||||
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
|
||||
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
|
||||
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
|
||||
#endif
|
||||
|
||||
template <typename Second2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair<First, Second2> const& rhs)
|
||||
: second(rhs.second) {}
|
||||
|
||||
template <typename Second2>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair<First, Second2> const& rhs)
|
||||
{
|
||||
second = rhs.second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair const& rhs)
|
||||
{
|
||||
second = rhs.second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair&& rhs)
|
||||
{
|
||||
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef First first_type;
|
||||
typedef Second second_type;
|
||||
Second second;
|
||||
};
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template<typename First, typename Second>
|
||||
struct make_pair
|
||||
{
|
||||
typedef fusion::pair<First,
|
||||
typename detail::as_fusion_element<Second>::type> type;
|
||||
};
|
||||
|
||||
template<class Pair>
|
||||
struct first
|
||||
{
|
||||
typedef typename Pair::first_type type;
|
||||
};
|
||||
|
||||
template<class Pair>
|
||||
struct second
|
||||
{
|
||||
typedef typename Pair::second_type type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename First, typename Second>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::make_pair<First,Second>::type
|
||||
make_pair(Second const& val)
|
||||
{
|
||||
return pair<First, typename detail::as_fusion_element<Second>::type>(val);
|
||||
}
|
||||
|
||||
template <typename First, typename Second>
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& os, pair<First, Second> const& p)
|
||||
{
|
||||
os << p.second;
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename First, typename Second>
|
||||
inline std::istream&
|
||||
operator>>(std::istream& is, pair<First, Second>& p)
|
||||
{
|
||||
is >> p.second;
|
||||
return is;
|
||||
}
|
||||
|
||||
template <typename First, typename SecondL, typename SecondR>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline bool
|
||||
operator==(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
|
||||
{
|
||||
return l.second == r.second;
|
||||
}
|
||||
|
||||
template <typename First, typename SecondL, typename SecondR>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline bool
|
||||
operator!=(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
|
||||
{
|
||||
return l.second != r.second;
|
||||
}
|
||||
|
||||
template <typename First, typename SecondL, typename SecondR>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline bool
|
||||
operator<(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
|
||||
{
|
||||
return l.second < r.second;
|
||||
}
|
||||
}}
|
||||
|
||||
#if defined (BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,200 @@
|
||||
#ifndef TRANSCEIVER_FACTORY_HPP__
|
||||
#define TRANSCEIVER_FACTORY_HPP__
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
#include "Transceiver.hpp"
|
||||
|
||||
#include "qt_helpers.hpp"
|
||||
|
||||
class QString;
|
||||
class QThread;
|
||||
class QDir;
|
||||
|
||||
//
|
||||
// Transceiver Factory
|
||||
//
|
||||
class TransceiverFactory
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS (DataBits StopBits Handshake PTTMethod TXAudioSource SplitMode)
|
||||
|
||||
public:
|
||||
//
|
||||
// Capabilities of a Transceiver that can be determined without
|
||||
// actually instantiating one, these are for use in Configuration
|
||||
// GUI behaviour determination
|
||||
//
|
||||
struct Capabilities
|
||||
{
|
||||
enum PortType {none, serial, network, usb};
|
||||
|
||||
explicit Capabilities (int model_number = 0
|
||||
, PortType port_type = none
|
||||
, bool has_CAT_PTT = false
|
||||
, bool has_CAT_PTT_mic_data = false
|
||||
, bool has_CAT_indirect_serial_PTT = false
|
||||
, bool asynchronous = false)
|
||||
: model_number_ {model_number}
|
||||
, port_type_ {port_type}
|
||||
, has_CAT_PTT_ {has_CAT_PTT}
|
||||
, has_CAT_PTT_mic_data_ {has_CAT_PTT_mic_data}
|
||||
, has_CAT_indirect_serial_PTT_ {has_CAT_indirect_serial_PTT}
|
||||
, asynchronous_ {asynchronous}
|
||||
{
|
||||
}
|
||||
|
||||
int model_number_;
|
||||
PortType port_type_;
|
||||
bool has_CAT_PTT_;
|
||||
bool has_CAT_PTT_mic_data_;
|
||||
bool has_CAT_indirect_serial_PTT_; // OmniRig controls RTS/DTR via COM interface
|
||||
bool asynchronous_;
|
||||
};
|
||||
|
||||
//
|
||||
// Dictionary of Transceiver types Capabilities
|
||||
//
|
||||
typedef QMap<QString, Capabilities> Transceivers;
|
||||
|
||||
//
|
||||
// various Transceiver parameters
|
||||
//
|
||||
enum DataBits {seven_data_bits = 7, eight_data_bits};
|
||||
Q_ENUM (DataBits)
|
||||
enum StopBits {one_stop_bit = 1, two_stop_bits};
|
||||
Q_ENUM (StopBits)
|
||||
enum Handshake {handshake_none, handshake_XonXoff, handshake_hardware};
|
||||
Q_ENUM (Handshake)
|
||||
enum PTTMethod {PTT_method_VOX, PTT_method_CAT, PTT_method_DTR, PTT_method_RTS};
|
||||
Q_ENUM (PTTMethod)
|
||||
enum TXAudioSource {TX_audio_source_front, TX_audio_source_rear};
|
||||
Q_ENUM (TXAudioSource)
|
||||
enum SplitMode {split_mode_none, split_mode_rig, split_mode_emulate};
|
||||
Q_ENUM (SplitMode)
|
||||
|
||||
TransceiverFactory ();
|
||||
~TransceiverFactory ();
|
||||
|
||||
static char const * const basic_transceiver_name_; // dummy transceiver is basic model
|
||||
|
||||
//
|
||||
// fetch all supported rigs as a list of name and model id
|
||||
//
|
||||
Transceivers const& supported_transceivers () const;
|
||||
|
||||
// supported model queries
|
||||
Capabilities::PortType CAT_port_type (QString const& name) const; // how to talk to CAT
|
||||
bool has_CAT_PTT (QString const& name) const; // can be keyed via CAT
|
||||
bool has_CAT_PTT_mic_data (QString const& name) const; // Tx audio port is switchable via CAT
|
||||
bool has_CAT_indirect_serial_PTT (QString const& name) const; // Can PTT via CAT port use DTR or RTS (OmniRig for example)
|
||||
bool has_asynchronous_CAT (QString const& name) const; // CAT asynchronous rather than polled
|
||||
|
||||
struct ParameterPack
|
||||
{
|
||||
QString rig_name; // from supported_transceivers () key
|
||||
QString serial_port; // serial port device name or empty
|
||||
QString network_port; // hostname:port or empty
|
||||
QString usb_port; // [vid[:pid[:vendor[:product]]]]
|
||||
int baud;
|
||||
DataBits data_bits;
|
||||
StopBits stop_bits;
|
||||
Handshake handshake;
|
||||
bool force_dtr;
|
||||
bool dtr_high; // to power interface
|
||||
bool force_rts;
|
||||
bool rts_high; // to power interface
|
||||
PTTMethod ptt_type; // "CAT" | "DTR" | "RTS" | "VOX"
|
||||
TXAudioSource audio_source; // some rigs allow audio routing
|
||||
// to Mic/Data connector
|
||||
SplitMode split_mode; // how to support split TX mode
|
||||
QString ptt_port; // serial port device name or special
|
||||
// value "CAT"
|
||||
int poll_interval; // in seconds for interfaces that
|
||||
// require polling for state changes
|
||||
|
||||
bool operator == (ParameterPack const& rhs) const
|
||||
{
|
||||
return rhs.rig_name == rig_name
|
||||
&& rhs.serial_port == serial_port
|
||||
&& rhs.network_port == network_port
|
||||
&& rhs.usb_port == usb_port
|
||||
&& rhs.baud == baud
|
||||
&& rhs.data_bits == data_bits
|
||||
&& rhs.stop_bits == stop_bits
|
||||
&& rhs.handshake == handshake
|
||||
&& rhs.force_dtr == force_dtr
|
||||
&& rhs.dtr_high == dtr_high
|
||||
&& rhs.force_rts == force_rts
|
||||
&& rhs.rts_high == rts_high
|
||||
&& rhs.ptt_type == ptt_type
|
||||
&& rhs.audio_source == audio_source
|
||||
&& rhs.split_mode == split_mode
|
||||
&& rhs.ptt_port == ptt_port
|
||||
&& rhs.poll_interval == poll_interval
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
// make a new Transceiver instance
|
||||
//
|
||||
// cat_port, cat_baud, cat_data_bits, cat_stop_bits, cat_handshake,
|
||||
// cat_dtr_control, cat_rts_control are only relevant to interfaces
|
||||
// that are served by Hamlib
|
||||
//
|
||||
// PTT port and to some extent ptt_type are independent of interface
|
||||
// type
|
||||
//
|
||||
std::unique_ptr<Transceiver> create (ParameterPack const&, QThread * target_thread = nullptr);
|
||||
|
||||
private:
|
||||
Transceivers transceivers_;
|
||||
};
|
||||
|
||||
inline
|
||||
bool operator != (TransceiverFactory::ParameterPack const& lhs, TransceiverFactory::ParameterPack const& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// boilerplate routines to make enum types useable and debuggable in
|
||||
// Qt
|
||||
//
|
||||
#if QT_VERSION < 0x050500
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::DataBits);
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::StopBits);
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::Handshake);
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::PTTMethod);
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::TXAudioSource);
|
||||
Q_DECLARE_METATYPE (TransceiverFactory::SplitMode);
|
||||
#endif
|
||||
|
||||
#if !defined (QT_NO_DEBUG_STREAM)
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, DataBits);
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, StopBits);
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, Handshake);
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, PTTMethod);
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, TXAudioSource);
|
||||
ENUM_QDEBUG_OPS_DECL (TransceiverFactory, SplitMode);
|
||||
#endif
|
||||
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, DataBits);
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, StopBits);
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, Handshake);
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, PTTMethod);
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, TXAudioSource);
|
||||
ENUM_QDATASTREAM_OPS_DECL (TransceiverFactory, SplitMode);
|
||||
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, DataBits);
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, StopBits);
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, Handshake);
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, PTTMethod);
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, TXAudioSource);
|
||||
ENUM_CONVERSION_OPS_DECL (TransceiverFactory, SplitMode);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,266 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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_MOVE_ADL_MOVE_SWAP_HPP
|
||||
#define BOOST_MOVE_ADL_MOVE_SWAP_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
#
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//Based on Boost.Core's swap.
|
||||
//Many thanks to Steven Watanabe, Joseph Gauterin and Niels Dekker.
|
||||
#include <cstddef> //for std::size_t
|
||||
#include <boost/move/detail/workaround.hpp> //forceinline
|
||||
|
||||
//Try to avoid including <algorithm>, as it's quite big
|
||||
#if defined(_MSC_VER) && defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> //Dinkum libraries define std::swap in utility which is lighter than algorithm
|
||||
#elif defined(BOOST_GNU_STDLIB)
|
||||
//For non-GCC compilers, where GNUC version is not very reliable, or old GCC versions
|
||||
//use the good old stl_algobase header, which is quite lightweight
|
||||
#if !defined(BOOST_GCC) || ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)))
|
||||
#include <bits/stl_algobase.h>
|
||||
#elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
|
||||
//In GCC 4.3 a tiny stl_move.h was created with swap and move utilities
|
||||
#include <bits/stl_move.h>
|
||||
#else
|
||||
//In GCC 4.4 stl_move.h was renamed to move.h
|
||||
#include <bits/move.h>
|
||||
#endif
|
||||
#elif defined(_LIBCPP_VERSION)
|
||||
#include <type_traits> //The initial import of libc++ defines std::swap and still there
|
||||
#elif __cplusplus >= 201103L
|
||||
#include <utility> //Fallback for C++ >= 2011
|
||||
#else
|
||||
#include <algorithm> //Fallback for C++98/03
|
||||
#endif
|
||||
|
||||
#include <boost/move/utility_core.hpp> //for boost::move
|
||||
|
||||
#if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
namespace boost_move_member_swap {
|
||||
|
||||
struct dont_care
|
||||
{
|
||||
dont_care(...);
|
||||
};
|
||||
|
||||
struct private_type
|
||||
{
|
||||
static private_type p;
|
||||
private_type const &operator,(int) const;
|
||||
};
|
||||
|
||||
typedef char yes_type;
|
||||
struct no_type{ char dummy[2]; };
|
||||
|
||||
template<typename T>
|
||||
no_type is_private_type(T const &);
|
||||
|
||||
yes_type is_private_type(private_type const &);
|
||||
|
||||
template <typename Type>
|
||||
class has_member_function_named_swap
|
||||
{
|
||||
struct BaseMixin
|
||||
{
|
||||
void swap();
|
||||
};
|
||||
|
||||
struct Base : public Type, public BaseMixin { Base(); };
|
||||
template <typename T, T t> class Helper{};
|
||||
|
||||
template <typename U>
|
||||
static no_type deduce(U*, Helper<void (BaseMixin::*)(), &U::swap>* = 0);
|
||||
static yes_type deduce(...);
|
||||
|
||||
public:
|
||||
static const bool value = sizeof(yes_type) == sizeof(deduce((Base*)(0)));
|
||||
};
|
||||
|
||||
template<typename Fun, bool HasFunc>
|
||||
struct has_member_swap_impl
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<typename Fun>
|
||||
struct has_member_swap_impl<Fun, true>
|
||||
{
|
||||
struct FunWrap : Fun
|
||||
{
|
||||
FunWrap();
|
||||
|
||||
using Fun::swap;
|
||||
private_type swap(dont_care) const;
|
||||
};
|
||||
|
||||
static Fun &declval_fun();
|
||||
static FunWrap declval_wrap();
|
||||
|
||||
static bool const value =
|
||||
sizeof(no_type) == sizeof(is_private_type( (declval_wrap().swap(declval_fun()), 0)) );
|
||||
};
|
||||
|
||||
template<typename Fun>
|
||||
struct has_member_swap : public has_member_swap_impl
|
||||
<Fun, has_member_function_named_swap<Fun>::value>
|
||||
{};
|
||||
|
||||
} //namespace boost_move_member_swap
|
||||
|
||||
namespace boost_move_adl_swap{
|
||||
|
||||
template<class P1, class P2, bool = P1::value>
|
||||
struct and_op_impl
|
||||
{ static const bool value = false; };
|
||||
|
||||
template<class P1, class P2>
|
||||
struct and_op_impl<P1, P2, true>
|
||||
{ static const bool value = P2::value; };
|
||||
|
||||
template<class P1, class P2>
|
||||
struct and_op
|
||||
: and_op_impl<P1, P2>
|
||||
{};
|
||||
|
||||
//////
|
||||
|
||||
template<class P1, class P2, bool = P1::value>
|
||||
struct and_op_not_impl
|
||||
{ static const bool value = false; };
|
||||
|
||||
template<class P1, class P2>
|
||||
struct and_op_not_impl<P1, P2, true>
|
||||
{ static const bool value = !P2::value; };
|
||||
|
||||
template<class P1, class P2>
|
||||
struct and_op_not
|
||||
: and_op_not_impl<P1, P2>
|
||||
{};
|
||||
|
||||
template<class T>
|
||||
BOOST_MOVE_FORCEINLINE void swap_proxy(T& x, T& y, typename boost::move_detail::enable_if_c<!boost::move_detail::has_move_emulation_enabled_impl<T>::value>::type* = 0)
|
||||
{
|
||||
//use std::swap if argument dependent lookup fails
|
||||
//Use using directive ("using namespace xxx;") instead as some older compilers
|
||||
//don't do ADL with using declarations ("using ns::func;").
|
||||
using namespace std;
|
||||
swap(x, y);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_MOVE_FORCEINLINE void swap_proxy(T& x, T& y
|
||||
, typename boost::move_detail::enable_if< and_op_not_impl<boost::move_detail::has_move_emulation_enabled_impl<T>
|
||||
, boost_move_member_swap::has_member_swap<T> >
|
||||
>::type* = 0)
|
||||
{ T t(::boost::move(x)); x = ::boost::move(y); y = ::boost::move(t); }
|
||||
|
||||
template<class T>
|
||||
BOOST_MOVE_FORCEINLINE void swap_proxy(T& x, T& y
|
||||
, typename boost::move_detail::enable_if< and_op_impl< boost::move_detail::has_move_emulation_enabled_impl<T>
|
||||
, boost_move_member_swap::has_member_swap<T> >
|
||||
>::type* = 0)
|
||||
{ x.swap(y); }
|
||||
|
||||
} //namespace boost_move_adl_swap{
|
||||
|
||||
#else
|
||||
|
||||
namespace boost_move_adl_swap{
|
||||
|
||||
template<class T>
|
||||
BOOST_MOVE_FORCEINLINE void swap_proxy(T& x, T& y)
|
||||
{
|
||||
using std::swap;
|
||||
swap(x, y);
|
||||
}
|
||||
|
||||
} //namespace boost_move_adl_swap{
|
||||
|
||||
#endif //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
namespace boost_move_adl_swap{
|
||||
|
||||
template<class T, std::size_t N>
|
||||
void swap_proxy(T (& x)[N], T (& y)[N])
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i){
|
||||
::boost_move_adl_swap::swap_proxy(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace boost_move_adl_swap {
|
||||
|
||||
#endif //!defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||
|
||||
namespace boost{
|
||||
|
||||
//! Exchanges the values of a and b, using Argument Dependent Lookup (ADL) to select a
|
||||
//! specialized swap function if available. If no specialized swap function is available,
|
||||
//! std::swap is used.
|
||||
//!
|
||||
//! <b>Exception</b>: If T uses Boost.Move's move emulation and the compiler has
|
||||
//! no rvalue references then:
|
||||
//!
|
||||
//! - If T has a <code>T::swap(T&)</code> member, that member is called.
|
||||
//! - Otherwise a move-based swap is called, equivalent to:
|
||||
//! <code>T t(::boost::move(x)); x = ::boost::move(y); y = ::boost::move(t);</code>.
|
||||
template<class T>
|
||||
BOOST_MOVE_FORCEINLINE void adl_move_swap(T& x, T& y)
|
||||
{
|
||||
::boost_move_adl_swap::swap_proxy(x, y);
|
||||
}
|
||||
|
||||
//! Exchanges elements between range [first1, last1) and another range starting at first2
|
||||
//! using boost::adl_move_swap.
|
||||
//!
|
||||
//! Parameters:
|
||||
//! first1, last1 - the first range of elements to swap
|
||||
//! first2 - beginning of the second range of elements to swap
|
||||
//!
|
||||
//! Type requirements:
|
||||
//! - ForwardIt1, ForwardIt2 must meet the requirements of ForwardIterator.
|
||||
//! - The types of dereferenced ForwardIt1 and ForwardIt2 must meet the
|
||||
//! requirements of Swappable
|
||||
//!
|
||||
//! Return value: Iterator to the element past the last element exchanged in the range
|
||||
//! beginning with first2.
|
||||
template<class ForwardIt1, class ForwardIt2>
|
||||
ForwardIt2 adl_move_swap_ranges(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2)
|
||||
{
|
||||
while (first1 != last1) {
|
||||
::boost::adl_move_swap(*first1, *first2);
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first2;
|
||||
}
|
||||
|
||||
template<class BidirIt1, class BidirIt2>
|
||||
BidirIt2 adl_move_swap_ranges_backward(BidirIt1 first1, BidirIt1 last1, BidirIt2 last2)
|
||||
{
|
||||
while (first1 != last1) {
|
||||
::boost::adl_move_swap(*(--last1), *(--last2));
|
||||
}
|
||||
return last2;
|
||||
}
|
||||
|
||||
} //namespace boost{
|
||||
|
||||
#endif //#ifndef BOOST_MOVE_ADL_MOVE_SWAP_HPP
|
||||
@@ -0,0 +1,124 @@
|
||||
/* Initialize a RS codec
|
||||
*
|
||||
* Copyright 2002 Phil Karn, KA9Q
|
||||
* May be used under the terms of the GNU General Public License (GPL)
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef CCSDS
|
||||
#include "ccsds.h"
|
||||
#elif defined(BIGSYM)
|
||||
#include "int.h"
|
||||
#else
|
||||
#include "char.h"
|
||||
#endif
|
||||
|
||||
void FREE_RS(void *p){
|
||||
struct rs *rs = (struct rs *)p;
|
||||
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs->genpoly);
|
||||
free(rs);
|
||||
}
|
||||
|
||||
/* Initialize a Reed-Solomon codec
|
||||
* symsize = symbol size, bits (1-8)
|
||||
* gfpoly = Field generator polynomial coefficients
|
||||
* fcr = first root of RS code generator polynomial, index form
|
||||
* prim = primitive element to generate polynomial roots
|
||||
* nroots = RS code generator polynomial degree (number of roots)
|
||||
* pad = padding bytes at front of shortened block
|
||||
*/
|
||||
void *INIT_RS(int symsize,int gfpoly,int fcr,int prim,
|
||||
int nroots,int pad){
|
||||
struct rs *rs;
|
||||
int i, j, sr,root,iprim;
|
||||
|
||||
/* Check parameter ranges */
|
||||
if(symsize < 0 || symsize > (int)(8*sizeof(DTYPE)))
|
||||
return NULL; /* Need version with ints rather than chars */
|
||||
|
||||
if(fcr < 0 || fcr >= (1<<symsize))
|
||||
return NULL;
|
||||
if(prim <= 0 || prim >= (1<<symsize))
|
||||
return NULL;
|
||||
if(nroots < 0 || nroots >= (1<<symsize))
|
||||
return NULL; /* Can't have more roots than symbol values! */
|
||||
if(pad < 0 || pad >= ((1<<symsize) -1 - nroots))
|
||||
return NULL; /* Too much padding */
|
||||
|
||||
rs = (struct rs *)calloc(1,sizeof(struct rs));
|
||||
rs->mm = symsize;
|
||||
rs->nn = (1<<symsize)-1;
|
||||
rs->pad = pad;
|
||||
|
||||
rs->alpha_to = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1));
|
||||
if(rs->alpha_to == NULL){
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
rs->index_of = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1));
|
||||
if(rs->index_of == NULL){
|
||||
free(rs->alpha_to);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Generate Galois field lookup tables */
|
||||
rs->index_of[0] = A0; /* log(zero) = -inf */
|
||||
rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */
|
||||
sr = 1;
|
||||
for(i=0;i<rs->nn;i++){
|
||||
rs->index_of[sr] = i;
|
||||
rs->alpha_to[i] = sr;
|
||||
sr <<= 1;
|
||||
if(sr & (1<<symsize))
|
||||
sr ^= gfpoly;
|
||||
sr &= rs->nn;
|
||||
}
|
||||
if(sr != 1){
|
||||
/* field generator polynomial is not primitive! */
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Form RS code generator polynomial from its roots */
|
||||
rs->genpoly = (DTYPE *)malloc(sizeof(DTYPE)*(nroots+1));
|
||||
if(rs->genpoly == NULL){
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
rs->fcr = fcr;
|
||||
rs->prim = prim;
|
||||
rs->nroots = nroots;
|
||||
|
||||
/* Find prim-th root of 1, used in decoding */
|
||||
for(iprim=1;(iprim % prim) != 0;iprim += rs->nn)
|
||||
;
|
||||
rs->iprim = iprim / prim;
|
||||
|
||||
rs->genpoly[0] = 1;
|
||||
for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) {
|
||||
rs->genpoly[i+1] = 1;
|
||||
|
||||
/* Multiply rs->genpoly[] by @**(root + x) */
|
||||
for (j = i; j > 0; j--){
|
||||
if (rs->genpoly[j] != 0)
|
||||
rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)];
|
||||
else
|
||||
rs->genpoly[j] = rs->genpoly[j-1];
|
||||
}
|
||||
/* rs->genpoly[0] can never be zero */
|
||||
rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)];
|
||||
}
|
||||
/* convert rs->genpoly[] to index form for quicker encoding */
|
||||
for (i = 0; i <= nroots; i++)
|
||||
rs->genpoly[i] = rs->index_of[rs->genpoly[i]];
|
||||
|
||||
return rs;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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(BOOST_FUSION_COUNT_IF_09162005_0137)
|
||||
#define BOOST_FUSION_COUNT_IF_09162005_0137
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/algorithm/query/detail/count_if.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct count_if
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename
|
||||
enable_if<
|
||||
traits::is_sequence<Sequence>
|
||||
, int
|
||||
>::type
|
||||
count_if(Sequence const& seq, F f)
|
||||
{
|
||||
return detail::count_if(
|
||||
seq, f, typename traits::category_of<Sequence>::type());
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
|
||||
|
||||
#include <boost/phoenix/object/detail/cpp03/preprocessed/construct_expr.hpp>
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/construct_expr_" BOOST_PHOENIX_LIMIT_STR ".hpp")
|
||||
#endif
|
||||
|
||||
/*==============================================================================
|
||||
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)
|
||||
==============================================================================*/
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 1)
|
||||
#endif
|
||||
|
||||
BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG(
|
||||
(boost)(phoenix)(construct)
|
||||
, (proto::terminal<detail::target<proto::_> >)
|
||||
(meta_grammar)
|
||||
, BOOST_PHOENIX_COMPOSITE_LIMIT
|
||||
)
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(output: null)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,469 @@
|
||||
// Copyright John Maddock 2012.
|
||||
// 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_AIRY_HPP
|
||||
#define BOOST_MATH_AIRY_HPP
|
||||
|
||||
#include <limits>
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#include <boost/math/special_functions/cbrt.hpp>
|
||||
#include <boost/math/special_functions/detail/airy_ai_bi_zero.hpp>
|
||||
#include <boost/math/tools/roots.hpp>
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_ai_imp(T x, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
if(x < 0)
|
||||
{
|
||||
T p = (-x * sqrt(-x) * 2) / 3;
|
||||
T v = T(1) / 3;
|
||||
T j1 = boost::math::cyl_bessel_j(v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_j(-v, p, pol);
|
||||
T ai = sqrt(-x) * (j1 + j2) / 3;
|
||||
//T bi = sqrt(-x / 3) * (j2 - j1);
|
||||
return ai;
|
||||
}
|
||||
else if(fabs(x * x * x) / 6 < tools::epsilon<T>())
|
||||
{
|
||||
T tg = boost::math::tgamma(constants::twothirds<T>(), pol);
|
||||
T ai = 1 / (pow(T(3), constants::twothirds<T>()) * tg);
|
||||
//T bi = 1 / (sqrt(boost::math::cbrt(T(3))) * tg);
|
||||
return ai;
|
||||
}
|
||||
else
|
||||
{
|
||||
T p = 2 * x * sqrt(x) / 3;
|
||||
T v = T(1) / 3;
|
||||
//T j1 = boost::math::cyl_bessel_i(-v, p, pol);
|
||||
//T j2 = boost::math::cyl_bessel_i(v, p, pol);
|
||||
//
|
||||
// Note that although we can calculate ai from j1 and j2, the accuracy is horrible
|
||||
// as we're subtracting two very large values, so use the Bessel K relation instead:
|
||||
//
|
||||
T ai = cyl_bessel_k(v, p, pol) * sqrt(x / 3) / boost::math::constants::pi<T>(); //sqrt(x) * (j1 - j2) / 3;
|
||||
//T bi = sqrt(x / 3) * (j1 + j2);
|
||||
return ai;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_bi_imp(T x, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
if(x < 0)
|
||||
{
|
||||
T p = (-x * sqrt(-x) * 2) / 3;
|
||||
T v = T(1) / 3;
|
||||
T j1 = boost::math::cyl_bessel_j(v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_j(-v, p, pol);
|
||||
//T ai = sqrt(-x) * (j1 + j2) / 3;
|
||||
T bi = sqrt(-x / 3) * (j2 - j1);
|
||||
return bi;
|
||||
}
|
||||
else if(fabs(x * x * x) / 6 < tools::epsilon<T>())
|
||||
{
|
||||
T tg = boost::math::tgamma(constants::twothirds<T>(), pol);
|
||||
//T ai = 1 / (pow(T(3), constants::twothirds<T>()) * tg);
|
||||
T bi = 1 / (sqrt(boost::math::cbrt(T(3))) * tg);
|
||||
return bi;
|
||||
}
|
||||
else
|
||||
{
|
||||
T p = 2 * x * sqrt(x) / 3;
|
||||
T v = T(1) / 3;
|
||||
T j1 = boost::math::cyl_bessel_i(-v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_i(v, p, pol);
|
||||
T bi = sqrt(x / 3) * (j1 + j2);
|
||||
return bi;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_ai_prime_imp(T x, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
if(x < 0)
|
||||
{
|
||||
T p = (-x * sqrt(-x) * 2) / 3;
|
||||
T v = T(2) / 3;
|
||||
T j1 = boost::math::cyl_bessel_j(v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_j(-v, p, pol);
|
||||
T aip = -x * (j1 - j2) / 3;
|
||||
return aip;
|
||||
}
|
||||
else if(fabs(x * x) / 2 < tools::epsilon<T>())
|
||||
{
|
||||
T tg = boost::math::tgamma(constants::third<T>(), pol);
|
||||
T aip = 1 / (boost::math::cbrt(T(3)) * tg);
|
||||
return -aip;
|
||||
}
|
||||
else
|
||||
{
|
||||
T p = 2 * x * sqrt(x) / 3;
|
||||
T v = T(2) / 3;
|
||||
//T j1 = boost::math::cyl_bessel_i(-v, p, pol);
|
||||
//T j2 = boost::math::cyl_bessel_i(v, p, pol);
|
||||
//
|
||||
// Note that although we can calculate ai from j1 and j2, the accuracy is horrible
|
||||
// as we're subtracting two very large values, so use the Bessel K relation instead:
|
||||
//
|
||||
T aip = -cyl_bessel_k(v, p, pol) * x / (boost::math::constants::root_three<T>() * boost::math::constants::pi<T>());
|
||||
return aip;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_bi_prime_imp(T x, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
if(x < 0)
|
||||
{
|
||||
T p = (-x * sqrt(-x) * 2) / 3;
|
||||
T v = T(2) / 3;
|
||||
T j1 = boost::math::cyl_bessel_j(v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_j(-v, p, pol);
|
||||
T aip = -x * (j1 + j2) / constants::root_three<T>();
|
||||
return aip;
|
||||
}
|
||||
else if(fabs(x * x) / 2 < tools::epsilon<T>())
|
||||
{
|
||||
T tg = boost::math::tgamma(constants::third<T>(), pol);
|
||||
T bip = sqrt(boost::math::cbrt(T(3))) / tg;
|
||||
return bip;
|
||||
}
|
||||
else
|
||||
{
|
||||
T p = 2 * x * sqrt(x) / 3;
|
||||
T v = T(2) / 3;
|
||||
T j1 = boost::math::cyl_bessel_i(-v, p, pol);
|
||||
T j2 = boost::math::cyl_bessel_i(v, p, pol);
|
||||
T aip = x * (j1 + j2) / boost::math::constants::root_three<T>();
|
||||
return aip;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_ai_zero_imp(int m, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for log, sqrt.
|
||||
|
||||
// Handle cases when a negative zero (negative rank) is requested.
|
||||
if(m < 0)
|
||||
{
|
||||
return policies::raise_domain_error<T>("boost::math::airy_ai_zero<%1%>(%1%, int)",
|
||||
"Requested the %1%'th zero, but the rank must be 1 or more !", static_cast<T>(m), pol);
|
||||
}
|
||||
|
||||
// Handle case when the zero'th zero is requested.
|
||||
if(m == 0U)
|
||||
{
|
||||
return policies::raise_domain_error<T>("boost::math::airy_ai_zero<%1%>(%1%,%1%)",
|
||||
"The requested rank of the zero is %1%, but must be 1 or more !", static_cast<T>(m), pol);
|
||||
}
|
||||
|
||||
// Set up the initial guess for the upcoming root-finding.
|
||||
const T guess_root = boost::math::detail::airy_zero::airy_ai_zero_detail::initial_guess<T>(m);
|
||||
|
||||
// Select the maximum allowed iterations based on the number
|
||||
// of decimal digits in the numeric type T, being at least 12.
|
||||
const int my_digits10 = static_cast<int>(static_cast<float>(policies::digits<T, Policy>() * 0.301F));
|
||||
|
||||
const boost::uintmax_t iterations_allowed = static_cast<boost::uintmax_t>((std::max)(12, my_digits10 * 2));
|
||||
|
||||
boost::uintmax_t iterations_used = iterations_allowed;
|
||||
|
||||
// Use a dynamic tolerance because the roots get closer the higher m gets.
|
||||
T tolerance;
|
||||
|
||||
if (m <= 10) { tolerance = T(0.3F); }
|
||||
else if(m <= 100) { tolerance = T(0.1F); }
|
||||
else if(m <= 1000) { tolerance = T(0.05F); }
|
||||
else { tolerance = T(1) / sqrt(T(m)); }
|
||||
|
||||
// Perform the root-finding using Newton-Raphson iteration from Boost.Math.
|
||||
const T am =
|
||||
boost::math::tools::newton_raphson_iterate(
|
||||
boost::math::detail::airy_zero::airy_ai_zero_detail::function_object_ai_and_ai_prime<T, Policy>(pol),
|
||||
guess_root,
|
||||
T(guess_root - tolerance),
|
||||
T(guess_root + tolerance),
|
||||
policies::digits<T, Policy>(),
|
||||
iterations_used);
|
||||
|
||||
static_cast<void>(iterations_used);
|
||||
|
||||
return am;
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T airy_bi_zero_imp(int m, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std names, needed for log, sqrt.
|
||||
|
||||
// Handle cases when a negative zero (negative rank) is requested.
|
||||
if(m < 0)
|
||||
{
|
||||
return policies::raise_domain_error<T>("boost::math::airy_bi_zero<%1%>(%1%, int)",
|
||||
"Requested the %1%'th zero, but the rank must 1 or more !", static_cast<T>(m), pol);
|
||||
}
|
||||
|
||||
// Handle case when the zero'th zero is requested.
|
||||
if(m == 0U)
|
||||
{
|
||||
return policies::raise_domain_error<T>("boost::math::airy_bi_zero<%1%>(%1%,%1%)",
|
||||
"The requested rank of the zero is %1%, but must be 1 or more !", static_cast<T>(m), pol);
|
||||
}
|
||||
// Set up the initial guess for the upcoming root-finding.
|
||||
const T guess_root = boost::math::detail::airy_zero::airy_bi_zero_detail::initial_guess<T>(m);
|
||||
|
||||
// Select the maximum allowed iterations based on the number
|
||||
// of decimal digits in the numeric type T, being at least 12.
|
||||
const int my_digits10 = static_cast<int>(static_cast<float>(policies::digits<T, Policy>() * 0.301F));
|
||||
|
||||
const boost::uintmax_t iterations_allowed = static_cast<boost::uintmax_t>((std::max)(12, my_digits10 * 2));
|
||||
|
||||
boost::uintmax_t iterations_used = iterations_allowed;
|
||||
|
||||
// Use a dynamic tolerance because the roots get closer the higher m gets.
|
||||
T tolerance;
|
||||
|
||||
if (m <= 10) { tolerance = T(0.3F); }
|
||||
else if(m <= 100) { tolerance = T(0.1F); }
|
||||
else if(m <= 1000) { tolerance = T(0.05F); }
|
||||
else { tolerance = T(1) / sqrt(T(m)); }
|
||||
|
||||
// Perform the root-finding using Newton-Raphson iteration from Boost.Math.
|
||||
const T bm =
|
||||
boost::math::tools::newton_raphson_iterate(
|
||||
boost::math::detail::airy_zero::airy_bi_zero_detail::function_object_bi_and_bi_prime<T, Policy>(pol),
|
||||
guess_root,
|
||||
T(guess_root - tolerance),
|
||||
T(guess_root + tolerance),
|
||||
policies::digits<T, Policy>(),
|
||||
iterations_used);
|
||||
|
||||
static_cast<void>(iterations_used);
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T, class Policy>
|
||||
inline typename tools::promote_args<T>::type airy_ai(T x, const Policy&)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename tools::promote_args<T>::type result_type;
|
||||
typedef typename policies::evaluation<result_type, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
return policies::checked_narrowing_cast<result_type, Policy>(detail::airy_ai_imp<value_type>(static_cast<value_type>(x), forwarding_policy()), "boost::math::airy<%1%>(%1%)");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename tools::promote_args<T>::type airy_ai(T x)
|
||||
{
|
||||
return airy_ai(x, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline typename tools::promote_args<T>::type airy_bi(T x, const Policy&)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename tools::promote_args<T>::type result_type;
|
||||
typedef typename policies::evaluation<result_type, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
return policies::checked_narrowing_cast<result_type, Policy>(detail::airy_bi_imp<value_type>(static_cast<value_type>(x), forwarding_policy()), "boost::math::airy<%1%>(%1%)");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename tools::promote_args<T>::type airy_bi(T x)
|
||||
{
|
||||
return airy_bi(x, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline typename tools::promote_args<T>::type airy_ai_prime(T x, const Policy&)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename tools::promote_args<T>::type result_type;
|
||||
typedef typename policies::evaluation<result_type, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
return policies::checked_narrowing_cast<result_type, Policy>(detail::airy_ai_prime_imp<value_type>(static_cast<value_type>(x), forwarding_policy()), "boost::math::airy<%1%>(%1%)");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename tools::promote_args<T>::type airy_ai_prime(T x)
|
||||
{
|
||||
return airy_ai_prime(x, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline typename tools::promote_args<T>::type airy_bi_prime(T x, const Policy&)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename tools::promote_args<T>::type result_type;
|
||||
typedef typename policies::evaluation<result_type, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
return policies::checked_narrowing_cast<result_type, Policy>(detail::airy_bi_prime_imp<value_type>(static_cast<value_type>(x), forwarding_policy()), "boost::math::airy<%1%>(%1%)");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename tools::promote_args<T>::type airy_bi_prime(T x)
|
||||
{
|
||||
return airy_bi_prime(x, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T airy_ai_zero(int m, const Policy& /*pol*/)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename policies::evaluation<T, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|
||||
|| ( true == std::numeric_limits<T>::is_specialized
|
||||
&& false == std::numeric_limits<T>::is_integer),
|
||||
"Airy value type must be a floating-point type.");
|
||||
|
||||
return policies::checked_narrowing_cast<T, Policy>(detail::airy_ai_zero_imp<value_type>(m, forwarding_policy()), "boost::math::airy_ai_zero<%1%>(unsigned)");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T airy_ai_zero(int m)
|
||||
{
|
||||
return airy_ai_zero<T>(m, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class OutputIterator, class Policy>
|
||||
inline OutputIterator airy_ai_zero(
|
||||
int start_index,
|
||||
unsigned number_of_zeros,
|
||||
OutputIterator out_it,
|
||||
const Policy& pol)
|
||||
{
|
||||
typedef T result_type;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|
||||
|| ( true == std::numeric_limits<T>::is_specialized
|
||||
&& false == std::numeric_limits<T>::is_integer),
|
||||
"Airy value type must be a floating-point type.");
|
||||
|
||||
for(unsigned i = 0; i < number_of_zeros; ++i)
|
||||
{
|
||||
*out_it = boost::math::airy_ai_zero<result_type>(start_index + i, pol);
|
||||
++out_it;
|
||||
}
|
||||
return out_it;
|
||||
}
|
||||
|
||||
template <class T, class OutputIterator>
|
||||
inline OutputIterator airy_ai_zero(
|
||||
int start_index,
|
||||
unsigned number_of_zeros,
|
||||
OutputIterator out_it)
|
||||
{
|
||||
return airy_ai_zero<T>(start_index, number_of_zeros, out_it, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T airy_bi_zero(int m, const Policy& /*pol*/)
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
typedef typename policies::evaluation<T, Policy>::type value_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|
||||
|| ( true == std::numeric_limits<T>::is_specialized
|
||||
&& false == std::numeric_limits<T>::is_integer),
|
||||
"Airy value type must be a floating-point type.");
|
||||
|
||||
return policies::checked_narrowing_cast<T, Policy>(detail::airy_bi_zero_imp<value_type>(m, forwarding_policy()), "boost::math::airy_bi_zero<%1%>(unsigned)");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T airy_bi_zero(int m)
|
||||
{
|
||||
return airy_bi_zero<T>(m, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T, class OutputIterator, class Policy>
|
||||
inline OutputIterator airy_bi_zero(
|
||||
int start_index,
|
||||
unsigned number_of_zeros,
|
||||
OutputIterator out_it,
|
||||
const Policy& pol)
|
||||
{
|
||||
typedef T result_type;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|
||||
|| ( true == std::numeric_limits<T>::is_specialized
|
||||
&& false == std::numeric_limits<T>::is_integer),
|
||||
"Airy value type must be a floating-point type.");
|
||||
|
||||
for(unsigned i = 0; i < number_of_zeros; ++i)
|
||||
{
|
||||
*out_it = boost::math::airy_bi_zero<result_type>(start_index + i, pol);
|
||||
++out_it;
|
||||
}
|
||||
return out_it;
|
||||
}
|
||||
|
||||
template <class T, class OutputIterator>
|
||||
inline OutputIterator airy_bi_zero(
|
||||
int start_index,
|
||||
unsigned number_of_zeros,
|
||||
OutputIterator out_it)
|
||||
{
|
||||
return airy_bi_zero<T>(start_index, number_of_zeros, out_it, policies::policy<>());
|
||||
}
|
||||
|
||||
}} // namespaces
|
||||
|
||||
#endif // BOOST_MATH_AIRY_HPP
|
||||
@@ -0,0 +1,86 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_END_HPP
|
||||
#define BOOST_RANGE_DETAIL_END_HPP
|
||||
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template< typename T >
|
||||
struct range_end;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
fun( C& c )
|
||||
{
|
||||
return c.end();
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<array_>
|
||||
{
|
||||
template<typename T>
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
namespace range_adl_barrier
|
||||
{
|
||||
template< typename C >
|
||||
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
end( C& c )
|
||||
{
|
||||
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
||||
}
|
||||
} // namespace range_adl_barrier
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_AT_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_AT_IMPL_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/begin_end.hpp>
|
||||
#include <boost/mpl/advance.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'at_impl' or the primary 'at' template
|
||||
|
||||
template< typename Tag >
|
||||
struct at_impl
|
||||
{
|
||||
template< typename Sequence, typename N > struct apply
|
||||
{
|
||||
typedef typename advance<
|
||||
typename begin<Sequence>::type
|
||||
, N
|
||||
>::type iter_;
|
||||
|
||||
typedef typename deref<iter_>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2, at_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_AT_IMPL_HPP_INCLUDED
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
|
||||
#define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
|
||||
|
||||
#include <boost/smart_ptr/detail/array_count_impl.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_if_array.hpp>
|
||||
|
||||
namespace boost {
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_array<T>::type
|
||||
make_shared(std::size_t size) {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_init(p2, n1);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_size_array<T>::type
|
||||
make_shared() {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
enum {
|
||||
N = boost::detail::array_total<T>::size
|
||||
};
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(&p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_init(p2, N);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_array<T>::type
|
||||
make_shared(std::size_t size,
|
||||
const typename boost::detail::array_inner<T>::type& value) {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef const T2 T3;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
enum {
|
||||
M = boost::detail::array_total<T1>::size
|
||||
};
|
||||
std::size_t n1 = M * size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T3* p3 = reinterpret_cast<T3*>(&value);
|
||||
D1 d1;
|
||||
A1 a1(size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_init<T2, M>(p2, n1, p3);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_size_array<T>::type
|
||||
make_shared(const typename boost::detail::array_inner<T>::type& value) {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef const T2 T3;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
enum {
|
||||
M = boost::detail::array_total<T1>::size,
|
||||
N = boost::detail::array_total<T>::size
|
||||
};
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T3* p3 = reinterpret_cast<T3*>(&value);
|
||||
D1 d1;
|
||||
A1 a1(&p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_init<T2, M>(p2, N, p3);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_array<T>::type
|
||||
make_shared_noinit(std::size_t size) {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_noinit(p2, n1);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename boost::detail::sp_if_size_array<T>::type
|
||||
make_shared_noinit() {
|
||||
typedef typename boost::detail::array_inner<T>::type T1;
|
||||
typedef typename boost::detail::array_base<T1>::type T2;
|
||||
typedef boost::detail::ms_allocator<T> A1;
|
||||
typedef boost::detail::ms_in_allocator_tag D1;
|
||||
enum {
|
||||
N = boost::detail::array_total<T>::size
|
||||
};
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(&p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(0);
|
||||
boost::detail::ms_noinit(p2, N);
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,373 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2003 Joel de Guzman
|
||||
Copyright (c) 2002-2003 Martin Wille
|
||||
Copyright (c) 2003 Hartmut Kaiser
|
||||
http://spirit.sourceforge.net/
|
||||
|
||||
Use, modification and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined BOOST_SPIRIT_GRAMMAR_IPP
|
||||
#define BOOST_SPIRIT_GRAMMAR_IPP
|
||||
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
#include <boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <memory> // for std::auto_ptr
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_SPIRIT_THREADSAFE
|
||||
#include <boost/spirit/home/classic/core/non_terminal/impl/static.hpp>
|
||||
#include <boost/thread/tss.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/lock_types.hpp>
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace spirit {
|
||||
|
||||
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
|
||||
|
||||
template <typename DerivedT, typename ContextT>
|
||||
struct grammar;
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
template <typename GrammarT, typename ScannerT>
|
||||
struct grammar_definition
|
||||
{
|
||||
typedef typename GrammarT::template definition<ScannerT> type;
|
||||
};
|
||||
|
||||
|
||||
namespace impl
|
||||
{
|
||||
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
struct grammar_tag {};
|
||||
|
||||
//////////////////////////////////
|
||||
template <typename GrammarT>
|
||||
struct grammar_helper_base
|
||||
{
|
||||
virtual int undefine(GrammarT *) = 0;
|
||||
virtual ~grammar_helper_base() {}
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
template <typename GrammarT>
|
||||
struct grammar_helper_list
|
||||
{
|
||||
typedef GrammarT grammar_t;
|
||||
typedef grammar_helper_base<GrammarT> helper_t;
|
||||
typedef std::vector<helper_t*> vector_t;
|
||||
|
||||
grammar_helper_list() {}
|
||||
grammar_helper_list(grammar_helper_list const& /*x*/)
|
||||
{ // Does _not_ copy the helpers member !
|
||||
}
|
||||
|
||||
grammar_helper_list& operator=(grammar_helper_list const& x)
|
||||
{ // Does _not_ copy the helpers member !
|
||||
return *this;
|
||||
}
|
||||
|
||||
void push_back(helper_t *helper)
|
||||
{ helpers.push_back(helper); }
|
||||
|
||||
void pop_back()
|
||||
{ helpers.pop_back(); }
|
||||
|
||||
typename vector_t::size_type
|
||||
size() const
|
||||
{ return helpers.size(); }
|
||||
|
||||
typename vector_t::reverse_iterator
|
||||
rbegin()
|
||||
{ return helpers.rbegin(); }
|
||||
|
||||
typename vector_t::reverse_iterator
|
||||
rend()
|
||||
{ return helpers.rend(); }
|
||||
|
||||
#ifdef BOOST_SPIRIT_THREADSAFE
|
||||
boost::mutex & mutex()
|
||||
{ return m; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
vector_t helpers;
|
||||
#ifdef BOOST_SPIRIT_THREADSAFE
|
||||
boost::mutex m;
|
||||
#endif
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
struct grammartract_helper_list;
|
||||
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
|
||||
struct grammartract_helper_list
|
||||
{
|
||||
template<typename GrammarT>
|
||||
static grammar_helper_list<GrammarT>&
|
||||
do_(GrammarT const* g)
|
||||
{
|
||||
return g->helpers;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////
|
||||
template <typename GrammarT, typename DerivedT, typename ScannerT>
|
||||
struct grammar_helper : private grammar_helper_base<GrammarT>
|
||||
{
|
||||
typedef GrammarT grammar_t;
|
||||
typedef ScannerT scanner_t;
|
||||
typedef DerivedT derived_t;
|
||||
typedef typename grammar_definition<DerivedT, ScannerT>::type definition_t;
|
||||
|
||||
typedef grammar_helper<grammar_t, derived_t, scanner_t> helper_t;
|
||||
typedef boost::shared_ptr<helper_t> helper_ptr_t;
|
||||
typedef boost::weak_ptr<helper_t> helper_weak_ptr_t;
|
||||
|
||||
grammar_helper*
|
||||
this_() { return this; }
|
||||
|
||||
grammar_helper(helper_weak_ptr_t& p)
|
||||
: definitions_cnt(0)
|
||||
, self(this_())
|
||||
{ p = self; }
|
||||
|
||||
definition_t&
|
||||
define(grammar_t const* target_grammar)
|
||||
{
|
||||
grammar_helper_list<GrammarT> &helpers =
|
||||
grammartract_helper_list::do_(target_grammar);
|
||||
typename grammar_t::object_id id = target_grammar->get_object_id();
|
||||
|
||||
if (definitions.size()<=id)
|
||||
definitions.resize(id*3/2+1);
|
||||
if (definitions[id]!=0)
|
||||
return *definitions[id];
|
||||
|
||||
std::auto_ptr<definition_t>
|
||||
result(new definition_t(target_grammar->derived()));
|
||||
|
||||
#ifdef BOOST_SPIRIT_THREADSAFE
|
||||
boost::unique_lock<boost::mutex> lock(helpers.mutex());
|
||||
#endif
|
||||
helpers.push_back(this);
|
||||
|
||||
++definitions_cnt;
|
||||
definitions[id] = result.get();
|
||||
return *(result.release());
|
||||
}
|
||||
|
||||
int
|
||||
undefine(grammar_t* target_grammar)
|
||||
{
|
||||
typename grammar_t::object_id id = target_grammar->get_object_id();
|
||||
|
||||
if (definitions.size()<=id)
|
||||
return 0;
|
||||
delete definitions[id];
|
||||
definitions[id] = 0;
|
||||
if (--definitions_cnt==0)
|
||||
self.reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<definition_t*> definitions;
|
||||
unsigned long definitions_cnt;
|
||||
helper_ptr_t self;
|
||||
};
|
||||
|
||||
#endif /* defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE) */
|
||||
|
||||
#ifdef BOOST_SPIRIT_THREADSAFE
|
||||
class get_definition_static_data_tag
|
||||
{
|
||||
template<typename DerivedT, typename ContextT, typename ScannerT>
|
||||
friend typename DerivedT::template definition<ScannerT> &
|
||||
get_definition(grammar<DerivedT, ContextT> const* self);
|
||||
|
||||
get_definition_static_data_tag() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename DerivedT, typename ContextT, typename ScannerT>
|
||||
inline typename DerivedT::template definition<ScannerT> &
|
||||
get_definition(grammar<DerivedT, ContextT> const* self)
|
||||
{
|
||||
#if defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
|
||||
typedef typename DerivedT::template definition<ScannerT> definition_t;
|
||||
static definition_t def(self->derived());
|
||||
return def;
|
||||
#else
|
||||
typedef grammar<DerivedT, ContextT> self_t;
|
||||
typedef impl::grammar_helper<self_t, DerivedT, ScannerT> helper_t;
|
||||
typedef typename helper_t::helper_weak_ptr_t ptr_t;
|
||||
|
||||
# ifdef BOOST_SPIRIT_THREADSAFE
|
||||
boost::thread_specific_ptr<ptr_t> & tld_helper
|
||||
= static_<boost::thread_specific_ptr<ptr_t>,
|
||||
get_definition_static_data_tag>(get_definition_static_data_tag());
|
||||
|
||||
if (!tld_helper.get())
|
||||
tld_helper.reset(new ptr_t);
|
||||
ptr_t &helper = *tld_helper;
|
||||
# else
|
||||
static ptr_t helper;
|
||||
# endif
|
||||
if (helper.expired())
|
||||
new helper_t(helper);
|
||||
return helper.lock()->define(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <int N>
|
||||
struct call_helper {
|
||||
|
||||
template <typename RT, typename DefinitionT, typename ScannerT>
|
||||
static void
|
||||
do_ (RT &result, DefinitionT &def, ScannerT const &scan)
|
||||
{
|
||||
result = def.template get_start_parser<N>()->parse(scan);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct call_helper<0> {
|
||||
|
||||
template <typename RT, typename DefinitionT, typename ScannerT>
|
||||
static void
|
||||
do_ (RT &result, DefinitionT &def, ScannerT const &scan)
|
||||
{
|
||||
result = def.start().parse(scan);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
template<int N, typename DerivedT, typename ContextT, typename ScannerT>
|
||||
inline typename parser_result<grammar<DerivedT, ContextT>, ScannerT>::type
|
||||
grammar_parser_parse(
|
||||
grammar<DerivedT, ContextT> const* self,
|
||||
ScannerT const &scan)
|
||||
{
|
||||
typedef
|
||||
typename parser_result<grammar<DerivedT, ContextT>, ScannerT>::type
|
||||
result_t;
|
||||
typedef typename DerivedT::template definition<ScannerT> definition_t;
|
||||
|
||||
result_t result;
|
||||
definition_t &def = get_definition<DerivedT, ContextT, ScannerT>(self);
|
||||
|
||||
call_helper<N>::do_(result, def, scan);
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
template<typename GrammarT>
|
||||
inline void
|
||||
grammar_destruct(GrammarT* self)
|
||||
{
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
typedef grammar_helper_list<GrammarT> helper_list_t;
|
||||
|
||||
helper_list_t& helpers =
|
||||
grammartract_helper_list::do_(self);
|
||||
|
||||
# if defined(BOOST_INTEL_CXX_VERSION)
|
||||
typedef typename helper_list_t::vector_t::reverse_iterator iterator_t;
|
||||
|
||||
for (iterator_t i = helpers.rbegin(); i != helpers.rend(); ++i)
|
||||
(*i)->undefine(self);
|
||||
# else
|
||||
typedef impl::grammar_helper_base<GrammarT> helper_base_t;
|
||||
|
||||
std::for_each(helpers.rbegin(), helpers.rend(),
|
||||
std::bind2nd(std::mem_fun(&helper_base_t::undefine), self));
|
||||
# endif
|
||||
|
||||
#else
|
||||
(void)self;
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// entry_grammar class
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename DerivedT, int N, typename ContextT>
|
||||
class entry_grammar
|
||||
: public parser<entry_grammar<DerivedT, N, ContextT> >
|
||||
{
|
||||
|
||||
public:
|
||||
typedef entry_grammar<DerivedT, N, ContextT> self_t;
|
||||
typedef self_t embed_t;
|
||||
typedef typename ContextT::context_linker_t context_t;
|
||||
typedef typename context_t::attr_t attr_t;
|
||||
|
||||
template <typename ScannerT>
|
||||
struct result
|
||||
{
|
||||
typedef typename match_result<ScannerT, attr_t>::type type;
|
||||
};
|
||||
|
||||
entry_grammar(DerivedT const &p) : target_grammar(p) {}
|
||||
|
||||
template <typename ScannerT>
|
||||
typename parser_result<self_t, ScannerT>::type
|
||||
parse_main(ScannerT const& scan) const
|
||||
{ return impl::grammar_parser_parse<N>(&target_grammar, scan); }
|
||||
|
||||
template <typename ScannerT>
|
||||
typename parser_result<self_t, ScannerT>::type
|
||||
parse(ScannerT const& scan) const
|
||||
{
|
||||
typedef typename parser_result<self_t, ScannerT>::type result_t;
|
||||
typedef parser_scanner_linker<ScannerT> scanner_t;
|
||||
BOOST_SPIRIT_CONTEXT_PARSE(scan, target_grammar, scanner_t,
|
||||
context_t, result_t)
|
||||
}
|
||||
|
||||
private:
|
||||
DerivedT const &target_grammar;
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
||||
///////////////////////////////////////
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
#define BOOST_SPIRIT_GRAMMAR_ID , public impl::object_with_id<impl::grammar_tag>
|
||||
#else
|
||||
#define BOOST_SPIRIT_GRAMMAR_ID
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////
|
||||
#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
|
||||
#define BOOST_SPIRIT_GRAMMAR_STATE \
|
||||
private: \
|
||||
friend struct impl::grammartract_helper_list; \
|
||||
mutable impl::grammar_helper_list<self_t> helpers;
|
||||
#else
|
||||
#define BOOST_SPIRIT_GRAMMAR_STATE
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
|
||||
|
||||
}} // namespace boost::spirit
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,220 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://boostorg.github.com/compute for more information.
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_COMPUTE_TYPES_TUPLE_HPP
|
||||
#define BOOST_COMPUTE_TYPES_TUPLE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
#include <boost/preprocessor/expr_if.hpp>
|
||||
#include <boost/preprocessor/repetition.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include <boost/compute/config.hpp>
|
||||
#include <boost/compute/functional/get.hpp>
|
||||
#include <boost/compute/type_traits/type_name.hpp>
|
||||
#include <boost/compute/detail/meta_kernel.hpp>
|
||||
|
||||
#ifndef BOOST_COMPUTE_NO_STD_TUPLE
|
||||
#include <tuple>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
namespace detail {
|
||||
|
||||
// meta_kernel operators for boost::tuple literals
|
||||
#define BOOST_COMPUTE_PRINT_ELEM(z, n, unused) \
|
||||
BOOST_PP_EXPR_IF(n, << ", ") \
|
||||
<< kernel.make_lit(boost::get<n>(x))
|
||||
|
||||
#define BOOST_COMPUTE_PRINT_TUPLE(z, n, unused) \
|
||||
template<BOOST_PP_ENUM_PARAMS(n, class T)> \
|
||||
inline meta_kernel& \
|
||||
operator<<(meta_kernel &kernel, \
|
||||
const boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> &x) \
|
||||
{ \
|
||||
return kernel \
|
||||
<< "(" \
|
||||
<< type_name<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> >() \
|
||||
<< ")" \
|
||||
<< "{" \
|
||||
BOOST_PP_REPEAT(n, BOOST_COMPUTE_PRINT_ELEM, ~) \
|
||||
<< "}"; \
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_PRINT_TUPLE, ~)
|
||||
|
||||
#undef BOOST_COMPUTE_PRINT_TUPLE
|
||||
#undef BOOST_COMPUTE_PRINT_ELEM
|
||||
|
||||
// inject_type() specializations for boost::tuple
|
||||
#define BOOST_COMPUTE_INJECT_TYPE(z, n, unused) \
|
||||
kernel.inject_type<T ## n>();
|
||||
|
||||
#define BOOST_COMPUTE_INJECT_DECL(z, n, unused) \
|
||||
<< " " << type_name<T ## n>() << " v" #n ";\n"
|
||||
|
||||
#define BOOST_COMPUTE_INJECT_IMPL(z, n, unused) \
|
||||
template<BOOST_PP_ENUM_PARAMS(n, class T)> \
|
||||
struct inject_type_impl<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \
|
||||
{ \
|
||||
void operator()(meta_kernel &kernel) \
|
||||
{ \
|
||||
typedef boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> tuple_type; \
|
||||
BOOST_PP_REPEAT(n, BOOST_COMPUTE_INJECT_TYPE, ~) \
|
||||
std::stringstream declaration; \
|
||||
declaration << "typedef struct {\n" \
|
||||
BOOST_PP_REPEAT(n, BOOST_COMPUTE_INJECT_DECL, ~) \
|
||||
<< "} " << type_name<tuple_type>() << ";\n"; \
|
||||
kernel.add_type_declaration<tuple_type>(declaration.str()); \
|
||||
} \
|
||||
};
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_INJECT_IMPL, ~)
|
||||
|
||||
#undef BOOST_COMPUTE_INJECT_IMPL
|
||||
#undef BOOST_COMPUTE_INJECT_DECL
|
||||
#undef BOOST_COMPUTE_INJECT_TYPE
|
||||
|
||||
#ifdef BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
|
||||
// type_name() specializations for boost::tuple (without variadic templates)
|
||||
#define BOOST_COMPUTE_PRINT_TYPE(z, n, unused) \
|
||||
+ type_name<T ## n>() + "_"
|
||||
|
||||
#define BOOST_COMPUTE_PRINT_TYPE_NAME(z, n, unused) \
|
||||
template<BOOST_PP_ENUM_PARAMS(n, class T)> \
|
||||
struct type_name_trait<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \
|
||||
{ \
|
||||
static const char* value() \
|
||||
{ \
|
||||
static std::string name = \
|
||||
std::string("boost_tuple_") \
|
||||
BOOST_PP_REPEAT(n, BOOST_COMPUTE_PRINT_TYPE, ~) \
|
||||
"t"; \
|
||||
return name.c_str(); \
|
||||
} \
|
||||
};
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_PRINT_TYPE_NAME, ~)
|
||||
|
||||
#undef BOOST_COMPUTE_PRINT_TYPE_NAME
|
||||
#undef BOOST_COMPUTE_PRINT_TYPE
|
||||
|
||||
#else
|
||||
template<size_t N, class T, class... Rest>
|
||||
struct write_tuple_type_names
|
||||
{
|
||||
void operator()(std::ostream &os)
|
||||
{
|
||||
os << type_name<T>() << "_";
|
||||
write_tuple_type_names<N-1, Rest...>()(os);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class... Rest>
|
||||
struct write_tuple_type_names<1, T, Rest...>
|
||||
{
|
||||
void operator()(std::ostream &os)
|
||||
{
|
||||
os << type_name<T>();
|
||||
}
|
||||
};
|
||||
|
||||
// type_name<> specialization for boost::tuple<...> (with variadic templates)
|
||||
template<class... T>
|
||||
struct type_name_trait<boost::tuple<T...>>
|
||||
{
|
||||
static const char* value()
|
||||
{
|
||||
static std::string str = make_type_name();
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
static std::string make_type_name()
|
||||
{
|
||||
typedef typename boost::tuple<T...> tuple_type;
|
||||
|
||||
std::stringstream s;
|
||||
s << "boost_tuple_";
|
||||
write_tuple_type_names<
|
||||
boost::tuples::length<tuple_type>::value, T...
|
||||
>()(s);
|
||||
s << "_t";
|
||||
return s.str();
|
||||
}
|
||||
};
|
||||
#endif // BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
|
||||
|
||||
#ifndef BOOST_COMPUTE_NO_STD_TUPLE
|
||||
// type_name<> specialization for std::tuple<T...>
|
||||
template<class... T>
|
||||
struct type_name_trait<std::tuple<T...>>
|
||||
{
|
||||
static const char* value()
|
||||
{
|
||||
static std::string str = make_type_name();
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
static std::string make_type_name()
|
||||
{
|
||||
typedef typename std::tuple<T...> tuple_type;
|
||||
|
||||
std::stringstream s;
|
||||
s << "std_tuple_";
|
||||
write_tuple_type_names<
|
||||
std::tuple_size<tuple_type>::value, T...
|
||||
>()(s);
|
||||
s << "_t";
|
||||
return s.str();
|
||||
}
|
||||
};
|
||||
#endif // BOOST_COMPUTE_NO_STD_TUPLE
|
||||
|
||||
// get<N>() result type specialization for boost::tuple<>
|
||||
#define BOOST_COMPUTE_GET_RESULT_TYPE(z, n, unused) \
|
||||
template<size_t N, BOOST_PP_ENUM_PARAMS(n, class T)> \
|
||||
struct get_result_type<N, boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \
|
||||
{ \
|
||||
typedef typename boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> T; \
|
||||
typedef typename boost::tuples::element<N, T>::type type; \
|
||||
};
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_GET_RESULT_TYPE, ~)
|
||||
|
||||
#undef BOOST_COMPUTE_GET_RESULT_TYPE
|
||||
|
||||
|
||||
// get<N>() specialization for boost::tuple<>
|
||||
#define BOOST_COMPUTE_GET_N(z, n, unused) \
|
||||
template<size_t N, class Arg, BOOST_PP_ENUM_PARAMS(n, class T)> \
|
||||
inline meta_kernel& operator<<(meta_kernel &kernel, \
|
||||
const invoked_get<N, Arg, boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > &expr) \
|
||||
{ \
|
||||
typedef typename boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> T; \
|
||||
BOOST_STATIC_ASSERT(N < size_t(boost::tuples::length<T>::value)); \
|
||||
kernel.inject_type<T>(); \
|
||||
return kernel << expr.m_arg << ".v" << uint_(N); \
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_GET_N, ~)
|
||||
|
||||
#undef BOOST_COMPUTE_GET_N
|
||||
|
||||
} // end detail namespace
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_TYPES_TUPLE_HPP
|
||||
@@ -0,0 +1,17 @@
|
||||
# /* **************************************************************************
|
||||
# * *
|
||||
# * (C) Copyright Paul Mensonides 2002.
|
||||
# * Distributed under the Boost Software License, Version 1.0. (See
|
||||
# * accompanying file LICENSE_1_0.txt or copy at
|
||||
# * http://www.boost.org/LICENSE_1_0.txt)
|
||||
# * *
|
||||
# ************************************************************************** */
|
||||
#
|
||||
# /* See http://www.boost.org for most recent version. */
|
||||
#
|
||||
# ifndef BOOST_PREPROCESSOR_IF_HPP
|
||||
# define BOOST_PREPROCESSOR_IF_HPP
|
||||
#
|
||||
# include <boost/preprocessor/control/if.hpp>
|
||||
#
|
||||
# endif
|
||||
@@ -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 norder #trials s '
|
||||
print*,'eg: ldpcsim 10 2 1000 0.84'
|
||||
print*,'belief propagation iterations: niter, ordered-statistics order: norder'
|
||||
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,*) norder
|
||||
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
|
||||
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)
|
||||
if( norder .ge. 0 .and. nharderrors .lt. 0 ) call osd174(llr, norder, decoded, cw, nharderrors)
|
||||
! 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/2048
|
||||
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
|
||||
Reference in New Issue
Block a user