Initial Commit

This commit is contained in:
Jordan Sherer
2018-02-08 21:28:33 -05:00
commit 678c1d3966
14352 changed files with 3176737 additions and 0 deletions
@@ -0,0 +1,23 @@
# if !defined(BOOST_PYTHON_SYNOPSIS)
# // Copyright David Abrahams 2002.
# // Distributed under the Boost Software License, Version 1.0. (See
# // accompanying file LICENSE_1_0.txt or copy at
# // http://www.boost.org/LICENSE_1_0.txt)
# if !defined(BOOST_PP_IS_ITERATING)
# error Boost.Python - do not include this file!
# endif
# define N BOOST_PP_ITERATION()
template <BOOST_PP_ENUM_PARAMS_Z(1, N, class A)>
typename detail::dependent<object, A0>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)) const
{
typedef typename detail::dependent<object, A0>::type obj;
U const& self = *static_cast<U const*>(this);
return call<obj>(get_managed_object(self, tag), BOOST_PP_ENUM_PARAMS_Z(1, N, a));
}
# undef N
# endif // BOOST_PYTHON_SYNOPSIS
@@ -0,0 +1,30 @@
// Copyright 2005 Daniel Wallin.
// Copyright 2005 Joel de Guzman.
// Copyright 2015 John Fletcher.
//
// 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)
//
// Modeled after range_ex, Copyright 2004 Eric Niebler
#ifndef BOOST_PHOENIX_ALGORITHM_DETAIL_END_HPP
#define BOOST_PHOENIX_ALGORITHM_DETAIL_END_HPP
//#include <boost/range/result_iterator.hpp> is deprecated
#include <boost/range/iterator.hpp>
#include <boost/range/end.hpp>
namespace boost { namespace phoenix {
namespace detail
{
template<class R>
typename range_iterator<R>::type
end_(R& r)
{
return boost::end(r);
}
}
}}
#endif
@@ -0,0 +1,219 @@
subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, &
btrain,datadir,nbiterrors,eyeopening,pcoeffs)
character*22 msg,msgsent
character*12 dxcall
character*12 training_dxcall
character*12 trained_dxcall
character*6 mygrid
character*512 pcoeff_filename
character*8 date
character*10 time
character*5 zone
character*512 datadir
complex cframe(864)
complex cross(864)
complex cross_avg(864)
complex canalytic(1024)
complex cmodel(1024)
integer i4tone(144)
integer hardbits(144)
integer msgbits(144)
integer values(8)
logical*1 bcontest
logical*1 btrain
logical*1 first
logical*1 currently_training
logical*1 msg_has_dxcall
logical*1 is_training_frame
real softbits(144)
real waveform(0:863)
real d(1024)
real phase(864)
real twopi,freq,phi,dphi0,dphi1,dphi
real*8 x(145),y(145),pp(145),sigmay(145),a(5),chisqr
real*8 pcoeffs(5)
parameter (NFREQLOW=500,NFREQHIGH=2500)
data first/.true./
save cross_avg,wt_avg,first,currently_training, &
navg,tlast,training_dxcall,trained_dxcall
if (first) then
navg=0
cross=cmplx(0.0,0.0)
cross_avg=cmplx(0.0,0.0)
wt_avg=0.0
tlast=0.0
trained_dxcall(1:12)=' '
training_dxcall(1:12)=' '
currently_training=.false.
first=.false.
endif
if( (currently_training .and. (dxcall .ne. training_dxcall)) .or. &
(navg .gt. 10 )) then !reset and retrain
navg=0
cross=cmplx(0.0,0.0)
cross_avg=cmplx(0.0,0.0)
wt_avg=0.0
tlast=0.0
trained_dxcall(1:12)=' '
currently_training=.false.
training_dxcall(1:12)=' '
trained_dxcall(1:12)=' '
!write(*,*) 'reset to untrained state '
endif
indx_dxcall=index(msg,trim(dxcall))
msg_has_dxcall = indx_dxcall .ge. 4
if( btrain .and. msg_has_dxcall .and. (.not. currently_training) ) then
currently_training=.true.
training_dxcall=trim(dxcall)
trained_dxcall(1:12)=' '
!write(*,*) 'start training on call ',training_dxcall
endif
if( msg_has_dxcall .and. currently_training ) then
trained_dxcall(1:12)=' '
training_dxcall=dxcall
endif
! use decoded message to figure out how many bit errors in the frame
do i=1, 144
hardbits(i)=0
if(softbits(i) .gt. 0 ) hardbits(i)=1
enddo
! generate tones from decoded message
mygrid="EN50"
ichk=0
bcontest=.false.
call genmsk144(msg,mygrid,ichk,bcontest,msgsent,i4tone,itype)
! reconstruct message bits from tones
msgbits(1)=0
do i=1,143
if( i4tone(i) .eq. 0 ) then
if( mod(i,2) .eq. 1 ) then
msgbits(i+1)=msgbits(i)
else
msgbits(i+1)=mod(msgbits(i)+1,2)
endif
else
if( mod(i,2) .eq. 1 ) then
msgbits(i+1)=mod(msgbits(i)+1,2)
else
msgbits(i+1)=msgbits(i)
endif
endif
enddo
nbiterrors=0
do i=1,144
if( hardbits(i) .ne. msgbits(i) ) nbiterrors=nbiterrors+1
enddo
nplus=0
nminus=0
eyetop=1
eyebot=-1
do i=1,144
if( msgbits(i) .eq. 1 ) then
if( softbits(i) .lt. eyetop ) eyetop=softbits(i)
else
if( softbits(i) .gt. eyebot ) eyebot=softbits(i)
endif
enddo
eyeopening=eyetop-eyebot
is_training_frame = &
(snr.gt.5.0 .and.(nbiterrors.lt.7)) .and. &
(abs(t0-tlast) .gt. 0.072) .and. &
msg_has_dxcall
if( currently_training .and. is_training_frame ) then
twopi=8.0*atan(1.0)
nsym=144
if( i4tone(41) .lt. 0 ) nsym=40
dphi0=twopi*(freq-500)/12000.0
dphi1=twopi*(freq+500)/12000.0
phi=-twopi/8
indx=0
do i=1,nsym
if( i4tone(i) .eq. 0 ) then
dphi=dphi0
else
dphi=dphi1
endif
do j=1,6
waveform(indx)=cos(phi);
indx=indx+1
phi=mod(phi+dphi,twopi)
enddo
enddo
! convert the passband waveform to complex baseband
npts=864
nfft=1024
d=0
d(1:864)=waveform(0:863)
call analytic(d,npts,nfft,canalytic,pcoeffs,.false.) ! don't equalize the model
call tweak1(canalytic,nfft,-freq,cmodel)
call four2a(cframe(1:864),864,1,-1,1)
call four2a(cmodel(1:864),864,1,-1,1)
! Cross spectra from different messages can be averaged
! as long as all messages originate from dxcall.
cross=cmodel(1:864)*conjg(cframe)/1000.0
cross=cshift(cross,864/2)
cross_avg=cross_avg+10**(snr/20.0)*cross
wt_avg=wt_avg+10**(snr/20.0)
navg=navg+1
tlast=t0
phase=atan2(imag(cross_avg),real(cross_avg))
df=12000.0/864.0
nm=145
do i=1,145
x(i)=(i-73)*df/1000.0
enddo
y=phase((864/2-nm/2):(864/2+nm/2))
sigmay=wt_avg/abs(cross_avg((864/2-nm/2):(864/2+nm/2)))
mode=1
npts=145
nterms=5
call polyfit(x,y,sigmay,npts,nterms,mode,a,chisqr)
pp=a(1)+x*(a(2)+x*(a(3)+x*(a(4)+x*a(5))))
rmsdiff=sum( (pp-phase((864/2-nm/2):(864/2+nm/2)))**2 )/145.0
!write(*,*) 'training ',navg,sqrt(chisqr),rmsdiff
if( (sqrt(chisqr).lt.1.8) .and. (rmsdiff.lt.0.5) .and. (navg.ge.5) ) then
trained_dxcall=dxcall
call date_and_time(date,time,zone,values)
write(pcoeff_filename,'(i2.2,i2.2,i2.2,"_",i2.2,i2.2,i2.2)') &
values(1)-2000,values(2),values(3),values(5),values(6),values(7)
pcoeff_filename=trim(trained_dxcall)//"_"//trim(pcoeff_filename)//".pcoeff"
l1=index(datadir,char(0))-1
datadir(l1+1:l1+1)="/"
pcoeff_filename=datadir(1:l1+1)//trim(pcoeff_filename)
!write(*,*) 'trained - writing coefficients to: ',pcoeff_filename
open(17,file=pcoeff_filename,status='new')
write(17,'(i4,2f10.2,3i5,5e25.16)') navg,sqrt(chisqr),rmsdiff,NFREQLOW,NFREQHIGH,nterms,a
do i=1, 145
write(17,*) x(i),pp(i),y(i),sigmay(i)
enddo
do i=1,864
write(17,*) i,real(cframe(i)),imag(cframe(i)),real(cross_avg(i)),imag(cross_avg(i))
enddo
close(17)
training_dxcall(1:12)=' '
currently_training=.false.
btrain=.false.
navg=0
endif
endif
return
end subroutine msk144signalquality
@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007-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_TREE_NODE_HPP
#define BOOST_INTRUSIVE_TREE_NODE_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/detail/workaround.hpp>
#include <boost/intrusive/pointer_rebind.hpp>
namespace boost {
namespace intrusive {
template<class VoidPointer>
struct tree_node
{
typedef typename pointer_rebind<VoidPointer, tree_node>::type node_ptr;
node_ptr parent_, left_, right_;
};
template<class VoidPointer>
struct tree_node_traits
{
typedef tree_node<VoidPointer> node;
typedef typename node::node_ptr node_ptr;
typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const const_node_ptr & n)
{ return n->parent_; }
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_parent(const node_ptr & n)
{ return n->parent_; }
BOOST_INTRUSIVE_FORCEINLINE static void set_parent(const node_ptr & n, const node_ptr & p)
{ n->parent_ = p; }
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const const_node_ptr & n)
{ return n->left_; }
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_left(const node_ptr & n)
{ return n->left_; }
BOOST_INTRUSIVE_FORCEINLINE static void set_left(const node_ptr & n, const node_ptr & l)
{ n->left_ = l; }
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const const_node_ptr & n)
{ return n->right_; }
BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_right(const node_ptr & n)
{ return n->right_; }
BOOST_INTRUSIVE_FORCEINLINE static void set_right(const node_ptr & n, const node_ptr & r)
{ n->right_ = r; }
};
} //namespace intrusive
} //namespace boost
#include <boost/intrusive/detail/config_end.hpp>
#endif //BOOST_INTRUSIVE_TREE_NODE_HPP
@@ -0,0 +1,28 @@
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 2012. *
# * Distributed under the Boost Software License, Version 1.0. (See *
# * accompanying file LICENSE_1_0.txt or copy at *
# * http://www.boost.org/LICENSE_1_0.txt) *
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_SEQ_VARIADIC_SEQ_TO_SEQ_HPP
# define BOOST_PREPROCESSOR_SEQ_VARIADIC_SEQ_TO_SEQ_HPP
#
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/config/config.hpp>
#
# /* BOOST_PP_VARIADIC_SEQ_TO_SEQ */
#
# if BOOST_PP_VARIADICS
# define BOOST_PP_VARIADIC_SEQ_TO_SEQ(vseq) BOOST_PP_CAT(BOOST_PP_VARIADIC_SEQ_TO_SEQ_A vseq, 0)
# define BOOST_PP_VARIADIC_SEQ_TO_SEQ_A(...) ((__VA_ARGS__)) BOOST_PP_VARIADIC_SEQ_TO_SEQ_B
# define BOOST_PP_VARIADIC_SEQ_TO_SEQ_B(...) ((__VA_ARGS__)) BOOST_PP_VARIADIC_SEQ_TO_SEQ_A
# define BOOST_PP_VARIADIC_SEQ_TO_SEQ_A0
# define BOOST_PP_VARIADIC_SEQ_TO_SEQ_B0
# endif
#
# endif
@@ -0,0 +1,68 @@
// Copyright 2002 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)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef COPY_ARRAY_RG092101_HPP
#define COPY_ARRAY_RG092101_HPP
//
// copy_array.hpp - generic code for copying the contents of one
// Basic_MultiArray to another. We assume that they are of the same
// shape
//
#include "boost/type.hpp"
#include "boost/assert.hpp"
namespace boost {
namespace detail {
namespace multi_array {
template <typename Element>
class copy_dispatch {
public:
template <typename SourceIterator, typename DestIterator>
static void copy_array (SourceIterator first, SourceIterator last,
DestIterator result) {
while (first != last) {
copy_array(*first++,*result++);
}
}
private:
// Array2 has to be passed by VALUE here because subarray
// pseudo-references are temporaries created by iterator::operator*()
template <typename Array1, typename Array2>
static void copy_array (const Array1& source, Array2 dest) {
copy_array(source.begin(),source.end(),dest.begin());
}
static void copy_array (const Element& source, Element& dest) {
dest = source;
}
};
template <typename Array1, typename Array2>
void copy_array (Array1& source, Array2& dest) {
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
dest.shape()));
// Dispatch to the proper function
typedef typename Array1::element element_type;
copy_dispatch<element_type>::
copy_array(source.begin(),source.end(),dest.begin());
}
} // namespace multi_array
} // namespace detail
} // namespace boost
#endif // COPY_ARRAY_RG092101_HPP
@@ -0,0 +1,150 @@
// (C) Copyright John Maddock 2000.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
// See boost/type_traits/*.hpp for full copyright notices.
#ifndef BOOST_TYPE_TRAITS_HPP
#define BOOST_TYPE_TRAITS_HPP
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_cv.hpp>
#include <boost/type_traits/add_lvalue_reference.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_rvalue_reference.hpp>
#include <boost/type_traits/add_volatile.hpp>
#include <boost/type_traits/aligned_storage.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/common_type.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/copy_cv.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/extent.hpp>
#include <boost/type_traits/floating_point_promotion.hpp>
#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/has_bit_and.hpp>
#include <boost/type_traits/has_bit_and_assign.hpp>
#include <boost/type_traits/has_bit_or.hpp>
#include <boost/type_traits/has_bit_or_assign.hpp>
#include <boost/type_traits/has_bit_xor.hpp>
#include <boost/type_traits/has_bit_xor_assign.hpp>
#include <boost/type_traits/has_complement.hpp>
#include <boost/type_traits/has_dereference.hpp>
#include <boost/type_traits/has_divides.hpp>
#include <boost/type_traits/has_divides_assign.hpp>
#include <boost/type_traits/has_equal_to.hpp>
#include <boost/type_traits/has_greater.hpp>
#include <boost/type_traits/has_greater_equal.hpp>
#include <boost/type_traits/has_left_shift.hpp>
#include <boost/type_traits/has_left_shift_assign.hpp>
#include <boost/type_traits/has_less.hpp>
#include <boost/type_traits/has_less_equal.hpp>
#include <boost/type_traits/has_logical_and.hpp>
#include <boost/type_traits/has_logical_not.hpp>
#include <boost/type_traits/has_logical_or.hpp>
#include <boost/type_traits/has_minus.hpp>
#include <boost/type_traits/has_minus_assign.hpp>
#include <boost/type_traits/has_modulus.hpp>
#include <boost/type_traits/has_modulus_assign.hpp>
#include <boost/type_traits/has_multiplies.hpp>
#include <boost/type_traits/has_multiplies_assign.hpp>
#include <boost/type_traits/has_negate.hpp>
#if !defined(__BORLANDC__) && !defined(__CUDACC__)
#include <boost/type_traits/has_new_operator.hpp>
#endif
#include <boost/type_traits/has_not_equal_to.hpp>
#include <boost/type_traits/has_nothrow_assign.hpp>
#include <boost/type_traits/has_nothrow_constructor.hpp>
#include <boost/type_traits/has_nothrow_copy.hpp>
#include <boost/type_traits/has_nothrow_destructor.hpp>
#include <boost/type_traits/has_plus.hpp>
#include <boost/type_traits/has_plus_assign.hpp>
#include <boost/type_traits/has_post_decrement.hpp>
#include <boost/type_traits/has_post_increment.hpp>
#include <boost/type_traits/has_pre_decrement.hpp>
#include <boost/type_traits/has_pre_increment.hpp>
#include <boost/type_traits/has_right_shift.hpp>
#include <boost/type_traits/has_right_shift_assign.hpp>
#include <boost/type_traits/has_trivial_assign.hpp>
#include <boost/type_traits/has_trivial_constructor.hpp>
#include <boost/type_traits/has_trivial_copy.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/type_traits/has_trivial_move_assign.hpp>
#include <boost/type_traits/has_trivial_move_constructor.hpp>
#include <boost/type_traits/has_unary_minus.hpp>
#include <boost/type_traits/has_unary_plus.hpp>
#include <boost/type_traits/has_virtual_destructor.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_abstract.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_assignable.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_complex.hpp>
#include <boost/type_traits/is_compound.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_copy_assignable.hpp>
#include <boost/type_traits/is_copy_constructible.hpp>
#include <boost/type_traits/is_default_constructible.hpp>
#include <boost/type_traits/is_destructible.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_final.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/is_member_object_pointer.hpp>
#include <boost/type_traits/is_member_pointer.hpp>
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
#include <boost/type_traits/is_object.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_polymorphic.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_rvalue_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_scalar.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_stateless.hpp>
#include <boost/type_traits/is_union.hpp>
#include <boost/type_traits/is_unsigned.hpp>
#include <boost/type_traits/is_virtual_base_of.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/make_signed.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/type_traits/rank.hpp>
#include <boost/type_traits/remove_all_extents.hpp>
#include <boost/type_traits/remove_bounds.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_volatile.hpp>
#include <boost/type_traits/type_identity.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#if !(defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238))
#include <boost/type_traits/integral_promotion.hpp>
#include <boost/type_traits/promote.hpp>
#endif
#endif // BOOST_TYPE_TRAITS_HPP
@@ -0,0 +1,28 @@
#ifndef BOOST_MPL_AUX_CONFIG_BCC_HPP_INCLUDED
#define BOOST_MPL_AUX_CONFIG_BCC_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2008
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date: 2004-09-02 10:41:37 -0500 (Thu, 02 Sep 2004) $
// $Revision: 24874 $
#include <boost/mpl/aux_/config/workaround.hpp>
#if !defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE) \
&& BOOST_WORKAROUND(__BORLANDC__, >= 0x590) \
&& BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610))
# define BOOST_MPL_CFG_BCC590_WORKAROUNDS
#endif
#endif // BOOST_MPL_AUX_CONFIG_BCC_HPP_INCLUDED
@@ -0,0 +1,318 @@
///////////////////////////////////////////////////////////////
// Copyright 2013 John Maddock. 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_
//
// Generic routines for converting floating point values to and from decimal strings.
// Note that these use "naive" algorithms which result in rounding error - so they
// do not round trip to and from the string representation (but should only be out
// in the last bit).
//
#ifndef BOOST_MP_FLOAT_STRING_CVT_HPP
#define BOOST_MP_FLOAT_STRING_CVT_HPP
#include <cctype>
namespace boost{ namespace multiprecision{ namespace detail{
template <class I>
inline void round_string_up_at(std::string& s, int pos, I& expon)
{
//
// Rounds up a string representation of a number at pos:
//
if(pos < 0)
{
s.insert(static_cast<std::string::size_type>(0), 1, '1');
s.erase(s.size() - 1);
++expon;
}
else if(s[pos] == '9')
{
s[pos] = '0';
round_string_up_at(s, pos - 1, expon);
}
else
{
if((pos == 0) && (s[pos] == '0') && (s.size() == 1))
++expon;
++s[pos];
}
}
template <class Backend>
std::string convert_to_string(Backend b, std::streamsize digits, std::ios_base::fmtflags f)
{
using default_ops::eval_log10;
using default_ops::eval_floor;
using default_ops::eval_pow;
using default_ops::eval_convert_to;
using default_ops::eval_multiply;
using default_ops::eval_divide;
using default_ops::eval_subtract;
using default_ops::eval_fpclassify;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type;
typedef typename Backend::exponent_type exponent_type;
std::string result;
bool iszero = false;
bool isneg = false;
exponent_type expon = 0;
std::streamsize org_digits = digits;
BOOST_ASSERT(digits > 0);
int fpt = eval_fpclassify(b);
if(fpt == (int)FP_ZERO)
{
result = "0";
iszero = true;
}
else if(fpt == (int)FP_INFINITE)
{
if(b.compare(ui_type(0)) < 0)
return "-inf";
else
return ((f & std::ios_base::showpos) == std::ios_base::showpos) ? "+inf" : "inf";
}
else if(fpt == (int)FP_NAN)
{
return "nan";
}
else
{
//
// Start by figuring out the exponent:
//
isneg = b.compare(ui_type(0)) < 0;
if(isneg)
b.negate();
Backend t;
Backend ten;
ten = ui_type(10);
eval_log10(t, b);
eval_floor(t, t);
eval_convert_to(&expon, t);
if(-expon > std::numeric_limits<number<Backend> >::max_exponent10 - 3)
{
int e = -expon / 2;
Backend t2;
eval_pow(t2, ten, e);
eval_multiply(t, t2, b);
eval_multiply(t, t2);
if(expon & 1)
eval_multiply(t, ten);
}
else
{
eval_pow(t, ten, -expon);
eval_multiply(t, b);
}
//
// Make sure we're between [1,10) and adjust if not:
//
if(t.compare(ui_type(1)) < 0)
{
eval_multiply(t, ui_type(10));
--expon;
}
else if(t.compare(ui_type(10)) >= 0)
{
eval_divide(t, ui_type(10));
++expon;
}
Backend digit;
ui_type cdigit;
//
// Adjust the number of digits required based on formatting options:
//
if(((f & std::ios_base::fixed) == std::ios_base::fixed) && (expon != -1))
digits += expon + 1;
if((f & std::ios_base::scientific) == std::ios_base::scientific)
++digits;
//
// Extract the digits one at a time:
//
for(unsigned i = 0; i < digits; ++i)
{
eval_floor(digit, t);
eval_convert_to(&cdigit, digit);
result += static_cast<char>('0' + cdigit);
eval_subtract(t, digit);
eval_multiply(t, ten);
}
//
// Possibly round result:
//
if(digits >= 0)
{
eval_floor(digit, t);
eval_convert_to(&cdigit, digit);
eval_subtract(t, digit);
if((cdigit == 5) && (t.compare(ui_type(0)) == 0))
{
// Bankers rounding:
if((*result.rbegin() - '0') & 1)
{
round_string_up_at(result, result.size() - 1, expon);
}
}
else if(cdigit >= 5)
{
round_string_up_at(result, result.size() - 1, expon);
}
}
}
while((result.size() > digits) && result.size())
{
// We may get here as a result of rounding...
if(result.size() > 1)
result.erase(result.size() - 1);
else
{
if(expon > 0)
--expon; // so we put less padding in the result.
else
++expon;
++digits;
}
}
BOOST_ASSERT(org_digits >= 0);
if(isneg)
result.insert(static_cast<std::string::size_type>(0), 1, '-');
format_float_string(result, expon, org_digits, f, iszero);
return result;
}
template <class Backend>
void convert_from_string(Backend& b, const char* p)
{
using default_ops::eval_multiply;
using default_ops::eval_add;
using default_ops::eval_pow;
using default_ops::eval_divide;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type;
b = ui_type(0);
if(!p || (*p == 0))
return;
bool is_neg = false;
bool is_neg_expon = false;
static const ui_type ten = ui_type(10);
typename Backend::exponent_type expon = 0;
int digits_seen = 0;
typedef std::numeric_limits<number<Backend, et_off> > limits;
static const int max_digits = limits::is_specialized ? limits::max_digits10 + 1 : INT_MAX;
if(*p == '+') ++p;
else if(*p == '-')
{
is_neg = true;
++p;
}
if((std::strcmp(p, "nan") == 0) || (std::strcmp(p, "NaN") == 0) || (std::strcmp(p, "NAN") == 0))
{
eval_divide(b, ui_type(0));
if(is_neg)
b.negate();
return;
}
if((std::strcmp(p, "inf") == 0) || (std::strcmp(p, "Inf") == 0) || (std::strcmp(p, "INF") == 0))
{
b = ui_type(1);
eval_divide(b, ui_type(0));
if(is_neg)
b.negate();
return;
}
//
// Grab all the leading digits before the decimal point:
//
while(std::isdigit(*p))
{
eval_multiply(b, ten);
eval_add(b, ui_type(*p - '0'));
++p;
++digits_seen;
}
if(*p == '.')
{
//
// Grab everything after the point, stop when we've seen
// enough digits, even if there are actually more available:
//
++p;
while(std::isdigit(*p))
{
eval_multiply(b, ten);
eval_add(b, ui_type(*p - '0'));
++p;
--expon;
if(++digits_seen > max_digits)
break;
}
while(std::isdigit(*p))
++p;
}
//
// Parse the exponent:
//
if((*p == 'e') || (*p == 'E'))
{
++p;
if(*p == '+') ++p;
else if(*p == '-')
{
is_neg_expon = true;
++p;
}
typename Backend::exponent_type e2 = 0;
while(std::isdigit(*p))
{
e2 *= 10;
e2 += (*p - '0');
++p;
}
if(is_neg_expon)
e2 = -e2;
expon += e2;
}
if(expon)
{
// Scale by 10^expon, note that 10^expon can be
// outside the range of our number type, even though the
// result is within range, if that looks likely, then split
// the calculation in two:
Backend t;
t = ten;
if(expon > limits::min_exponent10 + 2)
{
eval_pow(t, t, expon);
eval_multiply(b, t);
}
else
{
eval_pow(t, t, expon + digits_seen + 1);
eval_multiply(b, t);
t = ten;
eval_pow(t, t, -digits_seen - 1);
eval_multiply(b, t);
}
}
if(is_neg)
b.negate();
if(*p)
{
// Unexpected input in string:
BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected characters in string being interpreted as a float128."));
}
}
}}} // namespaces
#endif
@@ -0,0 +1,30 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/length.hpp>
#include <boost/units/physical_dimensions/mass.hpp>
namespace boost {
namespace units {
/// derived dimension for mass density : L^-3 M
typedef derived_dimension<length_base_dimension,-3,
mass_base_dimension,1>::type mass_density_dimension;
} // namespace units
} // namespace boost
#endif // BOOST_UNITS_MASS_DENSITY_DERIVED_DIMENSION_HPP
@@ -0,0 +1,57 @@
/*=============================================================================
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_CONVERT_09232005_1340)
#define FUSION_CONVERT_09232005_1340
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/map/detail/cpp03/as_map.hpp>
#include <boost/fusion/container/map/detail/cpp03/convert_impl.hpp>
#include <boost/fusion/container/map/detail/cpp03/map.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence>
struct as_map
{
typedef typename
detail::as_map<
result_of::size<Sequence>::value
, is_base_of<
associative_tag
, typename traits::category_of<Sequence>::type>::value
>
gen;
typedef typename gen::
template apply<typename result_of::begin<Sequence>::type>::type
type;
};
}
template <typename Sequence>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::as_map<Sequence>::type
as_map(Sequence& seq)
{
typedef typename result_of::as_map<Sequence>::gen gen;
return gen::call(fusion::begin(seq));
}
template <typename Sequence>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::as_map<Sequence const>::type
as_map(Sequence const& seq)
{
typedef typename result_of::as_map<Sequence const>::gen gen;
return gen::call(fusion::begin(seq));
}
}}
#endif
@@ -0,0 +1,60 @@
// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
/// @file
/// @brief defines specific version of execution monitor used to managed run unit of test cases
///
/// Translates execution exception into error level
// ***************************************************************************
#ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
#define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
// Boost.Test
#include <boost/test/execution_monitor.hpp>
#include <boost/test/detail/fwd_decl.hpp>
#include <boost/test/utils/trivial_singleton.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
namespace boost {
namespace unit_test {
// ************************************************************************** //
// ************** unit_test_monitor ************** //
// ************************************************************************** //
class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor {
public:
enum error_level {
test_ok = 0,
precondition_failure = -1,
unexpected_exception = -2,
os_exception = -3,
os_timeout = -4,
fatal_error = -5 // includes both system and user
};
static bool is_critical_error( error_level e ) { return e <= fatal_error; }
// monitor method
error_level execute_and_translate( boost::function<void ()> const& func, unsigned timeout = 0 );
private:
BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t )
};
BOOST_TEST_SINGLETON_INST( unit_test_monitor )
} // namespace unit_test
} // namespace boost
#include <boost/test/detail/enable_warnings.hpp>
#endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
@@ -0,0 +1,169 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/n_step_time_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
The dereferenced type contains also the time.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the n_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class n_step_time_iterator : public n_step_iterator_impl<
n_step_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
n_step_time_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
{}
n_step_time_iterator( Stepper stepper , System sys , State &s )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
}
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< n_step_time_iterator< Stepper , System , State > , n_step_time_iterator< Stepper , System , State > >
make_n_step_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return std::make_pair(
n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
n_step_time_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class n_step_time_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE starting from t
* with n steps and a constant step size dt.
* After each iteration the iterator dereferences to a pair of state and time at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_n_steps routine.
*
* n_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is pair of state and time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_n_step_time_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function for n_step_time_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step iterator.
*/
/**
* \fn make_n_step_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for n_step_time_iterator. Constructs an end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The const_step_iterator.
*/
/**
* \fn make_n_step_time_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
* of n_step_time_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,46 @@
/*==============================================================================
Copyright (c) 2001-2010 Joel de Guzman
Copyright (c) 2010 Eric Niebler
Copyright (c) 2010-2011 Thomas Heller
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)
==============================================================================*/
#define BOOST_PHOENIX_ARGUMENT_N_TYPE(_, N, name) \
typedef \
expression::argument<BOOST_PP_INC(N)>::type \
BOOST_PP_CAT(BOOST_PP_CAT(name, BOOST_PP_INC(N)), _type) \
BOOST_ATTRIBUTE_UNUSED; \
/**/
#define BOOST_PHOENIX_ARGUMENT_N_INSTANCE(_, N, name) \
expression::argument<BOOST_PP_INC(N)>::type const \
BOOST_ATTRIBUTE_UNUSED \
BOOST_PP_CAT(name, BOOST_PP_INC(N)) = {{{}}}; \
/**/
namespace placeholders
{
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_TYPE, arg)
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_TYPE, _)
#ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_INSTANCE, arg)
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_INSTANCE, _)
#endif
}
namespace arg_names
{
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_TYPE, arg)
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_TYPE, _)
#ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_INSTANCE, arg)
BOOST_PP_REPEAT(BOOST_PHOENIX_ARG_LIMIT, BOOST_PHOENIX_ARGUMENT_N_INSTANCE, _)
#endif
}
#undef BOOST_PHOENIX_ARGUMENT_N_TYPE
#undef BOOST_PHOENIX_ARGUMENT_N_INSTANCE
@@ -0,0 +1,669 @@
//
// (C) Copyright Jeremy Siek 2000.
// 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)
//
// Revision History:
//
// 17 July 2001: Added const to some member functions. (Jeremy Siek)
// 05 May 2001: Removed static dummy_cons object. (Jeremy Siek)
// See http://www.boost.org/libs/concept_check for documentation.
#ifndef BOOST_CONCEPT_ARCHETYPES_HPP
#define BOOST_CONCEPT_ARCHETYPES_HPP
#include <boost/config.hpp>
#include <boost/iterator.hpp>
#include <boost/mpl/identity.hpp>
#include <functional>
namespace boost {
//===========================================================================
// Basic Archetype Classes
namespace detail {
class dummy_constructor { };
}
// A type that models no concept. The template parameter
// is only there so that null_archetype types can be created
// that have different type.
template <class T = int>
class null_archetype {
private:
null_archetype() { }
null_archetype(const null_archetype&) { }
null_archetype& operator=(const null_archetype&) { return *this; }
public:
null_archetype(detail::dummy_constructor) { }
#ifndef __MWERKS__
template <class TT>
friend void dummy_friend(); // just to avoid warnings
#endif
};
// This is a helper class that provides a way to get a reference to
// an object. The get() function will never be called at run-time
// (nothing in this file will) so this seemingly very bad function
// is really quite innocent. The name of this class needs to be
// changed.
template <class T>
class static_object
{
public:
static T& get()
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
return *reinterpret_cast<T*>(0);
#else
static char d[sizeof(T)];
return *reinterpret_cast<T*>(d);
#endif
}
};
template <class Base = null_archetype<> >
class default_constructible_archetype : public Base {
public:
default_constructible_archetype()
: Base(static_object<detail::dummy_constructor>::get()) { }
default_constructible_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base = null_archetype<> >
class assignable_archetype : public Base {
assignable_archetype() { }
assignable_archetype(const assignable_archetype&) { }
public:
assignable_archetype& operator=(const assignable_archetype&) {
return *this;
}
assignable_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base = null_archetype<> >
class copy_constructible_archetype : public Base {
public:
copy_constructible_archetype()
: Base(static_object<detail::dummy_constructor>::get()) { }
copy_constructible_archetype(const copy_constructible_archetype&)
: Base(static_object<detail::dummy_constructor>::get()) { }
copy_constructible_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base = null_archetype<> >
class sgi_assignable_archetype : public Base {
public:
sgi_assignable_archetype(const sgi_assignable_archetype&)
: Base(static_object<detail::dummy_constructor>::get()) { }
sgi_assignable_archetype& operator=(const sgi_assignable_archetype&) {
return *this;
}
sgi_assignable_archetype(const detail::dummy_constructor& x) : Base(x) { }
};
struct default_archetype_base {
default_archetype_base(detail::dummy_constructor) { }
};
// Careful, don't use same type for T and Base. That results in the
// conversion operator being invalid. Since T is often
// null_archetype, can't use null_archetype for Base.
template <class T, class Base = default_archetype_base>
class convertible_to_archetype : public Base {
private:
convertible_to_archetype() { }
convertible_to_archetype(const convertible_to_archetype& ) { }
convertible_to_archetype& operator=(const convertible_to_archetype&)
{ return *this; }
public:
convertible_to_archetype(detail::dummy_constructor x) : Base(x) { }
operator const T&() const { return static_object<T>::get(); }
};
template <class T, class Base = default_archetype_base>
class convertible_from_archetype : public Base {
private:
convertible_from_archetype() { }
convertible_from_archetype(const convertible_from_archetype& ) { }
convertible_from_archetype& operator=(const convertible_from_archetype&)
{ return *this; }
public:
convertible_from_archetype(detail::dummy_constructor x) : Base(x) { }
convertible_from_archetype(const T&) { }
convertible_from_archetype& operator=(const T&)
{ return *this; }
};
class boolean_archetype {
public:
boolean_archetype(const boolean_archetype&) { }
operator bool() const { return true; }
boolean_archetype(detail::dummy_constructor) { }
private:
boolean_archetype() { }
boolean_archetype& operator=(const boolean_archetype&) { return *this; }
};
template <class Base = null_archetype<> >
class equality_comparable_archetype : public Base {
public:
equality_comparable_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base>
boolean_archetype
operator==(const equality_comparable_archetype<Base>&,
const equality_comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base>
boolean_archetype
operator!=(const equality_comparable_archetype<Base>&,
const equality_comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base = null_archetype<> >
class equality_comparable2_first_archetype : public Base {
public:
equality_comparable2_first_archetype(detail::dummy_constructor x)
: Base(x) { }
};
template <class Base = null_archetype<> >
class equality_comparable2_second_archetype : public Base {
public:
equality_comparable2_second_archetype(detail::dummy_constructor x)
: Base(x) { }
};
template <class Base1, class Base2>
boolean_archetype
operator==(const equality_comparable2_first_archetype<Base1>&,
const equality_comparable2_second_archetype<Base2>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base1, class Base2>
boolean_archetype
operator!=(const equality_comparable2_first_archetype<Base1>&,
const equality_comparable2_second_archetype<Base2>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base = null_archetype<> >
class less_than_comparable_archetype : public Base {
public:
less_than_comparable_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base>
boolean_archetype
operator<(const less_than_comparable_archetype<Base>&,
const less_than_comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base = null_archetype<> >
class comparable_archetype : public Base {
public:
comparable_archetype(detail::dummy_constructor x) : Base(x) { }
};
template <class Base>
boolean_archetype
operator<(const comparable_archetype<Base>&,
const comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base>
boolean_archetype
operator<=(const comparable_archetype<Base>&,
const comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base>
boolean_archetype
operator>(const comparable_archetype<Base>&,
const comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
template <class Base>
boolean_archetype
operator>=(const comparable_archetype<Base>&,
const comparable_archetype<Base>&)
{
return boolean_archetype(static_object<detail::dummy_constructor>::get());
}
// The purpose of the optags is so that one can specify
// exactly which types the operator< is defined between.
// This is useful for allowing the operations:
//
// A a; B b;
// a < b
// b < a
//
// without also allowing the combinations:
//
// a < a
// b < b
//
struct optag1 { };
struct optag2 { };
struct optag3 { };
#define BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(OP, NAME) \
template <class Base = null_archetype<>, class Tag = optag1 > \
class NAME##_first_archetype : public Base { \
public: \
NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \
\
template <class Base = null_archetype<>, class Tag = optag1 > \
class NAME##_second_archetype : public Base { \
public: \
NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \
\
template <class BaseFirst, class BaseSecond, class Tag> \
boolean_archetype \
operator OP (const NAME##_first_archetype<BaseFirst, Tag>&, \
const NAME##_second_archetype<BaseSecond, Tag>&) \
{ \
return boolean_archetype(static_object<detail::dummy_constructor>::get()); \
}
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(==, equal_op)
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(!=, not_equal_op)
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(<, less_than_op)
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(<=, less_equal_op)
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(>, greater_than_op)
BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(>=, greater_equal_op)
#define BOOST_DEFINE_OPERATOR_ARCHETYPE(OP, NAME) \
template <class Base = null_archetype<> > \
class NAME##_archetype : public Base { \
public: \
NAME##_archetype(detail::dummy_constructor x) : Base(x) { } \
NAME##_archetype(const NAME##_archetype&) \
: Base(static_object<detail::dummy_constructor>::get()) { } \
NAME##_archetype& operator=(const NAME##_archetype&) { return *this; } \
}; \
template <class Base> \
NAME##_archetype<Base> \
operator OP (const NAME##_archetype<Base>&,\
const NAME##_archetype<Base>&) \
{ \
return \
NAME##_archetype<Base>(static_object<detail::dummy_constructor>::get()); \
}
BOOST_DEFINE_OPERATOR_ARCHETYPE(+, addable)
BOOST_DEFINE_OPERATOR_ARCHETYPE(-, subtractable)
BOOST_DEFINE_OPERATOR_ARCHETYPE(*, multipliable)
BOOST_DEFINE_OPERATOR_ARCHETYPE(/, dividable)
BOOST_DEFINE_OPERATOR_ARCHETYPE(%, modable)
// As is, these are useless because of the return type.
// Need to invent a better way...
#define BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(OP, NAME) \
template <class Return, class Base = null_archetype<> > \
class NAME##_first_archetype : public Base { \
public: \
NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \
\
template <class Return, class Base = null_archetype<> > \
class NAME##_second_archetype : public Base { \
public: \
NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \
\
template <class Return, class BaseFirst, class BaseSecond> \
Return \
operator OP (const NAME##_first_archetype<Return, BaseFirst>&, \
const NAME##_second_archetype<Return, BaseSecond>&) \
{ \
return Return(static_object<detail::dummy_constructor>::get()); \
}
BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(+, plus_op)
BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(*, time_op)
BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(/, divide_op)
BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(-, subtract_op)
BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(%, mod_op)
//===========================================================================
// Function Object Archetype Classes
template <class Return>
class generator_archetype {
public:
const Return& operator()() {
return static_object<Return>::get();
}
};
class void_generator_archetype {
public:
void operator()() { }
};
template <class Arg, class Return>
class unary_function_archetype {
private:
unary_function_archetype() { }
public:
unary_function_archetype(detail::dummy_constructor) { }
const Return& operator()(const Arg&) const {
return static_object<Return>::get();
}
};
template <class Arg1, class Arg2, class Return>
class binary_function_archetype {
private:
binary_function_archetype() { }
public:
binary_function_archetype(detail::dummy_constructor) { }
const Return& operator()(const Arg1&, const Arg2&) const {
return static_object<Return>::get();
}
};
template <class Arg>
class unary_predicate_archetype {
typedef boolean_archetype Return;
unary_predicate_archetype() { }
public:
unary_predicate_archetype(detail::dummy_constructor) { }
const Return& operator()(const Arg&) const {
return static_object<Return>::get();
}
};
template <class Arg1, class Arg2, class Base = null_archetype<> >
class binary_predicate_archetype {
typedef boolean_archetype Return;
binary_predicate_archetype() { }
public:
binary_predicate_archetype(detail::dummy_constructor) { }
const Return& operator()(const Arg1&, const Arg2&) const {
return static_object<Return>::get();
}
};
//===========================================================================
// Iterator Archetype Classes
template <class T, int I = 0>
class input_iterator_archetype
{
private:
typedef input_iterator_archetype self;
public:
typedef std::input_iterator_tag iterator_category;
typedef T value_type;
struct reference {
operator const value_type&() const { return static_object<T>::get(); }
};
typedef const T* pointer;
typedef std::ptrdiff_t difference_type;
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return reference(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
};
template <class T>
class input_iterator_archetype_no_proxy
{
private:
typedef input_iterator_archetype_no_proxy self;
public:
typedef std::input_iterator_tag iterator_category;
typedef T value_type;
typedef const T& reference;
typedef const T* pointer;
typedef std::ptrdiff_t difference_type;
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
};
template <class T>
struct output_proxy {
output_proxy& operator=(const T&) { return *this; }
};
template <class T>
class output_iterator_archetype
{
public:
typedef output_iterator_archetype self;
public:
typedef std::output_iterator_tag iterator_category;
typedef output_proxy<T> value_type;
typedef output_proxy<T> reference;
typedef void pointer;
typedef void difference_type;
output_iterator_archetype(detail::dummy_constructor) { }
output_iterator_archetype(const self&) { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return output_proxy<T>(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
private:
output_iterator_archetype() { }
};
template <class T>
class input_output_iterator_archetype
{
private:
typedef input_output_iterator_archetype self;
struct in_out_tag : public std::input_iterator_tag, public std::output_iterator_tag { };
public:
typedef in_out_tag iterator_category;
typedef T value_type;
struct reference {
reference& operator=(const T&) { return *this; }
operator value_type() { return static_object<T>::get(); }
};
typedef const T* pointer;
typedef std::ptrdiff_t difference_type;
input_output_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return reference(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
};
template <class T>
class forward_iterator_archetype
{
public:
typedef forward_iterator_archetype self;
public:
typedef std::forward_iterator_tag iterator_category;
typedef T value_type;
typedef const T& reference;
typedef T const* pointer;
typedef std::ptrdiff_t difference_type;
forward_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
};
template <class T>
class mutable_forward_iterator_archetype
{
public:
typedef mutable_forward_iterator_archetype self;
public:
typedef std::forward_iterator_tag iterator_category;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
mutable_forward_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
};
template <class T>
class bidirectional_iterator_archetype
{
public:
typedef bidirectional_iterator_archetype self;
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef T value_type;
typedef const T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
bidirectional_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
self& operator--() { return *this; }
self operator--(int) { return *this; }
};
template <class T>
class mutable_bidirectional_iterator_archetype
{
public:
typedef mutable_bidirectional_iterator_archetype self;
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
mutable_bidirectional_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
self& operator--() { return *this; }
self operator--(int) { return *this; }
};
template <class T>
class random_access_iterator_archetype
{
public:
typedef random_access_iterator_archetype self;
public:
typedef std::random_access_iterator_tag iterator_category;
typedef T value_type;
typedef const T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
random_access_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
self& operator--() { return *this; }
self operator--(int) { return *this; }
reference operator[](difference_type) const
{ return static_object<T>::get(); }
self& operator+=(difference_type) { return *this; }
self& operator-=(difference_type) { return *this; }
difference_type operator-(const self&) const
{ return difference_type(); }
self operator+(difference_type) const { return *this; }
self operator-(difference_type) const { return *this; }
bool operator<(const self&) const { return true; }
bool operator<=(const self&) const { return true; }
bool operator>(const self&) const { return true; }
bool operator>=(const self&) const { return true; }
};
template <class T>
random_access_iterator_archetype<T>
operator+(typename random_access_iterator_archetype<T>::difference_type,
const random_access_iterator_archetype<T>& x)
{ return x; }
template <class T>
class mutable_random_access_iterator_archetype
{
public:
typedef mutable_random_access_iterator_archetype self;
public:
typedef std::random_access_iterator_tag iterator_category;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
mutable_random_access_iterator_archetype() { }
self& operator=(const self&) { return *this; }
bool operator==(const self&) const { return true; }
bool operator!=(const self&) const { return true; }
reference operator*() const { return static_object<T>::get(); }
self& operator++() { return *this; }
self operator++(int) { return *this; }
self& operator--() { return *this; }
self operator--(int) { return *this; }
reference operator[](difference_type) const
{ return static_object<T>::get(); }
self& operator+=(difference_type) { return *this; }
self& operator-=(difference_type) { return *this; }
difference_type operator-(const self&) const
{ return difference_type(); }
self operator+(difference_type) const { return *this; }
self operator-(difference_type) const { return *this; }
bool operator<(const self&) const { return true; }
bool operator<=(const self&) const { return true; }
bool operator>(const self&) const { return true; }
bool operator>=(const self&) const { return true; }
};
template <class T>
mutable_random_access_iterator_archetype<T>
operator+
(typename mutable_random_access_iterator_archetype<T>::difference_type,
const mutable_random_access_iterator_archetype<T>& x)
{ return x; }
} // namespace boost
#endif // BOOST_CONCEPT_ARCHETYPES_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
#ifndef NHASH_H_
#define NHASH_H_
#ifdef Win32
#include "win_stdint.h" /* defines uint32_t etc */
#else
#include <stddef.h>
#include <stdint.h> /* defines uint32_t etc */
#endif
#ifdef __cplusplus
extern "C" {
#endif
uint32_t nhash( const void * key, size_t length, uint32_t initval);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,36 @@
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
// Copyright (C) 2016 Andrzej Krzemienski.
//
// 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/libs/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
// akrzemi1@gmail.com
#ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_FACTORY_SUPPORT_AJK_12FEB2016_HPP
#define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_FACTORY_SUPPORT_AJK_12FEB2016_HPP
// Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<>
// member template of a factory as used in the optional<> implementation.
// He proposed this simple fix which is to move the call to apply<> outside
// namespace boost.
namespace boost_optional_detail
{
template <class T, class Factory>
inline void construct(Factory const& factory, void* address)
{
factory.BOOST_NESTED_TEMPLATE apply<T>(address);
}
}
namespace boost
{
class in_place_factory_base ;
class typed_in_place_factory_base ;
}
#endif // header guard
@@ -0,0 +1,170 @@
#ifndef TRANSCEIVER_BASE_HPP__
#define TRANSCEIVER_BASE_HPP__
#include <stdexcept>
#include <QString>
#include "Transceiver.hpp"
//
// Base Transceiver Implementation
//
// Behaviour common to all Transceiver implementations.
//
// Collaborations
//
// Implements the Transceiver abstract interface as template methods
// and provides a new abstract interface with similar functionality
// (do_XXXXX operations). Provides and calls abstract interface that
// gets called post the above operations (do_post_XXXXX) to allow
// caching implementation etc.
//
// A key factor is to catch all exceptions thrown by sub-class
// implementations where the template method is a Qt slot which is
// therefore likely to be called by Qt which doesn't handle
// exceptions. Any exceptions are converted to Transceiver::failure()
// signals.
//
// Sub-classes update the stored state via a protected interface.
//
// Responsibilities:
//
// Wrap incoming Transceiver messages catching all exceptions in Qt
// slot driven messages and converting them to Qt signals. This is
// done because exceptions make concrete Transceiver implementations
// simpler to write, but exceptions cannot cross signal/slot
// boundaries (especially across threads). This also removes any
// requirement for the client code to handle exceptions.
//
// Maintain the state of the concrete Transceiver instance that is
// passed back via the Transceiver::update(TransceiverState) signal,
// it is still the responsibility of concrete Transceiver
// implementations to emit the state_change signal when they have a
// status update.
//
// Maintain a go/no-go status for concrete Transceiver
// implementations ensuring only a valid sequence of messages are
// passed. A concrete Transceiver instance must be started before it
// can receive messages, any exception thrown takes the Transceiver
// offline.
//
// Implements methods that concrete Transceiver implementations use
// to update the Transceiver state. These do not signal state change
// to clients as this is the responsibility of the concrete
// Transceiver implementation, thus allowing multiple state component
// updates to be signalled together if required.
//
class TransceiverBase
: public Transceiver
{
Q_OBJECT;
protected:
TransceiverBase (QObject * parent)
: Transceiver {parent}
, last_sequence_number_ {0}
{}
public:
//
// Implement the Transceiver abstract interface.
//
void start (unsigned sequence_number) noexcept override final;
void set (TransceiverState const&,
unsigned sequence_number) noexcept override final;
void stop () noexcept override final;
//
// Query operations
//
TransceiverState const& state () const {return actual_;}
protected:
//
// Error exception which is thrown to signal unexpected errors.
//
struct error
: public std::runtime_error
{
explicit error (char const * const msg) : std::runtime_error (msg) {}
explicit error (QString const& msg) : std::runtime_error (msg.toStdString ()) {}
};
// Template methods that sub classes implement to do what they need to do.
//
// These methods may throw exceptions to signal errors.
virtual int do_start () = 0; // returns resolution, See Transceiver::resolution
virtual void do_post_start () {}
virtual void do_stop () = 0;
virtual void do_post_stop () {}
virtual void do_frequency (Frequency, MODE, bool no_ignore) = 0;
virtual void do_post_frequency (Frequency, MODE) {}
virtual void do_tx_frequency (Frequency, MODE, bool no_ignore) = 0;
virtual void do_post_tx_frequency (Frequency, MODE) {}
virtual void do_mode (MODE) = 0;
virtual void do_post_mode (MODE) {}
virtual void do_ptt (bool = true) = 0;
virtual void do_post_ptt (bool = true) {}
virtual void do_sync (bool force_signal = false, bool no_poll = false) = 0;
virtual bool do_pre_update () {return true;}
// sub classes report rig state changes with these methods
void update_rx_frequency (Frequency);
void update_other_frequency (Frequency = 0);
void update_split (bool);
void update_mode (MODE);
void update_PTT (bool = true);
// Calling this eventually triggers the Transceiver::update(State) signal.
void update_complete (bool force_signal = false);
// sub class may asynchronously take the rig offline by calling this
void offline (QString const& reason);
private:
void startup ();
void shutdown ();
bool maybe_low_resolution (Frequency low_res, Frequency high_res);
// use this convenience class to notify in update methods
class may_update
{
public:
explicit may_update (TransceiverBase * self, bool force_signal = false)
: self_ {self}
, force_signal_ {force_signal}
{}
~may_update () {self_->update_complete (force_signal_);}
private:
TransceiverBase * self_;
bool force_signal_;
};
TransceiverState requested_;
TransceiverState actual_;
TransceiverState last_;
unsigned last_sequence_number_; // from set state operation
};
// some trace macros
#if WSJT_TRACE_CAT
#define TRACE_CAT(FAC, MSG) qDebug () << QString {"%1::%2:"}.arg ((FAC)).arg (__func__) << MSG
#else
#define TRACE_CAT(FAC, MSG)
#endif
#if WSJT_TRACE_CAT && WSJT_TRACE_CAT_POLLS
#define TRACE_CAT_POLL(FAC, MSG) qDebug () << QString {"%1::%2:"}.arg ((FAC)).arg (__func__) << MSG
#else
#define TRACE_CAT_POLL(FAC, MSG)
#endif
#endif