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,113 @@
/* Boost interval/detail/msvc_rounding_control.hpp file
*
* Copyright 2000 Maarten Keijzer
* Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
*
* 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_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP
#define BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP
#ifndef _MSC_VER
# error This header is only intended for MSVC, but might work for Borland as well
#endif
#include <float.h> // MSVC rounding control
// Although the function is called _control87, it seems to work for
// other FPUs too, so it does not have to be changed to _controlfp.
namespace boost {
namespace numeric {
namespace interval_lib {
namespace detail {
#if BOOST_MSVC < 1400 || defined(_WIN64)
extern "C" { double rint(double); }
#else
inline double rint(double x)
{
_asm FLD [x] ;
_asm FRNDINT ;
//_asm RET ;
}
#endif
struct x86_rounding
{
static unsigned int hard2msvc(unsigned short m) {
unsigned int n = 0;
if (m & 0x01) n |= _EM_INVALID;
if (m & 0x02) n |= _EM_DENORMAL;
if (m & 0x04) n |= _EM_ZERODIVIDE;
if (m & 0x08) n |= _EM_OVERFLOW;
if (m & 0x10) n |= _EM_UNDERFLOW;
if (m & 0x20) n |= _EM_INEXACT;
switch (m & 0x300) {
case 0x000: n |= _PC_24; break;
case 0x200: n |= _PC_53; break;
case 0x300: n |= _PC_64; break;
}
switch (m & 0xC00) {
case 0x000: n |= _RC_NEAR; break;
case 0x400: n |= _RC_DOWN; break;
case 0x800: n |= _RC_UP; break;
case 0xC00: n |= _RC_CHOP; break;
}
if (m & 0x1000) n |= _IC_AFFINE; // only useful on 287
return n;
}
static unsigned short msvc2hard(unsigned int n) {
unsigned short m = 0;
if (n & _EM_INVALID) m |= 0x01;
if (n & _EM_DENORMAL) m |= 0x02;
if (n & _EM_ZERODIVIDE) m |= 0x04;
if (n & _EM_OVERFLOW) m |= 0x08;
if (n & _EM_UNDERFLOW) m |= 0x10;
if (n & _EM_INEXACT) m |= 0x20;
switch (n & _MCW_RC) {
case _RC_NEAR: m |= 0x000; break;
case _RC_DOWN: m |= 0x400; break;
case _RC_UP: m |= 0x800; break;
case _RC_CHOP: m |= 0xC00; break;
}
switch (n & _MCW_PC) {
case _PC_24: m |= 0x000; break;
case _PC_53: m |= 0x200; break;
case _PC_64: m |= 0x300; break;
}
if ((n & _MCW_IC) == _IC_AFFINE) m |= 0x1000;
return m;
}
typedef unsigned short rounding_mode;
static void get_rounding_mode(rounding_mode& mode)
{ mode = msvc2hard(_control87(0, 0)); }
static void set_rounding_mode(const rounding_mode mode)
{
_control87(hard2msvc(mode),
_MCW_EM | _MCW_RC
#if !defined(_M_AMD64) && !defined(_M_ARM)
// x64 ignores _MCW_PC and _MCW_IC, and the Debug CRT library actually
// asserts when these are passed to _control87.
// MSDN says on '_control87' that changing precision (_MCW_PC) or
// infinity (_MCW_IC) handling is not supported on the ARM and x64
// architectures and that _control87 raises an assertion
// and the invalid parameter handler is invoked.
| _MCW_PC | _MCW_IC
#endif
);
}
static double to_int(const double& x) { return rint(x); }
};
} // namespace detail
} // namespace interval_lib
} // namespace numeric
} // namespace boost
#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP */
@@ -0,0 +1,34 @@
// get_current_thread.hpp --------------------------------------------------------------//
// Copyright 2010 Vicente J. Botet Escriba
// Copyright 2015 Andrey Semashev
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_DETAIL_WINAPI_GET_CURRENT_THREAD_HPP
#define BOOST_DETAIL_WINAPI_GET_CURRENT_THREAD_HPP
#include <boost/detail/winapi/basic_types.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
// Windows CE define GetCurrentThread as an inline function in kfuncs.h
#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE )
extern "C" {
BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentThread(BOOST_DETAIL_WINAPI_VOID);
}
#endif
namespace boost {
namespace detail {
namespace winapi {
using ::GetCurrentThread;
}
}
}
#endif // BOOST_DETAIL_WINAPI_GET_CURRENT_THREAD_HPP
File diff suppressed because one or more lines are too long
@@ -0,0 +1,112 @@
///////////////////////////////////////////////////////////////////////////////
/// \file literal.hpp
/// The literal\<\> terminal wrapper, and the proto::lit() function for
/// creating literal\<\> wrappers.
//
// Copyright 2008 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
#define BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
#include <boost/config.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/expr.hpp>
#include <boost/proto/traits.hpp>
#include <boost/proto/extends.hpp>
namespace boost { namespace proto
{
namespace utility
{
/// \brief A simple wrapper for a terminal, provided for
/// ease of use.
///
/// A simple wrapper for a terminal, provided for
/// ease of use. In all cases, <tt>literal\<X\> l(x);</tt>
/// is equivalent to <tt>terminal\<X\>::type l = {x};</tt>.
///
/// The \c Domain template parameter defaults to
/// \c proto::default_domain.
template<
typename T
, typename Domain // = default_domain
>
struct literal
: extends<basic_expr<tag::terminal, term<T>, 0>, literal<T, Domain>, Domain>
{
private:
typedef basic_expr<tag::terminal, term<T>, 0> terminal_type;
typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
typedef literal<T, Domain> literal_t;
public:
typedef typename detail::term_traits<T>::value_type value_type;
typedef typename detail::term_traits<T>::reference reference;
typedef typename detail::term_traits<T>::const_reference const_reference;
literal()
: base_type(terminal_type::make(T()))
{}
template<typename U>
literal(U &u)
: base_type(terminal_type::make(u))
{}
template<typename U>
literal(U const &u)
: base_type(terminal_type::make(u))
{}
template<typename U>
literal(literal<U, Domain> const &u)
: base_type(terminal_type::make(u.get()))
{}
BOOST_PROTO_EXTENDS_USING_ASSIGN(literal_t)
reference get()
{
return proto::value(*this);
}
const_reference get() const
{
return proto::value(*this);
}
};
}
/// \brief A helper function for creating a \c literal\<\> wrapper.
/// \param t The object to wrap.
/// \return literal\<T &\>(t)
/// \attention The returned value holds the argument by reference.
/// \throw nothrow
template<typename T>
inline literal<T &> const lit(T &t)
{
return literal<T &>(t);
}
/// \overload
///
template<typename T>
inline literal<T const &> const lit(T const &t)
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4180) // warning C4180: qualifier applied to function type has no meaning; ignored
#endif
return literal<T const &>(t);
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}
}}
#endif
@@ -0,0 +1,163 @@
///////////////////////////////////////////////////////////////
// Copyright 2012 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_
#ifndef BOOST_MP_CPP_INT_CORE_HPP
#define BOOST_MP_CPP_INT_CORE_HPP
#include <boost/integer.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/static_assert.hpp>
#include <boost/assert.hpp>
namespace boost{ namespace multiprecision{
namespace detail{
//
// These traits calculate the largest type in the list
// [unsigned] boost::long_long_type, long, int, which has the specified number
// of bits. Note that intN_t and boost::int_t<N> find the first
// member of the above list, not the last. We want the last in the
// list to ensure that mixed arithmetic operations are as efficient
// as possible.
//
template <unsigned N>
struct largest_signed_type
{
typedef typename mpl::if_c<
1 + std::numeric_limits<boost::long_long_type>::digits == N,
boost::long_long_type,
typename mpl::if_c<
1 + std::numeric_limits<long>::digits == N,
long,
typename mpl::if_c<
1 + std::numeric_limits<int>::digits == N,
int,
typename boost::int_t<N>::exact
>::type
>::type
>::type type;
};
template <unsigned N>
struct largest_unsigned_type
{
typedef typename mpl::if_c<
std::numeric_limits<boost::ulong_long_type>::digits == N,
boost::ulong_long_type,
typename mpl::if_c<
std::numeric_limits<unsigned long>::digits == N,
unsigned long,
typename mpl::if_c<
std::numeric_limits<unsigned int>::digits == N,
unsigned int,
typename boost::uint_t<N>::exact
>::type
>::type
>::type type;
};
} // namespace detail
#if defined(BOOST_HAS_INT128)
typedef detail::largest_unsigned_type<64>::type limb_type;
typedef detail::largest_signed_type<64>::type signed_limb_type;
typedef boost::uint128_type double_limb_type;
typedef boost::int128_type signed_double_limb_type;
static const limb_type max_block_10 = 1000000000000000000uLL;
static const limb_type digits_per_block_10 = 18;
inline limb_type block_multiplier(unsigned count)
{
static const limb_type values[digits_per_block_10]
= { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000 };
BOOST_ASSERT(count < digits_per_block_10);
return values[count];
}
// Can't do formatted IO on an __int128
#define BOOST_MP_NO_DOUBLE_LIMB_TYPE_IO
// Need to specialise integer_traits for __int128 as it's not a normal native type:
} // namespace multiprecision
template<>
class integer_traits<multiprecision::double_limb_type>
: public std::numeric_limits<multiprecision::double_limb_type>,
public detail::integer_traits_base<multiprecision::double_limb_type, 0, ~static_cast<multiprecision::double_limb_type>(0)>
{ };
template<>
class integer_traits<multiprecision::signed_double_limb_type>
: public std::numeric_limits<multiprecision::signed_double_limb_type>,
public detail::integer_traits_base<multiprecision::signed_double_limb_type, static_cast<multiprecision::signed_double_limb_type>((static_cast<multiprecision::double_limb_type>(1) << 127)), static_cast<multiprecision::signed_double_limb_type>(((~static_cast<multiprecision::double_limb_type>(0)) >> 1))>
{ };
namespace multiprecision{
#else
typedef detail::largest_unsigned_type<32>::type limb_type;
typedef detail::largest_signed_type<32>::type signed_limb_type;
typedef detail::largest_unsigned_type<64>::type double_limb_type;
typedef detail::largest_signed_type<64>::type signed_double_limb_type;
static const limb_type max_block_10 = 1000000000;
static const limb_type digits_per_block_10 = 9;
inline limb_type block_multiplier(unsigned count)
{
static const limb_type values[digits_per_block_10]
= { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
BOOST_ASSERT(count < digits_per_block_10);
return values[count];
}
#endif
static const unsigned bits_per_limb = sizeof(limb_type) * CHAR_BIT;
template <class T>
inline void minmax(const T& a, const T& b, T& aa, T& bb)
{
if(a < b)
{
aa = a;
bb = b;
}
else
{
aa = b;
bb = a;
}
}
enum cpp_integer_type
{
signed_magnitude = 1,
unsigned_magnitude = 0,
signed_packed = 3,
unsigned_packed = 2
};
enum cpp_int_check_type
{
checked = 1,
unchecked = 0
};
}}
//
// Figure out whether to support user-defined-literals or not:
//
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_USER_DEFINED_LITERALS) \
&& !defined(BOOST_NO_CXX11_CONSTEXPR)
# define BOOST_MP_USER_DEFINED_LITERALS
#endif
#endif // BOOST_MP_CPP_INT_CORE_HPP
@@ -0,0 +1,95 @@
// -*- C++ -*-
// ----------------------------------------------------------------------------
// config_macros.hpp : configuration macros for the format library
// only BOOST_IO_STD is absolutely needed (it should be 'std::' in general)
// others are compiler-specific workaround macros used in #ifdef switches
// ----------------------------------------------------------------------------
// Copyright Samuel Krempp 2003. 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/format for library home page
// ----------------------------------------------------------------------------
#ifndef BOOST_FORMAT_CONFIG_MACROS_HPP
#define BOOST_FORMAT_CONFIG_MACROS_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
// make sure our local macros wont override something :
#if defined(BOOST_NO_LOCALE_ISDIGIT) || defined(BOOST_OVERLOAD_FOR_NON_CONST) \
|| defined(BOOST_IO_STD) || defined( BOOST_IO_NEEDS_USING_DECLARATION ) \
|| defined(BOOST_NO_TEMPLATE_STD_STREAM) \
|| defined(BOOST_FORMAT_STREAMBUF_DEFINED) || defined(BOOST_FORMAT_OSTREAM_DEFINED)
#error "boost::format uses a local macro that is already defined."
#endif
// specific workarounds. each header can define BOOS_IO_STD if it
// needs. (e.g. because of IO_NEEDS_USING_DECLARATION)
#include <boost/format/detail/workarounds_gcc-2_95.hpp>
#include <boost/format/detail/workarounds_stlport.hpp>
#ifndef BOOST_IO_STD
# define BOOST_IO_STD ::std::
#endif
#if defined(BOOST_NO_STD_LOCALE) || \
( BOOST_WORKAROUND(__BORLANDC__, <= 0x564) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT( 0x570 ) ) )
// some future __BORLANDC__ >0x564 versions might not need this
// 0x570 is Borland's kylix branch
#define BOOST_NO_LOCALE_ISDIGIT
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570) ) || BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1300))
#define BOOST_NO_OVERLOAD_FOR_NON_CONST
#endif
// **** Workaround for io streams, stlport and msvc.
#ifdef BOOST_IO_NEEDS_USING_DECLARATION
namespace boost {
using std::char_traits;
using std::basic_ostream;
namespace io {
using std::basic_ostream;
namespace detail {
using std::basic_ios;
using std::basic_ostream;
}
}
#if ! defined(BOOST_NO_STD_LOCALE)
using std::locale;
namespace io {
using std::locale;
namespace detail {
using std::locale;
}
}
#endif // locale
}
// -end N.S. boost
#endif // needs_using_declaration
#if ! defined(BOOST_NO_STD_LOCALE)
#include <locale>
#endif
// *** hide std::locale if it doesnt exist.
// this typedef is either std::locale or int, avoids placing ifdefs everywhere
namespace boost { namespace io { namespace detail {
#if ! defined(BOOST_NO_STD_LOCALE)
typedef BOOST_IO_STD locale locale_t;
#else
typedef int locale_t;
#endif
} } }
// ----------------------------------------------------------------------------
#endif // BOOST_FORMAT_MACROS_DEFAULT_HPP
@@ -0,0 +1,86 @@
/* RAND-SRC.C - Generate random message bits. */
/* Copyright (c) 1995-2012 by Radford M. Neal.
*
* Permission is granted for anyone to copy, use, modify, and distribute
* these programs and accompanying documents for any purpose, provided
* this copyright notice is retained and prominently displayed, and note
* is made of any changes made to these programs. These programs and
* documents are distributed without any warranty, express or implied.
* As the programs were written for research purposes only, they have not
* been tested to the degree that would be advisable in any important
* application. All use of these programs is entirely at the user's own
* risk.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "open.h"
#include "rand.h"
void usage(void);
/* MAIN PROGRAM. */
int main
( int argc,
char **argv
)
{
int seed, bs, nb;
char *file, *n_bits;
char junk;
int i, j;
FILE *f;
if (!(file = argv[1])
|| !argv[2] || sscanf(argv[2],"%d%c",&seed,&junk)!=1
|| !(n_bits = argv[3])
|| argv[4])
{ usage();
}
if (sscanf(n_bits,"%d%c",&nb,&junk)==1)
{ if (nb<=0) usage();
bs = 1;
}
else if (sscanf(n_bits,"%dx%d%c",&bs,&nb,&junk)==2)
{ if (nb<=0 || bs<=0) usage();
}
else
{ usage();
}
f = open_file_std(file,"w");
if (f==NULL)
{ fprintf(stderr,"Can't create source file: %s\n",file);
exit(1);
}
rand_seed(10*seed+2);
for (i = 0; i<nb; i++)
{ for (j = 0; j<bs; j++)
{ fprintf(f,"%d",rand_int(2));
}
fprintf(f,"\n");
}
if (ferror(f) || fclose(f)!=0)
{ fprintf(stderr,"Error writing random source blocks to %s\n",file);
exit(1);
}
return 0;
}
/* PRINT USAGE MESSAGE AND EXIT. */
void usage(void)
{ fprintf(stderr,"Usage: rand-src source-file seed n-bits\n");
exit(1);
}
@@ -0,0 +1,372 @@
/*
This file is part of wsprd.
File name: nhash.c
*------------------------------------------------------------------------------
*
* This file is part of the WSPR application, Weak Signal Propogation Reporter
*
* File Name: nhash.c
* Description: Functions to produce 32-bit hashes for hash table lookup
*
* Copyright (C) 2008-2014 Joseph Taylor, K1JT
* License: GNU GPL v3+
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Files: lookup3.c
* Copyright: Copyright (C) 2006 Bob Jenkins <bob_jenkins@burtleburtle.net>
* License: public-domain
* You may use this code any way you wish, private, educational, or commercial.
* It's free.
*
*-------------------------------------------------------------------------------
*/
/*
These are functions for producing 32-bit hashes for hash table lookup.
hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
are externally useful functions. Routines to test the hash are included
if SELF_TEST is defined. You can use this free for any purpose. It's in
the public domain. It has no warranty.
You probably want to use hashlittle(). hashlittle() and hashbig()
hash byte arrays. hashlittle() is is faster than hashbig() on
little-endian machines. Intel and AMD are little-endian machines.
On second thought, you probably want hashlittle2(), which is identical to
hashlittle() except it returns two 32-bit hashes for the price of one.
You could implement hashbig2() if you wanted but I haven't bothered here.
If you want to find a hash of, say, exactly 7 integers, do
a = i1; b = i2; c = i3;
mix(a,b,c);
a += i4; b += i5; c += i6;
mix(a,b,c);
a += i7;
final(a,b,c);
then use c as the hash value. If you have a variable length array of
4-byte integers to hash, use hashword(). If you have a byte array (like
a character string), use hashlittle(). If you have several byte arrays, or
a mix of things, see the comments above hashlittle().
Why is this so big? I read 12 bytes at a time into 3 4-byte integers,
then mix those integers. This is fast (you can do a lot more thorough
mixing with 12*3 instructions on 3 integers than you can with 3 instructions
on 1 byte), but shoehorning those bytes into integers efficiently is messy.
*/
#define SELF_TEST 1
#include <stdio.h> /* defines printf for tests */
#include <time.h> /* defines time_t for timings in the test */
#include "nhash.h"
//#include <sys/param.h> /* attempt to define endianness */
//#ifdef linux
//# include <endian.h> /* attempt to define endianness */
//#endif
#define HASH_LITTLE_ENDIAN 1
#define hashsize(n) ((uint32_t)1<<(n))
#define hashmask(n) (hashsize(n)-1)
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
/*
-------------------------------------------------------------------------------
mix -- mix 3 32-bit values reversibly.
This is reversible, so any information in (a,b,c) before mix() is
still in (a,b,c) after mix().
If four pairs of (a,b,c) inputs are run through mix(), or through
mix() in reverse, there are at least 32 bits of the output that
are sometimes the same for one pair and different for another pair.
This was tested for:
* pairs that differed by one bit, by two bits, in any combination
of top bits of (a,b,c), or in any combination of bottom bits of
(a,b,c).
* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
is commonly produced by subtraction) look like a single 1-bit
difference.
* the base values were pseudorandom, all zero but one bit set, or
all zero plus a counter that starts at zero.
Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
satisfy this are
4 6 8 16 19 4
9 15 3 18 27 15
14 9 3 7 17 3
Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
for "differ" defined as + with a one-bit base and a two-bit delta. I
used http://burtleburtle.net/bob/hash/avalanche.html to choose
the operations, constants, and arrangements of the variables.
This does not achieve avalanche. There are input bits of (a,b,c)
that fail to affect some output bits of (a,b,c), especially of a. The
most thoroughly mixed value is c, but it doesn't really even achieve
avalanche in c.
This allows some parallelism. Read-after-writes are good at doubling
the number of bits affected, so the goal of mixing pulls in the opposite
direction as the goal of parallelism. I did what I could. Rotates
seem to cost as much as shifts on every machine I could lay my hands
on, and rotates are much kinder to the top and bottom bits, so I used
rotates.
-------------------------------------------------------------------------------
*/
#define mix(a,b,c) \
{ \
a -= c; a ^= rot(c, 4); c += b; \
b -= a; b ^= rot(a, 6); a += c; \
c -= b; c ^= rot(b, 8); b += a; \
a -= c; a ^= rot(c,16); c += b; \
b -= a; b ^= rot(a,19); a += c; \
c -= b; c ^= rot(b, 4); b += a; \
}
/*
-------------------------------------------------------------------------------
final -- final mixing of 3 32-bit values (a,b,c) into c
Pairs of (a,b,c) values differing in only a few bits will usually
produce values of c that look totally different. This was tested for
* pairs that differed by one bit, by two bits, in any combination
of top bits of (a,b,c), or in any combination of bottom bits of
(a,b,c).
* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
is commonly produced by subtraction) look like a single 1-bit
difference.
* the base values were pseudorandom, all zero but one bit set, or
all zero plus a counter that starts at zero.
These constants passed:
14 11 25 16 4 14 24
12 14 25 16 4 14 24
and these came close:
4 8 15 26 3 22 24
10 8 15 26 3 22 24
11 8 15 26 3 22 24
-------------------------------------------------------------------------------
*/
#define final(a,b,c) \
{ \
c ^= b; c -= rot(b,14); \
a ^= c; a -= rot(c,11); \
b ^= a; b -= rot(a,25); \
c ^= b; c -= rot(b,16); \
a ^= c; a -= rot(c,4); \
b ^= a; b -= rot(a,14); \
c ^= b; c -= rot(b,24); \
}
/*
-------------------------------------------------------------------------------
hashlittle() -- hash a variable-length key into a 32-bit value
k : the key (the unaligned variable-length array of bytes)
length : the length of the key, counting by bytes
initval : can be any 4-byte value
Returns a 32-bit value. Every bit of the key affects every bit of
the return value. Two keys differing by one or two bits will have
totally different hash values.
The best hash table sizes are powers of 2. There is no need to do
mod a prime (mod is sooo slow!). If you need less than 32 bits,
use a bitmask. For example, if you need only 10 bits, do
h = (h & hashmask(10));
In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (uint8_t **)k, do it like this:
for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this
code any way you wish, private, educational, or commercial. It's free.
Use for hash table lookup, or anything where one collision in 2^^32 is
acceptable. Do NOT use for cryptographic purposes.
-------------------------------------------------------------------------------
*/
uint32_t nhash( const void *key, size_t length, uint32_t initval)
{
uint32_t a,b,c; /* internal state */
union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
/* Set up the internal state */
a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
u.ptr = key;
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
while (length > 12)
{
a += k[0];
b += k[1];
c += k[2];
mix(a,b,c);
length -= 12;
k += 3;
}
/*----------------------------- handle the last (probably partial) block */
/*
* "k[2]&0xffffff" actually reads beyond the end of the string, but
* then masks off the part it's not allowed to read. Because the
* string is aligned, the masked-off tail is in the same word as the
* rest of the string. Every machine with memory protection I've seen
* does it on word boundaries, so is OK with this. But VALGRIND will
* still catch it and complain. The masking trick does make the hash
* noticably faster for short strings (like English words).
*/
#ifndef VALGRIND
switch(length)
{
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
case 8 : b+=k[1]; a+=k[0]; break;
case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
case 6 : b+=k[1]&0xffff; a+=k[0]; break;
case 5 : b+=k[1]&0xff; a+=k[0]; break;
case 4 : a+=k[0]; break;
case 3 : a+=k[0]&0xffffff; break;
case 2 : a+=k[0]&0xffff; break;
case 1 : a+=k[0]&0xff; break;
case 0 : return c; /* zero length strings require no mixing */
}
#else /* make valgrind happy */
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[1]; a+=k[0]; break;
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]; break;
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
case 1 : a+=k8[0]; break;
case 0 : return c;
}
#endif /* !valgrind */
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
const uint8_t *k8;
/*--------------- all but last block: aligned reads and different mixing */
while (length > 12)
{
a += k[0] + (((uint32_t)k[1])<<16);
b += k[2] + (((uint32_t)k[3])<<16);
c += k[4] + (((uint32_t)k[5])<<16);
mix(a,b,c);
length -= 12;
k += 6;
}
/*----------------------------- handle the last (probably partial) block */
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[4]+(((uint32_t)k[5])<<16);
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=k[4];
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=k[2];
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=k[0];
break;
case 1 : a+=k8[0];
break;
case 0 : return c; /* zero length requires no mixing */
}
} else { /* need to read the key one byte at a time */
const uint8_t *k = (const uint8_t *)key;
/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
while (length > 12)
{
a += k[0];
a += ((uint32_t)k[1])<<8;
a += ((uint32_t)k[2])<<16;
a += ((uint32_t)k[3])<<24;
b += k[4];
b += ((uint32_t)k[5])<<8;
b += ((uint32_t)k[6])<<16;
b += ((uint32_t)k[7])<<24;
c += k[8];
c += ((uint32_t)k[9])<<8;
c += ((uint32_t)k[10])<<16;
c += ((uint32_t)k[11])<<24;
mix(a,b,c);
length -= 12;
k += 12;
}
/*-------------------------------- last block: affect all 32 bits of (c) */
switch(length) /* all the case statements fall through */
{
case 12: c+=((uint32_t)k[11])<<24;
case 11: c+=((uint32_t)k[10])<<16;
case 10: c+=((uint32_t)k[9])<<8;
case 9 : c+=k[8];
case 8 : b+=((uint32_t)k[7])<<24;
case 7 : b+=((uint32_t)k[6])<<16;
case 6 : b+=((uint32_t)k[5])<<8;
case 5 : b+=k[4];
case 4 : a+=((uint32_t)k[3])<<24;
case 3 : a+=((uint32_t)k[2])<<16;
case 2 : a+=((uint32_t)k[1])<<8;
case 1 : a+=k[0];
break;
case 0 : return c;
}
}
final(a,b,c);
c=(32767&c);
return c;
}
@@ -0,0 +1,337 @@
[[PROTOCOL_OVERVIEW]]
=== Overview
All QSO modes except ISCAT use structured messages that compress
user-readable information into fixed-length packets of 72 bits. Each
message consists of two 28-bit fields normally used for callsigns and
a 15-bit field for a grid locator, report, acknowledgment, or 73. An
additional bit flags a message containing arbitrary alphanumeric text,
up to 13 characters. Special cases allow other information such as
add-on callsign prefixes (e.g., ZA/K1ABC) or suffixes (e.g., K1ABC/P)
to be encoded. The basic aim is to compress the most common messages
used for minimally valid QSOs into a fixed 72-bit length. Information
payloads in FT8 include 3 additional bits (75 bits total), with
definitions yet to be defined.
A standard amateur callsign consists of a one- or two-character
prefix, at least one of which must be a letter, followed by a digit
and a suffix of one to three letters. Within these rules, the number
of possible callsigns is equal to 37×36×10×27×27×27, or somewhat over
262 million. (The numbers 27 and 37 arise because in the first and
last three positions a character may be absent, or a letter, or
perhaps a digit.) Since 2^28^ is more than 268 million, 28 bits are
enough to encode any standard callsign uniquely. Similarly, the number
of 4-digit Maidenhead grid locators on earth is 180×180 = 32,400,
which is less than 2^15^ = 32,768; so a grid locator requires 15 bits.
Some 6 million of the possible 28-bit values are not needed for
callsigns. A few of these slots have been assigned to special message
components such as `CQ`, `DE`, and `QRZ`. `CQ` may be followed by three
digits to indicate a desired callback frequency. (If K1ABC transmits
on a standard calling frequency, say 50.280, and sends `CQ 290 K1ABC
FN42`, it means that s/he will listen on 50.290 and respond there to
any replies.) A numerical signal report of the form `nn` or
`Rnn` can be sent in place of a grid locator. (As originally
defined, numerical signal reports `nn` were required to fall between -01
and -30 dB. Recent program versions accommodate reports between
-50 and +49 dB.) A country prefix or portable suffix may be
attached to one of the callsigns. When this feature is used the
additional information is sent in place of the grid locator or by
encoding additional information into some of the 6 million available
slots mentioned above.
As a convenience for sending directed CQ messages, the compression
algorithm supports messages starting with `CQ AA` through `CQ ZZ`.
These message fragments are encoded internally as if they were the
callsigns `E9AA` through `E9ZZ`. Upon reception they are converted
back to the form `CQ AA` through `CQ ZZ`, for display to the user.
The FT8 and MSK144 modes support a special feature allowing convenient
transmission and acknowledgment of four-character grid locators, the
required exchanges in most North American VHF contests. With this
Contest Mode enabled, _WSJT-X_ supports messages of the form `W9XYZ
K1ABC R FN42` by converting the grid locator to that of its
diametrically opposite point on Earth. The receiving program
recognizes a locator implying a distance greater than 10,000 km, does
the reverse transformation, and inserts the implied "`R`". Obviously,
this mode should not be used on the HF bands or under other
circumstances where world-wide propagation is possible.
To be useful on channels with low signal-to-noise ratio, this kind of
lossless message compression requires use of a strong forward error
correcting (FEC) code. Different codes are used for each mode.
Accurate synchronization of time and frequency is required between
transmitting and receiving stations. As an aid to the decoders, each
protocol includes a "`sync vector`" of known symbols interspersed with
the information-carrying symbols. Generated waveforms for all of the
_WSJT-X_ modes have continuous phase and constant envelope.
[[SLOW_MODES]]
=== Slow Modes
[[FT8PRO]]
==== FT8
Forward error correction (FEC) in FT8 uses a low-density parity check
(LDPC) code with 75 information bits, a 12-bit cyclic redundancy check
(CRC), and 87 parity bits making a 174-bit codeword. It is thus
called an LDPC (174,87) code. Synchronization uses 7×7 Costas arrays
at the beginning, middle, and end of each transmission. Modulation is
8-tone frequency-shift keying (8-FSK) at 12000/1920 = 6.25 baud. Each
transmitted symbol carries three bits, so the total number of channel
symbols is 174/3 + 21 = 79. The total occupied bandwidth is 8 × 6.25
= 50 Hz.
[[JT4PRO]]
==== JT4
FEC in JT4 uses a strong convolutional code with constraint length
K=32, rate r=1/2, and a zero tail. This choice leads to an encoded
message length of (72+31) x 2 = 206 information-carrying bits.
Modulation is 4-tone frequency-shift keying (4-FSK) at 11025 / 2520 =
4.375 baud. Each symbol carries one information bit (the most
significant bit) and one synchronizing bit. The two 32-bit
polynomials used for convolutional encoding have hexadecimal values
0xf2d05351 and 0xe4613c47, and the ordering of encoded bits is
scrambled by an interleaver. The pseudo-random sync vector is the
following sequence (60 bits per line):
000011000110110010100000001100000000000010110110101111101000
100100111110001010001111011001000110101010101111101010110101
011100101101111000011011000111011101110010001101100100011111
10011000011000101101111010
[[JT9PRO]]
==== JT9
FEC in JT9 uses the same strong convolutional code as JT4: constraint
length K=32, rate r=1/2, and a zero tail, leading to an encoded
message length of (72+31) × 2 = 206 information-carrying
bits. Modulation is nine-tone frequency-shift keying, 9-FSK at
12000.0/6912 = 1.736 baud. Eight tones are used for data, one for
synchronization. Eight data tones means that three data bits are
conveyed by each transmitted information symbol. Sixteen symbol
intervals are devoted to synchronization, so a transmission requires a
total of 206 / 3 + 16 = 85 (rounded up) channel symbols. The sync
symbols are those numbered 1, 2, 5, 10, 16, 23, 33, 35, 51, 52, 55,
60, 66, 73, 83, and 85 in the transmitted sequence. Tone spacing of
the 9-FSK modulation for JT9A is equal to the keying rate, 1.736 Hz.
The total occupied bandwidth is 9 × 1.736 = 15.6 Hz.
[[JT65PRO]]
==== JT65
A detailed description of the JT65 protocol was published in
{jt65protocol} for September-October, 2005. A Reed Solomon (63,12)
error-control code converts 72-bit user messages into sequences of 63
six-bit information-carrying symbols. These are interleaved with
another 63 symbols of synchronizing information according to the
following pseudo-random sequence:
100110001111110101000101100100011100111101101111000110101011001
101010100100000011000000011010010110101010011001001000011111111
The synchronizing tone is normally sent in each interval having a
"`1`" in the sequence. Modulation is 65-FSK at 11025/4096 = 2.692
baud. Frequency spacing between tones is equal to the keying rate for
JT65A, and 2 and 4 times larger for JT65B and JT65C. For EME QSOs the
signal report OOO is sometimes used instead of numerical signal
reports. It is conveyed by reversing sync and data positions in the
transmitted sequence. Shorthand messages for RO, RRR, and 73 dispense
with the sync vector entirely and use time intervals of 16384/11025 =
1.486 s for pairs of alternating tones. The lower frequency is the
same as that of the sync tone used in long messages, and the frequency
separation is 110250/4096 = 26.92 Hz multiplied by n for JT65A, with n
= 2, 3, 4 used to convey the messages RO, RRR, and 73.
[[QRA64_PROTOCOL]]
==== QRA64
QRA64 is intended for EME and other extreme weak-signal applications.
Its internal code was designed by IV3NWV. The protocol uses a (63,12)
**Q**-ary **R**epeat **A**ccumulate code that is inherently better
than the Reed Solomon (63,12) code used in JT65, yielding a 1.3 dB
advantage. A new synchronizing scheme is based on three 7 x 7 Costas
arrays. This change yields another 1.9 dB advantage.
In most respects the current implementation of QRA64 is operationally
similar to JT65. QRA64 does not use two-tone shorthand messages, and
it makes no use of a callsign database. Rather, additional
sensitivity is gained by making use of already known information as a
QSO progresses -- for example, when reports are being exchanged and
you have already decoded both callsigns in a previous transmission.
QRA64 presently offers no message averaging capability, though that
feature may be added. In early tests, many EME QSOs were made using
submodes QRA64A-E on bands from 144 MHz to 24 GHz.
[[SLOW_SUMMARY]]
==== Summary
Table 2 provides a brief summary parameters for the slow modes in
_WSJT-X_. Parameters K and r specify the constraint length and rate
of the convolutional codes; n and k specify the sizes of the
(equivalent) block codes; Q is the alphabet size for the
information-carrying channel symbols; Sync Energy is the fraction of
transmitted energy devoted to synchronizing symbols; and S/N Threshold
is the signal-to-noise ratio (in a 2500 Hz reference bandwidth) above
which the probability of decoding is 50% or higher.
[[SLOW_TAB]]
.Parameters of Slow Modes
[width="90%",cols="3h,^3,^2,^1,^2,^2,^2,^2,^2,^2",frame=topbot,options="header"]
|===============================================================================
|Mode |FEC Type |(n,k) | Q|Modulation type|Keying rate (Baud)|Bandwidth (Hz)
|Sync Energy|Tx Duration (s)|S/N Threshold (dB)
|FT8 |LDPC, r=1/2|(174,87)| 8| 8-FSK| 6.25 | 50.0 | 0.27| 12.6 | -21
|JT4A |K=32, r=1/2|(206,72)| 2| 4-FSK| 4.375| 17.5 | 0.50| 47.1 | -23
|JT9A |K=32, r=1/2|(206,72)| 8| 9-FSK| 1.736| 15.6 | 0.19| 49.0 | -27
|JT65A |Reed Solomon|(63,12) |64|65-FSK| 2.692| 177.6 | 0.50| 46.8 | -25
|QRA64A|Q-ary Repeat Accumulate|(63,12) |64|64-FSK|1.736|111.1|0.25|48.4| -26
| WSPR |K=32, r=1/2|(162,50)| 2| 4-FSK| 1.465| 5.9 | 0.50|110.6 | -28
|===============================================================================
Submodes of JT4, JT9, JT65, and QRA64 offer wider tone spacings for
circumstances that may require them, such significant Doppler spread.
Table 3 summarizes the tone spacings, bandwidths, and approximate
threshold sensitivities of the various submodes when spreading is
comparable to tone spacing.
[[SLOW_SUBMODES]]
.Parameters of Slow Submodes
[width="50%",cols="h,3*^",frame=topbot,options="header"]
|=====================================
|Mode |Tone Spacing |BW (Hz)|S/N (dB)
|FT8 |6.25 | 50.0 |-21
|JT4A |4.375| 17.5 |-23
|JT4B |8.75 | 30.6 |-22
|JT4C |17.5 | 56.9 |-21
|JT4D |39.375| 122.5 |-20
|JT4E |78.75| 240.6 |-19
|JT4F |157.5| 476.9 |-18
|JT4G |315.0| 949.4 |-17
|JT9A |1.736| 15.6 |-27
|JT9B |3.472| 29.5 |-26
|JT9C |6.944| 57.3 |-25
|JT9D |13.889| 112.8 |-24
|JT9E |27.778| 224.0 |-23
|JT9F |55.556| 446.2 |-22
|JT9G |111.111|890.6 |-21
|JT9H |222.222|1779.5|-20
|JT65A |2.692| 177.6 |-25
|JT65B |5.383| 352.6 |-25
|JT65C |10.767| 702.5 |-25
|QRA64A|1.736| 111.1 |-26
|QRA64B|3.472| 220.5 |-25
|QRA64C|6.944| 439.2 |-24
|QRA64D|13.889| 876.7 |-23
|QRA64E|27.778|1751.7 |-22
|=====================================
[[FAST_MODES]]
=== Fast Modes
==== ISCAT
ISCAT messages are free-form, up to 28 characters in length.
Modulation is 42-tone frequency-shift keying at 11025 / 512 = 21.533
baud (ISCAT-A), or 11025 / 256 = 43.066 baud (ISCAT-B). Tone
frequencies are spaced by an amount in Hz equal to the baud rate. The
available character set is:
----
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ /.?@-
----
Transmissions consist of sequences of 24 symbols: a synchronizing
pattern of four symbols at tone numbers 0, 1, 3, and 2, followed by
two symbols with tone number corresponding to (message length) and
(message length + 5), and finally 18 symbols conveying the user's
message, sent repeatedly character by character. The message always
starts with `@`, the beginning-of-message symbol, which is not
displayed to the user. The sync pattern and message-length indicator
have a fixed repetition period, recurring every 24 symbols. Message
information occurs periodically within the 18 symbol positions set
aside for its use, repeating at its own natural length.
For example, consider the user message `CQ WA9XYZ`. Including the
beginning-of-message symbol `@`, the message is 10 characters long.
Using the character sequence displayed above to indicate tone numbers,
the transmitted message will therefore start out as shown in the first
line below:
----
0132AF@CQ WA9XYZ@CQ WA9X0132AFYZ@CQ WA9XYZ@CQ W0132AFA9X ...
sync## sync## sync##
----
Note that the first six symbols (four for sync, two for message
length) repeat every 24 symbols. Within the 18 information-carrying
symbols in each 24, the user message `@CQ WA9XYZ` repeats at its own
natural length, 10 characters. The resulting sequence is extended as
many times as will fit into a Tx sequence.
==== JT9
The JT9 slow modes all use keying rate 12000/6912 = 1.736 baud. By contrast, with
the *Fast* setting submodes JT9E-H adjust the keying rate to match the
increased tone spacings. Message durations are therefore much
shorter, and they are sent repeatedly throughout each Tx sequence.
For details see Table 4, below.
==== MSK144
Standard MSK144 messages are structured in the same way as those in
the slow modes, with 72 bits of user information. Forward error
correction is implemented by first augmenting the 72 message bits with
an 8-bit cyclic redundancy check (CRC) calculated from the message
bits. The CRC is used to detect and eliminate most false decodes at
the receiver. The resulting 80-bit augmented message is mapped to a
128-bit codeword using a (128,80) binary low-density-parity-check
(LDPC) code designed by K9AN specifically for this purpose. Two 8-bit
synchronizing sequences are added to make a message frame 144 bits
long. Modulation is Offset Quadrature Phase-Shift Keying (OQPSK) at
2000 baud. Even-numbered bits are conveyed over the in-phase channel,
odd-numbered bits on the quadrature channel. Individual symbols are
shaped with half-sine profiles, thereby ensuring a generated waveform
with constant envelope, equivalent to a Minimum Shift Keying (MSK)
waveform. Frame duration is 72 ms, so the effective character
transmission rate for standard messages is up to 250 cps.
MSK144 also supports short-form messages that can be used after QSO
partners have exchanged both callsigns. Short messages consist of 4
bits encoding R+report, RRR, or 73, together with a 12-bit hash code
based on the ordered pair of "`to`" and "`from`" callsigns. Another
specially designed LDPC (32,16) code provides error correction, and an
8-bit synchronizing vector is appended to make up a 40-bit frame.
Short-message duration is thus 20 ms, and short messages can be
decoded from very short meteor pings.
The 72 ms or 20 ms frames of MSK144 messages are repeated without gaps
for the full duration of a transmission cycle. For most purposes, a
cycle duration of 15 s is suitable and recommended for MSK144.
The modulated MSK144 signal occupies the full bandwidth of a SSB
transmitter, so transmissions are always centered at audio frequency
1500 Hz. For best results, transmitter and receiver filters should be
adjusted to provide the flattest possible response over the range
300Hz to 2700Hz. The maximum permissible frequency offset between you
and your QSO partner ± 200 Hz.
==== Summary
.Parameters of Fast Modes
[width="90%",cols="3h,^3,^2,^1,^2,^2,^2,^2,^2",frame="topbot",options="header"]
|=====================================================================
|Mode |FEC Type |(n,k) | Q|Modulation Type|Keying rate (Baud)
|Bandwidth (Hz)|Sync Energy|Tx Duration (s)
|ISCAT-A | - | - |42|42-FSK| 21.5 | 905 | 0.17| 1.176
|ISCAT-B | - | - |42|42-FSK| 43.1 | 1809 | 0.17| 0.588
|JT9E |K=32, r=1/2|(206,72)| 8| 9-FSK| 25.0 | 225 | 0.19| 3.400
|JT9F |K=32, r=1/2|(206,72)| 8| 9-FSK| 50.0 | 450 | 0.19| 1.700
|JT9G |K=32, r=1/2|(206,72)| 8| 9-FSK|100.0 | 900 | 0.19| 0.850
|JT9H |K=32, r=1/2|(206,72)| 8| 9-FSK|200.0 | 1800 | 0.19| 0.425
|MSK144 |LDPC |(128,80)| 2| OQPSK| 2000 | 2400 | 0.11| 0.072
|MSK144 Sh|LDPC |(32,16) | 2| OQPSK| 2000 | 2400 | 0.20| 0.020
|=====================================================================
@@ -0,0 +1,41 @@
#ifndef BOOST_MPL_MAP_AUX_ERASE_IMPL_HPP_INCLUDED
#define BOOST_MPL_MAP_AUX_ERASE_IMPL_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/erase_fwd.hpp>
#include <boost/mpl/map/aux_/erase_key_impl.hpp>
#include <boost/mpl/map/aux_/tag.hpp>
namespace boost { namespace mpl {
template<>
struct erase_impl< aux::map_tag >
{
template<
typename Map
, typename Pos
, typename unused_
>
struct apply
: erase_key_impl<aux::map_tag>
::apply<Map,typename Pos::type::first>
{
};
};
}}
#endif // BOOST_MPL_MAP_AUX_ERASE_IMPL_HPP_INCLUDED
@@ -0,0 +1,135 @@
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
#define BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/intrinsics.hpp>
namespace boost{
namespace multi_index{
namespace detail{
/* Metafunction that checks if f(arg,arg2) executes without argument type
* conversion. By default (i.e. when it cannot be determined) it evaluates to
* true.
*/
template<typename F,typename Arg1,typename Arg2,typename=void>
struct is_transparent:mpl::true_{};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_SFINAE_EXPR)&& \
!defined(BOOST_NO_CXX11_DECLTYPE)&& \
(defined(BOOST_NO_CXX11_FINAL)||defined(BOOST_IS_FINAL))
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_final.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/utility/declval.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost{
namespace multi_index{
namespace detail{
struct not_is_transparent_result_type{};
template<typename F,typename Arg1,typename Arg2>
struct is_transparent_class_helper:F
{
using F::operator();
template<typename T,typename Q>
not_is_transparent_result_type operator()(const T&,const Q&)const;
};
template<typename F,typename Arg1,typename Arg2,typename=void>
struct is_transparent_class:mpl::true_{};
template<typename F,typename Arg1,typename Arg2>
struct is_transparent_class<
F,Arg1,Arg2,
typename enable_if<
is_same<
decltype(
declval<const is_transparent_class_helper<F,Arg1,Arg2> >()(
declval<const Arg1&>(),declval<const Arg2&>())
),
not_is_transparent_result_type
>
>::type
>:mpl::false_{};
template<typename F,typename Arg1,typename Arg2>
struct is_transparent<
F,Arg1,Arg2,
typename enable_if<
mpl::and_<
is_class<F>,
mpl::not_<is_final<F> > /* is_transparent_class_helper derives from F */
>
>::type
>:is_transparent_class<F,Arg1,Arg2>{};
template<typename F,typename Arg1,typename Arg2,typename=void>
struct is_transparent_function:mpl::true_{};
template<typename F,typename Arg1,typename Arg2>
struct is_transparent_function<
F,Arg1,Arg2,
typename enable_if<
mpl::or_<
mpl::not_<mpl::or_<
is_same<typename function_traits<F>::arg1_type,const Arg1&>,
is_same<typename function_traits<F>::arg1_type,Arg1>
> >,
mpl::not_<mpl::or_<
is_same<typename function_traits<F>::arg2_type,const Arg2&>,
is_same<typename function_traits<F>::arg2_type,Arg2>
> >
>
>::type
>:mpl::false_{};
template<typename F,typename Arg1,typename Arg2>
struct is_transparent<
F,Arg1,Arg2,
typename enable_if<
is_function<typename remove_pointer<F>::type>
>::type
>:is_transparent_function<typename remove_pointer<F>::type,Arg1,Arg2>{};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
#!/bin/sh
# Copy the LPDC programs to the directory specified. The program file
# might be the name of the program, or (eg, on Cygwin) the name of the
# program with .exe appended.
if [ x$1 == x -o x$2 != x ]; then
echo Usage: LDPC-install bin-directory
exit 1
fi
echo Installing LPDC programs in $1
mkdir -p $1
for prog in make-pchk alist-to-pchk pchk-to-alist \
make-ldpc print-pchk make-gen print-gen \
rand-src encode transmit decode extract verify; do
if [ -f $prog ]; then
cp $prog $1
elif [ -f $prog.exe ]; then
cp $prog.exe $1
else
echo No program $prog to install
fi
done
echo Done
@@ -0,0 +1,47 @@
// boost/detail/bitmask.hpp ------------------------------------------------//
// Copyright Beman Dawes 2006
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
// Usage: enum foo { a=1, b=2, c=4 };
// BOOST_BITMASK( foo );
//
// void f( foo arg );
// ...
// f( a | c );
#ifndef BOOST_BITMASK_HPP
#define BOOST_BITMASK_HPP
#include <boost/cstdint.hpp>
#define BOOST_BITMASK(Bitmask) \
\
inline Bitmask operator| (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
| static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator& (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
& static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator^ (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
^ static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator~ (Bitmask x ) \
{ return static_cast<Bitmask>(~static_cast<boost::int_least32_t>(x)); } \
\
inline Bitmask & operator&=(Bitmask & x , Bitmask y) \
{ x = x & y ; return x ; } \
\
inline Bitmask & operator|=(Bitmask & x , Bitmask y) \
{ x = x | y ; return x ; } \
\
inline Bitmask & operator^=(Bitmask & x , Bitmask y) \
{ x = x ^ y ; return x ; }
#endif // BOOST_BITMASK_HPP
@@ -0,0 +1,34 @@
#ifndef BOOST_MPL_AUX_HAS_KEY_IMPL_HPP_INCLUDED
#define BOOST_MPL_AUX_HAS_KEY_IMPL_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2002-2004
// Copyright David Abrahams 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)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/has_key_fwd.hpp>
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
namespace boost { namespace mpl {
// no default implementation; the definition is needed to make MSVC happy
template< typename Tag > struct has_key_impl
{
template< typename AssociativeSequence, typename Key > struct apply;
};
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2,has_key_impl)
}}
#endif // BOOST_MPL_AUX_HAS_KEY_IMPL_HPP_INCLUDED
@@ -0,0 +1,328 @@
// 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/set_c.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl {
template<
typename T, long C0 = LONG_MAX, long C1 = LONG_MAX, long C2 = LONG_MAX
, long C3 = LONG_MAX, long C4 = LONG_MAX, long C5 = LONG_MAX
, long C6 = LONG_MAX, long C7 = LONG_MAX, long C8 = LONG_MAX
, long C9 = LONG_MAX, long C10 = LONG_MAX, long C11 = LONG_MAX
, long C12 = LONG_MAX, long C13 = LONG_MAX, long C14 = LONG_MAX
, long C15 = LONG_MAX, long C16 = LONG_MAX, long C17 = LONG_MAX
, long C18 = LONG_MAX, long C19 = LONG_MAX
>
struct set_c;
template<
typename T
>
struct set_c<
T, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set0_c<T>
{
typedef typename set0_c<T>::type type;
};
template<
typename T, long C0
>
struct set_c<
T, C0, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set1_c< T,C0 >
{
typedef typename set1_c< T,C0 >::type type;
};
template<
typename T, long C0, long C1
>
struct set_c<
T, C0, C1, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set2_c< T,C0,C1 >
{
typedef typename set2_c< T,C0,C1 >::type type;
};
template<
typename T, long C0, long C1, long C2
>
struct set_c<
T, C0, C1, C2, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set3_c< T,C0,C1,C2 >
{
typedef typename set3_c< T,C0,C1,C2 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3
>
struct set_c<
T, C0, C1, C2, C3, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set4_c< T,C0,C1,C2,C3 >
{
typedef typename set4_c< T,C0,C1,C2,C3 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4
>
struct set_c<
T, C0, C1, C2, C3, C4, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set5_c< T,C0,C1,C2,C3,C4 >
{
typedef typename set5_c< T,C0,C1,C2,C3,C4 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX
>
: set6_c< T,C0,C1,C2,C3,C4,C5 >
{
typedef typename set6_c< T,C0,C1,C2,C3,C4,C5 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX
>
: set7_c< T,C0,C1,C2,C3,C4,C5,C6 >
{
typedef typename set7_c< T,C0,C1,C2,C3,C4,C5,C6 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX
>
: set8_c< T,C0,C1,C2,C3,C4,C5,C6,C7 >
{
typedef typename set8_c< T,C0,C1,C2,C3,C4,C5,C6,C7 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX
>
: set9_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8 >
{
typedef typename set9_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
, LONG_MAX
>
: set10_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9 >
{
typedef typename set10_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, LONG_MAX, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set11_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10 >
{
typedef typename set11_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set12_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11 >
{
typedef typename set12_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, LONG_MAX
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set13_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12 >
{
typedef typename set13_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set14_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13
>
{
typedef typename set14_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set15_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
>
{
typedef typename set15_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14, long C15
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX
>
: set16_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15
>
{
typedef typename set16_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14, long C15, long C16
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, LONG_MAX, LONG_MAX, LONG_MAX
>
: set17_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16
>
{
typedef typename set17_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14, long C15, long C16, long C17
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, C17, LONG_MAX, LONG_MAX
>
: set18_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, C17
>
{
typedef typename set18_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17 >::type type;
};
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14, long C15, long C16, long C17, long C18
>
struct set_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, C17, C18, LONG_MAX
>
: set19_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, C17, C18
>
{
typedef typename set19_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17,C18 >::type type;
};
/// primary template (not a specialization!)
template<
typename T, long C0, long C1, long C2, long C3, long C4, long C5
, long C6, long C7, long C8, long C9, long C10, long C11, long C12
, long C13, long C14, long C15, long C16, long C17, long C18, long C19
>
struct set_c
: set20_c<
T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
, C15, C16, C17, C18, C19
>
{
typedef typename set20_c< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17,C18,C19 >::type type;
};
}}
@@ -0,0 +1,33 @@
#ifndef BOOST_MPL_SET_AUX_SIZE_IMPL_HPP_INCLUDED
#define BOOST_MPL_SET_AUX_SIZE_IMPL_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2003-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/size_fwd.hpp>
#include <boost/mpl/set/aux_/tag.hpp>
namespace boost { namespace mpl {
template<>
struct size_impl< aux::set_tag >
{
template< typename Set > struct apply
: Set::size
{
};
};
}}
#endif // BOOST_MPL_SET_AUX_SIZE_IMPL_HPP_INCLUDED
@@ -0,0 +1,18 @@
/*==============================================================================
Copyright (c) 2001-2010 Joel de Guzman
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)
==============================================================================*/
namespace placeholders
{
typedef expression::argument<1>::type arg1_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<2>::type arg2_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<3>::type arg3_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<4>::type arg4_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<5>::type arg5_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<6>::type arg6_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<7>::type arg7_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<8>::type arg8_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<9>::type arg9_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<10>::type arg10_type BOOST_ATTRIBUTE_UNUSED;
typedef expression::argument<1>::type _1_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<2>::type _2_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<3>::type _3_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<4>::type _4_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<5>::type _5_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<6>::type _6_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<7>::type _7_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<8>::type _8_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<9>::type _9_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<10>::type _10_type BOOST_ATTRIBUTE_UNUSED;
}
namespace arg_names
{
typedef expression::argument<1>::type arg1_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<2>::type arg2_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<3>::type arg3_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<4>::type arg4_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<5>::type arg5_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<6>::type arg6_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<7>::type arg7_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<8>::type arg8_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<9>::type arg9_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<10>::type arg10_type BOOST_ATTRIBUTE_UNUSED;
typedef expression::argument<1>::type _1_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<2>::type _2_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<3>::type _3_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<4>::type _4_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<5>::type _5_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<6>::type _6_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<7>::type _7_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<8>::type _8_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<9>::type _9_type BOOST_ATTRIBUTE_UNUSED; typedef expression::argument<10>::type _10_type BOOST_ATTRIBUTE_UNUSED;
}
@@ -0,0 +1,92 @@
// 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/greater.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl {
template<
typename Tag1
, typename Tag2
>
struct greater_impl
: if_c<
( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
> BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
)
, aux::cast2nd_impl< greater_impl< Tag1,Tag1 >,Tag1, Tag2 >
, aux::cast1st_impl< greater_impl< Tag2,Tag2 >,Tag1, Tag2 >
>::type
{
};
/// for Digital Mars C++/compilers with no CTPS/TTP support
template<> struct greater_impl< na,na >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template< typename Tag > struct greater_impl< na,Tag >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template< typename Tag > struct greater_impl< Tag,na >
{
template< typename U1, typename U2 > struct apply
{
typedef apply type;
BOOST_STATIC_CONSTANT(int, value = 0);
};
};
template< typename T > struct greater_tag
{
typedef typename T::tag type;
};
template<
typename BOOST_MPL_AUX_NA_PARAM(N1)
, typename BOOST_MPL_AUX_NA_PARAM(N2)
>
struct greater
: greater_impl<
typename greater_tag<N1>::type
, typename greater_tag<N2>::type
>::template apply< N1,N2 >::type
{
};
BOOST_MPL_AUX_NA_SPEC2(2, 2, greater)
}}
namespace boost { namespace mpl {
template<>
struct greater_impl< integral_c_tag,integral_c_tag >
{
template< typename N1, typename N2 > struct apply
: bool_< ( BOOST_MPL_AUX_VALUE_WKND(N1)::value > BOOST_MPL_AUX_VALUE_WKND(N2)::value ) >
{
};
};
}}
@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2001-2007 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_INCLUDE_VECTOR20)
#define FUSION_INCLUDE_VECTOR20
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/vector/vector20.hpp>
#endif
@@ -0,0 +1,140 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_RANDOM_NORMAL_DISTRIBUTION_HPP
#define BOOST_COMPUTE_RANDOM_NORMAL_DISTRIBUTION_HPP
#include <limits>
#include <boost/assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/function.hpp>
#include <boost/compute/types/fundamental.hpp>
#include <boost/compute/type_traits/make_vector_type.hpp>
namespace boost {
namespace compute {
/// \class normal_distribution
/// \brief Produces random, normally-distributed floating-point numbers.
///
/// The following example shows how to setup a normal distribution to
/// produce random \c float values centered at \c 5:
///
/// \snippet test/test_normal_distribution.cpp generate
///
/// \see default_random_engine, uniform_real_distribution
template<class RealType = float>
class normal_distribution
{
public:
typedef RealType result_type;
/// Creates a new normal distribution producing numbers with the given
/// \p mean and \p stddev.
normal_distribution(RealType mean = 0.f, RealType stddev = 1.f)
: m_mean(mean),
m_stddev(stddev)
{
}
/// Destroys the normal distribution object.
~normal_distribution()
{
}
/// Returns the mean value of the distribution.
result_type mean() const
{
return m_mean;
}
/// Returns the standard-deviation of the distribution.
result_type stddev() const
{
return m_stddev;
}
/// Returns the minimum value of the distribution.
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return -std::numeric_limits<RealType>::infinity();
}
/// Returns the maximum value of the distribution.
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return std::numeric_limits<RealType>::infinity();
}
/// Generates normally-distributed floating-point numbers and stores
/// them to the range [\p first, \p last).
template<class OutputIterator, class Generator>
void generate(OutputIterator first,
OutputIterator last,
Generator &generator,
command_queue &queue)
{
typedef typename make_vector_type<RealType, 2>::type RealType2;
size_t count = detail::iterator_range_size(first, last);
vector<uint_> tmp(count, queue.get_context());
generator.generate(tmp.begin(), tmp.end(), queue);
BOOST_COMPUTE_FUNCTION(RealType2, box_muller, (const uint2_ x),
{
const RealType one = 1;
const RealType two = 2;
// Use nextafter to push values down into [0,1) range; without this, floating point rounding can
// lead to have x1 = 1, but that would lead to taking the log of 0, which would result in negative
// infinities; by pushing the values off 1 towards 0, we ensure this won't happen.
const RealType x1 = nextafter(x.x / (RealType) UINT_MAX, (RealType) 0);
const RealType x2 = x.y / (RealType) UINT_MAX;
const RealType rho = sqrt(-two * log(one-x1));
const RealType z1 = rho * cos(two * M_PI_F * x2);
const RealType z2 = rho * sin(two * M_PI_F * x2);
return (RealType2)(MEAN, MEAN) + (RealType2)(z1, z2) * (RealType2)(STDDEV, STDDEV);
});
box_muller.define("MEAN", boost::lexical_cast<std::string>(m_mean));
box_muller.define("STDDEV", boost::lexical_cast<std::string>(m_stddev));
box_muller.define("RealType", type_name<RealType>());
box_muller.define("RealType2", type_name<RealType2>());
transform(
make_buffer_iterator<uint2_>(tmp.get_buffer(), 0),
make_buffer_iterator<uint2_>(tmp.get_buffer(), count / 2),
make_buffer_iterator<RealType2>(first.get_buffer(), 0),
box_muller,
queue
);
}
private:
RealType m_mean;
RealType m_stddev;
BOOST_STATIC_ASSERT_MSG(
boost::is_floating_point<RealType>::value,
"Template argument must be a floating point type"
);
};
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_RANDOM_NORMAL_DISTRIBUTION_HPP