Initial Commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & 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.
|
||||
//
|
||||
// defines traits classes for transforming one type to another:
|
||||
// remove_reference, add_reference, remove_bounds, remove_pointer.
|
||||
//
|
||||
|
||||
#ifndef BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/add_pointer.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/remove_bounds.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
#endif // BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef PYOBJECT_TRAITS_DWA2002720_HPP
|
||||
# define PYOBJECT_TRAITS_DWA2002720_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/python/converter/pyobject_type.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
template <class> struct pyobject_traits;
|
||||
|
||||
template <>
|
||||
struct pyobject_traits<PyObject>
|
||||
{
|
||||
// All objects are convertible to PyObject
|
||||
static bool check(PyObject*) { return true; }
|
||||
static PyObject* checked_downcast(PyObject* x) { return x; }
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
static PyTypeObject const* get_pytype() { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// Specializations
|
||||
//
|
||||
|
||||
# define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \
|
||||
template <> struct pyobject_traits<Py##T##Object> \
|
||||
: pyobject_type<Py##T##Object, &Py##T##_Type> {}
|
||||
|
||||
// This is not an exhaustive list; should be expanded.
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
|
||||
#endif
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
|
||||
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
|
||||
|
||||
}}} // namespace boost::python::converter
|
||||
|
||||
#endif // PYOBJECT_TRAITS_DWA2002720_HPP
|
||||
@@ -0,0 +1,325 @@
|
||||
// Boost Lambda Library ret.hpp -----------------------------------------
|
||||
|
||||
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// For more information, see www.boost.org
|
||||
|
||||
|
||||
#ifndef BOOST_LAMBDA_RET_HPP
|
||||
#define BOOST_LAMBDA_RET_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace lambda {
|
||||
|
||||
// TODO:
|
||||
|
||||
// Add specializations for function references for ret, protect and unlambda
|
||||
// e.g void foo(); unlambda(foo); fails, as it would add a const qualifier
|
||||
// for a function type.
|
||||
// on the other hand unlambda(*foo) does work
|
||||
|
||||
|
||||
// -- ret -------------------------
|
||||
// the explicit return type template
|
||||
|
||||
// TODO: It'd be nice to make ret a nop for other than lambda functors
|
||||
// but causes an ambiguiyty with gcc (not with KCC), check what is the
|
||||
// right interpretation.
|
||||
|
||||
// // ret for others than lambda functors has no effect
|
||||
// template <class U, class T>
|
||||
// inline const T& ret(const T& t) { return t; }
|
||||
|
||||
|
||||
template<class RET, class Arg>
|
||||
inline const
|
||||
lambda_functor<
|
||||
lambda_functor_base<
|
||||
explicit_return_type_action<RET>,
|
||||
tuple<lambda_functor<Arg> >
|
||||
>
|
||||
>
|
||||
ret(const lambda_functor<Arg>& a1)
|
||||
{
|
||||
return
|
||||
lambda_functor_base<
|
||||
explicit_return_type_action<RET>,
|
||||
tuple<lambda_functor<Arg> >
|
||||
>
|
||||
(tuple<lambda_functor<Arg> >(a1));
|
||||
}
|
||||
|
||||
// protect ------------------
|
||||
|
||||
// protecting others than lambda functors has no effect
|
||||
template <class T>
|
||||
inline const T& protect(const T& t) { return t; }
|
||||
|
||||
template<class Arg>
|
||||
inline const
|
||||
lambda_functor<
|
||||
lambda_functor_base<
|
||||
protect_action,
|
||||
tuple<lambda_functor<Arg> >
|
||||
>
|
||||
>
|
||||
protect(const lambda_functor<Arg>& a1)
|
||||
{
|
||||
return
|
||||
lambda_functor_base<
|
||||
protect_action,
|
||||
tuple<lambda_functor<Arg> >
|
||||
>
|
||||
(tuple<lambda_functor<Arg> >(a1));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Hides the lambda functorness of a lambda functor.
|
||||
// After this, the functor is immune to argument substitution, etc.
|
||||
// This can be used, e.g. to make it safe to pass lambda functors as
|
||||
// arguments to functions, which might use them as target functions
|
||||
|
||||
// note, unlambda and protect are different things. Protect hides the lambda
|
||||
// functor for one application, unlambda for good.
|
||||
|
||||
template <class LambdaFunctor>
|
||||
class non_lambda_functor
|
||||
{
|
||||
LambdaFunctor lf;
|
||||
public:
|
||||
|
||||
// This functor defines the result_type typedef.
|
||||
// The result type must be deducible without knowing the arguments
|
||||
|
||||
template <class SigArgs> struct sig {
|
||||
typedef typename
|
||||
LambdaFunctor::inherited::
|
||||
template sig<typename SigArgs::tail_type>::type type;
|
||||
};
|
||||
|
||||
explicit non_lambda_functor(const LambdaFunctor& a) : lf(a) {}
|
||||
|
||||
typename LambdaFunctor::nullary_return_type
|
||||
operator()() const {
|
||||
return lf.template
|
||||
call<typename LambdaFunctor::nullary_return_type>
|
||||
(cnull_type(), cnull_type(), cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A>
|
||||
typename sig<tuple<const non_lambda_functor, A&> >::type
|
||||
operator()(A& a) const {
|
||||
return lf.template call<typename sig<tuple<const non_lambda_functor, A&> >::type >(a, cnull_type(), cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B>
|
||||
typename sig<tuple<const non_lambda_functor, A&, B&> >::type
|
||||
operator()(A& a, B& b) const {
|
||||
return lf.template call<typename sig<tuple<const non_lambda_functor, A&, B&> >::type >(a, b, cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B, class C>
|
||||
typename sig<tuple<const non_lambda_functor, A&, B&, C&> >::type
|
||||
operator()(A& a, B& b, C& c) const {
|
||||
return lf.template call<typename sig<tuple<const non_lambda_functor, A&, B&, C&> >::type>(a, b, c, cnull_type());
|
||||
}
|
||||
};
|
||||
|
||||
template <class Arg>
|
||||
inline const Arg& unlambda(const Arg& a) { return a; }
|
||||
|
||||
template <class Arg>
|
||||
inline const non_lambda_functor<lambda_functor<Arg> >
|
||||
unlambda(const lambda_functor<Arg>& a)
|
||||
{
|
||||
return non_lambda_functor<lambda_functor<Arg> >(a);
|
||||
}
|
||||
|
||||
// Due to a language restriction, lambda functors cannot be made to
|
||||
// accept non-const rvalue arguments. Usually iterators do not return
|
||||
// temporaries, but sometimes they do. That's why a workaround is provided.
|
||||
// Note, that this potentially breaks const correctness, so be careful!
|
||||
|
||||
// any lambda functor can be turned into a const_incorrect_lambda_functor
|
||||
// The operator() takes arguments as consts and then casts constness
|
||||
// away. So this breaks const correctness!!! but is a necessary workaround
|
||||
// in some cases due to language limitations.
|
||||
// Note, that this is not a lambda_functor anymore, so it can not be used
|
||||
// as a sub lambda expression.
|
||||
|
||||
template <class LambdaFunctor>
|
||||
struct const_incorrect_lambda_functor {
|
||||
LambdaFunctor lf;
|
||||
public:
|
||||
|
||||
explicit const_incorrect_lambda_functor(const LambdaFunctor& a) : lf(a) {}
|
||||
|
||||
template <class SigArgs> struct sig {
|
||||
typedef typename
|
||||
LambdaFunctor::inherited::template
|
||||
sig<typename SigArgs::tail_type>::type type;
|
||||
};
|
||||
|
||||
// The nullary case is not needed (no arguments, no parameter type problems)
|
||||
|
||||
template<class A>
|
||||
typename sig<tuple<const const_incorrect_lambda_functor, A&> >::type
|
||||
operator()(const A& a) const {
|
||||
return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&> >::type >(const_cast<A&>(a), cnull_type(), cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B>
|
||||
typename sig<tuple<const const_incorrect_lambda_functor, A&, B&> >::type
|
||||
operator()(const A& a, const B& b) const {
|
||||
return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&, B&> >::type >(const_cast<A&>(a), const_cast<B&>(b), cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B, class C>
|
||||
typename sig<tuple<const const_incorrect_lambda_functor, A&, B&, C&> >::type
|
||||
operator()(const A& a, const B& b, const C& c) const {
|
||||
return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&, B&, C&> >::type>(const_cast<A&>(a), const_cast<B&>(b), const_cast<C&>(c), cnull_type());
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// any lambda functor can be turned into a const_parameter_lambda_functor
|
||||
// The operator() takes arguments as const.
|
||||
// This is useful if lambda functors are called with non-const rvalues.
|
||||
// Note, that this is not a lambda_functor anymore, so it can not be used
|
||||
// as a sub lambda expression.
|
||||
|
||||
template <class LambdaFunctor>
|
||||
struct const_parameter_lambda_functor {
|
||||
LambdaFunctor lf;
|
||||
public:
|
||||
|
||||
explicit const_parameter_lambda_functor(const LambdaFunctor& a) : lf(a) {}
|
||||
|
||||
template <class SigArgs> struct sig {
|
||||
typedef typename
|
||||
LambdaFunctor::inherited::template
|
||||
sig<typename SigArgs::tail_type>::type type;
|
||||
};
|
||||
|
||||
// The nullary case is not needed: no arguments, no constness problems.
|
||||
|
||||
template<class A>
|
||||
typename sig<tuple<const const_parameter_lambda_functor, const A&> >::type
|
||||
operator()(const A& a) const {
|
||||
return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&> >::type >(a, cnull_type(), cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B>
|
||||
typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&> >::type
|
||||
operator()(const A& a, const B& b) const {
|
||||
return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&> >::type >(a, b, cnull_type(), cnull_type());
|
||||
}
|
||||
|
||||
template<class A, class B, class C>
|
||||
typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&, const C&>
|
||||
>::type
|
||||
operator()(const A& a, const B& b, const C& c) const {
|
||||
return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&, const C&> >::type>(a, b, c, cnull_type());
|
||||
}
|
||||
};
|
||||
|
||||
template <class Arg>
|
||||
inline const const_incorrect_lambda_functor<lambda_functor<Arg> >
|
||||
break_const(const lambda_functor<Arg>& lf)
|
||||
{
|
||||
return const_incorrect_lambda_functor<lambda_functor<Arg> >(lf);
|
||||
}
|
||||
|
||||
|
||||
template <class Arg>
|
||||
inline const const_parameter_lambda_functor<lambda_functor<Arg> >
|
||||
const_parameters(const lambda_functor<Arg>& lf)
|
||||
{
|
||||
return const_parameter_lambda_functor<lambda_functor<Arg> >(lf);
|
||||
}
|
||||
|
||||
// make void ------------------------------------------------
|
||||
// make_void( x ) turns a lambda functor x with some return type y into
|
||||
// another lambda functor, which has a void return type
|
||||
// when called, the original return type is discarded
|
||||
|
||||
// we use this action. The action class will be called, which means that
|
||||
// the wrapped lambda functor is evaluated, but we just don't do anything
|
||||
// with the result.
|
||||
struct voidifier_action {
|
||||
template<class Ret, class A> static void apply(A&) {}
|
||||
};
|
||||
|
||||
template<class Args> struct return_type_N<voidifier_action, Args> {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class Arg1>
|
||||
inline const
|
||||
lambda_functor<
|
||||
lambda_functor_base<
|
||||
action<1, voidifier_action>,
|
||||
tuple<lambda_functor<Arg1> >
|
||||
>
|
||||
>
|
||||
make_void(const lambda_functor<Arg1>& a1) {
|
||||
return
|
||||
lambda_functor_base<
|
||||
action<1, voidifier_action>,
|
||||
tuple<lambda_functor<Arg1> >
|
||||
>
|
||||
(tuple<lambda_functor<Arg1> > (a1));
|
||||
}
|
||||
|
||||
// for non-lambda functors, make_void does nothing
|
||||
// (the argument gets evaluated immediately)
|
||||
|
||||
template<class Arg1>
|
||||
inline const
|
||||
lambda_functor<
|
||||
lambda_functor_base<do_nothing_action, null_type>
|
||||
>
|
||||
make_void(const Arg1&) {
|
||||
return
|
||||
lambda_functor_base<do_nothing_action, null_type>();
|
||||
}
|
||||
|
||||
// std_functor -----------------------------------------------------
|
||||
|
||||
// The STL uses the result_type typedef as the convention to let binders know
|
||||
// the return type of a function object.
|
||||
// LL uses the sig template.
|
||||
// To let LL know that the function object has the result_type typedef
|
||||
// defined, it can be wrapped with the std_functor function.
|
||||
|
||||
|
||||
// Just inherit form the template parameter (the standard functor),
|
||||
// and provide a sig template. So we have a class which is still the
|
||||
// same functor + the sig template.
|
||||
|
||||
template<class T>
|
||||
struct result_type_to_sig : public T {
|
||||
template<class Args> struct sig { typedef typename T::result_type type; };
|
||||
result_type_to_sig(const T& t) : T(t) {}
|
||||
};
|
||||
|
||||
template<class F>
|
||||
inline result_type_to_sig<F> std_functor(const F& f) { return f; }
|
||||
|
||||
|
||||
} // namespace lambda
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright Rene Rivera 2008-2015
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_PREDEF_COMPILER_IBM_H
|
||||
#define BOOST_PREDEF_COMPILER_IBM_H
|
||||
|
||||
#include <boost/predef/version_number.h>
|
||||
#include <boost/predef/make.h>
|
||||
|
||||
/*`
|
||||
[heading `BOOST_COMP_IBM`]
|
||||
|
||||
[@http://en.wikipedia.org/wiki/VisualAge IBM XL C/C++] compiler.
|
||||
Version number available as major, minor, and patch.
|
||||
|
||||
[table
|
||||
[[__predef_symbol__] [__predef_version__]]
|
||||
|
||||
[[`__IBMCPP__`] [__predef_detection__]]
|
||||
[[`__xlC__`] [__predef_detection__]]
|
||||
[[`__xlc__`] [__predef_detection__]]
|
||||
|
||||
[[`__COMPILER_VER__`] [V.R.P]]
|
||||
[[`__xlC__`] [V.R.P]]
|
||||
[[`__xlc__`] [V.R.P]]
|
||||
[[`__IBMCPP__`] [V.R.P]]
|
||||
]
|
||||
*/
|
||||
|
||||
#define BOOST_COMP_IBM BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||
|
||||
#if defined(__IBMCPP__) || defined(__xlC__) || defined(__xlc__)
|
||||
# if !defined(BOOST_COMP_IBM_DETECTION) && defined(__COMPILER_VER__)
|
||||
# define BOOST_COMP_IBM_DETECTION BOOST_PREDEF_MAKE_0X_VRRPPPP(__COMPILER_VER__)
|
||||
# endif
|
||||
# if !defined(BOOST_COMP_IBM_DETECTION) && defined(__xlC__)
|
||||
# define BOOST_COMP_IBM_DETECTION BOOST_PREDEF_MAKE_0X_VVRR(__xlC__)
|
||||
# endif
|
||||
# if !defined(BOOST_COMP_IBM_DETECTION) && defined(__xlc__)
|
||||
# define BOOST_COMP_IBM_DETECTION BOOST_PREDEF_MAKE_0X_VVRR(__xlc__)
|
||||
# endif
|
||||
# if !defined(BOOST_COMP_IBM_DETECTION)
|
||||
# define BOOST_COMP_IBM_DETECTION BOOST_PREDEF_MAKE_10_VRP(__IBMCPP__)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_COMP_IBM_DETECTION
|
||||
# if defined(BOOST_PREDEF_DETAIL_COMP_DETECTED)
|
||||
# define BOOST_COMP_IBM_EMULATED BOOST_COMP_IBM_DETECTION
|
||||
# else
|
||||
# undef BOOST_COMP_IBM
|
||||
# define BOOST_COMP_IBM BOOST_COMP_IBM_DETECTION
|
||||
# endif
|
||||
# define BOOST_COMP_IBM_AVAILABLE
|
||||
# include <boost/predef/detail/comp_detected.h>
|
||||
#endif
|
||||
|
||||
#define BOOST_COMP_IBM_NAME "IBM XL C/C++"
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_IBM,BOOST_COMP_IBM_NAME)
|
||||
|
||||
#ifdef BOOST_COMP_IBM_EMULATED
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_IBM_EMULATED,BOOST_COMP_IBM_NAME)
|
||||
#endif
|
||||
@@ -0,0 +1,177 @@
|
||||
#ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
|
||||
#define BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// yield_k.hpp
|
||||
//
|
||||
// Copyright (c) 2008 Peter Dimov
|
||||
// Copyright (c) Microsoft Corporation 2014
|
||||
//
|
||||
// void yield( unsigned k );
|
||||
//
|
||||
// Typical use:
|
||||
//
|
||||
// for( unsigned k = 0; !try_lock(); ++k ) yield( k );
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#if BOOST_PLAT_WINDOWS_RUNTIME
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
// BOOST_SMT_PAUSE
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) )
|
||||
|
||||
extern "C" void _mm_pause();
|
||||
|
||||
#define BOOST_SMT_PAUSE _mm_pause();
|
||||
|
||||
#elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
|
||||
|
||||
#define BOOST_SMT_PAUSE __asm__ __volatile__( "rep; nop" : : : "memory" );
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
|
||||
|
||||
#if defined( BOOST_USE_WINDOWS_H )
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
|
||||
#if !BOOST_COMP_CLANG || !defined __MINGW32__
|
||||
extern "C" void __stdcall Sleep( unsigned long ms );
|
||||
#else
|
||||
#include <_mingw.h>
|
||||
#if !defined __MINGW64_VERSION_MAJOR
|
||||
extern "C" void __stdcall Sleep( unsigned long ms );
|
||||
#else
|
||||
extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long ms );
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inline void yield( unsigned k )
|
||||
{
|
||||
if( k < 4 )
|
||||
{
|
||||
}
|
||||
#if defined( BOOST_SMT_PAUSE )
|
||||
else if( k < 16 )
|
||||
{
|
||||
BOOST_SMT_PAUSE
|
||||
}
|
||||
#endif
|
||||
#if !BOOST_PLAT_WINDOWS_RUNTIME
|
||||
else if( k < 32 )
|
||||
{
|
||||
Sleep( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep( 1 );
|
||||
}
|
||||
#else
|
||||
else
|
||||
{
|
||||
// Sleep isn't supported on the Windows Runtime.
|
||||
std::this_thread::yield();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#elif defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
#ifndef _AIX
|
||||
#include <sched.h>
|
||||
#else
|
||||
// AIX's sched.h defines ::var which sometimes conflicts with Lambda's var
|
||||
extern "C" int sched_yield(void);
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void yield( unsigned k )
|
||||
{
|
||||
if( k < 4 )
|
||||
{
|
||||
}
|
||||
#if defined( BOOST_SMT_PAUSE )
|
||||
else if( k < 16 )
|
||||
{
|
||||
BOOST_SMT_PAUSE
|
||||
}
|
||||
#endif
|
||||
else if( k < 32 || k & 1 )
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
else
|
||||
{
|
||||
// g++ -Wextra warns on {} or {0}
|
||||
struct timespec rqtp = { 0, 0 };
|
||||
|
||||
// POSIX says that timespec has tv_sec and tv_nsec
|
||||
// But it doesn't guarantee order or placement
|
||||
|
||||
rqtp.tv_sec = 0;
|
||||
rqtp.tv_nsec = 1000;
|
||||
|
||||
nanosleep( &rqtp, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void yield( unsigned )
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
|
||||
@@ -0,0 +1,55 @@
|
||||
// get_thread_times.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_THREAD_TIMES_HPP
|
||||
#define BOOST_DETAIL_WINAPI_GET_THREAD_TIMES_HPP
|
||||
|
||||
#include <boost/detail/winapi/basic_types.hpp>
|
||||
#include <boost/detail/winapi/time.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_USE_WINDOWS_H )
|
||||
extern "C" {
|
||||
BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
|
||||
GetThreadTimes(
|
||||
boost::detail::winapi::HANDLE_ hThread,
|
||||
::_FILETIME* lpCreationTime,
|
||||
::_FILETIME* lpExitTime,
|
||||
::_FILETIME* lpKernelTime,
|
||||
::_FILETIME* lpUserTime);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace winapi {
|
||||
|
||||
BOOST_FORCEINLINE BOOL_ GetThreadTimes(
|
||||
HANDLE_ hThread,
|
||||
LPFILETIME_ lpCreationTime,
|
||||
LPFILETIME_ lpExitTime,
|
||||
LPFILETIME_ lpKernelTime,
|
||||
LPFILETIME_ lpUserTime)
|
||||
{
|
||||
return ::GetThreadTimes(
|
||||
hThread,
|
||||
reinterpret_cast< ::_FILETIME* >(lpCreationTime),
|
||||
reinterpret_cast< ::_FILETIME* >(lpExitTime),
|
||||
reinterpret_cast< ::_FILETIME* >(lpKernelTime),
|
||||
reinterpret_cast< ::_FILETIME* >(lpUserTime));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOOST_DETAIL_WINAPI_GET_THREAD_TIMES_HPP
|
||||
@@ -0,0 +1,187 @@
|
||||
program chkfft
|
||||
|
||||
! Tests and times one-dimensional FFTs computed by FFTW3
|
||||
use FFTW3
|
||||
parameter (NMAX=8*1024*1024) !Maximum FFT length
|
||||
complex a(NMAX),b(NMAX),c(NMAX)
|
||||
real ar(NMAX),br(NMAX),cr(NMAX)
|
||||
real mflops
|
||||
integer*8 plan1,plan2 !Pointers to stored plans
|
||||
character infile*12,arg*8
|
||||
logical list
|
||||
common/patience/npatience
|
||||
equivalence (a,ar),(b,br),(c,cr)
|
||||
! include 'fftw3.f90' !FFTW definitions
|
||||
|
||||
nargs=iargc()
|
||||
if(nargs.ne.6) then
|
||||
print*,'Usage: chkfft <nfft | infile> nr nw nc np inplace'
|
||||
print*,' nfft: length of FFT'
|
||||
print*,' nfft=0: do lengths 2^n, n=2^4 to 2^23'
|
||||
print*,' infile: name of file with nfft values, one per line'
|
||||
print*,' nr: 0/1 to not read (or read) wisdom'
|
||||
print*,' nw: 0/1 to not write (or write) wisdom'
|
||||
print*,' nc: 0/1 for real or complex data'
|
||||
print*,' np: 0-4 patience for finding best algorithm'
|
||||
print*,' inplace: 1 for inplace, 0 otherwise'
|
||||
go to 999
|
||||
endif
|
||||
|
||||
list=.false.
|
||||
nfft=-1
|
||||
call getarg(1,infile)
|
||||
open(10,file=infile,status='old',err=1)
|
||||
list=.true. !A valid file name was provided
|
||||
go to 2
|
||||
1 read(infile,*) nfft !Take first argument to be nfft
|
||||
2 call getarg(2,arg)
|
||||
read(arg,*) nr
|
||||
call getarg(3,arg)
|
||||
read(arg,*) nw
|
||||
call getarg(4,arg)
|
||||
read(arg,*) ncomplex
|
||||
call getarg(5,arg)
|
||||
read(arg,*) npatience
|
||||
call getarg(6,arg)
|
||||
read(arg,*) inplace
|
||||
|
||||
if(list) write(*,1000) infile,nr,nw,ncomplex,npatience
|
||||
1000 format(/'infile: ',a12,' nr:',i2,' nw',i2,' nc:',i2,' np:',i2/)
|
||||
if(.not.list) write(*,1002) nfft,nr,nw,ncomplex,npatience
|
||||
1002 format(/'nfft: ',i10,' nr:',i2,' nw',i2,' nc:',i2,' np:',i2/)
|
||||
|
||||
nflags=FFTW_ESTIMATE
|
||||
if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT
|
||||
if(npatience.eq.2) nflags=FFTW_MEASURE
|
||||
if(npatience.eq.3) nflags=FFTW_PATIENT
|
||||
if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE
|
||||
|
||||
open(12,file='chkfft.out',status='unknown')
|
||||
open(13,file='fftwf_wisdom.dat',status='unknown')
|
||||
|
||||
if(nr.ne.0) then
|
||||
call import_wisdom_from_file(isuccess,13)
|
||||
if(isuccess.eq.0) then
|
||||
write(*,1010)
|
||||
1010 format('Failed to import FFTW wisdom.')
|
||||
go to 999
|
||||
endif
|
||||
endif
|
||||
|
||||
idum=-1 !Set random seed
|
||||
ndim=1 !One-dimensional transforms
|
||||
do i=1,NMAX !Set random data
|
||||
x=gran()
|
||||
y=gran()
|
||||
b(i)=cmplx(x,y) !Generate random data
|
||||
enddo
|
||||
|
||||
iters=1000000
|
||||
if(list .or. (nfft.gt.0)) then
|
||||
n1=1
|
||||
n2=1
|
||||
if(nfft.eq.-1) n2=999999
|
||||
write(*,1020)
|
||||
1020 format(' NFFT Time rms MHz MFlops iters', &
|
||||
' tplan'/61('-'))
|
||||
else
|
||||
n1=4
|
||||
n2=23
|
||||
write(*,1030)
|
||||
1030 format(' n N=2^n Time rms MHz MFlops iters', &
|
||||
' tplan'/63('-'))
|
||||
endif
|
||||
|
||||
do ii=n1,n2 !Test one or more FFT lengths
|
||||
if(list) then
|
||||
read(10,*,end=900) nfft !Read nfft from file
|
||||
else if(n2.gt.n1) then
|
||||
nfft=2**ii !Do powers of 2
|
||||
endif
|
||||
|
||||
iformf=1
|
||||
iformb=1
|
||||
if(ncomplex.eq.0) then
|
||||
iformf=0 !Real-to-complex transform
|
||||
iformb=-1 !Complex-to-real (inverse) transform
|
||||
endif
|
||||
|
||||
if(nfft.gt.NMAX) go to 900
|
||||
a(1:nfft)=b(1:nfft) !Copy test data into a()
|
||||
t0=second()
|
||||
if(inplace.ne.0) then
|
||||
if(ncomplex.ne.0) then
|
||||
call sfftw_plan_dft_1d(plan1,nfft,a,a,FFTW_FORWARD,nflags)
|
||||
call sfftw_plan_dft_1d(plan2,nfft,a,a,FFTW_BACKWARD,nflags)
|
||||
else
|
||||
call sfftw_plan_dft_r2c_1d(plan1,nfft,a,a,nflags)
|
||||
call sfftw_plan_dft_c2r_1d(plan2,nfft,a,a,nflags)
|
||||
endif
|
||||
else
|
||||
if(ncomplex.ne.0) then
|
||||
call sfftw_plan_dft_1d(plan1,nfft,a,c,FFTW_FORWARD,nflags)
|
||||
call sfftw_plan_dft_1d(plan2,nfft,c,a,FFTW_BACKWARD,nflags)
|
||||
else
|
||||
call sfftw_plan_dft_r2c_1d(plan1,nfft,a,c,nflags)
|
||||
call sfftw_plan_dft_c2r_1d(plan2,nfft,c,a,nflags)
|
||||
endif
|
||||
endif
|
||||
|
||||
t2=second()
|
||||
tplan=t2-t0 !Total planning time for this length
|
||||
|
||||
total=0.
|
||||
do iter=1,iters !Now do many iterations
|
||||
a(1:nfft)=b(1:nfft) !Copy test data into a()
|
||||
t0=second()
|
||||
call sfftw_execute(plan1)
|
||||
call sfftw_execute(plan2)
|
||||
t1=second()
|
||||
total=total+t1-t0
|
||||
if(total.ge.1.0) go to 40 !Cut iterations short if t>1 s
|
||||
enddo
|
||||
iter=iters
|
||||
|
||||
40 time=0.5*total/iter !Time for one FFT of current length
|
||||
tplan=0.5*tplan-time !Planning time for one FFT
|
||||
if(tplan.lt.0) tplan=0.
|
||||
a(1:nfft)=a(1:nfft)/nfft
|
||||
|
||||
! Compute RMS difference between original array and back-transformed array.
|
||||
sq=0.
|
||||
if(ncomplex.eq.1) then
|
||||
do i=1,nfft
|
||||
sq=sq + real(a(i)-b(i))**2 + imag(a(i)-b(i))**2
|
||||
enddo
|
||||
else
|
||||
do i=1,nfft
|
||||
sq=sq + (ar(i)-br(i))**2
|
||||
enddo
|
||||
endif
|
||||
rms=sqrt(sq/nfft)
|
||||
|
||||
freq=1.e-6*nfft/time
|
||||
mflops=5.0/(1.e6*time/(nfft*log(float(nfft))/log(2.0)))
|
||||
if(n2.eq.1 .or. n2.eq.999999) then
|
||||
write(*,1050) nfft,time,rms,freq,mflops,iter,tplan
|
||||
write(12,1050) nfft,time,rms,freq,mflops,iter,tplan
|
||||
1050 format(i8,f11.7,f12.8,f7.2,f8.1,i8,f6.1)
|
||||
else
|
||||
write(*,1060) ii,nfft,time,rms,freq,mflops,iter,tplan
|
||||
write(12,1060) ii,nfft,time,rms,freq,mflops,iter,tplan
|
||||
1060 format(i2,i8,f11.7,f12.8,f7.2,f8.1,i8,f6.1)
|
||||
endif
|
||||
enddo
|
||||
|
||||
900 continue
|
||||
if(nw.eq.1) then
|
||||
rewind 13
|
||||
call export_wisdom_to_file(13)
|
||||
! write(*,1070)
|
||||
!1070 format(/'Exported FFTW wisdom')
|
||||
endif
|
||||
|
||||
call sfftw_destroy_plan(plan1)
|
||||
call sfftw_destroy_plan(plan2)
|
||||
|
||||
999 end program chkfft
|
||||
@@ -0,0 +1,144 @@
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// Copyright David Abrahams 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)
|
||||
#ifndef OVERRIDE_DWA2004721_HPP
|
||||
# define OVERRIDE_DWA2004721_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/converter/return_from_python.hpp>
|
||||
|
||||
# include <boost/python/extract.hpp>
|
||||
# include <boost/python/handle.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/debug/line.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
# include <boost/type.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
class override;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
class wrapper_base;
|
||||
|
||||
// The result of calling a method.
|
||||
class method_result
|
||||
{
|
||||
private:
|
||||
friend class boost::python::override;
|
||||
explicit method_result(PyObject* x)
|
||||
: m_obj(x)
|
||||
{}
|
||||
|
||||
public:
|
||||
template <class T>
|
||||
operator T()
|
||||
{
|
||||
converter::return_from_python<T> converter;
|
||||
return converter(m_obj.release());
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(140050215))
|
||||
template <class T>
|
||||
operator T*()
|
||||
{
|
||||
converter::return_from_python<T*> converter;
|
||||
return converter(m_obj.release());
|
||||
}
|
||||
# endif
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) || BOOST_WORKAROUND(BOOST_INTEL_WIN, >= 900)
|
||||
// No operator T&
|
||||
# else
|
||||
|
||||
template <class T>
|
||||
operator T&() const
|
||||
{
|
||||
converter::return_from_python<T&> converter;
|
||||
return converter(const_cast<handle<>&>(m_obj).release());
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class T>
|
||||
T as(type<T>* = 0)
|
||||
{
|
||||
converter::return_from_python<T> converter;
|
||||
return converter(m_obj.release());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T unchecked(type<T>* = 0)
|
||||
{
|
||||
return extract<T>(m_obj.get())();
|
||||
}
|
||||
private:
|
||||
mutable handle<> m_obj;
|
||||
};
|
||||
}
|
||||
|
||||
class override : public object
|
||||
{
|
||||
private:
|
||||
friend class detail::wrapper_base;
|
||||
override(handle<> x)
|
||||
: object(x)
|
||||
{}
|
||||
|
||||
public:
|
||||
detail::method_result
|
||||
operator()() const
|
||||
{
|
||||
detail::method_result x(
|
||||
PyEval_CallFunction(
|
||||
this->ptr()
|
||||
, const_cast<char*>("()")
|
||||
));
|
||||
return x;
|
||||
}
|
||||
|
||||
# define BOOST_PYTHON_fast_arg_to_python_get(z, n, _) \
|
||||
, converter::arg_to_python<A##n>(a##n).get()
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/override.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# undef BOOST_PYTHON_fast_arg_to_python_get
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // OVERRIDE_DWA2004721_HPP
|
||||
|
||||
#else
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, override.hpp)
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
template <
|
||||
BOOST_PP_ENUM_PARAMS_Z(1, N, class A)
|
||||
>
|
||||
detail::method_result
|
||||
operator()( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) ) const
|
||||
{
|
||||
detail::method_result x(
|
||||
PyEval_CallFunction(
|
||||
this->ptr()
|
||||
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
|
||||
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil)
|
||||
));
|
||||
return x;
|
||||
}
|
||||
|
||||
# undef N
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
// Copyright (C) 2004 Arkadiy Vertleyb
|
||||
// Copyright (C) 2005 Peder Holt
|
||||
// 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_TYPEOF_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing.hpp>
|
||||
#include <boost/preprocessor/control/iif.hpp>
|
||||
#include <boost/preprocessor/detail/is_unary.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/tuple/eat.hpp>
|
||||
#include <boost/preprocessor/seq/transform.hpp>
|
||||
#include <boost/preprocessor/seq/for_each_i.hpp>
|
||||
#include <boost/preprocessor/seq/cat.hpp>
|
||||
|
||||
#include <boost/typeof/encode_decode.hpp>
|
||||
#include <boost/typeof/int_encoding.hpp>
|
||||
|
||||
#include <boost/typeof/type_template_param.hpp>
|
||||
#include <boost/typeof/integral_template_param.hpp>
|
||||
#include <boost/typeof/template_template_param.hpp>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define BOOST_TYPEOF_QUALIFY(P) self_t::P
|
||||
#else
|
||||
#define BOOST_TYPEOF_QUALIFY(P) P
|
||||
#endif
|
||||
// The template parameter description, entered by the user,
|
||||
// is converted into a polymorphic "object"
|
||||
// that is used to generate the code responsible for
|
||||
// encoding/decoding the parameter, etc.
|
||||
|
||||
// make sure to cat the sequence first, and only then add the prefix.
|
||||
#define BOOST_TYPEOF_MAKE_OBJ(elem) BOOST_PP_CAT(\
|
||||
BOOST_TYPEOF_MAKE_OBJ,\
|
||||
BOOST_PP_SEQ_CAT((_) BOOST_TYPEOF_TO_SEQ(elem))\
|
||||
)
|
||||
|
||||
#define BOOST_TYPEOF_TO_SEQ(tokens) BOOST_TYPEOF_ ## tokens ## _BOOST_TYPEOF
|
||||
|
||||
// BOOST_TYPEOF_REGISTER_TEMPLATE
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_EXPLICIT_ID(Name, Params, Id)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_IMPL(\
|
||||
Name,\
|
||||
BOOST_TYPEOF_MAKE_OBJS(BOOST_TYPEOF_TOSEQ(Params)),\
|
||||
BOOST_PP_SEQ_SIZE(BOOST_TYPEOF_TOSEQ(Params)),\
|
||||
Id)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE(Name, Params)\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_EXPLICIT_ID(Name, Params, BOOST_TYPEOF_UNIQUE_ID())
|
||||
|
||||
#define BOOST_TYPEOF_OBJECT_MAKER(s, data, elem)\
|
||||
BOOST_TYPEOF_MAKE_OBJ(elem)
|
||||
|
||||
#define BOOST_TYPEOF_MAKE_OBJS(Params)\
|
||||
BOOST_PP_SEQ_TRANSFORM(BOOST_TYPEOF_OBJECT_MAKER, ~, Params)
|
||||
|
||||
// As suggested by Paul Mensonides:
|
||||
|
||||
#define BOOST_TYPEOF_TOSEQ(x)\
|
||||
BOOST_PP_IIF(\
|
||||
BOOST_PP_IS_UNARY(x),\
|
||||
x BOOST_PP_TUPLE_EAT(3), BOOST_PP_REPEAT\
|
||||
)(x, BOOST_TYPEOF_TOSEQ_2, ~)
|
||||
|
||||
#define BOOST_TYPEOF_TOSEQ_2(z, n, _) (class)
|
||||
|
||||
// BOOST_TYPEOF_VIRTUAL
|
||||
|
||||
#define BOOST_TYPEOF_CAT_4(a, b, c, d) BOOST_TYPEOF_CAT_4_I(a, b, c, d)
|
||||
#define BOOST_TYPEOF_CAT_4_I(a, b, c, d) a ## b ## c ## d
|
||||
|
||||
#define BOOST_TYPEOF_VIRTUAL(Fun, Obj)\
|
||||
BOOST_TYPEOF_CAT_4(BOOST_TYPEOF_, BOOST_PP_SEQ_HEAD(Obj), _, Fun)
|
||||
|
||||
// BOOST_TYPEOF_SEQ_ENUM[_TRAILING][_1]
|
||||
// Two versions provided due to reentrancy issue
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_EXPAND_ELEMENT(z,n,seq)\
|
||||
BOOST_PP_SEQ_ELEM(0,seq) (z,n,BOOST_PP_SEQ_ELEM(n,BOOST_PP_SEQ_ELEM(1,seq)))
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_ENUM(seq,macro)\
|
||||
BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_SEQ_EXPAND_ELEMENT,(macro)(seq))
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_ENUM_TRAILING(seq,macro)\
|
||||
BOOST_PP_ENUM_TRAILING(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_SEQ_EXPAND_ELEMENT,(macro)(seq))
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_EXPAND_ELEMENT_1(z,n,seq)\
|
||||
BOOST_PP_SEQ_ELEM(0,seq) (z,n,BOOST_PP_SEQ_ELEM(n,BOOST_PP_SEQ_ELEM(1,seq)))
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_ENUM_1(seq,macro)\
|
||||
BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_SEQ_EXPAND_ELEMENT_1,(macro)(seq))
|
||||
|
||||
#define BOOST_TYPEOF_SEQ_ENUM_TRAILING_1(seq,macro)\
|
||||
BOOST_PP_ENUM_TRAILING(BOOST_PP_SEQ_SIZE(seq),BOOST_TYPEOF_SEQ_EXPAND_ELEMENT_1,(macro)(seq))
|
||||
|
||||
//
|
||||
|
||||
#define BOOST_TYPEOF_PLACEHOLDER(z, n, elem)\
|
||||
BOOST_TYPEOF_VIRTUAL(PLACEHOLDER, elem)(elem)
|
||||
|
||||
#define BOOST_TYPEOF_PLACEHOLDER_TYPES(z, n, elem)\
|
||||
BOOST_TYPEOF_VIRTUAL(PLACEHOLDER_TYPES, elem)(elem, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM(r, data, n, elem)\
|
||||
BOOST_TYPEOF_VIRTUAL(ENCODE, elem)(elem, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM(r, data, n, elem)\
|
||||
BOOST_TYPEOF_VIRTUAL(DECODE, elem)(elem, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR(z, n, elem) \
|
||||
BOOST_TYPEOF_VIRTUAL(EXPANDTYPE, elem)(elem) BOOST_PP_CAT(P, n)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_DEFAULT_TEMPLATE_TYPE(Name,Params,ID)\
|
||||
Name< BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params), P) >
|
||||
|
||||
//Since we are creating an internal decode struct, we need to use different template names, T instead of P.
|
||||
#define BOOST_TYPEOF_REGISTER_DECODER_TYPE_PARAM_PAIR(z,n,elem) \
|
||||
BOOST_TYPEOF_VIRTUAL(EXPANDTYPE, elem)(elem) BOOST_PP_CAT(T, n)
|
||||
|
||||
//Default template param decoding
|
||||
|
||||
#define BOOST_TYPEOF_TYPEDEF_DECODED_TEMPLATE_TYPE(Name,Params)\
|
||||
typedef Name<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(Params),BOOST_TYPEOF_QUALIFY(P))> type;
|
||||
|
||||
//Branch the decoding
|
||||
#define BOOST_TYPEOF_TYPEDEF_DECODED_TYPE(Name,Params)\
|
||||
BOOST_PP_IF(BOOST_TYPEOF_HAS_TEMPLATES(Params),\
|
||||
BOOST_TYPEOF_TYPEDEF_DECODED_TEMPLATE_TEMPLATE_TYPE,\
|
||||
BOOST_TYPEOF_TYPEDEF_DECODED_TEMPLATE_TYPE)(Name,Params)
|
||||
|
||||
#define BOOST_TYPEOF_REGISTER_TEMPLATE_IMPL(Name, Params, Size, ID)\
|
||||
BOOST_TYPEOF_BEGIN_ENCODE_NS\
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE_TEMPLATE_IMPL(Name, Params, ID)\
|
||||
template<class V\
|
||||
BOOST_TYPEOF_SEQ_ENUM_TRAILING(Params, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR)\
|
||||
>\
|
||||
struct encode_type_impl<V, Name<BOOST_PP_ENUM_PARAMS(Size, P)> >\
|
||||
{\
|
||||
typedef typename boost::type_of::push_back<V, boost::mpl::size_t<ID> >::type V0;\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_TYPEOF_REGISTER_TEMPLATE_ENCODE_PARAM, ~, Params)\
|
||||
typedef BOOST_PP_CAT(V, Size) type;\
|
||||
};\
|
||||
template<class Iter>\
|
||||
struct decode_type_impl<boost::mpl::size_t<ID>, Iter>\
|
||||
{\
|
||||
typedef decode_type_impl<boost::mpl::size_t<ID>, Iter> self_t;\
|
||||
typedef boost::mpl::size_t<ID> self_id;\
|
||||
typedef Iter iter0;\
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_TYPEOF_REGISTER_TEMPLATE_DECODE_PARAM, ~, Params)\
|
||||
BOOST_TYPEOF_TYPEDEF_DECODED_TYPE(Name, Params)\
|
||||
typedef BOOST_PP_CAT(iter, Size) iter;\
|
||||
};\
|
||||
BOOST_TYPEOF_END_ENCODE_NS
|
||||
|
||||
#endif//BOOST_TYPEOF_TEMPLATE_ENCODING_HPP_INCLUDED
|
||||
@@ -0,0 +1,73 @@
|
||||
subroutine sync8(iwave,xdt,f1,s)
|
||||
|
||||
include 'ft8_params.f90'
|
||||
parameter (IZ=10,JZ=20)
|
||||
complex cx(0:NH1)
|
||||
real s(NH1,NHSYM)
|
||||
real savg(NH1)
|
||||
real x(NFFT1)
|
||||
real sync2d(-IZ:IZ,-JZ:JZ)
|
||||
integer*2 iwave(NMAX)
|
||||
integer icos7(0:6)
|
||||
data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
|
||||
equivalence (x,cx)
|
||||
|
||||
! Compute symbol spectra at half-symbol steps.
|
||||
savg=0.
|
||||
istep=NSPS/2
|
||||
tstep=istep/12000.0
|
||||
df=12000.0/NFFT1
|
||||
|
||||
fac=1.0/300.0
|
||||
do j=1,NHSYM
|
||||
ia=(j-1)*istep + 1
|
||||
ib=ia+NSPS-1
|
||||
x(1:NSPS)=fac*iwave(ia:ib)
|
||||
x(NSPS+1:)=0.
|
||||
call four2a(x,NFFT1,1,-1,0) !r2c FFT
|
||||
do i=1,NH1
|
||||
s(i,j)=real(cx(i))**2 + aimag(cx(i))**2
|
||||
enddo
|
||||
savg=savg + s(1:NH1,j)
|
||||
enddo
|
||||
|
||||
ia=nint(30.0/df)
|
||||
ib=nint(3000.0/df)
|
||||
savg=savg/NHSYM
|
||||
pmax=0.
|
||||
i0=0
|
||||
do i=ia,ib
|
||||
p=sum(savg(i-8:i+8))/17.0
|
||||
if(p.gt.pmax) then
|
||||
pmax=p
|
||||
i0=i-7
|
||||
endif
|
||||
enddo
|
||||
|
||||
tmax=0.
|
||||
ipk=0
|
||||
jpk=0
|
||||
j0=1
|
||||
do i=-IZ,IZ
|
||||
do j=-JZ,JZ
|
||||
t=0.
|
||||
do n=0,6
|
||||
k=j0+j+2*n
|
||||
if(k.ge.1) t=t + s(i0+i+2*icos7(n),k)
|
||||
t=t + s(i0+i+2*icos7(n),k+72)
|
||||
if(k+144.le.NHSYM) t=t + s(i0+i+2*icos7(n),k+144)
|
||||
enddo
|
||||
sync2d(i,j)=t
|
||||
if(t.gt.tmax) then
|
||||
tmax=t
|
||||
jpk=j
|
||||
ipk=i
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
f0=i0*df
|
||||
f1=(i0+ipk)*df
|
||||
xdt=jpk*tstep
|
||||
|
||||
return
|
||||
end subroutine sync8
|
||||
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2009 Christopher Schmidt
|
||||
|
||||
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_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
|
||||
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/iterator/deref_data.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename>
|
||||
struct deref_data_impl;
|
||||
|
||||
template <>
|
||||
struct deref_data_impl<joint_view_iterator_tag>
|
||||
{
|
||||
template <typename It>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::deref_data<typename It::first_type>::type
|
||||
type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static type
|
||||
call(It const& it)
|
||||
{
|
||||
return fusion::deref_data(it.first);
|
||||
}
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,570 @@
|
||||
//
|
||||
// Copyright (c) 2000-2002
|
||||
// Joerg Walter, Mathias Koch
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// The authors gratefully acknowledge the support of
|
||||
// GeNeSys mbH & Co. KG in producing this work.
|
||||
//
|
||||
|
||||
#ifndef _BOOST_UBLAS_VECTOR_ASSIGN_
|
||||
#define _BOOST_UBLAS_VECTOR_ASSIGN_
|
||||
|
||||
#include <boost/numeric/ublas/functional.hpp> // scalar_assign
|
||||
// Required for make_conformant storage
|
||||
#include <vector>
|
||||
|
||||
// Iterators based on ideas of Jeremy Siek
|
||||
|
||||
namespace boost { namespace numeric { namespace ublas {
|
||||
namespace detail {
|
||||
|
||||
// Weak equality check - useful to compare equality two arbitary vector expression results.
|
||||
// Since the actual expressions are unknown, we check for and arbitary error bound
|
||||
// on the relative error.
|
||||
// For a linear expression the infinity norm makes sense as we do not know how the elements will be
|
||||
// combined in the expression. False positive results are inevitable for arbirary expressions!
|
||||
template<class E1, class E2, class S>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool equals (const vector_expression<E1> &e1, const vector_expression<E2> &e2, S epsilon, S min_norm) {
|
||||
return norm_inf (e1 - e2) <= epsilon *
|
||||
std::max<S> (std::max<S> (norm_inf (e1), norm_inf (e2)), min_norm);
|
||||
}
|
||||
|
||||
template<class E1, class E2>
|
||||
BOOST_UBLAS_INLINE
|
||||
bool expression_type_check (const vector_expression<E1> &e1, const vector_expression<E2> &e2) {
|
||||
typedef typename type_traits<typename promote_traits<typename E1::value_type,
|
||||
typename E2::value_type>::promote_type>::real_type real_type;
|
||||
return equals (e1, e2, BOOST_UBLAS_TYPE_CHECK_EPSILON, BOOST_UBLAS_TYPE_CHECK_MIN);
|
||||
}
|
||||
|
||||
|
||||
// Make sparse proxies conformant
|
||||
template<class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void make_conformant (V &v, const vector_expression<E> &e) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
// FIXME unbounded_array with push_back maybe better
|
||||
std::vector<size_type> index;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
if (*ite != value_type/*zero*/())
|
||||
index.push_back (ite.index ());
|
||||
++ ite;
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (ite != ite_end) {
|
||||
if (*ite != value_type/*zero*/())
|
||||
index.push_back (ite.index ());
|
||||
++ ite;
|
||||
}
|
||||
for (size_type k = 0; k < index.size (); ++ k)
|
||||
v (index [k]) = value_type/*zero*/();
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
|
||||
// Explicitly iterating
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void iterating_vector_assign_scalar (V &v, const T &t) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (v.size ());
|
||||
typename V::iterator it (v.begin ());
|
||||
BOOST_UBLAS_CHECK (v.end () - it == size, bad_size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
#else
|
||||
DD (size, 4, r, (functor_type::apply (*it, t), ++ it));
|
||||
#endif
|
||||
}
|
||||
// Explicitly case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void indexing_vector_assign_scalar (V &v, const T &t) {
|
||||
typedef F<typename V::reference, T> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (v.size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
for (size_type i = 0; i < size; ++ i)
|
||||
functor_type::apply (v (i), t);
|
||||
#else
|
||||
size_type i (0);
|
||||
DD (size, 4, r, (functor_type::apply (v (i), t), ++ i));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, dense_proxy_tag) {
|
||||
#ifdef BOOST_UBLAS_USE_INDEXING
|
||||
indexing_vector_assign_scalar<F> (v, t);
|
||||
#elif BOOST_UBLAS_USE_ITERATING
|
||||
iterating_vector_assign_scalar<F> (v, t);
|
||||
#else
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (v.size ());
|
||||
if (size >= BOOST_UBLAS_ITERATOR_THRESHOLD)
|
||||
iterating_vector_assign_scalar<F> (v, t);
|
||||
else
|
||||
indexing_vector_assign_scalar<F> (v, t);
|
||||
#endif
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, packed_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
difference_type size (v.end () - it);
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
}
|
||||
// Sparse (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign_scalar (V &v, const T &t, sparse_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, T> functor_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
while (it != it_end)
|
||||
functor_type::apply (*it, t), ++ it;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class T>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_assign_scalar (V &v, const T &t) {
|
||||
typedef typename V::storage_category storage_category;
|
||||
vector_assign_scalar<F> (v, t, storage_category ());
|
||||
}
|
||||
|
||||
template<class SC, bool COMPUTED, class RI>
|
||||
struct vector_assign_traits {
|
||||
typedef SC storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<dense_tag, COMPUTED, packed_random_access_iterator_tag> {
|
||||
typedef packed_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<dense_proxy_tag, COMPUTED, packed_random_access_iterator_tag> {
|
||||
typedef packed_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_proxy_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<dense_proxy_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_assign_traits<packed_tag, false, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<packed_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<bool COMPUTED>
|
||||
struct vector_assign_traits<packed_proxy_tag, COMPUTED, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, dense_random_access_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, packed_random_access_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
template<>
|
||||
struct vector_assign_traits<sparse_tag, true, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
// Explicitly iterating
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void iterating_vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
typename V::iterator it (v.begin ());
|
||||
BOOST_UBLAS_CHECK (v.end () - it == size, bad_size ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
BOOST_UBLAS_CHECK (e ().end () - ite == size, bad_size ());
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
#else
|
||||
DD (size, 2, r, (functor_type::apply (*it, *ite), ++ it, ++ ite));
|
||||
#endif
|
||||
}
|
||||
// Explicitly indexing
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void indexing_vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef F<typename V::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
#ifndef BOOST_UBLAS_USE_DUFF_DEVICE
|
||||
for (size_type i = 0; i < size; ++ i)
|
||||
functor_type::apply (v (i), e () (i));
|
||||
#else
|
||||
size_type i (0);
|
||||
DD (size, 2, r, (functor_type::apply (v (i), e () (i)), ++ i));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, dense_proxy_tag) {
|
||||
#ifdef BOOST_UBLAS_USE_INDEXING
|
||||
indexing_vector_assign<F> (v, e);
|
||||
#elif BOOST_UBLAS_USE_ITERATING
|
||||
iterating_vector_assign<F> (v, e);
|
||||
#else
|
||||
typedef typename V::size_type size_type;
|
||||
size_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
if (size >= BOOST_UBLAS_ITERATOR_THRESHOLD)
|
||||
iterating_vector_assign<F> (v, e);
|
||||
else
|
||||
indexing_vector_assign<F> (v, e);
|
||||
#endif
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, packed_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
difference_type it_size (it_end - it);
|
||||
difference_type ite_size (ite_end - ite);
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (it.index () - ite.index ()), ite_size));
|
||||
if (size > 0) {
|
||||
ite += size;
|
||||
ite_size -= size;
|
||||
}
|
||||
}
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (ite.index () - it.index ()), it_size));
|
||||
if (size > 0) {
|
||||
it_size -= size;
|
||||
if (!functor_type::computed) {
|
||||
while (-- size >= 0) // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/()), ++ it;
|
||||
} else {
|
||||
it += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
difference_type size ((std::min) (it_size, ite_size));
|
||||
it_size -= size;
|
||||
ite_size -= size;
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
size = it_size;
|
||||
if (!functor_type::computed) {
|
||||
while (-- size >= 0) // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/()), ++ it;
|
||||
} else {
|
||||
it += size;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
// Sparse case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, sparse_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
BOOST_STATIC_ASSERT ((!functor_type::computed));
|
||||
typedef typename V::value_type value_type;
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
v.clear ();
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
while (ite != ite_end) {
|
||||
value_type t (*ite);
|
||||
if (t != value_type/*zero*/())
|
||||
v.insert_element (ite.index (), t);
|
||||
++ ite;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
// Sparse proxy or functional case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_assign (V &v, const vector_expression<E> &e, sparse_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::value_type> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typedef typename V::value_type value_type;
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
vector<value_type> cv (v.size ());
|
||||
indexing_vector_assign<scalar_assign> (cv, v);
|
||||
indexing_vector_assign<F> (cv, e);
|
||||
#endif
|
||||
detail::make_conformant (v, e);
|
||||
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::const_iterator ite (e ().begin ());
|
||||
typename E::const_iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
functor_type::apply (*it, *ite);
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
if (!functor_type::computed) {
|
||||
functor_type::apply (*it, value_type/*zero*/());
|
||||
++ it;
|
||||
} else
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
increment (ite, ite_end, compare);
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!functor_type::computed) {
|
||||
while (it != it_end) { // zeroing
|
||||
functor_type::apply (*it, value_type/*zero*/());
|
||||
++ it;
|
||||
}
|
||||
} else {
|
||||
it = it_end;
|
||||
}
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
if (! disable_type_check<bool>::value)
|
||||
BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv),
|
||||
external_logic ("external logic or bad condition of inputs"));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_assign (V &v, const vector_expression<E> &e) {
|
||||
typedef typename vector_assign_traits<typename V::storage_category,
|
||||
F<typename V::reference, typename E::value_type>::computed,
|
||||
typename E::const_iterator::iterator_category>::storage_category storage_category;
|
||||
vector_assign<F> (v, e, storage_category ());
|
||||
}
|
||||
|
||||
template<class SC, class RI>
|
||||
struct vector_swap_traits {
|
||||
typedef SC storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_swap_traits<dense_proxy_tag, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_swap_traits<packed_proxy_tag, sparse_bidirectional_iterator_tag> {
|
||||
typedef sparse_proxy_tag storage_category;
|
||||
};
|
||||
|
||||
// Dense (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, dense_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
difference_type size (BOOST_UBLAS_SAME (v.size (), e ().size ()));
|
||||
typename V::iterator it (v.begin ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
}
|
||||
// Packed (proxy) case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, packed_proxy_tag) {
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
typename E::iterator ite_end (e ().end ());
|
||||
difference_type it_size (it_end - it);
|
||||
difference_type ite_size (ite_end - ite);
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (it.index () - ite.index ()), ite_size));
|
||||
if (size > 0) {
|
||||
ite += size;
|
||||
ite_size -= size;
|
||||
}
|
||||
}
|
||||
if (it_size > 0 && ite_size > 0) {
|
||||
difference_type size ((std::min) (difference_type (ite.index () - it.index ()), it_size));
|
||||
if (size > 0)
|
||||
it_size -= size;
|
||||
}
|
||||
difference_type size ((std::min) (it_size, ite_size));
|
||||
it_size -= size;
|
||||
ite_size -= size;
|
||||
while (-- size >= 0)
|
||||
functor_type::apply (*it, *ite), ++ it, ++ ite;
|
||||
}
|
||||
// Sparse proxy case
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
|
||||
void vector_swap (V &v, vector_expression<E> &e, sparse_proxy_tag) {
|
||||
BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ());
|
||||
typedef F<typename V::iterator::reference, typename E::iterator::reference> functor_type;
|
||||
typedef typename V::size_type size_type;
|
||||
typedef typename V::difference_type difference_type;
|
||||
|
||||
detail::make_conformant (v, e);
|
||||
// FIXME should be a seperate restriction for E
|
||||
detail::make_conformant (e (), v);
|
||||
|
||||
typename V::iterator it (v.begin ());
|
||||
typename V::iterator it_end (v.end ());
|
||||
typename E::iterator ite (e ().begin ());
|
||||
typename E::iterator ite_end (e ().end ());
|
||||
if (it != it_end && ite != ite_end) {
|
||||
size_type it_index = it.index (), ite_index = ite.index ();
|
||||
while (true) {
|
||||
difference_type compare = it_index - ite_index;
|
||||
if (compare == 0) {
|
||||
functor_type::apply (*it, *ite);
|
||||
++ it, ++ ite;
|
||||
if (it != it_end && ite != ite_end) {
|
||||
it_index = it.index ();
|
||||
ite_index = ite.index ();
|
||||
} else
|
||||
break;
|
||||
} else if (compare < 0) {
|
||||
increment (it, it_end, - compare);
|
||||
if (it != it_end)
|
||||
it_index = it.index ();
|
||||
else
|
||||
break;
|
||||
} else if (compare > 0) {
|
||||
increment (ite, ite_end, compare);
|
||||
if (ite != ite_end)
|
||||
ite_index = ite.index ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if BOOST_UBLAS_TYPE_CHECK
|
||||
increment (ite, ite_end);
|
||||
increment (it, it_end);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
template<template <class T1, class T2> class F, class V, class E>
|
||||
BOOST_UBLAS_INLINE
|
||||
void vector_swap (V &v, vector_expression<E> &e) {
|
||||
typedef typename vector_swap_traits<typename V::storage_category,
|
||||
typename E::const_iterator::iterator_category>::storage_category storage_category;
|
||||
vector_swap<F> (v, e, storage_category ());
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
// (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 : $RCSfile$
|
||||
//
|
||||
// Version : $Revision$
|
||||
//
|
||||
// Description : basic_cstring class wrap C string and provide std_string like
|
||||
// interface
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP
|
||||
#define BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
template<typename CharT> class basic_cstring;
|
||||
typedef basic_cstring<char const> const_string;
|
||||
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041))
|
||||
typedef const_string literal_string;
|
||||
#else
|
||||
typedef const_string const literal_string;
|
||||
#endif
|
||||
|
||||
typedef char const* const c_literal_string;
|
||||
|
||||
} // namespace unit_test
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
// 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_ALIGNED_STORAGE_AJK_12FEB2016_HPP
|
||||
#define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_ALIGNED_STORAGE_AJK_12FEB2016_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace optional_detail {
|
||||
// This local class is used instead of that in "aligned_storage.hpp"
|
||||
// because I've found the 'official' class to ICE BCB5.5
|
||||
// when some types are used with optional<>
|
||||
// (due to sizeof() passed down as a non-type template parameter)
|
||||
template <class T>
|
||||
class aligned_storage
|
||||
{
|
||||
// Borland ICEs if unnamed unions are used for this!
|
||||
union
|
||||
// This works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
|
||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
||||
__attribute__((__may_alias__))
|
||||
#endif
|
||||
dummy_u
|
||||
{
|
||||
char data[ sizeof(T) ];
|
||||
BOOST_DEDUCED_TYPENAME type_with_alignment<
|
||||
::boost::alignment_of<T>::value >::type aligner_;
|
||||
} dummy_ ;
|
||||
|
||||
public:
|
||||
|
||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
||||
void const* address() const { return &dummy_; }
|
||||
void * address() { return &dummy_; }
|
||||
#else
|
||||
void const* address() const { return dummy_.data; }
|
||||
void * address() { return dummy_.data; }
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
||||
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
|
||||
T const* ptr_ref() const
|
||||
{
|
||||
union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
T * ptr_ref()
|
||||
{
|
||||
union { void* ap_pvoid; T* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
#else
|
||||
T const* ptr_ref() const { return static_cast<T const*>(address()); }
|
||||
T * ptr_ref() { return static_cast<T *> (address()); }
|
||||
#endif
|
||||
|
||||
T const& ref() const { return *ptr_ref(); }
|
||||
T & ref() { return *ptr_ref(); }
|
||||
|
||||
} ;
|
||||
|
||||
} // namespace optional_detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // header guard
|
||||
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2013 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(BOOST_FUSION_BUILD_DEQUE_02032013_1921)
|
||||
#define BOOST_FUSION_BUILD_DEQUE_02032013_1921
|
||||
|
||||
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
|
||||
#error "C++03 only! This file should not have been included"
|
||||
#endif
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/container/deque/detail/cpp03/as_deque.hpp>
|
||||
#include <boost/fusion/container/deque/front_extended_deque.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct as_deque
|
||||
: detail::as_deque<result_of::size<Sequence>::value>
|
||||
{
|
||||
typedef typename
|
||||
detail::as_deque<result_of::size<Sequence>::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_deque<Sequence>::type
|
||||
as_deque(Sequence& seq)
|
||||
{
|
||||
typedef typename result_of::as_deque<Sequence>::gen gen;
|
||||
return gen::call(fusion::begin(seq));
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::as_deque<Sequence const>::type
|
||||
as_deque(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::as_deque<Sequence const>::gen gen;
|
||||
return gen::call(fusion::begin(seq));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Some code in this file and accompanying files is based on work by
|
||||
// Moe Wheatley, AE4Y, released under the "Simplified BSD License".
|
||||
// For more details see the accompanying file LICENSE_WHEATLEY.TXT
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef FPLOTTER_H
|
||||
#define FPLOTTER_H
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QFrame>
|
||||
#include <QImage>
|
||||
#include <cstring>
|
||||
|
||||
class FPlotter : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FPlotter(QWidget *parent = 0);
|
||||
~FPlotter();
|
||||
|
||||
qint32 m_w;
|
||||
qint32 m_plotZero;
|
||||
qint32 m_plotGain;
|
||||
qint32 m_greenGain;
|
||||
qint32 m_greenZero;
|
||||
qint32 m_x0;
|
||||
qint32 m_x1;
|
||||
qint32 m_y0;
|
||||
qint32 m_UTCdisk;
|
||||
bool m_diskData;
|
||||
|
||||
void draw(); //Update the Fast plot
|
||||
void setPlotZero(int plotZero);
|
||||
void setPlotGain(int plotGain);
|
||||
void setGreenZero(int n);
|
||||
void setTRperiod(int n);
|
||||
void drawScale();
|
||||
void setMode(QString mode);
|
||||
|
||||
signals:
|
||||
void fastPick (int x0, int x1, int y);
|
||||
|
||||
protected:
|
||||
//re-implemented widget event handlers
|
||||
void paintEvent(QPaintEvent *event);
|
||||
// void resizeEvent(QResizeEvent* event);
|
||||
|
||||
private slots:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
void MakeTimeStrs();
|
||||
int XfromTime(float t);
|
||||
float TimefromX(int x);
|
||||
qint64 RoundFreq(qint64 freq, int resolution);
|
||||
|
||||
QPixmap m_ScalePixmap;
|
||||
QString m_HDivText[483];
|
||||
QString m_t;
|
||||
QString m_t0;
|
||||
QString m_t1;
|
||||
QString m_mode;
|
||||
|
||||
double m_pixPerSecond;
|
||||
|
||||
qint32 m_hdivs;
|
||||
qint32 m_h;
|
||||
qint32 m_h1;
|
||||
qint32 m_h2;
|
||||
QPixmap m_HorizPixmap;
|
||||
qint32 m_jh0;
|
||||
qint32 m_TRperiod;
|
||||
|
||||
bool m_bPaint2;
|
||||
};
|
||||
|
||||
extern float fast_green[703];
|
||||
extern float fast_green2[703];
|
||||
extern float fast_s[44992]; //44992=64*703
|
||||
extern float fast_s2[44992];
|
||||
extern int fast_jh;
|
||||
extern int fast_jh2;
|
||||
extern QVector<QColor> g_ColorTbl;
|
||||
|
||||
#endif // FPLOTTER_H
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
#ifndef BOOST_MPL_LIST_AUX_POP_FRONT_HPP_INCLUDED
|
||||
#define BOOST_MPL_LIST_AUX_POP_FRONT_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/pop_front_fwd.hpp>
|
||||
#include <boost/mpl/next_prior.hpp>
|
||||
#include <boost/mpl/list/aux_/tag.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct pop_front_impl< aux::list_tag >
|
||||
{
|
||||
template< typename List > struct apply
|
||||
{
|
||||
typedef typename mpl::next<List>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_LIST_AUX_POP_FRONT_HPP_INCLUDED
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Example of a (10000,5000) LDPC code with varying numbers of check per bit,
|
||||
# tested on Additive White Gaussian Noise channels with noise standard
|
||||
# deviations varying from 0.80 to 0.95. The code has 20% columns with two
|
||||
# check bits, 70% columns with three check bits, and 10% columns with seven
|
||||
# check bits.
|
||||
#
|
||||
# Testing is done by transmitting random messages, with pipes used so that
|
||||
# intermediate files are avoided. Decoding is done using a maximum of 250
|
||||
# iterations of probability propagation.
|
||||
|
||||
set -e # Stop if an error occurs
|
||||
set -v # Echo commands as they are read
|
||||
|
||||
make-ldpc ex-ldpcvar-5000a.pchk 5000 10000 2 evenboth 2x2/7x3/1x7 no4cycle
|
||||
make-gen ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen dense
|
||||
rand-src ex-ldpcvar-5000a.src 1 5000x100
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB
|
||||
|
||||
encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \
|
||||
| transmit - - 1 awgn 0.80 \
|
||||
| decode ex-ldpcvar-5000a.pchk - - awgn 0.80 prprp 250 \
|
||||
| verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB
|
||||
|
||||
encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \
|
||||
| transmit - - 1 awgn 0.85 \
|
||||
| decode ex-ldpcvar-5000a.pchk - - awgn 0.85 prprp 250 \
|
||||
| verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB
|
||||
|
||||
encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \
|
||||
| transmit - - 1 awgn 0.90 \
|
||||
| decode ex-ldpcvar-5000a.pchk - - awgn 0.90 prprp 250 \
|
||||
| verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB
|
||||
|
||||
encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \
|
||||
| transmit - - 1 awgn 0.95 \
|
||||
| decode ex-ldpcvar-5000a.pchk - - awgn 0.95 prprp 250 \
|
||||
| verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src
|
||||
@@ -0,0 +1,123 @@
|
||||
#include "fastgraph.h"
|
||||
|
||||
#include "commons.h"
|
||||
#include <QSettings>
|
||||
#include <QApplication>
|
||||
#include "fastplot.h"
|
||||
#include "SettingsGroup.hpp"
|
||||
|
||||
#include "ui_fastgraph.h"
|
||||
#include "moc_fastgraph.cpp"
|
||||
|
||||
#define NSMAX2 1366
|
||||
|
||||
FastGraph::FastGraph(QSettings * settings, QWidget *parent) :
|
||||
QDialog {parent, Qt::Window | Qt::WindowTitleHint |
|
||||
Qt::WindowCloseButtonHint |
|
||||
Qt::WindowMinimizeButtonHint},
|
||||
m_settings {settings},
|
||||
m_ave {40},
|
||||
ui {new Ui::FastGraph}
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle (QApplication::applicationName () + " - " + tr ("Fast Graph"));
|
||||
installEventFilter(parent); //Installing the filter
|
||||
ui->fastPlot->setCursor(Qt::CrossCursor);
|
||||
|
||||
//Restore user's settings
|
||||
SettingsGroup g {m_settings, "FastGraph"};
|
||||
restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ());
|
||||
ui->fastPlot->setPlotZero(m_settings->value("PlotZero", 0).toInt());
|
||||
ui->fastPlot->setPlotGain(m_settings->value("PlotGain", 0).toInt());
|
||||
ui->zeroSlider->setValue(ui->fastPlot->m_plotZero);
|
||||
ui->gainSlider->setValue(ui->fastPlot->m_plotGain);
|
||||
ui->fastPlot->setGreenZero(m_settings->value("GreenZero", 0).toInt());
|
||||
ui->greenZeroSlider->setValue(ui->fastPlot->m_greenZero);
|
||||
ui->controls_widget->setVisible (!m_settings->value("HideControls", false).toBool ());
|
||||
|
||||
connect (ui->fastPlot, &FPlotter::fastPick, this, &FastGraph::fastPick);
|
||||
}
|
||||
|
||||
void FastGraph::closeEvent (QCloseEvent * e)
|
||||
{
|
||||
saveSettings ();
|
||||
QDialog::closeEvent (e);
|
||||
}
|
||||
|
||||
FastGraph::~FastGraph ()
|
||||
{
|
||||
}
|
||||
|
||||
void FastGraph::saveSettings()
|
||||
{
|
||||
//Save user's settings
|
||||
SettingsGroup g {m_settings, "FastGraph"};
|
||||
m_settings->setValue ("geometry", saveGeometry ());
|
||||
m_settings->setValue("PlotZero",ui->fastPlot->m_plotZero);
|
||||
m_settings->setValue("PlotGain",ui->fastPlot->m_plotGain);
|
||||
m_settings->setValue("GreenZero",ui->fastPlot->m_greenZero);
|
||||
m_settings->setValue("GreenGain",ui->fastPlot->m_greenGain);
|
||||
m_settings->setValue ("HideControls", ui->controls_widget->isHidden ());
|
||||
}
|
||||
|
||||
void FastGraph::plotSpec(bool diskData, int UTCdisk)
|
||||
{
|
||||
ui->fastPlot->m_diskData=diskData;
|
||||
ui->fastPlot->m_UTCdisk=UTCdisk;
|
||||
ui->fastPlot->draw();
|
||||
}
|
||||
|
||||
void FastGraph::on_gainSlider_valueChanged(int value)
|
||||
{
|
||||
ui->fastPlot->setPlotGain(value);
|
||||
ui->fastPlot->draw();
|
||||
}
|
||||
|
||||
void FastGraph::on_zeroSlider_valueChanged(int value)
|
||||
{
|
||||
ui->fastPlot->setPlotZero(value);
|
||||
ui->fastPlot->draw();
|
||||
}
|
||||
|
||||
void FastGraph::on_greenZeroSlider_valueChanged(int value)
|
||||
{
|
||||
ui->fastPlot->setGreenZero(value);
|
||||
ui->fastPlot->draw();
|
||||
}
|
||||
|
||||
void FastGraph::setTRperiod(int n)
|
||||
{
|
||||
m_TRperiod=n;
|
||||
ui->fastPlot->setTRperiod(m_TRperiod);
|
||||
}
|
||||
|
||||
void FastGraph::on_pbAutoLevel_clicked()
|
||||
{
|
||||
float sum=0.0;
|
||||
for(int i=0; i<=fast_jh; i++) {
|
||||
sum += fast_green[i];
|
||||
}
|
||||
m_ave=sum/fast_jh;
|
||||
ui->gainSlider->setValue(127-int(2.2*m_ave));
|
||||
ui->zeroSlider->setValue(int(m_ave)+20);
|
||||
ui->greenZeroSlider->setValue(160-int(3.3*m_ave));
|
||||
}
|
||||
|
||||
void FastGraph::setMode(QString mode) //setMode
|
||||
{
|
||||
ui->fastPlot->setMode(mode);
|
||||
}
|
||||
|
||||
void FastGraph::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch(e->key())
|
||||
{
|
||||
case Qt::Key_M:
|
||||
if(e->modifiers() & Qt::ControlModifier) {
|
||||
ui->controls_widget->setVisible (!ui->controls_widget->isVisible ());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QDialog::keyPressEvent (e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
#include "Modulator.hpp"
|
||||
#include <limits>
|
||||
#include <qmath.h>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include "mainwindow.h"
|
||||
#include "soundout.h"
|
||||
|
||||
#include "moc_Modulator.cpp"
|
||||
|
||||
extern float gran(); // Noise generator (for tests only)
|
||||
|
||||
#define RAMP_INCREMENT 64 // MUST be an integral factor of 2^16
|
||||
|
||||
#if defined (WSJT_SOFT_KEYING)
|
||||
# define SOFT_KEYING WSJT_SOFT_KEYING
|
||||
#else
|
||||
# define SOFT_KEYING 1
|
||||
#endif
|
||||
|
||||
double constexpr Modulator::m_twoPi;
|
||||
|
||||
// float wpm=20.0;
|
||||
// unsigned m_nspd=1.2*48000.0/wpm;
|
||||
// m_nspd=3072; //18.75 WPM
|
||||
|
||||
Modulator::Modulator (unsigned frameRate, unsigned periodLengthInSeconds,
|
||||
QObject * parent)
|
||||
: AudioDevice {parent}
|
||||
, m_quickClose {false}
|
||||
, m_phi {0.0}
|
||||
, m_toneSpacing {0.0}
|
||||
, m_fSpread {0.0}
|
||||
, m_frameRate {frameRate}
|
||||
, m_period {periodLengthInSeconds}
|
||||
, m_state {Idle}
|
||||
, m_tuning {false}
|
||||
, m_cwLevel {false}
|
||||
, m_j0 {-1}
|
||||
, m_toneFrequency0 {1500.0}
|
||||
{
|
||||
}
|
||||
|
||||
void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
|
||||
double frequency, double toneSpacing,
|
||||
SoundOutput * stream, Channel channel,
|
||||
bool synchronize, bool fastMode, double dBSNR, int TRperiod)
|
||||
{
|
||||
Q_ASSERT (stream);
|
||||
// Time according to this computer which becomes our base time
|
||||
qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
||||
|
||||
if (m_state != Idle)
|
||||
{
|
||||
stop ();
|
||||
}
|
||||
|
||||
m_quickClose = false;
|
||||
|
||||
m_symbolsLength = symbolsLength;
|
||||
m_isym0 = std::numeric_limits<unsigned>::max (); // big number
|
||||
m_frequency0 = 0.;
|
||||
m_phi = 0.;
|
||||
m_addNoise = dBSNR < 0.;
|
||||
m_nsps = framesPerSymbol;
|
||||
m_frequency = frequency;
|
||||
m_amp = std::numeric_limits<qint16>::max ();
|
||||
m_toneSpacing = toneSpacing;
|
||||
m_bFastMode=fastMode;
|
||||
m_TRperiod=TRperiod;
|
||||
|
||||
// noise generator parameters
|
||||
if (m_addNoise) {
|
||||
m_snr = qPow (10.0, 0.05 * (dBSNR - 6.0));
|
||||
m_fac = 3000.0;
|
||||
if (m_snr > 1.0) m_fac = 3000.0 / m_snr;
|
||||
}
|
||||
|
||||
unsigned mstr = ms0 % (1000 * m_period); // ms in period
|
||||
m_ic = (mstr / 1000) * m_frameRate; // we start exactly N seconds
|
||||
// into period where N is the next whole second
|
||||
if(m_bFastMode) m_ic=0;
|
||||
|
||||
m_silentFrames = 0;
|
||||
// calculate number of silent frames to send
|
||||
if (synchronize && !m_tuning && !m_bFastMode) {
|
||||
m_silentFrames = m_ic + m_frameRate - (mstr * m_frameRate / 1000);
|
||||
}
|
||||
if(m_ic==0 and (m_silentFrames/48000.0 > 0.6) and m_nsps==1920 and m_period==15) {
|
||||
// FT8 mode: Start audio at t=0.5 s rather than t=1.0 s.
|
||||
m_silentFrames=m_silentFrames-24000;
|
||||
}
|
||||
|
||||
initialize (QIODevice::ReadOnly, channel);
|
||||
Q_EMIT stateChanged ((m_state = (synchronize && m_silentFrames) ?
|
||||
Synchronizing : Active));
|
||||
m_stream = stream;
|
||||
if (m_stream) m_stream->restart (this);
|
||||
}
|
||||
|
||||
void Modulator::tune (bool newState)
|
||||
{
|
||||
m_tuning = newState;
|
||||
if (!m_tuning) stop (true);
|
||||
}
|
||||
|
||||
void Modulator::stop (bool quick)
|
||||
{
|
||||
m_quickClose = quick;
|
||||
close ();
|
||||
}
|
||||
|
||||
void Modulator::close ()
|
||||
{
|
||||
if (m_stream)
|
||||
{
|
||||
if (m_quickClose)
|
||||
{
|
||||
m_stream->reset ();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stream->stop ();
|
||||
}
|
||||
}
|
||||
if (m_state != Idle)
|
||||
{
|
||||
Q_EMIT stateChanged ((m_state = Idle));
|
||||
}
|
||||
AudioDevice::close ();
|
||||
}
|
||||
|
||||
qint64 Modulator::readData (char * data, qint64 maxSize)
|
||||
{
|
||||
double toneFrequency=1500.0;
|
||||
if(m_nsps==6) {
|
||||
toneFrequency=1000.0;
|
||||
m_frequency=1000.0;
|
||||
m_frequency0=1000.0;
|
||||
}
|
||||
if(maxSize==0) return 0;
|
||||
Q_ASSERT (!(maxSize % qint64 (bytesPerFrame ()))); // no torn frames
|
||||
Q_ASSERT (isOpen ());
|
||||
|
||||
qint64 numFrames (maxSize / bytesPerFrame ());
|
||||
qint16 * samples (reinterpret_cast<qint16 *> (data));
|
||||
qint16 * end (samples + numFrames * (bytesPerFrame () / sizeof (qint16)));
|
||||
qint64 framesGenerated (0);
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case Synchronizing:
|
||||
{
|
||||
if (m_silentFrames) { // send silence up to first second
|
||||
framesGenerated = qMin (m_silentFrames, numFrames);
|
||||
for ( ; samples != end; samples = load (0, samples)) { // silence
|
||||
}
|
||||
m_silentFrames -= framesGenerated;
|
||||
return framesGenerated * bytesPerFrame ();
|
||||
}
|
||||
|
||||
Q_EMIT stateChanged ((m_state = Active));
|
||||
m_cwLevel = false;
|
||||
m_ramp = 0; // prepare for CW wave shaping
|
||||
}
|
||||
// fall through
|
||||
|
||||
case Active:
|
||||
{
|
||||
unsigned int isym=0;
|
||||
if(!m_tuning) isym=m_ic/(4.0*m_nsps); // Actual fsample=48000
|
||||
bool slowCwId=((isym >= m_symbolsLength) && (icw[0] > 0)) && (!m_bFastMode);
|
||||
if(m_TRperiod==3) slowCwId=false;
|
||||
bool fastCwId=false;
|
||||
static bool bCwId=false;
|
||||
qint64 ms = QDateTime::currentMSecsSinceEpoch();
|
||||
float tsec=0.001*(ms % (1000*m_TRperiod));
|
||||
if(m_bFastMode and (icw[0]>0) and (tsec>(m_TRperiod-5.0))) fastCwId=true;
|
||||
if(!m_bFastMode) m_nspd=2560; // 22.5 WPM
|
||||
|
||||
if(slowCwId or fastCwId) { // Transmit CW ID?
|
||||
m_dphi = m_twoPi*m_frequency/m_frameRate;
|
||||
if(m_bFastMode and !bCwId) {
|
||||
m_frequency=1500; // Set params for CW ID
|
||||
m_dphi = m_twoPi*m_frequency/m_frameRate;
|
||||
m_symbolsLength=126;
|
||||
m_nsps=4096.0*12000.0/11025.0;
|
||||
m_ic=2246949;
|
||||
m_nspd=2560; // 22.5 WPM
|
||||
if(icw[0]*m_nspd/48000.0 > 4.0) m_nspd=4.0*48000.0/icw[0]; //Faster CW for long calls
|
||||
}
|
||||
bCwId=true;
|
||||
unsigned ic0 = m_symbolsLength * 4 * m_nsps;
|
||||
unsigned j(0);
|
||||
|
||||
while (samples != end) {
|
||||
j = (m_ic - ic0)/m_nspd + 1; // symbol of this sample
|
||||
bool level {bool (icw[j])};
|
||||
m_phi += m_dphi;
|
||||
if (m_phi > m_twoPi) m_phi -= m_twoPi;
|
||||
qint16 sample=0;
|
||||
float amp=32767.0;
|
||||
float x=0;
|
||||
if(m_ramp!=0) {
|
||||
x=qSin(float(m_phi));
|
||||
if(SOFT_KEYING) {
|
||||
amp=qAbs(qint32(m_ramp));
|
||||
if(amp>32767.0) amp=32767.0;
|
||||
}
|
||||
sample=round(amp*x);
|
||||
}
|
||||
if(m_bFastMode) {
|
||||
sample=0;
|
||||
if(level) sample=32767.0*x;
|
||||
}
|
||||
if (int (j) <= icw[0] && j < NUM_CW_SYMBOLS) { // stop condition
|
||||
samples = load (postProcessSample (sample), samples);
|
||||
++framesGenerated;
|
||||
++m_ic;
|
||||
} else {
|
||||
Q_EMIT stateChanged ((m_state = Idle));
|
||||
return framesGenerated * bytesPerFrame ();
|
||||
}
|
||||
|
||||
// adjust ramp
|
||||
if ((m_ramp != 0 && m_ramp != std::numeric_limits<qint16>::min ()) || level != m_cwLevel) {
|
||||
// either ramp has terminated at max/min or direction has changed
|
||||
m_ramp += RAMP_INCREMENT; // ramp
|
||||
}
|
||||
m_cwLevel = level;
|
||||
}
|
||||
return framesGenerated * bytesPerFrame ();
|
||||
} else {
|
||||
bCwId=false;
|
||||
} //End of code for CW ID
|
||||
|
||||
double const baud (12000.0 / m_nsps);
|
||||
// fade out parameters (no fade out for tuning)
|
||||
unsigned int i0,i1;
|
||||
if(m_tuning) {
|
||||
i1 = i0 = (m_bFastMode ? 999999 : 9999) * m_nsps;
|
||||
} else {
|
||||
i0=(m_symbolsLength - 0.017) * 4.0 * m_nsps;
|
||||
i1= m_symbolsLength * 4.0 * m_nsps;
|
||||
}
|
||||
if(m_bFastMode and !m_tuning) {
|
||||
i1=m_TRperiod*48000 - 24000;
|
||||
i0=i1-816;
|
||||
}
|
||||
|
||||
|
||||
for (unsigned i = 0; i < numFrames && m_ic <= i1; ++i) {
|
||||
isym=0;
|
||||
if(!m_tuning and m_TRperiod!=3) isym=m_ic / (4.0 * m_nsps); //Actual fsample=48000
|
||||
if(m_bFastMode) isym=isym%m_symbolsLength;
|
||||
if (isym != m_isym0 || m_frequency != m_frequency0) {
|
||||
if(itone[0]>=100) {
|
||||
m_toneFrequency0=itone[0];
|
||||
} else {
|
||||
if(m_toneSpacing==0.0) {
|
||||
m_toneFrequency0=m_frequency + itone[isym]*baud;
|
||||
} else {
|
||||
m_toneFrequency0=m_frequency + itone[isym]*m_toneSpacing;
|
||||
}
|
||||
}
|
||||
// qDebug() << "B" << m_bFastMode << m_ic << numFrames << isym << itone[isym]
|
||||
// << m_toneFrequency0 << m_nsps;
|
||||
m_dphi = m_twoPi * m_toneFrequency0 / m_frameRate;
|
||||
m_isym0 = isym;
|
||||
m_frequency0 = m_frequency; //???
|
||||
}
|
||||
|
||||
int j=m_ic/480;
|
||||
if(m_fSpread>0.0 and j!=m_j0) {
|
||||
float x1=(float)qrand()/RAND_MAX;
|
||||
float x2=(float)qrand()/RAND_MAX;
|
||||
toneFrequency = m_toneFrequency0 + 0.5*m_fSpread*(x1+x2-1.0);
|
||||
m_dphi = m_twoPi * toneFrequency / m_frameRate;
|
||||
m_j0=j;
|
||||
}
|
||||
|
||||
m_phi += m_dphi;
|
||||
if (m_phi > m_twoPi) m_phi -= m_twoPi;
|
||||
if (m_ic > i0) m_amp = 0.98 * m_amp;
|
||||
if (m_ic > i1) m_amp = 0.0;
|
||||
|
||||
samples = load (postProcessSample (m_amp * qSin (m_phi)), samples);
|
||||
++framesGenerated;
|
||||
++m_ic;
|
||||
}
|
||||
|
||||
if (m_amp == 0.0) { // TODO G4WJS: compare double with zero might not be wise
|
||||
if (icw[0] == 0) {
|
||||
// no CW ID to send
|
||||
Q_EMIT stateChanged ((m_state = Idle));
|
||||
return framesGenerated * bytesPerFrame ();
|
||||
}
|
||||
m_phi = 0.0;
|
||||
}
|
||||
|
||||
m_frequency0 = m_frequency;
|
||||
// done for this chunk - continue on next call
|
||||
return framesGenerated * bytesPerFrame ();
|
||||
}
|
||||
// fall through
|
||||
|
||||
case Idle:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT (Idle == m_state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint16 Modulator::postProcessSample (qint16 sample) const
|
||||
{
|
||||
if (m_addNoise) { // Test frame, we'll add noise
|
||||
qint32 s = m_fac * (gran () + sample * m_snr / 32768.0);
|
||||
if (s > std::numeric_limits<qint16>::max ()) {
|
||||
s = std::numeric_limits<qint16>::max ();
|
||||
}
|
||||
if (s < std::numeric_limits<qint16>::min ()) {
|
||||
s = std::numeric_limits<qint16>::min ();
|
||||
}
|
||||
sample = s;
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
program count4
|
||||
|
||||
parameter(NMAX=1000)
|
||||
character*47 line
|
||||
real snr(NMAX)
|
||||
real dt(NMAX)
|
||||
real f(NMAX)
|
||||
|
||||
open(10,file='/users/joe/appdata/local/wsjt-x/all.txt',status='old')
|
||||
|
||||
read(10,1000,end=10) line
|
||||
1000 format(a47)
|
||||
|
||||
nsync1=0
|
||||
nsync2=0
|
||||
n1=0
|
||||
n2=0
|
||||
nerr=0
|
||||
|
||||
do i=1,99999
|
||||
read(10,1000,end=10) line
|
||||
if(line(47:47).ne.' ') cycle !Skip average decodes
|
||||
if(line(20:20).eq.'*') nsync1=nsync1+1
|
||||
if(line(20:20).eq.'#') nsync2=nsync2+1
|
||||
if(line(22:34).eq.'CQ K1ABC FN42') then
|
||||
n2=n2+1 !Correlation decode
|
||||
read(line,1002) snr(n2),dt(n2),f(n2)
|
||||
1002 format(4x,f4.0,f5.2,f5.0)
|
||||
if(line(42:42).eq.'*') n1=n1+1 !Convolutional decode
|
||||
else
|
||||
if(line(22:34).ne.' ') nerr=nerr+1
|
||||
endif
|
||||
enddo
|
||||
|
||||
10 call stats(snr,n2,snrave,snrdev)
|
||||
call stats(dt,n2,dtave,dtdev)
|
||||
call stats(f,n2,fave,fdev)
|
||||
|
||||
write(*,1010) nsync1,nsync2,n1,n2,nerr,snrave,dtave,fave,snrdev,dtdev,fdev
|
||||
1010 format(5i5,f7.1,f7.2,f7.0/25x,f7.1,f7.2,f7.0)
|
||||
|
||||
end program count4
|
||||
|
||||
subroutine stats(x,nz,ave,rms)
|
||||
real x(nz)
|
||||
|
||||
ave=0.
|
||||
rms=0.
|
||||
if(nz.gt.0) ave=sum(x)/nz
|
||||
x=x-ave
|
||||
if(nz.gt.1) rms=sqrt(dot_product(x,x)/(nz-1))
|
||||
|
||||
return
|
||||
end subroutine stats
|
||||
@@ -0,0 +1,93 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009.
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
#endif
|
||||
|
||||
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
|
||||
#ifndef BOOST_OLD_IOSTREAMS
|
||||
# if defined(__STL_CONFIG_H) && \
|
||||
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
|
||||
/**/
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
# endif
|
||||
#endif // #ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#ifndef _STLP_NO_IOSTREAMS
|
||||
# ifndef BOOST_OLD_IOSTREAMS
|
||||
# include <ostream>
|
||||
# else
|
||||
# include <ostream.h>
|
||||
# endif
|
||||
#endif // _STLP_NO_IOSTREAMS
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#ifndef _STLP_NO_IOSTREAMS
|
||||
# ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputted
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT, typename Elem, typename Traits >
|
||||
inline std::basic_ostream<Elem,Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( r.begin(), r.end(),
|
||||
std::ostream_iterator< BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type,
|
||||
Elem, Traits>(Os) );
|
||||
return Os;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputted
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
|
||||
return Os;
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif // _STLP_NO_IOSTREAMS
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_HAS_KEY_IMPL_31122005_1647)
|
||||
#define BOOST_FUSION_HAS_KEY_IMPL_31122005_1647
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/mpl/has_key.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct has_key_impl;
|
||||
|
||||
template <>
|
||||
struct has_key_impl<mpl_sequence_tag>
|
||||
{
|
||||
template <typename Sequence, typename Key>
|
||||
struct apply : mpl::has_key<Sequence, Key> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,220 @@
|
||||
/* boost random/negative_binomial_distribution.hpp header file
|
||||
*
|
||||
* Copyright Steven Watanabe 2010
|
||||
* 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 including documentation.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef BOOST_RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_HPP_INCLUDED
|
||||
#define BOOST_RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_HPP_INCLUDED
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/random/detail/config.hpp>
|
||||
#include <boost/random/gamma_distribution.hpp>
|
||||
#include <boost/random/poisson_distribution.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace random {
|
||||
|
||||
/**
|
||||
* The negative binomial distribution is an integer valued
|
||||
* distribution with two parameters, @c k and @c p. The
|
||||
* distribution produces non-negative values.
|
||||
*
|
||||
* The distribution function is
|
||||
* \f$\displaystyle P(i) = {k+i-1\choose i}p^k(1-p)^i\f$.
|
||||
*
|
||||
* This implementation uses a gamma-poisson mixture.
|
||||
*/
|
||||
template<class IntType = int, class RealType = double>
|
||||
class negative_binomial_distribution {
|
||||
public:
|
||||
typedef IntType result_type;
|
||||
typedef RealType input_type;
|
||||
|
||||
class param_type {
|
||||
public:
|
||||
typedef negative_binomial_distribution distribution_type;
|
||||
/**
|
||||
* Construct a param_type object. @c k and @c p
|
||||
* are the parameters of the distribution.
|
||||
*
|
||||
* Requires: k >=0 && 0 <= p <= 1
|
||||
*/
|
||||
explicit param_type(IntType k_arg = 1, RealType p_arg = RealType (0.5))
|
||||
: _k(k_arg), _p(p_arg)
|
||||
{}
|
||||
/** Returns the @c k parameter of the distribution. */
|
||||
IntType k() const { return _k; }
|
||||
/** Returns the @c p parameter of the distribution. */
|
||||
RealType p() const { return _p; }
|
||||
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
|
||||
/** Writes the parameters of the distribution to a @c std::ostream. */
|
||||
template<class CharT, class Traits>
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<(std::basic_ostream<CharT,Traits>& os,
|
||||
const param_type& parm)
|
||||
{
|
||||
os << parm._p << " " << parm._k;
|
||||
return os;
|
||||
}
|
||||
|
||||
/** Reads the parameters of the distribution from a @c std::istream. */
|
||||
template<class CharT, class Traits>
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>(std::basic_istream<CharT,Traits>& is, param_type& parm)
|
||||
{
|
||||
is >> parm._p >> std::ws >> parm._k;
|
||||
return is;
|
||||
}
|
||||
#endif
|
||||
/** Returns true if the parameters have the same values. */
|
||||
friend bool operator==(const param_type& lhs, const param_type& rhs)
|
||||
{
|
||||
return lhs._k == rhs._k && lhs._p == rhs._p;
|
||||
}
|
||||
/** Returns true if the parameters have different values. */
|
||||
friend bool operator!=(const param_type& lhs, const param_type& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
private:
|
||||
IntType _k;
|
||||
RealType _p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a @c negative_binomial_distribution object. @c k and @c p
|
||||
* are the parameters of the distribution.
|
||||
*
|
||||
* Requires: k >=0 && 0 <= p <= 1
|
||||
*/
|
||||
explicit negative_binomial_distribution(IntType k_arg = 1,
|
||||
RealType p_arg = RealType(0.5))
|
||||
: _k(k_arg), _p(p_arg)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Construct an @c negative_binomial_distribution object from the
|
||||
* parameters.
|
||||
*/
|
||||
explicit negative_binomial_distribution(const param_type& parm)
|
||||
: _k(parm.k()), _p(parm.p())
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns a random variate distributed according to the
|
||||
* negative binomial distribution.
|
||||
*/
|
||||
template<class URNG>
|
||||
IntType operator()(URNG& urng) const
|
||||
{
|
||||
gamma_distribution<RealType> gamma(_k, (1-_p)/_p);
|
||||
poisson_distribution<IntType, RealType> poisson(gamma(urng));
|
||||
return poisson(urng);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random variate distributed according to the negative
|
||||
* binomial distribution with parameters specified by @c param.
|
||||
*/
|
||||
template<class URNG>
|
||||
IntType operator()(URNG& urng, const param_type& parm) const
|
||||
{
|
||||
return negative_binomial_distribution(parm)(urng);
|
||||
}
|
||||
|
||||
/** Returns the @c k parameter of the distribution. */
|
||||
IntType k() const { return _k; }
|
||||
/** Returns the @c p parameter of the distribution. */
|
||||
RealType p() const { return _p; }
|
||||
|
||||
/** Returns the smallest value that the distribution can produce. */
|
||||
IntType min BOOST_PREVENT_MACRO_SUBSTITUTION() const { return 0; }
|
||||
/** Returns the largest value that the distribution can produce. */
|
||||
IntType max BOOST_PREVENT_MACRO_SUBSTITUTION() const
|
||||
{ return (std::numeric_limits<IntType>::max)(); }
|
||||
|
||||
/** Returns the parameters of the distribution. */
|
||||
param_type param() const { return param_type(_k, _p); }
|
||||
/** Sets parameters of the distribution. */
|
||||
void param(const param_type& parm)
|
||||
{
|
||||
_k = parm.k();
|
||||
_p = parm.p();
|
||||
}
|
||||
|
||||
/**
|
||||
* Effects: Subsequent uses of the distribution do not depend
|
||||
* on values produced by any engine prior to invoking reset.
|
||||
*/
|
||||
void reset() { }
|
||||
|
||||
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
|
||||
/** Writes the parameters of the distribution to a @c std::ostream. */
|
||||
template<class CharT, class Traits>
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<(std::basic_ostream<CharT,Traits>& os,
|
||||
const negative_binomial_distribution& bd)
|
||||
{
|
||||
os << bd.param();
|
||||
return os;
|
||||
}
|
||||
|
||||
/** Reads the parameters of the distribution from a @c std::istream. */
|
||||
template<class CharT, class Traits>
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>(std::basic_istream<CharT,Traits>& is,
|
||||
negative_binomial_distribution& bd)
|
||||
{
|
||||
bd.read(is);
|
||||
return is;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Returns true if the two distributions will produce the same
|
||||
sequence of values, given equal generators. */
|
||||
friend bool operator==(const negative_binomial_distribution& lhs,
|
||||
const negative_binomial_distribution& rhs)
|
||||
{
|
||||
return lhs._k == rhs._k && lhs._p == rhs._p;
|
||||
}
|
||||
/** Returns true if the two distributions could produce different
|
||||
sequences of values, given equal generators. */
|
||||
friend bool operator!=(const negative_binomial_distribution& lhs,
|
||||
const negative_binomial_distribution& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// @cond \show_private
|
||||
|
||||
template<class CharT, class Traits>
|
||||
void read(std::basic_istream<CharT, Traits>& is) {
|
||||
param_type parm;
|
||||
if(is >> parm) {
|
||||
param(parm);
|
||||
}
|
||||
}
|
||||
|
||||
// parameters
|
||||
IntType _k;
|
||||
RealType _p;
|
||||
|
||||
/// @endcond
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,118 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_COMMON_HPP
|
||||
#define BOOST_RANGE_DETAIL_COMMON_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/detail/sfinae.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// missing partial specialization workaround.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
// 1 = std containers
|
||||
// 2 = std::pair
|
||||
// 3 = const std::pair
|
||||
// 4 = array
|
||||
// 5 = const array
|
||||
// 6 = char array
|
||||
// 7 = wchar_t array
|
||||
// 8 = char*
|
||||
// 9 = const char*
|
||||
// 10 = whar_t*
|
||||
// 11 = const wchar_t*
|
||||
// 12 = string
|
||||
|
||||
typedef mpl::int_<1>::type std_container_;
|
||||
typedef mpl::int_<2>::type std_pair_;
|
||||
typedef mpl::int_<3>::type const_std_pair_;
|
||||
typedef mpl::int_<4>::type array_;
|
||||
typedef mpl::int_<5>::type const_array_;
|
||||
typedef mpl::int_<6>::type char_array_;
|
||||
typedef mpl::int_<7>::type wchar_t_array_;
|
||||
typedef mpl::int_<8>::type char_ptr_;
|
||||
typedef mpl::int_<9>::type const_char_ptr_;
|
||||
typedef mpl::int_<10>::type wchar_t_ptr_;
|
||||
typedef mpl::int_<11>::type const_wchar_t_ptr_;
|
||||
typedef mpl::int_<12>::type string_;
|
||||
|
||||
template< typename C >
|
||||
struct range_helper
|
||||
{
|
||||
static C* c;
|
||||
static C ptr;
|
||||
|
||||
BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::mpl::or_<boost::mpl::bool_<is_const_char_ptr_>, boost::mpl::bool_<is_const_wchar_t_ptr_> >::value ));
|
||||
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
|
||||
|
||||
};
|
||||
|
||||
template< typename C >
|
||||
class range
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
|
||||
boost::range_detail::std_pair_,
|
||||
void >::type pair_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
|
||||
boost::range_detail::array_,
|
||||
pair_t >::type array_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
|
||||
boost::range_detail::string_,
|
||||
array_t >::type string_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
|
||||
boost::range_detail::const_char_ptr_,
|
||||
string_t >::type const_char_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
|
||||
boost::range_detail::char_ptr_,
|
||||
const_char_ptr_t >::type char_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
|
||||
boost::range_detail::const_wchar_t_ptr_,
|
||||
char_ptr_t >::type const_wchar_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
|
||||
boost::range_detail::wchar_t_ptr_,
|
||||
const_wchar_ptr_t >::type wchar_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
|
||||
boost::range_detail::wchar_t_array_,
|
||||
wchar_ptr_t >::type wchar_array_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
|
||||
boost::range_detail::char_array_,
|
||||
wchar_array_t >::type char_array_t;
|
||||
public:
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
|
||||
boost::range_detail::std_container_,
|
||||
char_array_t >::type type;
|
||||
}; // class 'range'
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://boostorg.github.com/compute for more information.
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_ON_DEVICE_HPP
|
||||
#define BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_ON_DEVICE_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/compute/command_queue.hpp>
|
||||
#include <boost/compute/async/future.hpp>
|
||||
#include <boost/compute/iterator/buffer_iterator.hpp>
|
||||
#include <boost/compute/iterator/discard_iterator.hpp>
|
||||
#include <boost/compute/memory/svm_ptr.hpp>
|
||||
#include <boost/compute/detail/iterator_range_size.hpp>
|
||||
#include <boost/compute/detail/meta_kernel.hpp>
|
||||
#include <boost/compute/detail/parameter_cache.hpp>
|
||||
#include <boost/compute/detail/work_size.hpp>
|
||||
#include <boost/compute/detail/vendor.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
namespace detail {
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
inline event copy_on_device_cpu(InputIterator first,
|
||||
OutputIterator result,
|
||||
size_t count,
|
||||
command_queue &queue)
|
||||
{
|
||||
meta_kernel k("copy");
|
||||
const device& device = queue.get_device();
|
||||
|
||||
k <<
|
||||
"uint block = " <<
|
||||
"(uint)ceil(((float)count)/get_global_size(0));\n" <<
|
||||
"uint index = get_global_id(0) * block;\n" <<
|
||||
"uint end = min(count, index + block);\n" <<
|
||||
"while(index < end){\n" <<
|
||||
result[k.var<uint_>("index")] << '=' <<
|
||||
first[k.var<uint_>("index")] << ";\n" <<
|
||||
"index++;\n" <<
|
||||
"}\n";
|
||||
|
||||
k.add_set_arg<const uint_>("count", static_cast<uint_>(count));
|
||||
|
||||
size_t global_work_size = device.compute_units();
|
||||
if(count <= 1024) global_work_size = 1;
|
||||
return k.exec_1d(queue, 0, global_work_size);
|
||||
}
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
inline event copy_on_device_gpu(InputIterator first,
|
||||
OutputIterator result,
|
||||
size_t count,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type input_type;
|
||||
|
||||
const device& device = queue.get_device();
|
||||
boost::shared_ptr<parameter_cache> parameters =
|
||||
detail::parameter_cache::get_global_cache(device);
|
||||
std::string cache_key =
|
||||
"__boost_copy_kernel_" + boost::lexical_cast<std::string>(sizeof(input_type));
|
||||
|
||||
uint_ vpt = parameters->get(cache_key, "vpt", 4);
|
||||
uint_ tpb = parameters->get(cache_key, "tpb", 128);
|
||||
|
||||
meta_kernel k("copy");
|
||||
k <<
|
||||
"uint index = get_local_id(0) + " <<
|
||||
"(" << vpt * tpb << " * get_group_id(0));\n" <<
|
||||
"for(uint i = 0; i < " << vpt << "; i++){\n" <<
|
||||
" if(index < count){\n" <<
|
||||
result[k.var<uint_>("index")] << '=' <<
|
||||
first[k.var<uint_>("index")] << ";\n" <<
|
||||
" index += " << tpb << ";\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
k.add_set_arg<const uint_>("count", static_cast<uint_>(count));
|
||||
size_t global_work_size = calculate_work_size(count, vpt, tpb);
|
||||
return k.exec_1d(queue, 0, global_work_size, tpb);
|
||||
}
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
inline event dispatch_copy_on_device(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
command_queue &queue)
|
||||
{
|
||||
const size_t count = detail::iterator_range_size(first, last);
|
||||
|
||||
if(count == 0){
|
||||
// nothing to do
|
||||
return event();
|
||||
}
|
||||
|
||||
const device& device = queue.get_device();
|
||||
// copy_on_device_cpu() does not work for CPU on Apple platform
|
||||
// due to bug in its compiler.
|
||||
// See https://github.com/boostorg/compute/pull/626
|
||||
if((device.type() & device::cpu) && !is_apple_platform_device(device))
|
||||
{
|
||||
return copy_on_device_cpu(first, result, count, queue);
|
||||
}
|
||||
return copy_on_device_gpu(first, result, count, queue);
|
||||
}
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
inline OutputIterator copy_on_device(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
command_queue &queue)
|
||||
{
|
||||
dispatch_copy_on_device(first, last, result, queue);
|
||||
return result + std::distance(first, last);
|
||||
}
|
||||
|
||||
template<class InputIterator>
|
||||
inline discard_iterator copy_on_device(InputIterator first,
|
||||
InputIterator last,
|
||||
discard_iterator result,
|
||||
command_queue &queue)
|
||||
{
|
||||
(void) queue;
|
||||
|
||||
return result + std::distance(first, last);
|
||||
}
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
inline future<OutputIterator> copy_on_device_async(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
command_queue &queue)
|
||||
{
|
||||
event event_ = dispatch_copy_on_device(first, last, result, queue);
|
||||
return make_future(result + std::distance(first, last), event_);
|
||||
}
|
||||
|
||||
#ifdef CL_VERSION_2_0
|
||||
// copy_on_device() specialization for svm_ptr
|
||||
template<class T>
|
||||
inline svm_ptr<T> copy_on_device(svm_ptr<T> first,
|
||||
svm_ptr<T> last,
|
||||
svm_ptr<T> result,
|
||||
command_queue &queue)
|
||||
{
|
||||
size_t count = iterator_range_size(first, last);
|
||||
if(count == 0){
|
||||
return result;
|
||||
}
|
||||
|
||||
queue.enqueue_svm_memcpy(
|
||||
result.get(), first.get(), count * sizeof(T)
|
||||
);
|
||||
|
||||
return result + count;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline future<svm_ptr<T> > copy_on_device_async(svm_ptr<T> first,
|
||||
svm_ptr<T> last,
|
||||
svm_ptr<T> result,
|
||||
command_queue &queue)
|
||||
{
|
||||
size_t count = iterator_range_size(first, last);
|
||||
if(count == 0){
|
||||
return future<svm_ptr<T> >();
|
||||
}
|
||||
|
||||
event event_ = queue.enqueue_svm_memcpy_async(
|
||||
result.get(), first.get(), count * sizeof(T)
|
||||
);
|
||||
|
||||
return make_future(result + count, event_);
|
||||
}
|
||||
#endif // CL_VERSION_2_0
|
||||
|
||||
} // end detail namespace
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_ON_DEVICE_HPP
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
// 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/bind_fwd.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct bind0;
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct bind1;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct bind2;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct bind3;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct bind4;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
, typename T5
|
||||
>
|
||||
struct bind5;
|
||||
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
#ifndef BOOST_MPL_VECTOR_AUX_SIZE_HPP_INCLUDED
|
||||
#define BOOST_MPL_VECTOR_AUX_SIZE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/size_fwd.hpp>
|
||||
#include <boost/mpl/vector/aux_/O1_size.hpp>
|
||||
#include <boost/mpl/vector/aux_/tag.hpp>
|
||||
#include <boost/mpl/aux_/config/typeof.hpp>
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
|
||||
|
||||
template<>
|
||||
struct size_impl< aux::vector_tag >
|
||||
: O1_size_impl< aux::vector_tag >
|
||||
{
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template< long N >
|
||||
struct size_impl< aux::vector_tag<N> >
|
||||
: O1_size_impl< aux::vector_tag<N> >
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_VECTOR_AUX_SIZE_HPP_INCLUDED
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef BOOST_POINTER_TO_OTHER_HPP_INCLUDED
|
||||
#define BOOST_POINTER_TO_OTHER_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// pointer_to_other.hpp
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005.
|
||||
// Copyright (c) 2005 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/smart_ptr/pointer_to_other.html
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// Defines the same pointer type (raw or smart) to another pointee type
|
||||
|
||||
template<class T, class U>
|
||||
struct pointer_to_other;
|
||||
|
||||
template<class T, class U,
|
||||
template<class> class Sp>
|
||||
struct pointer_to_other< Sp<T>, U >
|
||||
{
|
||||
typedef Sp<U> type;
|
||||
};
|
||||
|
||||
template<class T, class T2, class U,
|
||||
template<class, class> class Sp>
|
||||
struct pointer_to_other< Sp<T, T2>, U >
|
||||
{
|
||||
typedef Sp<U, T2> type;
|
||||
};
|
||||
|
||||
template<class T, class T2, class T3, class U,
|
||||
template<class, class, class> class Sp>
|
||||
struct pointer_to_other< Sp<T, T2, T3>, U >
|
||||
{
|
||||
typedef Sp<U, T2, T3> type;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct pointer_to_other< T*, U >
|
||||
{
|
||||
typedef U* type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_POINTER_TO_OTHER_HPP_INCLUDED
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
@@ -0,0 +1,21 @@
|
||||
|
||||
#ifndef BOOST_MPL_LIMITS_LIST_HPP_INCLUDED
|
||||
#define BOOST_MPL_LIMITS_LIST_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_LIMIT_LIST_SIZE)
|
||||
# define BOOST_MPL_LIMIT_LIST_SIZE 20
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MPL_LIMITS_LIST_HPP_INCLUDED
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Bruno Dutra 2015
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/insert_range_fwd.hpp>
|
||||
#include <boost/mpl/set/aux_/tag.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/mpl/fold.hpp>
|
||||
#include <boost/mpl/insert.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<>
|
||||
struct insert_range_impl< aux::set_tag >
|
||||
{
|
||||
template<
|
||||
typename Sequence
|
||||
, typename /*Pos*/
|
||||
, typename Range
|
||||
>
|
||||
struct apply
|
||||
: fold<Range, Sequence, insert<_1, _2> >
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef MANAGE_NEW_OBJECT_DWA200222_HPP
|
||||
# define MANAGE_NEW_OBJECT_DWA200222_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/python/detail/indirect_traits.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/python/to_python_indirect.hpp>
|
||||
# include <boost/type_traits/composite_traits.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class R>
|
||||
struct manage_new_object_requires_a_pointer_return_type
|
||||
# if defined(__GNUC__) || defined(__EDG__)
|
||||
{}
|
||||
# endif
|
||||
;
|
||||
}
|
||||
|
||||
struct manage_new_object
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::if_c<
|
||||
boost::is_pointer<T>::value
|
||||
, to_python_indirect<T, detail::make_owning_holder>
|
||||
, detail::manage_new_object_requires_a_pointer_return_type<T>
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // MANAGE_NEW_OBJECT_DWA200222_HPP
|
||||
Reference in New Issue
Block a user