Initial Commit
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
#ifndef BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// text_woarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STD_WSTREAMBUF
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#else
|
||||
|
||||
#include <ostream>
|
||||
#include <cstddef> // size_t
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/auto_link_warchive.hpp>
|
||||
#include <boost/archive/basic_text_oprimitive.hpp>
|
||||
#include <boost/archive/basic_text_oarchive.hpp>
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
#include <boost/serialization/item_version_type.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 archive {
|
||||
|
||||
namespace detail {
|
||||
template<class Archive> class interface_oarchive;
|
||||
} // namespace detail
|
||||
|
||||
template<class Archive>
|
||||
class BOOST_SYMBOL_VISIBLE text_woarchive_impl :
|
||||
public basic_text_oprimitive<std::wostream>,
|
||||
public basic_text_oarchive<Archive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
public:
|
||||
#else
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
friend basic_text_oarchive<Archive>;
|
||||
friend save_access;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
friend class basic_text_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
#endif
|
||||
#endif
|
||||
template<class T>
|
||||
void save(const T & t){
|
||||
this->newtoken();
|
||||
basic_text_oprimitive<std::wostream>::save(t);
|
||||
}
|
||||
void save(const version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
}
|
||||
void save(const boost::serialization::item_version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
}
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const char * t);
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const wchar_t * t);
|
||||
#endif
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const std::string &s);
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const std::wstring &ws);
|
||||
#endif
|
||||
text_woarchive_impl(std::wostream & os, unsigned int flags) :
|
||||
basic_text_oprimitive<std::wostream>(
|
||||
os,
|
||||
0 != (flags & no_codecvt)
|
||||
),
|
||||
basic_text_oarchive<Archive>(flags)
|
||||
{
|
||||
if(0 == (flags & no_header))
|
||||
basic_text_oarchive<Archive>::init();
|
||||
}
|
||||
public:
|
||||
void save_binary(const void *address, std::size_t count){
|
||||
put(static_cast<wchar_t>('\n'));
|
||||
this->end_preamble();
|
||||
#if ! defined(__MWERKS__)
|
||||
this->basic_text_oprimitive<std::wostream>::save_binary(
|
||||
#else
|
||||
this->basic_text_oprimitive::save_binary(
|
||||
#endif
|
||||
address,
|
||||
count
|
||||
);
|
||||
put(static_cast<wchar_t>('\n'));
|
||||
this->delimiter = this->none;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// we use the following because we can't use
|
||||
// typedef text_oarchive_impl<text_oarchive_impl<...> > text_oarchive;
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from text_oarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
class BOOST_SYMBOL_VISIBLE text_woarchive :
|
||||
public text_woarchive_impl<text_woarchive>
|
||||
{
|
||||
public:
|
||||
text_woarchive(std::wostream & os, unsigned int flags = 0) :
|
||||
text_woarchive_impl<text_woarchive>(os, flags)
|
||||
{}
|
||||
~text_woarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive)
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef PHASE_EQUALIZATION_DIALOG_HPP__
|
||||
#define PHASE_EQUALIZATION_DIALOG_HPP__
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "pimpl_h.hpp"
|
||||
|
||||
class QWidget;
|
||||
class QSettings;
|
||||
class QDir;
|
||||
|
||||
class PhaseEqualizationDialog
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PhaseEqualizationDialog (QSettings *
|
||||
, QDir const& data_directory
|
||||
, QVector<double> const& coefficients
|
||||
, QWidget * = nullptr);
|
||||
Q_SLOT void show ();
|
||||
|
||||
Q_SIGNAL void phase_equalization_changed (QVector<double> const&);
|
||||
|
||||
private:
|
||||
class impl;
|
||||
pimpl<impl> m_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
// 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/equal_to.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Tag1
|
||||
, typename Tag2
|
||||
|
||||
, BOOST_MPL_AUX_NTTP_DECL(int, tag1_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value
|
||||
, BOOST_MPL_AUX_NTTP_DECL(int, tag2_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value
|
||||
>
|
||||
struct equal_to_impl
|
||||
: if_c<
|
||||
( tag1_ > tag2_ )
|
||||
, aux::cast2nd_impl< equal_to_impl< Tag1,Tag1 >,Tag1, Tag2 >
|
||||
, aux::cast1st_impl< equal_to_impl< Tag2,Tag2 >,Tag1, Tag2 >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
/// for Digital Mars C++/compilers with no CTPS/TTP support
|
||||
template<> struct equal_to_impl< na,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct equal_to_impl< na,integral_c_tag >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct equal_to_impl< integral_c_tag,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct equal_to_tag
|
||||
{
|
||||
typedef typename T::tag type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(N1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N2)
|
||||
>
|
||||
struct equal_to
|
||||
: aux::msvc_eti_base< typename apply_wrap2<
|
||||
equal_to_impl<
|
||||
typename equal_to_tag<N1>::type
|
||||
, typename equal_to_tag<N2>::type
|
||||
>
|
||||
, N1
|
||||
, N2
|
||||
>::type >::type
|
||||
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, equal_to, (N1, N2))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(2, 2, equal_to)
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct equal_to_impl< integral_c_tag,integral_c_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
( BOOST_MPL_AUX_VALUE_WKND(N1)::value ==
|
||||
BOOST_MPL_AUX_VALUE_WKND(N2)::value )
|
||||
);
|
||||
typedef bool_<value> type;
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef BOOST_SERIALIZATION_STATIC_WARNING_HPP
|
||||
#define BOOST_SERIALIZATION_STATIC_WARNING_HPP
|
||||
|
||||
// (C) Copyright Robert Ramey 2003. Jonathan Turkanis 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
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/static_assert for documentation.
|
||||
|
||||
/*
|
||||
Revision history:
|
||||
15 June 2003 - Initial version.
|
||||
31 March 2004 - improved diagnostic messages and portability
|
||||
(Jonathan Turkanis)
|
||||
03 April 2004 - works on VC6 at class and namespace scope
|
||||
- ported to DigitalMars
|
||||
- static warnings disabled by default; when enabled,
|
||||
uses pragmas to enable required compiler warnings
|
||||
on MSVC, Intel, Metrowerks and Borland 5.x.
|
||||
(Jonathan Turkanis)
|
||||
30 May 2004 - tweaked for msvc 7.1 and gcc 3.3
|
||||
- static warnings ENabled by default; when enabled,
|
||||
(Robert Ramey)
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// Implementation
|
||||
// Makes use of the following warnings:
|
||||
// 1. GCC prior to 3.3: division by zero.
|
||||
// 2. BCC 6.0 preview: unreferenced local variable.
|
||||
// 3. DigitalMars: returning address of local automatic variable.
|
||||
// 4. VC6: class previously seen as struct (as in 'boost/mpl/print.hpp')
|
||||
// 5. All others: deletion of pointer to incomplete type.
|
||||
//
|
||||
// The trick is to find code which produces warnings containing the name of
|
||||
// a structure or variable. Details, with same numbering as above:
|
||||
// 1. static_warning_impl<B>::value is zero iff B is false, so diving an int
|
||||
// by this value generates a warning iff B is false.
|
||||
// 2. static_warning_impl<B>::type has a constructor iff B is true, so an
|
||||
// unreferenced variable of this type generates a warning iff B is false.
|
||||
// 3. static_warning_impl<B>::type overloads operator& to return a dynamically
|
||||
// allocated int pointer only is B is true, so returning the address of an
|
||||
// automatic variable of this type generates a warning iff B is fasle.
|
||||
// 4. static_warning_impl<B>::STATIC_WARNING is decalred as a struct iff B is
|
||||
// false.
|
||||
// 5. static_warning_impl<B>::type is incomplete iff B is false, so deleting a
|
||||
// pointer to this type generates a warning iff B is false.
|
||||
//
|
||||
|
||||
//------------------Enable selected warnings----------------------------------//
|
||||
|
||||
// Enable the warnings relied on by BOOST_STATIC_WARNING, where possible.
|
||||
|
||||
// 6. replaced implementation with one which depends solely on
|
||||
// mpl::print<>. The previous one was found to fail for functions
|
||||
// under recent versions of gcc and intel compilers - Robert Ramey
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/print.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<int L>
|
||||
struct BOOST_SERIALIZATION_STATIC_WARNING_LINE{};
|
||||
|
||||
template<bool B, int L>
|
||||
struct static_warning_test{
|
||||
typename boost::mpl::eval_if_c<
|
||||
B,
|
||||
boost::mpl::true_,
|
||||
typename boost::mpl::identity<
|
||||
boost::mpl::print<
|
||||
BOOST_SERIALIZATION_STATIC_WARNING_LINE<L>
|
||||
>
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<int i>
|
||||
struct BOOST_SERIALIZATION_SS {};
|
||||
|
||||
} // serialization
|
||||
} // boost
|
||||
|
||||
#define BOOST_SERIALIZATION_BSW(B, L) \
|
||||
typedef boost::serialization::BOOST_SERIALIZATION_SS< \
|
||||
sizeof( boost::serialization::static_warning_test< B, L > ) \
|
||||
> BOOST_JOIN(STATIC_WARNING_LINE, L) BOOST_ATTRIBUTE_UNUSED;
|
||||
#define BOOST_STATIC_WARNING(B) BOOST_SERIALIZATION_BSW(B, __LINE__)
|
||||
|
||||
#endif // BOOST_SERIALIZATION_STATIC_WARNING_HPP
|
||||
@@ -0,0 +1,106 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_EQUAL_TO_05052005_1208)
|
||||
#define FUSION_EQUAL_TO_05052005_1208
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/fusion/support/tag_of.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/fusion/support/is_iterator.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
// Special tags:
|
||||
struct iterator_facade_tag; // iterator facade tag
|
||||
struct boost_array_iterator_tag; // boost::array iterator tag
|
||||
struct mpl_iterator_tag; // mpl sequence iterator tag
|
||||
struct std_pair_iterator_tag; // std::pair iterator tag
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct equal_to_impl
|
||||
{
|
||||
// default implementation
|
||||
template <typename I1, typename I2>
|
||||
struct apply
|
||||
: is_same<typename add_const<I1>::type, typename add_const<I2>::type>
|
||||
{};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<iterator_facade_tag>
|
||||
{
|
||||
template <typename It1, typename It2, typename Tag1, typename Tag2>
|
||||
struct dispatch : mpl::false_ {};
|
||||
|
||||
template <typename It1, typename It2, typename Tag>
|
||||
struct dispatch<It1, It2, Tag, Tag> // same tag
|
||||
: It1::template equal_to<It1, It2>
|
||||
{};
|
||||
|
||||
template<typename It1, typename It2>
|
||||
struct apply : dispatch<It1, It2,
|
||||
typename It1::fusion_tag, typename It2::fusion_tag>
|
||||
{};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<boost_array_iterator_tag>;
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<mpl_iterator_tag>;
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<std_pair_iterator_tag>;
|
||||
}
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct equal_to
|
||||
: extension::equal_to_impl<typename detail::tag_of<I1>::type>::
|
||||
template apply<I1, I2>
|
||||
{};
|
||||
}
|
||||
|
||||
namespace iterator_operators
|
||||
{
|
||||
template <typename Iter1, typename Iter2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename
|
||||
boost::enable_if<
|
||||
mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
|
||||
, bool
|
||||
>::type
|
||||
operator==(Iter1 const&, Iter2 const&)
|
||||
{
|
||||
return result_of::equal_to<Iter1, Iter2>::value;
|
||||
}
|
||||
|
||||
template <typename Iter1, typename Iter2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename
|
||||
boost::enable_if<
|
||||
mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
|
||||
, bool
|
||||
>::type
|
||||
operator!=(Iter1 const&, Iter2 const&)
|
||||
{
|
||||
return !result_of::equal_to<Iter1, Iter2>::value;
|
||||
}
|
||||
}
|
||||
|
||||
using iterator_operators::operator==;
|
||||
using iterator_operators::operator!=;
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
subroutine twkfreq1(ca,npts,fsample,a,cb)
|
||||
|
||||
complex ca(npts)
|
||||
complex cb(npts)
|
||||
complex w,wstep
|
||||
real a(5)
|
||||
data twopi/6.283185307/
|
||||
|
||||
! Mix the complex signal
|
||||
w=1.0
|
||||
wstep=1.0
|
||||
x0=0.5*(npts+1)
|
||||
s=2.0/npts
|
||||
do i=1,npts
|
||||
x=s*(i-x0)
|
||||
p2=1.5*x*x - 0.5
|
||||
p3=2.5*(x**3) - 1.5*x
|
||||
p4=4.375*(x**4) - 3.75*(x**2) + 0.375
|
||||
dphi=(a(1) + x*a(2) + p2*a(3) + p3*a(4) + p4*a(5)) * (twopi/fsample)
|
||||
wstep=cmplx(cos(dphi),sin(dphi))
|
||||
w=w*wstep
|
||||
cb(i)=w*ca(i)
|
||||
enddo
|
||||
|
||||
return
|
||||
end subroutine twkfreq1
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef LIVE_FREQUENCY_VALIDATOR_HPP__
|
||||
#define LIVE_FREQUENCY_VALIDATOR_HPP__
|
||||
|
||||
#include <QObject>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
#include "Radio.hpp"
|
||||
|
||||
class Bands;
|
||||
class FrequencyList;
|
||||
class QComboBox;
|
||||
class QWidget;
|
||||
|
||||
//
|
||||
// Class LiveFrequencyValidator
|
||||
//
|
||||
// QLineEdit validator that controls input to an editable
|
||||
// QComboBox where the user can enter a valid band or a valid
|
||||
// frequency in megahetz.
|
||||
//
|
||||
// Collabrations
|
||||
//
|
||||
// Implements the QRegExpValidator interface. Validates input
|
||||
// from the supplied QComboBox as either a valid frequency in
|
||||
// megahertz or a valid band as defined by the supplied column of
|
||||
// the supplied QAbstractItemModel.
|
||||
//
|
||||
class LiveFrequencyValidator final
|
||||
: public QRegExpValidator
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
using Frequency = Radio::Frequency;
|
||||
|
||||
LiveFrequencyValidator (QComboBox * combo_box // associated combo box
|
||||
, Bands const * bands // bands model
|
||||
, FrequencyList const * frequencies // working
|
||||
// frequencies
|
||||
// model
|
||||
, Frequency const * nominal_frequency
|
||||
, QWidget * parent = nullptr);
|
||||
|
||||
State validate (QString& input, int& pos) const override;
|
||||
void fixup (QString& input) const override;
|
||||
|
||||
Q_SIGNAL void valid (Frequency) const;
|
||||
|
||||
private:
|
||||
Bands const * bands_;
|
||||
FrequencyList const * frequencies_;
|
||||
Frequency const * nominal_frequency_;
|
||||
QComboBox * combo_box_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
#define BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
|
||||
#include <boost/units/derived_dimension.hpp>
|
||||
#include <boost/units/physical_dimensions/length.hpp>
|
||||
#include <boost/units/physical_dimensions/mass.hpp>
|
||||
#include <boost/units/physical_dimensions/time.hpp>
|
||||
#include <boost/units/physical_dimensions/current.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
/// derived dimension for impedance : L^2 M T^-3 I^-2
|
||||
typedef derived_dimension<length_base_dimension,2,
|
||||
mass_base_dimension,1,
|
||||
time_base_dimension,-3,
|
||||
current_base_dimension,-2>::type impedance_dimension;
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_IMPEDANCE_DERIVED_DIMENSION_HPP
|
||||
@@ -0,0 +1,200 @@
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* Free software: Progressive edge-growth (PEG) algorithm */
|
||||
/* Created by Xiaoyu Hu */
|
||||
/* Evangelos Eletheriou */
|
||||
/* Dieter Arnold */
|
||||
/* IBM Research, Zurich Research Lab., Switzerland */
|
||||
/* */
|
||||
/* The C++ sources files have been compiled using xlC compiler */
|
||||
/* at IBM RS/6000 running AIX. For other compilers and platforms,*/
|
||||
/* minor changes might be needed. */
|
||||
/* */
|
||||
/* Bug reporting to: xhu@zurich.ibm.com */
|
||||
/**********************************************************************/
|
||||
|
||||
////
|
||||
// Modified by F. P. Beekhof; 2008 / 08 / 19
|
||||
////
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include "BigGirth.h"
|
||||
#include "Random.h"
|
||||
#include "CyclesOfGraph.h"
|
||||
|
||||
const double EPS = 1e-6;
|
||||
|
||||
using namespace std;
|
||||
|
||||
void usage()
|
||||
{
|
||||
cout<<"*******************************************************************************************"<<endl;
|
||||
cout<<" Usage Reminder: MainPEG -numM M -numN N -codeName CodeName -degFileName DegFileName " <<endl;
|
||||
cout<<" option: -sglConcent SglConcent " <<endl;
|
||||
cout<<" sglConcent==0 ----- strictly concentrated parity-check " <<endl;
|
||||
cout<<" degree distribution (including regular graphs)" <<endl;
|
||||
cout<<" sglConcent==1 ----- Best-effort concentrated (DEFAULT) " <<endl;
|
||||
cout<<" option: -tgtGirth TgtGirth " <<endl;
|
||||
cout<<" TgtGirth==4, 6 ...; if very large, then greedy PEG (DEFAULT) " <<endl;
|
||||
cout<<" IF sglConcent==0, TgtGirth is recommended to be set relatively small" <<endl;
|
||||
cout<<" option: -q " <<endl;
|
||||
cout<<" Quiet mode. Produces less output to the screen. " <<endl;
|
||||
cout<<" option: -outputMode <0,1,2> " <<endl;
|
||||
cout<<" Specifies output format. " <<endl;
|
||||
cout<<" '0': H in compressed format (default) " <<endl;
|
||||
cout<<" '1': H in un-compressed format " <<endl;
|
||||
cout<<" '2': G and H in compressed format " <<endl;
|
||||
cout<<" " <<endl;
|
||||
cout<<" Remarks: File CodeName stores the generated PEG Tanner graph. The first line contains"<<endl;
|
||||
cout<<" the block length, N. The second line defines the number of parity-checks, M."<<endl;
|
||||
cout<<" The third line defines the number of columns of the compressed parity-check "<<endl;
|
||||
cout<<" matrix. The following M lines are then the compressed parity-check matrix. "<<endl;
|
||||
cout<<" Each of the M rows contains the indices (1 ... N) of 1's in the compressed "<<endl;
|
||||
cout<<" row of parity-check matrix. If not all column entries are used, the column "<<endl;
|
||||
cout<<" is filled up with 0's. "<<endl;
|
||||
cout<<" "<<endl;
|
||||
cout<<" If both G and H are in the output, (outMode 2), the first line contains"<<endl;
|
||||
cout<<" N, the 2nd line K, the number of message bits, the 3rd line M, the 4th line"<<endl;
|
||||
cout<<" contains the number of rows of the compressed generator matrix; the 5th"<<endl;
|
||||
cout<<" defines the number of columns of the compressed parity-check matrix. The"<<endl;
|
||||
cout<<" format of G is almost like that of H, but vertical -- i.e. the padding"<<endl;
|
||||
cout<<" zeroes are on the bottom. "<<endl;
|
||||
|
||||
cout<<" "<<endl;
|
||||
cout<<" File DegFileName is the input file to specify the degree distribution (node "<<endl;
|
||||
cout<<" perspective). The first line contains the number of various degrees. The second"<<endl;
|
||||
cout<<" defines the row vector of degree sequence in the increasing order. The vector"<<endl;
|
||||
cout<<" of fractions of the corresponding degree is defined in the last line. "<<endl;
|
||||
cout<<" "<<endl;
|
||||
cout<<" A log file called 'leftHandGirth.dat' will also be generated and stored in the"<<endl;
|
||||
cout<<" current directory, which gives the girth of the left-hand subgraph of j, where"<<endl;
|
||||
cout<<" 1<=j<=N. The left-hand subgraph of j is defined as all the edges emanating from"<<endl;
|
||||
cout<<" bit nodes {1 ... j} and their associated nodes. "<<endl;
|
||||
cout<<" "<<endl;
|
||||
cout<<" The last point is, when strictly concentrated parity-check degree distribution"<<endl;
|
||||
cout<<" is invoked, i.e. sglConcent==0, the girth might be weaken to some extent as "<<endl;
|
||||
cout<<" compared to the generic PEG algorithm. "<<endl;
|
||||
cout<<"**********************************************************************************************"<<endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]){
|
||||
int sglConcent=1; // default to non-strictly concentrated parity-check distribution
|
||||
int targetGirth=100000; // default to greedy PEG version
|
||||
std::string codeName, degFileName;
|
||||
int M = -1, N = -1;
|
||||
bool verbose = true;
|
||||
|
||||
const int OUTPUT_MODE_H_COMPRESSED = 0;
|
||||
const int OUTPUT_MODE_H = 1;
|
||||
const int OUTPUT_MODE_G_H_COMPRESSED = 2;
|
||||
int output_mode = OUTPUT_MODE_H_COMPRESSED; // default
|
||||
|
||||
if (argc<9) {
|
||||
usage();
|
||||
}else {
|
||||
for(int i=1;i<argc;++i){
|
||||
if (strcmp(argv[i], "-numM")==0) {
|
||||
if (++i >= argc) usage();
|
||||
M=atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-numN")==0) {
|
||||
if (++i >= argc) usage();
|
||||
N=atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-codeName")==0) {
|
||||
if (++i >= argc) usage();
|
||||
codeName = argv[i];
|
||||
} else if(strcmp(argv[i], "-degFileName")==0) {
|
||||
if (++i >= argc) usage();
|
||||
degFileName = argv[i];
|
||||
} else if(strcmp(argv[i], "-sglConcent")==0) {
|
||||
if (++i >= argc) usage();
|
||||
sglConcent=atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-tgtGirth")==0) {
|
||||
if (++i >= argc) usage();
|
||||
targetGirth=atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-outputMode")==0) {
|
||||
if (++i >= argc) usage();
|
||||
output_mode=atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-q")==0) {
|
||||
verbose=false;
|
||||
} else{
|
||||
usage();
|
||||
}
|
||||
}
|
||||
if (M == -1 || N == -1) {
|
||||
cout<<"Error: M or N not specified!"<<endl;
|
||||
exit(-1);
|
||||
}
|
||||
if (M>N) {
|
||||
cout<<"Error: M must be smaller than N!"<<endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> degSeq(N);
|
||||
|
||||
ifstream infn(degFileName.c_str());
|
||||
if (!infn) {cout << "\nCannot open file " << degFileName << endl; exit(-1); }
|
||||
int m;
|
||||
infn >>m;
|
||||
std::vector<int> deg(m);
|
||||
std::vector<double> degFrac(m);
|
||||
for(int i=0;i<m;i++) infn>>deg[i];
|
||||
for(int i=0;i<m;i++) infn>>degFrac[i];
|
||||
infn.close();
|
||||
double dtmp=0.0;
|
||||
for(int i=0;i<m;i++) dtmp+=degFrac[i];
|
||||
cout.setf(ios::fixed, ios::floatfield);
|
||||
if(abs(dtmp-1.0)>EPS) {
|
||||
cout.setf(ios::fixed, ios::floatfield);
|
||||
cout <<"\n Invalid degree distribution (node perspective): sum != 1.0 but "<<setprecision(10)<<dtmp<<endl; exit(-1);
|
||||
}
|
||||
for(int i=1;i<m;++i) degFrac[i]+=degFrac[i-1];
|
||||
for(int i=0;i<N;++i) {
|
||||
dtmp=double(i)/double(N);
|
||||
int j;
|
||||
for(j=m-1;j>=0;--j) {
|
||||
if(dtmp>degFrac[j]) break;
|
||||
}
|
||||
if(dtmp<degFrac[0]) degSeq[i]=deg[0];
|
||||
else degSeq[i]=deg[j+1];
|
||||
}
|
||||
|
||||
BigGirth bigGirth(M, N, °Seq[0], codeName.c_str(),
|
||||
sglConcent, targetGirth, verbose);
|
||||
|
||||
switch(output_mode)
|
||||
{
|
||||
case OUTPUT_MODE_H_COMPRESSED: bigGirth.writeToFile_Hcompressed(); break;
|
||||
case OUTPUT_MODE_H: // different output format
|
||||
bigGirth.writeToFile_Hmatrix(); break;
|
||||
case OUTPUT_MODE_G_H_COMPRESSED:
|
||||
// different output format: including generator matrix (compressed)
|
||||
bigGirth.writeToFile(); break;
|
||||
default:
|
||||
cout << "Error: invalid output mode specified." << endl << endl;
|
||||
usage();
|
||||
}
|
||||
|
||||
//computing local girth distribution
|
||||
|
||||
if (verbose && N<10000) {
|
||||
cout<<" Now computing the local girth on the global Tanner graph setting. "<<endl;
|
||||
cout<<" might take a bit long time. Please wait ... "<<endl;
|
||||
bigGirth.loadH();
|
||||
CyclesOfGraph cog(M, N, bigGirth.H);
|
||||
cog.getCyclesTable();
|
||||
cog.printCyclesTable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
@@ -0,0 +1,3 @@
|
||||
void ftrsd2_(int mrsym[], int mrprob[], int mr2sym[], int mr2prob[],
|
||||
int* ntrials0, int* verbose0, int correct[], int param[],
|
||||
int indexes[], double tt[], int ntry[]);
|
||||
@@ -0,0 +1,551 @@
|
||||
// (C) Copyright John Maddock 2006.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_SPECIAL_FUNCTIONS_IGAMMA_INVERSE_HPP
|
||||
#define BOOST_MATH_SPECIAL_FUNCTIONS_IGAMMA_INVERSE_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/math/tools/tuple.hpp>
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
#include <boost/math/tools/roots.hpp>
|
||||
#include <boost/math/policies/error_handling.hpp>
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class T>
|
||||
T find_inverse_s(T p, T q)
|
||||
{
|
||||
//
|
||||
// Computation of the Incomplete Gamma Function Ratios and their Inverse
|
||||
// ARMIDO R. DIDONATO and ALFRED H. MORRIS, JR.
|
||||
// ACM Transactions on Mathematical Software, Vol. 12, No. 4,
|
||||
// December 1986, Pages 377-393.
|
||||
//
|
||||
// See equation 32.
|
||||
//
|
||||
BOOST_MATH_STD_USING
|
||||
T t;
|
||||
if(p < 0.5)
|
||||
{
|
||||
t = sqrt(-2 * log(p));
|
||||
}
|
||||
else
|
||||
{
|
||||
t = sqrt(-2 * log(q));
|
||||
}
|
||||
static const double a[4] = { 3.31125922108741, 11.6616720288968, 4.28342155967104, 0.213623493715853 };
|
||||
static const double b[5] = { 1, 6.61053765625462, 6.40691597760039, 1.27364489782223, 0.3611708101884203e-1 };
|
||||
T s = t - tools::evaluate_polynomial(a, t) / tools::evaluate_polynomial(b, t);
|
||||
if(p < 0.5)
|
||||
s = -s;
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T didonato_SN(T a, T x, unsigned N, T tolerance = 0)
|
||||
{
|
||||
//
|
||||
// Computation of the Incomplete Gamma Function Ratios and their Inverse
|
||||
// ARMIDO R. DIDONATO and ALFRED H. MORRIS, JR.
|
||||
// ACM Transactions on Mathematical Software, Vol. 12, No. 4,
|
||||
// December 1986, Pages 377-393.
|
||||
//
|
||||
// See equation 34.
|
||||
//
|
||||
T sum = 1;
|
||||
if(N >= 1)
|
||||
{
|
||||
T partial = x / (a + 1);
|
||||
sum += partial;
|
||||
for(unsigned i = 2; i <= N; ++i)
|
||||
{
|
||||
partial *= x / (a + i);
|
||||
sum += partial;
|
||||
if(partial < tolerance)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T didonato_FN(T p, T a, T x, unsigned N, T tolerance, const Policy& pol)
|
||||
{
|
||||
//
|
||||
// Computation of the Incomplete Gamma Function Ratios and their Inverse
|
||||
// ARMIDO R. DIDONATO and ALFRED H. MORRIS, JR.
|
||||
// ACM Transactions on Mathematical Software, Vol. 12, No. 4,
|
||||
// December 1986, Pages 377-393.
|
||||
//
|
||||
// See equation 34.
|
||||
//
|
||||
BOOST_MATH_STD_USING
|
||||
T u = log(p) + boost::math::lgamma(a + 1, pol);
|
||||
return exp((u + x - log(didonato_SN(a, x, N, tolerance))) / a);
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T find_inverse_gamma(T a, T p, T q, const Policy& pol, bool* p_has_10_digits)
|
||||
{
|
||||
//
|
||||
// In order to understand what's going on here, you will
|
||||
// need to refer to:
|
||||
//
|
||||
// Computation of the Incomplete Gamma Function Ratios and their Inverse
|
||||
// ARMIDO R. DIDONATO and ALFRED H. MORRIS, JR.
|
||||
// ACM Transactions on Mathematical Software, Vol. 12, No. 4,
|
||||
// December 1986, Pages 377-393.
|
||||
//
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
T result;
|
||||
*p_has_10_digits = false;
|
||||
|
||||
if(a == 1)
|
||||
{
|
||||
result = -log(q);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if(a < 1)
|
||||
{
|
||||
T g = boost::math::tgamma(a, pol);
|
||||
T b = q * g;
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(g);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(b);
|
||||
if((b > 0.6) || ((b >= 0.45) && (a >= 0.3)))
|
||||
{
|
||||
// DiDonato & Morris Eq 21:
|
||||
//
|
||||
// There is a slight variation from DiDonato and Morris here:
|
||||
// the first form given here is unstable when p is close to 1,
|
||||
// making it impossible to compute the inverse of Q(a,x) for small
|
||||
// q. Fortunately the second form works perfectly well in this case.
|
||||
//
|
||||
T u;
|
||||
if((b * q > 1e-8) && (q > 1e-5))
|
||||
{
|
||||
u = pow(p * g * a, 1 / a);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(u);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = exp((-q / a) - constants::euler<T>());
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(u);
|
||||
}
|
||||
result = u / (1 - (u / (a + 1)));
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if((a < 0.3) && (b >= 0.35))
|
||||
{
|
||||
// DiDonato & Morris Eq 22:
|
||||
T t = exp(-constants::euler<T>() - b);
|
||||
T u = t * exp(t);
|
||||
result = t * exp(u);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if((b > 0.15) || (a >= 0.3))
|
||||
{
|
||||
// DiDonato & Morris Eq 23:
|
||||
T y = -log(b);
|
||||
T u = y - (1 - a) * log(y);
|
||||
result = y - (1 - a) * log(u) - log(1 + (1 - a) / (1 + u));
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if (b > 0.1)
|
||||
{
|
||||
// DiDonato & Morris Eq 24:
|
||||
T y = -log(b);
|
||||
T u = y - (1 - a) * log(y);
|
||||
result = y - (1 - a) * log(u) - log((u * u + 2 * (3 - a) * u + (2 - a) * (3 - a)) / (u * u + (5 - a) * u + 2));
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// DiDonato & Morris Eq 25:
|
||||
T y = -log(b);
|
||||
T c1 = (a - 1) * log(y);
|
||||
T c1_2 = c1 * c1;
|
||||
T c1_3 = c1_2 * c1;
|
||||
T c1_4 = c1_2 * c1_2;
|
||||
T a_2 = a * a;
|
||||
T a_3 = a_2 * a;
|
||||
|
||||
T c2 = (a - 1) * (1 + c1);
|
||||
T c3 = (a - 1) * (-(c1_2 / 2) + (a - 2) * c1 + (3 * a - 5) / 2);
|
||||
T c4 = (a - 1) * ((c1_3 / 3) - (3 * a - 5) * c1_2 / 2 + (a_2 - 6 * a + 7) * c1 + (11 * a_2 - 46 * a + 47) / 6);
|
||||
T c5 = (a - 1) * (-(c1_4 / 4)
|
||||
+ (11 * a - 17) * c1_3 / 6
|
||||
+ (-3 * a_2 + 13 * a -13) * c1_2
|
||||
+ (2 * a_3 - 25 * a_2 + 72 * a - 61) * c1 / 2
|
||||
+ (25 * a_3 - 195 * a_2 + 477 * a - 379) / 12);
|
||||
|
||||
T y_2 = y * y;
|
||||
T y_3 = y_2 * y;
|
||||
T y_4 = y_2 * y_2;
|
||||
result = y + c1 + (c2 / y) + (c3 / y_2) + (c4 / y_3) + (c5 / y_4);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
if(b < 1e-28f)
|
||||
*p_has_10_digits = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// DiDonato and Morris Eq 31:
|
||||
T s = find_inverse_s(p, q);
|
||||
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(s);
|
||||
|
||||
T s_2 = s * s;
|
||||
T s_3 = s_2 * s;
|
||||
T s_4 = s_2 * s_2;
|
||||
T s_5 = s_4 * s;
|
||||
T ra = sqrt(a);
|
||||
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(ra);
|
||||
|
||||
T w = a + s * ra + (s * s -1) / 3;
|
||||
w += (s_3 - 7 * s) / (36 * ra);
|
||||
w -= (3 * s_4 + 7 * s_2 - 16) / (810 * a);
|
||||
w += (9 * s_5 + 256 * s_3 - 433 * s) / (38880 * a * ra);
|
||||
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(w);
|
||||
|
||||
if((a >= 500) && (fabs(1 - w / a) < 1e-6))
|
||||
{
|
||||
result = w;
|
||||
*p_has_10_digits = true;
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else if (p > 0.5)
|
||||
{
|
||||
if(w < 3 * a)
|
||||
{
|
||||
result = w;
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
T D = (std::max)(T(2), T(a * (a - 1)));
|
||||
T lg = boost::math::lgamma(a, pol);
|
||||
T lb = log(q) + lg;
|
||||
if(lb < -D * 2.3)
|
||||
{
|
||||
// DiDonato and Morris Eq 25:
|
||||
T y = -lb;
|
||||
T c1 = (a - 1) * log(y);
|
||||
T c1_2 = c1 * c1;
|
||||
T c1_3 = c1_2 * c1;
|
||||
T c1_4 = c1_2 * c1_2;
|
||||
T a_2 = a * a;
|
||||
T a_3 = a_2 * a;
|
||||
|
||||
T c2 = (a - 1) * (1 + c1);
|
||||
T c3 = (a - 1) * (-(c1_2 / 2) + (a - 2) * c1 + (3 * a - 5) / 2);
|
||||
T c4 = (a - 1) * ((c1_3 / 3) - (3 * a - 5) * c1_2 / 2 + (a_2 - 6 * a + 7) * c1 + (11 * a_2 - 46 * a + 47) / 6);
|
||||
T c5 = (a - 1) * (-(c1_4 / 4)
|
||||
+ (11 * a - 17) * c1_3 / 6
|
||||
+ (-3 * a_2 + 13 * a -13) * c1_2
|
||||
+ (2 * a_3 - 25 * a_2 + 72 * a - 61) * c1 / 2
|
||||
+ (25 * a_3 - 195 * a_2 + 477 * a - 379) / 12);
|
||||
|
||||
T y_2 = y * y;
|
||||
T y_3 = y_2 * y;
|
||||
T y_4 = y_2 * y_2;
|
||||
result = y + c1 + (c2 / y) + (c3 / y_2) + (c4 / y_3) + (c5 / y_4);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// DiDonato and Morris Eq 33:
|
||||
T u = -lb + (a - 1) * log(w) - log(1 + (1 - a) / (1 + w));
|
||||
result = -lb + (a - 1) * log(u) - log(1 + (1 - a) / (1 + u));
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T z = w;
|
||||
T ap1 = a + 1;
|
||||
T ap2 = a + 2;
|
||||
if(w < 0.15f * ap1)
|
||||
{
|
||||
// DiDonato and Morris Eq 35:
|
||||
T v = log(p) + boost::math::lgamma(ap1, pol);
|
||||
z = exp((v + w) / a);
|
||||
s = boost::math::log1p(z / ap1 * (1 + z / ap2), pol);
|
||||
z = exp((v + z - s) / a);
|
||||
s = boost::math::log1p(z / ap1 * (1 + z / ap2), pol);
|
||||
z = exp((v + z - s) / a);
|
||||
s = boost::math::log1p(z / ap1 * (1 + z / ap2 * (1 + z / (a + 3))), pol);
|
||||
z = exp((v + z - s) / a);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(z);
|
||||
}
|
||||
|
||||
if((z <= 0.01 * ap1) || (z > 0.7 * ap1))
|
||||
{
|
||||
result = z;
|
||||
if(z <= 0.002 * ap1)
|
||||
*p_has_10_digits = true;
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// DiDonato and Morris Eq 36:
|
||||
T ls = log(didonato_SN(a, z, 100, T(1e-4)));
|
||||
T v = log(p) + boost::math::lgamma(ap1, pol);
|
||||
z = exp((v + z - ls) / a);
|
||||
result = z * (1 - (a * log(z) - z - v + ls) / (a - z));
|
||||
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
struct gamma_p_inverse_func
|
||||
{
|
||||
gamma_p_inverse_func(T a_, T p_, bool inv) : a(a_), p(p_), invert(inv)
|
||||
{
|
||||
//
|
||||
// If p is too near 1 then P(x) - p suffers from cancellation
|
||||
// errors causing our root-finding algorithms to "thrash", better
|
||||
// to invert in this case and calculate Q(x) - (1-p) instead.
|
||||
//
|
||||
// Of course if p is *very* close to 1, then the answer we get will
|
||||
// be inaccurate anyway (because there's not enough information in p)
|
||||
// but at least we will converge on the (inaccurate) answer quickly.
|
||||
//
|
||||
if(p > 0.9)
|
||||
{
|
||||
p = 1 - p;
|
||||
invert = !invert;
|
||||
}
|
||||
}
|
||||
|
||||
boost::math::tuple<T, T, T> operator()(const T& x)const
|
||||
{
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
//
|
||||
// Calculate P(x) - p and the first two derivates, or if the invert
|
||||
// flag is set, then Q(x) - q and it's derivatives.
|
||||
//
|
||||
typedef typename policies::evaluation<T, Policy>::type value_type;
|
||||
// typedef typename lanczos::lanczos<T, Policy>::type evaluation_type;
|
||||
typedef typename policies::normalise<
|
||||
Policy,
|
||||
policies::promote_float<false>,
|
||||
policies::promote_double<false>,
|
||||
policies::discrete_quantile<>,
|
||||
policies::assert_undefined<> >::type forwarding_policy;
|
||||
|
||||
BOOST_MATH_STD_USING // For ADL of std functions.
|
||||
|
||||
T f, f1;
|
||||
value_type ft;
|
||||
f = static_cast<T>(boost::math::detail::gamma_incomplete_imp(
|
||||
static_cast<value_type>(a),
|
||||
static_cast<value_type>(x),
|
||||
true, invert,
|
||||
forwarding_policy(), &ft));
|
||||
f1 = static_cast<T>(ft);
|
||||
T f2;
|
||||
T div = (a - x - 1) / x;
|
||||
f2 = f1;
|
||||
if((fabs(div) > 1) && (tools::max_value<T>() / fabs(div) < f2))
|
||||
{
|
||||
// overflow:
|
||||
f2 = -tools::max_value<T>() / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
f2 *= div;
|
||||
}
|
||||
|
||||
if(invert)
|
||||
{
|
||||
f1 = -f1;
|
||||
f2 = -f2;
|
||||
}
|
||||
|
||||
return boost::math::make_tuple(static_cast<T>(f - p), f1, f2);
|
||||
}
|
||||
private:
|
||||
T a, p;
|
||||
bool invert;
|
||||
};
|
||||
|
||||
template <class T, class Policy>
|
||||
T gamma_p_inv_imp(T a, T p, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std functions.
|
||||
|
||||
static const char* function = "boost::math::gamma_p_inv<%1%>(%1%, %1%)";
|
||||
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(a);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(p);
|
||||
|
||||
if(a <= 0)
|
||||
return policies::raise_domain_error<T>(function, "Argument a in the incomplete gamma function inverse must be >= 0 (got a=%1%).", a, pol);
|
||||
if((p < 0) || (p > 1))
|
||||
return policies::raise_domain_error<T>(function, "Probabilty must be in the range [0,1] in the incomplete gamma function inverse (got p=%1%).", p, pol);
|
||||
if(p == 1)
|
||||
return policies::raise_overflow_error<T>(function, 0, Policy());
|
||||
if(p == 0)
|
||||
return 0;
|
||||
bool has_10_digits;
|
||||
T guess = detail::find_inverse_gamma<T>(a, p, 1 - p, pol, &has_10_digits);
|
||||
if((policies::digits<T, Policy>() <= 36) && has_10_digits)
|
||||
return guess;
|
||||
T lower = tools::min_value<T>();
|
||||
if(guess <= lower)
|
||||
guess = tools::min_value<T>();
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(guess);
|
||||
//
|
||||
// Work out how many digits to converge to, normally this is
|
||||
// 2/3 of the digits in T, but if the first derivative is very
|
||||
// large convergence is slow, so we'll bump it up to full
|
||||
// precision to prevent premature termination of the root-finding routine.
|
||||
//
|
||||
unsigned digits = policies::digits<T, Policy>();
|
||||
if(digits < 30)
|
||||
{
|
||||
digits *= 2;
|
||||
digits /= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
digits /= 2;
|
||||
digits -= 1;
|
||||
}
|
||||
if((a < 0.125) && (fabs(gamma_p_derivative(a, guess, pol)) > 1 / sqrt(tools::epsilon<T>())))
|
||||
digits = policies::digits<T, Policy>() - 2;
|
||||
//
|
||||
// Go ahead and iterate:
|
||||
//
|
||||
boost::uintmax_t max_iter = policies::get_max_root_iterations<Policy>();
|
||||
guess = tools::halley_iterate(
|
||||
detail::gamma_p_inverse_func<T, Policy>(a, p, false),
|
||||
guess,
|
||||
lower,
|
||||
tools::max_value<T>(),
|
||||
digits,
|
||||
max_iter);
|
||||
policies::check_root_iterations<T>(function, max_iter, pol);
|
||||
BOOST_MATH_INSTRUMENT_VARIABLE(guess);
|
||||
if(guess == lower)
|
||||
guess = policies::raise_underflow_error<T>(function, "Expected result known to be non-zero, but is smaller than the smallest available number.", pol);
|
||||
return guess;
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
T gamma_q_inv_imp(T a, T q, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING // ADL of std functions.
|
||||
|
||||
static const char* function = "boost::math::gamma_q_inv<%1%>(%1%, %1%)";
|
||||
|
||||
if(a <= 0)
|
||||
return policies::raise_domain_error<T>(function, "Argument a in the incomplete gamma function inverse must be >= 0 (got a=%1%).", a, pol);
|
||||
if((q < 0) || (q > 1))
|
||||
return policies::raise_domain_error<T>(function, "Probabilty must be in the range [0,1] in the incomplete gamma function inverse (got q=%1%).", q, pol);
|
||||
if(q == 0)
|
||||
return policies::raise_overflow_error<T>(function, 0, Policy());
|
||||
if(q == 1)
|
||||
return 0;
|
||||
bool has_10_digits;
|
||||
T guess = detail::find_inverse_gamma<T>(a, 1 - q, q, pol, &has_10_digits);
|
||||
if((policies::digits<T, Policy>() <= 36) && has_10_digits)
|
||||
return guess;
|
||||
T lower = tools::min_value<T>();
|
||||
if(guess <= lower)
|
||||
guess = tools::min_value<T>();
|
||||
//
|
||||
// Work out how many digits to converge to, normally this is
|
||||
// 2/3 of the digits in T, but if the first derivative is very
|
||||
// large convergence is slow, so we'll bump it up to full
|
||||
// precision to prevent premature termination of the root-finding routine.
|
||||
//
|
||||
unsigned digits = policies::digits<T, Policy>();
|
||||
if(digits < 30)
|
||||
{
|
||||
digits *= 2;
|
||||
digits /= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
digits /= 2;
|
||||
digits -= 1;
|
||||
}
|
||||
if((a < 0.125) && (fabs(gamma_p_derivative(a, guess, pol)) > 1 / sqrt(tools::epsilon<T>())))
|
||||
digits = policies::digits<T, Policy>();
|
||||
//
|
||||
// Go ahead and iterate:
|
||||
//
|
||||
boost::uintmax_t max_iter = policies::get_max_root_iterations<Policy>();
|
||||
guess = tools::halley_iterate(
|
||||
detail::gamma_p_inverse_func<T, Policy>(a, q, true),
|
||||
guess,
|
||||
lower,
|
||||
tools::max_value<T>(),
|
||||
digits,
|
||||
max_iter);
|
||||
policies::check_root_iterations<T>(function, max_iter, pol);
|
||||
if(guess == lower)
|
||||
guess = policies::raise_underflow_error<T>(function, "Expected result known to be non-zero, but is smaller than the smallest available number.", pol);
|
||||
return guess;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T1, class T2, class Policy>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
gamma_p_inv(T1 a, T2 p, const Policy& pol)
|
||||
{
|
||||
typedef typename tools::promote_args<T1, T2>::type result_type;
|
||||
return detail::gamma_p_inv_imp(
|
||||
static_cast<result_type>(a),
|
||||
static_cast<result_type>(p), pol);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class Policy>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
gamma_q_inv(T1 a, T2 p, const Policy& pol)
|
||||
{
|
||||
typedef typename tools::promote_args<T1, T2>::type result_type;
|
||||
return detail::gamma_q_inv_imp(
|
||||
static_cast<result_type>(a),
|
||||
static_cast<result_type>(p), pol);
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
gamma_p_inv(T1 a, T2 p)
|
||||
{
|
||||
return gamma_p_inv(a, p, policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
gamma_q_inv(T1 a, T2 p)
|
||||
{
|
||||
return gamma_q_inv(a, p, policies::policy<>());
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_FUNCTIONS_IGAMMA_INVERSE_HPP
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
program chkfft
|
||||
|
||||
! Tests and times one-dimensional FFTs computed by four2a().
|
||||
! An all-Fortran version of four2a() is available, but the preferred
|
||||
! version uses calls to the FFTW library.
|
||||
|
||||
parameter (NMAX=8*1024*1024) !Maximum FFT length
|
||||
complex a(NMAX),b(NMAX)
|
||||
real ar(NMAX),br(NMAX)
|
||||
real mflops
|
||||
character infile*12,arg*8
|
||||
logical list
|
||||
common/patience/npatience
|
||||
equivalence (a,ar),(b,br)
|
||||
|
||||
nargs=iargc()
|
||||
if(nargs.ne.5) then
|
||||
print*,'Usage: chkfft <nfft | infile> nr nw nc np'
|
||||
print*,' nfft: length of FFT'
|
||||
print*,' nfft=0: do lengths 2^n, n=2^4 to 2^23'
|
||||
print*,' infile: name of file with nfft values, one per line'
|
||||
print*,' nr: 0/1 to not read (or read) wisdom'
|
||||
print*,' nw: 0/1 to not write (or write) wisdom'
|
||||
print*,' nc: 0/1 for real or complex data'
|
||||
print*,' np: 0-4 patience for finding best algorithm'
|
||||
go to 999
|
||||
endif
|
||||
|
||||
list=.false.
|
||||
nfft=-1
|
||||
call getarg(1,infile)
|
||||
open(10,file=infile,status='old',err=1)
|
||||
list=.true. !A valid file name was provided
|
||||
go to 2
|
||||
1 read(infile,*) nfft !Takje first argument to be nfft
|
||||
2 call getarg(2,arg)
|
||||
read(arg,*) nr
|
||||
call getarg(3,arg)
|
||||
read(arg,*) nw
|
||||
call getarg(4,arg)
|
||||
read(arg,*) ncomplex
|
||||
call getarg(5,arg)
|
||||
read(arg,*) npatience
|
||||
|
||||
call sgran()
|
||||
|
||||
if(list) write(*,1000) infile,nr,nw,ncomplex,npatience
|
||||
1000 format(/'infile: ',a12,' nr:',i2,' nw',i2,' nc:',i2,' np:',i2/)
|
||||
if(.not.list) write(*,1002) nfft,nr,nw,ncomplex,npatience
|
||||
1002 format(/'nfft: ',i10,' nr:',i2,' nw',i2,' nc:',i2,' np:',i2/)
|
||||
|
||||
open(12,file='chkfft.out',status='unknown')
|
||||
open(13,file='fftwf_wisdom.dat',status='unknown')
|
||||
|
||||
if(nr.ne.0) then
|
||||
call import_wisdom_from_file(isuccess,13)
|
||||
if(isuccess.eq.0) then
|
||||
write(*,1010)
|
||||
1010 format('Failed to import FFTW wisdom.')
|
||||
go to 999
|
||||
endif
|
||||
endif
|
||||
|
||||
idum=-1 !Set random seed
|
||||
ndim=1 !One-dimensional transforms
|
||||
do i=1,NMAX !Set random data
|
||||
x=gran()
|
||||
y=gran()
|
||||
b(i)=cmplx(x,y) !Generate random data
|
||||
enddo
|
||||
|
||||
iters=1000000
|
||||
if(list .or. (nfft.gt.0)) then
|
||||
n1=1
|
||||
n2=1
|
||||
if(nfft.eq.-1) n2=999999
|
||||
write(*,1020)
|
||||
1020 format(' NFFT Time rms MHz MFlops iters', &
|
||||
' tplan'/61('-'))
|
||||
else
|
||||
n1=4
|
||||
n2=23
|
||||
write(*,1030)
|
||||
1030 format(' n N=2^n Time rms MHz MFlops iters', &
|
||||
' tplan'/63('-'))
|
||||
endif
|
||||
|
||||
do ii=n1,n2 !Test one or more FFT lengths
|
||||
if(list) then
|
||||
read(10,*,end=900) nfft !Read nfft from file
|
||||
else if(n2.gt.n1) then
|
||||
nfft=2**ii !Do powers of 2
|
||||
endif
|
||||
|
||||
iformf=1
|
||||
iformb=1
|
||||
if(ncomplex.eq.0) then
|
||||
iformf=0 !Real-to-complex transform
|
||||
iformb=-1 !Complex-to-real (inverse) transform
|
||||
endif
|
||||
|
||||
if(nfft.gt.NMAX) go to 900
|
||||
a(1:nfft)=b(1:nfft) !Copy test data into a()
|
||||
t0=second()
|
||||
call four2a(a,nfft,ndim,-1,iformf) !Get planning time for forward FFT
|
||||
call four2a(a,nfft,ndim,+1,iformb) !Get planning time for backward FFT
|
||||
t2=second()
|
||||
tplan=t2-t0 !Total planning time for this length
|
||||
|
||||
total=0.
|
||||
do iter=1,iters !Now do many iterations
|
||||
a(1:nfft)=b(1:nfft) !Copy test data into a()
|
||||
|
||||
t0=second()
|
||||
call four2a(a,nfft,ndim,-1,iformf) !Forward FFT
|
||||
call four2a(a,nfft,ndim,+1,iformb) !Backward FFT on same data
|
||||
t1=second()
|
||||
total=total+t1-t0
|
||||
if(total.ge.1.0) go to 40 !Cut iterations short if t>1 s
|
||||
enddo
|
||||
iter=iters
|
||||
|
||||
40 time=0.5*total/iter !Time for one FFT of current length
|
||||
tplan=0.5*tplan-time !Planning time for one FFT
|
||||
if(tplan.lt.0) tplan=0.
|
||||
a(1:nfft)=a(1:nfft)/nfft
|
||||
|
||||
! Compute RMS difference between original array and back-transformed array.
|
||||
sq=0.
|
||||
if(ncomplex.eq.1) then
|
||||
do i=1,nfft
|
||||
sq=sq + real(a(i)-b(i))**2 + imag(a(i)-b(i))**2
|
||||
enddo
|
||||
else
|
||||
do i=1,nfft
|
||||
sq=sq + (ar(i)-br(i))**2
|
||||
enddo
|
||||
endif
|
||||
rms=sqrt(sq/nfft)
|
||||
|
||||
freq=1.e-6*nfft/time
|
||||
mflops=5.0/(1.e6*time/(nfft*log(float(nfft))/log(2.0)))
|
||||
if(n2.eq.1 .or. n2.eq.999999) then
|
||||
write(*,1050) nfft,time,rms,freq,mflops,iter,tplan
|
||||
write(12,1050) nfft,time,rms,freq,mflops,iter,tplan
|
||||
1050 format(i8,f11.7,f12.8,f7.2,f8.1,i8,f6.1)
|
||||
else
|
||||
write(*,1060) ii,nfft,time,rms,freq,mflops,iter,tplan
|
||||
write(12,1060) ii,nfft,time,rms,freq,mflops,iter,tplan
|
||||
1060 format(i2,i8,f11.7,f12.8,f7.2,f8.1,i8,f6.1)
|
||||
endif
|
||||
if(mod(ii,50).eq.0) call four2a(0,-1,0,0,0)
|
||||
enddo
|
||||
|
||||
900 continue
|
||||
if(nw.eq.1) then
|
||||
rewind 13
|
||||
call export_wisdom_to_file(13)
|
||||
! write(*,1070)
|
||||
!1070 format(/'Exported FFTW wisdom')
|
||||
endif
|
||||
|
||||
999 call four2a(0,-1,0,0,0)
|
||||
end program chkfft
|
||||
@@ -0,0 +1,295 @@
|
||||
|
||||
// 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 the main "reverse_fold_impl.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
/// forward declaration
|
||||
|
||||
template<
|
||||
long N
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct reverse_fold_impl;
|
||||
|
||||
template< long N >
|
||||
struct reverse_fold_chunk;
|
||||
|
||||
template<> struct reverse_fold_chunk<0>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef fwd_state0 bkwd_state0;
|
||||
typedef bkwd_state0 state;
|
||||
typedef iter0 iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct reverse_fold_chunk<1>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
|
||||
typedef typename mpl::next<iter0>::type iter1;
|
||||
|
||||
|
||||
typedef fwd_state1 bkwd_state1;
|
||||
typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
|
||||
typedef bkwd_state0 state;
|
||||
typedef iter1 iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct reverse_fold_chunk<2>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
|
||||
typedef typename mpl::next<iter0>::type iter1;
|
||||
typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
|
||||
typedef typename mpl::next<iter1>::type iter2;
|
||||
|
||||
|
||||
typedef fwd_state2 bkwd_state2;
|
||||
typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
|
||||
typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
|
||||
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef iter2 iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct reverse_fold_chunk<3>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
|
||||
typedef typename mpl::next<iter0>::type iter1;
|
||||
typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
|
||||
typedef typename mpl::next<iter1>::type iter2;
|
||||
typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
|
||||
typedef typename mpl::next<iter2>::type iter3;
|
||||
|
||||
|
||||
typedef fwd_state3 bkwd_state3;
|
||||
typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
|
||||
typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
|
||||
typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
|
||||
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef iter3 iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct reverse_fold_chunk<4>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
|
||||
typedef typename mpl::next<iter0>::type iter1;
|
||||
typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
|
||||
typedef typename mpl::next<iter1>::type iter2;
|
||||
typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
|
||||
typedef typename mpl::next<iter2>::type iter3;
|
||||
typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
|
||||
typedef typename mpl::next<iter3>::type iter4;
|
||||
|
||||
|
||||
typedef fwd_state4 bkwd_state4;
|
||||
typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
|
||||
typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
|
||||
typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
|
||||
typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
|
||||
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef iter4 iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template< long N >
|
||||
struct reverse_fold_chunk
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
|
||||
typedef typename mpl::next<iter0>::type iter1;
|
||||
typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
|
||||
typedef typename mpl::next<iter1>::type iter2;
|
||||
typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
|
||||
typedef typename mpl::next<iter2>::type iter3;
|
||||
typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
|
||||
typedef typename mpl::next<iter3>::type iter4;
|
||||
|
||||
|
||||
typedef reverse_fold_impl<
|
||||
( (N - 4) < 0 ? 0 : N - 4 )
|
||||
, iter4
|
||||
, Last
|
||||
, fwd_state4
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_chunk;
|
||||
|
||||
typedef typename nested_chunk::state bkwd_state4;
|
||||
typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
|
||||
typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
|
||||
typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
|
||||
typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
|
||||
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef typename nested_chunk::iterator iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct reverse_fold_step;
|
||||
|
||||
template<
|
||||
typename Last
|
||||
, typename State
|
||||
>
|
||||
struct reverse_fold_null_step
|
||||
{
|
||||
typedef Last iterator;
|
||||
typedef State state;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct reverse_fold_chunk< -1 >
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef typename if_<
|
||||
typename is_same< First,Last >::type
|
||||
, reverse_fold_null_step< Last,State >
|
||||
, reverse_fold_step< First,Last,State,BackwardOp,ForwardOp >
|
||||
>::type res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct reverse_fold_step
|
||||
{
|
||||
typedef reverse_fold_chunk< -1 >::template result_<
|
||||
typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State, typename deref<First>::type>::type
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_step;
|
||||
|
||||
typedef typename apply2<
|
||||
BackwardOp
|
||||
, typename nested_step::state
|
||||
, typename deref<First>::type
|
||||
>::type state;
|
||||
|
||||
typedef typename nested_step::iterator iterator;
|
||||
};
|
||||
|
||||
template<
|
||||
long N
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct reverse_fold_impl
|
||||
: reverse_fold_chunk<N>
|
||||
::template result_< First,Last,State,BackwardOp,ForwardOp >
|
||||
{
|
||||
};
|
||||
|
||||
}}}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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_CONST_REVERSE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// This interface is deprecated, use range_reverse_iterator<const T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_const_reverse_iterator
|
||||
: range_reverse_iterator<
|
||||
const BOOST_DEDUCED_TYPENAME remove_reference<C>::type>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://boostorg.github.com/compute for more information.
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
|
||||
#define BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
|
||||
|
||||
#include <boost/compute/system.hpp>
|
||||
#include <boost/compute/command_queue.hpp>
|
||||
#include <boost/compute/algorithm/mismatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
|
||||
/// Returns \c true if the range [\p first1, \p last1) and the range
|
||||
/// beginning at \p first2 are equal.
|
||||
template<class InputIterator1, class InputIterator2>
|
||||
inline bool equal(InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
command_queue &queue = system::default_queue())
|
||||
{
|
||||
return ::boost::compute::mismatch(first1,
|
||||
last1,
|
||||
first2,
|
||||
queue).first == last1;
|
||||
}
|
||||
|
||||
/// \overload
|
||||
template<class InputIterator1, class InputIterator2>
|
||||
inline bool equal(InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
command_queue &queue = system::default_queue())
|
||||
{
|
||||
if(std::distance(first1, last1) != std::distance(first2, last2)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return ::boost::compute::equal(first1, last1, first2, queue);
|
||||
}
|
||||
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
|
||||
@@ -0,0 +1,70 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// (C) Copyright Ion Gaztanaga 2005-2015.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
// The alignment and Type traits implementation comes from
|
||||
// John Maddock's TypeTraits library.
|
||||
//
|
||||
// Some other tricks come from Howard Hinnant's papers and StackOverflow replies
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP
|
||||
#define BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/move/detail/type_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
using ::boost::move_detail::enable_if;
|
||||
using ::boost::move_detail::enable_if_and;
|
||||
using ::boost::move_detail::is_same;
|
||||
using ::boost::move_detail::is_different;
|
||||
using ::boost::move_detail::is_pointer;
|
||||
using ::boost::move_detail::add_reference;
|
||||
using ::boost::move_detail::add_const;
|
||||
using ::boost::move_detail::add_const_reference;
|
||||
using ::boost::move_detail::remove_const;
|
||||
using ::boost::move_detail::remove_reference;
|
||||
using ::boost::move_detail::make_unsigned;
|
||||
using ::boost::move_detail::is_floating_point;
|
||||
using ::boost::move_detail::is_integral;
|
||||
using ::boost::move_detail::is_enum;
|
||||
using ::boost::move_detail::is_pod;
|
||||
using ::boost::move_detail::is_empty;
|
||||
using ::boost::move_detail::is_trivially_destructible;
|
||||
using ::boost::move_detail::is_trivially_default_constructible;
|
||||
using ::boost::move_detail::is_trivially_copy_constructible;
|
||||
using ::boost::move_detail::is_trivially_move_constructible;
|
||||
using ::boost::move_detail::is_trivially_copy_assignable;
|
||||
using ::boost::move_detail::is_trivially_move_assignable;
|
||||
using ::boost::move_detail::is_nothrow_default_constructible;
|
||||
using ::boost::move_detail::is_nothrow_copy_constructible;
|
||||
using ::boost::move_detail::is_nothrow_move_constructible;
|
||||
using ::boost::move_detail::is_nothrow_copy_assignable;
|
||||
using ::boost::move_detail::is_nothrow_move_assignable;
|
||||
using ::boost::move_detail::is_nothrow_swappable;
|
||||
using ::boost::move_detail::alignment_of;
|
||||
using ::boost::move_detail::aligned_storage;
|
||||
using ::boost::move_detail::nat;
|
||||
using ::boost::move_detail::max_align_t;
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP
|
||||
@@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2010-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/intrusive for documentation.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
|
||||
#define BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/detail/workaround.hpp>
|
||||
#include <boost/intrusive/intrusive_fwd.hpp>
|
||||
|
||||
#include <boost/intrusive/detail/parent_from_member.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
|
||||
//! Given a pointer to a member and its corresponding pointer to data member,
|
||||
//! this function returns the pointer of the parent containing that member.
|
||||
//! Note: this function does not work with pointer to members that rely on
|
||||
//! virtual inheritance.
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE Parent *get_parent_from_member(Member *member, const Member Parent::* ptr_to_member)
|
||||
{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); }
|
||||
|
||||
//! Given a const pointer to a member and its corresponding const pointer to data member,
|
||||
//! this function returns the const pointer of the parent containing that member.
|
||||
//! Note: this function does not work with pointer to members that rely on
|
||||
//! virtual inheritance.
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE const Parent *get_parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
|
||||
{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); }
|
||||
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
|
||||
@@ -0,0 +1,186 @@
|
||||
subroutine osd174(llr,apmask,norder,decoded,cw,nhardmin,dmin)
|
||||
!
|
||||
! An ordered-statistics decoder for the (174,87) code.
|
||||
!
|
||||
include "ldpc_174_87_params.f90"
|
||||
|
||||
integer*1 apmask(N),apmaskr(N)
|
||||
integer*1 gen(K,N)
|
||||
integer*1 genmrb(K,N),g2(N,K)
|
||||
integer*1 temp(K),m0(K),me(K),mi(K)
|
||||
integer indices(N),nxor(N)
|
||||
integer*1 cw(N),ce(N),c0(N),hdec(N)
|
||||
integer*1 decoded(K)
|
||||
integer indx(N)
|
||||
real llr(N),rx(N),absrx(N)
|
||||
logical first
|
||||
data first/.true./
|
||||
|
||||
save first,gen
|
||||
|
||||
if( first ) then ! fill the generator matrix
|
||||
gen=0
|
||||
do i=1,M
|
||||
do j=1,22
|
||||
read(g(i)(j:j),"(Z1)") istr
|
||||
do jj=1, 4
|
||||
irow=(j-1)*4+jj
|
||||
if( btest(istr,4-jj) ) gen(irow,i)=1
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
do irow=1,K
|
||||
gen(irow,M+irow)=1
|
||||
enddo
|
||||
first=.false.
|
||||
endif
|
||||
|
||||
! re-order received vector to place systematic msg bits at the end
|
||||
rx=llr(colorder+1)
|
||||
apmaskr=apmask(colorder+1)
|
||||
|
||||
|
||||
! hard decode the received word
|
||||
hdec=0
|
||||
where(rx .ge. 0) hdec=1
|
||||
|
||||
! use magnitude of received symbols as a measure of reliability.
|
||||
absrx=abs(rx)
|
||||
call indexx(absrx,N,indx)
|
||||
|
||||
! re-order the columns of the generator matrix in order of decreasing reliability.
|
||||
do i=1,N
|
||||
genmrb(1:K,i)=gen(1:K,indx(N+1-i))
|
||||
indices(i)=indx(N+1-i)
|
||||
enddo
|
||||
|
||||
! do gaussian elimination to create a generator matrix with the most reliable
|
||||
! received bits in positions 1:K in order of decreasing reliability (more or less).
|
||||
! reliability will not be strictly decreasing because column re-ordering is needed
|
||||
! to put the generator matrix in systematic form. the "indices" array tracks
|
||||
! column permutations caused by reliability sorting and gaussian elimination.
|
||||
do id=1,K ! diagonal element indices
|
||||
do icol=id,K+20 ! The 20 is ad hoc - beware
|
||||
iflag=0
|
||||
if( genmrb(id,icol) .eq. 1 ) then
|
||||
iflag=1
|
||||
if( icol .ne. id ) then ! reorder column
|
||||
temp(1:K)=genmrb(1:K,id)
|
||||
genmrb(1:K,id)=genmrb(1:K,icol)
|
||||
genmrb(1:K,icol)=temp(1:K)
|
||||
itmp=indices(id)
|
||||
indices(id)=indices(icol)
|
||||
indices(icol)=itmp
|
||||
endif
|
||||
do ii=1,K
|
||||
if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then
|
||||
genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N))
|
||||
endif
|
||||
enddo
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
|
||||
g2=transpose(genmrb)
|
||||
|
||||
! The hard decisions for the K MRB bits define the order 0 message, m0.
|
||||
! Encode m0 using the modified generator matrix to find the "order 0" codeword.
|
||||
! Flip various combinations of bits in m0 and re-encode to generate a list of
|
||||
! codewords. Test all such codewords against the received word to decide which
|
||||
! codeword is most likely to be correct.
|
||||
|
||||
hdec=hdec(indices) ! hard decisions from received symbols
|
||||
m0=hdec(1:K) ! zero'th order message
|
||||
absrx=absrx(indices)
|
||||
rx=rx(indices)
|
||||
apmaskr=apmaskr(indices)
|
||||
|
||||
s1=sum(absrx(1:K))
|
||||
s2=sum(absrx(K+1:N))
|
||||
xlam=7.0 ! larger values reject more error patterns
|
||||
rho=s1/(s1+xlam*s2)
|
||||
call mrbencode(m0,c0,g2,N,K)
|
||||
nxor=ieor(c0,hdec)
|
||||
nhardmin=sum(nxor)
|
||||
dmin=sum(nxor*absrx)
|
||||
thresh=rho*dmin
|
||||
|
||||
cw=c0
|
||||
nt=0
|
||||
nrejected=0
|
||||
do iorder=1,norder
|
||||
mi(1:K-iorder)=0
|
||||
mi(K-iorder+1:K)=1
|
||||
iflag=0
|
||||
do while(iflag .ge. 0 )
|
||||
if(all(iand(apmaskr(1:K),mi).eq.0)) then ! reject patterns with ap bits
|
||||
dpat=sum(mi*absrx(1:K))
|
||||
nt=nt+1
|
||||
if( dpat .lt. thresh ) then ! reject unlikely error patterns
|
||||
me=ieor(m0,mi)
|
||||
call mrbencode(me,ce,g2,N,K)
|
||||
nxor=ieor(ce,hdec)
|
||||
dd=sum(nxor*absrx)
|
||||
if( dd .lt. dmin ) then
|
||||
dmin=dd
|
||||
cw=ce
|
||||
nhardmin=sum(nxor)
|
||||
thresh=rho*dmin
|
||||
endif
|
||||
else
|
||||
nrejected=nrejected+1
|
||||
endif
|
||||
endif
|
||||
! get the next test error pattern, iflag will go negative
|
||||
! when the last pattern with weight iorder has been generated
|
||||
call nextpat(mi,k,iorder,iflag)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!write(*,*) 'nhardmin ',nhardmin
|
||||
!write(*,*) 'total patterns ',nt,' number rejected ',nrejected
|
||||
|
||||
! re-order the codeword to place message bits at the end
|
||||
cw(indices)=cw
|
||||
hdec(indices)=hdec
|
||||
decoded=cw(M+1:N)
|
||||
cw(colorder+1)=cw ! put the codeword back into received-word order
|
||||
return
|
||||
end subroutine osd174
|
||||
|
||||
subroutine mrbencode(me,codeword,g2,N,K)
|
||||
integer*1 me(K),codeword(N),g2(N,K)
|
||||
! fast encoding for low-weight test patterns
|
||||
codeword=0
|
||||
do i=1,K
|
||||
if( me(i) .eq. 1 ) then
|
||||
codeword=ieor(codeword,g2(1:N,i))
|
||||
endif
|
||||
enddo
|
||||
return
|
||||
end subroutine mrbencode
|
||||
|
||||
subroutine nextpat(mi,k,iorder,iflag)
|
||||
integer*1 mi(k),ms(k)
|
||||
! generate the next test error pattern
|
||||
ind=-1
|
||||
do i=1,k-1
|
||||
if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i
|
||||
enddo
|
||||
if( ind .lt. 0 ) then ! no more patterns of this order
|
||||
iflag=ind
|
||||
return
|
||||
endif
|
||||
ms=0
|
||||
ms(1:ind-1)=mi(1:ind-1)
|
||||
ms(ind)=1
|
||||
ms(ind+1)=0
|
||||
if( ind+1 .lt. k ) then
|
||||
nz=iorder-sum(ms)
|
||||
ms(k-nz+1:k)=1
|
||||
endif
|
||||
mi=ms
|
||||
iflag=ind
|
||||
return
|
||||
end subroutine nextpat
|
||||
@@ -0,0 +1,349 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
This is an auto-generated file. Do not edit!
|
||||
==============================================================================*/
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
template <typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19>
|
||||
struct tuple : vector<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19>
|
||||
{
|
||||
typedef vector<
|
||||
T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19>
|
||||
base_type;
|
||||
BOOST_FUSION_GPU_ENABLED tuple()
|
||||
: base_type() {}
|
||||
BOOST_FUSION_GPU_ENABLED tuple(tuple const& rhs)
|
||||
: base_type(static_cast<base_type const&>(rhs)) {}
|
||||
template <typename U1, typename U2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(std::pair<U1, U2> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
tuple(typename detail::call_param<T0 >::type arg0)
|
||||
: base_type(arg0) {}
|
||||
template <typename U0>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1)
|
||||
: base_type(arg0 , arg1) {}
|
||||
template <typename U0 , typename U1>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2)
|
||||
: base_type(arg0 , arg1 , arg2) {}
|
||||
template <typename U0 , typename U1 , typename U2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14 , typename detail::call_param<T15 >::type arg15)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14 , arg15) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14 , typename detail::call_param<T15 >::type arg15 , typename detail::call_param<T16 >::type arg16)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14 , arg15 , arg16) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14 , typename detail::call_param<T15 >::type arg15 , typename detail::call_param<T16 >::type arg16 , typename detail::call_param<T17 >::type arg17)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14 , arg15 , arg16 , arg17) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14 , typename detail::call_param<T15 >::type arg15 , typename detail::call_param<T16 >::type arg16 , typename detail::call_param<T17 >::type arg17 , typename detail::call_param<T18 >::type arg18)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14 , arg15 , arg16 , arg17 , arg18) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17 , U18> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17 , U18> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(typename detail::call_param<T0 >::type arg0 , typename detail::call_param<T1 >::type arg1 , typename detail::call_param<T2 >::type arg2 , typename detail::call_param<T3 >::type arg3 , typename detail::call_param<T4 >::type arg4 , typename detail::call_param<T5 >::type arg5 , typename detail::call_param<T6 >::type arg6 , typename detail::call_param<T7 >::type arg7 , typename detail::call_param<T8 >::type arg8 , typename detail::call_param<T9 >::type arg9 , typename detail::call_param<T10 >::type arg10 , typename detail::call_param<T11 >::type arg11 , typename detail::call_param<T12 >::type arg12 , typename detail::call_param<T13 >::type arg13 , typename detail::call_param<T14 >::type arg14 , typename detail::call_param<T15 >::type arg15 , typename detail::call_param<T16 >::type arg16 , typename detail::call_param<T17 >::type arg17 , typename detail::call_param<T18 >::type arg18 , typename detail::call_param<T19 >::type arg19)
|
||||
: base_type(arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 , arg14 , arg15 , arg16 , arg17 , arg18 , arg19) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17 , U18 , U19> const& rhs)
|
||||
: base_type(rhs) {}
|
||||
template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple<U0 , U1 , U2 , U3 , U4 , U5 , U6 , U7 , U8 , U9 , U10 , U11 , U12 , U13 , U14 , U15 , U16 , U17 , U18 , U19> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
template <typename T>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(T const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(tuple const& rhs)
|
||||
{
|
||||
base_type::operator=(static_cast<base_type const&>(rhs));
|
||||
return *this;
|
||||
}
|
||||
template <typename U1, typename U2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(std::pair<U1, U2> const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
template <typename Tuple>
|
||||
struct tuple_size : result_of::size<Tuple> {};
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_element : result_of::value_at_c<Tuple, N> {};
|
||||
template <int N, typename Tuple>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename
|
||||
lazy_disable_if<
|
||||
is_const<Tuple>
|
||||
, result_of::at_c<Tuple, N>
|
||||
>::type
|
||||
get(Tuple& tup)
|
||||
{
|
||||
return at_c<N>(tup);
|
||||
}
|
||||
template <int N, typename Tuple>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::at_c<Tuple const, N>::type
|
||||
get(Tuple const& tup)
|
||||
{
|
||||
return at_c<N>(tup);
|
||||
}
|
||||
}}
|
||||
@@ -0,0 +1,204 @@
|
||||
// Copyright (C) 2009 Andrew Sutton
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GRAPH_MUTABILITY_TRAITS_HPP
|
||||
#define BOOST_GRAPH_MUTABILITY_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// The mutabiltiy categories classify graphs by their mutating operations
|
||||
// on the edge and vertex sets. This is a substantially more refined
|
||||
// categorization than the MutableGraph and MutablePropertyGraph denote.
|
||||
// Currently, this framework is only used in the graph tests to help
|
||||
// dispatch test to the correct places. However, there are probably some
|
||||
// constructive or destructive algorithms (i.e., graph generators) that
|
||||
// may use these to describe requirements on graph inputs.
|
||||
|
||||
struct add_vertex_tag { };
|
||||
struct add_vertex_property_tag : virtual add_vertex_tag { };
|
||||
struct add_edge_tag { };
|
||||
struct add_edge_property_tag : virtual add_edge_tag { };
|
||||
struct remove_vertex_tag { };
|
||||
struct remove_edge_tag { };
|
||||
|
||||
struct mutable_vertex_graph_tag
|
||||
: virtual add_vertex_tag, virtual remove_vertex_tag
|
||||
{ };
|
||||
struct mutable_vertex_property_graph_tag
|
||||
: virtual add_vertex_property_tag, virtual remove_vertex_tag
|
||||
{ };
|
||||
|
||||
struct mutable_edge_graph_tag
|
||||
: virtual add_edge_tag, virtual remove_edge_tag
|
||||
{ };
|
||||
struct mutable_edge_property_graph_tag
|
||||
: virtual add_edge_property_tag, virtual remove_edge_tag
|
||||
{ };
|
||||
|
||||
struct mutable_graph_tag
|
||||
: virtual mutable_vertex_graph_tag
|
||||
, virtual mutable_edge_graph_tag
|
||||
{ };
|
||||
struct mutable_property_graph_tag
|
||||
: virtual mutable_vertex_property_graph_tag
|
||||
, virtual mutable_edge_property_graph_tag
|
||||
{ };
|
||||
|
||||
// Some graphs just don't like to be torn down. Note this only restricts
|
||||
// teardown to the set of vertices, not the vertex set.
|
||||
// TODO: Find a better name for this tag.
|
||||
struct add_only_property_graph_tag
|
||||
: virtual add_vertex_property_tag
|
||||
, virtual mutable_edge_property_graph_tag
|
||||
{ };
|
||||
|
||||
/**
|
||||
* The graph_mutability_traits provide methods for determining the
|
||||
* interfaces supported by graph classes for adding and removing vertices
|
||||
* and edges.
|
||||
*/
|
||||
template <typename Graph>
|
||||
struct graph_mutability_traits {
|
||||
typedef typename Graph::mutability_category category;
|
||||
};
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_add_vertex
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
add_vertex_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_add_vertex_with_property
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
add_vertex_property_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_remove_vertex
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
remove_vertex_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_add_edge
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
add_edge_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_add_edge_with_property
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
add_edge_property_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
|
||||
template <typename Graph>
|
||||
struct graph_has_remove_edge
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
remove_edge_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_vertex_graph
|
||||
: mpl::and_<
|
||||
graph_has_add_vertex<Graph>,
|
||||
graph_has_remove_vertex<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_vertex_property_graph
|
||||
: mpl::and_<
|
||||
graph_has_add_vertex_with_property<Graph>,
|
||||
graph_has_remove_vertex<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_edge_graph
|
||||
: mpl::and_<
|
||||
graph_has_add_edge<Graph>,
|
||||
graph_has_remove_edge<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_edge_property_graph
|
||||
: mpl::and_<
|
||||
graph_has_add_edge_with_property<Graph>,
|
||||
graph_has_remove_edge<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_graph
|
||||
: mpl::and_<
|
||||
is_mutable_vertex_graph<Graph>,
|
||||
is_mutable_edge_graph<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct is_mutable_property_graph
|
||||
: mpl::and_<
|
||||
is_mutable_vertex_property_graph<Graph>,
|
||||
is_mutable_edge_property_graph<Graph>
|
||||
>
|
||||
{ };
|
||||
|
||||
template <typename Graph>
|
||||
struct is_add_only_property_graph
|
||||
: mpl::bool_<
|
||||
is_convertible<
|
||||
typename graph_mutability_traits<Graph>::category,
|
||||
add_only_property_graph_tag
|
||||
>::value
|
||||
>
|
||||
{ };
|
||||
|
||||
/** @name Mutability Traits Specializations */
|
||||
//@{
|
||||
|
||||
//@}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2012-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_CONTAINER_THROW_EXCEPTION_HPP
|
||||
#define BOOST_CONTAINER_THROW_EXCEPTION_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#include <stdexcept> //for std exception types
|
||||
#include <string> //for implicit std::string conversion
|
||||
#include <new> //for std::bad_alloc
|
||||
#else
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdlib> //for std::abort
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
#if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS)
|
||||
//The user must provide definitions for the following functions
|
||||
|
||||
void throw_bad_alloc();
|
||||
|
||||
void throw_out_of_range(const char* str);
|
||||
|
||||
void throw_length_error(const char* str);
|
||||
|
||||
void throw_logic_error(const char* str);
|
||||
|
||||
void throw_runtime_error(const char* str);
|
||||
|
||||
#elif defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
inline void throw_bad_alloc()
|
||||
{
|
||||
BOOST_ASSERT(!"boost::container bad_alloc thrown");
|
||||
std::abort();
|
||||
}
|
||||
|
||||
inline void throw_out_of_range(const char* str)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
inline void throw_length_error(const char* str)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!"boost::container length_error thrown", str);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
inline void throw_logic_error(const char* str)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
inline void throw_runtime_error(const char* str)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
#else //defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
//! Exception callback called by Boost.Container when fails to allocate the requested storage space.
|
||||
//! <ul>
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::bad_alloc()</code> is thrown.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
|
||||
//! is NOT defined <code>BOOST_ASSERT(!"boost::container bad_alloc thrown")</code> is called
|
||||
//! and <code>std::abort()</code> if the former returns.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
|
||||
//! the user must provide an implementation and the function should not return.</li>
|
||||
//! </ul>
|
||||
inline void throw_bad_alloc()
|
||||
{
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
//! Exception callback called by Boost.Container to signal arguments out of range.
|
||||
//! <ul>
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::out_of_range(str)</code> is thrown.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
|
||||
//! is NOT defined <code>BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str)</code> is called
|
||||
//! and <code>std::abort()</code> if the former returns.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
|
||||
//! the user must provide an implementation and the function should not return.</li>
|
||||
//! </ul>
|
||||
inline void throw_out_of_range(const char* str)
|
||||
{
|
||||
throw std::out_of_range(str);
|
||||
}
|
||||
|
||||
//! Exception callback called by Boost.Container to signal errors resizing.
|
||||
//! <ul>
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::length_error(str)</code> is thrown.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
|
||||
//! is NOT defined <code>BOOST_ASSERT_MSG(!"boost::container length_error thrown", str)</code> is called
|
||||
//! and <code>std::abort()</code> if the former returns.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
|
||||
//! the user must provide an implementation and the function should not return.</li>
|
||||
//! </ul>
|
||||
inline void throw_length_error(const char* str)
|
||||
{
|
||||
throw std::length_error(str);
|
||||
}
|
||||
|
||||
//! Exception callback called by Boost.Container to report errors in the internal logical
|
||||
//! of the program, such as violation of logical preconditions or class invariants.
|
||||
//! <ul>
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::logic_error(str)</code> is thrown.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
|
||||
//! is NOT defined <code>BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str)</code> is called
|
||||
//! and <code>std::abort()</code> if the former returns.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
|
||||
//! the user must provide an implementation and the function should not return.</li>
|
||||
//! </ul>
|
||||
inline void throw_logic_error(const char* str)
|
||||
{
|
||||
throw std::logic_error(str);
|
||||
}
|
||||
|
||||
//! Exception callback called by Boost.Container to report errors that can only be detected during runtime.
|
||||
//! <ul>
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::runtime_error(str)</code> is thrown.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
|
||||
//! is NOT defined <code>BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str)</code> is called
|
||||
//! and <code>std::abort()</code> if the former returns.</li>
|
||||
//!
|
||||
//! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
|
||||
//! the user must provide an implementation and the function should not return.</li>
|
||||
//! </ul>
|
||||
inline void throw_runtime_error(const char* str)
|
||||
{
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}} //namespace boost { namespace container {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
|
||||
@@ -0,0 +1,607 @@
|
||||
// boost\math\special_functions\negative_binomial.hpp
|
||||
|
||||
// Copyright Paul A. Bristow 2007.
|
||||
// Copyright John Maddock 2007.
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// http://en.wikipedia.org/wiki/negative_binomial_distribution
|
||||
// http://mathworld.wolfram.com/NegativeBinomialDistribution.html
|
||||
// http://documents.wolfram.com/teachersedition/Teacher/Statistics/DiscreteDistributions.html
|
||||
|
||||
// The negative binomial distribution NegativeBinomialDistribution[n, p]
|
||||
// is the distribution of the number (k) of failures that occur in a sequence of trials before
|
||||
// r successes have occurred, where the probability of success in each trial is p.
|
||||
|
||||
// In a sequence of Bernoulli trials or events
|
||||
// (independent, yes or no, succeed or fail) with success_fraction probability p,
|
||||
// negative_binomial is the probability that k or fewer failures
|
||||
// preceed the r th trial's success.
|
||||
// random variable k is the number of failures (NOT the probability).
|
||||
|
||||
// Negative_binomial distribution is a discrete probability distribution.
|
||||
// But note that the negative binomial distribution
|
||||
// (like others including the binomial, Poisson & Bernoulli)
|
||||
// is strictly defined as a discrete function: only integral values of k are envisaged.
|
||||
// However because of the method of calculation using a continuous gamma function,
|
||||
// it is convenient to treat it as if a continous function,
|
||||
// and permit non-integral values of k.
|
||||
|
||||
// However, by default the policy is to use discrete_quantile_policy.
|
||||
|
||||
// To enforce the strict mathematical model, users should use conversion
|
||||
// on k outside this function to ensure that k is integral.
|
||||
|
||||
// MATHCAD cumulative negative binomial pnbinom(k, n, p)
|
||||
|
||||
// Implementation note: much greater speed, and perhaps greater accuracy,
|
||||
// might be achieved for extreme values by using a normal approximation.
|
||||
// This is NOT been tested or implemented.
|
||||
|
||||
#ifndef BOOST_MATH_SPECIAL_NEGATIVE_BINOMIAL_HPP
|
||||
#define BOOST_MATH_SPECIAL_NEGATIVE_BINOMIAL_HPP
|
||||
|
||||
#include <boost/math/distributions/fwd.hpp>
|
||||
#include <boost/math/special_functions/beta.hpp> // for ibeta(a, b, x) == Ix(a, b).
|
||||
#include <boost/math/distributions/complement.hpp> // complement.
|
||||
#include <boost/math/distributions/detail/common_error_handling.hpp> // error checks domain_error & logic_error.
|
||||
#include <boost/math/special_functions/fpclassify.hpp> // isnan.
|
||||
#include <boost/math/tools/roots.hpp> // for root finding.
|
||||
#include <boost/math/distributions/detail/inv_discrete_quantile.hpp>
|
||||
|
||||
#include <boost/type_traits/is_floating_point.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <limits> // using std::numeric_limits;
|
||||
#include <utility>
|
||||
|
||||
#if defined (BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
// This believed not now necessary, so commented out.
|
||||
//# pragma warning(disable: 4702) // unreachable code.
|
||||
// in domain_error_imp in error_handling.
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
namespace negative_binomial_detail
|
||||
{
|
||||
// Common error checking routines for negative binomial distribution functions:
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_successes(const char* function, const RealType& r, RealType* result, const Policy& pol)
|
||||
{
|
||||
if( !(boost::math::isfinite)(r) || (r <= 0) )
|
||||
{
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Number of successes argument is %1%, but must be > 0 !", r, pol);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_success_fraction(const char* function, const RealType& p, RealType* result, const Policy& pol)
|
||||
{
|
||||
if( !(boost::math::isfinite)(p) || (p < 0) || (p > 1) )
|
||||
{
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Success fraction argument is %1%, but must be >= 0 and <= 1 !", p, pol);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_dist(const char* function, const RealType& r, const RealType& p, RealType* result, const Policy& pol)
|
||||
{
|
||||
return check_success_fraction(function, p, result, pol)
|
||||
&& check_successes(function, r, result, pol);
|
||||
}
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_dist_and_k(const char* function, const RealType& r, const RealType& p, RealType k, RealType* result, const Policy& pol)
|
||||
{
|
||||
if(check_dist(function, r, p, result, pol) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !(boost::math::isfinite)(k) || (k < 0) )
|
||||
{ // Check k failures.
|
||||
*result = policies::raise_domain_error<RealType>(
|
||||
function,
|
||||
"Number of failures argument is %1%, but must be >= 0 !", k, pol);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // Check_dist_and_k
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline bool check_dist_and_prob(const char* function, const RealType& r, RealType p, RealType prob, RealType* result, const Policy& pol)
|
||||
{
|
||||
if((check_dist(function, r, p, result, pol) && detail::check_probability(function, prob, result, pol)) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // check_dist_and_prob
|
||||
} // namespace negative_binomial_detail
|
||||
|
||||
template <class RealType = double, class Policy = policies::policy<> >
|
||||
class negative_binomial_distribution
|
||||
{
|
||||
public:
|
||||
typedef RealType value_type;
|
||||
typedef Policy policy_type;
|
||||
|
||||
negative_binomial_distribution(RealType r, RealType p) : m_r(r), m_p(p)
|
||||
{ // Constructor.
|
||||
RealType result;
|
||||
negative_binomial_detail::check_dist(
|
||||
"negative_binomial_distribution<%1%>::negative_binomial_distribution",
|
||||
m_r, // Check successes r > 0.
|
||||
m_p, // Check success_fraction 0 <= p <= 1.
|
||||
&result, Policy());
|
||||
} // negative_binomial_distribution constructor.
|
||||
|
||||
// Private data getter class member functions.
|
||||
RealType success_fraction() const
|
||||
{ // Probability of success as fraction in range 0 to 1.
|
||||
return m_p;
|
||||
}
|
||||
RealType successes() const
|
||||
{ // Total number of successes r.
|
||||
return m_r;
|
||||
}
|
||||
|
||||
static RealType find_lower_bound_on_p(
|
||||
RealType trials,
|
||||
RealType successes,
|
||||
RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test.
|
||||
{
|
||||
static const char* function = "boost::math::negative_binomial<%1%>::find_lower_bound_on_p";
|
||||
RealType result = 0; // of error checks.
|
||||
RealType failures = trials - successes;
|
||||
if(false == detail::check_probability(function, alpha, &result, Policy())
|
||||
&& negative_binomial_detail::check_dist_and_k(
|
||||
function, successes, RealType(0), failures, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
// Use complement ibeta_inv function for lower bound.
|
||||
// This is adapted from the corresponding binomial formula
|
||||
// here: http://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm
|
||||
// This is a Clopper-Pearson interval, and may be overly conservative,
|
||||
// see also "A Simple Improved Inferential Method for Some
|
||||
// Discrete Distributions" Yong CAI and K. KRISHNAMOORTHY
|
||||
// http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf
|
||||
//
|
||||
return ibeta_inv(successes, failures + 1, alpha, static_cast<RealType*>(0), Policy());
|
||||
} // find_lower_bound_on_p
|
||||
|
||||
static RealType find_upper_bound_on_p(
|
||||
RealType trials,
|
||||
RealType successes,
|
||||
RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test.
|
||||
{
|
||||
static const char* function = "boost::math::negative_binomial<%1%>::find_upper_bound_on_p";
|
||||
RealType result = 0; // of error checks.
|
||||
RealType failures = trials - successes;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function, successes, RealType(0), failures, &result, Policy())
|
||||
&& detail::check_probability(function, alpha, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if(failures == 0)
|
||||
return 1;
|
||||
// Use complement ibetac_inv function for upper bound.
|
||||
// Note adjusted failures value: *not* failures+1 as usual.
|
||||
// This is adapted from the corresponding binomial formula
|
||||
// here: http://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm
|
||||
// This is a Clopper-Pearson interval, and may be overly conservative,
|
||||
// see also "A Simple Improved Inferential Method for Some
|
||||
// Discrete Distributions" Yong CAI and K. KRISHNAMOORTHY
|
||||
// http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf
|
||||
//
|
||||
return ibetac_inv(successes, failures, alpha, static_cast<RealType*>(0), Policy());
|
||||
} // find_upper_bound_on_p
|
||||
|
||||
// Estimate number of trials :
|
||||
// "How many trials do I need to be P% sure of seeing k or fewer failures?"
|
||||
|
||||
static RealType find_minimum_number_of_trials(
|
||||
RealType k, // number of failures (k >= 0).
|
||||
RealType p, // success fraction 0 <= p <= 1.
|
||||
RealType alpha) // risk level threshold 0 <= alpha <= 1.
|
||||
{
|
||||
static const char* function = "boost::math::negative_binomial<%1%>::find_minimum_number_of_trials";
|
||||
// Error checks:
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function, RealType(1), p, k, &result, Policy())
|
||||
&& detail::check_probability(function, alpha, &result, Policy()))
|
||||
{ return result; }
|
||||
|
||||
result = ibeta_inva(k + 1, p, alpha, Policy()); // returns n - k
|
||||
return result + k;
|
||||
} // RealType find_number_of_failures
|
||||
|
||||
static RealType find_maximum_number_of_trials(
|
||||
RealType k, // number of failures (k >= 0).
|
||||
RealType p, // success fraction 0 <= p <= 1.
|
||||
RealType alpha) // risk level threshold 0 <= alpha <= 1.
|
||||
{
|
||||
static const char* function = "boost::math::negative_binomial<%1%>::find_maximum_number_of_trials";
|
||||
// Error checks:
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function, RealType(1), p, k, &result, Policy())
|
||||
&& detail::check_probability(function, alpha, &result, Policy()))
|
||||
{ return result; }
|
||||
|
||||
result = ibetac_inva(k + 1, p, alpha, Policy()); // returns n - k
|
||||
return result + k;
|
||||
} // RealType find_number_of_trials complemented
|
||||
|
||||
private:
|
||||
RealType m_r; // successes.
|
||||
RealType m_p; // success_fraction
|
||||
}; // template <class RealType, class Policy> class negative_binomial_distribution
|
||||
|
||||
typedef negative_binomial_distribution<double> negative_binomial; // Reserved name of type double.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const negative_binomial_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable k.
|
||||
using boost::math::tools::max_value;
|
||||
return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>()); // max_integer?
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> support(const negative_binomial_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of supported values for random variable k.
|
||||
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
|
||||
using boost::math::tools::max_value;
|
||||
return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>()); // max_integer?
|
||||
}
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mean(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // Mean of Negative Binomial distribution = r(1-p)/p.
|
||||
return dist.successes() * (1 - dist.success_fraction() ) / dist.success_fraction();
|
||||
} // mean
|
||||
|
||||
//template <class RealType, class Policy>
|
||||
//inline RealType median(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
//{ // Median of negative_binomial_distribution is not defined.
|
||||
// return policies::raise_domain_error<RealType>(BOOST_CURRENT_FUNCTION, "Median is not implemented, result is %1%!", std::numeric_limits<RealType>::quiet_NaN());
|
||||
//} // median
|
||||
// Now implemented via quantile(half) in derived accessors.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType mode(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // Mode of Negative Binomial distribution = floor[(r-1) * (1 - p)/p]
|
||||
BOOST_MATH_STD_USING // ADL of std functions.
|
||||
return floor((dist.successes() -1) * (1 - dist.success_fraction()) / dist.success_fraction());
|
||||
} // mode
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType skewness(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // skewness of Negative Binomial distribution = 2-p / (sqrt(r(1-p))
|
||||
BOOST_MATH_STD_USING // ADL of std functions.
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
|
||||
return (2 - p) /
|
||||
sqrt(r * (1 - p));
|
||||
} // skewness
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // kurtosis of Negative Binomial distribution
|
||||
// http://en.wikipedia.org/wiki/Negative_binomial is kurtosis_excess so add 3
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
return 3 + (6 / r) + ((p * p) / (r * (1 - p)));
|
||||
} // kurtosis
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType kurtosis_excess(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // kurtosis excess of Negative Binomial distribution
|
||||
// http://mathworld.wolfram.com/Kurtosis.html table of kurtosis_excess
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
return (6 - p * (6-p)) / (r * (1-p));
|
||||
} // kurtosis_excess
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType variance(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
{ // Variance of Binomial distribution = r (1-p) / p^2.
|
||||
return dist.successes() * (1 - dist.success_fraction())
|
||||
/ (dist.success_fraction() * dist.success_fraction());
|
||||
} // variance
|
||||
|
||||
// RealType standard_deviation(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
// standard_deviation provided by derived accessors.
|
||||
// RealType hazard(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
// hazard of Negative Binomial distribution provided by derived accessors.
|
||||
// RealType chf(const negative_binomial_distribution<RealType, Policy>& dist)
|
||||
// chf of Negative Binomial distribution provided by derived accessors.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType pdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType& k)
|
||||
{ // Probability Density/Mass Function.
|
||||
BOOST_FPU_EXCEPTION_GUARD
|
||||
|
||||
static const char* function = "boost::math::pdf(const negative_binomial_distribution<%1%>&, %1%)";
|
||||
|
||||
RealType r = dist.successes();
|
||||
RealType p = dist.success_fraction();
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function,
|
||||
r,
|
||||
dist.success_fraction(),
|
||||
k,
|
||||
&result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (p/(r + k)) * ibeta_derivative(r, static_cast<RealType>(k+1), p, Policy());
|
||||
// Equivalent to:
|
||||
// return exp(lgamma(r + k) - lgamma(r) - lgamma(k+1)) * pow(p, r) * pow((1-p), k);
|
||||
return result;
|
||||
} // negative_binomial_pdf
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const negative_binomial_distribution<RealType, Policy>& dist, const RealType& k)
|
||||
{ // Cumulative Distribution Function of Negative Binomial.
|
||||
static const char* function = "boost::math::cdf(const negative_binomial_distribution<%1%>&, %1%)";
|
||||
using boost::math::ibeta; // Regularized incomplete beta function.
|
||||
// k argument may be integral, signed, or unsigned, or floating point.
|
||||
// If necessary, it has already been promoted from an integral type.
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
// Error check:
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function,
|
||||
r,
|
||||
dist.success_fraction(),
|
||||
k,
|
||||
&result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
RealType probability = ibeta(r, static_cast<RealType>(k+1), p, Policy());
|
||||
// Ip(r, k+1) = ibeta(r, k+1, p)
|
||||
return probability;
|
||||
} // cdf Cumulative Distribution Function Negative Binomial.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType cdf(const complemented2_type<negative_binomial_distribution<RealType, Policy>, RealType>& c)
|
||||
{ // Complemented Cumulative Distribution Function Negative Binomial.
|
||||
|
||||
static const char* function = "boost::math::cdf(const negative_binomial_distribution<%1%>&, %1%)";
|
||||
using boost::math::ibetac; // Regularized incomplete beta function complement.
|
||||
// k argument may be integral, signed, or unsigned, or floating point.
|
||||
// If necessary, it has already been promoted from an integral type.
|
||||
RealType const& k = c.param;
|
||||
negative_binomial_distribution<RealType, Policy> const& dist = c.dist;
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
// Error check:
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_k(
|
||||
function,
|
||||
r,
|
||||
p,
|
||||
k,
|
||||
&result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
// Calculate cdf negative binomial using the incomplete beta function.
|
||||
// Use of ibeta here prevents cancellation errors in calculating
|
||||
// 1-p if p is very small, perhaps smaller than machine epsilon.
|
||||
// Ip(k+1, r) = ibetac(r, k+1, p)
|
||||
// constrain_probability here?
|
||||
RealType probability = ibetac(r, static_cast<RealType>(k+1), p, Policy());
|
||||
// Numerical errors might cause probability to be slightly outside the range < 0 or > 1.
|
||||
// This might cause trouble downstream, so warn, possibly throw exception, but constrain to the limits.
|
||||
return probability;
|
||||
} // cdf Cumulative Distribution Function Negative Binomial.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const negative_binomial_distribution<RealType, Policy>& dist, const RealType& P)
|
||||
{ // Quantile, percentile/100 or Percent Point Negative Binomial function.
|
||||
// Return the number of expected failures k for a given probability p.
|
||||
|
||||
// Inverse cumulative Distribution Function or Quantile (percentile / 100) of negative_binomial Probability.
|
||||
// MAthCAD pnbinom return smallest k such that negative_binomial(k, n, p) >= probability.
|
||||
// k argument may be integral, signed, or unsigned, or floating point.
|
||||
// BUT Cephes/CodeCogs says: finds argument p (0 to 1) such that cdf(k, n, p) = y
|
||||
static const char* function = "boost::math::quantile(const negative_binomial_distribution<%1%>&, %1%)";
|
||||
BOOST_MATH_STD_USING // ADL of std functions.
|
||||
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
// Check dist and P.
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_prob
|
||||
(function, r, p, P, &result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Special cases.
|
||||
if (P == 1)
|
||||
{ // Would need +infinity failures for total confidence.
|
||||
result = policies::raise_overflow_error<RealType>(
|
||||
function,
|
||||
"Probability argument is 1, which implies infinite failures !", Policy());
|
||||
return result;
|
||||
// usually means return +std::numeric_limits<RealType>::infinity();
|
||||
// unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
|
||||
}
|
||||
if (P == 0)
|
||||
{ // No failures are expected if P = 0.
|
||||
return 0; // Total trials will be just dist.successes.
|
||||
}
|
||||
if (P <= pow(dist.success_fraction(), dist.successes()))
|
||||
{ // p <= pdf(dist, 0) == cdf(dist, 0)
|
||||
return 0;
|
||||
}
|
||||
if(p == 0)
|
||||
{ // Would need +infinity failures for total confidence.
|
||||
result = policies::raise_overflow_error<RealType>(
|
||||
function,
|
||||
"Success fraction is 0, which implies infinite failures !", Policy());
|
||||
return result;
|
||||
// usually means return +std::numeric_limits<RealType>::infinity();
|
||||
// unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
|
||||
}
|
||||
/*
|
||||
// Calculate quantile of negative_binomial using the inverse incomplete beta function.
|
||||
using boost::math::ibeta_invb;
|
||||
return ibeta_invb(r, p, P, Policy()) - 1; //
|
||||
*/
|
||||
RealType guess = 0;
|
||||
RealType factor = 5;
|
||||
if(r * r * r * P * p > 0.005)
|
||||
guess = detail::inverse_negative_binomial_cornish_fisher(r, p, RealType(1-p), P, RealType(1-P), Policy());
|
||||
|
||||
if(guess < 10)
|
||||
{
|
||||
//
|
||||
// Cornish-Fisher Negative binomial approximation not accurate in this area:
|
||||
//
|
||||
guess = (std::min)(RealType(r * 2), RealType(10));
|
||||
}
|
||||
else
|
||||
factor = (1-P < sqrt(tools::epsilon<RealType>())) ? 2 : (guess < 20 ? 1.2f : 1.1f);
|
||||
BOOST_MATH_INSTRUMENT_CODE("guess = " << guess);
|
||||
//
|
||||
// Max iterations permitted:
|
||||
//
|
||||
boost::uintmax_t max_iter = policies::get_max_root_iterations<Policy>();
|
||||
typedef typename Policy::discrete_quantile_type discrete_type;
|
||||
return detail::inverse_discrete_quantile(
|
||||
dist,
|
||||
P,
|
||||
false,
|
||||
guess,
|
||||
factor,
|
||||
RealType(1),
|
||||
discrete_type(),
|
||||
max_iter);
|
||||
} // RealType quantile(const negative_binomial_distribution dist, p)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline RealType quantile(const complemented2_type<negative_binomial_distribution<RealType, Policy>, RealType>& c)
|
||||
{ // Quantile or Percent Point Binomial function.
|
||||
// Return the number of expected failures k for a given
|
||||
// complement of the probability Q = 1 - P.
|
||||
static const char* function = "boost::math::quantile(const negative_binomial_distribution<%1%>&, %1%)";
|
||||
BOOST_MATH_STD_USING
|
||||
|
||||
// Error checks:
|
||||
RealType Q = c.param;
|
||||
const negative_binomial_distribution<RealType, Policy>& dist = c.dist;
|
||||
RealType p = dist.success_fraction();
|
||||
RealType r = dist.successes();
|
||||
RealType result = 0;
|
||||
if(false == negative_binomial_detail::check_dist_and_prob(
|
||||
function,
|
||||
r,
|
||||
p,
|
||||
Q,
|
||||
&result, Policy()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Special cases:
|
||||
//
|
||||
if(Q == 1)
|
||||
{ // There may actually be no answer to this question,
|
||||
// since the probability of zero failures may be non-zero,
|
||||
return 0; // but zero is the best we can do:
|
||||
}
|
||||
if(Q == 0)
|
||||
{ // Probability 1 - Q == 1 so infinite failures to achieve certainty.
|
||||
// Would need +infinity failures for total confidence.
|
||||
result = policies::raise_overflow_error<RealType>(
|
||||
function,
|
||||
"Probability argument complement is 0, which implies infinite failures !", Policy());
|
||||
return result;
|
||||
// usually means return +std::numeric_limits<RealType>::infinity();
|
||||
// unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
|
||||
}
|
||||
if (-Q <= boost::math::powm1(dist.success_fraction(), dist.successes(), Policy()))
|
||||
{ // q <= cdf(complement(dist, 0)) == pdf(dist, 0)
|
||||
return 0; //
|
||||
}
|
||||
if(p == 0)
|
||||
{ // Success fraction is 0 so infinite failures to achieve certainty.
|
||||
// Would need +infinity failures for total confidence.
|
||||
result = policies::raise_overflow_error<RealType>(
|
||||
function,
|
||||
"Success fraction is 0, which implies infinite failures !", Policy());
|
||||
return result;
|
||||
// usually means return +std::numeric_limits<RealType>::infinity();
|
||||
// unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
|
||||
}
|
||||
//return ibetac_invb(r, p, Q, Policy()) -1;
|
||||
RealType guess = 0;
|
||||
RealType factor = 5;
|
||||
if(r * r * r * (1-Q) * p > 0.005)
|
||||
guess = detail::inverse_negative_binomial_cornish_fisher(r, p, RealType(1-p), RealType(1-Q), Q, Policy());
|
||||
|
||||
if(guess < 10)
|
||||
{
|
||||
//
|
||||
// Cornish-Fisher Negative binomial approximation not accurate in this area:
|
||||
//
|
||||
guess = (std::min)(RealType(r * 2), RealType(10));
|
||||
}
|
||||
else
|
||||
factor = (Q < sqrt(tools::epsilon<RealType>())) ? 2 : (guess < 20 ? 1.2f : 1.1f);
|
||||
BOOST_MATH_INSTRUMENT_CODE("guess = " << guess);
|
||||
//
|
||||
// Max iterations permitted:
|
||||
//
|
||||
boost::uintmax_t max_iter = policies::get_max_root_iterations<Policy>();
|
||||
typedef typename Policy::discrete_quantile_type discrete_type;
|
||||
return detail::inverse_discrete_quantile(
|
||||
dist,
|
||||
Q,
|
||||
true,
|
||||
guess,
|
||||
factor,
|
||||
RealType(1),
|
||||
discrete_type(),
|
||||
max_iter);
|
||||
} // quantile complement
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
// This include must be at the end, *after* the accessors
|
||||
// for this distribution have been defined, in order to
|
||||
// keep compilers that support two-phase lookup happy.
|
||||
#include <boost/math/distributions/detail/derived_accessors.hpp>
|
||||
|
||||
#if defined (BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_NEGATIVE_BINOMIAL_HPP
|
||||
@@ -0,0 +1,18 @@
|
||||
[Setup]
|
||||
AppName=wsjtx
|
||||
AppVerName=wsjtx Version 1.2 r3537
|
||||
AppCopyright=Copyright (C) 2001-2013 by Joe Taylor, K1JT
|
||||
DefaultDirName=c:\wsjtx1.2
|
||||
DefaultGroupName=wsjtx1.2
|
||||
|
||||
[Files]
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\wsjtx.exe"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\jt9.exe"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx\shortcuts.txt"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx\mouse_commands.txt"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx\WSJT-X_Users_Guide_v1.2.pdf"; DestDir: "{app}"
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\wsjtx1.2"; Filename: "{app}\wsjtx.exe"; WorkingDir: {app}; IconFilename: {app}\wsjt.ico
|
||||
Name: "{userdesktop}\wsjtx1.2"; Filename: "{app}\wsjtx.exe"; WorkingDir: {app}; IconFilename: {app}\wsjt.ico
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
// 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/not_equal_to.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Tag1
|
||||
, typename Tag2
|
||||
|
||||
, BOOST_MPL_AUX_NTTP_DECL(int, tag1_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value
|
||||
, BOOST_MPL_AUX_NTTP_DECL(int, tag2_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value
|
||||
>
|
||||
struct not_equal_to_impl
|
||||
: if_c<
|
||||
( tag1_ > tag2_ )
|
||||
, aux::cast2nd_impl< not_equal_to_impl< Tag1,Tag1 >,Tag1, Tag2 >
|
||||
, aux::cast1st_impl< not_equal_to_impl< Tag2,Tag2 >,Tag1, Tag2 >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
/// for Digital Mars C++/compilers with no CTPS/TTP support
|
||||
template<> struct not_equal_to_impl< na,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct not_equal_to_impl< na,integral_c_tag >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct not_equal_to_impl< integral_c_tag,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct not_equal_to_tag
|
||||
: tag< T,na >
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(N1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N2)
|
||||
>
|
||||
struct not_equal_to
|
||||
: aux::msvc_eti_base< typename apply_wrap2<
|
||||
not_equal_to_impl<
|
||||
typename not_equal_to_tag<N1>::type
|
||||
, typename not_equal_to_tag<N2>::type
|
||||
>
|
||||
, N1
|
||||
, N2
|
||||
>::type >::type
|
||||
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, not_equal_to, (N1, N2))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(2, 2, not_equal_to)
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct not_equal_to_impl< integral_c_tag,integral_c_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
( BOOST_MPL_AUX_VALUE_WKND(N1)::value !=
|
||||
BOOST_MPL_AUX_VALUE_WKND(N2)::value )
|
||||
);
|
||||
typedef bool_<value> type;
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,141 @@
|
||||
program timefft
|
||||
|
||||
! Tests and times one-dimensional FFTs computed by FFTW3
|
||||
|
||||
use, intrinsic :: iso_c_binding
|
||||
use FFTW3
|
||||
|
||||
complex(C_FLOAT_COMPLEX),pointer :: a(:),b(:),c(:)
|
||||
real(C_FLOAT),pointer :: ar(:),br(:)
|
||||
type(C_PTR) :: plan1,plan2 !Pointers to FFTW plans
|
||||
type(C_PTR) :: pa,pb,pc
|
||||
integer(C_INT) iret
|
||||
integer*8 count0,count1,clkfreq
|
||||
character problem*9
|
||||
logical linplace,lcomplex,lthreading
|
||||
|
||||
! Get command-line parameters
|
||||
call timefft_opts(npatience,maxthreads,linplace,lcomplex,nfft,problem,nflags)
|
||||
lthreading=maxthreads.ge.1
|
||||
maxthreads=max(1,maxthreads)
|
||||
|
||||
call sgran() ! see C rand generator (used in gran)
|
||||
|
||||
! Allocate data arrays
|
||||
pa=fftwf_alloc_complex(int(nfft,C_SIZE_T))
|
||||
call c_f_pointer(pa,a,[nfft])
|
||||
call c_f_pointer(pa,ar,[nfft])
|
||||
|
||||
pb=fftwf_alloc_complex(int(nfft,C_SIZE_T))
|
||||
call c_f_pointer(pb,b,[nfft])
|
||||
call c_f_pointer(pb,br,[nfft])
|
||||
|
||||
pc=fftwf_alloc_complex(int(nfft,C_SIZE_T))
|
||||
call c_f_pointer(pc,c,[nfft])
|
||||
|
||||
! Initialize FFTW threading
|
||||
if(lthreading) iret=fftwf_init_threads()
|
||||
|
||||
! Import FFTW wisdom, if available
|
||||
iret=fftwf_import_wisdom_from_filename(C_CHAR_'wis.dat' // C_NULL_CHAR)
|
||||
|
||||
do i=1,nfft !Generate random data
|
||||
x=gran()
|
||||
y=gran()
|
||||
b(i)=cmplx(x,y)
|
||||
enddo
|
||||
iters=100
|
||||
|
||||
write(*,1000)
|
||||
1000 format(/'Problem Threads Plan Time Gflops RMS iters'/ &
|
||||
'--------------------------------------------------------')
|
||||
|
||||
! Try nthreads = 1,maxthreads
|
||||
do nthreads=1,maxthreads
|
||||
a(1:nfft)=b(1:nfft) !Copy test data into a()
|
||||
call system_clock(count0,clkfreq)
|
||||
! Make the plans
|
||||
if(lthreading) call fftwf_plan_with_nthreads(nthreads)
|
||||
if(lcomplex) then
|
||||
if(linplace) then
|
||||
plan1=fftwf_plan_dft_1d(nfft,a,a,-1,nflags)
|
||||
plan2=fftwf_plan_dft_1d(nfft,a,a,+1,nflags)
|
||||
else
|
||||
plan1=fftwf_plan_dft_1d(nfft,a,c,-1,nflags)
|
||||
plan2=fftwf_plan_dft_1d(nfft,c,a,+1,nflags)
|
||||
endif
|
||||
else
|
||||
if(linplace) then
|
||||
plan1=fftwf_plan_dft_r2c_1d(nfft,ar,a,nflags)
|
||||
plan2=fftwf_plan_dft_c2r_1d(nfft,a,ar,nflags)
|
||||
else
|
||||
plan1=fftwf_plan_dft_r2c_1d(nfft,ar,c,nflags)
|
||||
plan2=fftwf_plan_dft_c2r_1d(nfft,c,ar,nflags)
|
||||
endif
|
||||
endif
|
||||
call system_clock(count1,clkfreq)
|
||||
tplan=0.5*float(count1-count0)/float(clkfreq) !Plan time for one transform
|
||||
|
||||
total=0.
|
||||
do iter=1,iters !Do many iterations
|
||||
a=b !Copy test data into a()
|
||||
call system_clock(count0,clkfreq)
|
||||
! Compute the transforms
|
||||
if(lcomplex) then
|
||||
if(linplace) then
|
||||
call fftwf_execute_dft(plan1,a,a)
|
||||
call fftwf_execute_dft(plan2,a,a)
|
||||
else
|
||||
call fftwf_execute_dft(plan1,a,c)
|
||||
call fftwf_execute_dft(plan2,c,a)
|
||||
endif
|
||||
else
|
||||
if(linplace) then
|
||||
call fftwf_execute_dft_r2c(plan1,ar,a)
|
||||
call fftwf_execute_dft_c2r(plan2,a,ar)
|
||||
else
|
||||
call fftwf_execute_dft_r2c(plan1,ar,c)
|
||||
call fftwf_execute_dft_c2r(plan2,c,ar)
|
||||
endif
|
||||
endif
|
||||
call system_clock(count1,clkfreq)
|
||||
total=total + float(count1-count0)/float(clkfreq)
|
||||
if(total>=1.0 .and. iter>=10) go to 40 !Cut iterations short ?
|
||||
enddo
|
||||
iter=iters
|
||||
|
||||
40 time=0.5*total/iter !Time for one FFT
|
||||
gflops=5.0/(1.e9*time/(nfft*log(float(nfft))/log(2.0)))
|
||||
a(1:nfft)=a(1:nfft)/nfft !Normalize the back-transformed data
|
||||
|
||||
! Compute RMS difference between original data and back-transformed data.
|
||||
sq=0.
|
||||
if(lcomplex) then
|
||||
do i=1,nfft
|
||||
sq=sq + real(a(i)-b(i))**2 + aimag(a(i)-b(i))**2
|
||||
enddo
|
||||
else
|
||||
do i=1,nfft
|
||||
sq=sq + (ar(i)-br(i))**2
|
||||
enddo
|
||||
endif
|
||||
rms=sqrt(sq/nfft)
|
||||
|
||||
! Display results
|
||||
write(*,1050) problem,nthreads,tplan,time,gflops,rms,iter
|
||||
1050 format(a9,i4,f8.3,f10.6,f7.2,f11.7,i5)
|
||||
enddo
|
||||
|
||||
! Export accumulated FFTW wisdom
|
||||
iret=fftwf_export_wisdom_to_filename(C_CHAR_'wis.dat' // C_NULL_CHAR)
|
||||
|
||||
! Clean up
|
||||
call fftwf_destroy_plan(plan1)
|
||||
call fftwf_destroy_plan(plan2)
|
||||
call fftwf_free(pa)
|
||||
call fftwf_free(pb)
|
||||
call fftwf_free(pc)
|
||||
call fftwf_cleanup_threads()
|
||||
call fftwf_cleanup()
|
||||
|
||||
end program timefft
|
||||
@@ -0,0 +1,593 @@
|
||||
#ifndef BOOST_MATH_NONFINITE_NUM_FACETS_HPP
|
||||
#define BOOST_MATH_NONFINITE_NUM_FACETS_HPP
|
||||
|
||||
// Copyright 2006 Johan Rade
|
||||
// Copyright 2012 K R Walker
|
||||
// Copyright 2011, 2012 Paul A. Bristow
|
||||
|
||||
// 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)
|
||||
|
||||
/*
|
||||
\file
|
||||
|
||||
\brief non_finite_num facets for C99 standard output of infinity and NaN.
|
||||
|
||||
\details See fuller documentation at Boost.Math Facets
|
||||
for Floating-Point Infinities and NaNs.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127) // conditional expression is constant.
|
||||
# pragma warning(disable : 4706) // assignment within conditional expression.
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace math {
|
||||
|
||||
// flags (enums can be ORed together) -----------------------------------
|
||||
|
||||
const int legacy = 0x1; //!< get facet will recognize most string representations of infinity and NaN.
|
||||
const int signed_zero = 0x2; //!< put facet will distinguish between positive and negative zero.
|
||||
const int trap_infinity = 0x4; /*!< put facet will throw an exception of type std::ios_base::failure
|
||||
when an attempt is made to format positive or negative infinity.
|
||||
get will set the fail bit of the stream when an attempt is made
|
||||
to parse a string that represents positive or negative sign infinity.
|
||||
*/
|
||||
const int trap_nan = 0x8; /*!< put facet will throw an exception of type std::ios_base::failure
|
||||
when an attempt is made to format positive or negative NaN.
|
||||
get will set the fail bit of the stream when an attempt is made
|
||||
to parse a string that represents positive or negative sign infinity.
|
||||
*/
|
||||
|
||||
// class nonfinite_num_put -----------------------------------------------------
|
||||
|
||||
template<
|
||||
class CharType,
|
||||
class OutputIterator = std::ostreambuf_iterator<CharType>
|
||||
>
|
||||
class nonfinite_num_put : public std::num_put<CharType, OutputIterator>
|
||||
{
|
||||
public:
|
||||
explicit nonfinite_num_put(int flags = 0) : flags_(flags) {}
|
||||
|
||||
protected:
|
||||
virtual OutputIterator do_put(
|
||||
OutputIterator it, std::ios_base& iosb, CharType fill, double val) const
|
||||
{
|
||||
put_and_reset_width(it, iosb, fill, val);
|
||||
return it;
|
||||
}
|
||||
|
||||
virtual OutputIterator do_put(
|
||||
OutputIterator it, std::ios_base& iosb, CharType fill, long double val) const
|
||||
{
|
||||
put_and_reset_width(it, iosb, fill, val);
|
||||
return it;
|
||||
}
|
||||
|
||||
private:
|
||||
template<class ValType> void put_and_reset_width(
|
||||
OutputIterator& it, std::ios_base& iosb,
|
||||
CharType fill, ValType val) const
|
||||
{
|
||||
put_impl(it, iosb, fill, val);
|
||||
iosb.width(0);
|
||||
}
|
||||
|
||||
template<class ValType> void put_impl(
|
||||
OutputIterator& it, std::ios_base& iosb,
|
||||
CharType fill, ValType val) const
|
||||
{
|
||||
static const CharType prefix_plus[2] = { '+', '\0' };
|
||||
static const CharType prefix_minus[2] = { '-', '\0' };
|
||||
static const CharType body_inf[4] = { 'i', 'n', 'f', '\0' };
|
||||
static const CharType body_nan[4] = { 'n', 'a', 'n', '\0' };
|
||||
static const CharType* null_string = 0;
|
||||
|
||||
switch((boost::math::fpclassify)(val))
|
||||
{
|
||||
|
||||
case FP_INFINITE:
|
||||
if(flags_ & trap_infinity)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(std::ios_base::failure("Infinity"));
|
||||
}
|
||||
else if((boost::math::signbit)(val))
|
||||
{ // negative infinity.
|
||||
put_num_and_fill(it, iosb, prefix_minus, body_inf, fill, val);
|
||||
}
|
||||
else if(iosb.flags() & std::ios_base::showpos)
|
||||
{ // Explicit "+inf" wanted.
|
||||
put_num_and_fill(it, iosb, prefix_plus, body_inf, fill, val);
|
||||
}
|
||||
else
|
||||
{ // just "inf" wanted.
|
||||
put_num_and_fill(it, iosb, null_string, body_inf, fill, val);
|
||||
}
|
||||
break;
|
||||
|
||||
case FP_NAN:
|
||||
if(flags_ & trap_nan)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(std::ios_base::failure("NaN"));
|
||||
}
|
||||
else if((boost::math::signbit)(val))
|
||||
{ // negative so "-nan".
|
||||
put_num_and_fill(it, iosb, prefix_minus, body_nan, fill, val);
|
||||
}
|
||||
else if(iosb.flags() & std::ios_base::showpos)
|
||||
{ // explicit "+nan" wanted.
|
||||
put_num_and_fill(it, iosb, prefix_plus, body_nan, fill, val);
|
||||
}
|
||||
else
|
||||
{ // Just "nan".
|
||||
put_num_and_fill(it, iosb, null_string, body_nan, fill, val);
|
||||
}
|
||||
break;
|
||||
|
||||
case FP_ZERO:
|
||||
if((flags_ & signed_zero) && ((boost::math::signbit)(val)))
|
||||
{ // Flag set to distinguish between positive and negative zero.
|
||||
// But string "0" should have stuff after decimal point if setprecision and/or exp format.
|
||||
|
||||
std::basic_ostringstream<CharType> zeros; // Needs to be CharType version.
|
||||
|
||||
// Copy flags, fill, width and precision.
|
||||
zeros.flags(iosb.flags());
|
||||
zeros.unsetf(std::ios::showpos); // Ignore showpos because must be negative.
|
||||
zeros.precision(iosb.precision());
|
||||
//zeros.width is set by put_num_and_fill
|
||||
zeros.fill(static_cast<char>(fill));
|
||||
zeros << ValType(0);
|
||||
put_num_and_fill(it, iosb, prefix_minus, zeros.str().c_str(), fill, val);
|
||||
}
|
||||
else
|
||||
{ // Output the platform default for positive and negative zero.
|
||||
put_num_and_fill(it, iosb, null_string, null_string, fill, val);
|
||||
}
|
||||
break;
|
||||
|
||||
default: // Normal non-zero finite value.
|
||||
it = std::num_put<CharType, OutputIterator>::do_put(it, iosb, fill, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<class ValType>
|
||||
void put_num_and_fill(
|
||||
OutputIterator& it, std::ios_base& iosb, const CharType* prefix,
|
||||
const CharType* body, CharType fill, ValType val) const
|
||||
{
|
||||
int prefix_length = prefix ? (int)std::char_traits<CharType>::length(prefix) : 0;
|
||||
int body_length = body ? (int)std::char_traits<CharType>::length(body) : 0;
|
||||
int width = prefix_length + body_length;
|
||||
std::ios_base::fmtflags adjust = iosb.flags() & std::ios_base::adjustfield;
|
||||
const std::ctype<CharType>& ct
|
||||
= std::use_facet<std::ctype<CharType> >(iosb.getloc());
|
||||
|
||||
if(body || prefix)
|
||||
{ // adjust == std::ios_base::right, so leading fill needed.
|
||||
if(adjust != std::ios_base::internal && adjust != std::ios_base::left)
|
||||
put_fill(it, iosb, fill, width);
|
||||
}
|
||||
|
||||
if(prefix)
|
||||
{ // Adjust width for prefix.
|
||||
while(*prefix)
|
||||
*it = *(prefix++);
|
||||
iosb.width( iosb.width() - prefix_length );
|
||||
width -= prefix_length;
|
||||
}
|
||||
|
||||
if(body)
|
||||
{ //
|
||||
if(adjust == std::ios_base::internal)
|
||||
{ // Put fill between sign and digits.
|
||||
put_fill(it, iosb, fill, width);
|
||||
}
|
||||
if(iosb.flags() & std::ios_base::uppercase)
|
||||
{
|
||||
while(*body)
|
||||
*it = ct.toupper(*(body++));
|
||||
}
|
||||
else
|
||||
{
|
||||
while(*body)
|
||||
*it = *(body++);
|
||||
}
|
||||
|
||||
if(adjust == std::ios_base::left)
|
||||
put_fill(it, iosb, fill, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
it = std::num_put<CharType, OutputIterator>::do_put(it, iosb, fill, val);
|
||||
}
|
||||
}
|
||||
|
||||
void put_fill(
|
||||
OutputIterator& it, std::ios_base& iosb, CharType fill, int width) const
|
||||
{ // Insert fill chars.
|
||||
for(std::streamsize i = iosb.width() - static_cast<std::streamsize>(width); i > 0; --i)
|
||||
*it = fill;
|
||||
}
|
||||
|
||||
private:
|
||||
const int flags_;
|
||||
};
|
||||
|
||||
|
||||
// class nonfinite_num_get ------------------------------------------------------
|
||||
|
||||
template<
|
||||
class CharType,
|
||||
class InputIterator = std::istreambuf_iterator<CharType>
|
||||
>
|
||||
class nonfinite_num_get : public std::num_get<CharType, InputIterator>
|
||||
{
|
||||
|
||||
public:
|
||||
explicit nonfinite_num_get(int flags = 0) : flags_(flags)
|
||||
{}
|
||||
|
||||
protected: // float, double and long double versions of do_get.
|
||||
virtual InputIterator do_get(
|
||||
InputIterator it, InputIterator end, std::ios_base& iosb,
|
||||
std::ios_base::iostate& state, float& val) const
|
||||
{
|
||||
get_and_check_eof(it, end, iosb, state, val);
|
||||
return it;
|
||||
}
|
||||
|
||||
virtual InputIterator do_get(
|
||||
InputIterator it, InputIterator end, std::ios_base& iosb,
|
||||
std::ios_base::iostate& state, double& val) const
|
||||
{
|
||||
get_and_check_eof(it, end, iosb, state, val);
|
||||
return it;
|
||||
}
|
||||
|
||||
virtual InputIterator do_get(
|
||||
InputIterator it, InputIterator end, std::ios_base& iosb,
|
||||
std::ios_base::iostate& state, long double& val) const
|
||||
{
|
||||
get_and_check_eof(it, end, iosb, state, val);
|
||||
return it;
|
||||
}
|
||||
|
||||
//..............................................................................
|
||||
|
||||
private:
|
||||
template<class ValType> static ValType positive_nan()
|
||||
{
|
||||
// On some platforms quiet_NaN() may be negative.
|
||||
return (boost::math::copysign)(
|
||||
std::numeric_limits<ValType>::quiet_NaN(), static_cast<ValType>(1)
|
||||
);
|
||||
// static_cast<ValType>(1) added Paul A. Bristow 5 Apr 11
|
||||
}
|
||||
|
||||
template<class ValType> void get_and_check_eof
|
||||
(
|
||||
InputIterator& it, InputIterator end, std::ios_base& iosb,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
get_signed(it, end, iosb, state, val);
|
||||
if(it == end)
|
||||
state |= std::ios_base::eofbit;
|
||||
}
|
||||
|
||||
template<class ValType> void get_signed
|
||||
(
|
||||
InputIterator& it, InputIterator end, std::ios_base& iosb,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
const std::ctype<CharType>& ct
|
||||
= std::use_facet<std::ctype<CharType> >(iosb.getloc());
|
||||
|
||||
char c = peek_char(it, end, ct);
|
||||
|
||||
bool negative = (c == '-');
|
||||
|
||||
if(negative || c == '+')
|
||||
{
|
||||
++it;
|
||||
c = peek_char(it, end, ct);
|
||||
if(c == '-' || c == '+')
|
||||
{ // Without this check, "++5" etc would be accepted.
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
get_unsigned(it, end, iosb, ct, state, val);
|
||||
|
||||
if(negative)
|
||||
{
|
||||
val = (boost::math::changesign)(val);
|
||||
}
|
||||
} // void get_signed
|
||||
|
||||
template<class ValType> void get_unsigned
|
||||
( //! Get an unsigned floating-point value into val,
|
||||
//! but checking for letters indicating non-finites.
|
||||
InputIterator& it, InputIterator end, std::ios_base& iosb,
|
||||
const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
switch(peek_char(it, end, ct))
|
||||
{
|
||||
case 'i':
|
||||
get_i(it, end, ct, state, val);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
get_n(it, end, ct, state, val);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case 's':
|
||||
get_q(it, end, ct, state, val);
|
||||
break;
|
||||
|
||||
default: // Got a normal floating-point value into val.
|
||||
it = std::num_get<CharType, InputIterator>::do_get(
|
||||
it, end, iosb, state, val);
|
||||
if((flags_ & legacy) && val == static_cast<ValType>(1)
|
||||
&& peek_char(it, end, ct) == '#')
|
||||
get_one_hash(it, end, ct, state, val);
|
||||
break;
|
||||
}
|
||||
} // get_unsigned
|
||||
|
||||
//..........................................................................
|
||||
|
||||
template<class ValType> void get_i
|
||||
( // Get the rest of all strings starting with 'i', expect "inf", "infinity".
|
||||
InputIterator& it, InputIterator end, const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
if(!std::numeric_limits<ValType>::has_infinity
|
||||
|| (flags_ & trap_infinity))
|
||||
{
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
++it;
|
||||
if(!match_string(it, end, ct, "nf"))
|
||||
{
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
if(peek_char(it, end, ct) != 'i')
|
||||
{
|
||||
val = std::numeric_limits<ValType>::infinity(); // "inf"
|
||||
return;
|
||||
}
|
||||
|
||||
++it;
|
||||
if(!match_string(it, end, ct, "nity"))
|
||||
{ // Expected "infinity"
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
val = std::numeric_limits<ValType>::infinity(); // "infinity"
|
||||
} // void get_i
|
||||
|
||||
template<class ValType> void get_n
|
||||
( // Get expected strings after 'n', "nan", "nanq", "nans", "nan(...)"
|
||||
InputIterator& it, InputIterator end, const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
if(!std::numeric_limits<ValType>::has_quiet_NaN
|
||||
|| (flags_ & trap_nan)) {
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
++it;
|
||||
if(!match_string(it, end, ct, "an"))
|
||||
{
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
switch(peek_char(it, end, ct)) {
|
||||
case 'q':
|
||||
case 's':
|
||||
if(flags_ && legacy)
|
||||
++it;
|
||||
break; // "nanq", "nans"
|
||||
|
||||
case '(': // Optional payload field in (...) follows.
|
||||
{
|
||||
++it;
|
||||
char c;
|
||||
while((c = peek_char(it, end, ct))
|
||||
&& c != ')' && c != ' ' && c != '\n' && c != '\t')
|
||||
++it;
|
||||
if(c != ')')
|
||||
{ // Optional payload field terminator missing!
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
++it;
|
||||
break; // "nan(...)"
|
||||
}
|
||||
|
||||
default:
|
||||
break; // "nan"
|
||||
}
|
||||
|
||||
val = positive_nan<ValType>();
|
||||
} // void get_n
|
||||
|
||||
template<class ValType> void get_q
|
||||
( // Get expected rest of string starting with 'q': "qnan".
|
||||
InputIterator& it, InputIterator end, const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
if(!std::numeric_limits<ValType>::has_quiet_NaN
|
||||
|| (flags_ & trap_nan) || !(flags_ & legacy))
|
||||
{
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
++it;
|
||||
if(!match_string(it, end, ct, "nan"))
|
||||
{
|
||||
state |= std::ios_base::failbit;
|
||||
return;
|
||||
}
|
||||
|
||||
val = positive_nan<ValType>(); // "QNAN"
|
||||
} // void get_q
|
||||
|
||||
template<class ValType> void get_one_hash
|
||||
( // Get expected string after having read "1.#": "1.#IND", "1.#QNAN", "1.#SNAN".
|
||||
InputIterator& it, InputIterator end, const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
|
||||
++it;
|
||||
switch(peek_char(it, end, ct))
|
||||
{
|
||||
case 'i': // from IND (indeterminate), considered same a QNAN.
|
||||
get_one_hash_i(it, end, ct, state, val); // "1.#IND"
|
||||
return;
|
||||
|
||||
case 'q': // from QNAN
|
||||
case 's': // from SNAN - treated the same as QNAN.
|
||||
if(std::numeric_limits<ValType>::has_quiet_NaN
|
||||
&& !(flags_ & trap_nan))
|
||||
{
|
||||
++it;
|
||||
if(match_string(it, end, ct, "nan"))
|
||||
{ // "1.#QNAN", "1.#SNAN"
|
||||
// ++it; // removed as caused assert() cannot increment iterator).
|
||||
// (match_string consumes string, so not needed?).
|
||||
// https://svn.boost.org/trac/boost/ticket/5467
|
||||
// Change in nonfinite_num_facet.hpp Paul A. Bristow 11 Apr 11 makes legacy_test.cpp work OK.
|
||||
val = positive_nan<ValType>(); // "1.#QNAN"
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
state |= std::ios_base::failbit;
|
||||
} // void get_one_hash
|
||||
|
||||
template<class ValType> void get_one_hash_i
|
||||
( // Get expected strings after 'i', "1.#INF", 1.#IND".
|
||||
InputIterator& it, InputIterator end, const std::ctype<CharType>& ct,
|
||||
std::ios_base::iostate& state, ValType& val
|
||||
) const
|
||||
{
|
||||
++it;
|
||||
|
||||
if(peek_char(it, end, ct) == 'n')
|
||||
{
|
||||
++it;
|
||||
switch(peek_char(it, end, ct))
|
||||
{
|
||||
case 'f': // "1.#INF"
|
||||
if(std::numeric_limits<ValType>::has_infinity
|
||||
&& !(flags_ & trap_infinity))
|
||||
{
|
||||
++it;
|
||||
val = std::numeric_limits<ValType>::infinity();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd': // 1.#IND"
|
||||
if(std::numeric_limits<ValType>::has_quiet_NaN
|
||||
&& !(flags_ & trap_nan))
|
||||
{
|
||||
++it;
|
||||
val = positive_nan<ValType>();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
state |= std::ios_base::failbit;
|
||||
} // void get_one_hash_i
|
||||
|
||||
//..........................................................................
|
||||
|
||||
char peek_char
|
||||
( //! \return next char in the input buffer, ensuring lowercase (but do not 'consume' char).
|
||||
InputIterator& it, InputIterator end,
|
||||
const std::ctype<CharType>& ct
|
||||
) const
|
||||
{
|
||||
if(it == end) return 0;
|
||||
return ct.narrow(ct.tolower(*it), 0); // Always tolower to ensure case insensitive.
|
||||
}
|
||||
|
||||
bool match_string
|
||||
( //! Match remaining chars to expected string (case insensitive),
|
||||
//! consuming chars that match OK.
|
||||
//! \return true if matched expected string, else false.
|
||||
InputIterator& it, InputIterator end,
|
||||
const std::ctype<CharType>& ct,
|
||||
const char* s
|
||||
) const
|
||||
{
|
||||
while(it != end && *s && *s == ct.narrow(ct.tolower(*it), 0))
|
||||
{
|
||||
++s;
|
||||
++it; //
|
||||
}
|
||||
return !*s;
|
||||
} // bool match_string
|
||||
|
||||
private:
|
||||
const int flags_;
|
||||
}; //
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MATH_NONFINITE_NUM_FACETS_HPP
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright Rene Rivera 2008-2015
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_PREDEF_COMPILER_COMPAQ_H
|
||||
#define BOOST_PREDEF_COMPILER_COMPAQ_H
|
||||
|
||||
#include <boost/predef/version_number.h>
|
||||
#include <boost/predef/make.h>
|
||||
|
||||
/*`
|
||||
[heading `BOOST_COMP_DEC`]
|
||||
|
||||
[@http://www.openvms.compaq.com/openvms/brochures/deccplus/ Compaq C/C++] compiler.
|
||||
Version number available as major, minor, and patch.
|
||||
|
||||
[table
|
||||
[[__predef_symbol__] [__predef_version__]]
|
||||
|
||||
[[`__DECCXX`] [__predef_detection__]]
|
||||
[[`__DECC`] [__predef_detection__]]
|
||||
|
||||
[[`__DECCXX_VER`] [V.R.P]]
|
||||
[[`__DECC_VER`] [V.R.P]]
|
||||
]
|
||||
*/
|
||||
|
||||
#define BOOST_COMP_DEC BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||
|
||||
#if defined(__DECC) || defined(__DECCXX)
|
||||
# if !defined(BOOST_COMP_DEC_DETECTION) && defined(__DECCXX_VER)
|
||||
# define BOOST_COMP_DEC_DETECTION BOOST_PREDEF_MAKE_10_VVRR0PP00(__DECCXX_VER)
|
||||
# endif
|
||||
# if !defined(BOOST_COMP_DEC_DETECTION) && defined(__DECC_VER)
|
||||
# define BOOST_COMP_DEC_DETECTION BOOST_PREDEF_MAKE_10_VVRR0PP00(__DECC_VER)
|
||||
# endif
|
||||
# if !defined(BOOST_COMP_DEC_DETECTION)
|
||||
# define BOOST_COM_DEC_DETECTION BOOST_VERSION_NUMBER_AVAILABLE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_COMP_DEC_DETECTION
|
||||
# if defined(BOOST_PREDEF_DETAIL_COMP_DETECTED)
|
||||
# define BOOST_COMP_DEC_EMULATED BOOST_COMP_DEC_DETECTION
|
||||
# else
|
||||
# undef BOOST_COMP_DEC
|
||||
# define BOOST_COMP_DEC BOOST_COMP_DEC_DETECTION
|
||||
# endif
|
||||
# define BOOST_COMP_DEC_AVAILABLE
|
||||
# include <boost/predef/detail/comp_detected.h>
|
||||
#endif
|
||||
|
||||
#define BOOST_COMP_DEC_NAME "Compaq C/C++"
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_DEC,BOOST_COMP_DEC_NAME)
|
||||
|
||||
#ifdef BOOST_COMP_DEC_EMULATED
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_DEC_EMULATED,BOOST_COMP_DEC_NAME)
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2004 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Authors: Douglas Gregor
|
||||
// Andrew Lumsdaine
|
||||
|
||||
// File moved
|
||||
#include <boost/property_map/parallel/process_group.hpp>
|
||||
@@ -0,0 +1,99 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Jaap Suter 2003
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// *Preprocessed* version of the main "shift_left.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Tag1
|
||||
, typename Tag2
|
||||
>
|
||||
struct shift_left_impl
|
||||
: if_c<
|
||||
( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
|
||||
> BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
|
||||
)
|
||||
|
||||
, aux::cast2nd_impl< shift_left_impl< Tag1,Tag1 >,Tag1, Tag2 >
|
||||
, aux::cast1st_impl< shift_left_impl< Tag2,Tag2 >,Tag1, Tag2 >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
/// for Digital Mars C++/compilers with no CTPS/TTP support
|
||||
template<> struct shift_left_impl< na,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct shift_left_impl< na,Tag >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct shift_left_impl< Tag,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct shift_left_tag
|
||||
{
|
||||
typedef typename T::tag type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(N1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N2)
|
||||
>
|
||||
struct shift_left
|
||||
|
||||
: shift_left_impl<
|
||||
typename shift_left_tag<N1>::type
|
||||
, typename shift_left_tag<N2>::type
|
||||
>::template apply< N1,N2 >::type
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, shift_left, (N1, N2))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(2, 2, shift_left)
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
template<>
|
||||
struct shift_left_impl< integral_c_tag,integral_c_tag >
|
||||
{
|
||||
template< typename N, typename S > struct apply
|
||||
|
||||
: integral_c<
|
||||
typename N::value_type
|
||||
, ( BOOST_MPL_AUX_VALUE_WKND(N)::value
|
||||
<< BOOST_MPL_AUX_VALUE_WKND(S)::value
|
||||
)
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,41 @@
|
||||
// -*- Mode: C++ -*-
|
||||
#ifndef DISPLAYTEXT_H
|
||||
#define DISPLAYTEXT_H
|
||||
|
||||
#include <QTextEdit>
|
||||
#include "logbook/logbook.h"
|
||||
#include "decodedtext.h"
|
||||
|
||||
|
||||
class DisplayText : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DisplayText(QWidget *parent = 0);
|
||||
|
||||
void setContentFont (QFont const&);
|
||||
void insertLineSpacer(QString const&);
|
||||
void displayDecodedText(DecodedText decodedText, QString myCall, bool displayDXCCEntity,
|
||||
LogBook logBook, QColor color_CQ, QColor color_MyCall,
|
||||
QColor color_DXCC, QColor color_NewCall);
|
||||
void displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
|
||||
QColor color_TxMsg, bool bFastMode);
|
||||
void displayQSY(QString text);
|
||||
|
||||
signals:
|
||||
void selectCallsign(bool shift, bool ctrl);
|
||||
|
||||
public slots:
|
||||
void appendText(QString const& text, QString const& bg = "white");
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
void _appendDXCCWorkedB4(/*mod*/DecodedText& t1, QString &bg, LogBook logBook,
|
||||
QColor color_CQ, QColor color_DXCC, QColor color_NewCall);
|
||||
|
||||
QTextCharFormat m_charFormat;
|
||||
};
|
||||
|
||||
#endif // DISPLAYTEXT_H
|
||||
Reference in New Issue
Block a user