Initial Commit
This commit is contained in:
@@ -0,0 +1,541 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (c) 2015 Jakub Szuppe <j.szuppe@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_REDUCE_BY_KEY_WITH_SCAN_HPP
|
||||
#define BOOST_COMPUTE_ALGORITHM_DETAIL_REDUCE_BY_KEY_WITH_SCAN_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/compute/command_queue.hpp>
|
||||
#include <boost/compute/functional.hpp>
|
||||
#include <boost/compute/algorithm/inclusive_scan.hpp>
|
||||
#include <boost/compute/container/vector.hpp>
|
||||
#include <boost/compute/container/detail/scalar.hpp>
|
||||
#include <boost/compute/detail/meta_kernel.hpp>
|
||||
#include <boost/compute/detail/iterator_range_size.hpp>
|
||||
#include <boost/compute/detail/read_write_single_value.hpp>
|
||||
#include <boost/compute/type_traits.hpp>
|
||||
#include <boost/compute/utility/program_cache.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
namespace detail {
|
||||
|
||||
/// \internal_
|
||||
///
|
||||
/// Fills \p new_keys_first with unsigned integer keys generated from vector
|
||||
/// of original keys \p keys_first. New keys can be distinguish by simple equality
|
||||
/// predicate.
|
||||
///
|
||||
/// \param keys_first iterator pointing to the first key
|
||||
/// \param number_of_keys number of keys
|
||||
/// \param predicate binary predicate for key comparison
|
||||
/// \param new_keys_first iterator pointing to the new keys vector
|
||||
/// \param preferred_work_group_size preferred work group size
|
||||
/// \param queue command queue to perform the operation
|
||||
///
|
||||
/// Binary function \p predicate must take two keys as arguments and
|
||||
/// return true only if they are considered the same.
|
||||
///
|
||||
/// The first new key equals zero and the last equals number of unique keys
|
||||
/// minus one.
|
||||
///
|
||||
/// No local memory usage.
|
||||
template<class InputKeyIterator, class BinaryPredicate>
|
||||
inline void generate_uint_keys(InputKeyIterator keys_first,
|
||||
size_t number_of_keys,
|
||||
BinaryPredicate predicate,
|
||||
vector<uint_>::iterator new_keys_first,
|
||||
size_t preferred_work_group_size,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<InputKeyIterator>::value_type key_type;
|
||||
|
||||
detail::meta_kernel k("reduce_by_key_new_key_flags");
|
||||
k.add_set_arg<const uint_>("count", uint_(number_of_keys));
|
||||
|
||||
k <<
|
||||
k.decl<const uint_>("gid") << " = get_global_id(0);\n" <<
|
||||
k.decl<uint_>("value") << " = 0;\n" <<
|
||||
"if(gid >= count){\n return;\n}\n" <<
|
||||
"if(gid > 0){ \n" <<
|
||||
k.decl<key_type>("key") << " = " <<
|
||||
keys_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
k.decl<key_type>("previous_key") << " = " <<
|
||||
keys_first[k.var<const uint_>("gid - 1")] << ";\n" <<
|
||||
" value = " << predicate(k.var<key_type>("previous_key"),
|
||||
k.var<key_type>("key")) <<
|
||||
" ? 0 : 1;\n" <<
|
||||
"}\n else {\n" <<
|
||||
" value = 0;\n" <<
|
||||
"}\n" <<
|
||||
new_keys_first[k.var<const uint_>("gid")] << " = value;\n";
|
||||
|
||||
const context &context = queue.get_context();
|
||||
kernel kernel = k.compile(context);
|
||||
|
||||
size_t work_group_size = preferred_work_group_size;
|
||||
size_t work_groups_no = static_cast<size_t>(
|
||||
std::ceil(float(number_of_keys) / work_group_size)
|
||||
);
|
||||
|
||||
queue.enqueue_1d_range_kernel(kernel,
|
||||
0,
|
||||
work_groups_no * work_group_size,
|
||||
work_group_size);
|
||||
|
||||
inclusive_scan(new_keys_first, new_keys_first + number_of_keys,
|
||||
new_keys_first, queue);
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
/// Calculate carry-out for each work group.
|
||||
/// Carry-out is a pair of the last key processed by a work group and sum of all
|
||||
/// values under this key in this work group.
|
||||
template<class InputValueIterator, class OutputValueIterator, class BinaryFunction>
|
||||
inline void carry_outs(vector<uint_>::iterator keys_first,
|
||||
InputValueIterator values_first,
|
||||
size_t count,
|
||||
vector<uint_>::iterator carry_out_keys_first,
|
||||
OutputValueIterator carry_out_values_first,
|
||||
BinaryFunction function,
|
||||
size_t work_group_size,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<OutputValueIterator>::value_type value_out_type;
|
||||
|
||||
detail::meta_kernel k("reduce_by_key_with_scan_carry_outs");
|
||||
k.add_set_arg<const uint_>("count", uint_(count));
|
||||
size_t local_keys_arg = k.add_arg<uint_ *>(memory_object::local_memory, "lkeys");
|
||||
size_t local_vals_arg = k.add_arg<value_out_type *>(memory_object::local_memory, "lvals");
|
||||
|
||||
k <<
|
||||
k.decl<const uint_>("gid") << " = get_global_id(0);\n" <<
|
||||
k.decl<const uint_>("wg_size") << " = get_local_size(0);\n" <<
|
||||
k.decl<const uint_>("lid") << " = get_local_id(0);\n" <<
|
||||
k.decl<const uint_>("group_id") << " = get_group_id(0);\n" <<
|
||||
|
||||
k.decl<uint_>("key") << ";\n" <<
|
||||
k.decl<value_out_type>("value") << ";\n" <<
|
||||
"if(gid < count){\n" <<
|
||||
k.var<uint_>("key") << " = " <<
|
||||
keys_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
k.var<value_out_type>("value") << " = " <<
|
||||
values_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
"lkeys[lid] = key;\n" <<
|
||||
"lvals[lid] = value;\n" <<
|
||||
"}\n" <<
|
||||
|
||||
// Calculate carry out for each work group by performing Hillis/Steele scan
|
||||
// where only last element (key-value pair) is saved
|
||||
k.decl<value_out_type>("result") << " = value;\n" <<
|
||||
k.decl<uint_>("other_key") << ";\n" <<
|
||||
k.decl<value_out_type>("other_value") << ";\n" <<
|
||||
|
||||
"for(" << k.decl<uint_>("offset") << " = 1; " <<
|
||||
"offset < wg_size; offset *= 2){\n"
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" if(lid >= offset){\n"
|
||||
" other_key = lkeys[lid - offset];\n" <<
|
||||
" if(other_key == key){\n" <<
|
||||
" other_value = lvals[lid - offset];\n" <<
|
||||
" result = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("other_value")) << ";\n" <<
|
||||
" }\n" <<
|
||||
" }\n" <<
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" lvals[lid] = result;\n" <<
|
||||
"}\n" <<
|
||||
|
||||
// save carry out
|
||||
"if(lid == (wg_size - 1)){\n" <<
|
||||
carry_out_keys_first[k.var<const uint_>("group_id")] << " = key;\n" <<
|
||||
carry_out_values_first[k.var<const uint_>("group_id")] << " = result;\n" <<
|
||||
"}\n";
|
||||
|
||||
size_t work_groups_no = static_cast<size_t>(
|
||||
std::ceil(float(count) / work_group_size)
|
||||
);
|
||||
|
||||
const context &context = queue.get_context();
|
||||
kernel kernel = k.compile(context);
|
||||
kernel.set_arg(local_keys_arg, local_buffer<uint_>(work_group_size));
|
||||
kernel.set_arg(local_vals_arg, local_buffer<value_out_type>(work_group_size));
|
||||
|
||||
queue.enqueue_1d_range_kernel(kernel,
|
||||
0,
|
||||
work_groups_no * work_group_size,
|
||||
work_group_size);
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
/// Calculate carry-in by performing inclusive scan by key on carry-outs vector.
|
||||
template<class OutputValueIterator, class BinaryFunction>
|
||||
inline void carry_ins(vector<uint_>::iterator carry_out_keys_first,
|
||||
OutputValueIterator carry_out_values_first,
|
||||
OutputValueIterator carry_in_values_first,
|
||||
size_t carry_out_size,
|
||||
BinaryFunction function,
|
||||
size_t work_group_size,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<OutputValueIterator>::value_type value_out_type;
|
||||
|
||||
uint_ values_pre_work_item = static_cast<uint_>(
|
||||
std::ceil(float(carry_out_size) / work_group_size)
|
||||
);
|
||||
|
||||
detail::meta_kernel k("reduce_by_key_with_scan_carry_ins");
|
||||
k.add_set_arg<const uint_>("carry_out_size", uint_(carry_out_size));
|
||||
k.add_set_arg<const uint_>("values_per_work_item", values_pre_work_item);
|
||||
size_t local_keys_arg = k.add_arg<uint_ *>(memory_object::local_memory, "lkeys");
|
||||
size_t local_vals_arg = k.add_arg<value_out_type *>(memory_object::local_memory, "lvals");
|
||||
|
||||
k <<
|
||||
k.decl<uint_>("id") << " = get_global_id(0) * values_per_work_item;\n" <<
|
||||
k.decl<uint_>("idx") << " = id;\n" <<
|
||||
k.decl<const uint_>("wg_size") << " = get_local_size(0);\n" <<
|
||||
k.decl<const uint_>("lid") << " = get_local_id(0);\n" <<
|
||||
k.decl<const uint_>("group_id") << " = get_group_id(0);\n" <<
|
||||
|
||||
k.decl<uint_>("key") << ";\n" <<
|
||||
k.decl<value_out_type>("value") << ";\n" <<
|
||||
k.decl<uint_>("previous_key") << ";\n" <<
|
||||
k.decl<value_out_type>("result") << ";\n" <<
|
||||
|
||||
"if(id < carry_out_size){\n" <<
|
||||
k.var<uint_>("previous_key") << " = " <<
|
||||
carry_out_keys_first[k.var<const uint_>("id")] << ";\n" <<
|
||||
k.var<value_out_type>("result") << " = " <<
|
||||
carry_out_values_first[k.var<const uint_>("id")] << ";\n" <<
|
||||
carry_in_values_first[k.var<const uint_>("id")] << " = result;\n" <<
|
||||
"}\n" <<
|
||||
|
||||
k.decl<const uint_>("end") << " = (id + values_per_work_item) <= carry_out_size" <<
|
||||
" ? (values_per_work_item + id) : carry_out_size;\n" <<
|
||||
|
||||
"for(idx = idx + 1; idx < end; idx += 1){\n" <<
|
||||
" key = " << carry_out_keys_first[k.var<const uint_>("idx")] << ";\n" <<
|
||||
" value = " << carry_out_values_first[k.var<const uint_>("idx")] << ";\n" <<
|
||||
" if(previous_key == key){\n" <<
|
||||
" result = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("value")) << ";\n" <<
|
||||
" }\n else { \n" <<
|
||||
" result = value;\n"
|
||||
" }\n" <<
|
||||
" " << carry_in_values_first[k.var<const uint_>("idx")] << " = result;\n" <<
|
||||
" previous_key = key;\n"
|
||||
"}\n" <<
|
||||
|
||||
// save the last key and result to local memory
|
||||
"lkeys[lid] = previous_key;\n" <<
|
||||
"lvals[lid] = result;\n" <<
|
||||
|
||||
// Hillis/Steele scan
|
||||
"for(" << k.decl<uint_>("offset") << " = 1; " <<
|
||||
"offset < wg_size; offset *= 2){\n"
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" if(lid >= offset){\n"
|
||||
" key = lkeys[lid - offset];\n" <<
|
||||
" if(previous_key == key){\n" <<
|
||||
" value = lvals[lid - offset];\n" <<
|
||||
" result = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("value")) << ";\n" <<
|
||||
" }\n" <<
|
||||
" }\n" <<
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" lvals[lid] = result;\n" <<
|
||||
"}\n" <<
|
||||
"barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
|
||||
"if(lid > 0){\n" <<
|
||||
// load key-value reduced by previous work item
|
||||
" previous_key = lkeys[lid - 1];\n" <<
|
||||
" result = lvals[lid - 1];\n" <<
|
||||
"}\n" <<
|
||||
|
||||
// add key-value reduced by previous work item
|
||||
"for(idx = id; idx < id + values_per_work_item; idx += 1){\n" <<
|
||||
// make sure all carry-ins are saved in global memory
|
||||
" barrier( CLK_GLOBAL_MEM_FENCE );\n" <<
|
||||
" if(lid > 0 && idx < carry_out_size) {\n"
|
||||
" key = " << carry_out_keys_first[k.var<const uint_>("idx")] << ";\n" <<
|
||||
" value = " << carry_in_values_first[k.var<const uint_>("idx")] << ";\n" <<
|
||||
" if(previous_key == key){\n" <<
|
||||
" value = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("value")) << ";\n" <<
|
||||
" }\n" <<
|
||||
" " << carry_in_values_first[k.var<const uint_>("idx")] << " = value;\n" <<
|
||||
" }\n" <<
|
||||
"}\n";
|
||||
|
||||
|
||||
const context &context = queue.get_context();
|
||||
kernel kernel = k.compile(context);
|
||||
kernel.set_arg(local_keys_arg, local_buffer<uint_>(work_group_size));
|
||||
kernel.set_arg(local_vals_arg, local_buffer<value_out_type>(work_group_size));
|
||||
|
||||
queue.enqueue_1d_range_kernel(kernel,
|
||||
0,
|
||||
work_group_size,
|
||||
work_group_size);
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
///
|
||||
/// Perform final reduction by key. Each work item:
|
||||
/// 1. Perform local work-group reduction (Hillis/Steele scan)
|
||||
/// 2. Add carry-in (if keys are right)
|
||||
/// 3. Save reduced value if next key is different than processed one
|
||||
template<class InputKeyIterator, class InputValueIterator,
|
||||
class OutputKeyIterator, class OutputValueIterator,
|
||||
class BinaryFunction>
|
||||
inline void final_reduction(InputKeyIterator keys_first,
|
||||
InputValueIterator values_first,
|
||||
OutputKeyIterator keys_result,
|
||||
OutputValueIterator values_result,
|
||||
size_t count,
|
||||
BinaryFunction function,
|
||||
vector<uint_>::iterator new_keys_first,
|
||||
vector<uint_>::iterator carry_in_keys_first,
|
||||
OutputValueIterator carry_in_values_first,
|
||||
size_t carry_in_size,
|
||||
size_t work_group_size,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<OutputValueIterator>::value_type value_out_type;
|
||||
|
||||
detail::meta_kernel k("reduce_by_key_with_scan_final_reduction");
|
||||
k.add_set_arg<const uint_>("count", uint_(count));
|
||||
size_t local_keys_arg = k.add_arg<uint_ *>(memory_object::local_memory, "lkeys");
|
||||
size_t local_vals_arg = k.add_arg<value_out_type *>(memory_object::local_memory, "lvals");
|
||||
|
||||
k <<
|
||||
k.decl<const uint_>("gid") << " = get_global_id(0);\n" <<
|
||||
k.decl<const uint_>("wg_size") << " = get_local_size(0);\n" <<
|
||||
k.decl<const uint_>("lid") << " = get_local_id(0);\n" <<
|
||||
k.decl<const uint_>("group_id") << " = get_group_id(0);\n" <<
|
||||
|
||||
k.decl<uint_>("key") << ";\n" <<
|
||||
k.decl<value_out_type>("value") << ";\n"
|
||||
|
||||
"if(gid < count){\n" <<
|
||||
k.var<uint_>("key") << " = " <<
|
||||
new_keys_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
k.var<value_out_type>("value") << " = " <<
|
||||
values_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
"lkeys[lid] = key;\n" <<
|
||||
"lvals[lid] = value;\n" <<
|
||||
"}\n" <<
|
||||
|
||||
// Hillis/Steele scan
|
||||
k.decl<value_out_type>("result") << " = value;\n" <<
|
||||
k.decl<uint_>("other_key") << ";\n" <<
|
||||
k.decl<value_out_type>("other_value") << ";\n" <<
|
||||
|
||||
"for(" << k.decl<uint_>("offset") << " = 1; " <<
|
||||
"offset < wg_size ; offset *= 2){\n"
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" if(lid >= offset) {\n" <<
|
||||
" other_key = lkeys[lid - offset];\n" <<
|
||||
" if(other_key == key){\n" <<
|
||||
" other_value = lvals[lid - offset];\n" <<
|
||||
" result = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("other_value")) << ";\n" <<
|
||||
" }\n" <<
|
||||
" }\n" <<
|
||||
" barrier(CLK_LOCAL_MEM_FENCE);\n" <<
|
||||
" lvals[lid] = result;\n" <<
|
||||
"}\n" <<
|
||||
|
||||
"if(gid >= count) {\n return;\n};\n" <<
|
||||
|
||||
k.decl<const bool>("save") << " = (gid < (count - 1)) ?"
|
||||
<< new_keys_first[k.var<const uint_>("gid + 1")] << " != key" <<
|
||||
": true;\n" <<
|
||||
|
||||
// Add carry in
|
||||
k.decl<uint_>("carry_in_key") << ";\n" <<
|
||||
"if(group_id > 0 && save) {\n" <<
|
||||
" carry_in_key = " << carry_in_keys_first[k.var<const uint_>("group_id - 1")] << ";\n" <<
|
||||
" if(key == carry_in_key){\n" <<
|
||||
" other_value = " << carry_in_values_first[k.var<const uint_>("group_id - 1")] << ";\n" <<
|
||||
" result = " << function(k.var<value_out_type>("result"),
|
||||
k.var<value_out_type>("other_value")) << ";\n" <<
|
||||
" }\n" <<
|
||||
"}\n" <<
|
||||
|
||||
// Save result only if the next key is different or it's the last element.
|
||||
"if(save){\n" <<
|
||||
keys_result[k.var<uint_>("key")] << " = " << keys_first[k.var<const uint_>("gid")] << ";\n" <<
|
||||
values_result[k.var<uint_>("key")] << " = result;\n" <<
|
||||
"}\n"
|
||||
;
|
||||
|
||||
size_t work_groups_no = static_cast<size_t>(
|
||||
std::ceil(float(count) / work_group_size)
|
||||
);
|
||||
|
||||
const context &context = queue.get_context();
|
||||
kernel kernel = k.compile(context);
|
||||
kernel.set_arg(local_keys_arg, local_buffer<uint_>(work_group_size));
|
||||
kernel.set_arg(local_vals_arg, local_buffer<value_out_type>(work_group_size));
|
||||
|
||||
queue.enqueue_1d_range_kernel(kernel,
|
||||
0,
|
||||
work_groups_no * work_group_size,
|
||||
work_group_size);
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
/// Returns preferred work group size for reduce by key with scan algorithm.
|
||||
template<class KeyType, class ValueType>
|
||||
inline size_t get_work_group_size(const device& device)
|
||||
{
|
||||
std::string cache_key = std::string("__boost_reduce_by_key_with_scan")
|
||||
+ "k_" + type_name<KeyType>() + "_v_" + type_name<ValueType>();
|
||||
|
||||
// load parameters
|
||||
boost::shared_ptr<parameter_cache> parameters =
|
||||
detail::parameter_cache::get_global_cache(device);
|
||||
|
||||
return (std::max)(
|
||||
static_cast<size_t>(parameters->get(cache_key, "wgsize", 256)),
|
||||
static_cast<size_t>(device.get_info<CL_DEVICE_MAX_WORK_GROUP_SIZE>())
|
||||
);
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
///
|
||||
/// 1. For each work group carry-out value is calculated (it's done by key-oriented
|
||||
/// Hillis/Steele scan). Carry-out is a pair of the last key processed by work
|
||||
/// group and sum of all values under this key in work group.
|
||||
/// 2. From every carry-out carry-in is calculated by performing inclusive scan
|
||||
/// by key.
|
||||
/// 3. Final reduction by key is performed (key-oriented Hillis/Steele scan),
|
||||
/// carry-in values are added where needed.
|
||||
template<class InputKeyIterator, class InputValueIterator,
|
||||
class OutputKeyIterator, class OutputValueIterator,
|
||||
class BinaryFunction, class BinaryPredicate>
|
||||
inline size_t reduce_by_key_with_scan(InputKeyIterator keys_first,
|
||||
InputKeyIterator keys_last,
|
||||
InputValueIterator values_first,
|
||||
OutputKeyIterator keys_result,
|
||||
OutputValueIterator values_result,
|
||||
BinaryFunction function,
|
||||
BinaryPredicate predicate,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<InputValueIterator>::value_type value_type;
|
||||
typedef typename
|
||||
std::iterator_traits<InputKeyIterator>::value_type key_type;
|
||||
typedef typename
|
||||
std::iterator_traits<OutputValueIterator>::value_type value_out_type;
|
||||
|
||||
const context &context = queue.get_context();
|
||||
size_t count = detail::iterator_range_size(keys_first, keys_last);
|
||||
|
||||
if(count == 0){
|
||||
return size_t(0);
|
||||
}
|
||||
|
||||
const device &device = queue.get_device();
|
||||
size_t work_group_size = get_work_group_size<value_type, key_type>(device);
|
||||
|
||||
// Replace original key with unsigned integer keys generated based on given
|
||||
// predicate. New key is also an index for keys_result and values_result vectors,
|
||||
// which points to place where reduced value should be saved.
|
||||
vector<uint_> new_keys(count, context);
|
||||
vector<uint_>::iterator new_keys_first = new_keys.begin();
|
||||
generate_uint_keys(keys_first, count, predicate, new_keys_first,
|
||||
work_group_size, queue);
|
||||
|
||||
// Calculate carry-out and carry-in vectors size
|
||||
const size_t carry_out_size = static_cast<size_t>(
|
||||
std::ceil(float(count) / work_group_size)
|
||||
);
|
||||
vector<uint_> carry_out_keys(carry_out_size, context);
|
||||
vector<value_out_type> carry_out_values(carry_out_size, context);
|
||||
carry_outs(new_keys_first, values_first, count, carry_out_keys.begin(),
|
||||
carry_out_values.begin(), function, work_group_size, queue);
|
||||
|
||||
vector<value_out_type> carry_in_values(carry_out_size, context);
|
||||
carry_ins(carry_out_keys.begin(), carry_out_values.begin(),
|
||||
carry_in_values.begin(), carry_out_size, function, work_group_size,
|
||||
queue);
|
||||
|
||||
final_reduction(keys_first, values_first, keys_result, values_result,
|
||||
count, function, new_keys_first, carry_out_keys.begin(),
|
||||
carry_in_values.begin(), carry_out_size, work_group_size,
|
||||
queue);
|
||||
|
||||
const size_t result = read_single_value<uint_>(new_keys.get_buffer(),
|
||||
count - 1, queue);
|
||||
return result + 1;
|
||||
}
|
||||
|
||||
/// \internal_
|
||||
/// Return true if requirements for running reduce by key with scan on given
|
||||
/// device are met (at least one work group of preferred size can be run).
|
||||
template<class InputKeyIterator, class InputValueIterator,
|
||||
class OutputKeyIterator, class OutputValueIterator>
|
||||
bool reduce_by_key_with_scan_requirements_met(InputKeyIterator keys_first,
|
||||
InputValueIterator values_first,
|
||||
OutputKeyIterator keys_result,
|
||||
OutputValueIterator values_result,
|
||||
const size_t count,
|
||||
command_queue &queue)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<InputValueIterator>::value_type value_type;
|
||||
typedef typename
|
||||
std::iterator_traits<InputKeyIterator>::value_type key_type;
|
||||
typedef typename
|
||||
std::iterator_traits<OutputValueIterator>::value_type value_out_type;
|
||||
|
||||
(void) keys_first;
|
||||
(void) values_first;
|
||||
(void) keys_result;
|
||||
(void) values_result;
|
||||
|
||||
const device &device = queue.get_device();
|
||||
// device must have dedicated local memory storage
|
||||
if(device.get_info<CL_DEVICE_LOCAL_MEM_TYPE>() != CL_LOCAL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// local memory size in bytes (per compute unit)
|
||||
const size_t local_mem_size = device.get_info<CL_DEVICE_LOCAL_MEM_SIZE>();
|
||||
|
||||
// preferred work group size
|
||||
size_t work_group_size = get_work_group_size<key_type, value_type>(device);
|
||||
|
||||
// local memory size needed to perform parallel reduction
|
||||
size_t required_local_mem_size = 0;
|
||||
// keys size
|
||||
required_local_mem_size += sizeof(uint_) * work_group_size;
|
||||
// reduced values size
|
||||
required_local_mem_size += sizeof(value_out_type) * work_group_size;
|
||||
|
||||
return (required_local_mem_size <= local_mem_size);
|
||||
}
|
||||
|
||||
} // end detail namespace
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_ALGORITHM_DETAIL_REDUCE_BY_KEY_WITH_SCAN_HPP
|
||||
@@ -0,0 +1,36 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_ACCELERATION_HPP
|
||||
#define BOOST_UNITS_SI_ACCELERATION_HPP
|
||||
|
||||
#include <boost/units/systems/si/base.hpp>
|
||||
#include <boost/units/physical_dimensions/acceleration.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
typedef unit<acceleration_dimension,si::system> acceleration;
|
||||
|
||||
BOOST_UNITS_STATIC_CONSTANT(meter_per_second_squared,acceleration);
|
||||
BOOST_UNITS_STATIC_CONSTANT(meters_per_second_squared,acceleration);
|
||||
BOOST_UNITS_STATIC_CONSTANT(metre_per_second_squared,acceleration);
|
||||
BOOST_UNITS_STATIC_CONSTANT(metres_per_second_squared,acceleration);
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SI_ACCELERATION_HPP
|
||||
@@ -0,0 +1,42 @@
|
||||
# /* Copyright (C) 2001
|
||||
# * Housemarque Oy
|
||||
# * http://www.housemarque.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)
|
||||
# */
|
||||
#
|
||||
# /* Revised by Paul Mensonides (2002) */
|
||||
#
|
||||
# /* See http://www.boost.org for most recent version. */
|
||||
#
|
||||
# ifndef BOOST_PREPROCESSOR_LIST_CAT_HPP
|
||||
# define BOOST_PREPROCESSOR_LIST_CAT_HPP
|
||||
#
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/config/config.hpp>
|
||||
# include <boost/preprocessor/list/adt.hpp>
|
||||
# include <boost/preprocessor/list/fold_left.hpp>
|
||||
#
|
||||
# /* BOOST_PP_LIST_CAT */
|
||||
#
|
||||
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
||||
# define BOOST_PP_LIST_CAT(list) BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list))
|
||||
# else
|
||||
# define BOOST_PP_LIST_CAT(list) BOOST_PP_LIST_CAT_I(list)
|
||||
# define BOOST_PP_LIST_CAT_I(list) BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list))
|
||||
# endif
|
||||
#
|
||||
# define BOOST_PP_LIST_CAT_O(d, s, x) BOOST_PP_CAT(s, x)
|
||||
#
|
||||
# /* BOOST_PP_LIST_CAT_D */
|
||||
#
|
||||
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
||||
# define BOOST_PP_LIST_CAT_D(d, list) BOOST_PP_LIST_FOLD_LEFT_ ## d(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list))
|
||||
# else
|
||||
# define BOOST_PP_LIST_CAT_D(d, list) BOOST_PP_LIST_CAT_D_I(d, list)
|
||||
# define BOOST_PP_LIST_CAT_D_I(d, list) BOOST_PP_LIST_FOLD_LEFT_ ## d(BOOST_PP_LIST_CAT_O, BOOST_PP_LIST_FIRST(list), BOOST_PP_LIST_REST(list))
|
||||
# endif
|
||||
#
|
||||
# endif
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
@@ -0,0 +1,57 @@
|
||||
module timer_c_wrapper
|
||||
use :: iso_c_binding, only: c_ptr
|
||||
use timer_module, only: timer, null_timer
|
||||
implicit none
|
||||
|
||||
!
|
||||
! C interoperable callback setup
|
||||
!
|
||||
abstract interface
|
||||
subroutine c_timer_callback (context, dname, k)
|
||||
use, intrinsic :: iso_c_binding, only: c_ptr, c_char
|
||||
implicit none
|
||||
type(c_ptr), value, intent(in) :: context
|
||||
character(c_char), intent(in) :: dname(*)
|
||||
integer, intent(in), value :: k
|
||||
end subroutine c_timer_callback
|
||||
end interface
|
||||
|
||||
public :: init, fini
|
||||
|
||||
private
|
||||
|
||||
!
|
||||
! the following are singleton items which assumes that any timer
|
||||
! implementation should only assume one global instance, probably a
|
||||
! struct or class object whose address is stored the context below
|
||||
!
|
||||
type(c_ptr), private :: the_context
|
||||
procedure(C_timer_callback), pointer, private :: the_callback
|
||||
|
||||
contains
|
||||
subroutine timer_callback_wrapper (dname, k)
|
||||
use, intrinsic :: iso_c_binding, only: c_null_char
|
||||
implicit none
|
||||
character(len=8), intent(in) :: dname
|
||||
integer, intent(in) :: k
|
||||
call the_callback (the_context, trim (dname) // c_null_char, k)
|
||||
end subroutine timer_callback_wrapper
|
||||
|
||||
subroutine init (context, callback)
|
||||
use, intrinsic :: iso_c_binding, only: c_ptr, c_funptr, c_f_procpointer
|
||||
use iso_c_utilities, only: c_to_f_string
|
||||
use timer_module, only: timer
|
||||
implicit none
|
||||
type(c_ptr), value, intent(in) :: context
|
||||
type(c_funptr), value, intent(in) :: callback
|
||||
the_context=context
|
||||
call c_f_procpointer (callback, the_callback)
|
||||
timer => timer_callback_wrapper
|
||||
end subroutine init
|
||||
|
||||
subroutine fini ()
|
||||
implicit none
|
||||
timer => null_timer
|
||||
end subroutine fini
|
||||
|
||||
end module timer_c_wrapper
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Boost interval/limits.hpp template implementation file
|
||||
*
|
||||
* Copyright 2000 Jens Maurer
|
||||
* Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or
|
||||
* copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_NUMERIC_INTERVAL_LIMITS_HPP
|
||||
#define BOOST_NUMERIC_INTERVAL_LIMITS_HPP
|
||||
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/numeric/interval/detail/interval_prototype.hpp>
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class Policies>
|
||||
class numeric_limits<boost::numeric::interval<T, Policies> >
|
||||
: public numeric_limits<T>
|
||||
{
|
||||
private:
|
||||
typedef boost::numeric::interval<T, Policies> I;
|
||||
typedef numeric_limits<T> bl;
|
||||
public:
|
||||
static I min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return I((bl::min)(), (bl::min)()); }
|
||||
static I max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return I((bl::max)(), (bl::max)()); }
|
||||
static I epsilon() throw() { return I(bl::epsilon(), bl::epsilon()); }
|
||||
|
||||
BOOST_STATIC_CONSTANT(float_round_style, round_style = round_indeterminate);
|
||||
BOOST_STATIC_CONSTANT(bool, is_iec559 = false);
|
||||
|
||||
static I infinity () throw() { return I::whole(); }
|
||||
static I quiet_NaN() throw() { return I::empty(); }
|
||||
static I signaling_NaN() throw()
|
||||
{ return I(bl::signaling_NaN(), bl::signaling_Nan()); }
|
||||
static I denorm_min() throw()
|
||||
{ return I(bl::denorm_min(), bl::denorm_min()); }
|
||||
private:
|
||||
static I round_error(); // hide this on purpose, not yet implemented
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
#endif // BOOST_NUMERIC_INTERVAL_LIMITS_HPP
|
||||
@@ -0,0 +1,16 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file context.hpp
|
||||
/// Includes all the context classes in the context/ sub-directory.
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROTO_CONTEXT_HPP_EAN_06_23_2007
|
||||
#define BOOST_PROTO_CONTEXT_HPP_EAN_06_23_2007
|
||||
|
||||
#include <boost/proto/context/null.hpp>
|
||||
#include <boost/proto/context/default.hpp>
|
||||
#include <boost/proto/context/callable.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
subroutine zplot9(s,freq,drift)
|
||||
|
||||
real s(0:8,85)
|
||||
character*1 line(85),mark(0:6)
|
||||
data mark/' ',' ','.','-','+','X','$'/
|
||||
include 'jt9sync.f90'
|
||||
|
||||
write(32,1000) freq,drift
|
||||
1000 format('Freq:',f7.1,' Drift:',f5.1,' ',60('-'))
|
||||
do j=8,0,-1
|
||||
do i=1,85
|
||||
n=(s(j,i))
|
||||
if(n.lt.0) n=0
|
||||
if(n.gt.6) n=6
|
||||
line(i)=mark(n)
|
||||
enddo
|
||||
write(32,1010) j,line
|
||||
1010 format(i1,1x,85a1)
|
||||
enddo
|
||||
do i=1,85
|
||||
line(i)=' '
|
||||
if(isync(i).eq.1) line(i)='@'
|
||||
enddo
|
||||
write(32,1015)
|
||||
1015 format(87('-'))
|
||||
write(32,1020) line
|
||||
1020 format(2x,85a1)
|
||||
call flush(32)
|
||||
|
||||
return
|
||||
end subroutine zplot9
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
// boost/chrono/round.hpp ------------------------------------------------------------//
|
||||
|
||||
// (C) Copyright Howard Hinnant
|
||||
// Copyright 2011 Vicente J. Botet Escriba
|
||||
|
||||
// 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/chrono for documentation.
|
||||
|
||||
#ifndef BOOST_CHRONO_ROUND_HPP
|
||||
#define BOOST_CHRONO_ROUND_HPP
|
||||
|
||||
#include <boost/chrono/duration.hpp>
|
||||
#include <boost/chrono/duration.hpp>
|
||||
//#include <boost/chrono/typeof/boost/chrono/chrono.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace chrono
|
||||
{
|
||||
|
||||
/**
|
||||
* rounds to nearest, to even on tie
|
||||
*/
|
||||
template <class To, class Rep, class Period>
|
||||
To round(const duration<Rep, Period>& d)
|
||||
{
|
||||
typedef typename common_type<To, duration<Rep, Period> >::type result_type;
|
||||
result_type diff0;
|
||||
result_type diff1;
|
||||
|
||||
To t0 = duration_cast<To>(d);
|
||||
To t1 = t0;
|
||||
if (t0>d) {
|
||||
--t1;
|
||||
diff0 = t0 - d;
|
||||
diff1 = d - t1;
|
||||
} else {
|
||||
++t1;
|
||||
diff0 = d - t0;
|
||||
diff1 = t1 - d;
|
||||
}
|
||||
|
||||
if (diff0 == diff1)
|
||||
{
|
||||
if (t0.count() & 1)
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
else if (diff0 < diff1)
|
||||
return t0;
|
||||
return t1;
|
||||
}
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,875 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_ITERATORS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/detail/value_init.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/intrusive/detail/reverse_iterator.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/move/detail/fwd_macros.hpp>
|
||||
#else
|
||||
#include <boost/container/detail/variadic_templates_tools.hpp>
|
||||
#endif
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
template <class T, class Difference = std::ptrdiff_t>
|
||||
class constant_iterator
|
||||
: public ::boost::container::iterator
|
||||
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
|
||||
{
|
||||
typedef constant_iterator<T, Difference> this_type;
|
||||
|
||||
public:
|
||||
explicit constant_iterator(const T &ref, Difference range_size)
|
||||
: m_ptr(&ref), m_num(range_size){}
|
||||
|
||||
//Constructors
|
||||
constant_iterator()
|
||||
: m_ptr(0), m_num(0){}
|
||||
|
||||
constant_iterator& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
constant_iterator operator++(int)
|
||||
{
|
||||
constant_iterator result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
constant_iterator& operator--()
|
||||
{ decrement(); return *this; }
|
||||
|
||||
constant_iterator operator--(int)
|
||||
{
|
||||
constant_iterator result (*this);
|
||||
decrement();
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator== (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
friend bool operator!= (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
friend bool operator< (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return i.less(i2); }
|
||||
|
||||
friend bool operator> (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
friend bool operator<= (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
friend bool operator>= (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
friend Difference operator- (const constant_iterator& i, const constant_iterator& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
constant_iterator& operator+=(Difference off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
constant_iterator operator+(Difference off) const
|
||||
{
|
||||
constant_iterator other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
friend constant_iterator operator+(Difference off, const constant_iterator& right)
|
||||
{ return right + off; }
|
||||
|
||||
constant_iterator& operator-=(Difference off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
constant_iterator operator-(Difference off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
const T& operator*() const
|
||||
{ return dereference(); }
|
||||
|
||||
const T& operator[] (Difference ) const
|
||||
{ return dereference(); }
|
||||
|
||||
const T* operator->() const
|
||||
{ return &(dereference()); }
|
||||
|
||||
private:
|
||||
const T * m_ptr;
|
||||
Difference m_num;
|
||||
|
||||
void increment()
|
||||
{ --m_num; }
|
||||
|
||||
void decrement()
|
||||
{ ++m_num; }
|
||||
|
||||
bool equal(const this_type &other) const
|
||||
{ return m_num == other.m_num; }
|
||||
|
||||
bool less(const this_type &other) const
|
||||
{ return other.m_num < m_num; }
|
||||
|
||||
const T & dereference() const
|
||||
{ return *m_ptr; }
|
||||
|
||||
void advance(Difference n)
|
||||
{ m_num -= n; }
|
||||
|
||||
Difference distance_to(const this_type &other)const
|
||||
{ return m_num - other.m_num; }
|
||||
};
|
||||
|
||||
template <class T, class Difference>
|
||||
class value_init_construct_iterator
|
||||
: public ::boost::container::iterator
|
||||
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
|
||||
{
|
||||
typedef value_init_construct_iterator<T, Difference> this_type;
|
||||
|
||||
public:
|
||||
explicit value_init_construct_iterator(Difference range_size)
|
||||
: m_num(range_size){}
|
||||
|
||||
//Constructors
|
||||
value_init_construct_iterator()
|
||||
: m_num(0){}
|
||||
|
||||
value_init_construct_iterator& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
value_init_construct_iterator operator++(int)
|
||||
{
|
||||
value_init_construct_iterator result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
value_init_construct_iterator& operator--()
|
||||
{ decrement(); return *this; }
|
||||
|
||||
value_init_construct_iterator operator--(int)
|
||||
{
|
||||
value_init_construct_iterator result (*this);
|
||||
decrement();
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator== (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
friend bool operator!= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
friend bool operator< (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return i.less(i2); }
|
||||
|
||||
friend bool operator> (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
friend bool operator<= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
friend bool operator>= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
friend Difference operator- (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
value_init_construct_iterator& operator+=(Difference off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
value_init_construct_iterator operator+(Difference off) const
|
||||
{
|
||||
value_init_construct_iterator other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
friend value_init_construct_iterator operator+(Difference off, const value_init_construct_iterator& right)
|
||||
{ return right + off; }
|
||||
|
||||
value_init_construct_iterator& operator-=(Difference off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
value_init_construct_iterator operator-(Difference off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
//This pseudo-iterator's dereference operations have no sense since value is not
|
||||
//constructed until ::boost::container::construct_in_place is called.
|
||||
//So comment them to catch bad uses
|
||||
//const T& operator*() const;
|
||||
//const T& operator[](difference_type) const;
|
||||
//const T* operator->() const;
|
||||
|
||||
private:
|
||||
Difference m_num;
|
||||
|
||||
void increment()
|
||||
{ --m_num; }
|
||||
|
||||
void decrement()
|
||||
{ ++m_num; }
|
||||
|
||||
bool equal(const this_type &other) const
|
||||
{ return m_num == other.m_num; }
|
||||
|
||||
bool less(const this_type &other) const
|
||||
{ return other.m_num < m_num; }
|
||||
|
||||
const T & dereference() const
|
||||
{
|
||||
static T dummy;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
void advance(Difference n)
|
||||
{ m_num -= n; }
|
||||
|
||||
Difference distance_to(const this_type &other)const
|
||||
{ return m_num - other.m_num; }
|
||||
};
|
||||
|
||||
template <class T, class Difference>
|
||||
class default_init_construct_iterator
|
||||
: public ::boost::container::iterator
|
||||
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
|
||||
{
|
||||
typedef default_init_construct_iterator<T, Difference> this_type;
|
||||
|
||||
public:
|
||||
explicit default_init_construct_iterator(Difference range_size)
|
||||
: m_num(range_size){}
|
||||
|
||||
//Constructors
|
||||
default_init_construct_iterator()
|
||||
: m_num(0){}
|
||||
|
||||
default_init_construct_iterator& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
default_init_construct_iterator operator++(int)
|
||||
{
|
||||
default_init_construct_iterator result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
default_init_construct_iterator& operator--()
|
||||
{ decrement(); return *this; }
|
||||
|
||||
default_init_construct_iterator operator--(int)
|
||||
{
|
||||
default_init_construct_iterator result (*this);
|
||||
decrement();
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator== (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
friend bool operator!= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
friend bool operator< (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return i.less(i2); }
|
||||
|
||||
friend bool operator> (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
friend bool operator<= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
friend bool operator>= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
friend Difference operator- (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
default_init_construct_iterator& operator+=(Difference off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
default_init_construct_iterator operator+(Difference off) const
|
||||
{
|
||||
default_init_construct_iterator other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
friend default_init_construct_iterator operator+(Difference off, const default_init_construct_iterator& right)
|
||||
{ return right + off; }
|
||||
|
||||
default_init_construct_iterator& operator-=(Difference off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
default_init_construct_iterator operator-(Difference off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
//This pseudo-iterator's dereference operations have no sense since value is not
|
||||
//constructed until ::boost::container::construct_in_place is called.
|
||||
//So comment them to catch bad uses
|
||||
//const T& operator*() const;
|
||||
//const T& operator[](difference_type) const;
|
||||
//const T* operator->() const;
|
||||
|
||||
private:
|
||||
Difference m_num;
|
||||
|
||||
void increment()
|
||||
{ --m_num; }
|
||||
|
||||
void decrement()
|
||||
{ ++m_num; }
|
||||
|
||||
bool equal(const this_type &other) const
|
||||
{ return m_num == other.m_num; }
|
||||
|
||||
bool less(const this_type &other) const
|
||||
{ return other.m_num < m_num; }
|
||||
|
||||
const T & dereference() const
|
||||
{
|
||||
static T dummy;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
void advance(Difference n)
|
||||
{ m_num -= n; }
|
||||
|
||||
Difference distance_to(const this_type &other)const
|
||||
{ return m_num - other.m_num; }
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Difference = std::ptrdiff_t>
|
||||
class repeat_iterator
|
||||
: public ::boost::container::iterator
|
||||
<std::random_access_iterator_tag, T, Difference, T*, T&>
|
||||
{
|
||||
typedef repeat_iterator<T, Difference> this_type;
|
||||
public:
|
||||
explicit repeat_iterator(T &ref, Difference range_size)
|
||||
: m_ptr(&ref), m_num(range_size){}
|
||||
|
||||
//Constructors
|
||||
repeat_iterator()
|
||||
: m_ptr(0), m_num(0){}
|
||||
|
||||
this_type& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
this_type operator++(int)
|
||||
{
|
||||
this_type result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
this_type& operator--()
|
||||
{ increment(); return *this; }
|
||||
|
||||
this_type operator--(int)
|
||||
{
|
||||
this_type result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator== (const this_type& i, const this_type& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
friend bool operator!= (const this_type& i, const this_type& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
friend bool operator< (const this_type& i, const this_type& i2)
|
||||
{ return i.less(i2); }
|
||||
|
||||
friend bool operator> (const this_type& i, const this_type& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
friend bool operator<= (const this_type& i, const this_type& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
friend bool operator>= (const this_type& i, const this_type& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
friend Difference operator- (const this_type& i, const this_type& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
this_type& operator+=(Difference off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
this_type operator+(Difference off) const
|
||||
{
|
||||
this_type other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
friend this_type operator+(Difference off, const this_type& right)
|
||||
{ return right + off; }
|
||||
|
||||
this_type& operator-=(Difference off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
this_type operator-(Difference off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
T& operator*() const
|
||||
{ return dereference(); }
|
||||
|
||||
T& operator[] (Difference ) const
|
||||
{ return dereference(); }
|
||||
|
||||
T *operator->() const
|
||||
{ return &(dereference()); }
|
||||
|
||||
private:
|
||||
T * m_ptr;
|
||||
Difference m_num;
|
||||
|
||||
void increment()
|
||||
{ --m_num; }
|
||||
|
||||
void decrement()
|
||||
{ ++m_num; }
|
||||
|
||||
bool equal(const this_type &other) const
|
||||
{ return m_num == other.m_num; }
|
||||
|
||||
bool less(const this_type &other) const
|
||||
{ return other.m_num < m_num; }
|
||||
|
||||
T & dereference() const
|
||||
{ return *m_ptr; }
|
||||
|
||||
void advance(Difference n)
|
||||
{ m_num -= n; }
|
||||
|
||||
Difference distance_to(const this_type &other)const
|
||||
{ return m_num - other.m_num; }
|
||||
};
|
||||
|
||||
template <class T, class EmplaceFunctor, class Difference /*= std::ptrdiff_t*/>
|
||||
class emplace_iterator
|
||||
: public ::boost::container::iterator
|
||||
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
|
||||
{
|
||||
typedef emplace_iterator this_type;
|
||||
|
||||
public:
|
||||
typedef Difference difference_type;
|
||||
BOOST_CONTAINER_FORCEINLINE explicit emplace_iterator(EmplaceFunctor&e)
|
||||
: m_num(1), m_pe(&e){}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE emplace_iterator()
|
||||
: m_num(0), m_pe(0){}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE this_type& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
this_type operator++(int)
|
||||
{
|
||||
this_type result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE this_type& operator--()
|
||||
{ decrement(); return *this; }
|
||||
|
||||
this_type operator--(int)
|
||||
{
|
||||
this_type result (*this);
|
||||
decrement();
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator== (const this_type& i, const this_type& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const this_type& i, const this_type& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator< (const this_type& i, const this_type& i2)
|
||||
{ return i.less(i2); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator> (const this_type& i, const this_type& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const this_type& i, const this_type& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend difference_type operator- (const this_type& i, const this_type& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
BOOST_CONTAINER_FORCEINLINE this_type& operator+=(difference_type off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
this_type operator+(difference_type off) const
|
||||
{
|
||||
this_type other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend this_type operator+(difference_type off, const this_type& right)
|
||||
{ return right + off; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE this_type& operator-=(difference_type off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE this_type operator-(difference_type off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
private:
|
||||
//This pseudo-iterator's dereference operations have no sense since value is not
|
||||
//constructed until ::boost::container::construct_in_place is called.
|
||||
//So comment them to catch bad uses
|
||||
const T& operator*() const;
|
||||
const T& operator[](difference_type) const;
|
||||
const T* operator->() const;
|
||||
|
||||
public:
|
||||
template<class Allocator>
|
||||
void construct_in_place(Allocator &a, T* ptr)
|
||||
{ (*m_pe)(a, ptr); }
|
||||
|
||||
template<class DestIt>
|
||||
void assign_in_place(DestIt dest)
|
||||
{ (*m_pe)(dest); }
|
||||
|
||||
private:
|
||||
difference_type m_num;
|
||||
EmplaceFunctor * m_pe;
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void increment()
|
||||
{ --m_num; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void decrement()
|
||||
{ ++m_num; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
|
||||
{ return m_num == other.m_num; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
|
||||
{ return other.m_num < m_num; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE const T & dereference() const
|
||||
{
|
||||
static T dummy;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void advance(difference_type n)
|
||||
{ m_num -= n; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE difference_type distance_to(const this_type &other)const
|
||||
{ return difference_type(m_num - other.m_num); }
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class ...Args>
|
||||
struct emplace_functor
|
||||
{
|
||||
typedef typename container_detail::build_number_seq<sizeof...(Args)>::type index_tuple_t;
|
||||
|
||||
emplace_functor(BOOST_FWD_REF(Args)... args)
|
||||
: args_(args...)
|
||||
{}
|
||||
|
||||
template<class Allocator, class T>
|
||||
BOOST_CONTAINER_FORCEINLINE void operator()(Allocator &a, T *ptr)
|
||||
{ emplace_functor::inplace_impl(a, ptr, index_tuple_t()); }
|
||||
|
||||
template<class DestIt>
|
||||
BOOST_CONTAINER_FORCEINLINE void operator()(DestIt dest)
|
||||
{ emplace_functor::inplace_impl(dest, index_tuple_t()); }
|
||||
|
||||
private:
|
||||
template<class Allocator, class T, std::size_t ...IdxPack>
|
||||
BOOST_CONTAINER_FORCEINLINE void inplace_impl(Allocator &a, T* ptr, const container_detail::index_tuple<IdxPack...>&)
|
||||
{
|
||||
allocator_traits<Allocator>::construct
|
||||
(a, ptr, ::boost::forward<Args>(container_detail::get<IdxPack>(args_))...);
|
||||
}
|
||||
|
||||
template<class DestIt, std::size_t ...IdxPack>
|
||||
BOOST_CONTAINER_FORCEINLINE void inplace_impl(DestIt dest, const container_detail::index_tuple<IdxPack...>&)
|
||||
{
|
||||
typedef typename boost::container::iterator_traits<DestIt>::value_type value_type;
|
||||
value_type && tmp= value_type(::boost::forward<Args>(container_detail::get<IdxPack>(args_))...);
|
||||
*dest = ::boost::move(tmp);
|
||||
}
|
||||
|
||||
container_detail::tuple<Args&...> args_;
|
||||
};
|
||||
|
||||
template<class ...Args>
|
||||
struct emplace_functor_type
|
||||
{
|
||||
typedef emplace_functor<Args...> type;
|
||||
};
|
||||
|
||||
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
//Partial specializations cannot match argument list for primary template, so add an extra argument
|
||||
template <BOOST_MOVE_CLASSDFLT9, class Dummy = void>
|
||||
struct emplace_functor_type;
|
||||
|
||||
#define BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE(N) \
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
struct emplace_functor##N\
|
||||
{\
|
||||
explicit emplace_functor##N( BOOST_MOVE_UREF##N )\
|
||||
BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N{}\
|
||||
\
|
||||
template<class Allocator, class T>\
|
||||
void operator()(Allocator &a, T *ptr)\
|
||||
{ allocator_traits<Allocator>::construct(a, ptr BOOST_MOVE_I##N BOOST_MOVE_MFWD##N); }\
|
||||
\
|
||||
template<class DestIt>\
|
||||
void operator()(DestIt dest)\
|
||||
{\
|
||||
typedef typename boost::container::iterator_traits<DestIt>::value_type value_type;\
|
||||
BOOST_MOVE_IF(N, value_type tmp(BOOST_MOVE_MFWD##N), container_detail::value_init<value_type> tmp) ;\
|
||||
*dest = ::boost::move(const_cast<value_type &>(BOOST_MOVE_IF(N, tmp, tmp.get())));\
|
||||
}\
|
||||
\
|
||||
BOOST_MOVE_MREF##N\
|
||||
};\
|
||||
\
|
||||
template <BOOST_MOVE_CLASS##N>\
|
||||
struct emplace_functor_type<BOOST_MOVE_TARG##N>\
|
||||
{\
|
||||
typedef emplace_functor##N BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N type;\
|
||||
};\
|
||||
//
|
||||
|
||||
BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE)
|
||||
|
||||
#undef BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE
|
||||
|
||||
#endif
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
template<class T>
|
||||
struct has_iterator_category
|
||||
{
|
||||
struct two { char _[2]; };
|
||||
|
||||
template <typename X>
|
||||
static char test(int, typename X::iterator_category*);
|
||||
|
||||
template <typename X>
|
||||
static two test(int, ...);
|
||||
|
||||
static const bool value = (1 == sizeof(test<T>(0, 0)));
|
||||
};
|
||||
|
||||
|
||||
template<class T, bool = has_iterator_category<T>::value >
|
||||
struct is_input_iterator
|
||||
{
|
||||
static const bool value = is_same<typename T::iterator_category, std::input_iterator_tag>::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_input_iterator<T, false>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_not_input_iterator
|
||||
{
|
||||
static const bool value = !is_input_iterator<T>::value;
|
||||
};
|
||||
|
||||
template<class T, bool = has_iterator_category<T>::value >
|
||||
struct is_forward_iterator
|
||||
{
|
||||
static const bool value = is_same<typename T::iterator_category, std::forward_iterator_tag>::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_forward_iterator<T, false>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T, bool = has_iterator_category<T>::value >
|
||||
struct is_bidirectional_iterator
|
||||
{
|
||||
static const bool value = is_same<typename T::iterator_category, std::bidirectional_iterator_tag>::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_bidirectional_iterator<T, false>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class IINodeType>
|
||||
struct iiterator_node_value_type {
|
||||
typedef typename IINodeType::value_type type;
|
||||
};
|
||||
|
||||
template<class IIterator>
|
||||
struct iiterator_types
|
||||
{
|
||||
typedef typename IIterator::value_type it_value_type;
|
||||
typedef typename iiterator_node_value_type<it_value_type>::type value_type;
|
||||
typedef typename boost::container::iterator_traits<IIterator>::pointer it_pointer;
|
||||
typedef typename boost::container::iterator_traits<IIterator>::difference_type difference_type;
|
||||
typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
|
||||
template rebind_pointer<value_type>::type pointer;
|
||||
typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
|
||||
template rebind_pointer<const value_type>::type const_pointer;
|
||||
typedef typename ::boost::intrusive::
|
||||
pointer_traits<pointer>::reference reference;
|
||||
typedef typename ::boost::intrusive::
|
||||
pointer_traits<const_pointer>::reference const_reference;
|
||||
typedef typename IIterator::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
template<class IIterator, bool IsConst>
|
||||
struct iterator_types
|
||||
{
|
||||
typedef typename ::boost::container::iterator
|
||||
< typename iiterator_types<IIterator>::iterator_category
|
||||
, typename iiterator_types<IIterator>::value_type
|
||||
, typename iiterator_types<IIterator>::difference_type
|
||||
, typename iiterator_types<IIterator>::const_pointer
|
||||
, typename iiterator_types<IIterator>::const_reference> type;
|
||||
};
|
||||
|
||||
template<class IIterator>
|
||||
struct iterator_types<IIterator, false>
|
||||
{
|
||||
typedef typename ::boost::container::iterator
|
||||
< typename iiterator_types<IIterator>::iterator_category
|
||||
, typename iiterator_types<IIterator>::value_type
|
||||
, typename iiterator_types<IIterator>::difference_type
|
||||
, typename iiterator_types<IIterator>::pointer
|
||||
, typename iiterator_types<IIterator>::reference> type;
|
||||
};
|
||||
|
||||
template<class IIterator, bool IsConst>
|
||||
class iterator_from_iiterator
|
||||
{
|
||||
typedef typename iterator_types<IIterator, IsConst>::type types_t;
|
||||
|
||||
public:
|
||||
typedef typename types_t::pointer pointer;
|
||||
typedef typename types_t::reference reference;
|
||||
typedef typename types_t::difference_type difference_type;
|
||||
typedef typename types_t::iterator_category iterator_category;
|
||||
typedef typename types_t::value_type value_type;
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator()
|
||||
: m_iit()
|
||||
{}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE explicit iterator_from_iiterator(IIterator iit) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
: m_iit(iit)
|
||||
{}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator(iterator_from_iiterator<IIterator, false> const& other) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
: m_iit(other.get())
|
||||
{}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ ++this->m_iit; return *this; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
iterator_from_iiterator result (*this);
|
||||
++this->m_iit;
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
//If the iterator_from_iiterator is not a bidirectional iterator, operator-- should not exist
|
||||
BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator_from_iiterator>::value));
|
||||
--this->m_iit; return *this;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
iterator_from_iiterator result (*this);
|
||||
--this->m_iit;
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator== (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return l.m_iit == r.m_iit; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return !(l == r); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return this->m_iit->get_data(); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->operator*()); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE const IIterator &get() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return this->m_iit; }
|
||||
|
||||
private:
|
||||
IIterator m_iit;
|
||||
};
|
||||
|
||||
} //namespace container_detail {
|
||||
|
||||
using ::boost::intrusive::reverse_iterator;
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
#ifndef BOOST_MPL_VECTOR_VECTOR50_C_HPP_INCLUDED
|
||||
#define BOOST_MPL_VECTOR_VECTOR50_C_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_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/vector/vector40_c.hpp>
|
||||
# include <boost/mpl/vector/vector50.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER vector50_c.hpp
|
||||
# include <boost/mpl/vector/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# include <boost/mpl/aux_/config/typeof.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(41, 50, <boost/mpl/vector/aux_/numbered_c.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
|
||||
#endif // BOOST_MPL_VECTOR_VECTOR50_C_HPP_INCLUDED
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "LettersSpinBox.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include "moc_LettersSpinBox.cpp"
|
||||
|
||||
QString LettersSpinBox::textFromValue (int value) const
|
||||
{
|
||||
QString text;
|
||||
do {
|
||||
auto digit = value % 26;
|
||||
value /= 26;
|
||||
text = QChar {lowercase_ ? 'a' + digit : 'A' + digit} + text;
|
||||
} while (value);
|
||||
return text;
|
||||
}
|
||||
|
||||
int LettersSpinBox::valueFromText (QString const& text) const
|
||||
{
|
||||
int value {0};
|
||||
for (int index = text.size (); index > 0; --index)
|
||||
{
|
||||
value = value * 26 + text[index - 1].toLatin1 () - (lowercase_ ? 'a' : 'A');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// 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 DEPENDENT_DWA200286_HPP
|
||||
# define DEPENDENT_DWA200286_HPP
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
// A way to turn a concrete type T into a type dependent on U. This
|
||||
// keeps conforming compilers (those implementing proper 2-phase
|
||||
// name lookup for templates) from complaining about incomplete
|
||||
// types in situations where it would otherwise be inconvenient or
|
||||
// impossible to re-order code so that all types are defined in time.
|
||||
|
||||
// One such use is when we must return an incomplete T from a member
|
||||
// function template (which must be defined in the class body to
|
||||
// keep MSVC happy).
|
||||
template <class T, class U>
|
||||
struct dependent
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // DEPENDENT_DWA200286_HPP
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#ifndef BOOST_PHOENIX_CORE_EXPRESSION_HPP
|
||||
#define BOOST_PHOENIX_CORE_EXPRESSION_HPP
|
||||
|
||||
#include <boost/phoenix/core/limits.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/phoenix/core/as_actor.hpp>
|
||||
#include <boost/phoenix/core/detail/expression.hpp>
|
||||
#include <boost/phoenix/core/domain.hpp>
|
||||
#include <boost/proto/domain.hpp>
|
||||
#include <boost/proto/make_expr.hpp>
|
||||
#include <boost/proto/transform/pass_through.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
template <typename Expr> struct actor;
|
||||
|
||||
#ifdef BOOST_PHOENIX_NO_VARIADIC_EXPRESSION
|
||||
#include <boost/phoenix/core/detail/cpp03/expression.hpp>
|
||||
#else
|
||||
template <template <typename> class Actor, typename Tag, typename... A>
|
||||
struct expr_ext;
|
||||
|
||||
// This void filter is necessary to avoid forming reference to void
|
||||
// because most of other expressions are not based on variadics.
|
||||
template <typename Tag, typename F, typename... T>
|
||||
struct expr_impl;
|
||||
|
||||
template <typename Tag, typename... A>
|
||||
struct expr_impl<Tag, void(A...)> : expr_ext<actor, Tag, A...> {};
|
||||
|
||||
template <typename Tag, typename... A, typename... T>
|
||||
struct expr_impl<Tag, void(A...), void, T...> : expr_impl<Tag, void(A...)> {};
|
||||
|
||||
template <typename Tag, typename... A, typename H, typename... T>
|
||||
struct expr_impl<Tag, void(A...), H, T...> : expr_impl<Tag, void(A..., H), T...> {};
|
||||
|
||||
template <typename Tag, typename... A>
|
||||
struct expr : expr_impl<Tag, void(), A...> {};
|
||||
|
||||
template <template <typename> class Actor, typename Tag, typename... A>
|
||||
struct expr_ext
|
||||
: proto::transform<expr_ext<Actor, Tag, A...>, int>
|
||||
{
|
||||
typedef
|
||||
typename proto::result_of::make_expr<
|
||||
Tag
|
||||
, phoenix_default_domain //proto::basic_default_domain
|
||||
, typename proto::detail::uncvref<typename call_traits<A>::value_type>::type...
|
||||
>::type
|
||||
base_type;
|
||||
|
||||
typedef Actor<base_type> type;
|
||||
|
||||
typedef typename proto::nary_expr<Tag, A...>::proto_grammar proto_grammar;
|
||||
|
||||
static type make(typename call_traits<A>::param_type... a)
|
||||
{ //?? actor or Actor??
|
||||
//Actor<base_type> const e =
|
||||
actor<base_type> const e =
|
||||
{
|
||||
proto::make_expr<Tag, phoenix_default_domain>(a...)
|
||||
};
|
||||
return e;
|
||||
}
|
||||
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl
|
||||
: proto::pass_through<expr_ext>::template impl<Expr, State, Data>
|
||||
{};
|
||||
|
||||
typedef Tag proto_tag;
|
||||
};
|
||||
#endif
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
// Copyright David Abrahams 2003.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef DEF_VISITOR_DWA2003810_HPP
|
||||
# define DEF_VISITOR_DWA2003810_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <class DerivedVisitor> class def_visitor;
|
||||
template <class T, class X1, class X2, class X3> class class_;
|
||||
|
||||
class def_visitor_access
|
||||
{
|
||||
# if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
// Tasteless as this may seem, making all members public allows member templates
|
||||
// to work in the absence of member template friends.
|
||||
public:
|
||||
# else
|
||||
template <class Derived> friend class def_visitor;
|
||||
# endif
|
||||
|
||||
// unnamed visit, c.f. init<...>, container suites
|
||||
template <class V, class classT>
|
||||
static void visit(V const& v, classT& c)
|
||||
{
|
||||
v.derived_visitor().visit(c);
|
||||
}
|
||||
|
||||
// named visit, c.f. object, pure_virtual
|
||||
template <class V, class classT, class OptionalArgs>
|
||||
static void visit(
|
||||
V const& v
|
||||
, classT& c
|
||||
, char const* name
|
||||
, OptionalArgs const& options
|
||||
)
|
||||
{
|
||||
v.derived_visitor().visit(c, name, options);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class DerivedVisitor>
|
||||
class def_visitor
|
||||
{
|
||||
friend class def_visitor_access;
|
||||
|
||||
# if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
// Tasteless as this may seem, making all members public allows member templates
|
||||
// to work in the absence of member template friends.
|
||||
public:
|
||||
# else
|
||||
template <class T, class X1, class X2, class X3> friend class class_;
|
||||
# endif
|
||||
|
||||
// unnamed visit, c.f. init<...>, container suites
|
||||
template <class classT>
|
||||
void visit(classT& c) const
|
||||
{
|
||||
def_visitor_access::visit(*this, c);
|
||||
}
|
||||
|
||||
// named visit, c.f. object, pure_virtual
|
||||
template <class classT, class OptionalArgs>
|
||||
void visit(classT& c, char const* name, OptionalArgs const& options) const
|
||||
{
|
||||
def_visitor_access::visit(*this, c, name, options);
|
||||
}
|
||||
|
||||
protected:
|
||||
DerivedVisitor const& derived_visitor() const
|
||||
{
|
||||
return static_cast<DerivedVisitor const&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // DEF_VISITOR_DWA2003810_HPP
|
||||
@@ -0,0 +1,52 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file local.hpp
|
||||
/// Contains macros to ease the generation of repetitious code constructs
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_MACRO
|
||||
# error "local iteration target macro is not defined"
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_LIMITS
|
||||
# define BOOST_PROTO_LOCAL_LIMITS (1, BOOST_PROTO_MAX_ARITY)
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_typename_A
|
||||
# define BOOST_PROTO_LOCAL_typename_A BOOST_PROTO_typename_A
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_A
|
||||
# define BOOST_PROTO_LOCAL_A BOOST_PROTO_A_const_ref
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_A_a
|
||||
# define BOOST_PROTO_LOCAL_A_a BOOST_PROTO_A_const_ref_a
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_PROTO_LOCAL_a
|
||||
# define BOOST_PROTO_LOCAL_a BOOST_PROTO_ref_a
|
||||
#endif
|
||||
|
||||
#define BOOST_PP_LOCAL_LIMITS BOOST_PROTO_LOCAL_LIMITS
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(N) \
|
||||
BOOST_PROTO_LOCAL_MACRO( \
|
||||
N \
|
||||
, BOOST_PROTO_LOCAL_typename_A \
|
||||
, BOOST_PROTO_LOCAL_A \
|
||||
, BOOST_PROTO_LOCAL_A_a \
|
||||
, BOOST_PROTO_LOCAL_a \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
#undef BOOST_PROTO_LOCAL_MACRO
|
||||
#undef BOOST_PROTO_LOCAL_LIMITS
|
||||
#undef BOOST_PROTO_LOCAL_typename_A
|
||||
#undef BOOST_PROTO_LOCAL_A
|
||||
#undef BOOST_PROTO_LOCAL_A_a
|
||||
#undef BOOST_PROTO_LOCAL_a
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range
|
||||
{
|
||||
|
||||
/// \brief template function remove_copy
|
||||
///
|
||||
/// range-based version of the remove_copy std algorithm
|
||||
///
|
||||
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
|
||||
/// \pre OutputIterator is a model of the OutputIteratorConcept
|
||||
/// \pre Value is a model of the EqualityComparableConcept
|
||||
/// \pre Objects of type Value can be compared for equality with objects of
|
||||
/// InputIterator's value type.
|
||||
template< class SinglePassRange, class OutputIterator, class Value >
|
||||
inline OutputIterator
|
||||
remove_copy(const SinglePassRange& rng, OutputIterator out_it, const Value& val)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val);
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
using range::remove_copy;
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,45 @@
|
||||
// (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 : runtime parameters forward declaration
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_UTILS_RUNTIME_FWD_HPP
|
||||
#define BOOST_TEST_UTILS_RUNTIME_FWD_HPP
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
#include <boost/test/utils/basic_cstring/io.hpp> // operator<<(boost::runtime::cstring)
|
||||
|
||||
// Boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
// STL
|
||||
#include <map>
|
||||
|
||||
namespace boost {
|
||||
namespace runtime {
|
||||
|
||||
typedef unit_test::const_string cstring;
|
||||
|
||||
class argument;
|
||||
typedef shared_ptr<argument> argument_ptr;
|
||||
|
||||
template<typename T> class typed_argument;
|
||||
|
||||
class basic_param;
|
||||
typedef shared_ptr<basic_param> basic_param_ptr;
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TEST_UTILS_RUNTIME_FWD_HPP
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright Vladimir Prus 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 BOOST_OPTION_HPP_VP_2004_02_25
|
||||
#define BOOST_OPTION_HPP_VP_2004_02_25
|
||||
|
||||
#include <boost/program_options/config.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace boost { namespace program_options {
|
||||
|
||||
/** Option found in input source.
|
||||
Contains a key and a value. The key, in turn, can be a string (name of
|
||||
an option), or an integer (position in input source) \-- in case no name
|
||||
is specified. The latter is only possible for command line.
|
||||
The template parameter specifies the type of char used for storing the
|
||||
option's value.
|
||||
*/
|
||||
template<class charT>
|
||||
class basic_option {
|
||||
public:
|
||||
basic_option()
|
||||
: position_key(-1)
|
||||
, unregistered(false)
|
||||
, case_insensitive(false)
|
||||
{}
|
||||
basic_option(const std::string& xstring_key,
|
||||
const std::vector< std::string> &xvalue)
|
||||
: string_key(xstring_key)
|
||||
, value(xvalue)
|
||||
, unregistered(false)
|
||||
, case_insensitive(false)
|
||||
{}
|
||||
|
||||
/** String key of this option. Intentionally independent of the template
|
||||
parameter. */
|
||||
std::string string_key;
|
||||
/** Position key of this option. All options without an explicit name are
|
||||
sequentially numbered starting from 0. If an option has explicit name,
|
||||
'position_key' is equal to -1. It is possible that both
|
||||
position_key and string_key is specified, in case name is implicitly
|
||||
added.
|
||||
*/
|
||||
int position_key;
|
||||
/** Option's value */
|
||||
std::vector< std::basic_string<charT> > value;
|
||||
/** The original unchanged tokens this option was
|
||||
created from. */
|
||||
std::vector< std::basic_string<charT> > original_tokens;
|
||||
/** True if option was not recognized. In that case,
|
||||
'string_key' and 'value' are results of purely
|
||||
syntactic parsing of source. The original tokens can be
|
||||
recovered from the "original_tokens" member.
|
||||
*/
|
||||
bool unregistered;
|
||||
/** True if string_key has to be handled
|
||||
case insensitive.
|
||||
*/
|
||||
bool case_insensitive;
|
||||
};
|
||||
typedef basic_option<char> option;
|
||||
typedef basic_option<wchar_t> woption;
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2012 Hartmut Kaiser
|
||||
* Copyright (c) 2014 Andrey Semashev
|
||||
*/
|
||||
/*!
|
||||
* \file atomic/detail/config.hpp
|
||||
*
|
||||
* This header defines configuraion macros for Boost.Atomic
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_
|
||||
#define BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__has_builtin)
|
||||
#if __has_builtin(__builtin_memcpy)
|
||||
#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY
|
||||
#endif
|
||||
#if __has_builtin(__builtin_memcmp)
|
||||
#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP
|
||||
#endif
|
||||
#elif defined(BOOST_GCC)
|
||||
#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY
|
||||
#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY)
|
||||
#define BOOST_ATOMIC_DETAIL_MEMCPY __builtin_memcpy
|
||||
#else
|
||||
#define BOOST_ATOMIC_DETAIL_MEMCPY std::memcpy
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP)
|
||||
#define BOOST_ATOMIC_DETAIL_MEMCMP __builtin_memcmp
|
||||
#else
|
||||
#define BOOST_ATOMIC_DETAIL_MEMCMP std::memcmp
|
||||
#endif
|
||||
|
||||
#if defined(__CUDACC__)
|
||||
// nvcc does not support alternatives in asm statement constraints
|
||||
#define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES
|
||||
// nvcc does not support condition code register ("cc") clobber in asm statements
|
||||
#define BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC)
|
||||
#define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC "cc"
|
||||
#define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "cc",
|
||||
#else
|
||||
#define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
|
||||
#define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA
|
||||
#endif
|
||||
|
||||
#if ((defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 403)) ||\
|
||||
defined(__SUNPRO_CC)
|
||||
// This macro indicates we're using older binutils that don't support implied zero displacements for memory opereands,
|
||||
// making code like this invalid:
|
||||
// movl 4+(%%edx), %%eax
|
||||
#define BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40500) || defined(__SUNPRO_CC)
|
||||
// This macro indicates that the compiler does not support allocating rax:rdx register pairs ("A") in asm blocks
|
||||
#define BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_
|
||||
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
Functions used by wsprsim
|
||||
*/
|
||||
#include "wsprsim_utils.h"
|
||||
#include "wsprd_utils.h"
|
||||
#include "nhash.h"
|
||||
#include "fano.h"
|
||||
|
||||
char get_locator_character_code(char ch) {
|
||||
if( ch >=48 && ch <=57 ) { //0-9
|
||||
return ch-48;
|
||||
}
|
||||
if( ch == 32 ) { //space
|
||||
return 36;
|
||||
}
|
||||
if( ch >= 65 && ch <= 82 ) { //A-Z
|
||||
return ch-65;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char get_callsign_character_code(char ch) {
|
||||
if( ch >=48 && ch <=57 ) { //0-9
|
||||
return ch-48;
|
||||
}
|
||||
if( ch == 32 ) { //space
|
||||
return 36;
|
||||
}
|
||||
if( ch >= 65 && ch <= 90 ) { //A-Z
|
||||
return ch-55;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
long unsigned int pack_grid4_power(char *grid4, int power) {
|
||||
long unsigned int m;
|
||||
|
||||
m=(179-10*grid4[0]-grid4[2])*180+10*grid4[1]+grid4[3];
|
||||
m=m*128+power+64;
|
||||
return m;
|
||||
}
|
||||
|
||||
long unsigned int pack_call(char *callsign) {
|
||||
unsigned int i;
|
||||
long unsigned int n;
|
||||
char call6[6];
|
||||
memset(call6,32,sizeof(char)*6);
|
||||
// callsign is 6 characters in length. Exactly.
|
||||
size_t call_len = strlen(callsign);
|
||||
if( call_len > 6 ) {
|
||||
return 0;
|
||||
}
|
||||
if( isdigit(*(callsign+2)) ) {
|
||||
for (i=0; i<call_len; i++) {
|
||||
if( callsign[i] == 0 ) {
|
||||
call6[i]=32;
|
||||
} else {
|
||||
call6[i]=*(callsign+i);
|
||||
}
|
||||
}
|
||||
} else if( isdigit(*(callsign+1)) ) {
|
||||
call6[0]=32;
|
||||
for (i=1; i<call_len+1; i++) {
|
||||
if( callsign[i-1]==0 ) {
|
||||
call6[i]=32;
|
||||
} else {
|
||||
call6[i]=*(callsign+i-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0; i<6; i++) {
|
||||
call6[i]=get_callsign_character_code(call6[i]);
|
||||
}
|
||||
n = call6[0];
|
||||
n = n*36+call6[1];
|
||||
n = n*10+call6[2];
|
||||
n = n*27+call6[3]-10;
|
||||
n = n*27+call6[4]-10;
|
||||
n = n*27+call6[5]-10;
|
||||
return n;
|
||||
}
|
||||
|
||||
void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ) {
|
||||
size_t i;
|
||||
char *call6;
|
||||
call6=malloc(sizeof(char)*6);
|
||||
memset(call6,32,sizeof(char)*6);
|
||||
size_t i1=strcspn(callsign,"/");
|
||||
|
||||
if( callsign[i1+2] == 0 ) {
|
||||
//single char suffix
|
||||
for (i=0; i<i1; i++) {
|
||||
call6[i]=callsign[i];
|
||||
}
|
||||
*n=pack_call(call6);
|
||||
*nadd=1;
|
||||
int nc = callsign[i1+1];
|
||||
if( nc >= 48 && nc <= 57 ) {
|
||||
*m=nc-48;
|
||||
} else if ( nc >= 65 && nc <= 90 ) {
|
||||
*m=nc-65+10;
|
||||
} else {
|
||||
*m=38;
|
||||
}
|
||||
*m=60000-32768+*m;
|
||||
} else if( callsign[i1+3]==0 ) {
|
||||
//two char suffix
|
||||
for (i=0; i<i1; i++) {
|
||||
call6[i]=callsign[i];
|
||||
}
|
||||
*n=pack_call(call6);
|
||||
*nadd=1;
|
||||
*m=10*(callsign[i1+1]-48)+(callsign[i1+2]-48);
|
||||
*m=60000 + 26 + *m;
|
||||
} else {
|
||||
char* pfx=strtok(callsign,"/");
|
||||
call6=strtok(NULL," ");
|
||||
*n=pack_call(call6);
|
||||
size_t plen=strlen(pfx);
|
||||
if( plen ==1 ) {
|
||||
*m=36;
|
||||
*m=37*(*m)+36;
|
||||
} else if( plen == 2 ) {
|
||||
*m=36;
|
||||
} else {
|
||||
*m=0;
|
||||
}
|
||||
for (i=0; i<plen; i++) {
|
||||
int nc = callsign[i];
|
||||
if( nc >= 48 && nc <= 57 ) {
|
||||
nc=nc-48;
|
||||
} else if ( nc >= 65 && nc <= 90 ) {
|
||||
nc=nc-65+10;
|
||||
} else {
|
||||
nc=36;
|
||||
}
|
||||
*m=37*(*m)+nc;
|
||||
}
|
||||
*nadd=0;
|
||||
if( *m > 32768 ) {
|
||||
*m=*m-32768;
|
||||
*nadd=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void interleave(unsigned char *sym)
|
||||
{
|
||||
unsigned char tmp[162];
|
||||
unsigned char p, i, j;
|
||||
|
||||
p=0;
|
||||
i=0;
|
||||
while (p<162) {
|
||||
j=((i * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
|
||||
if (j < 162 ) {
|
||||
tmp[j]=sym[p];
|
||||
p=p+1;
|
||||
}
|
||||
i=i+1;
|
||||
}
|
||||
for (i=0; i<162; i++) {
|
||||
sym[i]=tmp[i];
|
||||
}
|
||||
}
|
||||
|
||||
int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* symbols) {
|
||||
int m=0, n=0, ntype=0;
|
||||
int i, j, ihash;
|
||||
unsigned char pr3[162]=
|
||||
{1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,
|
||||
0,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1,
|
||||
0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1,
|
||||
1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1,
|
||||
0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,0,0,0,1,0,
|
||||
0,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,1,1,
|
||||
0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,1,1,
|
||||
0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0,
|
||||
0,0};
|
||||
int nu[10]={0,-1,1,0,-1,2,1,0,-1,1};
|
||||
char *callsign, *grid, *powstr;
|
||||
char grid4[5], message[23];
|
||||
|
||||
memset(message,0,sizeof(char)*23);
|
||||
i=0;
|
||||
while ( rawmessage[i] != 0 && i<23 ) {
|
||||
message[i]=rawmessage[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
size_t i1=strcspn(message," ");
|
||||
size_t i2=strcspn(message,"/");
|
||||
size_t i3=strcspn(message,"<");
|
||||
size_t i4=strcspn(message,">");
|
||||
size_t mlen=strlen(message);
|
||||
|
||||
// Use the presence and/or absence of "<" and "/" to decide what
|
||||
// type of message. No sanity checks! Beware!
|
||||
|
||||
if( (i1>3) & (i1<7) & (i2==mlen) & (i3==mlen) ) {
|
||||
// Type 1 message: K9AN EN50 33
|
||||
// xxnxxxx xxnn nn
|
||||
callsign = strtok(message," ");
|
||||
grid = strtok(NULL," ");
|
||||
powstr = strtok(NULL," ");
|
||||
int power = atoi(powstr);
|
||||
n = pack_call(callsign);
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
grid4[i]=get_locator_character_code(*(grid+i));
|
||||
}
|
||||
m = pack_grid4_power(grid4,power);
|
||||
|
||||
} else if ( i3 == 0 && i4 < mlen ) {
|
||||
// Type 3: <K1ABC> EN50WC 33
|
||||
// <PJ4/K1ABC> FK52UD 37
|
||||
// send hash instead of callsign to make room for 6 char grid.
|
||||
// if 4-digit locator is specified, 2 spaces are added to the end.
|
||||
callsign=strtok(message,"<> ");
|
||||
grid=strtok(NULL," ");
|
||||
powstr=strtok(NULL," ");
|
||||
int power = atoi(powstr);
|
||||
if( power < 0 ) power=0;
|
||||
if( power > 60 ) power=60;
|
||||
power=power+nu[power%10];
|
||||
ntype=-(power+1);
|
||||
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
|
||||
m=128*ihash + ntype + 64;
|
||||
|
||||
char grid6[6];
|
||||
memset(grid6,32,sizeof(char)*6);
|
||||
j=strlen(grid);
|
||||
for(i=0; i<j-1; i++) {
|
||||
grid6[i]=grid[i+1];
|
||||
}
|
||||
grid6[5]=grid[0];
|
||||
n=pack_call(grid6);
|
||||
} else if ( i2 < mlen ) { // just looks for a right slash
|
||||
// Type 2: PJ4/K1ABC 37
|
||||
callsign=strtok(message," ");
|
||||
if( strlen(callsign) < i2 ) return 0; //guards against pathological case
|
||||
powstr=strtok(NULL," ");
|
||||
int power = atoi(powstr);
|
||||
if( power < 0 ) power=0;
|
||||
if( power > 60 ) power=60;
|
||||
power=power+nu[power%10];
|
||||
int n1, ng, nadd;
|
||||
pack_prefix(callsign, &n1, &ng, &nadd);
|
||||
ntype=power + 1 + nadd;
|
||||
m=128*ng+ntype+64;
|
||||
n=n1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// pack 50 bits + 31 (0) tail bits into 11 bytes
|
||||
unsigned char it, data[11];
|
||||
memset(data,0,sizeof(char)*11);
|
||||
it=0xFF & (n>>20);
|
||||
data[0]=it;
|
||||
it=0xFF & (n>>12);
|
||||
data[1]=it;
|
||||
it=0xFF & (n>>4);
|
||||
data[2]=it;
|
||||
it= ((n&(0x0F))<<4) + ((m>>18)&(0x0F));
|
||||
data[3]=it;
|
||||
it=0xFF & (m>>10);
|
||||
data[4]=it;
|
||||
it=0xFF & (m>>2);
|
||||
data[5]=it;
|
||||
it=(m & 0x03)<<6 ;
|
||||
data[6]=it;
|
||||
data[7]=0;
|
||||
data[8]=0;
|
||||
data[9]=0;
|
||||
data[10]=0;
|
||||
|
||||
if( printdata ) {
|
||||
printf("Data is :");
|
||||
for (i=0; i<11; i++) {
|
||||
printf("%02X ",data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// make sure that the 11-byte data vector is unpackable
|
||||
// unpack it with the routine that the decoder will use and display
|
||||
// the result. let the operator decide whether it worked.
|
||||
|
||||
char *check_call_loc_pow, *check_callsign;
|
||||
check_call_loc_pow=malloc(sizeof(char)*23);
|
||||
check_callsign=malloc(sizeof(char)*13);
|
||||
signed char check_data[11];
|
||||
memcpy(check_data,data,sizeof(char)*11);
|
||||
unpk_(check_data,hashtab,check_call_loc_pow,check_callsign);
|
||||
// printf("Will decode as: %s\n",check_call_loc_pow);
|
||||
|
||||
unsigned int nbytes=11; // The message with tail is packed into almost 11 bytes.
|
||||
unsigned char channelbits[nbytes*8*2]; /* 162 rounded up */
|
||||
memset(channelbits,0,sizeof channelbits);
|
||||
|
||||
encode(channelbits,data,nbytes);
|
||||
|
||||
interleave(channelbits);
|
||||
|
||||
for (i=0; i<162; i++) {
|
||||
symbols[i]=2*channelbits[i]+pr3[i];
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file any.hpp
|
||||
/// Contains definition the detail::any type
|
||||
//
|
||||
// Copyright 2012 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROTO_DETAIL_ANY_HPP_EAN_18_07_2012
|
||||
#define BOOST_PROTO_DETAIL_ANY_HPP_EAN_18_07_2012
|
||||
|
||||
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/proto/proto_fwd.hpp>
|
||||
|
||||
namespace boost { namespace proto
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace anyns
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
struct any
|
||||
{
|
||||
template<typename T> any(T const &) {}
|
||||
any operator=(any);
|
||||
any operator[](any);
|
||||
#define M0(Z, N, DATA) any operator()(BOOST_PP_ENUM_PARAMS_Z(Z, N, any BOOST_PP_INTERCEPT));
|
||||
BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, ~)
|
||||
#undef M0
|
||||
|
||||
template<typename T>
|
||||
operator T &() const volatile;
|
||||
|
||||
any operator+();
|
||||
any operator-();
|
||||
any operator*();
|
||||
any operator&();
|
||||
any operator~();
|
||||
any operator!();
|
||||
any operator++();
|
||||
any operator--();
|
||||
any operator++(int);
|
||||
any operator--(int);
|
||||
|
||||
friend any operator<<(any, any);
|
||||
friend any operator>>(any, any);
|
||||
friend any operator*(any, any);
|
||||
friend any operator/(any, any);
|
||||
friend any operator%(any, any);
|
||||
friend any operator+(any, any);
|
||||
friend any operator-(any, any);
|
||||
friend any operator<(any, any);
|
||||
friend any operator>(any, any);
|
||||
friend any operator<=(any, any);
|
||||
friend any operator>=(any, any);
|
||||
friend any operator==(any, any);
|
||||
friend any operator!=(any, any);
|
||||
friend any operator||(any, any);
|
||||
friend any operator&&(any, any);
|
||||
friend any operator&(any, any);
|
||||
friend any operator|(any, any);
|
||||
friend any operator^(any, any);
|
||||
friend any operator,(any, any);
|
||||
friend any operator->*(any, any);
|
||||
|
||||
friend any operator<<=(any, any);
|
||||
friend any operator>>=(any, any);
|
||||
friend any operator*=(any, any);
|
||||
friend any operator/=(any, any);
|
||||
friend any operator%=(any, any);
|
||||
friend any operator+=(any, any);
|
||||
friend any operator-=(any, any);
|
||||
friend any operator&=(any, any);
|
||||
friend any operator|=(any, any);
|
||||
friend any operator^=(any, any);
|
||||
};
|
||||
}
|
||||
|
||||
using anyns::any;
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
// 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_SERIAL_ACCUMULATE_HPP
|
||||
#define BOOST_COMPUTE_ALGORITHM_DETAIL_SERIAL_ACCUMULATE_HPP
|
||||
|
||||
#include <boost/compute/command_queue.hpp>
|
||||
#include <boost/compute/detail/meta_kernel.hpp>
|
||||
#include <boost/compute/detail/iterator_range_size.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace compute {
|
||||
namespace detail {
|
||||
|
||||
template<class InputIterator, class OutputIterator, class T, class BinaryFunction>
|
||||
inline void serial_accumulate(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
T init,
|
||||
BinaryFunction function,
|
||||
command_queue &queue)
|
||||
{
|
||||
const context &context = queue.get_context();
|
||||
size_t count = detail::iterator_range_size(first, last);
|
||||
|
||||
meta_kernel k("serial_accumulate");
|
||||
size_t init_arg = k.add_arg<T>("init");
|
||||
size_t count_arg = k.add_arg<cl_uint>("count");
|
||||
|
||||
k <<
|
||||
k.decl<T>("result") << " = init;\n" <<
|
||||
"for(uint i = 0; i < count; i++)\n" <<
|
||||
" result = " << function(k.var<T>("result"),
|
||||
first[k.var<cl_uint>("i")]) << ";\n" <<
|
||||
result[0] << " = result;\n";
|
||||
|
||||
kernel kernel = k.compile(context);
|
||||
|
||||
kernel.set_arg(init_arg, init);
|
||||
kernel.set_arg(count_arg, static_cast<cl_uint>(count));
|
||||
|
||||
queue.enqueue_task(kernel);
|
||||
}
|
||||
|
||||
} // end detail namespace
|
||||
} // end compute namespace
|
||||
} // end boost namespace
|
||||
|
||||
#endif // BOOST_COMPUTE_ALGORITHM_DETAIL_SERIAL_ACCUMULATE_HPP
|
||||
@@ -0,0 +1,139 @@
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// This file is machine generated, do not edit by hand
|
||||
|
||||
// Polynomial evaluation using second order Horners rule
|
||||
#ifndef BOOST_MATH_TOOLS_POLY_EVAL_17_HPP
|
||||
#define BOOST_MATH_TOOLS_POLY_EVAL_17_HPP
|
||||
|
||||
namespace boost{ namespace math{ namespace tools{ namespace detail{
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(0);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(a[1] * x + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>((a[2] * x + a[1]) * x + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
return static_cast<V>(((a[3] * x + a[2]) * x + a[1]) * x + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V)
|
||||
{
|
||||
V x2 = x * x;
|
||||
return static_cast<V>((((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x);
|
||||
}
|
||||
|
||||
|
||||
}}}} // namespaces
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* From an ADIF file and cty.dat, get a call's DXCC entity and its worked before status
|
||||
* VK3ACF July 2013
|
||||
*/
|
||||
|
||||
#ifndef LOGBOOK_H
|
||||
#define LOGBOOK_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QFont>
|
||||
|
||||
#include "countrydat.h"
|
||||
#include "countriesworked.h"
|
||||
#include "adif.h"
|
||||
|
||||
class QDir;
|
||||
|
||||
class LogBook
|
||||
{
|
||||
public:
|
||||
void init();
|
||||
void match(/*in*/ const QString call,
|
||||
/*out*/ QString &countryName,
|
||||
bool &callWorkedBefore,
|
||||
bool &countryWorkedBefore) const;
|
||||
void addAsWorked(const QString call, const QString band, const QString mode, const QString date);
|
||||
|
||||
private:
|
||||
CountryDat _countries;
|
||||
CountriesWorked _worked;
|
||||
ADIF _log;
|
||||
|
||||
void _setAlreadyWorkedFromLog();
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGBOOK_H
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
// 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 ITERATOR_DWA2002512_HPP
|
||||
# define ITERATOR_DWA2002512_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/detail/target.hpp>
|
||||
# include <boost/python/object/iterator.hpp>
|
||||
# include <boost/python/object_core.hpp>
|
||||
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
|
||||
# if defined(BOOST_MSVC) && (BOOST_MSVC == 1400) /*
|
||||
> warning C4180: qualifier applied to function type has no meaning; ignored
|
||||
Peter Dimov wrote:
|
||||
This warning is caused by an overload resolution bug in VC8 that cannot be
|
||||
worked around and will probably not be fixed by MS in the VC8 line. The
|
||||
problematic overload is only instantiated and never called, and the code
|
||||
works correctly. */
|
||||
# pragma warning(disable: 4180)
|
||||
# endif
|
||||
|
||||
# include <boost/bind.hpp>
|
||||
# include <boost/bind/protect.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Adds an additional layer of binding to
|
||||
// objects::make_iterator(...), which allows us to pass member
|
||||
// function and member data pointers.
|
||||
template <class Target, class Accessor1, class Accessor2, class NextPolicies>
|
||||
inline object make_iterator(
|
||||
Accessor1 get_start
|
||||
, Accessor2 get_finish
|
||||
, NextPolicies next_policies
|
||||
, Target&(*)()
|
||||
)
|
||||
{
|
||||
return objects::make_iterator_function<Target>(
|
||||
boost::protect(boost::bind(get_start, _1))
|
||||
, boost::protect(boost::bind(get_finish, _1))
|
||||
, next_policies
|
||||
);
|
||||
}
|
||||
|
||||
// Guts of template class iterators<>, below.
|
||||
template <bool const_ = false>
|
||||
struct iterators_impl
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::iterator iterator;
|
||||
static iterator begin(T& x) { return x.begin(); }
|
||||
static iterator end(T& x) { return x.end(); }
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct iterators_impl<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::const_iterator iterator;
|
||||
static iterator begin(T& x) { return x.begin(); }
|
||||
static iterator end(T& x) { return x.end(); }
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// An "ordinary function generator" which contains static begin(x) and
|
||||
// end(x) functions that invoke T::begin() and T::end(), respectively.
|
||||
template <class T>
|
||||
struct iterators
|
||||
: detail::iterators_impl<
|
||||
boost::is_const<T>::value
|
||||
>::template apply<T>
|
||||
{
|
||||
};
|
||||
|
||||
// Create an iterator-building function which uses the given
|
||||
// accessors. Deduce the Target type from the accessors. The iterator
|
||||
// returns copies of the inderlying elements.
|
||||
template <class Accessor1, class Accessor2>
|
||||
object range(Accessor1 start, Accessor2 finish)
|
||||
{
|
||||
return detail::make_iterator(
|
||||
start, finish
|
||||
, objects::default_iterator_call_policies()
|
||||
, detail::target(start)
|
||||
);
|
||||
}
|
||||
|
||||
// Create an iterator-building function which uses the given accessors
|
||||
// and next() policies. Deduce the Target type.
|
||||
template <class NextPolicies, class Accessor1, class Accessor2>
|
||||
object range(Accessor1 start, Accessor2 finish, NextPolicies* = 0)
|
||||
{
|
||||
return detail::make_iterator(start, finish, NextPolicies(), detail::target(start));
|
||||
}
|
||||
|
||||
// Create an iterator-building function which uses the given accessors
|
||||
// and next() policies, operating on the given Target type
|
||||
template <class NextPolicies, class Target, class Accessor1, class Accessor2>
|
||||
object range(Accessor1 start, Accessor2 finish, NextPolicies* = 0, boost::type<Target>* = 0)
|
||||
{
|
||||
// typedef typename add_reference<Target>::type target;
|
||||
return detail::make_iterator(start, finish, NextPolicies(), (Target&(*)())0);
|
||||
}
|
||||
|
||||
// A Python callable object which produces an iterator traversing
|
||||
// [x.begin(), x.end()), where x is an instance of the Container
|
||||
// type. NextPolicies are used as the CallPolicies for the iterator's
|
||||
// next() function.
|
||||
template <class Container
|
||||
, class NextPolicies = objects::default_iterator_call_policies>
|
||||
struct iterator : object
|
||||
{
|
||||
iterator()
|
||||
: object(
|
||||
python::range<NextPolicies>(
|
||||
&iterators<Container>::begin, &iterators<Container>::end
|
||||
))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // ITERATOR_DWA2002512_HPP
|
||||
@@ -0,0 +1,84 @@
|
||||
// (C) Copyright John Maddock 2006.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_POWM1
|
||||
#define BOOST_MATH_POWM1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4702) // Unreachable code (release mode only warning)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/math_fwd.hpp>
|
||||
#include <boost/math/special_functions/log1p.hpp>
|
||||
#include <boost/math/special_functions/expm1.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost{ namespace math{ namespace detail{
|
||||
|
||||
template <class T, class Policy>
|
||||
inline T powm1_imp(const T x, const T y, const Policy& pol)
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
static const char* function = "boost::math::powm1<%1%>(%1%, %1%)";
|
||||
|
||||
if (x > 0)
|
||||
{
|
||||
if ((fabs(y * (x - 1)) < 0.5) || (fabs(y) < 0.2))
|
||||
{
|
||||
// We don't have any good/quick approximation for log(x) * y
|
||||
// so just try it and see:
|
||||
T l = y * log(x);
|
||||
if (l < 0.5)
|
||||
return boost::math::expm1(l);
|
||||
if (l > boost::math::tools::log_max_value<T>())
|
||||
return boost::math::policies::raise_overflow_error<T>(function, 0, pol);
|
||||
// fall through....
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// y had better be an integer:
|
||||
if (boost::math::trunc(y) != y)
|
||||
return boost::math::policies::raise_domain_error<T>(function, "For non-integral exponent, expected base > 0 but got %1%", x, pol);
|
||||
if (boost::math::trunc(y / 2) == y / 2)
|
||||
return powm1_imp(T(-x), y, pol);
|
||||
}
|
||||
return pow(x, y) - 1;
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
||||
template <class T1, class T2>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
powm1(const T1 a, const T2 z)
|
||||
{
|
||||
typedef typename tools::promote_args<T1, T2>::type result_type;
|
||||
return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), policies::policy<>());
|
||||
}
|
||||
|
||||
template <class T1, class T2, class Policy>
|
||||
inline typename tools::promote_args<T1, T2>::type
|
||||
powm1(const T1 a, const T2 z, const Policy& pol)
|
||||
{
|
||||
typedef typename tools::promote_args<T1, T2>::type result_type;
|
||||
return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), pol);
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MATH_POWM1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
// (C) Copyright Tobias Schwinger
|
||||
//
|
||||
// Use modification and distribution are subject to the boost Software License,
|
||||
// Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// no include guards, this file is intended for multiple inclusions
|
||||
|
||||
#define callable_builtin BOOST_FT_callable_builtin
|
||||
#define member BOOST_FT_member_pointer
|
||||
#define non_member BOOST_FT_non_member
|
||||
#define variadic BOOST_FT_variadic
|
||||
#define non_variadic BOOST_FT_non_variadic
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2009 Helge Bahmann
|
||||
* Copyright (c) 2012 Tim Blechmann
|
||||
* Copyright (c) 2014 Andrey Semashev
|
||||
*/
|
||||
/*!
|
||||
* \file atomic/detail/ops_msvc_common.hpp
|
||||
*
|
||||
* This header contains common tools for MSVC implementation of the \c operations template.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_
|
||||
#define BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_
|
||||
|
||||
#include <boost/atomic/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Define compiler barriers
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() __memory_barrier()
|
||||
#elif defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
extern "C" void _ReadWriteBarrier(void);
|
||||
#pragma intrinsic(_ReadWriteBarrier)
|
||||
#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() _ReadWriteBarrier()
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_ATOMIC_DETAIL_COMPILER_BARRIER
|
||||
#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER()
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Reference in New Issue
Block a user