diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e1c98107210fd3d3015221edc7c630cffd435459..3c895be65197d0a73d33068cc375a1e464e997af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,14 +10,23 @@ build: script: - chmod +x build_aubio.sh - ./build_aubio.sh + - cd src/lib + - ./build_libs.sh + - cd ../.. - mkdir -p build - cd build - /usr/src/mxe/usr/x86_64-w64-mingw32.shared.posix/qt5/bin/qmake ../src/Lichtsteuerung.pro - make -j$(nproc) - cd .. + cache: + key: build_boost + paths: + - src/lib/boost/ artifacts: paths: - build/release/Lichtsteuerung.exe + - src/lib/boost/lib/libboost_context-mt-x64.dll + - src/lib/boost/lib/libboost_coroutine-mt-x64.dll # we use this version file to check if a new version exists version: @@ -40,6 +49,8 @@ deploy: - windows-release script: - cp build/release/Lichtsteuerung.exe windows-release-5.13.0 + - cp src/lib/boost/lib/libboost_context-mt-x64.dll windows-release-5.13.0 + - cp src/lib/boost/lib/libboost_coroutine-mt-x64.dll windows-release-5.13.0 - mkdir -p windows-release-5.13.0/modulesHeader - cp -r src/modules windows-release-5.13.0/modulesHeader - echo "includePath=modulesHeader" >> windows-release-5.13.0/settings.ini diff --git a/README.md b/README.md index 792fdcc81072f4fcdd7f84f7add827a47d1ea658..4b9ad0ae4ddfead7e2dc3f204e6245f614d58a2e 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ Features: Siehe [hier](Docker.md). ## Abhängigkeiten -Die Lichtsteuerung hängt von ein paar anderen Projekten ab. +Die Lichtsteuerung hängt von ein paar anderen Projekten ab. +**Abhängigkeiten bauen:** im Ordner `src/lib` befindet sich die Datei `build_libs.sh`, dise muss vor dem ersten Bauen ausgeführt werden um alle Abhängigkeiten zu installieren. #### [Boost](https://www.boost.org/) -Boost wird benötigt, um bei Modules nicht lineare Codeausführung zu ermöglichen (Corotines). Boost läst sich unter Linux und Windows durch einen beliebigen Paketmanager installieren, für Windows ist die Anleitung [hier](boost.md) zu finden. -Hinweis für Windows: Im git liegen schon alle benötigten Header und libs, man muss boost nicht neu kompilieren. Man muss dies nur machen um boost zu updaten (dann bitte neue libs und header ins git pushen). +Boost wird benötigt, um bei Modules nicht lineare Codeausführung zu ermöglichen (Corotines) und wird genutzt, um Stacktraces auszugeben. #### [Capture_Windows_SoundOutput](https://git.rwth-aachen.de/leander.schulten/Capture_Windows_SoundOutput) Dieses Project ermöglicht das abfangen des Windows Audioausgangs. Für andere Plattformen ligen keine implementierungen vor, diese sind aber herzlich willkommen. Die kompilierte Version ist hier im git vorhanden. diff --git a/boost.md b/boost.md deleted file mode 100644 index e827abeef4267703f8b1255d335848c7d7b00e58..0000000000000000000000000000000000000000 --- a/boost.md +++ /dev/null @@ -1,9 +0,0 @@ -## build boost for Windows -1. Download boost from [here](https://www.boost.org/users/download/) -2. Unzip the file -3. open powershell and cd to the unziped folder -4. exec: `.\bootstrap.bat` -5. Set the PATH Variable to the compiler - - eg: `$env:path="C:\Qt\Tools\mingw730_64\bin";` for mingw-64 installed with QT - -6. Execute `.\b2.exe toolset=gcc --build-dir=build --libdir=lib --stagedir=dist link=shared` this will need some time(40 min) \ No newline at end of file diff --git a/boost/accumulators/accumulators.hpp b/boost/accumulators/accumulators.hpp deleted file mode 100644 index 55ee2f918405ca9a5363c28ccd375829e64cbec7..0000000000000000000000000000000000000000 --- a/boost/accumulators/accumulators.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file accumulators.hpp -/// Includes all of the Accumulators Framework -// -// Copyright 2005 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_ACCUMULATORS_ACCUMULATORS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_ACCUMULATORS_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/boost/accumulators/accumulators_fwd.hpp b/boost/accumulators/accumulators_fwd.hpp deleted file mode 100644 index 4c0370e21ecdccc8b06ecffcd1b98f7d0f879506..0000000000000000000000000000000000000000 --- a/boost/accumulators/accumulators_fwd.hpp +++ /dev/null @@ -1,230 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// accumulators_fwd.hpp -// -// Copyright 2005 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_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 - -#include -#include // for mpl::na -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef BOOST_ACCUMULATORS_MAX_FEATURES - /// The maximum number of accumulators that may be put in an accumulator_set. - /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20). -# define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE -#endif - -#if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE -# error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE -#endif - -#ifndef BOOST_ACCUMULATORS_MAX_ARGS - /// The maximum number of arguments that may be specified to an accumulator_set's - /// accumulation function. Defaults to 15. -# define BOOST_ACCUMULATORS_MAX_ARGS 15 -#endif - -#if BOOST_WORKAROUND(__GNUC__, == 3) \ - || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306)) -# define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS -#endif - -#ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS -# include -# include -# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\ - , typename boost::disable_if >::type * = 0 -#else -# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T) -#endif - -#define BOOST_ACCUMULATORS_GCC_VERSION \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// Named parameters tags -// -namespace tag -{ - struct sample; - struct weight; - struct accumulator; - struct weights; -} - -/////////////////////////////////////////////////////////////////////////////// -// User-level features -// -namespace tag -{ - template - struct value; - - template - struct value_tag; - - template - struct reference; - - template - struct reference_tag; - - template - struct external; - - template - struct droppable; -} - -template -struct droppable_accumulator_base; - -template -struct droppable_accumulator; - -template -struct with_cached_result; - -template -struct accumulator_set; - -template -struct extractor; - -template -struct feature_of; - -template -struct as_feature; - -template -struct as_weighted_feature; - -template -struct depends_on; - -template -struct features; - -template -typename mpl::apply::type const & -find_accumulator(AccumulatorSet const &acc); - -template -typename mpl::apply::type::result_type -extract_result(AccumulatorSet const &acc); - -template -typename mpl::apply::type::result_type -extract_result(AccumulatorSet const &acc, A1 const &a1); - -// ... other overloads generated by Boost.Preprocessor: - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \ - template< \ - typename Feature \ - , typename AccumulatorSet \ - BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ - > \ - typename mpl::apply::type::result_type \ - extract_result( \ - AccumulatorSet const &acc \ - BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ - ); - -/// INTERNAL ONLY -/// -BOOST_PP_REPEAT_FROM_TO( - 2 - , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) - , BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD - , _ -) - -#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED -template -typename mpl::apply::type::result_type -extract_result(AccumulatorSet const &acc, A1 const &a1, A2 const &a2 ...); -#endif - -namespace impl -{ - using namespace numeric::operators; - - template - struct external_impl; -} - -namespace detail -{ - template - struct feature_tag; - - template - struct to_accumulator; - - struct accumulator_set_base; - - template - struct is_accumulator_set; - - inline void ignore_variable(void const *) {} - -#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \ - namespace detail \ - { \ - struct BOOST_PP_CAT(ignore_, X) \ - { \ - void ignore() \ - { \ - boost::accumulators::detail::ignore_variable(&X); \ - } \ - }; \ - } \ - /**/ -} - -}} // namespace boost::accumulators - -// For defining boost::parameter keywords that can be inherited from to -// get a nested, class-scoped keyword with the requested alias -#define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \ - namespace tag_namespace \ - { \ - template \ - struct name ## _ \ - { \ - static char const* keyword_name() \ - { \ - return #name; \ - } \ - static ::boost::parameter::keyword > &alias; \ - }; \ - template \ - ::boost::parameter::keyword > &name ## _::alias = \ - ::boost::parameter::keyword >::get(); \ - typedef name ## _ <> name; \ - } \ - namespace \ - { \ - ::boost::parameter::keyword &name = \ - ::boost::parameter::keyword::get(); \ - } - -#endif diff --git a/boost/accumulators/framework/accumulator_base.hpp b/boost/accumulators/framework/accumulator_base.hpp deleted file mode 100644 index 52c520d10747ac2daf6c7072905369f97c6d0774..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulator_base.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// accumulator_base.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace detail -{ - typedef void void_; -} - -/////////////////////////////////////////////////////////////////////////////// -// dont_care -// -struct dont_care -{ - template - dont_care(Args const &) - { - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// accumulator_base -// -struct accumulator_base -{ - // hidden if defined in derived classes - detail::void_ operator ()(dont_care) - { - } - - typedef mpl::false_ is_droppable; - - detail::void_ add_ref(dont_care) - { - } - - detail::void_ drop(dont_care) - { - } - - detail::void_ on_drop(dont_care) - { - } -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulator_concept.hpp b/boost/accumulators/framework/accumulator_concept.hpp deleted file mode 100644 index 492357efbaa676aa19e6547436a208b53aaff838..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulator_concept.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// accumulator_concept.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 - -#include - -namespace boost { namespace accumulators -{ - -template -struct accumulator_concept -{ - void constraints() - { - // TODO: define the stat concept - } - - Stat stat; -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulator_set.hpp b/boost/accumulators/framework/accumulator_set.hpp deleted file mode 100644 index ed1ceb1afa407253251201defcc781f59c090aad..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulator_set.hpp +++ /dev/null @@ -1,401 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// accumulator_set.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace detail -{ - /////////////////////////////////////////////////////////////////////////////// - // accumulator_visitor - // wrap a boost::parameter argument pack in a Fusion extractor object - template - struct accumulator_visitor - { - explicit accumulator_visitor(Args const &a) - : args(a) - { - } - - template - void operator ()(Accumulator &accumulator) const - { - accumulator(this->args); - } - - private: - accumulator_visitor &operator =(accumulator_visitor const &); - Args const &args; - }; - - template - inline accumulator_visitor const make_accumulator_visitor(Args const &args) - { - return accumulator_visitor(args); - } - - typedef - parameter::parameters< - parameter::required - , parameter::optional - // ... and others which are not specified here... - > - accumulator_params; - - /////////////////////////////////////////////////////////////////////////////// - // accumulator_set_base - struct accumulator_set_base - { - }; - - /////////////////////////////////////////////////////////////////////////////// - // is_accumulator_set - template - struct is_accumulator_set - : is_base_and_derived - { - }; - -} // namespace detail - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list -#endif - -/////////////////////////////////////////////////////////////////////////////// -/// \brief A set of accumulators. -/// -/// accumulator_set resolves the dependencies between features and ensures that -/// the accumulators in the set are updated in the proper order. -/// -/// acccumulator_set provides a general mechanism to visit the accumulators -/// in the set in order, with or without a filter. You can also fetch a reference -/// to an accumulator that corresponds to a feature. -/// -template -struct accumulator_set - : detail::accumulator_set_base -{ - typedef Sample sample_type; ///< The type of the samples that will be accumulated - typedef Features features_type; ///< An MPL sequence of the features that should be accumulated. - typedef Weight weight_type; ///< The type of the weight parameter. Must be a scalar. Defaults to void. - - /// INTERNAL ONLY - /// - typedef - typename detail::make_accumulator_tuple< - Features - , Sample - , Weight - >::type - accumulators_mpl_vector; - - // generate a fusion::list of accumulators - /// INTERNAL ONLY - /// - typedef - typename detail::meta::make_acc_list< - accumulators_mpl_vector - >::type - accumulators_type; - - /// INTERNAL ONLY - /// - //BOOST_MPL_ASSERT((mpl::is_sequence)); - - /////////////////////////////////////////////////////////////////////////////// - /// default-construct all contained accumulators - accumulator_set() - : accumulators( - detail::make_acc_list( - accumulators_mpl_vector() - , detail::accumulator_params()(*this) - ) - ) - { - // Add-ref the Features that the user has specified - this->template visit_if >( - detail::make_add_ref_visitor(detail::accumulator_params()(*this)) - ); - } - - /// \overload - /// - /// \param a1 Optional named parameter to be passed to all the accumulators - template - explicit accumulator_set(A1 const &a1) - : accumulators( - detail::make_acc_list( - accumulators_mpl_vector() - , detail::accumulator_params()(*this, a1) - ) - ) - { - // Add-ref the Features that the user has specified - this->template visit_if >( - detail::make_add_ref_visitor(detail::accumulator_params()(*this)) - ); - } - - // ... other overloads generated by Boost.Preprocessor: - - /// INTERNAL ONLY - /// -#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR(z, n, _) \ - template \ - accumulator_set(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \ - : accumulators( \ - detail::make_acc_list( \ - accumulators_mpl_vector() \ - , detail::accumulator_params()( \ - *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ - ) \ - ) \ - ) \ - { \ - /* Add-ref the Features that the user has specified */ \ - this->template visit_if >( \ - detail::make_add_ref_visitor(detail::accumulator_params()(*this)) \ - ); \ - } - - /// INTERNAL ONLY - /// - BOOST_PP_REPEAT_FROM_TO( - 2 - , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) - , BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR - , _ - ) - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// \overload - /// - template - accumulator_set(A1 const &a1, A2 const &a2, ...); - #endif - - // ... other overloads generated by Boost.Preprocessor below ... - - /////////////////////////////////////////////////////////////////////////////// - /// Visitation - /// \param func UnaryFunction which is invoked with each accumulator in turn. - template - void visit(UnaryFunction const &func) - { - fusion::for_each(this->accumulators, func); - } - - /////////////////////////////////////////////////////////////////////////////// - /// Conditional visitation - /// \param func UnaryFunction which is invoked with each accumulator in turn, - /// provided the accumulator satisfies the MPL predicate FilterPred. - template - void visit_if(UnaryFunction const &func) - { - fusion::filter_view filtered_accs(this->accumulators); - fusion::for_each(filtered_accs, func); - } - - /////////////////////////////////////////////////////////////////////////////// - /// The return type of the operator() overloads is void. - typedef void result_type; - - /////////////////////////////////////////////////////////////////////////////// - /// Accumulation - /// \param a1 Optional named parameter to be passed to all the accumulators - void operator ()() - { - this->visit( - detail::make_accumulator_visitor( - detail::accumulator_params()(*this) - ) - ); - } - - template - void operator ()(A1 const &a1) - { - this->visit( - detail::make_accumulator_visitor( - detail::accumulator_params()(*this, a1) - ) - ); - } - - // ... other overloads generated by Boost.Preprocessor: - - /// INTERNAL ONLY - /// -#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP(z, n, _) \ - template \ - void operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \ - { \ - this->visit( \ - detail::make_accumulator_visitor( \ - detail::accumulator_params()( \ - *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ - ) \ - ) \ - ); \ - } - - /// INTERNAL ONLY - /// - BOOST_PP_REPEAT_FROM_TO( - 2 - , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) - , BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP - , _ - ) - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// \overload - /// - template - void operator ()(A1 const &a1, A2 const &a2, ...); - #endif - - /////////////////////////////////////////////////////////////////////////////// - /// Extraction - template - struct apply - : fusion::result_of::value_of< - typename fusion::result_of::find_if< - accumulators_type - , detail::matches_feature - >::type - > - { - }; - - /////////////////////////////////////////////////////////////////////////////// - /// Extraction - template - typename apply::type &extract() - { - return *fusion::find_if >(this->accumulators); - } - - /// \overload - template - typename apply::type const &extract() const - { - return *fusion::find_if >(this->accumulators); - } - - /////////////////////////////////////////////////////////////////////////////// - /// Drop - template - void drop() - { - // You can only drop the features that you have specified explicitly - typedef typename apply::type the_accumulator; - BOOST_MPL_ASSERT((detail::contains_feature_of)); - - typedef - typename feature_of::type>::type - the_feature; - - (*fusion::find_if >(this->accumulators)) - .drop(detail::accumulator_params()(*this)); - - // Also drop accumulators that this feature depends on - typedef typename the_feature::dependencies dependencies; - this->template visit_if >( - detail::make_drop_visitor(detail::accumulator_params()(*this)) - ); - } - -private: - - accumulators_type accumulators; -}; - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -/////////////////////////////////////////////////////////////////////////////// -// find_accumulator -// find an accumulator in an accumulator_set corresponding to a feature -template -typename mpl::apply::type & -find_accumulator(AccumulatorSet &acc BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(AccumulatorSet)) -{ - return acc.template extract(); -} - -/// \overload -template -typename mpl::apply::type const & -find_accumulator(AccumulatorSet const &acc) -{ - return acc.template extract(); -} - -/////////////////////////////////////////////////////////////////////////////// -// extract_result -// extract a result from an accumulator set -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN(z, n, _) \ - template< \ - typename Feature \ - , typename AccumulatorSet \ - BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ - > \ - typename mpl::apply::type::result_type \ - extract_result( \ - AccumulatorSet const &acc \ - BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ - ) \ - { \ - return find_accumulator(acc).result( \ - detail::accumulator_params()( \ - acc \ - BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ - ) \ - ); \ - } - -BOOST_PP_REPEAT( - BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) - , BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN - , _ -) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulators/droppable_accumulator.hpp b/boost/accumulators/framework/accumulators/droppable_accumulator.hpp deleted file mode 100644 index 0e882b5c35d10e283f78156fe7c411080816bb76..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulators/droppable_accumulator.hpp +++ /dev/null @@ -1,328 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// droppable_accumulator.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 - -#include -#include -#include -#include -#include // for feature_of -#include // for accumulator - -namespace boost { namespace accumulators -{ - - template - struct droppable_accumulator; - - namespace detail - { - /////////////////////////////////////////////////////////////////////////////// - // add_ref_visitor - // a fusion function object for add_ref'ing accumulators - template - struct add_ref_visitor - { - explicit add_ref_visitor(Args const &args) - : args_(args) - { - } - - template - void operator ()(Accumulator &acc) const - { - typedef typename Accumulator::feature_tag::dependencies dependencies; - - acc.add_ref(this->args_); - - // Also add_ref accumulators that this feature depends on - this->args_[accumulator].template - visit_if >( - *this - ); - } - - private: - add_ref_visitor &operator =(add_ref_visitor const &); - Args const &args_; - }; - - template - add_ref_visitor make_add_ref_visitor(Args const &args) - { - return add_ref_visitor(args); - } - - /////////////////////////////////////////////////////////////////////////////// - // drop_visitor - // a fusion function object for dropping accumulators - template - struct drop_visitor - { - explicit drop_visitor(Args const &args) - : args_(args) - { - } - - template - void operator ()(Accumulator &acc) const - { - if(typename Accumulator::is_droppable()) - { - typedef typename Accumulator::feature_tag::dependencies dependencies; - - acc.drop(this->args_); - // Also drop accumulators that this feature depends on - this->args_[accumulator].template - visit_if >( - *this - ); - } - } - - private: - drop_visitor &operator =(drop_visitor const &); - Args const &args_; - }; - - template - drop_visitor make_drop_visitor(Args const &args) - { - return drop_visitor(args); - } - } - - ////////////////////////////////////////////////////////////////////////// - // droppable_accumulator_base - template - struct droppable_accumulator_base - : Accumulator - { - typedef droppable_accumulator_base base; - typedef mpl::true_ is_droppable; - typedef typename Accumulator::result_type result_type; - - template - droppable_accumulator_base(Args const &args) - : Accumulator(args) - , ref_count_(0) - { - } - - droppable_accumulator_base(droppable_accumulator_base const &that) - : Accumulator(*static_cast(&that)) - , ref_count_(that.ref_count_) - { - } - - template - void operator ()(Args const &args) - { - if(!this->is_dropped()) - { - this->Accumulator::operator ()(args); - } - } - - template - void add_ref(Args const &) - { - ++this->ref_count_; - } - - template - void drop(Args const &args) - { - BOOST_ASSERT(0 < this->ref_count_); - if(1 == this->ref_count_) - { - static_cast *>(this)->on_drop(args); - } - --this->ref_count_; - } - - bool is_dropped() const - { - return 0 == this->ref_count_; - } - - private: - int ref_count_; - }; - - ////////////////////////////////////////////////////////////////////////// - // droppable_accumulator - // this can be specialized for any type that needs special handling - template - struct droppable_accumulator - : droppable_accumulator_base - { - template - droppable_accumulator(Args const &args) - : droppable_accumulator::base(args) - { - } - - droppable_accumulator(droppable_accumulator const &that) - : droppable_accumulator::base(*static_cast(&that)) - { - } - }; - - ////////////////////////////////////////////////////////////////////////// - // with_cached_result - template - struct with_cached_result - : Accumulator - { - typedef typename Accumulator::result_type result_type; - - template - with_cached_result(Args const &args) - : Accumulator(args) - , cache() - { - } - - with_cached_result(with_cached_result const &that) - : Accumulator(*static_cast(&that)) - , cache() - { - if(that.has_result()) - { - this->set(that.get()); - } - } - - ~with_cached_result() - { - // Since this is a base class of droppable_accumulator_base, - // this destructor is called before any of droppable_accumulator_base's - // members get cleaned up, including is_dropped, so the following - // call to has_result() is valid. - if(this->has_result()) - { - this->get().~result_type(); - } - } - - template - void on_drop(Args const &args) - { - // cache the result at the point this calculation was dropped - BOOST_ASSERT(!this->has_result()); - this->set(this->Accumulator::result(args)); - } - - template - result_type result(Args const &args) const - { - return this->has_result() ? this->get() : this->Accumulator::result(args); - } - - private: - with_cached_result &operator =(with_cached_result const &); - - void set(result_type const &r) - { - ::new(this->cache.address()) result_type(r); - } - - result_type const &get() const - { - return *static_cast(this->cache.address()); - } - - bool has_result() const - { - typedef with_cached_result this_type; - typedef droppable_accumulator_base derived_type; - return static_cast(this)->is_dropped(); - } - - aligned_storage cache; - }; - - namespace tag - { - template - struct as_droppable - { - typedef droppable type; - }; - - template - struct as_droppable > - { - typedef droppable type; - }; - - ////////////////////////////////////////////////////////////////////////// - // droppable - template - struct droppable - : as_feature::type - { - typedef typename as_feature::type feature_type; - typedef typename feature_type::dependencies tmp_dependencies_; - - typedef - typename mpl::transform< - typename feature_type::dependencies - , as_droppable - >::type - dependencies; - - struct impl - { - template - struct apply - { - typedef - droppable_accumulator< - typename mpl::apply2::type - > - type; - }; - }; - }; - } - - // make droppable work - template - struct as_feature > - { - typedef tag::droppable::type> type; - }; - - // make droppable work with non-void weights (should become - // droppable - template - struct as_weighted_feature > - { - typedef tag::droppable::type> type; - }; - - // for the purposes of feature-based dependency resolution, - // droppable provides the same feature as Foo - template - struct feature_of > - : feature_of - { - }; - - // Note: Usually, the extractor is pulled into the accumulators namespace with - // a using directive, not the tag. But the droppable<> feature doesn't have an - // extractor, so we can put the droppable tag in the accumulators namespace - // without fear of a name conflict. - using tag::droppable; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulators/external_accumulator.hpp b/boost/accumulators/framework/accumulators/external_accumulator.hpp deleted file mode 100644 index 71dce42e51b67ff59bb456417f1fb1e4244ba7cd..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulators/external_accumulator.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// external_accumulator.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 - -#include -#include -#include -#include // for feature_tag -#include -#include - -namespace boost { namespace accumulators { namespace impl -{ - - ////////////////////////////////////////////////////////////////////////// - // external_impl - /// INTERNAL ONLY - /// - template - struct external_impl - : accumulator_base - { - typedef typename Accumulator::result_type result_type; - typedef typename detail::feature_tag::type feature_tag; - - external_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - return this->extract_(args, args[parameter::keyword::get() | 0]); - } - - private: - - template - static result_type extract_(Args const &args, int) - { - // No named parameter passed to the extractor. Maybe the external - // feature is held by reference<>. - extractor extract; - return extract(accumulators::reference_tag(args)); - } - - template - static result_type extract_(Args const &, AccumulatorSet const &acc) - { - // OK, a named parameter for this external feature was passed to the - // extractor, so use that. - extractor extract; - return extract(acc); - } - }; - -} // namespace impl - -namespace tag -{ - ////////////////////////////////////////////////////////////////////////// - // external - template - struct external - : depends_on > - { - typedef - accumulators::impl::external_impl< - detail::to_accumulator - , Tag - > - impl; - }; - - template - struct external - : depends_on<> - { - typedef - accumulators::impl::external_impl< - detail::to_accumulator - , Tag - > - impl; - }; -} - -// for the purposes of feature-based dependency resolution, -// external_accumulator provides the same feature as Feature -template -struct feature_of > - : feature_of -{ -}; - -// Note: Usually, the extractor is pulled into the accumulators namespace with -// a using directive, not the tag. But the external<> feature doesn't have an -// extractor, so we can put the external tag in the accumulators namespace -// without fear of a name conflict. -using tag::external; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulators/reference_accumulator.hpp b/boost/accumulators/framework/accumulators/reference_accumulator.hpp deleted file mode 100644 index bf4252ca6a9bb97ec874062e293ed793c1c9ecce..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulators/reference_accumulator.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// reference_accumulator.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 - -#include -#include -#include -#include // for feature_tag -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - ////////////////////////////////////////////////////////////////////////// - // reference_accumulator_impl - // - template - struct reference_accumulator_impl - : accumulator_base - { - typedef Referent &result_type; - - template - reference_accumulator_impl(Args const &args) - : ref(args[parameter::keyword::get()]) - { - } - - result_type result(dont_care) const - { - return this->ref; - } - - private: - reference_wrapper ref; - }; -} // namespace impl - -namespace tag -{ - ////////////////////////////////////////////////////////////////////////// - // reference_tag - template - struct reference_tag - { - }; - - ////////////////////////////////////////////////////////////////////////// - // reference - template - struct reference - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; -} - -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference, (typename)(typename)) - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference_tag, (typename)) -} - -using extract::reference; -using extract::reference_tag; - -// Map all reference features to reference_tag so -// that references can be extracted using reference_tag -// without specifying the referent type. -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/accumulators/value_accumulator.hpp b/boost/accumulators/framework/accumulators/value_accumulator.hpp deleted file mode 100644 index 02bf7f34993373abe76c144fb3bca2d14dda575a..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/accumulators/value_accumulator.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// value_accumulator.hpp -// -// Copyright 2005 Eric Niebler, Daniel Egloff. 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_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 -#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 - -#include -#include -#include // for feature_tag -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - ////////////////////////////////////////////////////////////////////////// - // value_accumulator_impl - template - struct value_accumulator_impl - : accumulator_base - { - typedef ValueType result_type; - - template - value_accumulator_impl(Args const &args) - : val(args[parameter::keyword::get()]) - { - } - - result_type result(dont_care) const - { - return this->val; - } - - private: - ValueType val; - }; - -} // namespace impl - -namespace tag -{ - ////////////////////////////////////////////////////////////////////////// - // value_tag - template - struct value_tag - { - }; - - ////////////////////////////////////////////////////////////////////////// - // value - template - struct value - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; -} - -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename)) - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename)) -} - -using extract::value; -using extract::value_tag; - -// Map all value features to value_tag so -// that values can be extracted using value_tag -// without specifying the value type. -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/depends_on.hpp b/boost/accumulators/framework/depends_on.hpp deleted file mode 100644 index 008f1217da44a6f2d1d326e421d05eac731b8eb9..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/depends_on.hpp +++ /dev/null @@ -1,448 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// depends_on.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - /////////////////////////////////////////////////////////////////////////// - // as_feature - template - struct as_feature - { - typedef Feature type; - }; - - /////////////////////////////////////////////////////////////////////////// - // weighted_feature - template - struct as_weighted_feature - { - typedef Feature type; - }; - - /////////////////////////////////////////////////////////////////////////// - // feature_of - template - struct feature_of - { - typedef Feature type; - }; - - namespace detail - { - /////////////////////////////////////////////////////////////////////////// - // feature_tag - template - struct feature_tag - { - typedef typename Accumulator::feature_tag type; - }; - - template - struct undroppable - { - typedef Feature type; - }; - - template - struct undroppable > - { - typedef Feature type; - }; - - // For the purpose of determining whether one feature depends on another, - // disregard whether the feature is droppable or not. - template - struct is_dependent_on - : is_base_and_derived< - typename feature_of::type>::type - , typename undroppable::type - > - {}; - - template - struct dependencies_of - { - typedef typename Feature::dependencies type; - }; - - // Should use mpl::insert_range, but doesn't seem to work with mpl sets - template - struct set_insert_range - : mpl::fold< - Range - , Set - , mpl::insert - > - {}; - - template - struct collect_abstract_features - : mpl::fold< - Features - , mpl::set0<> - , set_insert_range< - mpl::insert > - , collect_abstract_features > - > - > - {}; - - template - struct depends_on_base - : mpl::inherit_linearly< - typename mpl::sort< - typename mpl::copy< - typename collect_abstract_features::type - , mpl::back_inserter > - >::type - , is_dependent_on - >::type - // Don't inherit multiply from a feature - , mpl::if_< - is_dependent_on - , mpl::_1 - , mpl::inherit - > - >::type - { - }; - } - - /////////////////////////////////////////////////////////////////////////// - /// depends_on - template - struct depends_on - : detail::depends_on_base< - typename mpl::transform< - mpl::vector - , as_feature - >::type - > - { - typedef mpl::false_ is_weight_accumulator; - typedef - typename mpl::transform< - mpl::vector - , as_feature - >::type - dependencies; - }; - - namespace detail - { - template - struct matches_feature - { - template - struct apply - : is_same< - typename feature_of::type>::type - , typename feature_of::type>::type>::type - > - {}; - }; - - template - struct contains_feature_of - { - typedef - mpl::transform_view > > - features_list; - - typedef - typename feature_of::type>::type - the_feature; - - typedef - typename mpl::contains::type - type; - }; - - // This is to work around a bug in early versions of Fusion which caused - // a compile error if contains_feature_of is used as a - // predicate to fusion::find_if - template - struct contains_feature_of_ - { - template - struct apply - : contains_feature_of - {}; - }; - - template< - typename First - , typename Last - , bool is_empty = fusion::result_of::equal_to::value - > - struct build_acc_list; - - template - struct build_acc_list - { - typedef fusion::nil_ type; - - template - static fusion::nil_ - call(Args const &, First const&, Last const&) - { - return fusion::nil_(); - } - }; - - template - struct build_acc_list - { - typedef - build_acc_list::type, Last> - next_build_acc_list; - - typedef fusion::cons< - typename fusion::result_of::value_of::type - , typename next_build_acc_list::type> - type; - - template - static type - call(Args const &args, First const& f, Last const& l) - { - return type(args, next_build_acc_list::call(args, fusion::next(f), l)); - } - }; - - namespace meta - { - template - struct make_acc_list - : build_acc_list< - typename fusion::result_of::begin::type - , typename fusion::result_of::end::type - > - {}; - } - - template - typename meta::make_acc_list::type - make_acc_list(Sequence const &seq, Args const &args) - { - return meta::make_acc_list::call(args, fusion::begin(seq), fusion::end(seq)); - } - - /////////////////////////////////////////////////////////////////////////// - // checked_as_weighted_feature - template - struct checked_as_weighted_feature - { - typedef typename as_feature::type feature_type; - typedef typename as_weighted_feature::type type; - // weighted and non-weighted flavors should provide the same feature. - BOOST_MPL_ASSERT(( - is_same< - typename feature_of::type - , typename feature_of::type - > - )); - }; - - /////////////////////////////////////////////////////////////////////////// - // as_feature_list - template - struct as_feature_list - : mpl::transform_view > - { - }; - - template - struct as_feature_list - : mpl::transform_view > - { - }; - - /////////////////////////////////////////////////////////////////////////// - // accumulator_wrapper - template - struct accumulator_wrapper - : Accumulator - { - typedef Feature feature_tag; - - accumulator_wrapper(accumulator_wrapper const &that) - : Accumulator(*static_cast(&that)) - { - } - - template - accumulator_wrapper(Args const &args) - : Accumulator(args) - { - } - }; - - /////////////////////////////////////////////////////////////////////////// - // to_accumulator - template - struct to_accumulator - { - typedef - accumulator_wrapper< - typename mpl::apply2::type - , Feature - > - type; - }; - - template - struct to_accumulator > - { - BOOST_MPL_ASSERT((is_same)); - BOOST_MPL_ASSERT((is_same)); - - typedef - accumulator_wrapper< - typename mpl::apply2::type - , Feature - > - accumulator_type; - - typedef - typename mpl::if_< - typename Feature::is_weight_accumulator - , accumulator_wrapper, Feature> - , accumulator_type - >::type - type; - }; - - // BUGBUG work around an MPL bug wrt map insertion - template - struct insert_feature - : mpl::eval_if< - mpl::has_key::type> - , mpl::identity - , mpl::insert::type, Feature> > - > - { - }; - - template - struct insert_dependencies - : mpl::fold< - as_feature_list - , FeatureMap - , insert_dependencies< - insert_feature - , mpl::_2 - , Weight - > - > - { - }; - - template - struct insert_sequence - : mpl::fold< // BUGBUG should use insert_range, but doesn't seem to work for maps - as_feature_list - , FeatureMap - , insert_feature - > - { - }; - - template - struct make_accumulator_tuple - { - typedef - typename mpl::fold< - as_feature_list - , mpl::map0<> - , mpl::if_< - mpl::is_sequence - , insert_sequence - , insert_feature - > - >::type - feature_map; - - // for each element in the map, add its dependencies also - typedef - typename mpl::fold< - feature_map - , feature_map - , insert_dependencies, Weight> - >::type - feature_map_with_dependencies; - - // turn the map into a vector so we can sort it - typedef - typename mpl::insert_range< - mpl::vector<> - , mpl::end >::type - , mpl::transform_view > - >::type - feature_vector_with_dependencies; - - // sort the features according to which is derived from which - typedef - typename mpl::sort< - feature_vector_with_dependencies - , is_dependent_on - >::type - sorted_feature_vector; - - // From the vector of features, construct a vector of accumulators - typedef - typename mpl::transform< - sorted_feature_vector - , to_accumulator - >::type - type; - }; - - } // namespace detail - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/external.hpp b/boost/accumulators/framework/external.hpp deleted file mode 100644 index dbd5d91693942f69f5520310fcdcd723ec80f284..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/external.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// external.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 - -#include -#include - -//namespace boost { namespace accumulators -//{ -// -///////////////////////////////////////////////////////////////////////////////// -//// external -//// -//template -//struct external -//{ -//}; -// -//}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/extractor.hpp b/boost/accumulators/framework/extractor.hpp deleted file mode 100644 index 98281cecb9d9bb779917eccca2e2b1036fda188b..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/extractor.hpp +++ /dev/null @@ -1,229 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// extractor.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace detail -{ - template - struct accumulator_set_result - { - typedef typename as_feature::type feature_type; - typedef typename mpl::apply::type::result_type type; - }; - - template - struct argument_pack_result - : accumulator_set_result< - typename remove_reference< - typename parameter::binding::type - >::type - , Feature - > - { - }; - - template - struct extractor_result - : mpl::eval_if< - detail::is_accumulator_set - , accumulator_set_result - , argument_pack_result - > - { - }; - - template - typename extractor_result::type - do_extract(AccumulatorSet const &acc, mpl::true_) - { - typedef typename as_feature::type feature_type; - return extract_result(acc); - } - - template - typename extractor_result::type - do_extract(Args const &args, mpl::false_) - { - typedef typename as_feature::type feature_type; - return find_accumulator(args[accumulator]).result(args); - } - -} // namespace detail - - -/////////////////////////////////////////////////////////////////////////////// -/// Extracts the result associated with Feature from the specified accumulator_set. -template -struct extractor -{ - typedef extractor this_type; - - /// The result meta-function for determining the return type of the extractor - template - struct result; - - template - struct result - : detail::extractor_result - { - }; - - /// Extract the result associated with Feature from the accumulator set - /// \param acc The accumulator set object from which to extract the result - template - typename detail::extractor_result::type - operator ()(Arg1 const &arg1) const - { - // Arg1 could be an accumulator_set or an argument pack containing - // an accumulator_set. Dispatch accordingly. - return detail::do_extract(arg1, detail::is_accumulator_set()); - } - - /// \overload - /// - /// \param a1 Optional named parameter to be passed to the accumulator's result() function. - template - typename detail::extractor_result::type - operator ()(AccumulatorSet const &acc, A1 const &a1) const - { - BOOST_MPL_ASSERT((detail::is_accumulator_set)); - typedef typename as_feature::type feature_type; - return extract_result(acc, a1); - } - - // ... other overloads generated by Boost.Preprocessor: - - /// INTERNAL ONLY - /// -#define BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP(z, n, _) \ - template \ - struct result \ - : detail::extractor_result \ - {}; \ - template< \ - typename AccumulatorSet \ - BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ - > \ - typename detail::extractor_result::type \ - operator ()( \ - AccumulatorSet const &acc \ - BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ - ) const \ - { \ - BOOST_MPL_ASSERT((detail::is_accumulator_set)); \ - typedef typename as_feature::type feature_type; \ - return extract_result(acc BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a));\ - } - - BOOST_PP_REPEAT_FROM_TO( - 2 - , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) - , BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP - , _ - ) - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// \overload - /// - template - typename detail::extractor_result::type - operator ()(AccumulatorSet const &acc, A1 const &a1, A2 const &a2, ...); - #endif -}; - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \ - BOOST_PP_TUPLE_REM_CTOR(BOOST_PP_ARRAY_SIZE(Array), BOOST_PP_ARRAY_DATA(Array)) - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_SEQ_REM(Seq) \ - BOOST_ACCUMULATORS_ARRAY_REM(BOOST_PP_SEQ_TO_ARRAY(Seq)) - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_ARGS_OP(s, data, elem) \ - T ## s - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_PARAMS_OP(s, data, elem) \ - elem T ## s - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ - Tag::Feature< \ - BOOST_ACCUMULATORS_SEQ_REM( \ - BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_ARGS_OP, ~, ParamsSeq) \ - ) \ - > - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL(z, n, Tag, Feature, ParamsSeq) \ - template< \ - BOOST_ACCUMULATORS_SEQ_REM( \ - BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_PARAMS_OP, ~, ParamsSeq) \ - ) \ - , typename Arg1 \ - BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ - > \ - typename boost::accumulators::detail::extractor_result< \ - Arg1 \ - , BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ - >::type \ - Feature(Arg1 const &arg1 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) ) \ - { \ - typedef BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) feature_type; \ - return boost::accumulators::extractor()( \ - arg1 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a)); \ - } - -/// INTERNAL ONLY -/// -#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN(z, n, _) \ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL( \ - z \ - , n \ - , BOOST_PP_ARRAY_ELEM(0, _) \ - , BOOST_PP_ARRAY_ELEM(1, _) \ - , BOOST_PP_ARRAY_ELEM(2, _) \ - ) - -#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(Tag, Feature, ParamSeq) \ - BOOST_PP_REPEAT( \ - BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) \ - , BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN \ - , (3, (Tag, Feature, ParamSeq)) \ - ) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/features.hpp b/boost/accumulators/framework/features.hpp deleted file mode 100644 index 21cae004daecffb9496dbf9fae3ccd748a3e469d..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/features.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// features.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005 -#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005 - -#include -#include -#include - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// features -// -template -struct features - : mpl::vector -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/parameters/accumulator.hpp b/boost/accumulators/framework/parameters/accumulator.hpp deleted file mode 100644 index 525ebb30ba339b5e5c44301e9a6be43076ea2885..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/parameters/accumulator.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// accumulator.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -BOOST_PARAMETER_KEYWORD(tag, accumulator) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(accumulator) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/parameters/sample.hpp b/boost/accumulators/framework/parameters/sample.hpp deleted file mode 100644 index 8b227eb3343d590ac809bc07aa2a3f5e968e237c..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/parameters/sample.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// sample.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -BOOST_PARAMETER_KEYWORD(tag, sample) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(sample) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/parameters/weight.hpp b/boost/accumulators/framework/parameters/weight.hpp deleted file mode 100644 index f36016f37267d1afb2d1ff012f88dca768d5fe33..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/parameters/weight.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weight.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -// The weight of a single sample -BOOST_PARAMETER_KEYWORD(tag, weight) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(weight) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/framework/parameters/weights.hpp b/boost/accumulators/framework/parameters/weights.hpp deleted file mode 100644 index 6beae61386cc8679de5041b3ab1e7611a29181aa..0000000000000000000000000000000000000000 --- a/boost/accumulators/framework/parameters/weights.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weights.hpp -// -// Copyright 2005 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_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -// The weight accumulator -BOOST_PARAMETER_KEYWORD(tag, weights) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(weights) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/numeric/detail/function1.hpp b/boost/accumulators/numeric/detail/function1.hpp deleted file mode 100644 index 282eb1ef3e945951dda2348d2440fc1676de4e26..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/function1.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION1_DWA200655_HPP -# define BOOST_DETAIL_FUNCTION1_DWA200655_HPP - -# include -# include -# include -# include - -namespace boost { namespace detail { - -// A utility for creating unary function objects that play nicely with -// boost::result_of and that handle the forwarding problem. -// -// mpl::apply::type is expected to be a stateless function -// object that accepts an argument of type A0&. It is also expected -// to have a nested ::result_type identical to its return type. -template -struct function1 -{ - template - struct result - {}; - - template - struct result - { - // How adding const to arguments handles rvalues. - // - // if A0 is arg0 is represents actual argument - // -------- ------- -------------------------- - // T const & T const const T lvalue - // T & T non-const T lvalue - // T const T const const T rvalue - // T T const non-const T rvalue - typedef typename remove_reference< - typename add_const< A0 >::type - >::type arg0; - - typedef typename mpl::apply1::type impl; - typedef typename impl::result_type type; - }; - - // Handles mutable lvalues - template - typename result::type - operator ()(A0 &a0) const - { - typedef typename result::impl impl; - typedef typename result::type type; - typedef A0 &arg0; - BOOST_CONCEPT_ASSERT((UnaryFunction)); - //boost::function_requires >(); - return impl()(a0); - } - - // Handles const lvalues and all rvalues - template - typename result::type - operator ()(A0 const &a0) const - { - typedef typename result::impl impl; - typedef typename result::type type; - typedef A0 const &arg0; - BOOST_CONCEPT_ASSERT((UnaryFunction)); - //boost::function_requires >(); - return impl()(a0); - } -}; - -}} // namespace boost::detail - -#endif // BOOST_DETAIL_FUNCTION1_DWA200655_HPP diff --git a/boost/accumulators/numeric/detail/function2.hpp b/boost/accumulators/numeric/detail/function2.hpp deleted file mode 100644 index daf3c4d4e76c13370133fc3cd5f9ce321768e520..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/function2.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION2_DWA200655_HPP -# define BOOST_DETAIL_FUNCTION2_DWA200655_HPP - -# define args (2) -# include - -#endif // BOOST_DETAIL_FUNCTION2_DWA200655_HPP diff --git a/boost/accumulators/numeric/detail/function3.hpp b/boost/accumulators/numeric/detail/function3.hpp deleted file mode 100644 index 175e4d5b3a81a5355a9f3ee66c0ea82e78079ba6..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/function3.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION3_DWA2006514_HPP -# define BOOST_DETAIL_FUNCTION3_DWA2006514_HPP - -# define args (3) -# include - -#endif // BOOST_DETAIL_FUNCTION3_DWA2006514_HPP diff --git a/boost/accumulators/numeric/detail/function4.hpp b/boost/accumulators/numeric/detail/function4.hpp deleted file mode 100644 index a0d710837e570adf86f2a3b686cb342b8770eb7b..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/function4.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION4_DWA2006514_HPP -# define BOOST_DETAIL_FUNCTION4_DWA2006514_HPP - -# define args (4) -# include - -#endif // BOOST_DETAIL_FUNCTION4_DWA2006514_HPP diff --git a/boost/accumulators/numeric/detail/function_n.hpp b/boost/accumulators/numeric/detail/function_n.hpp deleted file mode 100644 index 47c42ed05b8eab1c090dda02ce9682323eb1dcca..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/function_n.hpp +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// #include guards intentionally disabled. -// #ifndef BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP -// # define BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace detail { - -# define BOOST_DETAIL_default_arg(z, n, _) \ - typedef mpl::void_ BOOST_PP_CAT(arg, n); - -# define BOOST_DETAIL_function_arg(z, n, _) \ - typedef typename remove_reference< \ - typename add_const< BOOST_PP_CAT(A, n) >::type \ - >::type BOOST_PP_CAT(arg, n); - -#define BOOST_DETAIL_cat_arg_counts(s, state, n) \ - BOOST_PP_IF( \ - n \ - , BOOST_PP_CAT(state, BOOST_PP_CAT(_, n)) \ - , state \ - ) \ - /**/ - -#define function_name \ - BOOST_PP_SEQ_FOLD_LEFT( \ - BOOST_DETAIL_cat_arg_counts \ - , BOOST_PP_CAT(function, BOOST_PP_SEQ_HEAD(args)) \ - , BOOST_PP_SEQ_TAIL(args)(0) \ - ) \ - /**/ - -template -struct function_name -{ - BOOST_PP_REPEAT( - BOOST_MPL_LIMIT_METAFUNCTION_ARITY - , BOOST_DETAIL_default_arg - , ~ - ) - - template - struct result {}; - -#define BOOST_DETAIL_function_result(r, _, n) \ - template \ - struct result \ - { \ - BOOST_PP_REPEAT(n, BOOST_DETAIL_function_arg, ~) \ - typedef \ - typename BOOST_PP_CAT(mpl::apply, BOOST_MPL_LIMIT_METAFUNCTION_ARITY)<\ - F \ - BOOST_PP_ENUM_TRAILING_PARAMS( \ - BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ - , arg \ - ) \ - >::type \ - impl; \ - typedef typename impl::result_type type; \ - }; \ - /**/ - - BOOST_PP_SEQ_FOR_EACH(BOOST_DETAIL_function_result, _, args) - -# define arg_type(r, _, i, is_const) \ - BOOST_PP_COMMA_IF(i) BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & - -# define result_(r, n, constness) \ - typename result< \ - function_name( \ - BOOST_PP_SEQ_FOR_EACH_I_R(r, arg_type, ~, constness) \ - ) \ - > \ - /**/ - -# define param(r, _, i, is_const) BOOST_PP_COMMA_IF(i) \ - BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & BOOST_PP_CAT(x, i) - -# define param_list(r, n, constness) \ - BOOST_PP_SEQ_FOR_EACH_I_R(r, param, ~, constness) - -# define call_operator(r, constness) \ - template \ - result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::type \ - operator ()( param_list(r, BOOST_PP_SEQ_SIZE(constness), constness) ) const \ - { \ - typedef result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::impl impl; \ - return impl()(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), x)); \ - } \ - /**/ - -# define const_if0 -# define const_if1 const - -# define bits(z, n, _) ((0)(1)) - -# define gen_operator(r, _, n) \ - BOOST_PP_SEQ_FOR_EACH_PRODUCT_R( \ - r \ - , call_operator \ - , BOOST_PP_REPEAT(n, bits, ~) \ - ) \ - /**/ - - BOOST_PP_SEQ_FOR_EACH( - gen_operator - , ~ - , args - ) - -# undef bits -# undef const_if1 -# undef const_if0 -# undef call_operator -# undef param_list -# undef param -# undef result_ -# undef default_ -# undef arg_type -# undef gen_operator -# undef function_name - -# undef args -}; - -}} // namespace boost::detail - -//#endif // BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP diff --git a/boost/accumulators/numeric/detail/pod_singleton.hpp b/boost/accumulators/numeric/detail/pod_singleton.hpp deleted file mode 100644 index 317d85fb24a290ab8d0c83dc51c18b88ee1bd450..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/detail/pod_singleton.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright David Abrahams 2006. 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_DETAIL_POD_SINGLETON_DWA200655_HPP -# define BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP - -namespace boost { namespace detail { - -template -struct pod_singleton -{ - static T instance; -}; - -template -T pod_singleton::instance; - -}} // namespace boost::detail - -#endif // BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP diff --git a/boost/accumulators/numeric/functional.hpp b/boost/accumulators/numeric/functional.hpp deleted file mode 100644 index 858decc199a72ad7936fb6096ef640586521c111..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/functional.hpp +++ /dev/null @@ -1,537 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file functional.hpp -/// -// Copyright 2005 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_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 -#define BOOST_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VECTOR_SUPPORT -# include -#endif - -#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VALARRAY_SUPPORT -# include -#endif - -#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_COMPLEX_SUPPORT -# include -#endif - -/// INTERNAL ONLY -/// -#define BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED - -#ifdef BOOST_NUMERIC_FUNCTIONAL_DOXYGEN_INVOKED -// Hack to make Doxygen show the inheritance relationships -/// INTERNAL ONLY -/// -namespace std -{ - /// INTERNAL ONLY - /// - template struct unary_function {}; - /// INTERNAL ONLY - /// - template struct binary_function {}; -} -#endif - -namespace boost { namespace numeric -{ - namespace functional - { - /// INTERNAL ONLY - /// - template - struct are_integral - : mpl::and_, is_integral > - {}; - - template - struct left_ref - { - typedef Left &type; - }; - - namespace detail - { - template - T &lvalue_of(); - } - } - - // TODO: handle complex weight, valarray, MTL vectors - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(Name, Op) \ - namespace functional \ - { \ - template \ - struct result_of_ ## Name \ - { \ - BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ - nested \ - , Op boost::numeric::functional::detail::lvalue_of() \ - ) \ - typedef typename nested::type type; \ - }; \ - template \ - struct Name ## _base \ - { \ - typedef typename remove_const::type argument_type; \ - typedef typename result_of_ ## Name::type result_type; \ - typename result_of_ ## Name::type operator ()(Arg &arg) const \ - { \ - return Op arg; \ - } \ - }; \ - template \ - struct Name \ - : Name ## _base \ - {}; \ - } \ - namespace op \ - { \ - struct Name \ - : boost::detail::function1 > > \ - {}; \ - } \ - namespace \ - { \ - op::Name const &Name = boost::detail::pod_singleton::instance; \ - } \ - /**/ - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(Name, Op, RetType) \ - namespace functional \ - { \ - template \ - struct result_of_ ## Name \ - { \ - RetType(Left, Op, Right) \ - }; \ - template \ - struct Name ## _base \ - { \ - typedef typename remove_const::type first_argument_type; \ - typedef typename remove_const::type second_argument_type; \ - typedef typename result_of_ ## Name::type result_type; \ - typename result_of_ ## Name::type \ - operator ()(Left &left, Right &right) const \ - { \ - return left Op right; \ - } \ - }; \ - template \ - struct Name \ - : Name ## _base \ - {}; \ - } \ - namespace op \ - { \ - struct Name \ - : boost::detail::function2< \ - functional::Name<_1, _2, functional::tag<_1>, functional::tag<_2> > \ - > \ - {}; \ - } \ - namespace \ - { \ - op::Name const &Name = boost::detail::pod_singleton::instance; \ - } \ - BOOST_ACCUMULATORS_IGNORE_GLOBAL(Name) \ - /**/ - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_DEDUCED(Left, Op, Right) \ - BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ - nested \ - , boost::numeric::functional::detail::lvalue_of() Op \ - boost::numeric::functional::detail::lvalue_of() \ - ) \ - typedef typename nested::type type; \ - /**/ - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_LEFT(Left, Op, Right) \ - typedef Left &type; \ - /**/ - - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus, +, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus, -, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies, *, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides, /, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus, %, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater, >, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater_equal, >=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less, <, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less_equal, <=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(equal_to, ==, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(not_equal_to, !=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) - - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(assign, =, BOOST_NUMERIC_FUNCTIONAL_LEFT) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus_assign, +=, BOOST_NUMERIC_FUNCTIONAL_LEFT) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus_assign, -=, BOOST_NUMERIC_FUNCTIONAL_LEFT) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies_assign, *=, BOOST_NUMERIC_FUNCTIONAL_LEFT) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides_assign, /=, BOOST_NUMERIC_FUNCTIONAL_LEFT) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus_assign, %=, BOOST_NUMERIC_FUNCTIONAL_LEFT) - - BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_plus, +) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_minus, -) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(complement, ~) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(logical_not, !) - -#undef BOOST_NUMERIC_FUNCTIONAL_LEFT -#undef BOOST_NUMERIC_FUNCTIONAL_DEDUCED -#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP -#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP - - namespace functional - { - template - struct min_assign_base - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - if(numeric::less(right, left)) - { - left = right; - } - } - }; - - template - struct max_assign_base - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - if(numeric::greater(right, left)) - { - left = right; - } - } - }; - - template - struct fdiv_base - : functional::divides - {}; - - // partial specialization that promotes the arguments to double for - // integral division. - template - struct fdiv_base >::type> - : functional::divides - {}; - - template - struct promote_base - { - typedef From argument_type; - typedef To result_type; - - To operator ()(From &from) const - { - return from; - } - }; - - template - struct promote_base - { - typedef ToFrom argument_type; - typedef ToFrom result_type; - - ToFrom &operator ()(ToFrom &tofrom) - { - return tofrom; - } - }; - - template - struct as_min_base - { - BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); - - typedef Arg argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(Arg &) const - { - return (std::numeric_limits::type>::min)(); - } - }; - - template - struct as_min_base >::type> - { - BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); - - typedef Arg argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(Arg &) const - { - return -(std::numeric_limits::type>::max)(); - } - }; - - template - struct as_max_base - { - BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); - - typedef Arg argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(Arg &) const - { - return (std::numeric_limits::type>::max)(); - } - }; - - template - struct as_zero_base - { - typedef Arg argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(Arg &) const - { - return numeric::zero::type>::value; - } - }; - - template - struct as_one_base - { - typedef Arg argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(Arg &) const - { - return numeric::one::type>::value; - } - }; - - template - struct promote - : promote_base - {}; - - template - struct min_assign - : min_assign_base - {}; - - template - struct max_assign - : max_assign_base - {}; - - template - struct fdiv - : fdiv_base - {}; - - /// INTERNAL ONLY - /// For back-compat only. Use fdiv. - template - struct average - : fdiv - {}; - - template - struct as_min - : as_min_base - {}; - - template - struct as_max - : as_max_base - {}; - - template - struct as_zero - : as_zero_base - {}; - - template - struct as_one - : as_one_base - {}; - } - - namespace op - { - template - struct promote - : boost::detail::function1::type, functional::tag<_> > > - {}; - - struct min_assign - : boost::detail::function2, functional::tag<_2> > > - {}; - - struct max_assign - : boost::detail::function2, functional::tag<_2> > > - {}; - - struct fdiv - : boost::detail::function2, functional::tag<_2> > > - {}; - - /// INTERNAL ONLY - struct average - : boost::detail::function2, functional::tag<_2> > > - {}; - - struct as_min - : boost::detail::function1 > > - {}; - - struct as_max - : boost::detail::function1 > > - {}; - - struct as_zero - : boost::detail::function1 > > - {}; - - struct as_one - : boost::detail::function1 > > - {}; - } - - namespace - { - op::min_assign const &min_assign = boost::detail::pod_singleton::instance; - op::max_assign const &max_assign = boost::detail::pod_singleton::instance; - op::fdiv const &fdiv = boost::detail::pod_singleton::instance; - op::fdiv const &average = boost::detail::pod_singleton::instance; ///< INTERNAL ONLY - op::as_min const &as_min = boost::detail::pod_singleton::instance; - op::as_max const &as_max = boost::detail::pod_singleton::instance; - op::as_zero const &as_zero = boost::detail::pod_singleton::instance; - op::as_one const &as_one = boost::detail::pod_singleton::instance; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(min_assign) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(max_assign) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(fdiv) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(average) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_min) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_max) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_zero) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_one) - } - - /////////////////////////////////////////////////////////////////////////////// - // promote - template - typename lazy_disable_if, mpl::if_, To &, To> >::type - promote(From &from) - { - return functional::promote()(from); - } - - template - typename mpl::if_, To const &, To const>::type - promote(From const &from) - { - return functional::promote()(from); - } - - template - struct default_ - { - typedef default_ type; - typedef T value_type; - static T const value; - - operator T const & () const - { - return default_::value; - } - }; - - template - T const default_::value = T(); - - template - struct one - { - typedef one type; - typedef T value_type; - static T const value; - - operator T const & () const - { - return one::value; - } - }; - - template - T const one::value = T(1); - - template - struct zero - { - typedef zero type; - typedef T value_type; - static T const value; - - operator T const & () const - { - return zero::value; - } - }; - - template - T const zero::value = T(); - - template - struct one_or_default - : mpl::if_, default_, one >::type - {}; - - template - struct zero_or_default - : mpl::if_, default_, zero >::type - {}; - -}} // namespace boost::numeric - -#endif diff --git a/boost/accumulators/numeric/functional/complex.hpp b/boost/accumulators/numeric/functional/complex.hpp deleted file mode 100644 index ea8c0332400d9088b6fea2383c6189a18c84bbb5..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/functional/complex.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file complex.hpp -/// -// Copyright 2005 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_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 -#define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 - -#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED -# error Include this file before boost/accumulators/numeric/functional.hpp -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { namespace numeric { namespace operators -{ - // So that the stats compile when Sample type is std::complex - template - typename - disable_if< - mpl::or_, is_same, U> > - , std::complex - >::type - operator *(std::complex ri, U const &u) - { - // BUGBUG promote result to typeof(T()*u) ? - return ri *= static_cast(u); - } - - template - typename - disable_if< - mpl::or_, is_same, U> > - , std::complex - >::type - operator /(std::complex ri, U const &u) - { - // BUGBUG promote result to typeof(T()*u) ? - return ri /= static_cast(u); - } - -}}} // namespace boost::numeric::operators - -namespace boost { namespace numeric -{ - namespace detail - { - template - struct one_complex - { - static std::complex const value; - }; - - template - std::complex const one_complex::value - = std::complex(numeric::one::value, numeric::one::value); - } - - /// INTERNAL ONLY - /// - template - struct one > - : detail::one_complex - { - typedef one type; - typedef std::complex value_type; - operator value_type const & () const - { - return detail::one_complex::value; - } - }; - -}} // namespace boost::numeric - -#endif diff --git a/boost/accumulators/numeric/functional/valarray.hpp b/boost/accumulators/numeric/functional/valarray.hpp deleted file mode 100644 index 1996c75845fa0bfe9a47c73351cd83944de314e4..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/functional/valarray.hpp +++ /dev/null @@ -1,362 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file valarray.hpp -/// -// Copyright 2005 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_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 -#define BOOST_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 - -#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED -# error Include this file before boost/accumulators/numeric/functional.hpp -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace numeric -{ - namespace operators - { - namespace acc_detail - { - template - struct make_valarray - { - typedef std::valarray type; - }; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle valarray / Right where Right is a scalar and Right != Left. - template - typename lazy_enable_if< - mpl::and_, mpl::not_ > > - , acc_detail::make_valarray > - >::type - operator /(std::valarray const &left, Right const &right) - { - typedef typename functional::divides::result_type value_type; - std::valarray result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::divides(left[i], right); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle valarray * Right where Right is a scalar and Right != Left. - template - typename lazy_enable_if< - mpl::and_, mpl::not_ > > - , acc_detail::make_valarray > - >::type - operator *(std::valarray const &left, Right const &right) - { - typedef typename functional::multiplies::result_type value_type; - std::valarray result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::multiplies(left[i], right); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle valarray + valarray where Right != Left. - template - typename lazy_disable_if< - is_same - , acc_detail::make_valarray > - >::type - operator +(std::valarray const &left, std::valarray const &right) - { - typedef typename functional::plus::result_type value_type; - std::valarray result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::plus(left[i], right[i]); - } - return result; - } - } - - namespace functional - { - struct std_valarray_tag; - - template - struct tag > - { - typedef std_valarray_tag type; - }; - - #ifdef __GLIBCXX__ - template - struct tag > - { - typedef std_valarray_tag type; - }; - #endif - - /// INTERNAL ONLY - /// - // This is necessary because the GCC stdlib uses expression templates, and - // typeof(som-valarray-expression) is not an instance of std::valarray - #define BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(Name, Op) \ - template \ - struct Name \ - { \ - typedef Left first_argument_type; \ - typedef Right second_argument_type; \ - typedef typename Left::value_type left_value_type; \ - typedef typename Right::value_type right_value_type; \ - typedef \ - std::valarray< \ - typename Name::result_type \ - > \ - result_type; \ - result_type \ - operator ()(Left &left, Right &right) const \ - { \ - return numeric::promote >(left) \ - Op numeric::promote >(right); \ - } \ - }; \ - template \ - struct Name \ - { \ - typedef Left first_argument_type; \ - typedef Right second_argument_type; \ - typedef typename Left::value_type left_value_type; \ - typedef \ - std::valarray< \ - typename Name::result_type \ - > \ - result_type; \ - result_type \ - operator ()(Left &left, Right &right) const \ - { \ - return numeric::promote >(left) Op right;\ - } \ - }; \ - template \ - struct Name \ - { \ - typedef Left first_argument_type; \ - typedef Right second_argument_type; \ - typedef typename Right::value_type right_value_type; \ - typedef \ - std::valarray< \ - typename Name::result_type \ - > \ - result_type; \ - result_type \ - operator ()(Left &left, Right &right) const \ - { \ - return left Op numeric::promote >(right);\ - } \ - }; - - BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(plus, +) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(minus, -) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(multiplies, *) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(divides, /) - BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(modulus, %) - - #undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP - - /////////////////////////////////////////////////////////////////////////////// - // element-wise min of std::valarray - template - struct min_assign - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - BOOST_ASSERT(left.size() == right.size()); - for(std::size_t i = 0, size = left.size(); i != size; ++i) - { - if(numeric::less(right[i], left[i])) - { - left[i] = right[i]; - } - } - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // element-wise max of std::valarray - template - struct max_assign - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - BOOST_ASSERT(left.size() == right.size()); - for(std::size_t i = 0, size = left.size(); i != size; ++i) - { - if(numeric::greater(right[i], left[i])) - { - left[i] = right[i]; - } - } - } - }; - - // partial specialization of numeric::fdiv<> for std::valarray. - template - struct fdiv - : mpl::if_< - are_integral - , divides - , divides - >::type - {}; - - // promote - template - struct promote - { - typedef From argument_type; - typedef To result_type; - - To operator ()(From &arr) const - { - typename remove_const::type res(arr.size()); - for(std::size_t i = 0, size = arr.size(); i != size; ++i) - { - res[i] = numeric::promote(arr[i]); - } - return res; - } - }; - - template - struct promote - { - typedef ToFrom argument_type; - typedef ToFrom result_type; - - ToFrom &operator ()(ToFrom &tofrom) const - { - return tofrom; - } - }; - - // for "promoting" a std::valarray to a bool, useful for - // comparing 2 valarrays for equality: - // if(numeric::promote(a == b)) - template - struct promote - { - typedef From argument_type; - typedef bool result_type; - - bool operator ()(From &arr) const - { - BOOST_MPL_ASSERT((is_same)); - for(std::size_t i = 0, size = arr.size(); i != size; ++i) - { - if(!arr[i]) - { - return false; - } - } - return true; - } - }; - - template - struct promote - : promote - {}; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_min - template - struct as_min - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(numeric::as_min(arr[0]), arr.size()); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_max - template - struct as_max - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(numeric::as_max(arr[0]), arr.size()); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_zero - template - struct as_zero - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(numeric::as_zero(arr[0]), arr.size()); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_one - template - struct as_one - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(numeric::as_one(arr[0]), arr.size()); - } - }; - - } // namespace functional - -}} // namespace boost::numeric - -#endif - diff --git a/boost/accumulators/numeric/functional/vector.hpp b/boost/accumulators/numeric/functional/vector.hpp deleted file mode 100644 index 4c2fbd8ada7e5ddd405fbf1ad3941d1a5b5ec30e..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/functional/vector.hpp +++ /dev/null @@ -1,347 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file vector.hpp -/// -// Copyright 2005 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_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 -#define BOOST_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 - -#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED -# error Include this file before boost/accumulators/numeric/functional.hpp -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace numeric -{ - namespace operators - { - namespace acc_detail - { - template - struct make_vector - { - typedef std::vector type; - }; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector / Right where Right is a scalar. - template - typename lazy_enable_if< - is_scalar - , acc_detail::make_vector > - >::type - operator /(std::vector const &left, Right const &right) - { - typedef typename functional::divides::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::divides(left[i], right); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector / vector. - template - std::vector::result_type> - operator /(std::vector const &left, std::vector const &right) - { - typedef typename functional::divides::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::divides(left[i], right[i]); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector * Right where Right is a scalar. - template - typename lazy_enable_if< - is_scalar - , acc_detail::make_vector > - >::type - operator *(std::vector const &left, Right const &right) - { - typedef typename functional::multiplies::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::multiplies(left[i], right); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle Left * vector where Left is a scalar. - template - typename lazy_enable_if< - is_scalar - , acc_detail::make_vector > - >::type - operator *(Left const &left, std::vector const &right) - { - typedef typename functional::multiplies::result_type value_type; - std::vector result(right.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::multiplies(left, right[i]); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector * vector - template - std::vector::result_type> - operator *(std::vector const &left, std::vector const &right) - { - typedef typename functional::multiplies::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::multiplies(left[i], right[i]); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector + vector - template - std::vector::result_type> - operator +(std::vector const &left, std::vector const &right) - { - typedef typename functional::plus::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::plus(left[i], right[i]); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector - vector - template - std::vector::result_type> - operator -(std::vector const &left, std::vector const &right) - { - typedef typename functional::minus::result_type value_type; - std::vector result(left.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::minus(left[i], right[i]); - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle vector += vector - template - std::vector & - operator +=(std::vector &left, std::vector const &right) - { - BOOST_ASSERT(left.size() == right.size()); - for(std::size_t i = 0, size = left.size(); i != size; ++i) - { - numeric::plus_assign(left[i], right[i]); - } - return left; - } - - /////////////////////////////////////////////////////////////////////////////// - // Handle -vector - template - std::vector::result_type> - operator -(std::vector const &arg) - { - typedef typename functional::unary_minus::result_type value_type; - std::vector result(arg.size()); - for(std::size_t i = 0, size = result.size(); i != size; ++i) - { - result[i] = numeric::unary_minus(arg[i]); - } - return result; - } - } - - namespace functional - { - struct std_vector_tag; - - template - struct tag > - { - typedef std_vector_tag type; - }; - - /////////////////////////////////////////////////////////////////////////////// - // element-wise min of std::vector - template - struct min_assign - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - BOOST_ASSERT(left.size() == right.size()); - for(std::size_t i = 0, size = left.size(); i != size; ++i) - { - if(numeric::less(right[i], left[i])) - { - left[i] = right[i]; - } - } - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // element-wise max of std::vector - template - struct max_assign - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef void result_type; - - void operator ()(Left &left, Right &right) const - { - BOOST_ASSERT(left.size() == right.size()); - for(std::size_t i = 0, size = left.size(); i != size; ++i) - { - if(numeric::greater(right[i], left[i])) - { - left[i] = right[i]; - } - } - } - }; - - // partial specialization for std::vector. - template - struct fdiv - : mpl::if_< - are_integral - , divides - , divides - >::type - {}; - - // promote - template - struct promote - { - typedef From argument_type; - typedef To result_type; - - To operator ()(From &arr) const - { - typename remove_const::type res(arr.size()); - for(std::size_t i = 0, size = arr.size(); i != size; ++i) - { - res[i] = numeric::promote(arr[i]); - } - return res; - } - }; - - template - struct promote - { - typedef ToFrom argument_type; - typedef ToFrom result_type; - - ToFrom &operator ()(ToFrom &tofrom) const - { - return tofrom; - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_min - template - struct as_min - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(arr.size(), numeric::as_min(arr[0])); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_max - template - struct as_max - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(arr.size(), numeric::as_max(arr[0])); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_zero - template - struct as_zero - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(arr.size(), numeric::as_zero(arr[0])); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // functional::as_one - template - struct as_one - { - typedef T argument_type; - typedef typename remove_const::type result_type; - - typename remove_const::type operator ()(T &arr) const - { - return 0 == arr.size() - ? T() - : T(arr.size(), numeric::as_one(arr[0])); - } - }; - - } // namespace functional - -}} // namespace boost::numeric - -#endif - diff --git a/boost/accumulators/numeric/functional_fwd.hpp b/boost/accumulators/numeric/functional_fwd.hpp deleted file mode 100644 index 501f654b298100c0cca2d0520fea954b9beb599c..0000000000000000000000000000000000000000 --- a/boost/accumulators/numeric/functional_fwd.hpp +++ /dev/null @@ -1,221 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file functional_fwd.hpp -/// -// Copyright 2005 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_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 -#define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 - -#include -#include -#include -#include -#include - -namespace boost { namespace numeric -{ - // For using directives -- this namespace may be re-opened elsewhere - namespace operators - {} - - namespace op - { - using mpl::_; - using mpl::_1; - using mpl::_2; - } - - namespace functional - { - using namespace operators; - - template - struct tag - { - typedef void type; - }; - - template - struct tag - : tag - {}; - - template - struct tag - : tag - {}; - - template - struct tag - : tag - {}; - - template - struct static_; - - template - struct are_integral; - } - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op) \ - namespace functional \ - { \ - template \ - struct Name ## _base; \ - template::type> \ - struct Name; \ - } \ - namespace op \ - { \ - struct Name; \ - } \ - namespace \ - { \ - extern op::Name const &Name; \ - } - - /// INTERNAL ONLY - /// -#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name) \ - namespace functional \ - { \ - template \ - struct result_of_ ## Name; \ - template \ - struct Name ## _base; \ - template< \ - typename Left \ - , typename Right \ - , typename LeftTag = typename tag::type \ - , typename RightTag = typename tag::type \ - > \ - struct Name; \ - } \ - namespace op \ - { \ - struct Name; \ - } \ - namespace \ - { \ - extern op::Name const &Name; \ - } - - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to) - - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign) - - BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~) - BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !) - -#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP -#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP - - - namespace functional - { - template - struct promote_base; - template - struct min_assign_base; - template - struct max_assign_base; - template - struct fdiv_base; - template - struct as_min_base; - template - struct as_max_base; - template - struct as_zero_base; - template - struct as_one_base; - - template::type, typename FromTag = typename tag::type> - struct promote; - template::type, typename RightTag = typename tag::type> - struct min_assign; - template::type, typename RightTag = typename tag::type> - struct max_assign; - template::type, typename RightTag = typename tag::type> - struct fdiv; - template::type> - struct as_min; - template::type> - struct as_max; - template::type> - struct as_zero; - template::type> - struct as_one; - } - - namespace op - { - template - struct promote; - struct min_assign; - struct max_assign; - struct fdiv; - struct as_min; - struct as_max; - struct as_zero; - struct as_one; - } - - namespace - { - extern op::min_assign const &min_assign; - extern op::max_assign const &max_assign; - extern op::fdiv const &fdiv; - extern op::as_min const &as_min; - extern op::as_max const &as_max; - extern op::as_zero const &as_zero; - extern op::as_one const &as_one; - } - - template - typename lazy_disable_if, mpl::if_, To &, To> >::type - promote(From &from); - - template - typename mpl::if_, To const &, To const>::type - promote(From const &from); - - template - struct default_; - - template - struct one; - - template - struct zero; - - template - struct one_or_default; - - template - struct zero_or_default; - -}} // namespace boost::numeric - -#endif diff --git a/boost/accumulators/statistics.hpp b/boost/accumulators/statistics.hpp deleted file mode 100644 index 01786079a8f647042bc49a7292fe853e2c9d7bed..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file statistics.hpp -/// Includes all of the Statistical Accumulators Library -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_HPP_EAN_01_17_2006 -#define BOOST_ACCUMULATORS_STATISTICS_HPP_EAN_01_17_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/boost/accumulators/statistics/count.hpp b/boost/accumulators/statistics/count.hpp deleted file mode 100644 index 6d30b41e263d6a3c47dbeddafb9a6e3533e36ebe..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/count.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// count.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_COUNT_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_COUNT_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - /////////////////////////////////////////////////////////////////////////////// - // count_impl - struct count_impl - : accumulator_base - { - // for boost::result_of - typedef std::size_t result_type; - - count_impl(dont_care) - : cnt(0) - { - } - - void operator ()(dont_care) - { - ++this->cnt; - } - - result_type result(dont_care) const - { - return this->cnt; - } - - private: - std::size_t cnt; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::count -// -namespace tag -{ - struct count - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef mpl::always impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::count -// -namespace extract -{ - extractor const count = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(count) -} - -using extract::count; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/covariance.hpp b/boost/accumulators/statistics/covariance.hpp deleted file mode 100644 index b3030b96765380418e2a46b86b03d2f24d6366cd..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/covariance.hpp +++ /dev/null @@ -1,212 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// covariance.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_COVARIANCE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_COVARIANCE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace numeric -{ - namespace functional - { - struct std_vector_tag; - - /////////////////////////////////////////////////////////////////////////////// - // functional::outer_product - template - struct outer_product_base - : functional::multiplies - {}; - - template::type, typename RightTag = typename tag::type> - struct outer_product - : outer_product_base - {}; - - template - struct outer_product - { - typedef Left first_argument_type; - typedef Right second_argument_type; - typedef - ublas::matrix< - typename functional::multiplies< - typename Left::value_type - , typename Right::value_type - >::result_type - > - result_type; - - result_type - operator ()(Left & left, Right & right) const - { - std::size_t left_size = left.size(); - std::size_t right_size = right.size(); - result_type result(left_size, right_size); - for (std::size_t i = 0; i < left_size; ++i) - for (std::size_t j = 0; j < right_size; ++j) - result(i,j) = numeric::multiplies(left[i], right[j]); - return result; - } - }; - } - - namespace op - { - struct outer_product - : boost::detail::function2, functional::tag<_2> > > - {}; - } - - namespace - { - op::outer_product const &outer_product = boost::detail::pod_singleton::instance; - } - -}} - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // covariance_impl - // - /** - @brief Covariance Estimator - - An iterative Monte Carlo estimator for the covariance \f$\mathrm{Cov}(X,X')\f$, where \f$X\f$ is a sample - and \f$X'\f$ is a variate, is given by: - - \f[ - \hat{c}_n = \frac{n-1}{n} \hat{c}_{n-1} + \frac{1}{n-1}(X_n - \hat{\mu}_n)(X_n' - \hat{\mu}_n'),\quad n\ge2,\quad\hat{c}_1 = 0, - \f] - - \f$\hat{\mu}_n\f$ and \f$\hat{\mu}_n'\f$ being the means of the samples and variates. - */ - template - struct covariance_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type sample_type; - typedef typename numeric::functional::fdiv::result_type variate_type; - // for boost::result_of - typedef typename numeric::functional::outer_product::result_type result_type; - - template - covariance_impl(Args const &args) - : cov_( - numeric::outer_product( - numeric::fdiv(args[sample | Sample()], (std::size_t)1) - , numeric::fdiv(args[parameter::keyword::get() | VariateType()], (std::size_t)1) - ) - ) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - if (cnt > 1) - { - extractor > const some_mean_of_variates = {}; - - this->cov_ = this->cov_*(cnt-1.)/cnt - + numeric::outer_product( - some_mean_of_variates(args) - args[parameter::keyword::get()] - , mean(args) - args[sample] - ) / (cnt-1.); - } - } - - result_type result(dont_care) const - { - return this->cov_; - } - - private: - result_type cov_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::covariance -// -namespace tag -{ - template - struct covariance - : depends_on > - { - typedef accumulators::impl::covariance_impl impl; - }; - - struct abstract_covariance - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::covariance -// -namespace extract -{ - extractor const covariance = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariance) -} - -using extract::covariance; - -template -struct feature_of > - : feature_of -{ -}; - -// So that covariance can be automatically substituted with -// weighted_covariance when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_covariance type; -}; - -template -struct feature_of > - : feature_of > -{}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/density.hpp b/boost/accumulators/statistics/density.hpp deleted file mode 100644 index 88ca17df79d8a1df6cfacb720ff4f9fba52eccef..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/density.hpp +++ /dev/null @@ -1,250 +0,0 @@ - -/////////////////////////////////////////////////////////////////////////////// -// density.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_DENSITY_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_DENSITY_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// cache_size and num_bins named parameters -// -BOOST_PARAMETER_NESTED_KEYWORD(tag, density_cache_size, cache_size) -BOOST_PARAMETER_NESTED_KEYWORD(tag, density_num_bins, num_bins) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_cache_size) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_num_bins) - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // density_impl - // density histogram - /** - @brief Histogram density estimator - - The histogram density estimator returns a histogram of the sample distribution. The positions and sizes of the bins - are determined using a specifiable number of cached samples (cache_size). The range between the minimum and the - maximum of the cached samples is subdivided into a specifiable number of bins (num_bins) of same size. Additionally, - an under- and an overflow bin is added to capture future under- and overflow samples. Once the bins are determined, - the cached samples and all subsequent samples are added to the correct bins. At the end, a range of std::pair is - return, where each pair contains the position of the bin (lower bound) and the samples count (normalized with the - total number of samples). - - @param density_cache_size Number of first samples used to determine min and max. - @param density_num_bins Number of bins (two additional bins collect under- and overflow samples). - */ - template - struct density_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range result_type; - - template - density_impl(Args const &args) - : cache_size(args[density_cache_size]) - , cache(cache_size) - , num_bins(args[density_num_bins]) - , samples_in_bin(num_bins + 2, 0.) - , bin_positions(num_bins + 2) - , histogram( - num_bins + 2 - , std::make_pair( - numeric::fdiv(args[sample | Sample()],(std::size_t)1) - , numeric::fdiv(args[sample | Sample()],(std::size_t)1) - ) - ) - , is_dirty(true) - { - } - - template - void operator ()(Args const &args) - { - this->is_dirty = true; - - std::size_t cnt = count(args); - - // Fill up cache with cache_size first samples - if (cnt <= this->cache_size) - { - this->cache[cnt - 1] = args[sample]; - } - - // Once cache_size samples have been accumulated, create num_bins bins of same size between - // the minimum and maximum of the cached samples as well as under and overflow bins. - // Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin). - if (cnt == this->cache_size) - { - float_type minimum = numeric::fdiv((min)(args), (std::size_t)1); - float_type maximum = numeric::fdiv((max)(args), (std::size_t)1); - float_type bin_size = numeric::fdiv(maximum - minimum, this->num_bins ); - - // determine bin positions (their lower bounds) - for (std::size_t i = 0; i < this->num_bins + 2; ++i) - { - this->bin_positions[i] = minimum + (i - 1.) * bin_size; - } - - for (typename array_type::const_iterator iter = this->cache.begin(); iter != this->cache.end(); ++iter) - { - if (*iter < this->bin_positions[1]) - { - ++(this->samples_in_bin[0]); - } - else if (*iter >= this->bin_positions[this->num_bins + 1]) - { - ++(this->samples_in_bin[this->num_bins + 1]); - } - else - { - typename array_type::iterator it = std::upper_bound( - this->bin_positions.begin() - , this->bin_positions.end() - , *iter - ); - - std::size_t d = std::distance(this->bin_positions.begin(), it); - ++(this->samples_in_bin[d - 1]); - } - } - } - // Add each subsequent sample to the correct bin - else if (cnt > this->cache_size) - { - if (args[sample] < this->bin_positions[1]) - { - ++(this->samples_in_bin[0]); - } - else if (args[sample] >= this->bin_positions[this->num_bins + 1]) - { - ++(this->samples_in_bin[this->num_bins + 1]); - } - else - { - typename array_type::iterator it = std::upper_bound( - this->bin_positions.begin() - , this->bin_positions.end() - , args[sample] - ); - - std::size_t d = std::distance(this->bin_positions.begin(), it); - ++(this->samples_in_bin[d - 1]); - } - } - } - - /** - @pre The number of samples must meet or exceed the cache size - */ - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - // creates a vector of std::pair where each pair i holds - // the values bin_positions[i] (x-axis of histogram) and - // samples_in_bin[i] / cnt (y-axis of histogram). - - for (std::size_t i = 0; i < this->num_bins + 2; ++i) - { - this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::fdiv(this->samples_in_bin[i], count(args))); - } - } - // returns a range of pairs - return make_iterator_range(this->histogram); - } - - private: - std::size_t cache_size; // number of cached samples - array_type cache; // cache to store the first cache_size samples - std::size_t num_bins; // number of bins - array_type samples_in_bin; // number of samples in each bin - array_type bin_positions; // lower bounds of bins - mutable histogram_type histogram; // histogram - mutable bool is_dirty; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::density -// -namespace tag -{ - struct density - : depends_on - , density_cache_size - , density_num_bins - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::density_impl impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::density::cache_size named parameter - /// tag::density::num_bins named parameter - static boost::parameter::keyword const cache_size; - static boost::parameter::keyword const num_bins; - #endif - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::density -// -namespace extract -{ - extractor const density = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(density) -} - -using extract::density; - -// So that density can be automatically substituted -// with weighted_density when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_density type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/error_of.hpp b/boost/accumulators/statistics/error_of.hpp deleted file mode 100644 index a29da02f579c5bf337a76d9646543b8259dd7b37..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/error_of.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// error_of.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 - -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /// INTERNAL ONLY - /// - template - struct this_feature_has_no_error_calculation - : mpl::false_ - { - }; - - /////////////////////////////////////////////////////////////////////////////// - // error_of_impl - /// INTERNAL ONLY - /// - template - struct error_of_impl - : accumulator_base - { - // TODO: specialize this on the specific features that have errors we're - // interested in. - BOOST_MPL_ASSERT((this_feature_has_no_error_calculation)); - - // for boost::result_of - typedef int result_type; - - error_of_impl(dont_care) - { - } - - result_type result(dont_care) const - { - return 0; - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::error_of -// -namespace tag -{ - template - struct error_of - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::error_of_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::error_of -// -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, error_of, (typename)) -} - -using extract::error_of; - -// make tag::error_of work -template -struct as_feature > -{ - typedef tag::error_of::type> type; -}; - -// make error_of work with non-void weights (should become -// error_of -template -struct as_weighted_feature > -{ - typedef tag::error_of::type> type; -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/error_of_mean.hpp b/boost/accumulators/statistics/error_of_mean.hpp deleted file mode 100644 index 7cd923d5f4a34e82683b82132dcdf6d22baae3cc..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/error_of_mean.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// error_of.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006 -#define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // error_of_mean_impl - template - struct error_of_mean_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - error_of_mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - using namespace std; - extractor const variance = {}; - return sqrt(numeric::fdiv(variance(args), count(args) - 1)); - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::error_of -// -namespace tag -{ - template<> - struct error_of - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::error_of_mean_impl impl; - }; - - template<> - struct error_of - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::error_of_mean_impl impl; - }; -} - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/extended_p_square.hpp b/boost/accumulators/statistics/extended_p_square.hpp deleted file mode 100644 index e6cc8dc9a118be149343178abac2766d320728cb..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/extended_p_square.hpp +++ /dev/null @@ -1,295 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// extended_p_square.hpp -// -// Copyright 2005 Daniel Egloff. 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_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ -/////////////////////////////////////////////////////////////////////////////// -// probabilities named parameter -// -BOOST_PARAMETER_NESTED_KEYWORD(tag, extended_p_square_probabilities, probabilities) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_probabilities) - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // extended_p_square_impl - // multiple quantile estimation - /** - @brief Multiple quantile estimation with the extended \f$P^2\f$ algorithm - - Extended \f$P^2\f$ algorithm for estimation of several quantiles without storing samples. - Assume that \f$m\f$ quantiles \f$\xi_{p_1}, \ldots, \xi_{p_m}\f$ are to be estimated. - Instead of storing the whole sample cumulative distribution, the algorithm maintains only - \f$m+2\f$ principal markers and \f$m+1\f$ middle markers, whose positions are updated - with each sample and whose heights are adjusted (if necessary) using a piecewise-parablic - formula. The heights of these central markers are the current estimates of the quantiles - and returned as an iterator range. - - For further details, see - - K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49, - Number 4 (October), 1986, p. 159-164. - - The extended \f$ P^2 \f$ algorithm generalizes the \f$ P^2 \f$ algorithm of - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param extended_p_square_probabilities A vector of quantile probabilities. - */ - template - struct extended_p_square_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range< - detail::lvalue_index_iterator< - permutation_iterator< - typename array_type::const_iterator - , detail::times2_iterator - > - > - > result_type; - - template - extended_p_square_impl(Args const &args) - : probabilities( - boost::begin(args[extended_p_square_probabilities]) - , boost::end(args[extended_p_square_probabilities]) - ) - , heights(2 * probabilities.size() + 3) - , actual_positions(heights.size()) - , desired_positions(heights.size()) - , positions_increments(heights.size()) - { - std::size_t num_quantiles = this->probabilities.size(); - std::size_t num_markers = this->heights.size(); - - for(std::size_t i = 0; i < num_markers; ++i) - { - this->actual_positions[i] = i + 1; - } - - this->positions_increments[0] = 0.; - this->positions_increments[num_markers - 1] = 1.; - - for(std::size_t i = 0; i < num_quantiles; ++i) - { - this->positions_increments[2 * i + 2] = probabilities[i]; - } - - for(std::size_t i = 0; i <= num_quantiles; ++i) - { - this->positions_increments[2 * i + 1] = - 0.5 * (this->positions_increments[2 * i] + this->positions_increments[2 * i + 2]); - } - - for(std::size_t i = 0; i < num_markers; ++i) - { - this->desired_positions[i] = 1. + 2. * (num_quantiles + 1.) * this->positions_increments[i]; - } - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - // m+2 principal markers and m+1 middle markers - std::size_t num_markers = 2 * this->probabilities.size() + 3; - - // first accumulate num_markers samples - if(cnt <= num_markers) - { - this->heights[cnt - 1] = args[sample]; - - // complete the initialization of heights by sorting - if(cnt == num_markers) - { - std::sort(this->heights.begin(), this->heights.end()); - } - } - else - { - std::size_t sample_cell = 1; - - // find cell k = sample_cell such that heights[k-1] <= sample < heights[k] - if(args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - sample_cell = 1; - } - else if(args[sample] >= this->heights[num_markers - 1]) - { - this->heights[num_markers - 1] = args[sample]; - sample_cell = num_markers - 1; - } - else - { - typedef typename array_type::iterator iterator; - iterator it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // update actual positions of all markers above sample_cell index - for(std::size_t i = sample_cell; i < num_markers; ++i) - { - ++this->actual_positions[i]; - } - - // update desired positions of all markers - for(std::size_t i = 0; i < num_markers; ++i) - { - this->desired_positions[i] += this->positions_increments[i]; - } - - // adjust heights and actual positions of markers 1 to num_markers-2 if necessary - for(std::size_t i = 1; i <= num_markers - 2; ++i) - { - // offset to desired position - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i+1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i-1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i+1] - this->heights[i]) / dp; - float_type hm = (this->heights[i-1] - this->heights[i]) / dm; - - if((d >= 1 && dp > 1) || (d <= -1 && dm < -1)) - { - short sign_d = static_cast(d / std::abs(d)); - - float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm)*hp - + (dp - sign_d) * hm); - - // try adjusting heights[i] using p-squared formula - if(this->heights[i - 1] < h && h < this->heights[i + 1]) - { - this->heights[i] = h; - } - else - { - // use linear formula - if(d > 0) - { - this->heights[i] += hp; - } - if(d < 0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - result_type result(dont_care) const - { - // for i in [1,probabilities.size()], return heights[i * 2] - detail::times2_iterator idx_begin = detail::make_times2_iterator(1); - detail::times2_iterator idx_end = detail::make_times2_iterator(this->probabilities.size() + 1); - - return result_type( - make_permutation_iterator(this->heights.begin(), idx_begin) - , make_permutation_iterator(this->heights.begin(), idx_end) - ); - } - - private: - array_type probabilities; // the quantile probabilities - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // d_i - array_type positions_increments; // f_i - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::extended_p_square -// -namespace tag -{ - struct extended_p_square - : depends_on - , extended_p_square_probabilities - { - typedef accumulators::impl::extended_p_square_impl impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::extended_p_square::probabilities named parameter - static boost::parameter::keyword const probabilities; - #endif - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::extended_p_square -// -namespace extract -{ - extractor const extended_p_square = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square) -} - -using extract::extended_p_square; - -// So that extended_p_square can be automatically substituted with -// weighted_extended_p_square when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_extended_p_square type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/extended_p_square_quantile.hpp b/boost/accumulators/statistics/extended_p_square_quantile.hpp deleted file mode 100644 index a17843d774747b7203c51c822d7ba34d6042c8ba..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/extended_p_square_quantile.hpp +++ /dev/null @@ -1,320 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// extended_p_square_quantile.hpp -// -// Copyright 2005 Daniel Egloff. 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_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // extended_p_square_quantile_impl - // single quantile estimation - /** - @brief Quantile estimation using the extended \f$P^2\f$ algorithm for weighted and unweighted samples - - Uses the quantile estimates calculated by the extended \f$P^2\f$ algorithm to compute - intermediate quantile estimates by means of quadratic interpolation. - - @param quantile_probability The probability of the quantile to be estimated. - */ - template // Impl1: weighted/unweighted // Impl2: linear/quadratic - struct extended_p_square_quantile_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector array_type; - typedef iterator_range< - detail::lvalue_index_iterator< - permutation_iterator< - typename array_type::const_iterator - , detail::times2_iterator - > - > - > range_type; - // for boost::result_of - typedef float_type result_type; - - template - extended_p_square_quantile_impl(Args const &args) - : probabilities( - boost::begin(args[extended_p_square_probabilities]) - , boost::end(args[extended_p_square_probabilities]) - ) - { - } - - template - result_type result(Args const &args) const - { - typedef - typename mpl::if_< - is_same - , tag::weighted_extended_p_square - , tag::extended_p_square - >::type - extended_p_square_tag; - - extractor const some_extended_p_square = {}; - - array_type heights(some_extended_p_square(args).size()); - std::copy(some_extended_p_square(args).begin(), some_extended_p_square(args).end(), heights.begin()); - - this->probability = args[quantile_probability]; - - typename array_type::const_iterator iter_probs = std::lower_bound(this->probabilities.begin(), this->probabilities.end(), this->probability); - std::size_t dist = std::distance(this->probabilities.begin(), iter_probs); - typename array_type::const_iterator iter_heights = heights.begin() + dist; - - // If this->probability is not in a valid range return NaN or throw exception - if (this->probability < *this->probabilities.begin() || this->probability > *(this->probabilities.end() - 1)) - { - if (std::numeric_limits::has_quiet_NaN) - { - return std::numeric_limits::quiet_NaN(); - } - else - { - std::ostringstream msg; - msg << "probability = " << this->probability << " is not in valid range ("; - msg << *this->probabilities.begin() << ", " << *(this->probabilities.end() - 1) << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return Sample(0); - } - - } - - if (*iter_probs == this->probability) - { - return heights[dist]; - } - else - { - result_type res; - - if (is_same::value) - { - ///////////////////////////////////////////////////////////////////////////////// - // LINEAR INTERPOLATION - // - float_type p1 = *iter_probs; - float_type p0 = *(iter_probs - 1); - float_type h1 = *iter_heights; - float_type h0 = *(iter_heights - 1); - - float_type a = numeric::fdiv(h1 - h0, p1 - p0); - float_type b = h1 - p1 * a; - - res = a * this->probability + b; - } - else - { - ///////////////////////////////////////////////////////////////////////////////// - // QUADRATIC INTERPOLATION - // - float_type p0, p1, p2; - float_type h0, h1, h2; - - if ( (dist == 1 || *iter_probs - this->probability <= this->probability - *(iter_probs - 1) ) && dist != this->probabilities.size() - 1 ) - { - p0 = *(iter_probs - 1); - p1 = *iter_probs; - p2 = *(iter_probs + 1); - h0 = *(iter_heights - 1); - h1 = *iter_heights; - h2 = *(iter_heights + 1); - } - else - { - p0 = *(iter_probs - 2); - p1 = *(iter_probs - 1); - p2 = *iter_probs; - h0 = *(iter_heights - 2); - h1 = *(iter_heights - 1); - h2 = *iter_heights; - } - - float_type hp21 = numeric::fdiv(h2 - h1, p2 - p1); - float_type hp10 = numeric::fdiv(h1 - h0, p1 - p0); - float_type p21 = numeric::fdiv(p2 * p2 - p1 * p1, p2 - p1); - float_type p10 = numeric::fdiv(p1 * p1 - p0 * p0, p1 - p0); - - float_type a = numeric::fdiv(hp21 - hp10, p21 - p10); - float_type b = hp21 - a * p21; - float_type c = h2 - a * p2 * p2 - b * p2; - - res = a * this->probability * this-> probability + b * this->probability + c; - } - - return res; - } - - } - private: - - array_type probabilities; - mutable float_type probability; - - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::extended_p_square_quantile -// -namespace tag -{ - struct extended_p_square_quantile - : depends_on - { - typedef accumulators::impl::extended_p_square_quantile_impl impl; - }; - struct extended_p_square_quantile_quadratic - : depends_on - { - typedef accumulators::impl::extended_p_square_quantile_impl impl; - }; - struct weighted_extended_p_square_quantile - : depends_on - { - typedef accumulators::impl::extended_p_square_quantile_impl impl; - }; - struct weighted_extended_p_square_quantile_quadratic - : depends_on - { - typedef accumulators::impl::extended_p_square_quantile_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::extended_p_square_quantile -// extract::weighted_extended_p_square_quantile -// -namespace extract -{ - extractor const extended_p_square_quantile = {}; - extractor const extended_p_square_quantile_quadratic = {}; - extractor const weighted_extended_p_square_quantile = {}; - extractor const weighted_extended_p_square_quantile_quadratic = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile_quadratic) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile_quadratic) -} - -using extract::extended_p_square_quantile; -using extract::extended_p_square_quantile_quadratic; -using extract::weighted_extended_p_square_quantile; -using extract::weighted_extended_p_square_quantile_quadratic; - -// extended_p_square_quantile(linear) -> extended_p_square_quantile -template<> -struct as_feature -{ - typedef tag::extended_p_square_quantile type; -}; - -// extended_p_square_quantile(quadratic) -> extended_p_square_quantile_quadratic -template<> -struct as_feature -{ - typedef tag::extended_p_square_quantile_quadratic type; -}; - -// weighted_extended_p_square_quantile(linear) -> weighted_extended_p_square_quantile -template<> -struct as_feature -{ - typedef tag::weighted_extended_p_square_quantile type; -}; - -// weighted_extended_p_square_quantile(quadratic) -> weighted_extended_p_square_quantile_quadratic -template<> -struct as_feature -{ - typedef tag::weighted_extended_p_square_quantile_quadratic type; -}; - -// for the purposes of feature-based dependency resolution, -// extended_p_square_quantile and weighted_extended_p_square_quantile -// provide the same feature as quantile -template<> -struct feature_of - : feature_of -{ -}; -template<> -struct feature_of - : feature_of -{ -}; -// So that extended_p_square_quantile can be automatically substituted with -// weighted_extended_p_square_quantile when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_extended_p_square_quantile type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -// So that extended_p_square_quantile_quadratic can be automatically substituted with -// weighted_extended_p_square_quantile_quadratic when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_extended_p_square_quantile_quadratic type; -}; -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/kurtosis.hpp b/boost/accumulators/statistics/kurtosis.hpp deleted file mode 100644 index 76c93d3850536c78bde5076dc60f7af8c6eb2846..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/kurtosis.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// kurtosis.hpp -// -// Copyright 2006 Olivier Gygi, Daniel Egloff. 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_ACCUMULATORS_STATISTICS_KURTOSIS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_KURTOSIS_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // kurtosis_impl - /** - @brief Kurtosis estimation - - The kurtosis of a sample distribution is defined as the ratio of the 4th central moment and the square of the 2nd central - moment (the variance) of the samples, minus 3. The term \f$ -3 \f$ is added in order to ensure that the normal distribution - has zero kurtosis. The kurtosis can also be expressed by the simple moments: - - \f[ - \hat{g}_2 = - \frac - {\widehat{m}_n^{(4)}-4\widehat{m}_n^{(3)}\hat{\mu}_n+6\widehat{m}_n^{(2)}\hat{\mu}_n^2-3\hat{\mu}_n^4} - {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^2} - 3, - \f] - - where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the - \f$ n \f$ samples. - */ - template - struct kurtosis_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - kurtosis_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - return numeric::fdiv( - accumulators::moment<4>(args) - - 4. * accumulators::moment<3>(args) * mean(args) - + 6. * accumulators::moment<2>(args) * mean(args) * mean(args) - - 3. * mean(args) * mean(args) * mean(args) * mean(args) - , ( accumulators::moment<2>(args) - mean(args) * mean(args) ) - * ( accumulators::moment<2>(args) - mean(args) * mean(args) ) - ) - 3.; - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::kurtosis -// -namespace tag -{ - struct kurtosis - : depends_on, moment<3>, moment<4> > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::kurtosis_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::kurtosis -// -namespace extract -{ - extractor const kurtosis = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(kurtosis) -} - -using extract::kurtosis; - -// So that kurtosis can be automatically substituted with -// weighted_kurtosis when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_kurtosis type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/max.hpp b/boost/accumulators/statistics/max.hpp deleted file mode 100644 index 820f6593f0d122ac47688c559e4b5a4d455fa6b6..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/max.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// max.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // max_impl - template - struct max_impl - : accumulator_base - { - // for boost::result_of - typedef Sample result_type; - - template - max_impl(Args const &args) - : max_(numeric::as_min(args[sample | Sample()])) - { - } - - template - void operator ()(Args const &args) - { - numeric::max_assign(this->max_, args[sample]); - } - - result_type result(dont_care) const - { - return this->max_; - } - - private: - Sample max_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::max -// -namespace tag -{ - struct max - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::max_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::max -// -namespace extract -{ - extractor const max = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(max) -} - -using extract::max; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/mean.hpp b/boost/accumulators/statistics/mean.hpp deleted file mode 100644 index 47888371843adae3474b97b6ac8b72185ea27971..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/mean.hpp +++ /dev/null @@ -1,298 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// mean.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_MEAN_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_MEAN_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // mean_impl - // lazy, by default - template - struct mean_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - extractor sum; - return numeric::fdiv(sum(args), count(args)); - } - }; - - template - struct immediate_mean_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - immediate_mean_impl(Args const &args) - : mean(numeric::fdiv(args[sample | Sample()], numeric::one::value)) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - this->mean = numeric::fdiv( - (this->mean * (cnt - 1)) + args[parameter::keyword::get()] - , cnt - ); - } - - result_type result(dont_care) const - { - return this->mean; - } - - private: - result_type mean; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::mean -// tag::immediate_mean -// tag::mean_of_weights -// tag::immediate_mean_of_weights -// tag::mean_of_variates -// tag::immediate_mean_of_variates -// -namespace tag -{ - struct mean - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::mean_impl impl; - }; - struct immediate_mean - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_mean_impl impl; - }; - struct mean_of_weights - : depends_on - { - typedef mpl::true_ is_weight_accumulator; - /// INTERNAL ONLY - /// - typedef accumulators::impl::mean_impl impl; - }; - struct immediate_mean_of_weights - : depends_on - { - typedef mpl::true_ is_weight_accumulator; - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_mean_impl impl; - }; - template - struct mean_of_variates - : depends_on > - { - /// INTERNAL ONLY - /// - typedef mpl::always > > impl; - }; - template - struct immediate_mean_of_variates - : depends_on - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::mean -// extract::mean_of_weights -// extract::mean_of_variates -// -namespace extract -{ - extractor const mean = {}; - extractor const mean_of_weights = {}; - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, mean_of_variates, (typename)(typename)) - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean_of_weights) -} - -using extract::mean; -using extract::mean_of_weights; -using extract::mean_of_variates; - -// mean(lazy) -> mean -template<> -struct as_feature -{ - typedef tag::mean type; -}; - -// mean(immediate) -> immediate_mean -template<> -struct as_feature -{ - typedef tag::immediate_mean type; -}; - -// mean_of_weights(lazy) -> mean_of_weights -template<> -struct as_feature -{ - typedef tag::mean_of_weights type; -}; - -// mean_of_weights(immediate) -> immediate_mean_of_weights -template<> -struct as_feature -{ - typedef tag::immediate_mean_of_weights type; -}; - -// mean_of_variates(lazy) -> mean_of_variates -template -struct as_feature(lazy)> -{ - typedef tag::mean_of_variates type; -}; - -// mean_of_variates(immediate) -> immediate_mean_of_variates -template -struct as_feature(immediate)> -{ - typedef tag::immediate_mean_of_variates type; -}; - -// for the purposes of feature-based dependency resolution, -// immediate_mean provides the same feature as mean -template<> -struct feature_of - : feature_of -{ -}; - -// for the purposes of feature-based dependency resolution, -// immediate_mean provides the same feature as mean -template<> -struct feature_of - : feature_of -{ -}; - -// for the purposes of feature-based dependency resolution, -// immediate_mean provides the same feature as mean -template -struct feature_of > - : feature_of > -{ -}; - -// So that mean can be automatically substituted with -// weighted_mean when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_mean type; -}; - -template<> -struct feature_of - : feature_of -{}; - -// So that immediate_mean can be automatically substituted with -// immediate_weighted_mean when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::immediate_weighted_mean type; -}; - -template<> -struct feature_of - : feature_of -{}; - -// So that mean_of_weights<> can be automatically substituted with -// weighted_mean_of_variates<> when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_mean_of_variates type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -// So that immediate_mean_of_weights<> can be automatically substituted with -// immediate_weighted_mean_of_variates<> when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::immediate_weighted_mean_of_variates type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -//////////////////////////////////////////////////////////////////////////// -//// droppable_accumulator -//// need to specialize droppable lazy mean to cache the result at the -//// point the accumulator is dropped. -///// INTERNAL ONLY -///// -//template -//struct droppable_accumulator > -// : droppable_accumulator_base< -// with_cached_result > -// > -//{ -// template -// droppable_accumulator(Args const &args) -// : droppable_accumulator::base(args) -// { -// } -//}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/median.hpp b/boost/accumulators/statistics/median.hpp deleted file mode 100644 index d361c6dda4363c5539345322aa09594c2a2fbe0c..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/median.hpp +++ /dev/null @@ -1,301 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// median.hpp -// -// Copyright 2006 Eric Niebler, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_MEDIAN_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_MEDIAN_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // median_impl - // - /** - @brief Median estimation based on the \f$P^2\f$ quantile estimator - - The \f$P^2\f$ algorithm is invoked with a quantile probability of 0.5. - */ - template - struct median_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - median_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - return p_square_quantile_for_median(args); - } - }; - /////////////////////////////////////////////////////////////////////////////// - // with_density_median_impl - // - /** - @brief Median estimation based on the density estimator - - The algorithm determines the bin in which the \f$0.5*cnt\f$-th sample lies, \f$cnt\f$ being - the total number of samples. It returns the approximate horizontal position of this sample, - based on a linear interpolation inside the bin. - */ - template - struct with_density_median_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef iterator_range range_type; - // for boost::result_of - typedef float_type result_type; - - template - with_density_median_impl(Args const &args) - : sum(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , is_dirty(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty = true; - } - - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - std::size_t cnt = count(args); - range_type histogram = density(args); - typename range_type::iterator it = histogram.begin(); - while (this->sum < 0.5 * cnt) - { - this->sum += it->second * cnt; - ++it; - } - --it; - float_type over = numeric::fdiv(this->sum - 0.5 * cnt, it->second * cnt); - this->median = it->first * over + (it + 1)->first * (1. - over); - } - - return this->median; - } - - private: - mutable float_type sum; - mutable bool is_dirty; - mutable float_type median; - }; - - /////////////////////////////////////////////////////////////////////////////// - // with_p_square_cumulative_distribution_median_impl - // - /** - @brief Median estimation based on the \f$P^2\f$ cumulative distribution estimator - - The algorithm determines the first (leftmost) bin with a height exceeding 0.5. It - returns the approximate horizontal position of where the cumulative distribution - equals 0.5, based on a linear interpolation inside the bin. - */ - template - struct with_p_square_cumulative_distribution_median_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef iterator_range range_type; - // for boost::result_of - typedef float_type result_type; - - with_p_square_cumulative_distribution_median_impl(dont_care) - : is_dirty(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty = true; - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - range_type histogram = p_square_cumulative_distribution(args); - typename range_type::iterator it = histogram.begin(); - while (it->second < 0.5) - { - ++it; - } - float_type over = numeric::fdiv(it->second - 0.5, it->second - (it - 1)->second); - this->median = it->first * over + (it + 1)->first * ( 1. - over ); - } - - return this->median; - } - private: - - mutable bool is_dirty; - mutable float_type median; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::median -// tag::with_densisty_median -// tag::with_p_square_cumulative_distribution_median -// -namespace tag -{ - struct median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::median_impl impl; - }; - struct with_density_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::with_density_median_impl impl; - }; - struct with_p_square_cumulative_distribution_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::with_p_square_cumulative_distribution_median_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::median -// extract::with_density_median -// extract::with_p_square_cumulative_distribution_median -// -namespace extract -{ - extractor const median = {}; - extractor const with_density_median = {}; - extractor const with_p_square_cumulative_distribution_median = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(median) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_density_median) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_p_square_cumulative_distribution_median) -} - -using extract::median; -using extract::with_density_median; -using extract::with_p_square_cumulative_distribution_median; - -// median(with_p_square_quantile) -> median -template<> -struct as_feature -{ - typedef tag::median type; -}; - -// median(with_density) -> with_density_median -template<> -struct as_feature -{ - typedef tag::with_density_median type; -}; - -// median(with_p_square_cumulative_distribution) -> with_p_square_cumulative_distribution_median -template<> -struct as_feature -{ - typedef tag::with_p_square_cumulative_distribution_median type; -}; - -// for the purposes of feature-based dependency resolution, -// with_density_median and with_p_square_cumulative_distribution_median -// provide the same feature as median -template<> -struct feature_of - : feature_of -{ -}; - -template<> -struct feature_of - : feature_of -{ -}; - -// So that median can be automatically substituted with -// weighted_median when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_median type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -// So that with_density_median can be automatically substituted with -// with_density_weighted_median when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::with_density_weighted_median type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -// So that with_p_square_cumulative_distribution_median can be automatically substituted with -// with_p_square_cumulative_distribution_weighted_median when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::with_p_square_cumulative_distribution_weighted_median type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/min.hpp b/boost/accumulators/statistics/min.hpp deleted file mode 100644 index 83943bdb3c36a2b754f4b15685ea42ecdc5bf0a1..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/min.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// min.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_MIN_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_MIN_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // min_impl - template - struct min_impl - : accumulator_base - { - // for boost::result_of - typedef Sample result_type; - - template - min_impl(Args const &args) - : min_(numeric::as_max(args[sample | Sample()])) - { - } - - template - void operator ()(Args const &args) - { - numeric::min_assign(this->min_, args[sample]); - } - - result_type result(dont_care) const - { - return this->min_; - } - - private: - Sample min_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::min -// -namespace tag -{ - struct min - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::min_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::min -// -namespace extract -{ - extractor const min = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(min) -} - -using extract::min; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/moment.hpp b/boost/accumulators/statistics/moment.hpp deleted file mode 100644 index 3dabd47ecf20c4707ec3515a718b7d1d49c4e42d..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/moment.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// moment.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_MOMENT_HPP_EAN_15_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_MOMENT_HPP_EAN_15_11_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace numeric -{ - /// INTERNAL ONLY - /// - template - T const &pow(T const &x, mpl::int_<1>) - { - return x; - } - - /// INTERNAL ONLY - /// - template - T pow(T const &x, mpl::int_) - { - using namespace operators; - T y = numeric::pow(x, mpl::int_()); - T z = y * y; - return (N % 2) ? (z * x) : z; - } -}} - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // moment_impl - template - struct moment_impl - : accumulator_base // TODO: also depends_on sum of powers - { - BOOST_MPL_ASSERT_RELATION(N::value, >, 0); - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - moment_impl(Args const &args) - : sum(args[sample | Sample()]) - { - } - - template - void operator ()(Args const &args) - { - this->sum += numeric::pow(args[sample], N()); - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv(this->sum, count(args)); - } - - private: - Sample sum; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::moment -// -namespace tag -{ - template - struct moment - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::moment_impl, mpl::_1> impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::moment -// -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, moment, (int)) -} - -using extract::moment; - -// So that moment can be automatically substituted with -// weighted_moment when the weight parameter is non-void -template -struct as_weighted_feature > -{ - typedef tag::weighted_moment type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/p_square_cumul_dist.hpp b/boost/accumulators/statistics/p_square_cumul_dist.hpp deleted file mode 100644 index 50692838c7bf85cc06bb562dedea8096bd0a719e..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/p_square_cumul_dist.hpp +++ /dev/null @@ -1,263 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// p_square_cumulative_distribution.hpp -// -// Copyright 2005 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_P_SQUARE_CUMUL_DIST_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_CUMUL_DIST_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ -/////////////////////////////////////////////////////////////////////////////// -// num_cells named parameter -// -BOOST_PARAMETER_NESTED_KEYWORD(tag, p_square_cumulative_distribution_num_cells, num_cells) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_cumulative_distribution_num_cells) - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // p_square_cumulative_distribution_impl - // cumulative_distribution calculation (as histogram) - /** - @brief Histogram calculation of the cumulative distribution with the \f$P^2\f$ algorithm - - A histogram of the sample cumulative distribution is computed dynamically without storing samples - based on the \f$ P^2 \f$ algorithm. The returned histogram has a specifiable amount (num_cells) - equiprobable (and not equal-sized) cells. - - For further details, see - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param p_square_cumulative_distribution_num_cells. - */ - template - struct p_square_cumulative_distribution_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector array_type; - typedef std::vector > histogram_type; - // for boost::result_of - typedef iterator_range result_type; - - template - p_square_cumulative_distribution_impl(Args const &args) - : num_cells(args[p_square_cumulative_distribution_num_cells]) - , heights(num_cells + 1) - , actual_positions(num_cells + 1) - , desired_positions(num_cells + 1) - , positions_increments(num_cells + 1) - , histogram(num_cells + 1) - , is_dirty(true) - { - std::size_t b = this->num_cells; - - for (std::size_t i = 0; i < b + 1; ++i) - { - this->actual_positions[i] = i + 1.; - this->desired_positions[i] = i + 1.; - this->positions_increments[i] = numeric::fdiv(i, b); - } - } - - template - void operator ()(Args const &args) - { - this->is_dirty = true; - - std::size_t cnt = count(args); - std::size_t sample_cell = 1; // k - std::size_t b = this->num_cells; - - // accumulate num_cells + 1 first samples - if (cnt <= b + 1) - { - this->heights[cnt - 1] = args[sample]; - - // complete the initialization of heights by sorting - if (cnt == b + 1) - { - std::sort(this->heights.begin(), this->heights.end()); - } - } - else - { - // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values - if (args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - sample_cell = 1; - } - else if (this->heights[b] <= args[sample]) - { - this->heights[b] = args[sample]; - sample_cell = b; - } - else - { - typename array_type::iterator it; - it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // increment positions of markers above sample_cell - for (std::size_t i = sample_cell; i < b + 1; ++i) - { - ++this->actual_positions[i]; - } - - // update desired position of markers 2 to num_cells + 1 - // (desired position of first marker is always 1) - for (std::size_t i = 1; i < b + 1; ++i) - { - this->desired_positions[i] += this->positions_increments[i]; - } - - // adjust heights of markers 2 to num_cells if necessary - for (std::size_t i = 1; i < b; ++i) - { - // offset to desire position - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; - float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; - - if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) - { - short sign_d = static_cast(d / std::abs(d)); - - // try adjusting heights[i] using p-squared formula - float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); - - if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) - { - this->heights[i] = h; - } - else - { - // use linear formula - if (d>0) - { - this->heights[i] += hp; - } - if (d<0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - // creates a vector of std::pair where each pair i holds - // the values heights[i] (x-axis of histogram) and - // actual_positions[i] / cnt (y-axis of histogram) - - std::size_t cnt = count(args); - - for (std::size_t i = 0; i < this->histogram.size(); ++i) - { - this->histogram[i] = std::make_pair(this->heights[i], numeric::fdiv(this->actual_positions[i], cnt)); - } - } - //return histogram; - return make_iterator_range(this->histogram); - } - - private: - std::size_t num_cells; // number of cells b - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // n'_i - array_type positions_increments; // dn'_i - mutable histogram_type histogram; // histogram - mutable bool is_dirty; - }; - -} // namespace detail - -/////////////////////////////////////////////////////////////////////////////// -// tag::p_square_cumulative_distribution -// -namespace tag -{ - struct p_square_cumulative_distribution - : depends_on - , p_square_cumulative_distribution_num_cells - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::p_square_cumulative_distribution_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::p_square_cumulative_distribution -// -namespace extract -{ - extractor const p_square_cumulative_distribution = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_cumulative_distribution) -} - -using extract::p_square_cumulative_distribution; - -// So that p_square_cumulative_distribution can be automatically substituted with -// weighted_p_square_cumulative_distribution when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_p_square_cumulative_distribution type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/p_square_cumulative_distribution.hpp b/boost/accumulators/statistics/p_square_cumulative_distribution.hpp deleted file mode 100644 index 5e08b51293e28dd894cb8778dd38987f4d692349..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/p_square_cumulative_distribution.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// p_square_cumulative_distribution.hpp -// -// 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_ACCUMULATORS_STATISTICS_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_03_19_2012 -#define BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_03_19_2012 - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__) -# pragma message ("Warning: This header is deprecated. Please use: boost/accumulators/statistics/p_square_cumul_dist.hpp") -#elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__) -# warning "This header is deprecated. Please use: boost/accumulators/statistics/p_square_cumul_dist.hpp" -#endif - -#include - -#endif diff --git a/boost/accumulators/statistics/p_square_quantile.hpp b/boost/accumulators/statistics/p_square_quantile.hpp deleted file mode 100644 index 636fea7f23515c632af9f7691848f6a19149cb23..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/p_square_quantile.hpp +++ /dev/null @@ -1,257 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// p_square_quantile.hpp -// -// Copyright 2005 Daniel Egloff. 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_ACCUMULATORS_STATISTICS_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // p_square_quantile_impl - // single quantile estimation - /** - @brief Single quantile estimation with the \f$P^2\f$ algorithm - - The \f$P^2\f$ algorithm estimates a quantile dynamically without storing samples. Instead of - storing the whole sample cumulative distribution, only five points (markers) are stored. The heights - of these markers are the minimum and the maximum of the samples and the current estimates of the - \f$(p/2)\f$-, \f$p\f$- and \f$(1+p)/2\f$-quantiles. Their positions are equal to the number - of samples that are smaller or equal to the markers. Each time a new samples is recorded, the - positions of the markers are updated and if necessary their heights are adjusted using a piecewise- - parabolic formula. - - For further details, see - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param quantile_probability - */ - template - struct p_square_quantile_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef array array_type; - // for boost::result_of - typedef float_type result_type; - - template - p_square_quantile_impl(Args const &args) - : p(is_same::value ? 0.5 : args[quantile_probability | 0.5]) - , heights() - , actual_positions() - , desired_positions() - , positions_increments() - { - for(std::size_t i = 0; i < 5; ++i) - { - this->actual_positions[i] = i + 1.; - } - - this->desired_positions[0] = 1.; - this->desired_positions[1] = 1. + 2. * this->p; - this->desired_positions[2] = 1. + 4. * this->p; - this->desired_positions[3] = 3. + 2. * this->p; - this->desired_positions[4] = 5.; - - this->positions_increments[0] = 0.; - this->positions_increments[1] = this->p / 2.; - this->positions_increments[2] = this->p; - this->positions_increments[3] = (1. + this->p) / 2.; - this->positions_increments[4] = 1.; - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - // accumulate 5 first samples - if(cnt <= 5) - { - this->heights[cnt - 1] = args[sample]; - - // complete the initialization of heights by sorting - if(cnt == 5) - { - std::sort(this->heights.begin(), this->heights.end()); - } - } - else - { - std::size_t sample_cell = 1; // k - - // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values - if (args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - sample_cell = 1; - } - else if (this->heights[4] <= args[sample]) - { - this->heights[4] = args[sample]; - sample_cell = 4; - } - else - { - typedef typename array_type::iterator iterator; - iterator it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // update positions of markers above sample_cell - for(std::size_t i = sample_cell; i < 5; ++i) - { - ++this->actual_positions[i]; - } - - // update desired positions of all markers - for(std::size_t i = 0; i < 5; ++i) - { - this->desired_positions[i] += this->positions_increments[i]; - } - - // adjust heights and actual positions of markers 1 to 3 if necessary - for(std::size_t i = 1; i <= 3; ++i) - { - // offset to desired positions - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; - float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; - - if((d >= 1. && dp > 1.) || (d <= -1. && dm < -1.)) - { - short sign_d = static_cast(d / std::abs(d)); - - // try adjusting heights[i] using p-squared formula - float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm) * hp - + (dp - sign_d) * hm); - - if(this->heights[i - 1] < h && h < this->heights[i + 1]) - { - this->heights[i] = h; - } - else - { - // use linear formula - if(d > 0) - { - this->heights[i] += hp; - } - if(d < 0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - result_type result(dont_care) const - { - return this->heights[2]; - } - - private: - float_type p; // the quantile probability p - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // n'_i - array_type positions_increments; // dn'_i - }; - -} // namespace detail - -/////////////////////////////////////////////////////////////////////////////// -// tag::p_square_quantile -// -namespace tag -{ - struct p_square_quantile - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::p_square_quantile_impl impl; - }; - struct p_square_quantile_for_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::p_square_quantile_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::p_square_quantile -// extract::p_square_quantile_for_median -// -namespace extract -{ - extractor const p_square_quantile = {}; - extractor const p_square_quantile_for_median = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_quantile) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_quantile_for_median) -} - -using extract::p_square_quantile; -using extract::p_square_quantile_for_median; - -// So that p_square_quantile can be automatically substituted with -// weighted_p_square_quantile when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_p_square_quantile type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/parameters/quantile_probability.hpp b/boost/accumulators/statistics/parameters/quantile_probability.hpp deleted file mode 100644 index e8792642ec43c520790e3e1417d139baf992a13b..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/parameters/quantile_probability.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// quantile_probability.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_PARAMETERS_QUANTILE_PROBABILITY_HPP_EAN_03_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_PARAMETERS_QUANTILE_PROBABILITY_HPP_EAN_03_11_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -BOOST_PARAMETER_KEYWORD(tag, quantile_probability) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(quantile_probability) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/peaks_over_threshold.hpp b/boost/accumulators/statistics/peaks_over_threshold.hpp deleted file mode 100644 index f04f743a0c6152a4deaf82a9474e1c3bf60054f7..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/peaks_over_threshold.hpp +++ /dev/null @@ -1,405 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// peaks_over_threshold.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include // pow -#include // stringstream -#include // runtime_error -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// threshold_probability and threshold named parameters -// -BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_value, threshold_value) -BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_probability, threshold_probability) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(pot_threshold_value) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(pot_threshold_probability) - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // peaks_over_threshold_impl - // works with an explicit threshold value and does not depend on order statistics - /** - @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation - - According to the theorem of Pickands-Balkema-de Haan, the distribution function \f$F_u(x)\f$ of - the excesses \f$x\f$ over some sufficiently high threshold \f$u\f$ of a distribution function \f$F(x)\f$ - may be approximated by a generalized Pareto distribution - \f[ - G_{\xi,\beta}(x) = - \left\{ - \begin{array}{ll} - \beta^{-1}\left(1+\frac{\xi x}{\beta}\right)^{-1/\xi-1} & \textrm{if }\xi\neq0\\ - \beta^{-1}\exp\left(-\frac{x}{\beta}\right) & \textrm{if }\xi=0, - \end{array} - \right. - \f] - with suitable parameters \f$\xi\f$ and \f$\beta\f$ that can be estimated, e.g., with the method of moments, cf. - Hosking and Wallis (1987), - \f[ - \begin{array}{lll} - \hat{\xi} & = & \frac{1}{2}\left[1-\frac{(\hat{\mu}-u)^2}{\hat{\sigma}^2}\right]\\ - \hat{\beta} & = & \frac{\hat{\mu}-u}{2}\left[\frac{(\hat{\mu}-u)^2}{\hat{\sigma}^2}+1\right], - \end{array} - \f] - \f$\hat{\mu}\f$ and \f$\hat{\sigma}^2\f$ being the empirical mean and variance of the samples over - the threshold \f$u\f$. Equivalently, the distribution function - \f$F_u(x-u)\f$ of the exceedances \f$x-u\f$ can be approximated by - \f$G_{\xi,\beta}(x-u)=G_{\xi,\beta,u}(x)\f$. Since for \f$x\geq u\f$ the distribution function \f$F(x)\f$ - can be written as - \f[ - F(x) = [1 - \P(X \leq u)]F_u(x - u) + \P(X \leq u) - \f] - and the probability \f$\P(X \leq u)\f$ can be approximated by the empirical distribution function - \f$F_n(u)\f$ evaluated at \f$u\f$, an estimator of \f$F(x)\f$ is given by - \f[ - \widehat{F}(x) = [1 - F_n(u)]G_{\xi,\beta,u}(x) + F_n(u). - \f] - It can be shown that \f$\widehat{F}(x)\f$ is a generalized - Pareto distribution \f$G_{\xi,\bar{\beta},\bar{u}}(x)\f$ with \f$\bar{\beta}=\beta[1-F_n(u)]^{\xi}\f$ - and \f$\bar{u}=u-\bar{\beta}\left\{[1-F_n(u)]^{-\xi}-1\right\}/\xi\f$. By inverting \f$\widehat{F}(x)\f$, - one obtains an estimator for the \f$\alpha\f$-quantile, - \f[ - \hat{q}_{\alpha} = \bar{u} + \frac{\bar{\beta}}{\xi}\left[(1-\alpha)^{-\xi}-1\right], - \f] - and similarly an estimator for the (coherent) tail mean, - \f[ - \widehat{CTM}_{\alpha} = \hat{q}_{\alpha} - \frac{\bar{\beta}}{\xi-1}(1-\alpha)^{-\xi}, - \f] - cf. McNeil and Frey (2000). - - Note that in case extreme values of the left tail are fitted, the distribution is mirrored with respect to the - \f$y\f$ axis such that the left tail can be treated as a right tail. The computed fit parameters thus define - the Pareto distribution that fits the mirrored left tail. When quantities like a quantile or a tail mean are - computed using the fit parameters obtained from the mirrored data, the result is mirrored back, yielding the - correct result. - - For further details, see - - J. R. M. Hosking and J. R. Wallis, Parameter and quantile estimation for the generalized Pareto distribution, - Technometrics, Volume 29, 1987, p. 339-349 - - A. J. McNeil and R. Frey, Estimation of Tail-Related Risk Measures for Heteroscedastic Financial Time Series: - an Extreme Value Approach, Journal of Empirical Finance, Volume 7, 2000, p. 271-300 - - @param quantile_probability - @param pot_threshold_value - */ - template - struct peaks_over_threshold_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef boost::tuple result_type; - // for left tail fitting, mirror the extreme values - typedef mpl::int_::value ? -1 : 1> sign; - - template - peaks_over_threshold_impl(Args const &args) - : Nu_(0) - , mu_(sign::value * numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , threshold_(sign::value * args[pot_threshold_value]) - , fit_parameters_(boost::make_tuple(0., 0., 0.)) - , is_dirty_(true) - { - } - - template - void operator ()(Args const &args) - { - this->is_dirty_ = true; - - if (sign::value * args[sample] > this->threshold_) - { - this->mu_ += args[sample]; - this->sigma2_ += args[sample] * args[sample]; - ++this->Nu_; - } - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty_) - { - this->is_dirty_ = false; - - std::size_t cnt = count(args); - - this->mu_ = sign::value * numeric::fdiv(this->mu_, this->Nu_); - this->sigma2_ = numeric::fdiv(this->sigma2_, this->Nu_); - this->sigma2_ -= this->mu_ * this->mu_; - - float_type threshold_probability = numeric::fdiv(cnt - this->Nu_, cnt); - - float_type tmp = numeric::fdiv(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_); - float_type xi_hat = 0.5 * ( 1. - tmp ); - float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp ); - float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat); - float_type u_bar = this->threshold_ - beta_bar * ( std::pow(1. - threshold_probability, -xi_hat) - 1.)/xi_hat; - this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); - } - - return this->fit_parameters_; - } - - private: - std::size_t Nu_; // number of samples larger than threshold - mutable float_type mu_; // mean of Nu_ largest samples - mutable float_type sigma2_; // variance of Nu_ largest samples - float_type threshold_; - mutable result_type fit_parameters_; // boost::tuple that stores fit parameters - mutable bool is_dirty_; - }; - - /////////////////////////////////////////////////////////////////////////////// - // peaks_over_threshold_prob_impl - // determines threshold from a given threshold probability using order statistics - /** - @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation - - @sa peaks_over_threshold_impl - - @param quantile_probability - @param pot_threshold_probability - */ - template - struct peaks_over_threshold_prob_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef boost::tuple result_type; - // for left tail fitting, mirror the extreme values - typedef mpl::int_::value ? -1 : 1> sign; - - template - peaks_over_threshold_prob_impl(Args const &args) - : mu_(sign::value * numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , threshold_probability_(args[pot_threshold_probability]) - , fit_parameters_(boost::make_tuple(0., 0., 0.)) - , is_dirty_(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty_ = true; - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty_) - { - this->is_dirty_ = false; - - std::size_t cnt = count(args); - - // the n'th cached sample provides an approximate threshold value u - std::size_t n = static_cast( - std::ceil( - cnt * ( ( is_same::value ) ? this->threshold_probability_ : 1. - this->threshold_probability_ ) - ) - ); - - // If n is in a valid range, return result, otherwise return NaN or throw exception - if ( n >= static_cast(tail(args).size())) - { - if (std::numeric_limits::has_quiet_NaN) - { - return boost::make_tuple( - std::numeric_limits::quiet_NaN() - , std::numeric_limits::quiet_NaN() - , std::numeric_limits::quiet_NaN() - ); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return boost::make_tuple(Sample(0), Sample(0), Sample(0)); - } - } - else - { - float_type u = *(tail(args).begin() + n - 1) * sign::value; - - // compute mean and variance of samples above/under threshold value u - for (std::size_t i = 0; i < n; ++i) - { - mu_ += *(tail(args).begin() + i); - sigma2_ += *(tail(args).begin() + i) * (*(tail(args).begin() + i)); - } - - this->mu_ = sign::value * numeric::fdiv(this->mu_, n); - this->sigma2_ = numeric::fdiv(this->sigma2_, n); - this->sigma2_ -= this->mu_ * this->mu_; - - if (is_same::value) - this->threshold_probability_ = 1. - this->threshold_probability_; - - float_type tmp = numeric::fdiv(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_); - float_type xi_hat = 0.5 * ( 1. - tmp ); - float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp ); - float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat); - float_type u_bar = u - beta_bar * ( std::pow(1. - threshold_probability_, -xi_hat) - 1.)/xi_hat; - this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); - } - } - - return this->fit_parameters_; - } - - private: - mutable float_type mu_; // mean of samples above threshold u - mutable float_type sigma2_; // variance of samples above threshold u - mutable float_type threshold_probability_; - mutable result_type fit_parameters_; // boost::tuple that stores fit parameters - mutable bool is_dirty_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::peaks_over_threshold -// -namespace tag -{ - template - struct peaks_over_threshold - : depends_on - , pot_threshold_value - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::peaks_over_threshold_impl impl; - }; - - template - struct peaks_over_threshold_prob - : depends_on > - , pot_threshold_probability - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::peaks_over_threshold_prob_impl impl; - }; - - struct abstract_peaks_over_threshold - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::peaks_over_threshold -// -namespace extract -{ - extractor const peaks_over_threshold = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(peaks_over_threshold) -} - -using extract::peaks_over_threshold; - -// peaks_over_threshold(with_threshold_value) -> peaks_over_threshold -template -struct as_feature(with_threshold_value)> -{ - typedef tag::peaks_over_threshold type; -}; - -// peaks_over_threshold(with_threshold_probability) -> peaks_over_threshold_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::peaks_over_threshold_prob type; -}; - -template -struct feature_of > - : feature_of -{ -}; - -template -struct feature_of > - : feature_of -{ -}; - -// So that peaks_over_threshold can be automatically substituted -// with weighted_peaks_over_threshold when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_peaks_over_threshold type; -}; - -template -struct feature_of > - : feature_of > -{}; - -// So that peaks_over_threshold_prob can be automatically substituted -// with weighted_peaks_over_threshold_prob when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_peaks_over_threshold_prob type; -}; - -template -struct feature_of > - : feature_of > -{}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/pot_quantile.hpp b/boost/accumulators/statistics/pot_quantile.hpp deleted file mode 100644 index 470bdbace3e8e91797adecc8b7d77081855bb837..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/pot_quantile.hpp +++ /dev/null @@ -1,205 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// pot_quantile.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // pot_quantile_impl - // - /** - @brief Quantile Estimation based on Peaks over Threshold Method (for both left and right tails) - - Computes an estimate - \f[ - \hat{q}_{\alpha} = \bar{u} + \frac{\bar{\beta}}{\xi}\left[(1-\alpha)^{-\xi}-1\right] - \f] - for a right or left extreme quantile, \f$\bar[u]\f$, \f$\bar{\beta}\f$ and \f$\xi\f$ being the parameters of the - generalized Pareto distribution that approximates the right tail of the distribution (or the mirrored left tail, - in case the left tail is used). In the latter case, the result is mirrored back, yielding the correct result. - */ - template - struct pot_quantile_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef float_type result_type; - - pot_quantile_impl(dont_care) - : sign_((is_same::value) ? -1 : 1) - { - } - - template - result_type result(Args const &args) const - { - typedef - typename mpl::if_< - is_same - , tag::weighted_peaks_over_threshold - , tag::peaks_over_threshold - >::type - peaks_over_threshold_tag; - - extractor const some_peaks_over_threshold = {}; - - float_type u_bar = some_peaks_over_threshold(args).template get<0>(); - float_type beta_bar = some_peaks_over_threshold(args).template get<1>(); - float_type xi_hat = some_peaks_over_threshold(args).template get<2>(); - - return this->sign_ * (u_bar + beta_bar/xi_hat * ( std::pow( - is_same::value ? args[quantile_probability] : 1. - args[quantile_probability] - , -xi_hat - ) - 1.)); - } - - private: - short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::pot_quantile<> -// tag::pot_quantile_prob<> -// tag::weighted_pot_quantile<> -// tag::weighted_pot_quantile_prob<> -// -namespace tag -{ - template - struct pot_quantile - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_quantile_impl impl; - }; - template - struct pot_quantile_prob - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_quantile_impl impl; - }; - template - struct weighted_pot_quantile - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_quantile_impl impl; - }; - template - struct weighted_pot_quantile_prob - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_quantile_impl impl; - }; -} - -// pot_quantile(with_threshold_value) -> pot_quantile -template -struct as_feature(with_threshold_value)> -{ - typedef tag::pot_quantile type; -}; - -// pot_quantile(with_threshold_probability) -> pot_quantile_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::pot_quantile_prob type; -}; - -// weighted_pot_quantile(with_threshold_value) -> weighted_pot_quantile -template -struct as_feature(with_threshold_value)> -{ - typedef tag::weighted_pot_quantile type; -}; - -// weighted_pot_quantile(with_threshold_probability) -> weighted_pot_quantile_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::weighted_pot_quantile_prob type; -}; - -// for the purposes of feature-based dependency resolution, -// pot_quantile and pot_quantile_prob provide -// the same feature as quantile -template -struct feature_of > - : feature_of -{ -}; - -template -struct feature_of > - : feature_of -{ -}; - -// So that pot_quantile can be automatically substituted -// with weighted_pot_quantile when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_pot_quantile type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -// So that pot_quantile_prob can be automatically substituted -// with weighted_pot_quantile_prob when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_pot_quantile_prob type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/pot_tail_mean.hpp b/boost/accumulators/statistics/pot_tail_mean.hpp deleted file mode 100644 index a78043fce290c388c011d99dec3b43674b46d4f6..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/pot_tail_mean.hpp +++ /dev/null @@ -1,211 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// pot_tail_mean.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_POT_TAIL_MEAN_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_POT_TAIL_MEAN_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // pot_tail_mean_impl - // - /** - @brief Estimation of the (coherent) tail mean based on the peaks over threshold method (for both left and right tails) - - Computes an estimate for the (coherent) tail mean - \f[ - \widehat{CTM}_{\alpha} = \hat{q}_{\alpha} - \frac{\bar{\beta}}{\xi-1}(1-\alpha)^{-\xi}, - \f] - where \f$\bar[u]\f$, \f$\bar{\beta}\f$ and \f$\xi\f$ are the parameters of the - generalized Pareto distribution that approximates the right tail of the distribution (or the - mirrored left tail, in case the left tail is used). In the latter case, the result is mirrored - back, yielding the correct result. - */ - template - struct pot_tail_mean_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef float_type result_type; - - pot_tail_mean_impl(dont_care) - : sign_((is_same::value) ? -1 : 1) - { - } - - template - result_type result(Args const &args) const - { - typedef - typename mpl::if_< - is_same - , tag::weighted_peaks_over_threshold - , tag::peaks_over_threshold - >::type - peaks_over_threshold_tag; - - typedef - typename mpl::if_< - is_same - , tag::weighted_pot_quantile - , tag::pot_quantile - >::type - pot_quantile_tag; - - extractor const some_peaks_over_threshold = {}; - extractor const some_pot_quantile = {}; - - float_type beta_bar = some_peaks_over_threshold(args).template get<1>(); - float_type xi_hat = some_peaks_over_threshold(args).template get<2>(); - - return some_pot_quantile(args) - this->sign_ * beta_bar/( xi_hat - 1. ) * std::pow( - is_same::value ? args[quantile_probability] : 1. - args[quantile_probability] - , -xi_hat); - } - private: - short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::pot_tail_mean -// tag::pot_tail_mean_prob -// -namespace tag -{ - template - struct pot_tail_mean - : depends_on, pot_quantile > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_tail_mean_impl impl; - }; - template - struct pot_tail_mean_prob - : depends_on, pot_quantile_prob > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_tail_mean_impl impl; - }; - template - struct weighted_pot_tail_mean - : depends_on, weighted_pot_quantile > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_tail_mean_impl impl; - }; - template - struct weighted_pot_tail_mean_prob - : depends_on, weighted_pot_quantile_prob > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::pot_tail_mean_impl impl; - }; -} - -// pot_tail_mean(with_threshold_value) -> pot_tail_mean -template -struct as_feature(with_threshold_value)> -{ - typedef tag::pot_tail_mean type; -}; - -// pot_tail_mean(with_threshold_probability) -> pot_tail_mean_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::pot_tail_mean_prob type; -}; - -// weighted_pot_tail_mean(with_threshold_value) -> weighted_pot_tail_mean -template -struct as_feature(with_threshold_value)> -{ - typedef tag::weighted_pot_tail_mean type; -}; - -// weighted_pot_tail_mean(with_threshold_probability) -> weighted_pot_tail_mean_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::weighted_pot_tail_mean_prob type; -}; - -// for the purposes of feature-based dependency resolution, -// pot_tail_mean and pot_tail_mean_prob provide -// the same feature as tail_mean -template -struct feature_of > - : feature_of -{ -}; - -template -struct feature_of > - : feature_of -{ -}; - -// So that pot_tail_mean can be automatically substituted -// with weighted_pot_tail_mean when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_pot_tail_mean type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -// So that pot_tail_mean_prob can be automatically substituted -// with weighted_pot_tail_mean_prob when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_pot_tail_mean_prob type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/rolling_count.hpp b/boost/accumulators/statistics/rolling_count.hpp deleted file mode 100644 index 1e34f76354569a28761428fb937492d50004016a..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_count.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_count.hpp -// -// 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_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - /////////////////////////////////////////////////////////////////////////////// - // rolling_count_impl - // returns the count of elements in the rolling window - template - struct rolling_count_impl - : accumulator_base - { - typedef std::size_t result_type; - - rolling_count_impl(dont_care) - {} - - template - result_type result(Args const &args) const - { - return static_cast(rolling_window_plus1(args).size()) - is_rolling_window_plus1_full(args); - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::rolling_count -// -namespace tag -{ - struct rolling_count - : depends_on< rolling_window_plus1 > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::rolling_count_impl< mpl::_1 > impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; - #endif - }; -} // namespace tag - -/////////////////////////////////////////////////////////////////////////////// -// extract::rolling_count -// -namespace extract -{ - extractor const rolling_count = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_count) -} - -using extract::rolling_count; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/rolling_mean.hpp b/boost/accumulators/statistics/rolling_mean.hpp deleted file mode 100644 index 1439da1e2c9e24bcf0da965a91cbcfd1c84dc1e2..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_mean.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_mean.hpp -// Copyright (C) 2008 Eric Niebler. -// Copyright (C) 2012 Pieter Bastiaan Ober (Integricom). -// 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_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - namespace impl - { - /////////////////////////////////////////////////////////////////////////////// - // lazy_rolling_mean_impl - // returns the mean over the rolling window and is calculated only - // when the result is requested - template - struct lazy_rolling_mean_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - lazy_rolling_mean_impl(dont_care) - { - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv(rolling_sum(args), rolling_count(args)); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // immediate_rolling_mean_impl - // The non-lazy version computes the rolling mean recursively when a new - // sample is added - template - struct immediate_rolling_mean_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - immediate_rolling_mean_impl(Args const &args) - : mean_(numeric::fdiv(args[sample | Sample()],numeric::one::value)) - { - } - - template - void operator()(Args const &args) - { - if(is_rolling_window_plus1_full(args)) - { - mean_ += numeric::fdiv(args[sample]-rolling_window_plus1(args).front(),rolling_count(args)); - } - else - { - result_type prev_mean = mean_; - mean_ += numeric::fdiv(args[sample]-prev_mean,rolling_count(args)); - } - } - - template - result_type result(Args const &) const - { - return mean_; - } - - private: - - result_type mean_; - }; - } // namespace impl - - /////////////////////////////////////////////////////////////////////////////// - // tag::lazy_rolling_mean - // tag::immediate_rolling_mean - // tag::rolling_mean - // - namespace tag - { - struct lazy_rolling_mean - : depends_on< rolling_sum, rolling_count > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::lazy_rolling_mean_impl< mpl::_1 > impl; - -#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; -#endif - }; - - struct immediate_rolling_mean - : depends_on< rolling_window_plus1, rolling_count> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_rolling_mean_impl< mpl::_1> impl; - -#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; -#endif - }; - - // make immediate_rolling_mean the default implementation - struct rolling_mean : immediate_rolling_mean {}; - } // namespace tag - - /////////////////////////////////////////////////////////////////////////////// - // extract::lazy_rolling_mean - // extract::immediate_rolling_mean - // extract::rolling_mean - // - namespace extract - { - extractor const lazy_rolling_mean = {}; - extractor const immediate_rolling_mean = {}; - extractor const rolling_mean = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_rolling_mean) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(immediate_rolling_mean) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_mean) - } - - using extract::lazy_rolling_mean; - using extract::immediate_rolling_mean; - using extract::rolling_mean; - - // rolling_mean(lazy) -> lazy_rolling_mean - template<> - struct as_feature - { - typedef tag::lazy_rolling_mean type; - }; - - // rolling_mean(immediate) -> immediate_rolling_mean - template<> - struct as_feature - { - typedef tag::immediate_rolling_mean type; - }; - - // for the purposes of feature-based dependency resolution, - // immediate_rolling_mean provides the same feature as rolling_mean - template<> - struct feature_of - : feature_of - { - }; - - // for the purposes of feature-based dependency resolution, - // lazy_rolling_mean provides the same feature as rolling_mean - template<> - struct feature_of - : feature_of - { - }; -}} // namespace boost::accumulators - -#endif \ No newline at end of file diff --git a/boost/accumulators/statistics/rolling_moment.hpp b/boost/accumulators/statistics/rolling_moment.hpp deleted file mode 100644 index f172cee34f7254b9af1ad6726d846de0bb4160b4..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_moment.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_moment.hpp -// Copyright 2005 Eric Niebler. -// Copyright (C) 2014 Pieter Bastiaan Ober (Integricom). -// 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_ACCUMULATORS_STATISTICS_ROLLING_MOMENT_HPP_EAN_27_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MOMENT_HPP_EAN_27_11_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // rolling_moment_impl - template - struct rolling_moment_impl - : accumulator_base - { - BOOST_MPL_ASSERT_RELATION(N::value, >, 0); - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - rolling_moment_impl(Args const &args) - : sum_(args[sample | Sample()]) - { - } - - template - void operator ()(Args const &args) - { - if(is_rolling_window_plus1_full(args)) - { - this->sum_ -= numeric::pow(rolling_window_plus1(args).front(), N()); - } - this->sum_ += numeric::pow(args[sample], N()); - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv(this->sum_, rolling_count(args)); - } - - private: - result_type sum_; - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::rolling_moment -// -namespace tag -{ - template - struct rolling_moment - : depends_on< rolling_window_plus1, rolling_count> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::rolling_moment_impl, mpl::_1> impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; - #endif - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::rolling_moment -// -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, rolling_moment, (int)) -} - -using extract::rolling_moment; - -// There is no weighted_rolling_moment (yet)... -// -//// So that rolling_moment can be automatically substituted with -//// weighted_rolling_moment when the weight parameter is non-void -//template -//struct as_weighted_feature > -//{ -// typedef tag::weighted_rolling_moment type; -//}; -// -//template -//struct feature_of > -// : feature_of > -//{ -//}; -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/rolling_sum.hpp b/boost/accumulators/statistics/rolling_sum.hpp deleted file mode 100644 index bbb7a8e9a0d891a079387449687989727715e2e6..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_sum.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_sum.hpp -// -// 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_ACCUMULATORS_STATISTICS_ROLLING_SUM_HPP_EAN_26_12_2008 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_SUM_HPP_EAN_26_12_2008 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // rolling_sum_impl - // returns the sum of the samples in the rolling window - template - struct rolling_sum_impl - : accumulator_base - { - typedef Sample result_type; - - template - rolling_sum_impl(Args const &args) - : sum_(args[sample | Sample()]) - {} - - template - void operator ()(Args const &args) - { - if(is_rolling_window_plus1_full(args)) - { - this->sum_ -= rolling_window_plus1(args).front(); - } - this->sum_ += args[sample]; - } - - template - result_type result(Args const & /*args*/) const - { - return this->sum_; - } - - private: - Sample sum_; - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::rolling_sum -// -namespace tag -{ - struct rolling_sum - : depends_on< rolling_window_plus1 > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::rolling_sum_impl< mpl::_1 > impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; - #endif - }; -} // namespace tag - -/////////////////////////////////////////////////////////////////////////////// -// extract::rolling_sum -// -namespace extract -{ - extractor const rolling_sum = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_sum) -} - -using extract::rolling_sum; -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/rolling_variance.hpp b/boost/accumulators/statistics/rolling_variance.hpp deleted file mode 100644 index 33b3922a506748e0011c7714fd40527360ce5bfb..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_variance.hpp +++ /dev/null @@ -1,247 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_variance.hpp -// Copyright (C) 2005 Eric Niebler -// Copyright (C) 2014 Pieter Bastiaan Ober (Integricom). -// 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_ACCUMULATORS_STATISTICS_ROLLING_VARIANCE_HPP_EAN_15_11_2011 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_VARIANCE_HPP_EAN_15_11_2011 - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace boost { namespace accumulators -{ -namespace impl -{ - //! Immediate (lazy) calculation of the rolling variance. - /*! - Calculation of sample variance \f$\sigma_n^2\f$ is done as follows, see also - http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance. - For a rolling window of size \f$N\f$, when \f$n <= N\f$, the variance is computed according to the formula - \f[ - \sigma_n^2 = \frac{1}{n-1} \sum_{i = 1}^n (x_i - \mu_n)^2. - \f] - When \f$n > N\f$, the sample variance over the window becomes: - \f[ - \sigma_n^2 = \frac{1}{N-1} \sum_{i = n-N+1}^n (x_i - \mu_n)^2. - \f] - */ - /////////////////////////////////////////////////////////////////////////////// - // lazy_rolling_variance_impl - // - template - struct lazy_rolling_variance_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - lazy_rolling_variance_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - result_type mean = rolling_mean(args); - size_t nr_samples = rolling_count(args); - if (nr_samples < 2) return result_type(); - return nr_samples*(rolling_moment<2>(args) - mean*mean)/(nr_samples-1); - } - }; - - //! Iterative calculation of the rolling variance. - /*! - Iterative calculation of sample variance \f$\sigma_n^2\f$ is done as follows, see also - http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance. - For a rolling window of size \f$N\f$, for the first \f$N\f$ samples, the variance is computed according to the formula - \f[ - \sigma_n^2 = \frac{1}{n-1} \sum_{i = 1}^n (x_i - \mu_n)^2 = \frac{1}{n-1}M_{2,n}, - \f] - where the sum of squares \f$M_{2,n}\f$ can be recursively computed as: - \f[ - M_{2,n} = \sum_{i = 1}^n (x_i - \mu_n)^2 = M_{2,n-1} + (x_n - \mu_n)(x_n - \mu_{n-1}), - \f] - and the estimate of the sample mean as: - \f[ - \mu_n = \frac{1}{n} \sum_{i = 1}^n x_i = \mu_{n-1} + \frac{1}{n}(x_n - \mu_{n-1}). - \f] - For further samples, when the rolling window is fully filled with data, one has to take into account that the oldest - sample \f$x_{n-N}\f$ is dropped from the window. The sample variance over the window now becomes: - \f[ - \sigma_n^2 = \frac{1}{N-1} \sum_{i = n-N+1}^n (x_i - \mu_n)^2 = \frac{1}{n-1}M_{2,n}, - \f] - where the sum of squares \f$M_{2,n}\f$ now equals: - \f[ - M_{2,n} = \sum_{i = n-N+1}^n (x_i - \mu_n)^2 = M_{2,n-1} + (x_n - \mu_n)(x_n - \mu_{n-1}) - (x_{n-N} - \mu_n)(x_{n-N} - \mu_{n-1}), - \f] - and the estimated mean is: - \f[ - \mu_n = \frac{1}{N} \sum_{i = n-N+1}^n x_i = \mu_{n-1} + \frac{1}{n}(x_n - x_{n-N}). - \f] - - Note that the sample variance is not defined for \f$n <= 1\f$. - - */ - /////////////////////////////////////////////////////////////////////////////// - // immediate_rolling_variance_impl - // - template - struct immediate_rolling_variance_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - immediate_rolling_variance_impl(Args const &args) - : previous_mean_(numeric::fdiv(args[sample | Sample()], numeric::one::value)) - , sum_of_squares_(numeric::fdiv(args[sample | Sample()], numeric::one::value)) - { - } - - template - void operator()(Args const &args) - { - Sample added_sample = args[sample]; - - result_type mean = immediate_rolling_mean(args); - sum_of_squares_ += (added_sample-mean)*(added_sample-previous_mean_); - - if(is_rolling_window_plus1_full(args)) - { - Sample removed_sample = rolling_window_plus1(args).front(); - sum_of_squares_ -= (removed_sample-mean)*(removed_sample-previous_mean_); - prevent_underflow(sum_of_squares_); - } - previous_mean_ = mean; - } - - template - result_type result(Args const &args) const - { - size_t nr_samples = rolling_count(args); - if (nr_samples < 2) return result_type(); - return numeric::fdiv(sum_of_squares_,(nr_samples-1)); - } - - private: - - result_type previous_mean_; - result_type sum_of_squares_; - - template - void prevent_underflow(T &non_negative_number,typename boost::enable_if,T>::type* = 0) - { - if (non_negative_number < T(0)) non_negative_number = T(0); - } - template - void prevent_underflow(T &non_arithmetic_quantity,typename boost::disable_if,T>::type* = 0) - { - } - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag:: lazy_rolling_variance -// tag:: immediate_rolling_variance -// tag:: rolling_variance -// -namespace tag -{ - struct lazy_rolling_variance - : depends_on< rolling_count, rolling_mean, rolling_moment<2> > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::lazy_rolling_variance_impl< mpl::_1 > impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; - #endif - }; - - struct immediate_rolling_variance - : depends_on< rolling_window_plus1, rolling_count, immediate_rolling_mean> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_rolling_variance_impl< mpl::_1> impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::window_size named parameter - static boost::parameter::keyword const window_size; - #endif - }; - - // make immediate_rolling_variance the default implementation - struct rolling_variance : immediate_rolling_variance {}; -} // namespace tag - -/////////////////////////////////////////////////////////////////////////////// -// extract::lazy_rolling_variance -// extract::immediate_rolling_variance -// extract::rolling_variance -// -namespace extract -{ - extractor const lazy_rolling_variance = {}; - extractor const immediate_rolling_variance = {}; - extractor const rolling_variance = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_rolling_variance) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(immediate_rolling_variance) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_variance) -} - -using extract::lazy_rolling_variance; -using extract::immediate_rolling_variance; -using extract::rolling_variance; - -// rolling_variance(lazy) -> lazy_rolling_variance -template<> -struct as_feature -{ - typedef tag::lazy_rolling_variance type; -}; - -// rolling_variance(immediate) -> immediate_rolling_variance -template<> -struct as_feature -{ - typedef tag::immediate_rolling_variance type; -}; - -// for the purposes of feature-based dependency resolution, -// lazy_rolling_variance provides the same feature as rolling_variance -template<> -struct feature_of - : feature_of -{ -}; - -// for the purposes of feature-based dependency resolution, -// immediate_rolling_variance provides the same feature as rolling_variance -template<> -struct feature_of - : feature_of -{ -}; -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/rolling_window.hpp b/boost/accumulators/statistics/rolling_window.hpp deleted file mode 100644 index 2e0a33420a2aa73ecd4b09131824435857080344..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/rolling_window.hpp +++ /dev/null @@ -1,172 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// rolling_window.hpp -// -// 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_ACCUMULATORS_STATISTICS_ROLLING_WINDOW_HPP_EAN_26_12_2008 -#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_WINDOW_HPP_EAN_26_12_2008 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// tag::rolling_window::size named parameter -BOOST_PARAMETER_NESTED_KEYWORD(tag, rolling_window_size, window_size) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window_size) - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // rolling_window_plus1_impl - // stores the latest N+1 samples, where N is specified at construction time - // with the rolling_window_size named parameter - template - struct rolling_window_plus1_impl - : accumulator_base - { - typedef typename circular_buffer::const_iterator const_iterator; - typedef iterator_range result_type; - - template - rolling_window_plus1_impl(Args const & args) - : buffer_(args[rolling_window_size] + 1) - {} - - #if BOOST_VERSION < 103600 - // Before Boost 1.36, copying a circular buffer didn't copy - // it's capacity, and we need that behavior. - rolling_window_plus1_impl(rolling_window_plus1_impl const &that) - : buffer_(that.buffer_) - { - this->buffer_.set_capacity(that.buffer_.capacity()); - } - - rolling_window_plus1_impl &operator =(rolling_window_plus1_impl const &that) - { - this->buffer_ = that.buffer_; - this->buffer_.set_capacity(that.buffer_.capacity()); - } - #endif - - template - void operator ()(Args const &args) - { - this->buffer_.push_back(args[sample]); - } - - bool full() const - { - return this->buffer_.full(); - } - - // The result of a shifted rolling window is the range including - // everything except the most recently added element. - result_type result(dont_care) const - { - return result_type(this->buffer_.begin(), this->buffer_.end()); - } - - private: - circular_buffer buffer_; - }; - - template - bool is_rolling_window_plus1_full(Args const &args) - { - return find_accumulator(args[accumulator]).full(); - } - - /////////////////////////////////////////////////////////////////////////////// - // rolling_window_impl - // stores the latest N samples, where N is specified at construction type - // with the rolling_window_size named parameter - template - struct rolling_window_impl - : accumulator_base - { - typedef typename circular_buffer::const_iterator const_iterator; - typedef iterator_range result_type; - - rolling_window_impl(dont_care) - {} - - template - result_type result(Args const &args) const - { - return rolling_window_plus1(args).advance_begin(is_rolling_window_plus1_full(args)); - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::rolling_window_plus1 -// tag::rolling_window -// -namespace tag -{ - struct rolling_window_plus1 - : depends_on<> - , tag::rolling_window_size - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::rolling_window_plus1_impl< mpl::_1 > impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::size named parameter - static boost::parameter::keyword const window_size; - #endif - }; - - struct rolling_window - : depends_on< rolling_window_plus1 > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::rolling_window_impl< mpl::_1 > impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::rolling_window::size named parameter - static boost::parameter::keyword const window_size; - #endif - }; - -} // namespace tag - -/////////////////////////////////////////////////////////////////////////////// -// extract::rolling_window_plus1 -// extract::rolling_window -// -namespace extract -{ - extractor const rolling_window_plus1 = {}; - extractor const rolling_window = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window_plus1) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window) -} - -using extract::rolling_window_plus1; -using extract::rolling_window; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/skewness.hpp b/boost/accumulators/statistics/skewness.hpp deleted file mode 100644 index c383ec4a6c264de924115242ee7cc92c7a3b4e67..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/skewness.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// skewness.hpp -// -// Copyright 2006 Olivier Gygi, Daniel Egloff. 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_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // skewness_impl - /** - @brief Skewness estimation - - The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$ 3/2 \f$-th power - of the 2nd central moment (the variance) of the samples 3. The skewness can also be expressed by the simple moments: - - \f[ - \hat{g}_1 = - \frac - {\widehat{m}_n^{(3)}-3\widehat{m}_n^{(2)}\hat{\mu}_n+2\hat{\mu}_n^3} - {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^{3/2}} - \f] - - where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the - \f$ n \f$ samples. - */ - template - struct skewness_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - skewness_impl(dont_care) - { - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv( - accumulators::moment<3>(args) - - 3. * accumulators::moment<2>(args) * mean(args) - + 2. * mean(args) * mean(args) * mean(args) - , ( accumulators::moment<2>(args) - mean(args) * mean(args) ) - * std::sqrt( accumulators::moment<2>(args) - mean(args) * mean(args) ) - ); - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::skewness -// -namespace tag -{ - struct skewness - : depends_on, moment<3> > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::skewness_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::skewness -// -namespace extract -{ - extractor const skewness = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(skewness) -} - -using extract::skewness; - -// So that skewness can be automatically substituted with -// weighted_skewness when the weight parameter is non-void -template<> -struct as_weighted_feature -{ - typedef tag::weighted_skewness type; -}; - -template<> -struct feature_of - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/stats.hpp b/boost/accumulators/statistics/stats.hpp deleted file mode 100644 index 22c4ede0273c1085f402b4e50701bbec3581cc0e..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/stats.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file stats.hpp -/// Contains the stats<> template. -/// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_28_10_2005 - -#include -#include -#include - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -/// An MPL sequence of statistics. -template -struct stats - : mpl::vector -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/sum.hpp b/boost/accumulators/statistics/sum.hpp deleted file mode 100644 index 126ce244fde67f6d0dc0efe5fd42a7f16595c70f..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/sum.hpp +++ /dev/null @@ -1,141 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// sum.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_SUM_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_SUM_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // sum_impl - template - struct sum_impl - : accumulator_base - { - // for boost::result_of - typedef Sample result_type; - - template - sum_impl(Args const &args) - : sum(args[parameter::keyword::get() | Sample()]) - { - } - - template - void operator ()(Args const &args) - { - // what about overflow? - this->sum += args[parameter::keyword::get()]; - } - - result_type result(dont_care) const - { - return this->sum; - } - - private: - - Sample sum; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::sum -// tag::sum_of_weights -// tag::sum_of_variates -// -namespace tag -{ - struct sum - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::sum_impl impl; - }; - - struct sum_of_weights - : depends_on<> - { - typedef mpl::true_ is_weight_accumulator; - /// INTERNAL ONLY - /// - typedef accumulators::impl::sum_impl impl; - }; - - template - struct sum_of_variates - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; - - struct abstract_sum_of_variates - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::sum -// extract::sum_of_weights -// extract::sum_of_variates -// -namespace extract -{ - extractor const sum = {}; - extractor const sum_of_weights = {}; - extractor const sum_of_variates = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates) -} - -using extract::sum; -using extract::sum_of_weights; -using extract::sum_of_variates; - -// So that mean can be automatically substituted with -// weighted_mean when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_sum type; -}; - -template<> -struct feature_of - : feature_of -{}; - -template -struct feature_of > - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/sum_kahan.hpp b/boost/accumulators/statistics/sum_kahan.hpp deleted file mode 100644 index 97ade18da814f04086cc940d2efd431ea6874669..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/sum_kahan.hpp +++ /dev/null @@ -1,188 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// sum_kahan.hpp -// -// Copyright 2010 Gaetano Mendola, 2011 Simon West. 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_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010 -#define BOOST_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010 - -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - -#if _MSC_VER > 1400 -# pragma float_control(push) -# pragma float_control(precise, on) -#endif - -template -struct sum_kahan_impl - : accumulator_base -{ - typedef Sample result_type; - - //////////////////////////////////////////////////////////////////////////// - // sum_kahan_impl - /** - @brief Kahan summation algorithm - - The Kahan summation algorithm reduces the numerical error obtained with standard - sequential sum. - - */ - template - sum_kahan_impl(Args const & args) - : sum(args[parameter::keyword::get() | Sample()]), - compensation(boost::numeric_cast(0.0)) - { - } - - template - void -#if BOOST_ACCUMULATORS_GCC_VERSION > 40305 - __attribute__((__optimize__("no-associative-math"))) -#endif - operator ()(Args const & args) - { - const Sample myTmp1 = args[parameter::keyword::get()] - this->compensation; - const Sample myTmp2 = this->sum + myTmp1; - this->compensation = (myTmp2 - this->sum) - myTmp1; - this->sum = myTmp2; - } - - result_type result(dont_care) const - { - return this->sum; - } - -private: - Sample sum; - Sample compensation; -}; - -#if _MSC_VER > 1400 -# pragma float_control(pop) -#endif - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::sum_kahan -// tag::sum_of_weights_kahan -// tag::sum_of_variates_kahan -// -namespace tag -{ - - struct sum_kahan - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef impl::sum_kahan_impl< mpl::_1, tag::sample > impl; - }; - - struct sum_of_weights_kahan - : depends_on<> - { - typedef mpl::true_ is_weight_accumulator; - /// INTERNAL ONLY - /// - typedef accumulators::impl::sum_kahan_impl impl; - }; - - template - struct sum_of_variates_kahan - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; - -} // namespace tag - -/////////////////////////////////////////////////////////////////////////////// -// extract::sum_kahan -// extract::sum_of_weights_kahan -// extract::sum_of_variates_kahan -// -namespace extract -{ - extractor const sum_kahan = {}; - extractor const sum_of_weights_kahan = {}; - extractor const sum_of_variates_kahan = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_kahan) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights_kahan) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates_kahan) -} // namespace extract - -using extract::sum_kahan; -using extract::sum_of_weights_kahan; -using extract::sum_of_variates_kahan; - -// sum(kahan) -> sum_kahan -template<> -struct as_feature -{ - typedef tag::sum_kahan type; -}; - -// sum_of_weights(kahan) -> sum_of_weights_kahan -template<> -struct as_feature -{ - typedef tag::sum_of_weights_kahan type; -}; - -// So that sum_kahan can be automatically substituted with -// weighted_sum_kahan when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_sum_kahan type; -}; - -template<> -struct feature_of - : feature_of -{}; - -// for the purposes of feature-based dependency resolution, -// sum_kahan provides the same feature as sum -template<> -struct feature_of - : feature_of -{ -}; - -// for the purposes of feature-based dependency resolution, -// sum_of_weights_kahan provides the same feature as sum_of_weights -template<> -struct feature_of - : feature_of -{ -}; - -template -struct feature_of > - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif - diff --git a/boost/accumulators/statistics/tail.hpp b/boost/accumulators/statistics/tail.hpp deleted file mode 100644 index be6cdee392c7d253f464f1ecc41f1693c9997034..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/tail.hpp +++ /dev/null @@ -1,341 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// tail.hpp -// -// Copyright 2005 Eric Niebler, Michael Gauckler. 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_ACCUMULATORS_STATISTICS_TAIL_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_TAIL_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ -/////////////////////////////////////////////////////////////////////////////// -// cache_size named parameters -BOOST_PARAMETER_NESTED_KEYWORD(tag, right_tail_cache_size, cache_size) -BOOST_PARAMETER_NESTED_KEYWORD(tag, left_tail_cache_size, cache_size) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(right_tail_cache_size) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(left_tail_cache_size) - -namespace detail -{ - /////////////////////////////////////////////////////////////////////////////// - // tail_range - /// INTERNAL ONLY - /// - template - struct tail_range - { - typedef boost::iterator_range< - boost::reverse_iterator > - > type; - }; - - /////////////////////////////////////////////////////////////////////////////// - // make_tail_range - /// INTERNAL ONLY - /// - template - typename tail_range::type - make_tail_range(ElementIterator elem_begin, IndexIterator index_begin, IndexIterator index_end) - { - return boost::make_iterator_range( - boost::make_reverse_iterator( - boost::make_permutation_iterator(elem_begin, index_end) - ) - , boost::make_reverse_iterator( - boost::make_permutation_iterator(elem_begin, index_begin) - ) - ); - } - - /////////////////////////////////////////////////////////////////////////////// - // stat_assign_visitor - /// INTERNAL ONLY - /// - template - struct stat_assign_visitor - { - stat_assign_visitor(Args const &a, std::size_t i) - : args(a) - , index(i) - { - } - - template - void operator ()(Stat &stat) const - { - stat.assign(this->args, this->index); - } - - private: - stat_assign_visitor &operator =(stat_assign_visitor const &); - Args const &args; - std::size_t index; - }; - - /////////////////////////////////////////////////////////////////////////////// - // stat_assign - /// INTERNAL ONLY - /// - template - inline stat_assign_visitor const stat_assign(Args const &args, std::size_t index) - { - return stat_assign_visitor(args, index); - } - - /////////////////////////////////////////////////////////////////////////////// - // is_tail_variate_feature - /// INTERNAL ONLY - /// - template - struct is_tail_variate_feature - : mpl::false_ - { - }; - - /// INTERNAL ONLY - /// - template - struct is_tail_variate_feature, LeftRight> - : mpl::true_ - { - }; - - /// INTERNAL ONLY - /// - template - struct is_tail_variate_feature, LeftRight> - : mpl::true_ - { - }; - -} // namespace detail - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // tail_impl - template - struct tail_impl - : accumulator_base - { - // LeftRight must be either right or left - BOOST_MPL_ASSERT(( - mpl::or_, is_same > - )); - - typedef - typename mpl::if_< - is_same - , numeric::functional::greater - , numeric::functional::less - >::type - predicate_type; - - // for boost::result_of - typedef typename detail::tail_range< - typename std::vector::const_iterator - , std::vector::iterator - >::type result_type; - - template - tail_impl(Args const &args) - : is_sorted(false) - , indices() - , samples(args[tag::tail::cache_size], args[sample | Sample()]) - { - this->indices.reserve(this->samples.size()); - } - - tail_impl(tail_impl const &that) - : is_sorted(that.is_sorted) - , indices(that.indices) - , samples(that.samples) - { - this->indices.reserve(this->samples.size()); - } - - // This just stores the heap and the samples. - // In operator()() below, if we are adding a new sample - // to the sample cache, we force all the - // tail_variates to update also. (It's not - // good enough to wait for the accumulator_set to do it - // for us because then information about whether a sample - // was stored and where is lost, and would need to be - // queried at runtime, which would be slow.) This is - // implemented as a filtered visitation over the stats, - // which we can access because args[accumulator] gives us - // all the stats. - - template - void operator ()(Args const &args) - { - if(this->indices.size() < this->samples.size()) - { - this->indices.push_back(this->indices.size()); - this->assign(args, this->indices.back()); - } - else if(predicate_type()(args[sample], this->samples[this->indices[0]])) - { - std::pop_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); - this->assign(args, this->indices.back()); - } - } - - result_type result(dont_care) const - { - if(!this->is_sorted) - { - // Must use the same predicate here as in push_heap/pop_heap above. - std::sort_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); - // sort_heap puts elements in reverse order. Calling std::reverse - // turns the sorted sequence back into a valid heap. - std::reverse(this->indices.begin(), this->indices.end()); - this->is_sorted = true; - } - - return detail::make_tail_range( - this->samples.begin() - , this->indices.begin() - , this->indices.end() - ); - } - - private: - - struct is_tail_variate - { - template - struct apply - : detail::is_tail_variate_feature< - typename detail::feature_tag::type - , LeftRight - > - {}; - }; - - template - void assign(Args const &args, std::size_t index) - { - BOOST_ASSERT(index < this->samples.size()); - this->samples[index] = args[sample]; - std::push_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); - this->is_sorted = false; - // Tell the tail variates to store their values also - args[accumulator].template visit_if(detail::stat_assign(args, index)); - } - - /////////////////////////////////////////////////////////////////////////////// - // - struct indirect_cmp - { - typedef std::size_t first_argument_type; - typedef std::size_t second_argument_type; - typedef bool result_type; - - indirect_cmp(std::vector const &s) - : samples(s) - { - } - - bool operator ()(std::size_t left, std::size_t right) const - { - return predicate_type()(this->samples[left], this->samples[right]); - } - - private: - indirect_cmp &operator =(indirect_cmp const &); - std::vector const &samples; - }; - - mutable bool is_sorted; - mutable std::vector indices; - std::vector samples; - }; - -} // namespace impl - -// TODO The templatized tag::tail below should inherit from the correct named parameter. -// The following lines provide a workaround, but there must be a better way of doing this. -template -struct tail_cache_size_named_arg -{ -}; -template<> -struct tail_cache_size_named_arg - : tag::left_tail_cache_size -{ -}; -template<> -struct tail_cache_size_named_arg - : tag::right_tail_cache_size -{ -}; - -/////////////////////////////////////////////////////////////////////////////// -// tag::tail<> -// -namespace tag -{ - template - struct tail - : depends_on<> - , tail_cache_size_named_arg - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::tail_impl impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - /// tag::tail::cache_size named parameter - static boost::parameter::keyword > const cache_size; - #endif - }; - - struct abstract_tail - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::tail -// -namespace extract -{ - extractor const tail = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail) -} - -using extract::tail; - -template -struct feature_of > - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/tail_mean.hpp b/boost/accumulators/statistics/tail_mean.hpp deleted file mode 100644 index 67dae37b50f2a34c83de09fb5ff7cebfdab4dcfd..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/tail_mean.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// tail_mean.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_TAIL_MEAN_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_TAIL_MEAN_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - /////////////////////////////////////////////////////////////////////////////// - // coherent_tail_mean_impl - // - /** - @brief Estimation of the coherent tail mean based on order statistics (for both left and right tails) - - The coherent tail mean \f$\widehat{CTM}_{n,\alpha}(X)\f$ is equal to the non-coherent tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ - plus a correction term that ensures coherence in case of non-continuous distributions. - - \f[ - \widehat{CTM}_{n,\alpha}^{\mathrm{right}}(X) = \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) + - \frac{1}{\lceil n(1-\alpha)\rceil}\hat{q}_{n,\alpha}(X)\left(1 - \alpha - \frac{1}{n}\lceil n(1-\alpha)\rceil \right) - \f] - - \f[ - \widehat{CTM}_{n,\alpha}^{\mathrm{left}}(X) = \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) + - \frac{1}{\lceil n\alpha\rceil}\hat{q}_{n,\alpha}(X)\left(\alpha - \frac{1}{n}\lceil n\alpha\rceil \right) - \f] - */ - template - struct coherent_tail_mean_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef float_type result_type; - - coherent_tail_mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - std::size_t cnt = count(args); - - std::size_t n = static_cast( - std::ceil( - cnt * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) - ) - ); - - extractor > const some_non_coherent_tail_mean = {}; - - return some_non_coherent_tail_mean(args) - + numeric::fdiv(quantile(args), n) - * ( - ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] - - numeric::fdiv(n, count(args)) - ); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // non_coherent_tail_mean_impl - // - /** - @brief Estimation of the (non-coherent) tail mean based on order statistics (for both left and right tails) - - An estimation of the non-coherent tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ is given by the mean of the - \f$\lceil n\alpha\rceil\f$ smallest samples (left tail) or the mean of the \f$\lceil n(1-\alpha)\rceil\f$ - largest samples (right tail), \f$n\f$ being the total number of samples and \f$\alpha\f$ the quantile level: - - \f[ - \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) = \frac{1}{\lceil n(1-\alpha)\rceil} \sum_{i=\lceil \alpha n \rceil}^n X_{i:n} - \f] - - \f[ - \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) = \frac{1}{\lceil n\alpha\rceil} \sum_{i=1}^{\lceil \alpha n \rceil} X_{i:n} - \f] - - It thus requires the caching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ - largest samples. - - @param quantile_probability - */ - template - struct non_coherent_tail_mean_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef float_type result_type; - - non_coherent_tail_mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - std::size_t cnt = count(args); - - std::size_t n = static_cast( - std::ceil( - cnt * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) - ) - ); - - // If n is in a valid range, return result, otherwise return NaN or throw exception - if (n <= static_cast(tail(args).size())) - return numeric::fdiv( - std::accumulate( - tail(args).begin() - , tail(args).begin() + n - , Sample(0) - ) - , n - ); - else - { - if (std::numeric_limits::has_quiet_NaN) - { - return std::numeric_limits::quiet_NaN(); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return Sample(0); - } - } - } - }; - -} // namespace impl - - -/////////////////////////////////////////////////////////////////////////////// -// tag::coherent_tail_mean<> -// tag::non_coherent_tail_mean<> -// -namespace tag -{ - template - struct coherent_tail_mean - : depends_on > - { - typedef accumulators::impl::coherent_tail_mean_impl impl; - }; - - template - struct non_coherent_tail_mean - : depends_on > - { - typedef accumulators::impl::non_coherent_tail_mean_impl impl; - }; - - struct abstract_non_coherent_tail_mean - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::non_coherent_tail_mean; -// extract::coherent_tail_mean; -// -namespace extract -{ - extractor const non_coherent_tail_mean = {}; - extractor const coherent_tail_mean = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(non_coherent_tail_mean) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(coherent_tail_mean) -} - -using extract::non_coherent_tail_mean; -using extract::coherent_tail_mean; - -// for the purposes of feature-based dependency resolution, -// coherent_tail_mean provides the same feature as tail_mean -template -struct feature_of > - : feature_of -{ -}; - -template -struct feature_of > - : feature_of -{ -}; - -// So that non_coherent_tail_mean can be automatically substituted -// with weighted_non_coherent_tail_mean when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::non_coherent_weighted_tail_mean type; -}; - -template -struct feature_of > - : feature_of > -{}; - -// NOTE that non_coherent_tail_mean cannot be feature-grouped with tail_mean, -// which is the base feature for coherent tail means, since (at least for -// non-continuous distributions) non_coherent_tail_mean is a different measure! - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/tail_quantile.hpp b/boost/accumulators/statistics/tail_quantile.hpp deleted file mode 100644 index 9ff56b56e54bd4a498d1e8728fdf4488996b1f7d..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/tail_quantile.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// tail_quantile.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_TAIL_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_TAIL_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include // For ceil -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // tail_quantile_impl - // Tail quantile estimation based on order statistics - /** - @brief Tail quantile estimation based on order statistics (for both left and right tails) - - The estimation of a tail quantile \f$\hat{q}\f$ with level \f$\alpha\f$ based on order statistics requires the - caching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ largest samples, - \f$n\f$ being the total number of samples. The largest of the \f$\lceil n\alpha\rceil\f$ smallest samples or the - smallest of the \f$\lceil n(1-\alpha)\rceil\f$ largest samples provides an estimate for the quantile: - - \f[ - \hat{q}_{n,\alpha} = X_{\lceil \alpha n \rceil:n} - \f] - - @param quantile_probability - */ - template - struct tail_quantile_impl - : accumulator_base - { - // for boost::result_of - typedef Sample result_type; - - tail_quantile_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - std::size_t cnt = count(args); - - std::size_t n = static_cast( - std::ceil( - cnt * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) - ) - ); - - // If n is in a valid range, return result, otherwise return NaN or throw exception - if ( n < static_cast(tail(args).size())) - { - // Note that the cached samples of the left are sorted in ascending order, - // whereas the samples of the right tail are sorted in descending order - return *(boost::begin(tail(args)) + n - 1); - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - return std::numeric_limits::quiet_NaN(); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return Sample(0); - } - } - } - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::tail_quantile<> -// -namespace tag -{ - template - struct tail_quantile - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::tail_quantile_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::tail_quantile -// -namespace extract -{ - extractor const tail_quantile = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_quantile) -} - -using extract::tail_quantile; - -// for the purposes of feature-based dependency resolution, -// tail_quantile provide the same feature as quantile -template -struct feature_of > - : feature_of -{ -}; - -// So that tail_quantile can be automatically substituted with -// weighted_tail_quantile when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::weighted_tail_quantile type; -}; - -template -struct feature_of > - : feature_of > -{}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/tail_variate.hpp b/boost/accumulators/statistics/tail_variate.hpp deleted file mode 100644 index a9fc7d297a3341d2b7e05119e100f1af9d6d27dc..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/tail_variate.hpp +++ /dev/null @@ -1,141 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// tail_variate.hpp -// -// Copyright 2005 Eric Niebler, Michael Gauckler. 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_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005 -#define BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // tail_variate_impl - template - struct tail_variate_impl - : accumulator_base - { - // for boost::result_of - typedef - typename detail::tail_range< - typename std::vector::const_iterator - , std::vector::iterator - >::type - result_type; - - template - tail_variate_impl(Args const &args) - : variates(args[tag::tail::cache_size], args[parameter::keyword::get() | VariateType()]) - { - } - - template - void assign(Args const &args, std::size_t index) - { - this->variates[index] = args[parameter::keyword::get()]; - } - - template - result_type result(Args const &args) const - { - // getting the order result causes the indices vector to be sorted. - extractor > const some_tail = {}; - return this->do_result(some_tail(args)); - } - - private: - template - result_type do_result(TailRng const &rng) const - { - return detail::make_tail_range( - this->variates.begin() - , rng.end().base().base() // the index iterator - , rng.begin().base().base() // (begin and end reversed because these are reverse iterators) - ); - } - - std::vector variates; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::tail_variate<> -// -namespace tag -{ - template - struct tail_variate - : depends_on > - { - /// INTERNAL ONLY - /// - typedef mpl::always > impl; - }; - - struct abstract_tail_variate - : depends_on<> - { - }; - - template - struct tail_weights - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::tail_variate_impl impl; - }; - - struct abstract_tail_weights - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::tail_variate -// extract::tail_weights -// -namespace extract -{ - extractor const tail_variate = {}; - extractor const tail_weights = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_weights) -} - -using extract::tail_variate; -using extract::tail_weights; - -template -struct feature_of > - : feature_of -{ -}; - -template -struct feature_of > -{ - typedef tag::abstract_tail_weights type; -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/tail_variate_means.hpp b/boost/accumulators/statistics/tail_variate_means.hpp deleted file mode 100644 index a97eab5648c712cef4d825b605a4df3807224bfc..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/tail_variate_means.hpp +++ /dev/null @@ -1,262 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// tail_variate_means.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /** - @brief Estimation of the absolute and relative tail variate means (for both left and right tails) - - For all \f$j\f$-th variates associated to the \f$\lceil n(1-\alpha)\rceil\f$ largest samples (or the - \f$\lceil n(1-\alpha)\rceil\f$ smallest samples in case of the left tail), the absolute tail means - \f$\widehat{ATM}_{n,\alpha}(X, j)\f$ are computed and returned as an iterator range. Alternatively, - the relative tail means \f$\widehat{RTM}_{n,\alpha}(X, j)\f$ are returned, which are the absolute - tail means normalized with the (non-coherent) sample tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$. - - \f[ - \widehat{ATM}_{n,\alpha}^{\mathrm{right}}(X, j) = - \frac{1}{\lceil n(1-\alpha) \rceil} - \sum_{i=\lceil \alpha n \rceil}^n \xi_{j,i} - \f] - - \f[ - \widehat{ATM}_{n,\alpha}^{\mathrm{left}}(X, j) = - \frac{1}{\lceil n\alpha \rceil} - \sum_{i=1}^{\lceil n\alpha \rceil} \xi_{j,i} - \f] - - \f[ - \widehat{RTM}_{n,\alpha}^{\mathrm{right}}(X, j) = - \frac{\sum_{i=\lceil n\alpha \rceil}^n \xi_{j,i}} - {\lceil n(1-\alpha)\rceil\widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X)} - \f] - - \f[ - \widehat{RTM}_{n,\alpha}^{\mathrm{left}}(X, j) = - \frac{\sum_{i=1}^{\lceil n\alpha \rceil} \xi_{j,i}} - {\lceil n\alpha\rceil\widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X)} - \f] - */ - - /////////////////////////////////////////////////////////////////////////////// - // tail_variate_means_impl - // by default: absolute tail_variate_means - template - struct tail_variate_means_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range result_type; - - tail_variate_means_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - std::size_t cnt = count(args); - - std::size_t n = static_cast( - std::ceil( - cnt * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) - ) - ); - - std::size_t num_variates = tail_variate(args).begin()->size(); - - this->tail_means_.clear(); - this->tail_means_.resize(num_variates, Sample(0)); - - // If n is in a valid range, return result, otherwise return NaN or throw exception - if (n < static_cast(tail(args).size())) - { - this->tail_means_ = std::accumulate( - tail_variate(args).begin() - , tail_variate(args).begin() + n - , this->tail_means_ - , numeric::plus - ); - - float_type factor = n * ( (is_same::value) ? non_coherent_tail_mean(args) : 1. ); - - std::transform( - this->tail_means_.begin() - , this->tail_means_.end() - , this->tail_means_.begin() -#ifdef BOOST_NO_CXX98_BINDERS - , std::bind(std::divides(), std::placeholders::_1, factor) -#else - , std::bind2nd(std::divides(), factor) -#endif - ); - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - std::fill( - this->tail_means_.begin() - , this->tail_means_.end() - , std::numeric_limits::quiet_NaN() - ); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - } - } - return make_iterator_range(this->tail_means_); - } - - private: - - mutable array_type tail_means_; - - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::absolute_tail_variate_means -// tag::relative_tail_variate_means -// -namespace tag -{ - template - struct absolute_tail_variate_means - : depends_on, tail_variate > - { - typedef accumulators::impl::tail_variate_means_impl impl; - }; - template - struct relative_tail_variate_means - : depends_on, tail_variate > - { - typedef accumulators::impl::tail_variate_means_impl impl; - }; - struct abstract_absolute_tail_variate_means - : depends_on<> - { - }; - struct abstract_relative_tail_variate_means - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::tail_variate_means -// extract::relative_tail_variate_means -// -namespace extract -{ - extractor const tail_variate_means = {}; - extractor const relative_tail_variate_means = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate_means) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(relative_tail_variate_means) -} - -using extract::tail_variate_means; -using extract::relative_tail_variate_means; - -// tail_variate_means(absolute) -> absolute_tail_variate_means -template -struct as_feature(absolute)> -{ - typedef tag::absolute_tail_variate_means type; -}; - -// tail_variate_means(relative) ->relative_tail_variate_means -template -struct as_feature(relative)> -{ - typedef tag::relative_tail_variate_means type; -}; - -// Provides non-templatized extractor -template -struct feature_of > - : feature_of -{ -}; - -// Provides non-templatized extractor -template -struct feature_of > - : feature_of -{ -}; - -// So that absolute_tail_means can be automatically substituted -// with absolute_weighted_tail_means when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::absolute_weighted_tail_variate_means type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -// So that relative_tail_means can be automatically substituted -// with relative_weighted_tail_means when the weight parameter is non-void. -template -struct as_weighted_feature > -{ - typedef tag::relative_weighted_tail_variate_means type; -}; - -template -struct feature_of > - : feature_of > -{ -}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/times2_iterator.hpp b/boost/accumulators/statistics/times2_iterator.hpp deleted file mode 100644 index dbd81af7cf9570ea3458f54add40f920dce32d63..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/times2_iterator.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// times2_iterator.hpp -// -// Copyright 2006 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_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace detail -{ - typedef transform_iterator< -#ifdef BOOST_NO_CXX98_BINDERS - decltype(std::bind(std::multiplies(), 2, std::placeholders::_1)) -#else - std::binder1st > -#endif - , counting_iterator - > times2_iterator; - - inline times2_iterator make_times2_iterator(std::size_t i) - { - return make_transform_iterator( - make_counting_iterator(i) -#ifdef BOOST_NO_CXX98_BINDERS - , std::bind(std::multiplies(), 2, std::placeholders::_1) -#else - , std::bind1st(std::multiplies(), 2) -#endif - ); - } - - /////////////////////////////////////////////////////////////////////////////// - // lvalue_index_iterator - template - struct lvalue_index_iterator - : Base - { - lvalue_index_iterator() - : Base() - {} - - lvalue_index_iterator(Base base) - : Base(base) - { - } - - typename Base::reference operator [](typename Base::difference_type n) const - { - return *(*this + n); - } - }; -} // namespace detail - -}} - -#endif diff --git a/boost/accumulators/statistics/variance.hpp b/boost/accumulators/statistics/variance.hpp deleted file mode 100644 index baac55696b332c88d1254e966d2cbe3a8799d4b1..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/variance.hpp +++ /dev/null @@ -1,236 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// variance.hpp -// -// Copyright 2005 Daniel Egloff, 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_ACCUMULATORS_STATISTICS_VARIANCE_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_VARIANCE_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - //! Lazy calculation of variance. - /*! - Default sample variance implementation based on the second moment \f$ M_n^{(2)} \f$ moment<2>, mean and count. - \f[ - \sigma_n^2 = M_n^{(2)} - \mu_n^2. - \f] - where - \f[ - \mu_n = \frac{1}{n} \sum_{i = 1}^n x_i. - \f] - is the estimate of the sample mean and \f$n\f$ is the number of samples. - */ - template - struct lazy_variance_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - lazy_variance_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - extractor mean; - result_type tmp = mean(args); - return accumulators::moment<2>(args) - tmp * tmp; - } - }; - - //! Iterative calculation of variance. - /*! - Iterative calculation of sample variance \f$\sigma_n^2\f$ according to the formula - \f[ - \sigma_n^2 = \frac{1}{n} \sum_{i = 1}^n (x_i - \mu_n)^2 = \frac{n-1}{n} \sigma_{n-1}^2 + \frac{1}{n-1}(x_n - \mu_n)^2. - \f] - where - \f[ - \mu_n = \frac{1}{n} \sum_{i = 1}^n x_i. - \f] - is the estimate of the sample mean and \f$n\f$ is the number of samples. - - Note that the sample variance is not defined for \f$n <= 1\f$. - - A simplification can be obtained by the approximate recursion - \f[ - \sigma_n^2 \approx \frac{n-1}{n} \sigma_{n-1}^2 + \frac{1}{n}(x_n - \mu_n)^2. - \f] - because the difference - \f[ - \left(\frac{1}{n-1} - \frac{1}{n}\right)(x_n - \mu_n)^2 = \frac{1}{n(n-1)}(x_n - \mu_n)^2. - \f] - converges to zero as \f$n \rightarrow \infty\f$. However, for small \f$ n \f$ the difference - can be non-negligible. - */ - template - struct variance_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - variance_impl(Args const &args) - : variance(numeric::fdiv(args[sample | Sample()], numeric::one::value)) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - if(cnt > 1) - { - extractor mean; - result_type tmp = args[parameter::keyword::get()] - mean(args); - this->variance = - numeric::fdiv(this->variance * (cnt - 1), cnt) - + numeric::fdiv(tmp * tmp, cnt - 1); - } - } - - result_type result(dont_care) const - { - return this->variance; - } - - private: - result_type variance; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::variance -// tag::immediate_variance -// -namespace tag -{ - struct lazy_variance - : depends_on, mean> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::lazy_variance_impl impl; - }; - - struct variance - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::variance_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::lazy_variance -// extract::variance -// -namespace extract -{ - extractor const lazy_variance = {}; - extractor const variance = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_variance) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(variance) -} - -using extract::lazy_variance; -using extract::variance; - -// variance(lazy) -> lazy_variance -template<> -struct as_feature -{ - typedef tag::lazy_variance type; -}; - -// variance(immediate) -> variance -template<> -struct as_feature -{ - typedef tag::variance type; -}; - -// for the purposes of feature-based dependency resolution, -// immediate_variance provides the same feature as variance -template<> -struct feature_of - : feature_of -{ -}; - -// So that variance can be automatically substituted with -// weighted_variance when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::weighted_variance type; -}; - -// for the purposes of feature-based dependency resolution, -// weighted_variance provides the same feature as variance -template<> -struct feature_of - : feature_of -{ -}; - -// So that immediate_variance can be automatically substituted with -// immediate_weighted_variance when the weight parameter is non-void. -template<> -struct as_weighted_feature -{ - typedef tag::lazy_weighted_variance type; -}; - -// for the purposes of feature-based dependency resolution, -// immediate_weighted_variance provides the same feature as immediate_variance -template<> -struct feature_of - : feature_of -{ -}; - -//////////////////////////////////////////////////////////////////////////// -//// droppable_accumulator -//// need to specialize droppable lazy variance to cache the result at the -//// point the accumulator is dropped. -///// INTERNAL ONLY -///// -//template -//struct droppable_accumulator > -// : droppable_accumulator_base< -// with_cached_result > -// > -//{ -// template -// droppable_accumulator(Args const &args) -// : droppable_accumulator::base(args) -// { -// } -//}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/variates/covariate.hpp b/boost/accumulators/statistics/variates/covariate.hpp deleted file mode 100644 index aba113a4a316c5b4784ee12d8550e9a9998d0570..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/variates/covariate.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weight.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_VARIATES_COVARIATE_HPP_EAN_03_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_VARIATES_COVARIATE_HPP_EAN_03_11_2005 - -#include -#include - -namespace boost { namespace accumulators -{ - -BOOST_PARAMETER_KEYWORD(tag, covariate1) -BOOST_PARAMETER_KEYWORD(tag, covariate2) - -BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariate1) -BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariate2) - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_covariance.hpp b/boost/accumulators/statistics/weighted_covariance.hpp deleted file mode 100644 index 25d613c120bd495dff37ca2b59f3cec0fd9cc546..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_covariance.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_covariance.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_COVARIANCE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_COVARIANCE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for numeric::outer_product() and type traits -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_covariance_impl - // - /** - @brief Weighted Covariance Estimator - - An iterative Monte Carlo estimator for the weighted covariance \f$\mathrm{Cov}(X,X')\f$, where \f$X\f$ is a sample - and \f$X'\f$ a variate, is given by: - - \f[ - \hat{c}_n = \frac{\bar{w}_n-w_n}{\bar{w}_n} \hat{c}_{n-1} + \frac{w_n}{\bar{w}_n-w_n}(X_n - \hat{\mu}_n)(X_n' - \hat{\mu}_n'), - \quad n\ge2,\quad\hat{c}_1 = 0, - \f] - - \f$\hat{\mu}_n\f$ and \f$\hat{\mu}_n'\f$ being the weighted means of the samples and variates and - \f$\bar{w}_n\f$ the sum of the \f$n\f$ first weights \f$w_i\f$. - */ - template - struct weighted_covariance_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type>::result_type weighted_sample_type; - typedef typename numeric::functional::multiplies::result_type>::result_type weighted_variate_type; - // for boost::result_of - typedef typename numeric::functional::outer_product::result_type result_type; - - template - weighted_covariance_impl(Args const &args) - : cov_( - numeric::outer_product( - numeric::fdiv(args[sample | Sample()], (std::size_t)1) - * numeric::one::value - , numeric::fdiv(args[parameter::keyword::get() | VariateType()], (std::size_t)1) - * numeric::one::value - ) - ) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - if (cnt > 1) - { - extractor > const some_weighted_mean_of_variates = {}; - - this->cov_ = this->cov_ * (sum_of_weights(args) - args[weight]) / sum_of_weights(args) - + numeric::outer_product( - some_weighted_mean_of_variates(args) - args[parameter::keyword::get()] - , weighted_mean(args) - args[sample] - ) * args[weight] / (sum_of_weights(args) - args[weight]); - } - } - - result_type result(dont_care) const - { - return this->cov_; - } - - private: - result_type cov_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_covariance -// -namespace tag -{ - template - struct weighted_covariance - : depends_on > - { - typedef accumulators::impl::weighted_covariance_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_covariance -// -namespace extract -{ - extractor const weighted_covariance = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_covariance) -} - -using extract::weighted_covariance; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_density.hpp b/boost/accumulators/statistics/weighted_density.hpp deleted file mode 100644 index 14073680161231ef4f70a5b6b327d5ac5f7959c9..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_density.hpp +++ /dev/null @@ -1,221 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_density.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_DENSITY_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_DENSITY_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for named parameters density_cache_size and density_num_bins - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_density_impl - // density histogram for weighted samples - /** - @brief Histogram density estimator for weighted samples - - The histogram density estimator returns a histogram of the sample distribution. The positions and sizes of the bins - are determined using a specifiable number of cached samples (cache_size). The range between the minimum and the - maximum of the cached samples is subdivided into a specifiable number of bins (num_bins) of same size. Additionally, - an under- and an overflow bin is added to capture future under- and overflow samples. Once the bins are determined, - the cached samples and all subsequent samples are added to the correct bins. At the end, a range of std::pair is - returned, where each pair contains the position of the bin (lower bound) and the sum of the weights (normalized with the - sum of all weights). - - @param density_cache_size Number of first samples used to determine min and max. - @param density_num_bins Number of bins (two additional bins collect under- and overflow samples). - */ - template - struct weighted_density_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range result_type; - - template - weighted_density_impl(Args const &args) - : cache_size(args[density_cache_size]) - , cache(cache_size) - , num_bins(args[density_num_bins]) - , samples_in_bin(num_bins + 2, 0.) - , bin_positions(num_bins + 2) - , histogram( - num_bins + 2 - , std::make_pair( - numeric::fdiv(args[sample | Sample()],(std::size_t)1) - , numeric::fdiv(args[sample | Sample()],(std::size_t)1) - ) - ) - , is_dirty(true) - { - } - - template - void operator ()(Args const &args) - { - this->is_dirty = true; - - std::size_t cnt = count(args); - - // Fill up cache with cache_size first samples - if (cnt <= this->cache_size) - { - this->cache[cnt - 1] = std::make_pair(args[sample], args[weight]); - } - - // Once cache_size samples have been accumulated, create num_bins bins of same size between - // the minimum and maximum of the cached samples as well as an under- and an overflow bin. - // Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin). - if (cnt == this->cache_size) - { - float_type minimum = numeric::fdiv((min)(args),(std::size_t)1); - float_type maximum = numeric::fdiv((max)(args),(std::size_t)1); - float_type bin_size = numeric::fdiv(maximum - minimum, this->num_bins); - - // determine bin positions (their lower bounds) - for (std::size_t i = 0; i < this->num_bins + 2; ++i) - { - this->bin_positions[i] = minimum + (i - 1.) * bin_size; - } - - for (typename histogram_type::const_iterator iter = this->cache.begin(); iter != this->cache.end(); ++iter) - { - if (iter->first < this->bin_positions[1]) - { - this->samples_in_bin[0] += iter->second; - } - else if (iter->first >= this->bin_positions[this->num_bins + 1]) - { - this->samples_in_bin[this->num_bins + 1] += iter->second; - } - else - { - typename array_type::iterator it = std::upper_bound( - this->bin_positions.begin() - , this->bin_positions.end() - , iter->first - ); - - std::size_t d = std::distance(this->bin_positions.begin(), it); - this->samples_in_bin[d - 1] += iter->second; - } - } - } - // Add each subsequent sample to the correct bin - else if (cnt > this->cache_size) - { - if (args[sample] < this->bin_positions[1]) - { - this->samples_in_bin[0] += args[weight]; - } - else if (args[sample] >= this->bin_positions[this->num_bins + 1]) - { - this->samples_in_bin[this->num_bins + 1] += args[weight]; - } - else - { - typename array_type::iterator it = std::upper_bound( - this->bin_positions.begin() - , this->bin_positions.end() - , args[sample] - ); - - std::size_t d = std::distance(this->bin_positions.begin(), it); - this->samples_in_bin[d - 1] += args[weight]; - } - } - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - // creates a vector of std::pair where each pair i holds - // the values bin_positions[i] (x-axis of histogram) and - // samples_in_bin[i] / cnt (y-axis of histogram). - - for (std::size_t i = 0; i < this->num_bins + 2; ++i) - { - this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::fdiv(this->samples_in_bin[i], sum_of_weights(args))); - } - } - - // returns a range of pairs - return make_iterator_range(this->histogram); - } - - private: - std::size_t cache_size; // number of cached samples - histogram_type cache; // cache to store the first cache_size samples with their weights as std::pair - std::size_t num_bins; // number of bins - array_type samples_in_bin; // number of samples in each bin - array_type bin_positions; // lower bounds of bins - mutable histogram_type histogram; // histogram - mutable bool is_dirty; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_density -// -namespace tag -{ - struct weighted_density - : depends_on - , density_cache_size - , density_num_bins - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_density_impl impl; - - #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED - static boost::parameter::keyword const cache_size; - static boost::parameter::keyword const num_bins; - #endif - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_density -// -namespace extract -{ - extractor const weighted_density = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_density) -} - -using extract::weighted_density; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_extended_p_square.hpp b/boost/accumulators/statistics/weighted_extended_p_square.hpp deleted file mode 100644 index ac857e056d2f2fc7b280cae52a7364d0ac73a509..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_extended_p_square.hpp +++ /dev/null @@ -1,290 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_extended_p_square.hpp -// -// Copyright 2005 Daniel Egloff. 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_ACCUMULATORS_STATISTICS_WEIGHTED_EXTENDED_P_SQUARE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_EXTENDED_P_SQUARE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_extended_p_square_impl - // multiple quantile estimation with weighted samples - /** - @brief Multiple quantile estimation with the extended \f$P^2\f$ algorithm for weighted samples - - This version of the extended \f$P^2\f$ algorithm extends the extended \f$P^2\f$ algorithm to - support weighted samples. The extended \f$P^2\f$ algorithm dynamically estimates several - quantiles without storing samples. Assume that \f$m\f$ quantiles - \f$\xi_{p_1}, \ldots, \xi_{p_m}\f$ are to be estimated. Instead of storing the whole sample - cumulative distribution, the algorithm maintains only \f$m+2\f$ principal markers and - \f$m+1\f$ middle markers, whose positions are updated with each sample and whose heights - are adjusted (if necessary) using a piecewise-parablic formula. The heights of the principal - markers are the current estimates of the quantiles and are returned as an iterator range. - - For further details, see - - K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49, - Number 4 (October), 1986, p. 159-164. - - The extended \f$ P^2 \f$ algorithm generalizes the \f$ P^2 \f$ algorithm of - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param extended_p_square_probabilities A vector of quantile probabilities. - */ - template - struct weighted_extended_p_square_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range< - detail::lvalue_index_iterator< - permutation_iterator< - typename array_type::const_iterator - , detail::times2_iterator - > - > - > result_type; - - template - weighted_extended_p_square_impl(Args const &args) - : probabilities( - boost::begin(args[extended_p_square_probabilities]) - , boost::end(args[extended_p_square_probabilities]) - ) - , heights(2 * probabilities.size() + 3) - , actual_positions(heights.size()) - , desired_positions(heights.size()) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - std::size_t sample_cell = 1; // k - std::size_t num_quantiles = this->probabilities.size(); - - // m+2 principal markers and m+1 middle markers - std::size_t num_markers = 2 * num_quantiles + 3; - - // first accumulate num_markers samples - if(cnt <= num_markers) - { - this->heights[cnt - 1] = args[sample]; - this->actual_positions[cnt - 1] = args[weight]; - - // complete the initialization of heights (and actual_positions) by sorting - if(cnt == num_markers) - { - // TODO: we need to sort the initial samples (in heights) in ascending order and - // sort their weights (in actual_positions) the same way. The following lines do - // it, but there must be a better and more efficient way of doing this. - typename array_type::iterator it_begin, it_end, it_min; - - it_begin = this->heights.begin(); - it_end = this->heights.end(); - - std::size_t pos = 0; - - while (it_begin != it_end) - { - it_min = std::min_element(it_begin, it_end); - std::size_t d = std::distance(it_begin, it_min); - std::swap(*it_begin, *it_min); - std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); - ++it_begin; - ++pos; - } - - // calculate correct initial actual positions - for (std::size_t i = 1; i < num_markers; ++i) - { - actual_positions[i] += actual_positions[i - 1]; - } - } - } - else - { - if(args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - this->actual_positions[0] = args[weight]; - sample_cell = 1; - } - else if(args[sample] >= this->heights[num_markers - 1]) - { - this->heights[num_markers - 1] = args[sample]; - sample_cell = num_markers - 1; - } - else - { - // find cell k = sample_cell such that heights[k-1] <= sample < heights[k] - - typedef typename array_type::iterator iterator; - iterator it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // update actual position of all markers above sample_cell - for(std::size_t i = sample_cell; i < num_markers; ++i) - { - this->actual_positions[i] += args[weight]; - } - - // compute desired positions - { - this->desired_positions[0] = this->actual_positions[0]; - this->desired_positions[num_markers - 1] = sum_of_weights(args); - this->desired_positions[1] = (sum_of_weights(args) - this->actual_positions[0]) * probabilities[0] - / 2. + this->actual_positions[0]; - this->desired_positions[num_markers - 2] = (sum_of_weights(args) - this->actual_positions[0]) - * (probabilities[num_quantiles - 1] + 1.) - / 2. + this->actual_positions[0]; - - for (std::size_t i = 0; i < num_quantiles; ++i) - { - this->desired_positions[2 * i + 2] = (sum_of_weights(args) - this->actual_positions[0]) - * probabilities[i] + this->actual_positions[0]; - } - - for (std::size_t i = 1; i < num_quantiles; ++i) - { - this->desired_positions[2 * i + 1] = (sum_of_weights(args) - this->actual_positions[0]) - * (probabilities[i - 1] + probabilities[i]) - / 2. + this->actual_positions[0]; - } - } - - // adjust heights and actual_positions of markers 1 to num_markers - 2 if necessary - for (std::size_t i = 1; i <= num_markers - 2; ++i) - { - // offset to desired position - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; - float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; - - if((d >= 1 && dp > 1) || (d <= -1 && dm < -1)) - { - short sign_d = static_cast(d / std::abs(d)); - - float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm)*hp + (dp - sign_d) * hm); - - // try adjusting heights[i] using p-squared formula - if(this->heights[i - 1] < h && h < this->heights[i + 1]) - { - this->heights[i] = h; - } - else - { - // use linear formula - if(d > 0) - { - this->heights[i] += hp; - } - if(d < 0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - result_type result(dont_care) const - { - // for i in [1,probabilities.size()], return heights[i * 2] - detail::times2_iterator idx_begin = detail::make_times2_iterator(1); - detail::times2_iterator idx_end = detail::make_times2_iterator(this->probabilities.size() + 1); - - return result_type( - make_permutation_iterator(this->heights.begin(), idx_begin) - , make_permutation_iterator(this->heights.begin(), idx_end) - ); - } - - private: - array_type probabilities; // the quantile probabilities - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // d_i - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_extended_p_square -// -namespace tag -{ - struct weighted_extended_p_square - : depends_on - , extended_p_square_probabilities - { - typedef accumulators::impl::weighted_extended_p_square_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_extended_p_square -// -namespace extract -{ - extractor const weighted_extended_p_square = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square) -} - -using extract::weighted_extended_p_square; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_kurtosis.hpp b/boost/accumulators/statistics/weighted_kurtosis.hpp deleted file mode 100644 index 3fd4ed7b411568d471cc369e41c71423a64e752c..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_kurtosis.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_kurtosis.hpp -// -// Copyright 2006 Olivier Gygi, Daniel Egloff. 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_ACCUMULATORS_STATISTICS_WEIGHTED_KURTOSIS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_KURTOSIS_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_kurtosis_impl - /** - @brief Kurtosis estimation for weighted samples - - The kurtosis of a sample distribution is defined as the ratio of the 4th central moment and the square of the 2nd central - moment (the variance) of the samples, minus 3. The term \f$ -3 \f$ is added in order to ensure that the normal distribution - has zero kurtosis. The kurtosis can also be expressed by the simple moments: - - \f[ - \hat{g}_2 = - \frac - {\widehat{m}_n^{(4)}-4\widehat{m}_n^{(3)}\hat{\mu}_n+6\widehat{m}_n^{(2)}\hat{\mu}_n^2-3\hat{\mu}_n^4} - {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^2} - 3, - \f] - - where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the - \f$ n \f$ samples. - - The kurtosis estimator for weighted samples is formally identical to the estimator for unweighted samples, except that - the weighted counterparts of all measures it depends on are to be taken. - */ - template - struct weighted_kurtosis_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - weighted_kurtosis_impl(dont_care) - { - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv( - accumulators::weighted_moment<4>(args) - - 4. * accumulators::weighted_moment<3>(args) * weighted_mean(args) - + 6. * accumulators::weighted_moment<2>(args) * weighted_mean(args) * weighted_mean(args) - - 3. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) - , ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) - * ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) - ) - 3.; - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_kurtosis -// -namespace tag -{ - struct weighted_kurtosis - : depends_on, weighted_moment<3>, weighted_moment<4> > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_kurtosis_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_kurtosis -// -namespace extract -{ - extractor const weighted_kurtosis = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_kurtosis) -} - -using extract::weighted_kurtosis; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_mean.hpp b/boost/accumulators/statistics/weighted_mean.hpp deleted file mode 100644 index a80ef0984c59d26e145060479beef8bf603ae37e..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_mean.hpp +++ /dev/null @@ -1,189 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_mean.hpp -// -// Copyright 2006 Eric Niebler, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_MEAN_HPP_EAN_03_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEAN_HPP_EAN_03_11_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_mean_impl - // lazy, by default - template - struct weighted_mean_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - weighted_mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - typedef - typename mpl::if_< - is_same - , tag::weighted_sum - , tag::weighted_sum_of_variates - >::type - weighted_sum_tag; - - extractor const some_weighted_sum = {}; - - return numeric::fdiv(some_weighted_sum(args), sum_of_weights(args)); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // immediate_weighted_mean_impl - // immediate - template - struct immediate_weighted_mean_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - immediate_weighted_mean_impl(Args const &args) - : mean( - numeric::fdiv( - args[parameter::keyword::get() | Sample()] - * numeric::one::value - , numeric::one::value - ) - ) - { - } - - template - void operator ()(Args const &args) - { - // Matthias: - // need to pass the argument pack since the weight might be an external - // accumulator set passed as a named parameter - Weight w_sum = sum_of_weights(args); - Weight w = args[weight]; - weighted_sample const &s = args[parameter::keyword::get()] * w; - this->mean = numeric::fdiv(this->mean * (w_sum - w) + s, w_sum); - } - - result_type result(dont_care) const - { - return this->mean; - } - - private: - result_type mean; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_mean -// tag::immediate_weighted_mean -// -namespace tag -{ - struct weighted_mean - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_mean_impl impl; - }; - struct immediate_weighted_mean - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_weighted_mean_impl impl; - }; - template - struct weighted_mean_of_variates - : depends_on > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_mean_impl impl; - }; - template - struct immediate_weighted_mean_of_variates - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::immediate_weighted_mean_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_mean -// extract::weighted_mean_of_variates -// -namespace extract -{ - extractor const weighted_mean = {}; - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, weighted_mean_of_variates, (typename)(typename)) - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_mean) -} - -using extract::weighted_mean; -using extract::weighted_mean_of_variates; - -// weighted_mean(lazy) -> weighted_mean -template<> -struct as_feature -{ - typedef tag::weighted_mean type; -}; - -// weighted_mean(immediate) -> immediate_weighted_mean -template<> -struct as_feature -{ - typedef tag::immediate_weighted_mean type; -}; - -// weighted_mean_of_variates(lazy) -> weighted_mean_of_variates -template -struct as_feature(lazy)> -{ - typedef tag::weighted_mean_of_variates type; -}; - -// weighted_mean_of_variates(immediate) -> immediate_weighted_mean_of_variates -template -struct as_feature(immediate)> -{ - typedef tag::immediate_weighted_mean_of_variates type; -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_median.hpp b/boost/accumulators/statistics/weighted_median.hpp deleted file mode 100644 index ed7cadb331c60e0b16975a519425b996f05a2ccf..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_median.hpp +++ /dev/null @@ -1,237 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_median.hpp -// -// Copyright 2006 Eric Niebler, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_MEDIAN_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEDIAN_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_median_impl - // - /** - @brief Median estimation for weighted samples based on the \f$P^2\f$ quantile estimator - - The \f$P^2\f$ algorithm for weighted samples is invoked with a quantile probability of 0.5. - */ - template - struct weighted_median_impl - : accumulator_base - { - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - weighted_median_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - return weighted_p_square_quantile_for_median(args); - } - }; - - /////////////////////////////////////////////////////////////////////////////// - // with_density_weighted_median_impl - // - /** - @brief Median estimation for weighted samples based on the density estimator - - The algorithm determines the bin in which the \f$0.5*cnt\f$-th sample lies, \f$cnt\f$ being - the total number of samples. It returns the approximate horizontal position of this sample, - based on a linear interpolation inside the bin. - */ - template - struct with_density_weighted_median_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef iterator_range range_type; - // for boost::result_of - typedef float_type result_type; - - template - with_density_weighted_median_impl(Args const &args) - : sum(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , is_dirty(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty = true; - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - std::size_t cnt = count(args); - range_type histogram = weighted_density(args); - typename range_type::iterator it = histogram.begin(); - while (this->sum < 0.5 * cnt) - { - this->sum += it->second * cnt; - ++it; - } - --it; - float_type over = numeric::fdiv(this->sum - 0.5 * cnt, it->second * cnt); - this->median = it->first * over + (it + 1)->first * ( 1. - over ); - } - - return this->median; - } - - private: - mutable float_type sum; - mutable bool is_dirty; - mutable float_type median; - }; - - /////////////////////////////////////////////////////////////////////////////// - // with_p_square_cumulative_distribution_weighted_median_impl - // - /** - @brief Median estimation for weighted samples based on the \f$P^2\f$ cumulative distribution estimator - - The algorithm determines the first (leftmost) bin with a height exceeding 0.5. It - returns the approximate horizontal position of where the cumulative distribution - equals 0.5, based on a linear interpolation inside the bin. - */ - template - struct with_p_square_cumulative_distribution_weighted_median_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef iterator_range range_type; - // for boost::result_of - typedef float_type result_type; - - with_p_square_cumulative_distribution_weighted_median_impl(dont_care) - : is_dirty(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty = true; - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - range_type histogram = weighted_p_square_cumulative_distribution(args); - typename range_type::iterator it = histogram.begin(); - while (it->second < 0.5) - { - ++it; - } - float_type over = numeric::fdiv(it->second - 0.5, it->second - (it - 1)->second); - this->median = it->first * over + (it + 1)->first * ( 1. - over ); - } - - return this->median; - } - private: - mutable bool is_dirty; - mutable float_type median; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_median -// tag::with_density_weighted_median -// tag::with_p_square_cumulative_distribution_weighted_median -// -namespace tag -{ - struct weighted_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_median_impl impl; - }; - struct with_density_weighted_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::with_density_weighted_median_impl impl; - }; - struct with_p_square_cumulative_distribution_weighted_median - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::with_p_square_cumulative_distribution_weighted_median_impl impl; - }; - -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_median -// -namespace extract -{ - extractor const weighted_median = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_median) -} - -using extract::weighted_median; -// weighted_median(with_p_square_quantile) -> weighted_median -template<> -struct as_feature -{ - typedef tag::weighted_median type; -}; - -// weighted_median(with_density) -> with_density_weighted_median -template<> -struct as_feature -{ - typedef tag::with_density_weighted_median type; -}; - -// weighted_median(with_p_square_cumulative_distribution) -> with_p_square_cumulative_distribution_weighted_median -template<> -struct as_feature -{ - typedef tag::with_p_square_cumulative_distribution_weighted_median type; -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_moment.hpp b/boost/accumulators/statistics/weighted_moment.hpp deleted file mode 100644 index 011701c7047cc09297dc460ffec442d0ac107cce..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_moment.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_moment.hpp -// -// Copyright 2006, Eric Niebler, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_MOMENT_HPP_EAN_15_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MOMENT_HPP_EAN_15_11_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for pow() -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_moment_impl - template - struct weighted_moment_impl - : accumulator_base // TODO: also depends_on sum of powers - { - BOOST_MPL_ASSERT_RELATION(N::value, >, 0); - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - weighted_moment_impl(Args const &args) - : sum(args[sample | Sample()] * numeric::one::value) - { - } - - template - void operator ()(Args const &args) - { - this->sum += args[weight] * numeric::pow(args[sample], N()); - } - - template - result_type result(Args const &args) const - { - return numeric::fdiv(this->sum, sum_of_weights(args)); - } - - private: - weighted_sample sum; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_moment -// -namespace tag -{ - template - struct weighted_moment - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_moment_impl, mpl::_1, mpl::_2> impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_moment -// -namespace extract -{ - BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, weighted_moment, (int)) -} - -using extract::weighted_moment; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp b/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp deleted file mode 100644 index ce750ed1f51940cf270b12693bcc0218f6255b87..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp +++ /dev/null @@ -1,262 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_p_square_cumul_dist.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMUL_DIST_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMUL_DIST_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for named parameter p_square_cumulative_distribution_num_cells - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_p_square_cumulative_distribution_impl - // cumulative distribution calculation (as histogram) - /** - @brief Histogram calculation of the cumulative distribution with the \f$P^2\f$ algorithm for weighted samples - - A histogram of the sample cumulative distribution is computed dynamically without storing samples - based on the \f$ P^2 \f$ algorithm for weighted samples. The returned histogram has a specifiable - amount (num_cells) equiprobable (and not equal-sized) cells. - - Note that applying importance sampling results in regions to be more and other regions to be less - accurately estimated than without importance sampling, i.e., with unweighted samples. - - For further details, see - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param p_square_cumulative_distribution_num_cells - */ - template - struct weighted_p_square_cumulative_distribution_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - typedef std::vector > histogram_type; - typedef std::vector array_type; - // for boost::result_of - typedef iterator_range result_type; - - template - weighted_p_square_cumulative_distribution_impl(Args const &args) - : num_cells(args[p_square_cumulative_distribution_num_cells]) - , heights(num_cells + 1) - , actual_positions(num_cells + 1) - , desired_positions(num_cells + 1) - , histogram(num_cells + 1) - , is_dirty(true) - { - } - - template - void operator ()(Args const &args) - { - this->is_dirty = true; - - std::size_t cnt = count(args); - std::size_t sample_cell = 1; // k - std::size_t b = this->num_cells; - - // accumulate num_cells + 1 first samples - if (cnt <= b + 1) - { - this->heights[cnt - 1] = args[sample]; - this->actual_positions[cnt - 1] = args[weight]; - - // complete the initialization of heights by sorting - if (cnt == b + 1) - { - //std::sort(this->heights.begin(), this->heights.end()); - - // TODO: we need to sort the initial samples (in heights) in ascending order and - // sort their weights (in actual_positions) the same way. The following lines do - // it, but there must be a better and more efficient way of doing this. - typename array_type::iterator it_begin, it_end, it_min; - - it_begin = this->heights.begin(); - it_end = this->heights.end(); - - std::size_t pos = 0; - - while (it_begin != it_end) - { - it_min = std::min_element(it_begin, it_end); - std::size_t d = std::distance(it_begin, it_min); - std::swap(*it_begin, *it_min); - std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); - ++it_begin; - ++pos; - } - - // calculate correct initial actual positions - for (std::size_t i = 1; i < b; ++i) - { - this->actual_positions[i] += this->actual_positions[i - 1]; - } - } - } - else - { - // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values - if (args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - this->actual_positions[0] = args[weight]; - sample_cell = 1; - } - else if (this->heights[b] <= args[sample]) - { - this->heights[b] = args[sample]; - sample_cell = b; - } - else - { - typename array_type::iterator it; - it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // increment positions of markers above sample_cell - for (std::size_t i = sample_cell; i < b + 1; ++i) - { - this->actual_positions[i] += args[weight]; - } - - // determine desired marker positions - for (std::size_t i = 1; i < b + 1; ++i) - { - this->desired_positions[i] = this->actual_positions[0] - + numeric::fdiv((i-1) * (sum_of_weights(args) - this->actual_positions[0]), b); - } - - // adjust heights of markers 2 to num_cells if necessary - for (std::size_t i = 1; i < b; ++i) - { - // offset to desire position - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; - float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; - - if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) - { - short sign_d = static_cast(d / std::abs(d)); - - // try adjusting heights[i] using p-squared formula - float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); - - if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) - { - this->heights[i] = h; - } - else - { - // use linear formula - if (d>0) - { - this->heights[i] += hp; - } - if (d<0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty) - { - this->is_dirty = false; - - // creates a vector of std::pair where each pair i holds - // the values heights[i] (x-axis of histogram) and - // actual_positions[i] / sum_of_weights (y-axis of histogram) - - for (std::size_t i = 0; i < this->histogram.size(); ++i) - { - this->histogram[i] = std::make_pair(this->heights[i], numeric::fdiv(this->actual_positions[i], sum_of_weights(args))); - } - } - - return make_iterator_range(this->histogram); - } - - private: - std::size_t num_cells; // number of cells b - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // n'_i - mutable histogram_type histogram; // histogram - mutable bool is_dirty; - }; - -} // namespace detail - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_p_square_cumulative_distribution -// -namespace tag -{ - struct weighted_p_square_cumulative_distribution - : depends_on - , p_square_cumulative_distribution_num_cells - { - typedef accumulators::impl::weighted_p_square_cumulative_distribution_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_p_square_cumulative_distribution -// -namespace extract -{ - extractor const weighted_p_square_cumulative_distribution = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_cumulative_distribution) -} - -using extract::weighted_p_square_cumulative_distribution; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp b/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp deleted file mode 100644 index 918970e8dc739ddc939c14df9990c7df37b60fae..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_p_square_cumulative_distribution.hpp -// -// 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_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_03_19_2012 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_03_19_2012 - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__) -# pragma message ("Warning: This header is deprecated. Please use: boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp") -#elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__) -# warning "This header is deprecated. Please use: boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp" -#endif - -#include - -#endif diff --git a/boost/accumulators/statistics/weighted_p_square_quantile.hpp b/boost/accumulators/statistics/weighted_p_square_quantile.hpp deleted file mode 100644 index 2ebc7b184512f8a1c376cb9c0436f0b47d3e8825..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_p_square_quantile.hpp +++ /dev/null @@ -1,255 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_p_square_quantile.hpp -// -// Copyright 2005 Daniel Egloff. 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_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl { - /////////////////////////////////////////////////////////////////////////////// - // weighted_p_square_quantile_impl - // single quantile estimation with weighted samples - /** - @brief Single quantile estimation with the \f$P^2\f$ algorithm for weighted samples - - This version of the \f$P^2\f$ algorithm extends the \f$P^2\f$ algorithm to support weighted samples. - The \f$P^2\f$ algorithm estimates a quantile dynamically without storing samples. Instead of - storing the whole sample cumulative distribution, only five points (markers) are stored. The heights - of these markers are the minimum and the maximum of the samples and the current estimates of the - \f$(p/2)\f$-, \f$p\f$ - and \f$(1+p)/2\f$ -quantiles. Their positions are equal to the number - of samples that are smaller or equal to the markers. Each time a new sample is added, the - positions of the markers are updated and if necessary their heights are adjusted using a piecewise- - parabolic formula. - - For further details, see - - R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and - histograms without storing observations, Communications of the ACM, - Volume 28 (October), Number 10, 1985, p. 1076-1085. - - @param quantile_probability - */ - template - struct weighted_p_square_quantile_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - typedef array array_type; - // for boost::result_of - typedef float_type result_type; - - template - weighted_p_square_quantile_impl(Args const &args) - : p(is_same::value ? 0.5 : args[quantile_probability | 0.5]) - , heights() - , actual_positions() - , desired_positions() - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - // accumulate 5 first samples - if (cnt <= 5) - { - this->heights[cnt - 1] = args[sample]; - - // In this initialization phase, actual_positions stores the weights of the - // initial samples that are needed at the end of the initialization phase to - // compute the correct initial positions of the markers. - this->actual_positions[cnt - 1] = args[weight]; - - // complete the initialization of heights and actual_positions by sorting - if (cnt == 5) - { - // TODO: we need to sort the initial samples (in heights) in ascending order and - // sort their weights (in actual_positions) the same way. The following lines do - // it, but there must be a better and more efficient way of doing this. - typename array_type::iterator it_begin, it_end, it_min; - - it_begin = this->heights.begin(); - it_end = this->heights.end(); - - std::size_t pos = 0; - - while (it_begin != it_end) - { - it_min = std::min_element(it_begin, it_end); - std::size_t d = std::distance(it_begin, it_min); - std::swap(*it_begin, *it_min); - std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); - ++it_begin; - ++pos; - } - - // calculate correct initial actual positions - for (std::size_t i = 1; i < 5; ++i) - { - this->actual_positions[i] += this->actual_positions[i - 1]; - } - } - } - else - { - std::size_t sample_cell = 1; // k - - // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values - if (args[sample] < this->heights[0]) - { - this->heights[0] = args[sample]; - this->actual_positions[0] = args[weight]; - sample_cell = 1; - } - else if (this->heights[4] <= args[sample]) - { - this->heights[4] = args[sample]; - sample_cell = 4; - } - else - { - typedef typename array_type::iterator iterator; - iterator it = std::upper_bound( - this->heights.begin() - , this->heights.end() - , args[sample] - ); - - sample_cell = std::distance(this->heights.begin(), it); - } - - // increment positions of markers above sample_cell - for (std::size_t i = sample_cell; i < 5; ++i) - { - this->actual_positions[i] += args[weight]; - } - - // update desired positions for all markers - this->desired_positions[0] = this->actual_positions[0]; - this->desired_positions[1] = (sum_of_weights(args) - this->actual_positions[0]) - * this->p/2. + this->actual_positions[0]; - this->desired_positions[2] = (sum_of_weights(args) - this->actual_positions[0]) - * this->p + this->actual_positions[0]; - this->desired_positions[3] = (sum_of_weights(args) - this->actual_positions[0]) - * (1. + this->p)/2. + this->actual_positions[0]; - this->desired_positions[4] = sum_of_weights(args); - - // adjust height and actual positions of markers 1 to 3 if necessary - for (std::size_t i = 1; i <= 3; ++i) - { - // offset to desired positions - float_type d = this->desired_positions[i] - this->actual_positions[i]; - - // offset to next position - float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; - - // offset to previous position - float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; - - // height ds - float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; - float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; - - if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) - { - short sign_d = static_cast(d / std::abs(d)); - - // try adjusting heights[i] using p-squared formula - float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); - - if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) - { - this->heights[i] = h; - } - else - { - // use linear formula - if (d>0) - { - this->heights[i] += hp; - } - if (d<0) - { - this->heights[i] -= hm; - } - } - this->actual_positions[i] += sign_d; - } - } - } - } - - result_type result(dont_care) const - { - return this->heights[2]; - } - - private: - float_type p; // the quantile probability p - array_type heights; // q_i - array_type actual_positions; // n_i - array_type desired_positions; // n'_i - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_p_square_quantile -// -namespace tag -{ - struct weighted_p_square_quantile - : depends_on - { - typedef accumulators::impl::weighted_p_square_quantile_impl impl; - }; - struct weighted_p_square_quantile_for_median - : depends_on - { - typedef accumulators::impl::weighted_p_square_quantile_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_p_square_quantile -// extract::weighted_p_square_quantile_for_median -// -namespace extract -{ - extractor const weighted_p_square_quantile = {}; - extractor const weighted_p_square_quantile_for_median = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_quantile) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_quantile_for_median) -} - -using extract::weighted_p_square_quantile; -using extract::weighted_p_square_quantile_for_median; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp b/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp deleted file mode 100644 index 418b38cfe04aef107008c064b1346bcb4c562c1e..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_peaks_over_threshold.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for named parameters pot_threshold_value and pot_threshold_probability -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - /////////////////////////////////////////////////////////////////////////////// - // weighted_peaks_over_threshold_impl - // works with an explicit threshold value and does not depend on order statistics of weighted samples - /** - @brief Weighted Peaks over Threshold Method for Weighted Quantile and Weighted Tail Mean Estimation - - @sa peaks_over_threshold_impl - - @param quantile_probability - @param pot_threshold_value - */ - template - struct weighted_peaks_over_threshold_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef boost::tuple result_type; - - template - weighted_peaks_over_threshold_impl(Args const &args) - : sign_((is_same::value) ? -1 : 1) - , mu_(sign_ * numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , w_sum_(numeric::fdiv(args[weight | Weight()], (std::size_t)1)) - , threshold_(sign_ * args[pot_threshold_value]) - , fit_parameters_(boost::make_tuple(0., 0., 0.)) - , is_dirty_(true) - { - } - - template - void operator ()(Args const &args) - { - this->is_dirty_ = true; - - if (this->sign_ * args[sample] > this->threshold_) - { - this->mu_ += args[weight] * args[sample]; - this->sigma2_ += args[weight] * args[sample] * args[sample]; - this->w_sum_ += args[weight]; - } - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty_) - { - this->is_dirty_ = false; - - this->mu_ = this->sign_ * numeric::fdiv(this->mu_, this->w_sum_); - this->sigma2_ = numeric::fdiv(this->sigma2_, this->w_sum_); - this->sigma2_ -= this->mu_ * this->mu_; - - float_type threshold_probability = numeric::fdiv(sum_of_weights(args) - this->w_sum_, sum_of_weights(args)); - - float_type tmp = numeric::fdiv(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_); - float_type xi_hat = 0.5 * ( 1. - tmp ); - float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp ); - float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat); - float_type u_bar = this->threshold_ - beta_bar * ( std::pow(1. - threshold_probability, -xi_hat) - 1.)/xi_hat; - this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); - } - - return this->fit_parameters_; - } - - private: - short sign_; // for left tail fitting, mirror the extreme values - mutable float_type mu_; // mean of samples above threshold - mutable float_type sigma2_; // variance of samples above threshold - mutable float_type w_sum_; // sum of weights of samples above threshold - float_type threshold_; - mutable result_type fit_parameters_; // boost::tuple that stores fit parameters - mutable bool is_dirty_; - }; - - /////////////////////////////////////////////////////////////////////////////// - // weighted_peaks_over_threshold_prob_impl - // determines threshold from a given threshold probability using order statistics - /** - @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation - - @sa weighted_peaks_over_threshold_impl - - @param quantile_probability - @param pot_threshold_probability - */ - template - struct weighted_peaks_over_threshold_prob_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef boost::tuple result_type; - - template - weighted_peaks_over_threshold_prob_impl(Args const &args) - : sign_((is_same::value) ? -1 : 1) - , mu_(sign_ * numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) - , threshold_probability_(args[pot_threshold_probability]) - , fit_parameters_(boost::make_tuple(0., 0., 0.)) - , is_dirty_(true) - { - } - - void operator ()(dont_care) - { - this->is_dirty_ = true; - } - - template - result_type result(Args const &args) const - { - if (this->is_dirty_) - { - this->is_dirty_ = false; - - float_type threshold = sum_of_weights(args) - * ( ( is_same::value ) ? this->threshold_probability_ : 1. - this->threshold_probability_ ); - - std::size_t n = 0; - Weight sum = Weight(0); - - while (sum < threshold) - { - if (n < static_cast(tail_weights(args).size())) - { - mu_ += *(tail_weights(args).begin() + n) * *(tail(args).begin() + n); - sigma2_ += *(tail_weights(args).begin() + n) * *(tail(args).begin() + n) * (*(tail(args).begin() + n)); - sum += *(tail_weights(args).begin() + n); - n++; - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - return boost::make_tuple( - std::numeric_limits::quiet_NaN() - , std::numeric_limits::quiet_NaN() - , std::numeric_limits::quiet_NaN() - ); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return boost::make_tuple(Sample(0), Sample(0), Sample(0)); - } - } - } - - float_type u = *(tail(args).begin() + n - 1) * this->sign_; - - - this->mu_ = this->sign_ * numeric::fdiv(this->mu_, sum); - this->sigma2_ = numeric::fdiv(this->sigma2_, sum); - this->sigma2_ -= this->mu_ * this->mu_; - - if (is_same::value) - this->threshold_probability_ = 1. - this->threshold_probability_; - - float_type tmp = numeric::fdiv(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_); - float_type xi_hat = 0.5 * ( 1. - tmp ); - float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp ); - float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat); - float_type u_bar = u - beta_bar * ( std::pow(1. - threshold_probability_, -xi_hat) - 1.)/xi_hat; - this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); - - } - - return this->fit_parameters_; - } - - private: - short sign_; // for left tail fitting, mirror the extreme values - mutable float_type mu_; // mean of samples above threshold u - mutable float_type sigma2_; // variance of samples above threshold u - mutable float_type threshold_probability_; - mutable result_type fit_parameters_; // boost::tuple that stores fit parameters - mutable bool is_dirty_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_peaks_over_threshold -// -namespace tag -{ - template - struct weighted_peaks_over_threshold - : depends_on - , pot_threshold_value - { - /// INTERNAL ONLY - typedef accumulators::impl::weighted_peaks_over_threshold_impl impl; - }; - - template - struct weighted_peaks_over_threshold_prob - : depends_on > - , pot_threshold_probability - { - /// INTERNAL ONLY - typedef accumulators::impl::weighted_peaks_over_threshold_prob_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_peaks_over_threshold -// -namespace extract -{ - extractor const weighted_peaks_over_threshold = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_peaks_over_threshold) -} - -using extract::weighted_peaks_over_threshold; - -// weighted_peaks_over_threshold(with_threshold_value) -> weighted_peaks_over_threshold -template -struct as_feature(with_threshold_value)> -{ - typedef tag::weighted_peaks_over_threshold type; -}; - -// weighted_peaks_over_threshold(with_threshold_probability) -> weighted_peaks_over_threshold_prob -template -struct as_feature(with_threshold_probability)> -{ - typedef tag::weighted_peaks_over_threshold_prob type; -}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/weighted_skewness.hpp b/boost/accumulators/statistics/weighted_skewness.hpp deleted file mode 100644 index a3ac3876f554fd0e3cb1ea2b8be58d30ed036862..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_skewness.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_skewness.hpp -// -// Copyright 2006 Olivier Gygi, Daniel Egloff. 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_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_skewness_impl - /** - @brief Skewness estimation for weighted samples - - The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$ 3/2 \f$-th power $ - of the 2nd central moment (the variance) of the samples. The skewness can also be expressed by the simple moments: - - \f[ - \hat{g}_1 = - \frac - {\widehat{m}_n^{(3)}-3\widehat{m}_n^{(2)}\hat{\mu}_n+2\hat{\mu}_n^3} - {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^{3/2}} - \f] - - where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the - \f$ n \f$ samples. - - The skewness estimator for weighted samples is formally identical to the estimator for unweighted samples, except that - the weighted counterparts of all measures it depends on are to be taken. - */ - template - struct weighted_skewness_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - weighted_skewness_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - return numeric::fdiv( - accumulators::weighted_moment<3>(args) - - 3. * accumulators::weighted_moment<2>(args) * weighted_mean(args) - + 2. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) - , ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) - * std::sqrt( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) - ); - } - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_skewness -// -namespace tag -{ - struct weighted_skewness - : depends_on, weighted_moment<3> > - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_skewness_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_skewness -// -namespace extract -{ - extractor const weighted_skewness = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_skewness) -} - -using extract::weighted_skewness; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_sum.hpp b/boost/accumulators/statistics/weighted_sum.hpp deleted file mode 100644 index 27153906d0b933ee2f7c5a2b41d830fd5ad3dec6..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_sum.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_sum.hpp -// -// Copyright 2006 Eric Niebler, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_sum_impl - template - struct weighted_sum_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - - // for boost::result_of - typedef weighted_sample result_type; - - template - weighted_sum_impl(Args const &args) - : weighted_sum_( - args[parameter::keyword::get() | Sample()] - * numeric::one::value - ) - { - } - - template - void operator ()(Args const &args) - { - // what about overflow? - this->weighted_sum_ += args[parameter::keyword::get()] * args[weight]; - } - - result_type result(dont_care) const - { - return this->weighted_sum_; - } - - private: - - weighted_sample weighted_sum_; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_sum -// -namespace tag -{ - struct weighted_sum - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_sum_impl impl; - }; - - template - struct weighted_sum_of_variates - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_sum_impl impl; - }; - - struct abstract_weighted_sum_of_variates - : depends_on<> - { - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_sum -// -namespace extract -{ - extractor const weighted_sum = {}; - extractor const weighted_sum_of_variates = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_of_variates) -} - -using extract::weighted_sum; -using extract::weighted_sum_of_variates; - -template -struct feature_of > - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_sum_kahan.hpp b/boost/accumulators/statistics/weighted_sum_kahan.hpp deleted file mode 100644 index fbb0303accf8243a9a75ace2f87d98b880c6f7aa..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_sum_kahan.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_sum_kahan.hpp -// -// Copyright 2011 Simon West. 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_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ -#if _MSC_VER > 1400 -# pragma float_control(push) -# pragma float_control(precise, on) -#endif - - /////////////////////////////////////////////////////////////////////////////// - // weighted_sum_kahan_impl - template - struct weighted_sum_kahan_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - - // for boost::result_of - typedef weighted_sample result_type; - - template - weighted_sum_kahan_impl(Args const &args) - : weighted_sum_( - args[parameter::keyword::get() | Sample()] * numeric::one::value), - compensation(boost::numeric_cast(0.0)) - { - } - - template - void -#if BOOST_ACCUMULATORS_GCC_VERSION > 40305 - __attribute__((__optimize__("no-associative-math"))) -#endif - operator ()(Args const &args) - { - const weighted_sample myTmp1 = args[parameter::keyword::get()] * args[weight] - this->compensation; - const weighted_sample myTmp2 = this->weighted_sum_ + myTmp1; - this->compensation = (myTmp2 - this->weighted_sum_) - myTmp1; - this->weighted_sum_ = myTmp2; - - } - - result_type result(dont_care) const - { - return this->weighted_sum_; - } - - private: - weighted_sample weighted_sum_; - weighted_sample compensation; - }; - -#if _MSC_VER > 1400 -# pragma float_control(pop) -#endif - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_sum_kahan -// tag::weighted_sum_of_variates_kahan -// -namespace tag -{ - struct weighted_sum_kahan - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_sum_kahan_impl impl; - }; - - template - struct weighted_sum_of_variates_kahan - : depends_on<> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_sum_kahan_impl impl; - }; - -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_sum_kahan -// extract::weighted_sum_of_variates_kahan -// -namespace extract -{ - extractor const weighted_sum_kahan = {}; - extractor const weighted_sum_of_variates_kahan = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_kahan) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_of_variates_kahan) -} - -using extract::weighted_sum_kahan; -using extract::weighted_sum_of_variates_kahan; - -// weighted_sum(kahan) -> weighted_sum_kahan -template<> -struct as_feature -{ - typedef tag::weighted_sum_kahan type; -}; - -template -struct feature_of > - : feature_of -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/weighted_tail_mean.hpp b/boost/accumulators/statistics/weighted_tail_mean.hpp deleted file mode 100644 index bae8530674ebbdc34352a7c0c37ac2bfb1ef4d4a..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_tail_mean.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_tail_mean.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_MEAN_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_MEAN_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - - /////////////////////////////////////////////////////////////////////////////// - // coherent_weighted_tail_mean_impl - // - // TODO - - /////////////////////////////////////////////////////////////////////////////// - // non_coherent_weighted_tail_mean_impl - // - /** - @brief Estimation of the (non-coherent) weighted tail mean based on order statistics (for both left and right tails) - - - - An estimation of the non-coherent, weighted tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ is given by the weighted mean - of the - - \f[ - \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} - \f] - - smallest samples (left tail) or the weighted mean of the - - \f[ - n + 1 - \rho = n + 1 - \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\} - \f] - - largest samples (right tail) above a quantile \f$\hat{q}_{\alpha}\f$ of level \f$\alpha\f$, \f$n\f$ being the total number of sample - and \f$\bar{w}_n\f$ the sum of all \f$n\f$ weights: - - \f[ - \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) = \frac{\sum_{i=1}^{\lambda} w_i X_{i:n}}{\sum_{i=1}^{\lambda} w_i}, - \f] - - \f[ - \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) = \frac{\sum_{i=\rho}^n w_i X_{i:n}}{\sum_{i=\rho}^n w_i}. - \f] - - @param quantile_probability - */ - template - struct non_coherent_weighted_tail_mean_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - non_coherent_weighted_tail_mean_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - float_type threshold = sum_of_weights(args) - * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); - - std::size_t n = 0; - Weight sum = Weight(0); - - while (sum < threshold) - { - if (n < static_cast(tail_weights(args).size())) - { - sum += *(tail_weights(args).begin() + n); - n++; - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - return std::numeric_limits::quiet_NaN(); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return result_type(0); - } - } - } - - return numeric::fdiv( - std::inner_product( - tail(args).begin() - , tail(args).begin() + n - , tail_weights(args).begin() - , weighted_sample(0) - ) - , sum - ); - } - }; - -} // namespace impl - - -/////////////////////////////////////////////////////////////////////////////// -// tag::non_coherent_weighted_tail_mean<> -// -namespace tag -{ - template - struct non_coherent_weighted_tail_mean - : depends_on > - { - typedef accumulators::impl::non_coherent_weighted_tail_mean_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::non_coherent_weighted_tail_mean; -// -namespace extract -{ - extractor const non_coherent_weighted_tail_mean = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(non_coherent_weighted_tail_mean) -} - -using extract::non_coherent_weighted_tail_mean; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/weighted_tail_quantile.hpp b/boost/accumulators/statistics/weighted_tail_quantile.hpp deleted file mode 100644 index b143457dd0fb71b2dae99d01e9b3983eeb0c1330..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_tail_quantile.hpp +++ /dev/null @@ -1,146 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_tail_quantile.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // weighted_tail_quantile_impl - // Tail quantile estimation based on order statistics of weighted samples - /** - @brief Tail quantile estimation based on order statistics of weighted samples (for both left and right tails) - - An estimator \f$\hat{q}\f$ of tail quantiles with level \f$\alpha\f$ based on order statistics - \f$X_{1:n} \leq X_{2:n} \leq\dots\leq X_{n:n}\f$ of weighted samples are given by \f$X_{\lambda:n}\f$ (left tail) - and \f$X_{\rho:n}\f$ (right tail), where - - \f[ - \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} - \f] - - and - - \f[ - \rho = \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\}, - \f] - - \f$n\f$ being the number of samples and \f$\bar{w}_n\f$ the sum of all weights. - - @param quantile_probability - */ - template - struct weighted_tail_quantile_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - // for boost::result_of - typedef Sample result_type; - - weighted_tail_quantile_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - float_type threshold = sum_of_weights(args) - * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); - - std::size_t n = 0; - Weight sum = Weight(0); - - while (sum < threshold) - { - if (n < static_cast(tail_weights(args).size())) - { - sum += *(tail_weights(args).begin() + n); - n++; - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - return std::numeric_limits::quiet_NaN(); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - return Sample(0); - } - } - } - - // Note that the cached samples of the left are sorted in ascending order, - // whereas the samples of the right tail are sorted in descending order - return *(boost::begin(tail(args)) + n - 1); - } - }; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_tail_quantile<> -// -namespace tag -{ - template - struct weighted_tail_quantile - : depends_on > - { - /// INTERNAL ONLY - typedef accumulators::impl::weighted_tail_quantile_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_tail_quantile -// -namespace extract -{ - extractor const weighted_tail_quantile = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_tail_quantile) -} - -using extract::weighted_tail_quantile; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/weighted_tail_variate_means.hpp b/boost/accumulators/statistics/weighted_tail_variate_means.hpp deleted file mode 100644 index b1133109edaf837b394bad5d7344ddc0cdf29d27..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_tail_variate_means.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_tail_variate_means.hpp -// -// Copyright 2006 Daniel Egloff, Olivier Gygi. 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_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost -{ - // for _BinaryOperatrion2 in std::inner_product below - // multiplies two values and promotes the result to double - namespace numeric { namespace functional - { - /////////////////////////////////////////////////////////////////////////////// - // numeric::functional::multiply_and_promote_to_double - template - struct multiply_and_promote_to_double - : multiplies - { - }; - }} -} - -namespace boost { namespace accumulators -{ - -namespace impl -{ - /** - @brief Estimation of the absolute and relative weighted tail variate means (for both left and right tails) - - For all \f$j\f$-th variates associated to the - - \f[ - \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} - \f] - - smallest samples (left tail) or the weighted mean of the - - \f[ - n + 1 - \rho = n + 1 - \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\} - \f] - - largest samples (right tail), the absolute weighted tail means \f$\widehat{ATM}_{n,\alpha}(X, j)\f$ - are computed and returned as an iterator range. Alternatively, the relative weighted tail means - \f$\widehat{RTM}_{n,\alpha}(X, j)\f$ are returned, which are the absolute weighted tail means - normalized with the weighted (non-coherent) sample tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$. - - \f[ - \widehat{ATM}_{n,\alpha}^{\mathrm{right}}(X, j) = - \frac{1}{\sum_{i=\rho}^n w_i} - \sum_{i=\rho}^n w_i \xi_{j,i} - \f] - - \f[ - \widehat{ATM}_{n,\alpha}^{\mathrm{left}}(X, j) = - \frac{1}{\sum_{i=1}^{\lambda}} - \sum_{i=1}^{\lambda} w_i \xi_{j,i} - \f] - - \f[ - \widehat{RTM}_{n,\alpha}^{\mathrm{right}}(X, j) = - \frac{\sum_{i=\rho}^n w_i \xi_{j,i}} - {\sum_{i=\rho}^n w_i \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X)} - \f] - - \f[ - \widehat{RTM}_{n,\alpha}^{\mathrm{left}}(X, j) = - \frac{\sum_{i=1}^{\lambda} w_i \xi_{j,i}} - {\sum_{i=1}^{\lambda} w_i \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X)} - \f] - */ - - /////////////////////////////////////////////////////////////////////////////// - // weighted_tail_variate_means_impl - // by default: absolute weighted_tail_variate_means - template - struct weighted_tail_variate_means_impl - : accumulator_base - { - typedef typename numeric::functional::fdiv::result_type float_type; - typedef typename numeric::functional::fdiv::result_type, Weight>::result_type array_type; - // for boost::result_of - typedef iterator_range result_type; - - weighted_tail_variate_means_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - float_type threshold = sum_of_weights(args) - * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); - - std::size_t n = 0; - Weight sum = Weight(0); - - while (sum < threshold) - { - if (n < static_cast(tail_weights(args).size())) - { - sum += *(tail_weights(args).begin() + n); - n++; - } - else - { - if (std::numeric_limits::has_quiet_NaN) - { - std::fill( - this->tail_means_.begin() - , this->tail_means_.end() - , std::numeric_limits::quiet_NaN() - ); - } - else - { - std::ostringstream msg; - msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; - boost::throw_exception(std::runtime_error(msg.str())); - } - } - } - - std::size_t num_variates = tail_variate(args).begin()->size(); - - this->tail_means_.clear(); - this->tail_means_.resize(num_variates, Sample(0)); - - this->tail_means_ = std::inner_product( - tail_variate(args).begin() - , tail_variate(args).begin() + n - , tail_weights(args).begin() - , this->tail_means_ - , numeric::functional::plus() - , numeric::functional::multiply_and_promote_to_double() - ); - - float_type factor = sum * ( (is_same::value) ? non_coherent_weighted_tail_mean(args) : 1. ); - - std::transform( - this->tail_means_.begin() - , this->tail_means_.end() - , this->tail_means_.begin() -#ifdef BOOST_NO_CXX98_BINDERS - , std::bind(numeric::functional::divides(), std::placeholders::_1, factor) -#else - , std::bind2nd(numeric::functional::divides(), factor) -#endif - ); - - return make_iterator_range(this->tail_means_); - } - - private: - - mutable array_type tail_means_; - - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::absolute_weighted_tail_variate_means -// tag::relative_weighted_tail_variate_means -// -namespace tag -{ - template - struct absolute_weighted_tail_variate_means - : depends_on, tail_variate, tail_weights > - { - typedef accumulators::impl::weighted_tail_variate_means_impl impl; - }; - template - struct relative_weighted_tail_variate_means - : depends_on, tail_variate, tail_weights > - { - typedef accumulators::impl::weighted_tail_variate_means_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_tail_variate_means -// extract::relative_weighted_tail_variate_means -// -namespace extract -{ - extractor const weighted_tail_variate_means = {}; - extractor const relative_weighted_tail_variate_means = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_tail_variate_means) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(relative_weighted_tail_variate_means) -} - -using extract::weighted_tail_variate_means; -using extract::relative_weighted_tail_variate_means; - -// weighted_tail_variate_means(absolute) -> absolute_weighted_tail_variate_means -template -struct as_feature(absolute)> -{ - typedef tag::absolute_weighted_tail_variate_means type; -}; - -// weighted_tail_variate_means(relative) -> relative_weighted_tail_variate_means -template -struct as_feature(relative)> -{ - typedef tag::relative_weighted_tail_variate_means type; -}; - -}} // namespace boost::accumulators - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif diff --git a/boost/accumulators/statistics/weighted_variance.hpp b/boost/accumulators/statistics/weighted_variance.hpp deleted file mode 100644 index bc199affa4d87a3ea8e3646ca2712c674941458f..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/weighted_variance.hpp +++ /dev/null @@ -1,186 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// weighted_variance.hpp -// -// Copyright 2005 Daniel Egloff, 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_ACCUMULATORS_STATISTICS_WEIGHTED_VARIANCE_HPP_EAN_28_10_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_VARIANCE_HPP_EAN_28_10_2005 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace impl -{ - //! Lazy calculation of variance of weighted samples. - /*! - The default implementation of the variance of weighted samples is based on the second moment - \f$\widehat{m}_n^{(2)}\f$ (weighted_moment<2>) and the mean\f$ \hat{\mu}_n\f$ (weighted_mean): - \f[ - \hat{\sigma}_n^2 = \widehat{m}_n^{(2)}-\hat{\mu}_n^2, - \f] - where \f$n\f$ is the number of samples. - */ - template - struct lazy_weighted_variance_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - lazy_weighted_variance_impl(dont_care) {} - - template - result_type result(Args const &args) const - { - extractor const some_mean = {}; - result_type tmp = some_mean(args); - return accumulators::weighted_moment<2>(args) - tmp * tmp; - } - }; - - //! Iterative calculation of variance of weighted samples. - /*! - Iterative calculation of variance of weighted samples: - \f[ - \hat{\sigma}_n^2 = - \frac{\bar{w}_n - w_n}{\bar{w}_n}\hat{\sigma}_{n - 1}^2 - + \frac{w_n}{\bar{w}_n - w_n}\left(X_n - \hat{\mu}_n\right)^2 - ,\quad n\ge2,\quad\hat{\sigma}_0^2 = 0. - \f] - where \f$\bar{w}_n\f$ is the sum of the \f$n\f$ weights \f$w_i\f$ and \f$\hat{\mu}_n\f$ - the estimate of the mean of the weighted samples. Note that the sample variance is not defined for - \f$n <= 1\f$. - */ - template - struct weighted_variance_impl - : accumulator_base - { - typedef typename numeric::functional::multiplies::result_type weighted_sample; - // for boost::result_of - typedef typename numeric::functional::fdiv::result_type result_type; - - template - weighted_variance_impl(Args const &args) - : weighted_variance(numeric::fdiv(args[sample | Sample()], numeric::one::value)) - { - } - - template - void operator ()(Args const &args) - { - std::size_t cnt = count(args); - - if(cnt > 1) - { - extractor const some_mean = {}; - - result_type tmp = args[parameter::keyword::get()] - some_mean(args); - - this->weighted_variance = - numeric::fdiv(this->weighted_variance * (sum_of_weights(args) - args[weight]), sum_of_weights(args)) - + numeric::fdiv(tmp * tmp * args[weight], sum_of_weights(args) - args[weight] ); - } - } - - result_type result(dont_care) const - { - return this->weighted_variance; - } - - private: - result_type weighted_variance; - }; - -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// tag::weighted_variance -// tag::immediate_weighted_variance -// -namespace tag -{ - struct lazy_weighted_variance - : depends_on, weighted_mean> - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::lazy_weighted_variance_impl impl; - }; - - struct weighted_variance - : depends_on - { - /// INTERNAL ONLY - /// - typedef accumulators::impl::weighted_variance_impl impl; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// extract::weighted_variance -// extract::immediate_weighted_variance -// -namespace extract -{ - extractor const lazy_weighted_variance = {}; - extractor const weighted_variance = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_weighted_variance) - BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_variance) -} - -using extract::lazy_weighted_variance; -using extract::weighted_variance; - -// weighted_variance(lazy) -> lazy_weighted_variance -template<> -struct as_feature -{ - typedef tag::lazy_weighted_variance type; -}; - -// weighted_variance(immediate) -> weighted_variance -template<> -struct as_feature -{ - typedef tag::weighted_variance type; -}; - -//////////////////////////////////////////////////////////////////////////// -//// droppable_accumulator -//// need to specialize droppable lazy weighted_variance to cache the result at the -//// point the accumulator is dropped. -///// INTERNAL ONLY -///// -//template -//struct droppable_accumulator > -// : droppable_accumulator_base< -// with_cached_result > -// > -//{ -// template -// droppable_accumulator(Args const &args) -// : droppable_accumulator::base(args) -// { -// } -//}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics/with_error.hpp b/boost/accumulators/statistics/with_error.hpp deleted file mode 100644 index adafc8e0d810ff3103b44292ab8a5f8c7fbe5bb4..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics/with_error.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// with_error.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_WITH_ERROR_HPP_EAN_01_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_WITH_ERROR_HPP_EAN_01_11_2005 - -#include -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -namespace detail -{ - template - struct error_of_tag - { - typedef tag::error_of type; - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// with_error -// -template -struct with_error - : mpl::transform_view< - mpl::vector - , detail::error_of_tag - > -{ -}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/accumulators/statistics_fwd.hpp b/boost/accumulators/statistics_fwd.hpp deleted file mode 100644 index 61904f30b36c1d40905241ffe38c7ab0a56857e2..0000000000000000000000000000000000000000 --- a/boost/accumulators/statistics_fwd.hpp +++ /dev/null @@ -1,432 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// statistics_fwd.hpp -// -// Copyright 2005 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_ACCUMULATORS_STATISTICS_STATISTICS_FWD_HPP_EAN_23_11_2005 -#define BOOST_ACCUMULATORS_STATISTICS_STATISTICS_FWD_HPP_EAN_23_11_2005 - -#include // for mpl::na -#include -#include -#include -#include -#include - -namespace boost { namespace accumulators -{ - -/////////////////////////////////////////////////////////////////////////////// -// base struct and base extractor for quantiles -namespace tag -{ - struct quantile - : depends_on<> - { - typedef mpl::print impl; - }; -} -namespace extract -{ - extractor const quantile = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(quantile) -} -using extract::quantile; - -/////////////////////////////////////////////////////////////////////////////// -// base struct and base extractor for *coherent* tail means -namespace tag -{ - struct tail_mean - : depends_on<> - { - typedef mpl::print impl; - }; -} -namespace extract -{ - extractor const tail_mean = {}; - - BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_mean) -} -using extract::tail_mean; - -namespace tag -{ - /////////////////////////////////////////////////////////////////////////////// - // Variates tags - struct weights; - struct covariate1; - struct covariate2; - - /////////////////////////////////////////////////////////////////////////////// - // Statistic tags - struct count; - template - struct covariance; - struct density; - template - struct error_of; - struct extended_p_square; - struct extended_p_square_quantile; - struct extended_p_square_quantile_quadratic; - struct kurtosis; - struct max; - struct mean; - struct immediate_mean; - struct mean_of_weights; - struct immediate_mean_of_weights; - template - struct mean_of_variates; - template - struct immediate_mean_of_variates; - struct median; - struct with_density_median; - struct with_p_square_cumulative_distribution_median; - struct min; - template - struct moment; - template - struct peaks_over_threshold; - template - struct peaks_over_threshold_prob; - template - struct pot_tail_mean; - template - struct pot_tail_mean_prob; - template - struct pot_quantile; - template - struct pot_quantile_prob; - struct p_square_cumulative_distribution; - struct p_square_quantile; - struct p_square_quantile_for_median; - struct skewness; - struct sum; - struct sum_of_weights; - template - struct sum_of_variates; - struct sum_kahan; - struct sum_of_weights_kahan; - template - struct sum_of_variates_kahan; - template - struct tail; - template - struct coherent_tail_mean; - template - struct non_coherent_tail_mean; - template - struct tail_quantile; - template - struct tail_variate; - template - struct tail_weights; - template - struct right_tail_variate; - template - struct left_tail_variate; - template - struct tail_variate_means; - template - struct absolute_tail_variate_means; - template - struct relative_tail_variate_means; - struct lazy_variance; - struct variance; - template - struct weighted_covariance; - struct weighted_density; - struct weighted_kurtosis; - struct weighted_mean; - struct immediate_weighted_mean; - template - struct weighted_mean_of_variates; - template - struct immediate_weighted_mean_of_variates; - struct weighted_median; - struct with_density_weighted_median; - struct with_p_square_cumulative_distribution_weighted_median; - struct weighted_extended_p_square; - struct weighted_extended_p_square_quantile; - struct weighted_extended_p_square_quantile_quadratic; - template - struct weighted_moment; - template - struct weighted_peaks_over_threshold; - template - struct weighted_peaks_over_threshold_prob; - template - struct weighted_pot_quantile; - template - struct weighted_pot_quantile_prob; - template - struct weighted_pot_tail_mean; - template - struct weighted_pot_tail_mean_prob; - struct weighted_p_square_cumulative_distribution; - struct weighted_p_square_quantile; - struct weighted_p_square_quantile_for_median; - struct weighted_skewness; - template - struct weighted_tail_quantile; - template - struct non_coherent_weighted_tail_mean; - template - struct weighted_tail_quantile; - template - struct weighted_tail_variate_means; - template - struct absolute_weighted_tail_variate_means; - template - struct relative_weighted_tail_variate_means; - struct lazy_weighted_variance; - struct weighted_variance; - struct weighted_sum; - template - struct weighted_sum_of_variates; - struct rolling_window_plus1; - struct rolling_window; - struct rolling_sum; - struct rolling_count; - struct rolling_mean; -} // namespace tag - -namespace impl -{ - /////////////////////////////////////////////////////////////////////////////// - // Statistics impls - struct count_impl; - - template - struct covariance_impl; - - template - struct density_impl; - - template - struct error_of_impl; - - template - struct error_of_mean_impl; - - template - struct extended_p_square_impl; - - template - struct extended_p_square_quantile_impl; - - template - struct kurtosis_impl; - - template - struct max_impl; - - template - struct median_impl; - - template - struct with_density_median_impl; - - template - struct with_p_square_cumulative_distribution_median_impl; - - template - struct min_impl; - - template - struct mean_impl; - - template - struct immediate_mean_impl; - - template - struct moment_impl; - - template - struct peaks_over_threshold_prob_impl; - - template - struct pot_quantile_impl; - - template - struct pot_tail_mean_impl; - - template - struct p_square_cumulative_distribution_impl; - - template - struct p_square_quantile_impl; - - template - struct skewness_impl; - - template - struct sum_impl; - - template - struct sum_kahan_impl; - - template - struct tail_impl; - - template - struct coherent_tail_mean_impl; - - template - struct non_coherent_tail_mean_impl; - - template - struct tail_quantile_impl; - - template - struct tail_variate_impl; - - template - struct tail_variate_means_impl; - - template - struct lazy_variance_impl; - - template - struct variance_impl; - - template - struct weighted_covariance_impl; - - template - struct weighted_density_impl; - - template - struct weighted_kurtosis_impl; - - template - struct weighted_median_impl; - - template - struct with_density_weighted_median_impl; - - template - struct with_p_square_cumulative_distribution_weighted_median_impl; - - template - struct weighted_mean_impl; - - template - struct immediate_weighted_mean_impl; - - template - struct weighted_peaks_over_threshold_impl; - - template - struct weighted_peaks_over_threshold_prob_impl; - - template - struct with_p_square_cumulative_distribution_weighted_median_impl; - - template - struct weighted_extended_p_square_impl; - - template - struct weighted_moment_impl; - - template - struct weighted_p_square_cumulative_distribution_impl; - - template - struct weighted_p_square_quantile_impl; - - template - struct weighted_skewness_impl; - - template - struct weighted_sum_impl; - - template - struct weighted_sum_kahan_impl; - - template - struct non_coherent_weighted_tail_mean_impl; - - template - struct weighted_tail_quantile_impl; - - template - struct weighted_tail_variate_means_impl; - - template - struct lazy_weighted_variance_impl; - - template - struct weighted_variance_impl; - - template - struct rolling_window_plus1_impl; - - template - struct rolling_window_impl; - - template - struct rolling_sum_impl; - - template - struct rolling_count_impl; - - template - struct rolling_mean_impl; -} // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -// stats -// A more descriptive name for an MPL sequence of statistics. -template -struct stats; - -template -struct with_error; - -// modifiers for the mean and variance stats -struct lazy {}; -struct immediate {}; - -// modifiers for the variance stat -// struct fast {}; -// struct accurate {}; - -// modifiers for order -struct right {}; -struct left {}; -// typedef right default_order_tag_type; - -// modifiers for the tail_variate_means stat -struct absolute {}; -struct relative {}; - -// modifiers for median and weighted_median stats -struct with_density {}; -struct with_p_square_cumulative_distribution {}; -struct with_p_square_quantile {}; - -// modifiers for peaks_over_threshold stat -struct with_threshold_value {}; -struct with_threshold_probability {}; - -// modifiers for extended_p_square_quantile and weighted_extended_p_square_quantile stats -struct weighted {}; -struct unweighted {}; -struct linear {}; -struct quadratic {}; - -// modifiers for p_square_quantile -struct regular {}; -struct for_median {}; - -// modifier for sum_kahan, sum_of_weights_kahan, sum_of_variates_kahan, weighted_sum_kahan -struct kahan {}; - -}} // namespace boost::accumulators - -#endif diff --git a/boost/algorithm/algorithm.hpp b/boost/algorithm/algorithm.hpp deleted file mode 100644 index ab0d4aff5833cfb34279bd35280734c210d06d67..0000000000000000000000000000000000000000 --- a/boost/algorithm/algorithm.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (c) Marshall Clow 2014. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Revision history: - 2 Dec 2014 mtc First version; power - -*/ - -/// \file algorithm.hpp -/// \brief Misc Algorithms -/// \author Marshall Clow -/// - -#ifndef BOOST_ALGORITHM_HPP -#define BOOST_ALGORITHM_HPP - -#include // for plus and multiplies - -#include // for boost::disable_if -#include - -namespace boost { namespace algorithm { - -template -T identity_operation ( std::multiplies ) { return T(1); } - -template -T identity_operation ( std::plus ) { return T(0); } - - -/// \fn power ( T x, Integer n ) -/// \return the value "x" raised to the power "n" -/// -/// \param x The value to be exponentiated -/// \param n The exponent (must be >= 0) -/// -// \remark Taken from Knuth, The Art of Computer Programming, Volume 2: -// Seminumerical Algorithms, Section 4.6.3 -template -typename boost::enable_if, T>::type -power (T x, Integer n) { - T y = 1; // Should be "T y{1};" - if (n == 0) return y; - while (true) { - if (n % 2 == 1) { - y = x * y; - if (n == 1) - return y; - } - n = n / 2; - x = x * x; - } - return y; - } - -/// \fn power ( T x, Integer n, Operation op ) -/// \return the value "x" raised to the power "n" -/// using the operation "op". -/// -/// \param x The value to be exponentiated -/// \param n The exponent (must be >= 0) -/// \param op The operation used -/// -// \remark Taken from Knuth, The Art of Computer Programming, Volume 2: -// Seminumerical Algorithms, Section 4.6.3 -template -typename boost::enable_if, T>::type -power (T x, Integer n, Operation op) { - T y = identity_operation(op); - if (n == 0) return y; - while (true) { - if (n % 2 == 1) { - y = op(x, y); - if (n == 1) - return y; - } - n = n / 2; - x = op(x, x); - } - return y; - } - -}} - -#endif // BOOST_ALGORITHM_HPP diff --git a/boost/algorithm/clamp.hpp b/boost/algorithm/clamp.hpp deleted file mode 100644 index 7bfa47ec9b6b54f167b0a1b127c47c170b0eb881..0000000000000000000000000000000000000000 --- a/boost/algorithm/clamp.hpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Revision history: - 27 June 2009 mtc First version - 23 Oct 2010 mtc Added predicate version - -*/ - -/// \file clamp.hpp -/// \brief Clamp algorithm -/// \author Marshall Clow -/// -/// Suggested by olafvdspek in https://svn.boost.org/trac/boost/ticket/3215 - -#ifndef BOOST_ALGORITHM_CLAMP_HPP -#define BOOST_ALGORITHM_CLAMP_HPP - -#include // For std::less -#include // For std::iterator_traits -#include - -#include -#include -#include // for identity -#include // for boost::disable_if - -namespace boost { namespace algorithm { - -/// \fn clamp ( T const& val, -/// typename boost::mpl::identity::type const & lo, -/// typename boost::mpl::identity::type const & hi, Pred p ) -/// \return the value "val" brought into the range [ lo, hi ] -/// using the comparison predicate p. -/// If p ( val, lo ) return lo. -/// If p ( hi, val ) return hi. -/// Otherwise, return the original value. -/// -/// \param val The value to be clamped -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// \param p A predicate to use to compare the values. -/// p ( a, b ) returns a boolean. -/// - template - T const & clamp ( T const& val, - typename boost::mpl::identity::type const & lo, - typename boost::mpl::identity::type const & hi, Pred p ) - { -// assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal - return p ( val, lo ) ? lo : p ( hi, val ) ? hi : val; - } - - -/// \fn clamp ( T const& val, -/// typename boost::mpl::identity::type const & lo, -/// typename boost::mpl::identity::type const & hi ) -/// \return the value "val" brought into the range [ lo, hi ]. -/// If the value is less than lo, return lo. -/// If the value is greater than "hi", return hi. -/// Otherwise, return the original value. -/// -/// \param val The value to be clamped -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// - template - T const& clamp ( const T& val, - typename boost::mpl::identity::type const & lo, - typename boost::mpl::identity::type const & hi ) - { - return (clamp) ( val, lo, hi, std::less()); - } - -/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, -/// std::iterator_traits::value_type const & lo, -/// std::iterator_traits::value_type const & hi ) -/// \return clamp the sequence of values [first, last) into [ lo, hi ] -/// -/// \param first The start of the range of values -/// \param last One past the end of the range of input values -/// \param out An output iterator to write the clamped values into -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// - template - OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out, - typename std::iterator_traits::value_type const & lo, - typename std::iterator_traits::value_type const & hi ) - { - // this could also be written with bind and std::transform - while ( first != last ) - *out++ = clamp ( *first++, lo, hi ); - return out; - } - -/// \fn clamp_range ( const Range &r, OutputIterator out, -/// typename std::iterator_traits::type>::value_type const & lo, -/// typename std::iterator_traits::type>::value_type const & hi ) -/// \return clamp the sequence of values [first, last) into [ lo, hi ] -/// -/// \param r The range of values to be clamped -/// \param out An output iterator to write the clamped values into -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// - template - typename boost::disable_if_c::value, OutputIterator>::type - clamp_range ( const Range &r, OutputIterator out, - typename std::iterator_traits::type>::value_type const & lo, - typename std::iterator_traits::type>::value_type const & hi ) - { - return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi ); - } - - -/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, -/// std::iterator_traits::value_type const & lo, -/// std::iterator_traits::value_type const & hi, Pred p ) -/// \return clamp the sequence of values [first, last) into [ lo, hi ] -/// using the comparison predicate p. -/// -/// \param first The start of the range of values -/// \param last One past the end of the range of input values -/// \param out An output iterator to write the clamped values into -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// \param p A predicate to use to compare the values. -/// p ( a, b ) returns a boolean. - -/// - template - OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out, - typename std::iterator_traits::value_type const & lo, - typename std::iterator_traits::value_type const & hi, Pred p ) - { - // this could also be written with bind and std::transform - while ( first != last ) - *out++ = clamp ( *first++, lo, hi, p ); - return out; - } - -/// \fn clamp_range ( const Range &r, OutputIterator out, -/// typename std::iterator_traits::type>::value_type const & lo, -/// typename std::iterator_traits::type>::value_type const & hi, -/// Pred p ) -/// \return clamp the sequence of values [first, last) into [ lo, hi ] -/// using the comparison predicate p. -/// -/// \param r The range of values to be clamped -/// \param out An output iterator to write the clamped values into -/// \param lo The lower bound of the range to be clamped to -/// \param hi The upper bound of the range to be clamped to -/// \param p A predicate to use to compare the values. -/// p ( a, b ) returns a boolean. -// -// Disable this template if the first two parameters are the same type; -// In that case, the user will get the two iterator version. - template - typename boost::disable_if_c::value, OutputIterator>::type - clamp_range ( const Range &r, OutputIterator out, - typename std::iterator_traits::type>::value_type const & lo, - typename std::iterator_traits::type>::value_type const & hi, - Pred p ) - { - return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p ); - } - - -}} - -#endif // BOOST_ALGORITHM_CLAMP_HPP diff --git a/boost/algorithm/cxx11/all_of.hpp b/boost/algorithm/cxx11/all_of.hpp deleted file mode 100644 index 8280b18d62ff764527de6390bc548119e9d52bc2..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/all_of.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file all_of.hpp -/// \brief Test ranges to see if all elements match a value or predicate. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_ALL_OF_HPP -#define BOOST_ALGORITHM_ALL_OF_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn all_of ( InputIterator first, InputIterator last, Predicate p ) -/// \return true if all elements in [first, last) satisfy the predicate 'p' -/// \note returns true on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p A predicate for testing the elements of the sequence -/// -/// \note This function is part of the C++2011 standard library. -template -bool all_of ( InputIterator first, InputIterator last, Predicate p ) -{ - for ( ; first != last; ++first ) - if ( !p(*first)) - return false; - return true; -} - -/// \fn all_of ( const Range &r, Predicate p ) -/// \return true if all elements in the range satisfy the predicate 'p' -/// \note returns true on an empty range -/// -/// \param r The input range -/// \param p A predicate for testing the elements of the range -/// -template -bool all_of ( const Range &r, Predicate p ) -{ - return boost::algorithm::all_of ( boost::begin (r), boost::end (r), p ); -} - -/// \fn all_of_equal ( InputIterator first, InputIterator last, const T &val ) -/// \return true if all elements in [first, last) are equal to 'val' -/// \note returns true on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param val A value to compare against -/// -template -bool all_of_equal ( InputIterator first, InputIterator last, const T &val ) -{ - for ( ; first != last; ++first ) - if ( val != *first ) - return false; - return true; -} - -/// \fn all_of_equal ( const Range &r, const T &val ) -/// \return true if all elements in the range are equal to 'val' -/// \note returns true on an empty range -/// -/// \param r The input range -/// \param val A value to compare against -/// -template -bool all_of_equal ( const Range &r, const T &val ) -{ - return boost::algorithm::all_of_equal ( boost::begin (r), boost::end (r), val ); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_ALL_OF_HPP diff --git a/boost/algorithm/cxx11/any_of.hpp b/boost/algorithm/cxx11/any_of.hpp deleted file mode 100644 index e68135a2b3c3391efc6c41612888cae0efd1ea0a..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/any_of.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -/// \file -/// \brief Test ranges to see if any elements match a value or predicate. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_ANY_OF_HPP -#define BOOST_ALGORITHM_ANY_OF_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn any_of ( InputIterator first, InputIterator last, Predicate p ) -/// \return true if any of the elements in [first, last) satisfy the predicate -/// \note returns false on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p A predicate for testing the elements of the sequence -/// -template -bool any_of ( InputIterator first, InputIterator last, Predicate p ) -{ - for ( ; first != last; ++first ) - if ( p(*first)) - return true; - return false; -} - -/// \fn any_of ( const Range &r, Predicate p ) -/// \return true if any elements in the range satisfy the predicate 'p' -/// \note returns false on an empty range -/// -/// \param r The input range -/// \param p A predicate for testing the elements of the range -/// -template -bool any_of ( const Range &r, Predicate p ) -{ - return boost::algorithm::any_of (boost::begin (r), boost::end (r), p); -} - -/// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val ) -/// \return true if any of the elements in [first, last) are equal to 'val' -/// \note returns false on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param val A value to compare against -/// -template -bool any_of_equal ( InputIterator first, InputIterator last, const V &val ) -{ - for ( ; first != last; ++first ) - if ( val == *first ) - return true; - return false; -} - -/// \fn any_of_equal ( const Range &r, const V &val ) -/// \return true if any of the elements in the range are equal to 'val' -/// \note returns false on an empty range -/// -/// \param r The input range -/// \param val A value to compare against -/// -template -bool any_of_equal ( const Range &r, const V &val ) -{ - return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_ANY_OF_HPP diff --git a/boost/algorithm/cxx11/copy_if.hpp b/boost/algorithm/cxx11/copy_if.hpp deleted file mode 100644 index 73e85d99c61bedd52cb3c7efe08557158d8521a6..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/copy_if.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file copy_if.hpp -/// \brief Copy a subset of a sequence to a new sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_COPY_IF_HPP -#define BOOST_ALGORITHM_COPY_IF_HPP - -#include // for std::pair, std::make_pair -#include -#include - -namespace boost { namespace algorithm { - -/// \fn copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -/// \brief Copies all the elements from the input range that satisfy the -/// predicate to the output range. -/// \return The updated output iterator -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// \note This function is part of the C++2011 standard library. -template -OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -{ - for ( ; first != last; ++first ) - if (p(*first)) - *result++ = *first; - return result; -} - -/// \fn copy_if ( const Range &r, OutputIterator result, Predicate p ) -/// \brief Copies all the elements from the input range that satisfy the -/// predicate to the output range. -/// \return The updated output iterator -/// -/// \param r The input range -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// -template -OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p ) -{ - return boost::algorithm::copy_if (boost::begin (r), boost::end(r), result, p); -} - - -/// \fn copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -/// \brief Copies all the elements at the start of the input range that -/// satisfy the predicate to the output range. -/// \return The updated input and output iterators -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// -template -std::pair -copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -{ - for ( ; first != last && p(*first); ++first ) - *result++ = *first; - return std::make_pair(first, result); -} - -/// \fn copy_while ( const Range &r, OutputIterator result, Predicate p ) -/// \brief Copies all the elements at the start of the input range that -/// satisfy the predicate to the output range. -/// \return The updated input and output iterators -/// -/// \param r The input range -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// -template -std::pair::type, OutputIterator> -copy_while ( const Range &r, OutputIterator result, Predicate p ) -{ - return boost::algorithm::copy_while (boost::begin (r), boost::end(r), result, p); -} - - -/// \fn copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -/// \brief Copies all the elements at the start of the input range that do not -/// satisfy the predicate to the output range. -/// \return The updated output iterator -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// -template -std::pair -copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) -{ - for ( ; first != last && !p(*first); ++first ) - *result++ = *first; - return std::make_pair(first, result); -} - -/// \fn copy_until ( const Range &r, OutputIterator result, Predicate p ) -/// \brief Copies all the elements at the start of the input range that do not -/// satisfy the predicate to the output range. -/// \return The updated output iterator -/// -/// \param r The input range -/// \param result An output iterator to write the results into -/// \param p A predicate for testing the elements of the range -/// -template -std::pair::type, OutputIterator> -copy_until ( const Range &r, OutputIterator result, Predicate p ) -{ - return boost::algorithm::copy_until (boost::begin (r), boost::end(r), result, p); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_COPY_IF_HPP diff --git a/boost/algorithm/cxx11/copy_n.hpp b/boost/algorithm/cxx11/copy_n.hpp deleted file mode 100644 index ac880856db7b8309cdce855555cb46b5b1024e40..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/copy_n.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file copy_n.hpp -/// \brief Copy n items from one sequence to another -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_COPY_N_HPP -#define BOOST_ALGORITHM_COPY_N_HPP - -namespace boost { namespace algorithm { - -/// \fn copy_n ( InputIterator first, Size n, OutputIterator result ) -/// \brief Copies exactly n (n > 0) elements from the range starting at first to -/// the range starting at result. -/// \return The updated output iterator -/// -/// \param first The start of the input sequence -/// \param n The number of elements to copy -/// \param result An output iterator to write the results into -/// \note This function is part of the C++2011 standard library. -template -OutputIterator copy_n ( InputIterator first, Size n, OutputIterator result ) -{ - for ( ; n > 0; --n, ++first, ++result ) - *result = *first; - return result; -} -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_COPY_IF_HPP diff --git a/boost/algorithm/cxx11/find_if_not.hpp b/boost/algorithm/cxx11/find_if_not.hpp deleted file mode 100644 index 02ff4dce7b08c75ed7aaf87b8de0a30703ea72f3..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/find_if_not.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file find_if_not.hpp -/// \brief Find the first element in a sequence that does not satisfy a predicate. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_FIND_IF_NOT_HPP -#define BOOST_ALGORITHM_FIND_IF_NOT_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn find_if_not(InputIterator first, InputIterator last, Predicate p) -/// \brief Finds the first element in the sequence that does not satisfy the predicate. -/// \return The iterator pointing to the desired element. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p A predicate for testing the elements of the range -/// \note This function is part of the C++2011 standard library. -template -InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p ) -{ - for ( ; first != last; ++first ) - if ( !p(*first)) - break; - return first; -} - -/// \fn find_if_not ( const Range &r, Predicate p ) -/// \brief Finds the first element in the sequence that does not satisfy the predicate. -/// \return The iterator pointing to the desired element. -/// -/// \param r The input range -/// \param p A predicate for testing the elements of the range -/// -template -typename boost::range_iterator::type find_if_not ( const Range &r, Predicate p ) -{ - return boost::algorithm::find_if_not (boost::begin (r), boost::end(r), p); -} - -}} -#endif // BOOST_ALGORITHM_FIND_IF_NOT_HPP diff --git a/boost/algorithm/cxx11/iota.hpp b/boost/algorithm/cxx11/iota.hpp deleted file mode 100644 index 675093f02d6aed89c6d94b9fd50103b2651d6cd0..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/iota.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file iota.hpp -/// \brief Generate an increasing series -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_IOTA_HPP -#define BOOST_ALGORITHM_IOTA_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn iota ( ForwardIterator first, ForwardIterator last, T value ) -/// \brief Generates an increasing sequence of values, and stores them in [first, last) -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param value The initial value of the sequence to be generated -/// \note This function is part of the C++2011 standard library. -template -void iota ( ForwardIterator first, ForwardIterator last, T value ) -{ - for ( ; first != last; ++first, ++value ) - *first = value; -} - -/// \fn iota ( Range &r, T value ) -/// \brief Generates an increasing sequence of values, and stores them in the input Range. -/// -/// \param r The input range -/// \param value The initial value of the sequence to be generated -/// -template -void iota ( Range &r, T value ) -{ - boost::algorithm::iota (boost::begin(r), boost::end(r), value); -} - - -/// \fn iota_n ( OutputIterator out, T value, std::size_t n ) -/// \brief Generates an increasing sequence of values, and stores them in the input Range. -/// -/// \param out An output iterator to write the results into -/// \param value The initial value of the sequence to be generated -/// \param n The number of items to write -/// -template -OutputIterator iota_n ( OutputIterator out, T value, std::size_t n ) -{ - for ( ; n > 0; --n, ++value ) - *out++ = value; - - return out; -} - -}} - -#endif // BOOST_ALGORITHM_IOTA_HPP diff --git a/boost/algorithm/cxx11/is_partitioned.hpp b/boost/algorithm/cxx11/is_partitioned.hpp deleted file mode 100644 index c0076b932bcb93d636a2a73ec2bc54c71ab36808..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/is_partitioned.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file is_partitioned.hpp -/// \brief Tell if a sequence is partitioned -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_IS_PARTITIONED_HPP -#define BOOST_ALGORITHM_IS_PARTITIONED_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) -/// \brief Tests to see if a sequence is partitioned according to a predicate. -/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p The predicate to test the values with -/// \note This function is part of the C++2011 standard library. -template -bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) -{ -// Run through the part that satisfy the predicate - for ( ; first != last; ++first ) - if ( !p (*first)) - break; -// Now the part that does not satisfy the predicate - for ( ; first != last; ++first ) - if ( p (*first)) - return false; - return true; -} - -/// \fn is_partitioned ( const Range &r, UnaryPredicate p ) -/// \brief Tests to see if a sequence is partitioned according to a predicate. -/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. -/// -/// \param r The input range -/// \param p The predicate to test the values with -/// -template -bool is_partitioned ( const Range &r, UnaryPredicate p ) -{ - return boost::algorithm::is_partitioned (boost::begin(r), boost::end(r), p); -} - - -}} - -#endif // BOOST_ALGORITHM_IS_PARTITIONED_HPP diff --git a/boost/algorithm/cxx11/is_permutation.hpp b/boost/algorithm/cxx11/is_permutation.hpp deleted file mode 100644 index 0098cd53fed8fff60c7e45198b77c28b2f109cff..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/is_permutation.hpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file is_permutation.hpp -/// \brief Is a sequence a permutation of another sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_IS_PERMUTATION11_HPP -#define BOOST_ALGORITHM_IS_PERMUTATION11_HPP - -#include // for std::find_if, count_if, mismatch -#include // for std::pair -#include // for std::equal_to -#include - -#include -#include -#include -#include - -namespace boost { namespace algorithm { - -/// \cond DOXYGEN_HIDE -namespace detail { - template - struct value_predicate { - value_predicate ( Predicate p, Iterator it ) : p_ ( p ), it_ ( it ) {} - - template - bool operator () ( const T1 &t1 ) const { return p_ ( *it_, t1 ); } - private: - Predicate p_; - Iterator it_; - }; - -// Preconditions: -// 1. The sequences are the same length -// 2. Any common elements on the front have been removed (not necessary for correctness, just for performance) - template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > - bool is_permutation_inner ( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate p ) { - // for each unique value in the sequence [first1,last1), count how many times - // it occurs, and make sure it occurs the same number of times in [first2, last2) - for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) { - value_predicate pred ( p, iter ); - - /* For each value we haven't seen yet... */ - if ( std::find_if ( first1, iter, pred ) == iter ) { - std::size_t dest_count = std::count_if ( first2, last2, pred ); - if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred )) - return false; - } - } - - return true; - } - - template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> - bool is_permutation_tag ( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate p, - std::forward_iterator_tag, std::forward_iterator_tag ) { - - // Skip the common prefix (if any) - while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) { - ++first1; - ++first2; - } - if ( first1 != last1 && first2 != last2 ) - return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, - std::equal_to::value_type> ()); - return first1 == last1 && first2 == last2; - } - - template - bool is_permutation_tag ( RandomAccessIterator1 first1, RandomAccessIterator1 last1, - RandomAccessIterator2 first2, RandomAccessIterator2 last2, - BinaryPredicate p, - std::random_access_iterator_tag, std::random_access_iterator_tag ) { - // Cheap check - if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 )) - return false; - // Skip the common prefix (if any) - while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) { - ++first1; - ++first2; - } - - if ( first1 != last1 && first2 != last2 ) - return is_permutation_inner (first1, last1, first2, last2, p); - return first1 == last1 && first2 == last2; - } - -} -/// \endcond - -/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2, BinaryPredicate p ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param first1 The start of the input sequence -/// \param last1 One past the end of the input sequence -/// \param first2 The start of the second sequence -/// \param p The predicate to compare elements with -/// -/// \note This function is part of the C++2011 standard library. -template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > -bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, BinaryPredicate p ) -{ -// Skip the common prefix (if any) - std::pair eq = std::mismatch (first1, last1, first2, p); - first1 = eq.first; - first2 = eq.second; - if ( first1 != last1 ) { - // Create last2 - ForwardIterator2 last2 = first2; - std::advance ( last2, std::distance (first1, last1)); - return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, p ); - } - - return true; -} - -/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2 ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param first1 The start of the input sequence -/// \param last2 One past the end of the input sequence -/// \param first2 The start of the second sequence -/// \note This function is part of the C++2011 standard library. -template< class ForwardIterator1, class ForwardIterator2 > -bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2 ) -{ -// How should I deal with the idea that ForwardIterator1::value_type -// and ForwardIterator2::value_type could be different? Define my own comparison predicate? -// Skip the common prefix (if any) - std::pair eq = std::mismatch (first1, last1, first2 ); - first1 = eq.first; - first2 = eq.second; - if ( first1 != last1 ) { - // Create last2 - ForwardIterator2 last2 = first2; - std::advance ( last2, std::distance (first1, last1)); - return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, - std::equal_to::value_type> ()); - } - return true; -} - - -/// \fn is_permutation ( const Range &r, ForwardIterator first2 ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param r The input range -/// \param first2 The start of the second sequence -template -bool is_permutation ( const Range &r, ForwardIterator first2 ) -{ - return boost::algorithm::is_permutation (boost::begin (r), boost::end (r), first2 ); -} - -/// \fn is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param r The input range -/// \param first2 The start of the second sequence -/// \param pred The predicate to compare elements with -/// -// Disable this template when the first two parameters are the same type -// That way the non-range version will be chosen. -template -typename boost::disable_if_c::value, bool>::type -is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred ) -{ - return boost::algorithm::is_permutation (boost::begin (r), boost::end (r), first2, pred ); -} - -}} - -#endif // BOOST_ALGORITHM_IS_PERMUTATION11_HPP diff --git a/boost/algorithm/cxx11/is_sorted.hpp b/boost/algorithm/cxx11/is_sorted.hpp deleted file mode 100644 index f4dbb38c0855285b37714f937f7cefed23f7089a..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/is_sorted.hpp +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (c) 2010 Nuovation System Designs, LLC -// Grant Erickson -// -// Reworked somewhat by Marshall Clow; August 2010 -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/ for latest version. -// - -#ifndef BOOST_ALGORITHM_ORDERED_HPP -#define BOOST_ALGORITHM_ORDERED_HPP - -#include -#include - -#include -#include - -#include -#include -#include - -namespace boost { namespace algorithm { - -/// \fn is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p ) -/// \return the point in the sequence [first, last) where the elements are unordered -/// (according to the comparison predicate 'p'). -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// \param p A binary predicate that returns true if two elements are ordered. -/// - template - ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p ) - { - if ( first == last ) return last; // the empty sequence is ordered - ForwardIterator next = first; - while ( ++next != last ) - { - if ( p ( *next, *first )) - return next; - first = next; - } - return last; - } - -/// \fn is_sorted_until ( ForwardIterator first, ForwardIterator last ) -/// \return the point in the sequence [first, last) where the elements are unordered -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// - template - ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last ) - { - typedef typename std::iterator_traits::value_type value_type; - return boost::algorithm::is_sorted_until ( first, last, std::less()); - } - - -/// \fn is_sorted ( ForwardIterator first, ForwardIterator last, Pred p ) -/// \return whether or not the entire sequence is sorted -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// \param p A binary predicate that returns true if two elements are ordered. -/// - template - bool is_sorted ( ForwardIterator first, ForwardIterator last, Pred p ) - { - return boost::algorithm::is_sorted_until (first, last, p) == last; - } - -/// \fn is_sorted ( ForwardIterator first, ForwardIterator last ) -/// \return whether or not the entire sequence is sorted -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// - template - bool is_sorted ( ForwardIterator first, ForwardIterator last ) - { - return boost::algorithm::is_sorted_until (first, last) == last; - } - -/// -/// -- Range based versions of the C++11 functions -/// - -/// \fn is_sorted_until ( const R &range, Pred p ) -/// \return the point in the range R where the elements are unordered -/// (according to the comparison predicate 'p'). -/// -/// \param range The range to be tested. -/// \param p A binary predicate that returns true if two elements are ordered. -/// - template - typename boost::lazy_disable_if_c< - boost::is_same::value, - typename boost::range_iterator - >::type is_sorted_until ( const R &range, Pred p ) - { - return boost::algorithm::is_sorted_until ( boost::begin ( range ), boost::end ( range ), p ); - } - - -/// \fn is_sorted_until ( const R &range ) -/// \return the point in the range R where the elements are unordered -/// -/// \param range The range to be tested. -/// - template - typename boost::range_iterator::type is_sorted_until ( const R &range ) - { - return boost::algorithm::is_sorted_until ( boost::begin ( range ), boost::end ( range )); - } - -/// \fn is_sorted ( const R &range, Pred p ) -/// \return whether or not the entire range R is sorted -/// (according to the comparison predicate 'p'). -/// -/// \param range The range to be tested. -/// \param p A binary predicate that returns true if two elements are ordered. -/// - template - typename boost::lazy_disable_if_c< boost::is_same::value, boost::mpl::identity >::type - is_sorted ( const R &range, Pred p ) - { - return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ), p ); - } - - -/// \fn is_sorted ( const R &range ) -/// \return whether or not the entire range R is sorted -/// -/// \param range The range to be tested. -/// - template - bool is_sorted ( const R &range ) - { - return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range )); - } - - -/// -/// -- Range based versions of the C++11 functions -/// - -/// \fn is_increasing ( ForwardIterator first, ForwardIterator last ) -/// \return true if the entire sequence is increasing; i.e, each item is greater than or -/// equal to the previous one. -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// -/// \note This function will return true for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_strictly_increasing instead. - template - bool is_increasing ( ForwardIterator first, ForwardIterator last ) - { - typedef typename std::iterator_traits::value_type value_type; - return boost::algorithm::is_sorted (first, last, std::less()); - } - - -/// \fn is_increasing ( const R &range ) -/// \return true if the entire sequence is increasing; i.e, each item is greater than or -/// equal to the previous one. -/// -/// \param range The range to be tested. -/// -/// \note This function will return true for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_strictly_increasing instead. - template - bool is_increasing ( const R &range ) - { - return is_increasing ( boost::begin ( range ), boost::end ( range )); - } - - - -/// \fn is_decreasing ( ForwardIterator first, ForwardIterator last ) -/// \return true if the entire sequence is decreasing; i.e, each item is less than -/// or equal to the previous one. -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// -/// \note This function will return true for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_strictly_decreasing instead. - template - bool is_decreasing ( ForwardIterator first, ForwardIterator last ) - { - typedef typename std::iterator_traits::value_type value_type; - return boost::algorithm::is_sorted (first, last, std::greater()); - } - -/// \fn is_decreasing ( const R &range ) -/// \return true if the entire sequence is decreasing; i.e, each item is less than -/// or equal to the previous one. -/// -/// \param range The range to be tested. -/// -/// \note This function will return true for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_strictly_decreasing instead. - template - bool is_decreasing ( const R &range ) - { - return is_decreasing ( boost::begin ( range ), boost::end ( range )); - } - - - -/// \fn is_strictly_increasing ( ForwardIterator first, ForwardIterator last ) -/// \return true if the entire sequence is strictly increasing; i.e, each item is greater -/// than the previous one -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// -/// \note This function will return false for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_increasing instead. - template - bool is_strictly_increasing ( ForwardIterator first, ForwardIterator last ) - { - typedef typename std::iterator_traits::value_type value_type; - return boost::algorithm::is_sorted (first, last, std::less_equal()); - } - -/// \fn is_strictly_increasing ( const R &range ) -/// \return true if the entire sequence is strictly increasing; i.e, each item is greater -/// than the previous one -/// -/// \param range The range to be tested. -/// -/// \note This function will return false for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_increasing instead. - template - bool is_strictly_increasing ( const R &range ) - { - return is_strictly_increasing ( boost::begin ( range ), boost::end ( range )); - } - - -/// \fn is_strictly_decreasing ( ForwardIterator first, ForwardIterator last ) -/// \return true if the entire sequence is strictly decreasing; i.e, each item is less than -/// the previous one -/// -/// \param first The start of the sequence to be tested. -/// \param last One past the end of the sequence -/// -/// \note This function will return false for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_decreasing instead. - template - bool is_strictly_decreasing ( ForwardIterator first, ForwardIterator last ) - { - typedef typename std::iterator_traits::value_type value_type; - return boost::algorithm::is_sorted (first, last, std::greater_equal()); - } - -/// \fn is_strictly_decreasing ( const R &range ) -/// \return true if the entire sequence is strictly decreasing; i.e, each item is less than -/// the previous one -/// -/// \param range The range to be tested. -/// -/// \note This function will return false for sequences that contain items that compare -/// equal. If that is not what you intended, you should use is_decreasing instead. - template - bool is_strictly_decreasing ( const R &range ) - { - return is_strictly_decreasing ( boost::begin ( range ), boost::end ( range )); - } - -}} // namespace boost - -#endif // BOOST_ALGORITHM_ORDERED_HPP diff --git a/boost/algorithm/cxx11/none_of.hpp b/boost/algorithm/cxx11/none_of.hpp deleted file mode 100644 index ba13144fb857592e28dc39fcf461b5012b929f2a..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/none_of.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file none_of.hpp -/// \brief Test ranges to see if no elements match a value or predicate. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_NONE_OF_HPP -#define BOOST_ALGORITHM_NONE_OF_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn none_of ( InputIterator first, InputIterator last, Predicate p ) -/// \return true if none of the elements in [first, last) satisfy the predicate 'p' -/// \note returns true on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p A predicate for testing the elements of the sequence -/// -template -bool none_of ( InputIterator first, InputIterator last, Predicate p ) -{ - for ( ; first != last; ++first ) - if ( p(*first)) - return false; - return true; -} - -/// \fn none_of ( const Range &r, Predicate p ) -/// \return true if none of the elements in the range satisfy the predicate 'p' -/// \note returns true on an empty range -/// -/// \param r The input range -/// \param p A predicate for testing the elements of the range -/// -template -bool none_of ( const Range &r, Predicate p ) -{ - return boost::algorithm::none_of (boost::begin (r), boost::end (r), p ); -} - -/// \fn none_of_equal ( InputIterator first, InputIterator last, const V &val ) -/// \return true if none of the elements in [first, last) are equal to 'val' -/// \note returns true on an empty range -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param val A value to compare against -/// -template -bool none_of_equal ( InputIterator first, InputIterator last, const V &val ) -{ - for ( ; first != last; ++first ) - if ( val == *first ) - return false; - return true; -} - -/// \fn none_of_equal ( const Range &r, const V &val ) -/// \return true if none of the elements in the range are equal to 'val' -/// \note returns true on an empty range -/// -/// \param r The input range -/// \param val A value to compare against -/// -template -bool none_of_equal ( const Range &r, const V & val ) -{ - return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_NONE_OF_HPP diff --git a/boost/algorithm/cxx11/one_of.hpp b/boost/algorithm/cxx11/one_of.hpp deleted file mode 100644 index b6e8c77194eefa1ca512570e5afd0aa2407811ae..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/one_of.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file one_of.hpp -/// \brief Test ranges to see if only one element matches a value or predicate. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_ONE_OF_HPP -#define BOOST_ALGORITHM_ONE_OF_HPP - -#include // for std::find and std::find_if -#include - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn one_of ( InputIterator first, InputIterator last, Predicate p ) -/// \return true if the predicate 'p' is true for exactly one item in [first, last). -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p A predicate for testing the elements of the sequence -/// -template -bool one_of ( InputIterator first, InputIterator last, Predicate p ) -{ - InputIterator i = std::find_if (first, last, p); - if (i == last) - return false; // Didn't occur at all - return boost::algorithm::none_of (++i, last, p); -} - -/// \fn one_of ( const Range &r, Predicate p ) -/// \return true if the predicate 'p' is true for exactly one item in the range. -/// -/// \param r The input range -/// \param p A predicate for testing the elements of the range -/// -template -bool one_of ( const Range &r, Predicate p ) -{ - return boost::algorithm::one_of ( boost::begin (r), boost::end (r), p ); -} - - -/// \fn one_of_equal ( InputIterator first, InputIterator last, const V &val ) -/// \return true if the value 'val' exists only once in [first, last). -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param val A value to compare against -/// -template -bool one_of_equal ( InputIterator first, InputIterator last, const V &val ) -{ - InputIterator i = std::find (first, last, val); // find first occurrence of 'val' - if (i == last) - return false; // Didn't occur at all - return boost::algorithm::none_of_equal (++i, last, val); -} - -/// \fn one_of_equal ( const Range &r, const V &val ) -/// \return true if the value 'val' exists only once in the range. -/// -/// \param r The input range -/// \param val A value to compare against -/// -template -bool one_of_equal ( const Range &r, const V &val ) -{ - return boost::algorithm::one_of_equal ( boost::begin (r), boost::end (r), val ); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_ALL_HPP diff --git a/boost/algorithm/cxx11/partition_copy.hpp b/boost/algorithm/cxx11/partition_copy.hpp deleted file mode 100644 index f347f2128f2d72d3d2810e09af5b7055bf01859a..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/partition_copy.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file partition_copy.hpp -/// \brief Copy a subset of a sequence to a new sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_PARTITION_COPY_HPP -#define BOOST_ALGORITHM_PARTITION_COPY_HPP - -#include // for std::pair - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn partition_copy ( InputIterator first, InputIterator last, -/// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) -/// \brief Copies the elements that satisfy the predicate p from the range [first, last) -/// to the range beginning at d_first_true, and -/// copies the elements that do not satisfy p to the range beginning at d_first_false. -/// -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param out_true An output iterator to write the elements that satisfy the predicate into -/// \param out_false An output iterator to write the elements that do not satisfy the predicate into -/// \param p A predicate for dividing the elements of the input sequence. -/// -/// \note This function is part of the C++2011 standard library. -template -std::pair -partition_copy ( InputIterator first, InputIterator last, - OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) -{ - for ( ; first != last; ++first ) - if ( p (*first)) - *out_true++ = *first; - else - *out_false++ = *first; - return std::pair ( out_true, out_false ); -} - -/// \fn partition_copy ( const Range &r, -/// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) -/// -/// \param r The input range -/// \param out_true An output iterator to write the elements that satisfy the predicate into -/// \param out_false An output iterator to write the elements that do not satisfy the predicate into -/// \param p A predicate for dividing the elements of the input sequence. -/// -template -std::pair -partition_copy ( const Range &r, OutputIterator1 out_true, OutputIterator2 out_false, - UnaryPredicate p ) -{ - return boost::algorithm::partition_copy - (boost::begin(r), boost::end(r), out_true, out_false, p ); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_PARTITION_COPY_HPP diff --git a/boost/algorithm/cxx11/partition_point.hpp b/boost/algorithm/cxx11/partition_point.hpp deleted file mode 100644 index 2c2767ae5af300724d0a49b1822092918b799cae..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx11/partition_point.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file partition_point.hpp -/// \brief Find the partition point in a sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_PARTITION_POINT_HPP -#define BOOST_ALGORITHM_PARTITION_POINT_HPP - -#include // for std::distance, advance - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn partition_point ( ForwardIterator first, ForwardIterator last, Predicate p ) -/// \brief Given a partitioned range, returns the partition point, i.e, the first element -/// that does not satisfy p -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p The predicate to test the values with -/// \note This function is part of the C++2011 standard library. -template -ForwardIterator partition_point ( ForwardIterator first, ForwardIterator last, Predicate p ) -{ - std::size_t dist = std::distance ( first, last ); - while ( first != last ) { - std::size_t d2 = dist / 2; - ForwardIterator ret_val = first; - std::advance (ret_val, d2); - if (p (*ret_val)) { - first = ++ret_val; - dist -= d2 + 1; - } - else { - last = ret_val; - dist = d2; - } - } - return first; -} - -/// \fn partition_point ( Range &r, Predicate p ) -/// \brief Given a partitioned range, returns the partition point -/// -/// \param r The input range -/// \param p The predicate to test the values with -/// -template -typename boost::range_iterator::type partition_point ( Range &r, Predicate p ) -{ - return boost::algorithm::partition_point (boost::begin(r), boost::end(r), p); -} - - -}} - -#endif // BOOST_ALGORITHM_PARTITION_POINT_HPP diff --git a/boost/algorithm/cxx14/equal.hpp b/boost/algorithm/cxx14/equal.hpp deleted file mode 100644 index 9f97be1d626d28b3c57f61d61dd2d3ef2ed33d6a..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx14/equal.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file equal.hpp -/// \brief Test ranges to if they are equal -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_EQUAL_HPP -#define BOOST_ALGORITHM_EQUAL_HPP - -#include // for std::equal -#include - -namespace boost { namespace algorithm { - -namespace detail { - - template - struct eq { - bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;} - }; - - template - bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1, - RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred, - std::random_access_iterator_tag, std::random_access_iterator_tag ) - { - // Random-access iterators let is check the sizes in constant time - if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 )) - return false; - // If we know that the sequences are the same size, the original version is fine - return std::equal ( first1, last1, first2, pred ); - } - - template - bool equal ( InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred, - std::input_iterator_tag, std::input_iterator_tag ) - { - for (; first1 != last1 && first2 != last2; ++first1, ++first2 ) - if ( !pred(*first1, *first2 )) - return false; - - return first1 == last1 && first2 == last2; - } -} - -/// \fn equal ( InputIterator1 first1, InputIterator1 last1, -/// InputIterator2 first2, InputIterator2 last2, -/// BinaryPredicate pred ) -/// \return true if all elements in the two ranges are equal -/// -/// \param first1 The start of the first range. -/// \param last1 One past the end of the first range. -/// \param first2 The start of the second range. -/// \param last2 One past the end of the second range. -/// \param pred A predicate for comparing the elements of the ranges -template -bool equal ( InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred ) -{ - return boost::algorithm::detail::equal ( - first1, last1, first2, last2, pred, - typename std::iterator_traits::iterator_category (), - typename std::iterator_traits::iterator_category ()); -} - -/// \fn equal ( InputIterator1 first1, InputIterator1 last1, -/// InputIterator2 first2, InputIterator2 last2 ) -/// \return true if all elements in the two ranges are equal -/// -/// \param first1 The start of the first range. -/// \param last1 One past the end of the first range. -/// \param first2 The start of the second range. -/// \param last2 One past the end of the second range. -template -bool equal ( InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2 ) -{ - return boost::algorithm::detail::equal ( - first1, last1, first2, last2, - boost::algorithm::detail::eq< - typename std::iterator_traits::value_type, - typename std::iterator_traits::value_type> (), - typename std::iterator_traits::iterator_category (), - typename std::iterator_traits::iterator_category ()); -} - -// There are already range-based versions of these. - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_EQUAL_HPP diff --git a/boost/algorithm/cxx14/is_permutation.hpp b/boost/algorithm/cxx14/is_permutation.hpp deleted file mode 100644 index 639446bf373436b56909d252b8831e73dbfee11c..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx14/is_permutation.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (c) Marshall Clow 2014. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file is_permutation.hpp -/// \brief Is a sequence a permutation of another sequence (four iterator versions) -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_IS_PERMUTATION14_HPP -#define BOOST_ALGORITHM_IS_PERMUTATION14_HPP - -#include // for std::pair -#include // for std::equal_to -#include - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, -/// ForwardIterator2 first2, ForwardIterator2 last2 ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param first1 The start of the input sequence -/// \param last2 One past the end of the input sequence -/// \param first2 The start of the second sequence -/// \param last1 One past the end of the second sequence -/// \note This function is part of the C++2014 standard library. -template< class ForwardIterator1, class ForwardIterator2 > -bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2 ) -{ -// How should I deal with the idea that ForwardIterator1::value_type -// and ForwardIterator2::value_type could be different? Define my own comparison predicate? - std::pair eq = boost::algorithm::mismatch - ( first1, last1, first2, last2 ); - if ( eq.first == last1 && eq.second == last2) - return true; - return boost::algorithm::detail::is_permutation_tag ( - eq.first, last1, eq.second, last2, - std::equal_to::value_type> (), - typename std::iterator_traits::iterator_category (), - typename std::iterator_traits::iterator_category ()); -} - -/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, -/// ForwardIterator2 first2, ForwardIterator2 last2, -/// BinaryPredicate p ) -/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 -/// -/// \param first1 The start of the input sequence -/// \param last1 One past the end of the input sequence -/// \param first2 The start of the second sequence -/// \param last2 One past the end of the second sequence -/// \param pred The predicate to compare elements with -/// -/// \note This function is part of the C++2014 standard library. -template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > -bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate pred ) -{ - std::pair eq = boost::algorithm::mismatch - ( first1, last1, first2, last2, pred ); - if ( eq.first == last1 && eq.second == last2) - return true; - return boost::algorithm::detail::is_permutation_tag ( - first1, last1, first2, last2, pred, - typename std::iterator_traits::iterator_category (), - typename std::iterator_traits::iterator_category ()); -} - -}} - -#endif // BOOST_ALGORITHM_IS_PERMUTATION14_HPP diff --git a/boost/algorithm/cxx14/mismatch.hpp b/boost/algorithm/cxx14/mismatch.hpp deleted file mode 100644 index c3de41822259d9c416f1e3f55af6e562397de2aa..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx14/mismatch.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file mismatch.hpp -/// \brief Find the first mismatched element in a sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_MISMATCH_HPP -#define BOOST_ALGORITHM_MISMATCH_HPP - -#include // for std::pair - -namespace boost { namespace algorithm { - -/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, -/// InputIterator2 first2, InputIterator2 last2, -/// BinaryPredicate pred ) -/// \return a pair of iterators pointing to the first elements in the sequence that do not match -/// -/// \param first1 The start of the first range. -/// \param last1 One past the end of the first range. -/// \param first2 The start of the second range. -/// \param last2 One past the end of the second range. -/// \param pred A predicate for comparing the elements of the ranges -template -std::pair mismatch ( - InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - BinaryPredicate pred ) -{ - for (; first1 != last1 && first2 != last2; ++first1, ++first2) - if ( !pred ( *first1, *first2 )) - break; - return std::pair(first1, first2); -} - -/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, -/// InputIterator2 first2, InputIterator2 last2 ) -/// \return a pair of iterators pointing to the first elements in the sequence that do not match -/// -/// \param first1 The start of the first range. -/// \param last1 One past the end of the first range. -/// \param first2 The start of the second range. -/// \param last2 One past the end of the second range. -template -std::pair mismatch ( - InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2 ) -{ - for (; first1 != last1 && first2 != last2; ++first1, ++first2) - if ( *first1 != *first2 ) - break; - return std::pair(first1, first2); -} - -// There are already range-based versions of these. - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_MISMATCH_HPP diff --git a/boost/algorithm/cxx17/exclusive_scan.hpp b/boost/algorithm/cxx17/exclusive_scan.hpp deleted file mode 100644 index 03ecea52ecf96a0dd14302986d09be54699c0e4c..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/exclusive_scan.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file exclusive_scan.hpp -/// \brief ??? -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP -#define BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -OutputIterator exclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, T init, BinaryOperation bOp) -{ - if (first != last) - { - T saved = init; - do - { - init = bOp(init, *first); - *result = saved; - saved = init; - ++result; - } while (++first != last); - } - return result; -} - -template -OutputIterator exclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, T init) -{ - typedef typename std::iterator_traits::value_type VT; - return exclusive_scan(first, last, result, init, std::plus()); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP diff --git a/boost/algorithm/cxx17/for_each_n.hpp b/boost/algorithm/cxx17/for_each_n.hpp deleted file mode 100644 index b8134cc06ac4639a183712804bcbbcabf28334f4..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/for_each_n.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file for_each_n.hpp -/// \brief Apply a functor to the elements of a sequence -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP -#define BOOST_ALGORITHM_FOR_EACH_N_HPP - -#include // for std::pair - -namespace boost { namespace algorithm { - -/// \fn for_each_n(InputIterator first, Size n, Function f); -/// \return first + n -/// -/// \param first The start of the first range. -/// \param n One past the end of the first range. -/// \param f A functor to apply to the elements of the sequence -/// \note If f returns a result, the result is ignored. -template -InputIterator for_each_n(InputIterator first, Size n, Function f) -{ - for ( ; n > 0; --n, ++first ) - f(*first); - - return first; -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_FOR_EACH_N_HPP diff --git a/boost/algorithm/cxx17/inclusive_scan.hpp b/boost/algorithm/cxx17/inclusive_scan.hpp deleted file mode 100644 index cd015f100fba3034adca1994667dc318e195b3f2..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/inclusive_scan.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file transform_reduce.hpp -/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP -#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -OutputIterator inclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, BinaryOperation bOp, T init) -{ - for (; first != last; ++first, (void) ++result) { - init = bOp(init, *first); - *result = init; - } - return result; -} - - -template -OutputIterator inclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, BinaryOperation bOp) -{ - if (first != last) { - typename std::iterator_traits::value_type init = *first; - *result++ = init; - if (++first != last) - return inclusive_scan(first, last, result, bOp, init); - } - - return result; -} - -template -OutputIterator inclusive_scan(InputIterator first, InputIterator last, - OutputIterator result) -{ - typedef typename std::iterator_traits::value_type VT; - return inclusive_scan(first, last, result, std::plus()); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/reduce.hpp b/boost/algorithm/cxx17/reduce.hpp deleted file mode 100644 index f47695b53a6c1f7970a8303b2a6e10585ffbc834..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/reduce.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file reduce.hpp -/// \brief Combine the elements of a sequence into a single value -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_REDUCE_HPP -#define BOOST_ALGORITHM_REDUCE_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -T reduce(InputIterator first, InputIterator last, T init, BinaryOperation bOp) -{ - ; - for (; first != last; ++first) - init = bOp(init, *first); - return init; -} - -template -T reduce(InputIterator first, InputIterator last, T init) -{ - typedef typename std::iterator_traits::value_type VT; - return reduce(first, last, init, std::plus()); -} - -template -typename std::iterator_traits::value_type -reduce(InputIterator first, InputIterator last) -{ - return reduce(first, last, - typename std::iterator_traits::value_type()); -} - -template -typename boost::range_value::type -reduce(const Range &r) -{ - return reduce(boost::begin(r), boost::end(r)); -} - -// Not sure that this won't be ambiguous (1) -template -T reduce(const Range &r, T init) -{ - return reduce(boost::begin (r), boost::end (r), init); -} - - -// Not sure that this won't be ambiguous (2) -template -T reduce(const Range &r, T init, BinaryOperation bOp) -{ - return reduce(boost::begin(r), boost::end(r), init, bOp); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/transform_exclusive_scan.hpp b/boost/algorithm/cxx17/transform_exclusive_scan.hpp deleted file mode 100644 index d3b4329a0a148b737db8f17e39c86a600aa0789c..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/transform_exclusive_scan.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file transform_exclusive_scan.hpp -/// \brief ???? -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP -#define BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, T init, - BinaryOperation bOp, UnaryOperation uOp) -{ - if (first != last) - { - T saved = init; - do - { - init = bOp(init, uOp(*first)); - *result = saved; - saved = init; - ++result; - } while (++first != last); - } - return result; -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/boost/algorithm/cxx17/transform_inclusive_scan.hpp b/boost/algorithm/cxx17/transform_inclusive_scan.hpp deleted file mode 100644 index 476c117f927a74aa8aaae3df29a47d1c6da7d627..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/transform_inclusive_scan.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file transform_reduce.hpp -/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP -#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, - BinaryOperation bOp, UnaryOperation uOp, - T init) -{ - for (; first != last; ++first, (void) ++result) { - init = bOp(init, uOp(*first)); - *result = init; - } - - return result; -} - -template -OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, - OutputIterator result, - BinaryOperation bOp, UnaryOperation uOp) -{ - if (first != last) { - typename std::iterator_traits::value_type init = uOp(*first); - *result++ = init; - if (++first != last) - return transform_inclusive_scan(first, last, result, bOp, uOp, init); - } - - return result; -} - - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/cxx17/transform_reduce.hpp b/boost/algorithm/cxx17/transform_reduce.hpp deleted file mode 100644 index 7ebde7d3255b3cfa4ab508b93d6662b3cf92e768..0000000000000000000000000000000000000000 --- a/boost/algorithm/cxx17/transform_reduce.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (c) Marshall Clow 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt) -*/ - -/// \file transform_reduce.hpp -/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP -#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP - -#include // for std::plus -#include // for std::iterator_traits - -#include -#include -#include - -namespace boost { namespace algorithm { - -template -T transform_reduce(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, T init, - BinaryOperation1 bOp1, BinaryOperation2 bOp2) -{ - for (; first1 != last1; ++first1, (void) ++first2) - init = bOp1(init, bOp2(*first1, *first2)); - return init; -} - -template -T transform_reduce(InputIterator first, InputIterator last, - T init, BinaryOperation bOp, UnaryOperation uOp) -{ - for (; first != last; ++first) - init = bOp(init, uOp(*first)); - return init; -} - -template -T transform_reduce(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, T init) -{ - return transform_reduce(first1, last1, first2, init, - std::plus(), std::multiplies()); -} - -}} // namespace boost and algorithm - -#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/boost/algorithm/gather.hpp b/boost/algorithm/gather.hpp deleted file mode 100644 index 944bc94348d6b1cf519395079bb81819b154c88f..0000000000000000000000000000000000000000 --- a/boost/algorithm/gather.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright 2008 Adobe Systems Incorporated - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Revision history: - January 2008 mtc Version for Adobe Source Library - January 2013 mtc Version for Boost.Algorithm - -*/ - -/**************************************************************************************************/ - -/*! -\author Marshall Clow -\date January 2008 -*/ - -#ifndef BOOST_ALGORITHM_GATHER_HPP -#define BOOST_ALGORITHM_GATHER_HPP - -#include // for std::stable_partition -#include - -#include // for boost::bind -#include // for boost::begin(range) -#include // for boost::end(range) - - -/**************************************************************************************************/ -/*! - \defgroup gather gather - \ingroup mutating_algorithm - - \c gather() takes a collection of elements defined by a pair of iterators and moves - the ones satisfying a predicate to them to a position (called the pivot) within - the sequence. The algorithm is stable. The result is a pair of iterators that - contains the items that satisfy the predicate. - - Given an sequence containing: -
-    0 1 2 3 4 5 6 7 8 9
-    
- - a call to gather ( arr, arr + 10, arr + 4, IsEven ()) will result in: - -
-    1 3 0 2 4 6 8 5 7 9
-        |---|-----|
-      first |  second
-          pivot
-    
- - - The problem is broken down into two basic steps, namely, moving the items before the pivot - and then moving the items from the pivot to the end. These "moves" are done with calls to - stable_partition. - - \par Storage Requirements: - - The algorithm uses stable_partition, which will attempt to allocate temporary memory, - but will work in-situ if there is none available. - - \par Time Complexity: - - If there is sufficient memory available, the run time is linear in N. - If there is not any memory available, then the run time is O(N log N). -*/ - -/**************************************************************************************************/ - -namespace boost { namespace algorithm { - -/**************************************************************************************************/ - -/*! - \ingroup gather - \brief iterator-based gather implementation -*/ - -template < - typename BidirectionalIterator, // Iter models BidirectionalIterator - typename Pred> // Pred models UnaryPredicate -std::pair gather - ( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred ) -{ -// The first call partitions everything up to (but not including) the pivot element, -// while the second call partitions the rest of the sequence. - return std::make_pair ( - std::stable_partition ( first, pivot, !boost::bind ( pred, _1 )), - std::stable_partition ( pivot, last, boost::bind ( pred, _1 ))); -} - -/**************************************************************************************************/ - -/*! - \ingroup gather - \brief range-based gather implementation -*/ - -template < - typename BidirectionalRange, // - typename Pred> // Pred models UnaryPredicate -std::pair< - typename boost::range_iterator::type, - typename boost::range_iterator::type> -gather ( - const BidirectionalRange &range, - typename boost::range_iterator::type pivot, - Pred pred ) -{ - return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred ); -} - -/**************************************************************************************************/ - -}} // namespace - -/**************************************************************************************************/ - -#endif - diff --git a/boost/algorithm/hex.hpp b/boost/algorithm/hex.hpp deleted file mode 100644 index b8335843a88b8c488313d4e9eb520dbbe51e765b..0000000000000000000000000000000000000000 --- a/boost/algorithm/hex.hpp +++ /dev/null @@ -1,325 +0,0 @@ -/* - Copyright (c) Marshall Clow 2011-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Thanks to Nevin for his comments/help. -*/ - -/* - General problem - turn a sequence of integral types into a sequence of hexadecimal characters. - - and back. -*/ - -/// \file hex.hpp -/// \brief Convert sequence of integral types into a sequence of hexadecimal -/// characters and back. Based on the MySQL functions HEX and UNHEX -/// \author Marshall Clow - -#ifndef BOOST_ALGORITHM_HEXHPP -#define BOOST_ALGORITHM_HEXHPP - -#include // for std::iterator_traits -#include - -#include -#include -#include -#include -#include - -#include -#include - - -namespace boost { namespace algorithm { - -/*! - \struct hex_decode_error - \brief Base exception class for all hex decoding errors -*/ /*! - \struct non_hex_input - \brief Thrown when a non-hex value (0-9, A-F) encountered when decoding. - Contains the offending character -*/ /*! - \struct not_enough_input - \brief Thrown when the input sequence unexpectedly ends - -*/ -struct hex_decode_error : virtual boost::exception, virtual std::exception {}; -struct not_enough_input : virtual hex_decode_error {}; -struct non_hex_input : virtual hex_decode_error {}; -typedef boost::error_info bad_char; - -namespace detail { -/// \cond DOXYGEN_HIDE - - template - OutputIterator encode_one ( T val, OutputIterator out, const char * hexDigits ) { - const std::size_t num_hex_digits = 2 * sizeof ( T ); - char res [ num_hex_digits ]; - char *p = res + num_hex_digits; - for ( std::size_t i = 0; i < num_hex_digits; ++i, val >>= 4 ) - *--p = hexDigits [ val & 0x0F ]; - return std::copy ( res, res + num_hex_digits, out ); - } - - template - unsigned char hex_char_to_int ( T val ) { - char c = static_cast ( val ); - unsigned retval = 0; - if ( c >= '0' && c <= '9' ) retval = c - '0'; - else if ( c >= 'A' && c <= 'F' ) retval = c - 'A' + 10; - else if ( c >= 'a' && c <= 'f' ) retval = c - 'a' + 10; - else BOOST_THROW_EXCEPTION (non_hex_input() << bad_char (c)); - return static_cast(retval); - } - -// My own iterator_traits class. -// It is here so that I can "reach inside" some kinds of output iterators -// and get the type to write. - template - struct hex_iterator_traits { - typedef typename std::iterator_traits::value_type value_type; - }; - - template - struct hex_iterator_traits< std::back_insert_iterator > { - typedef typename Container::value_type value_type; - }; - - template - struct hex_iterator_traits< std::front_insert_iterator > { - typedef typename Container::value_type value_type; - }; - - template - struct hex_iterator_traits< std::insert_iterator > { - typedef typename Container::value_type value_type; - }; - -// ostream_iterators have three template parameters. -// The first one is the output type, the second one is the character type of -// the underlying stream, the third is the character traits. -// We only care about the first one. - template - struct hex_iterator_traits< std::ostream_iterator > { - typedef T value_type; - }; - - template - bool iter_end ( Iterator current, Iterator last ) { return current == last; } - - template - bool ptr_end ( const T* ptr, const T* /*end*/ ) { return *ptr == '\0'; } - -// What can we assume here about the inputs? -// is std::iterator_traits::value_type always 'char' ? -// Could it be wchar_t, say? Does it matter? -// We are assuming ASCII for the values - but what about the storage? - template - typename boost::enable_if::value_type>, OutputIterator>::type - decode_one ( InputIterator &first, InputIterator last, OutputIterator out, EndPred pred ) { - typedef typename hex_iterator_traits::value_type T; - T res (0); - - // Need to make sure that we get can read that many chars here. - for ( std::size_t i = 0; i < 2 * sizeof ( T ); ++i, ++first ) { - if ( pred ( first, last )) - BOOST_THROW_EXCEPTION (not_enough_input ()); - res = ( 16 * res ) + hex_char_to_int (*first); - } - - *out = res; - return ++out; - } -/// \endcond - } - - -/// \fn hex ( InputIterator first, InputIterator last, OutputIterator out ) -/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if::value_type>, OutputIterator>::type -hex ( InputIterator first, InputIterator last, OutputIterator out ) { - for ( ; first != last; ++first ) - out = detail::encode_one ( *first, out, "0123456789ABCDEF" ); - return out; - } - - -/// \fn hex_lower ( InputIterator first, InputIterator last, OutputIterator out ) -/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if::value_type>, OutputIterator>::type -hex_lower ( InputIterator first, InputIterator last, OutputIterator out ) { - for ( ; first != last; ++first ) - out = detail::encode_one ( *first, out, "0123456789abcdef" ); - return out; - } - - -/// \fn hex ( const T *ptr, OutputIterator out ) -/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. -/// -/// \param ptr A pointer to a 0-terminated sequence of data. -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if, OutputIterator>::type -hex ( const T *ptr, OutputIterator out ) { - while ( *ptr ) - out = detail::encode_one ( *ptr++, out, "0123456789ABCDEF" ); - return out; - } - - -/// \fn hex_lower ( const T *ptr, OutputIterator out ) -/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. -/// -/// \param ptr A pointer to a 0-terminated sequence of data. -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if, OutputIterator>::type -hex_lower ( const T *ptr, OutputIterator out ) { - while ( *ptr ) - out = detail::encode_one ( *ptr++, out, "0123456789abcdef" ); - return out; - } - - -/// \fn hex ( const Range &r, OutputIterator out ) -/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. -/// -/// \param r The input range -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if::value_type>, OutputIterator>::type -hex ( const Range &r, OutputIterator out ) { - return hex (boost::begin(r), boost::end(r), out); -} - - -/// \fn hex_lower ( const Range &r, OutputIterator out ) -/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. -/// -/// \param r The input range -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -typename boost::enable_if::value_type>, OutputIterator>::type -hex_lower ( const Range &r, OutputIterator out ) { - return hex_lower (boost::begin(r), boost::end(r), out); -} - - -/// \fn unhex ( InputIterator first, InputIterator last, OutputIterator out ) -/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -OutputIterator unhex ( InputIterator first, InputIterator last, OutputIterator out ) { - while ( first != last ) - out = detail::decode_one ( first, last, out, detail::iter_end ); - return out; - } - - -/// \fn unhex ( const T *ptr, OutputIterator out ) -/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. -/// -/// \param ptr A pointer to a null-terminated input sequence. -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -OutputIterator unhex ( const T *ptr, OutputIterator out ) { -// If we run into the terminator while decoding, we will throw a -// malformed input exception. It would be nicer to throw a 'Not enough input' -// exception - but how much extra work would that require? - while ( *ptr ) - out = detail::decode_one ( ptr, (const T *) NULL, out, detail::ptr_end ); - return out; - } - - -/// \fn OutputIterator unhex ( const Range &r, OutputIterator out ) -/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. -/// -/// \param r The input range -/// \param out An output iterator to the results into -/// \return The updated output iterator -/// \note Based on the MySQL function of the same name -template -OutputIterator unhex ( const Range &r, OutputIterator out ) { - return unhex (boost::begin(r), boost::end(r), out); - } - - -/// \fn String hex ( const String &input ) -/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. -/// -/// \param input A container to be converted -/// \return A container with the encoded text -template -String hex ( const String &input ) { - String output; - output.reserve (input.size () * (2 * sizeof (typename String::value_type))); - (void) hex (input, std::back_inserter (output)); - return output; - } - - -/// \fn String hex_lower ( const String &input ) -/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. -/// -/// \param input A container to be converted -/// \return A container with the encoded text -template -String hex_lower ( const String &input ) { - String output; - output.reserve (input.size () * (2 * sizeof (typename String::value_type))); - (void) hex_lower (input, std::back_inserter (output)); - return output; - } - - -/// \fn String unhex ( const String &input ) -/// \brief Converts a sequence of hexadecimal characters into a sequence of characters. -/// -/// \param input A container to be converted -/// \return A container with the decoded text -template -String unhex ( const String &input ) { - String output; - output.reserve (input.size () / (2 * sizeof (typename String::value_type))); - (void) unhex (input, std::back_inserter (output)); - return output; - } - -}} - -#endif // BOOST_ALGORITHM_HEXHPP diff --git a/boost/algorithm/is_palindrome.hpp b/boost/algorithm/is_palindrome.hpp deleted file mode 100644 index 09881109a37e3a088dce6cf7ed8b98a0fd22b619..0000000000000000000000000000000000000000 --- a/boost/algorithm/is_palindrome.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (c) Alexander Zaitsev , 2016 - - Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) - - See http://www.boost.org/ for latest version. -*/ - -/// \file is_palindrome.hpp -/// \brief Checks the input sequence on palindrome. -/// \author Alexander Zaitsev - -#ifndef BOOST_ALGORITHM_IS_PALINDROME_HPP -#define BOOST_ALGORITHM_IS_PALINDROME_HPP - -#include -#include -#include - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn is_palindrome ( BidirectionalIterator begin, BidirectionalIterator end, Predicate p ) -/// \return true if the entire sequence is palindrome -/// -/// \param begin The start of the input sequence -/// \param end One past the end of the input sequence -/// \param p A predicate used to compare the values. -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -template -bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predicate p) -{ - if(begin == end) - { - return true; - } - - --end; - while(begin != end) - { - if(!p(*begin, *end)) - { - return false; - } - ++begin; - if(begin == end) - { - break; - } - --end; - } - return true; -} - -/// \fn is_palindrome ( BidirectionalIterator begin, BidirectionalIterator end ) -/// \return true if the entire sequence is palindrome -/// -/// \param begin The start of the input sequence -/// \param end One past the end of the input sequence -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -template -bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end) -{ - return is_palindrome(begin, end, - std::equal_to::value_type> ()); -} - -/// \fn is_palindrome ( const R& range ) -/// \return true if the entire sequence is palindrome -/// -/// \param range The range to be tested. -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -template -bool is_palindrome(const R& range) -{ - return is_palindrome(boost::begin(range), boost::end(range)); -} - -/// \fn is_palindrome ( const R& range, Predicate p ) -/// \return true if the entire sequence is palindrome -/// -/// \param range The range to be tested. -/// \param p A predicate used to compare the values. -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -template -bool is_palindrome(const R& range, Predicate p) -{ - return is_palindrome(boost::begin(range), boost::end(range), p); -} - -/// \fn is_palindrome ( const char* str ) -/// \return true if the entire sequence is palindrome -/// -/// \param str C-string to be tested. -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -bool is_palindrome(const char* str) -{ - if(!str) - return true; - return is_palindrome(str, str + strlen(str)); -} - -/// \fn is_palindrome ( const char* str, Predicate p ) -/// \return true if the entire sequence is palindrome -/// -/// \param str C-string to be tested. -/// \param p A predicate used to compare the values. -/// -/// \note This function will return true for empty sequences and for palindromes. -/// For other sequences function will return false. -/// Complexity: O(N). -template -bool is_palindrome(const char* str, Predicate p) -{ - if(!str) - return true; - return is_palindrome(str, str + strlen(str), p); -} -}} - -#endif // BOOST_ALGORITHM_IS_PALINDROME_HPP diff --git a/boost/algorithm/is_partitioned_until.hpp b/boost/algorithm/is_partitioned_until.hpp deleted file mode 100644 index 42683e1d8e53d6fe53f3d8ae2a24bedd4070fe6b..0000000000000000000000000000000000000000 --- a/boost/algorithm/is_partitioned_until.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (c) Alexander Zaitsev , 2017. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -/// \file is_partitioned_until.hpp -/// \brief Tell if a sequence is partitioned -/// \author Alexander Zaitsev - -#ifndef BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP -#define BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) -/// \brief Tests to see if a sequence is partitioned according to a predicate. -/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. -/// -/// \param first The start of the input sequence -/// \param last One past the end of the input sequence -/// \param p The predicate to test the values with -/// -/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. -/// Returns last if the entire sequence is partitioned. -/// Complexity: O(N). -template -InputIterator is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) -{ -// Run through the part that satisfy the predicate - for ( ; first != last; ++first ) - if ( !p (*first)) - break; -// Now the part that does not satisfy the predicate - for ( ; first != last; ++first ) - if ( p (*first)) - return first; - return last; -} - -/// \fn is_partitioned_until ( const Range &r, UnaryPredicate p ) -/// \brief Tests to see if a sequence is partitioned according to a predicate. -/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. -/// -/// \param r The input range -/// \param p The predicate to test the values with -/// -/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. -/// Returns last if the entire sequence is partitioned. -/// Complexity: O(N). -template -typename boost::range_iterator::type is_partitioned_until ( const Range &r, UnaryPredicate p ) -{ - return boost::algorithm::is_partitioned_until (boost::begin(r), boost::end(r), p); -} - -}} - -#endif // BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP diff --git a/boost/algorithm/minmax.hpp b/boost/algorithm/minmax.hpp deleted file mode 100644 index 053a7d60ae0be25088042678f303ae1b3d1ee18c..0000000000000000000000000000000000000000 --- a/boost/algorithm/minmax.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// (C) Copyright Herve Bronnimann 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) - -/* - Revision history: - 1 July 2004 - Split the code into two headers to lessen dependence on - Boost.tuple. (Herve) - 26 June 2004 - Added the code for the boost minmax library. (Herve) -*/ - -#ifndef BOOST_ALGORITHM_MINMAX_HPP -#define BOOST_ALGORITHM_MINMAX_HPP - -/* PROPOSED STANDARD EXTENSIONS: - * - * minmax(a, b) - * Effect: (b // for using pairs with boost::cref -#include - -namespace boost { - - template - tuple< T const&, T const& > - minmax(T const& a, T const& b) { - return (b - tuple< T const&, T const& > - minmax(T const& a, T const& b, BinaryPredicate comp) { - return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); - } - -} // namespace boost - -#endif // BOOST_ALGORITHM_MINMAX_HPP diff --git a/boost/algorithm/minmax_element.hpp b/boost/algorithm/minmax_element.hpp deleted file mode 100644 index 752f6cbdb16b71d9c97803c6c44d3f80a24f721d..0000000000000000000000000000000000000000 --- a/boost/algorithm/minmax_element.hpp +++ /dev/null @@ -1,553 +0,0 @@ -// (C) Copyright Herve Bronnimann 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) - -/* - Revision history: - 1 July 2004 - Split the code into two headers to lessen dependence on - Boost.tuple. (Herve) - 26 June 2004 - Added the code for the boost minmax library. (Herve) -*/ - -#ifndef BOOST_ALGORITHM_MINMAX_ELEMENT_HPP -#define BOOST_ALGORITHM_MINMAX_ELEMENT_HPP - -/* PROPOSED STANDARD EXTENSIONS: - * - * minmax_element(first, last) - * Effect: std::make_pair( std::min_element(first, last), - * std::max_element(first, last) ); - * - * minmax_element(first, last, comp) - * Effect: std::make_pair( std::min_element(first, last, comp), - * std::max_element(first, last, comp) ); - */ - -#include // for std::pair and std::make_pair - -namespace boost { - - namespace detail { // for obtaining a uniform version of minmax_element - // that compiles with VC++ 6.0 -- avoid the iterator_traits by - // having comparison object over iterator, not over dereferenced value - - template - struct less_over_iter { - bool operator()(Iterator const& it1, - Iterator const& it2) const { return *it1 < *it2; } - }; - - template - struct binary_pred_over_iter { - explicit binary_pred_over_iter(BinaryPredicate const& p ) : m_p( p ) {} - bool operator()(Iterator const& it1, - Iterator const& it2) const { return m_p(*it1, *it2); } - private: - BinaryPredicate m_p; - }; - - // common base for the two minmax_element overloads - - template - std::pair - basic_minmax_element(ForwardIter first, ForwardIter last, Compare comp) - { - if (first == last) - return std::make_pair(last,last); - - ForwardIter min_result = first; - ForwardIter max_result = first; - - // if only one element - ForwardIter second = first; ++second; - if (second == last) - return std::make_pair(min_result, max_result); - - // treat first pair separately (only one comparison for first two elements) - ForwardIter potential_min_result = last; - if (comp(first, second)) - max_result = second; - else { - min_result = second; - potential_min_result = first; - } - - // then each element by pairs, with at most 3 comparisons per pair - first = ++second; if (first != last) ++second; - while (second != last) { - if (comp(first, second)) { - if (comp(first, min_result)) { - min_result = first; - potential_min_result = last; - } - if (comp(max_result, second)) - max_result = second; - } else { - if (comp(second, min_result)) { - min_result = second; - potential_min_result = first; - } - if (comp(max_result, first)) - max_result = first; - } - first = ++second; - if (first != last) ++second; - } - - // if odd number of elements, treat last element - if (first != last) { // odd number of elements - if (comp(first, min_result)) { - min_result = first; - potential_min_result = last; - } - else if (comp(max_result, first)) - max_result = first; - } - - // resolve min_result being incorrect with one extra comparison - // (in which case potential_min_result is necessarily the correct result) - if (potential_min_result != last - && !comp(min_result, potential_min_result)) - min_result = potential_min_result; - - return std::make_pair(min_result,max_result); - } - - } // namespace detail - - template - std::pair - minmax_element(ForwardIter first, ForwardIter last) - { - return detail::basic_minmax_element(first, last, - detail::less_over_iter() ); - } - - template - std::pair - minmax_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) - { - return detail::basic_minmax_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - -} - -/* PROPOSED BOOST EXTENSIONS - * In the description below, [rfirst,rlast) denotes the reversed range - * of [first,last). Even though the iterator type of first and last may - * be only a Forward Iterator, it is possible to explain the semantics - * by assuming that it is a Bidirectional Iterator. In the sequel, - * reverse(ForwardIterator&) returns the reverse_iterator adaptor. - * This is not how the functions would be implemented! - * - * first_min_element(first, last) - * Effect: std::min_element(first, last); - * - * first_min_element(first, last, comp) - * Effect: std::min_element(first, last, comp); - * - * last_min_element(first, last) - * Effect: reverse( std::min_element(reverse(last), reverse(first)) ); - * - * last_min_element(first, last, comp) - * Effect: reverse( std::min_element(reverse(last), reverse(first), comp) ); - * - * first_max_element(first, last) - * Effect: std::max_element(first, last); - * - * first_max_element(first, last, comp) - * Effect: max_element(first, last); - * - * last_max_element(first, last) - * Effect: reverse( std::max_element(reverse(last), reverse(first)) ); - * - * last_max_element(first, last, comp) - * Effect: reverse( std::max_element(reverse(last), reverse(first), comp) ); - * - * first_min_first_max_element(first, last) - * Effect: std::make_pair( first_min_element(first, last), - * first_max_element(first, last) ); - * - * first_min_first_max_element(first, last, comp) - * Effect: std::make_pair( first_min_element(first, last, comp), - * first_max_element(first, last, comp) ); - * - * first_min_last_max_element(first, last) - * Effect: std::make_pair( first_min_element(first, last), - * last_max_element(first, last) ); - * - * first_min_last_max_element(first, last, comp) - * Effect: std::make_pair( first_min_element(first, last, comp), - * last_max_element(first, last, comp) ); - * - * last_min_first_max_element(first, last) - * Effect: std::make_pair( last_min_element(first, last), - * first_max_element(first, last) ); - * - * last_min_first_max_element(first, last, comp) - * Effect: std::make_pair( last_min_element(first, last, comp), - * first_max_element(first, last, comp) ); - * - * last_min_last_max_element(first, last) - * Effect: std::make_pair( last_min_element(first, last), - * last_max_element(first, last) ); - * - * last_min_last_max_element(first, last, comp) - * Effect: std::make_pair( last_min_element(first, last, comp), - * last_max_element(first, last, comp) ); - */ - -namespace boost { - - // Min_element and max_element variants - - namespace detail { // common base for the overloads - - template - ForwardIter - basic_first_min_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return last; - ForwardIter min_result = first; - while (++first != last) - if (comp(first, min_result)) - min_result = first; - return min_result; - } - - template - ForwardIter - basic_last_min_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return last; - ForwardIter min_result = first; - while (++first != last) - if (!comp(min_result, first)) - min_result = first; - return min_result; - } - - template - ForwardIter - basic_first_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return last; - ForwardIter max_result = first; - while (++first != last) - if (comp(max_result, first)) - max_result = first; - return max_result; - } - - template - ForwardIter - basic_last_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return last; - ForwardIter max_result = first; - while (++first != last) - if (!comp(first, max_result)) - max_result = first; - return max_result; - } - - } // namespace detail - - template - ForwardIter - first_min_element(ForwardIter first, ForwardIter last) - { - return detail::basic_first_min_element(first, last, - detail::less_over_iter() ); - } - - template - ForwardIter - first_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) - { - return detail::basic_first_min_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - template - ForwardIter - last_min_element(ForwardIter first, ForwardIter last) - { - return detail::basic_last_min_element(first, last, - detail::less_over_iter() ); - } - - template - ForwardIter - last_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) - { - return detail::basic_last_min_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - template - ForwardIter - first_max_element(ForwardIter first, ForwardIter last) - { - return detail::basic_first_max_element(first, last, - detail::less_over_iter() ); - } - - template - ForwardIter - first_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) - { - return detail::basic_first_max_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - template - ForwardIter - last_max_element(ForwardIter first, ForwardIter last) - { - return detail::basic_last_max_element(first, last, - detail::less_over_iter() ); - } - - template - ForwardIter - last_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) - { - return detail::basic_last_max_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - - // Minmax_element variants -- comments removed - - namespace detail { - - template - std::pair - basic_first_min_last_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) - return std::make_pair(last,last); - - ForwardIter min_result = first; - ForwardIter max_result = first; - - ForwardIter second = ++first; - if (second == last) - return std::make_pair(min_result, max_result); - - if (comp(second, min_result)) - min_result = second; - else - max_result = second; - - first = ++second; if (first != last) ++second; - while (second != last) { - if (!comp(second, first)) { - if (comp(first, min_result)) - min_result = first; - if (!comp(second, max_result)) - max_result = second; - } else { - if (comp(second, min_result)) - min_result = second; - if (!comp(first, max_result)) - max_result = first; - } - first = ++second; if (first != last) ++second; - } - - if (first != last) { - if (comp(first, min_result)) - min_result = first; - else if (!comp(first, max_result)) - max_result = first; - } - - return std::make_pair(min_result, max_result); - } - - template - std::pair - basic_last_min_first_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return std::make_pair(last,last); - - ForwardIter min_result = first; - ForwardIter max_result = first; - - ForwardIter second = ++first; - if (second == last) - return std::make_pair(min_result, max_result); - - if (comp(max_result, second)) - max_result = second; - else - min_result = second; - - first = ++second; if (first != last) ++second; - while (second != last) { - if (comp(first, second)) { - if (!comp(min_result, first)) - min_result = first; - if (comp(max_result, second)) - max_result = second; - } else { - if (!comp(min_result, second)) - min_result = second; - if (comp(max_result, first)) - max_result = first; - } - first = ++second; if (first != last) ++second; - } - - if (first != last) { - if (!comp(min_result, first)) - min_result = first; - else if (comp(max_result, first)) - max_result = first; - } - - return std::make_pair(min_result, max_result); - } - - template - std::pair - basic_last_min_last_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - if (first == last) return std::make_pair(last,last); - - ForwardIter min_result = first; - ForwardIter max_result = first; - - ForwardIter second = first; ++second; - if (second == last) - return std::make_pair(min_result,max_result); - - ForwardIter potential_max_result = last; - if (comp(first, second)) - max_result = second; - else { - min_result = second; - potential_max_result = second; - } - - first = ++second; if (first != last) ++second; - while (second != last) { - if (comp(first, second)) { - if (!comp(min_result, first)) - min_result = first; - if (!comp(second, max_result)) { - max_result = second; - potential_max_result = last; - } - } else { - if (!comp(min_result, second)) - min_result = second; - if (!comp(first, max_result)) { - max_result = first; - potential_max_result = second; - } - } - first = ++second; - if (first != last) ++second; - } - - if (first != last) { - if (!comp(min_result, first)) - min_result = first; - if (!comp(first, max_result)) { - max_result = first; - potential_max_result = last; - } - } - - if (potential_max_result != last - && !comp(potential_max_result, max_result)) - max_result = potential_max_result; - - return std::make_pair(min_result,max_result); - } - - } // namespace detail - - template - inline std::pair - first_min_first_max_element(ForwardIter first, ForwardIter last) - { - return minmax_element(first, last); - } - - template - inline std::pair - first_min_first_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - return minmax_element(first, last, comp); - } - - template - std::pair - first_min_last_max_element(ForwardIter first, ForwardIter last) - { - return detail::basic_first_min_last_max_element(first, last, - detail::less_over_iter() ); - } - - template - inline std::pair - first_min_last_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - return detail::basic_first_min_last_max_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - template - std::pair - last_min_first_max_element(ForwardIter first, ForwardIter last) - { - return detail::basic_last_min_first_max_element(first, last, - detail::less_over_iter() ); - } - - template - inline std::pair - last_min_first_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - return detail::basic_last_min_first_max_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - - template - std::pair - last_min_last_max_element(ForwardIter first, ForwardIter last) - { - return detail::basic_last_min_last_max_element(first, last, - detail::less_over_iter() ); - } - - template - inline std::pair - last_min_last_max_element(ForwardIter first, ForwardIter last, - BinaryPredicate comp) - { - return detail::basic_last_min_last_max_element(first, last, - detail::binary_pred_over_iter(comp) ); - } - -} // namespace boost - -#endif // BOOST_ALGORITHM_MINMAX_ELEMENT_HPP diff --git a/boost/algorithm/searching/boyer_moore.hpp b/boost/algorithm/searching/boyer_moore.hpp deleted file mode 100644 index 192d4dec25b3a0d7056aef5f2f020a56831c7b6a..0000000000000000000000000000000000000000 --- a/boost/algorithm/searching/boyer_moore.hpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - Copyright (c) Marshall Clow 2010-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -#ifndef BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP -#define BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP - -#include // for std::iterator_traits - -#include -#include - -#include -#include - -#include -#include - -#include -#include - -namespace boost { namespace algorithm { - -/* - A templated version of the boyer-moore searching algorithm. - -References: - http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/ - http://www.cs.utexas.edu/~moore/publications/fstrpos.pdf - -Explanations: - http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm - http://www.movsd.com/bm.htm - http://www.cs.ucdavis.edu/~gusfield/cs224f09/bnotes.pdf - -The Boyer-Moore search algorithm uses two tables, a "bad character" table -to tell how far to skip ahead when it hits a character that is not in the pattern, -and a "good character" table to tell how far to skip ahead when it hits a -mismatch on a character that _is_ in the pattern. - -Requirements: - * Random access iterators - * The two iterator types (patIter and corpusIter) must - "point to" the same underlying type and be comparable. - * Additional requirements may be imposed but the skip table, such as: - ** Numeric type (array-based skip table) - ** Hashable type (map-based skip table) -*/ - - template > - class boyer_moore { - typedef typename std::iterator_traits::difference_type difference_type; - public: - boyer_moore ( patIter first, patIter last ) - : pat_first ( first ), pat_last ( last ), - k_pattern_length ( std::distance ( pat_first, pat_last )), - skip_ ( k_pattern_length, -1 ), - suffix_ ( k_pattern_length + 1 ) - { - this->build_skip_table ( first, last ); - this->build_suffix_table ( first, last ); - } - - ~boyer_moore () {} - - /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last ) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// - template - std::pair - operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { - BOOST_STATIC_ASSERT (( boost::is_same< - typename std::iterator_traits::value_type, - typename std::iterator_traits::value_type>::value )); - - if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! - if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start - - const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); - // If the pattern is larger than the corpus, we can't find it! - if ( k_corpus_length < k_pattern_length ) - return std::make_pair(corpus_last, corpus_last); - - // Do the search - return this->do_search ( corpus_first, corpus_last ); - } - - template - std::pair::type, typename boost::range_iterator::type> - operator () ( Range &r ) const { - return (*this) (boost::begin(r), boost::end(r)); - } - - private: -/// \cond DOXYGEN_HIDE - patIter pat_first, pat_last; - const difference_type k_pattern_length; - typename traits::skip_table_t skip_; - std::vector suffix_; - - /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// \param p A predicate used for the search comparisons. - /// - template - std::pair - do_search ( corpusIter corpus_first, corpusIter corpus_last ) const { - /* ---- Do the matching ---- */ - corpusIter curPos = corpus_first; - const corpusIter lastPos = corpus_last - k_pattern_length; - difference_type j, k, m; - - while ( curPos <= lastPos ) { - /* while ( std::distance ( curPos, corpus_last ) >= k_pattern_length ) { */ - // Do we match right where we are? - j = k_pattern_length; - while ( pat_first [j-1] == curPos [j-1] ) { - j--; - // We matched - we're done! - if ( j == 0 ) - return std::make_pair(curPos, curPos + k_pattern_length); - } - - // Since we didn't match, figure out how far to skip forward - k = skip_ [ curPos [ j - 1 ]]; - m = j - k - 1; - if ( k < j && m > suffix_ [ j ] ) - curPos += m; - else - curPos += suffix_ [ j ]; - } - - return std::make_pair(corpus_last, corpus_last); // We didn't find anything - } - - - void build_skip_table ( patIter first, patIter last ) { - for ( std::size_t i = 0; first != last; ++first, ++i ) - skip_.insert ( *first, i ); - } - - - template - void compute_bm_prefix ( Iter first, Iter last, Container &prefix ) { - const std::size_t count = std::distance ( first, last ); - BOOST_ASSERT ( count > 0 ); - BOOST_ASSERT ( prefix.size () == count ); - - prefix[0] = 0; - std::size_t k = 0; - for ( std::size_t i = 1; i < count; ++i ) { - BOOST_ASSERT ( k < count ); - while ( k > 0 && ( first[k] != first[i] )) { - BOOST_ASSERT ( k < count ); - k = prefix [ k - 1 ]; - } - - if ( first[k] == first[i] ) - k++; - prefix [ i ] = k; - } - } - - void build_suffix_table ( patIter first, patIter last ) { - const std::size_t count = (std::size_t) std::distance ( first, last ); - - if ( count > 0 ) { // empty pattern - std::vector::value_type> reversed(count); - (void) std::reverse_copy ( first, last, reversed.begin ()); - - std::vector prefix (count); - compute_bm_prefix ( first, last, prefix ); - - std::vector prefix_reversed (count); - compute_bm_prefix ( reversed.begin (), reversed.end (), prefix_reversed ); - - for ( std::size_t i = 0; i <= count; i++ ) - suffix_[i] = count - prefix [count-1]; - - for ( std::size_t i = 0; i < count; i++ ) { - const std::size_t j = count - prefix_reversed[i]; - const difference_type k = i - prefix_reversed[i] + 1; - - if (suffix_[j] > k) - suffix_[j] = k; - } - } - } -/// \endcond - }; - - -/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters - Use a bit of TMP to disambiguate the 3-argument templates */ - -/// \fn boyer_moore_search ( corpusIter corpus_first, corpusIter corpus_last, -/// patIter pat_first, patIter pat_last ) -/// \brief Searches the corpus for the pattern. -/// -/// \param corpus_first The start of the data to search (Random Access Iterator) -/// \param corpus_last One past the end of the data to search -/// \param pat_first The start of the pattern to search for (Random Access Iterator) -/// \param pat_last One past the end of the data to search for -/// - template - std::pair boyer_moore_search ( - corpusIter corpus_first, corpusIter corpus_last, - patIter pat_first, patIter pat_last ) - { - boyer_moore bm ( pat_first, pat_last ); - return bm ( corpus_first, corpus_last ); - } - - template - std::pair boyer_moore_search ( - corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - boyer_moore bm ( boost::begin(pattern), boost::end (pattern)); - return bm ( corpus_first, corpus_last ); - } - - template - typename boost::disable_if_c< - boost::is_same::value, - std::pair::type, typename boost::range_iterator::type> > - ::type - boyer_moore_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) - { - boyer_moore bm ( pat_first, pat_last ); - return bm (boost::begin (corpus), boost::end (corpus)); - } - - template - std::pair::type, typename boost::range_iterator::type> - boyer_moore_search ( CorpusRange &corpus, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - boyer_moore bm ( boost::begin(pattern), boost::end (pattern)); - return bm (boost::begin (corpus), boost::end (corpus)); - } - - - // Creator functions -- take a pattern range, return an object - template - boost::algorithm::boyer_moore::type> - make_boyer_moore ( const Range &r ) { - return boost::algorithm::boyer_moore - ::type> (boost::begin(r), boost::end(r)); - } - - template - boost::algorithm::boyer_moore::type> - make_boyer_moore ( Range &r ) { - return boost::algorithm::boyer_moore - ::type> (boost::begin(r), boost::end(r)); - } - -}} - -#endif // BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP diff --git a/boost/algorithm/searching/boyer_moore_horspool.hpp b/boost/algorithm/searching/boyer_moore_horspool.hpp deleted file mode 100644 index aacb5cb833b2145e8fd925e786ba9b8e908bce23..0000000000000000000000000000000000000000 --- a/boost/algorithm/searching/boyer_moore_horspool.hpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - Copyright (c) Marshall Clow 2010-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -#ifndef BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP -#define BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP - -#include // for std::iterator_traits - -#include -#include - -#include -#include - -#include -#include - -#include -#include - -// #define BOOST_ALGORITHM_BOYER_MOORE_HORSPOOL_DEBUG_HPP - -namespace boost { namespace algorithm { - -/* - A templated version of the boyer-moore-horspool searching algorithm. - - Requirements: - * Random access iterators - * The two iterator types (patIter and corpusIter) must - "point to" the same underlying type. - * Additional requirements may be imposed buy the skip table, such as: - ** Numeric type (array-based skip table) - ** Hashable type (map-based skip table) - -http://www-igm.univ-mlv.fr/%7Elecroq/string/node18.html - -*/ - - template > - class boyer_moore_horspool { - typedef typename std::iterator_traits::difference_type difference_type; - public: - boyer_moore_horspool ( patIter first, patIter last ) - : pat_first ( first ), pat_last ( last ), - k_pattern_length ( std::distance ( pat_first, pat_last )), - skip_ ( k_pattern_length, k_pattern_length ) { - - // Build the skip table - std::size_t i = 0; - if ( first != last ) // empty pattern? - for ( patIter iter = first; iter != last-1; ++iter, ++i ) - skip_.insert ( *iter, k_pattern_length - 1 - i ); -#ifdef BOOST_ALGORITHM_BOYER_MOORE_HORSPOOL_DEBUG_HPP - skip_.PrintSkipTable (); -#endif - } - - ~boyer_moore_horspool () {} - - /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// - template - std::pair - operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { - BOOST_STATIC_ASSERT (( boost::is_same< - typename std::iterator_traits::value_type, - typename std::iterator_traits::value_type>::value )); - - if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! - if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start - - const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); - // If the pattern is larger than the corpus, we can't find it! - if ( k_corpus_length < k_pattern_length ) - return std::make_pair(corpus_last, corpus_last); - - // Do the search - return this->do_search ( corpus_first, corpus_last ); - } - - template - std::pair::type, typename boost::range_iterator::type> - operator () ( Range &r ) const { - return (*this) (boost::begin(r), boost::end(r)); - } - - private: -/// \cond DOXYGEN_HIDE - patIter pat_first, pat_last; - const difference_type k_pattern_length; - typename traits::skip_table_t skip_; - - /// \fn do_search ( corpusIter corpus_first, corpusIter corpus_last ) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// \param k_corpus_length The length of the corpus to search - /// - template - std::pair - do_search ( corpusIter corpus_first, corpusIter corpus_last ) const { - corpusIter curPos = corpus_first; - const corpusIter lastPos = corpus_last - k_pattern_length; - while ( curPos <= lastPos ) { - // Do we match right where we are? - std::size_t j = k_pattern_length - 1; - while ( pat_first [j] == curPos [j] ) { - // We matched - we're done! - if ( j == 0 ) - return std::make_pair(curPos, curPos + k_pattern_length); - j--; - } - - curPos += skip_ [ curPos [ k_pattern_length - 1 ]]; - } - - return std::make_pair(corpus_last, corpus_last); - } -// \endcond - }; - -/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters - Use a bit of TMP to disambiguate the 3-argument templates */ - -/// \fn boyer_moore_horspool_search ( corpusIter corpus_first, corpusIter corpus_last, -/// patIter pat_first, patIter pat_last ) -/// \brief Searches the corpus for the pattern. -/// -/// \param corpus_first The start of the data to search (Random Access Iterator) -/// \param corpus_last One past the end of the data to search -/// \param pat_first The start of the pattern to search for (Random Access Iterator) -/// \param pat_last One past the end of the data to search for -/// - template - std::pair boyer_moore_horspool_search ( - corpusIter corpus_first, corpusIter corpus_last, - patIter pat_first, patIter pat_last ) - { - boyer_moore_horspool bmh ( pat_first, pat_last ); - return bmh ( corpus_first, corpus_last ); - } - - template - std::pair boyer_moore_horspool_search ( - corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - boyer_moore_horspool bmh ( boost::begin(pattern), boost::end (pattern)); - return bmh ( corpus_first, corpus_last ); - } - - template - typename boost::disable_if_c< - boost::is_same::value, - std::pair::type, typename boost::range_iterator::type> > - ::type - boyer_moore_horspool_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) - { - boyer_moore_horspool bmh ( pat_first, pat_last ); - return bm (boost::begin (corpus), boost::end (corpus)); - } - - template - std::pair::type, typename boost::range_iterator::type> - boyer_moore_horspool_search ( CorpusRange &corpus, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - boyer_moore_horspool bmh ( boost::begin(pattern), boost::end (pattern)); - return bmh (boost::begin (corpus), boost::end (corpus)); - } - - - // Creator functions -- take a pattern range, return an object - template - boost::algorithm::boyer_moore_horspool::type> - make_boyer_moore_horspool ( const Range &r ) { - return boost::algorithm::boyer_moore_horspool - ::type> (boost::begin(r), boost::end(r)); - } - - template - boost::algorithm::boyer_moore_horspool::type> - make_boyer_moore_horspool ( Range &r ) { - return boost::algorithm::boyer_moore_horspool - ::type> (boost::begin(r), boost::end(r)); - } - -}} - -#endif // BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP diff --git a/boost/algorithm/searching/detail/bm_traits.hpp b/boost/algorithm/searching/detail/bm_traits.hpp deleted file mode 100644 index 12143636be0f88bc05e0d10c8e84138d71ab6221..0000000000000000000000000000000000000000 --- a/boost/algorithm/searching/detail/bm_traits.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright (c) Marshall Clow 2010-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -#ifndef BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP -#define BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP - -#include // for CHAR_BIT -#include -#include // for std::iterator_traits - -#include -#include -#include -#include - -#include -#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP -#include -#else -#include -#endif - -#include - -namespace boost { namespace algorithm { namespace detail { - -// -// Default implementations of the skip tables for B-M and B-M-H -// - template class skip_table; - -// General case for data searching other than bytes; use a map - template - class skip_table { - private: -#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP - typedef boost::unordered_map skip_map; -#else - typedef std::unordered_map skip_map; -#endif - const value_type k_default_value; - skip_map skip_; - - public: - skip_table ( std::size_t patSize, value_type default_value ) - : k_default_value ( default_value ), skip_ ( patSize ) {} - - void insert ( key_type key, value_type val ) { - skip_ [ key ] = val; // Would skip_.insert (val) be better here? - } - - value_type operator [] ( key_type key ) const { - typename skip_map::const_iterator it = skip_.find ( key ); - return it == skip_.end () ? k_default_value : it->second; - } - - void PrintSkipTable () const { - std::cout << "BM(H) Skip Table :" << std::endl; - for ( typename skip_map::const_iterator it = skip_.begin (); it != skip_.end (); ++it ) - if ( it->second != k_default_value ) - std::cout << " " << it->first << ": " << it->second << std::endl; - std::cout << std::endl; - } - }; - - -// Special case small numeric values; use an array - template - class skip_table { - private: - typedef typename boost::make_unsigned::type unsigned_key_type; - typedef boost::array skip_map; - skip_map skip_; - const value_type k_default_value; - public: - skip_table ( std::size_t /*patSize*/, value_type default_value ) : k_default_value ( default_value ) { - std::fill_n ( skip_.begin(), skip_.size(), default_value ); - } - - void insert ( key_type key, value_type val ) { - skip_ [ static_cast ( key ) ] = val; - } - - value_type operator [] ( key_type key ) const { - return skip_ [ static_cast ( key ) ]; - } - - void PrintSkipTable () const { - std::cout << "BM(H) Skip Table :" << std::endl; - for ( typename skip_map::const_iterator it = skip_.begin (); it != skip_.end (); ++it ) - if ( *it != k_default_value ) - std::cout << " " << std::distance (skip_.begin (), it) << ": " << *it << std::endl; - std::cout << std::endl; - } - }; - - template - struct BM_traits { - typedef typename std::iterator_traits::difference_type value_type; - typedef typename std::iterator_traits::value_type key_type; - typedef boost::algorithm::detail::skip_table::value && (sizeof(key_type)==1)> skip_table_t; - }; - -}}} // namespaces - -#endif // BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP diff --git a/boost/algorithm/searching/detail/debugging.hpp b/boost/algorithm/searching/detail/debugging.hpp deleted file mode 100644 index 3996e0f503c129397e451dfed6db6d6e6cf44494..0000000000000000000000000000000000000000 --- a/boost/algorithm/searching/detail/debugging.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (c) Marshall Clow 2010-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -#ifndef BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP -#define BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP - -#include -/// \cond DOXYGEN_HIDE - -namespace boost { namespace algorithm { namespace detail { - -// Debugging support - template - void PrintTable ( Iter first, Iter last ) { - std::cout << std::distance ( first, last ) << ": { "; - for ( Iter iter = first; iter != last; ++iter ) - std::cout << *iter << " "; - std::cout << "}" << std::endl; - } - -}}} -/// \endcond - -#endif // BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP diff --git a/boost/algorithm/searching/knuth_morris_pratt.hpp b/boost/algorithm/searching/knuth_morris_pratt.hpp deleted file mode 100644 index 5b5b64a729a812ccd71d825b7a103756fb622247..0000000000000000000000000000000000000000 --- a/boost/algorithm/searching/knuth_morris_pratt.hpp +++ /dev/null @@ -1,263 +0,0 @@ -/* - Copyright (c) Marshall Clow 2010-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - For more information, see http://www.boost.org -*/ - -#ifndef BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP -#define BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP - -#include -#include // for std::iterator_traits - -#include -#include - -#include -#include - -#include -#include - -#include - -// #define BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_DEBUG - -namespace boost { namespace algorithm { - -// #define NEW_KMP - -/* - A templated version of the Knuth-Morris-Pratt searching algorithm. - - Requirements: - * Random-access iterators - * The two iterator types (I1 and I2) must "point to" the same underlying type. - - http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm - http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/kmpen.htm -*/ - - template - class knuth_morris_pratt { - typedef typename std::iterator_traits::difference_type difference_type; - public: - knuth_morris_pratt ( patIter first, patIter last ) - : pat_first ( first ), pat_last ( last ), - k_pattern_length ( std::distance ( pat_first, pat_last )), - skip_ ( k_pattern_length + 1 ) { -#ifdef NEW_KMP - preKmp ( pat_first, pat_last ); -#else - init_skip_table ( pat_first, pat_last ); -#endif -#ifdef BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_DEBUG - detail::PrintTable ( skip_.begin (), skip_.end ()); -#endif - } - - ~knuth_morris_pratt () {} - - /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// \param p A predicate used for the search comparisons. - /// - template - std::pair - operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { - BOOST_STATIC_ASSERT (( boost::is_same< - typename std::iterator_traits::value_type, - typename std::iterator_traits::value_type>::value )); - - if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! - if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start - - const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); - // If the pattern is larger than the corpus, we can't find it! - if ( k_corpus_length < k_pattern_length ) - return std::make_pair(corpus_last, corpus_last); - - return do_search ( corpus_first, corpus_last, k_corpus_length ); - } - - template - std::pair::type, typename boost::range_iterator::type> - operator () ( Range &r ) const { - return (*this) (boost::begin(r), boost::end(r)); - } - - private: -/// \cond DOXYGEN_HIDE - patIter pat_first, pat_last; - const difference_type k_pattern_length; - std::vector skip_; - - /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) - /// \brief Searches the corpus for the pattern that was passed into the constructor - /// - /// \param corpus_first The start of the data to search (Random Access Iterator) - /// \param corpus_last One past the end of the data to search - /// \param p A predicate used for the search comparisons. - /// - template - std::pair - do_search ( corpusIter corpus_first, corpusIter corpus_last, - difference_type k_corpus_length ) const { - difference_type match_start = 0; // position in the corpus that we're matching - -#ifdef NEW_KMP - int patternIdx = 0; - while ( match_start < k_corpus_length ) { - while ( patternIdx > -1 && pat_first[patternIdx] != corpus_first [match_start] ) - patternIdx = skip_ [patternIdx]; //<--- Shifting the pattern on mismatch - - patternIdx++; - match_start++; //<--- corpus is always increased by 1 - - if ( patternIdx >= (int) k_pattern_length ) - return corpus_first + match_start - patternIdx; - } - -#else -// At this point, we know: -// k_pattern_length <= k_corpus_length -// for all elements of skip, it holds -1 .. k_pattern_length -// -// In the loop, we have the following invariants -// idx is in the range 0 .. k_pattern_length -// match_start is in the range 0 .. k_corpus_length - k_pattern_length + 1 - - const difference_type last_match = k_corpus_length - k_pattern_length; - difference_type idx = 0; // position in the pattern we're comparing - - while ( match_start <= last_match ) { - while ( pat_first [ idx ] == corpus_first [ match_start + idx ] ) { - if ( ++idx == k_pattern_length ) - return std::make_pair(corpus_first + match_start, corpus_first + match_start + k_pattern_length); - } - // Figure out where to start searching again - // assert ( idx - skip_ [ idx ] > 0 ); // we're always moving forward - match_start += idx - skip_ [ idx ]; - idx = skip_ [ idx ] >= 0 ? skip_ [ idx ] : 0; - // assert ( idx >= 0 && idx < k_pattern_length ); - } -#endif - - // We didn't find anything - return std::make_pair(corpus_last, corpus_last); - } - - - void preKmp ( patIter first, patIter last ) { - const difference_type count = std::distance ( first, last ); - - difference_type i, j; - - i = 0; - j = skip_[0] = -1; - while (i < count) { - while (j > -1 && first[i] != first[j]) - j = skip_[j]; - i++; - j++; - if (first[i] == first[j]) - skip_[i] = skip_[j]; - else - skip_[i] = j; - } - } - - - void init_skip_table ( patIter first, patIter last ) { - const difference_type count = std::distance ( first, last ); - - difference_type j; - skip_ [ 0 ] = -1; - for ( int i = 1; i <= count; ++i ) { - j = skip_ [ i - 1 ]; - while ( j >= 0 ) { - if ( first [ j ] == first [ i - 1 ] ) - break; - j = skip_ [ j ]; - } - skip_ [ i ] = j + 1; - } - } -// \endcond - }; - - -/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters - Use a bit of TMP to disambiguate the 3-argument templates */ - -/// \fn knuth_morris_pratt_search ( corpusIter corpus_first, corpusIter corpus_last, -/// patIter pat_first, patIter pat_last ) -/// \brief Searches the corpus for the pattern. -/// -/// \param corpus_first The start of the data to search (Random Access Iterator) -/// \param corpus_last One past the end of the data to search -/// \param pat_first The start of the pattern to search for (Random Access Iterator) -/// \param pat_last One past the end of the data to search for -/// - template - std::pair knuth_morris_pratt_search ( - corpusIter corpus_first, corpusIter corpus_last, - patIter pat_first, patIter pat_last ) - { - knuth_morris_pratt kmp ( pat_first, pat_last ); - return kmp ( corpus_first, corpus_last ); - } - - template - std::pair knuth_morris_pratt_search ( - corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - knuth_morris_pratt kmp ( boost::begin(pattern), boost::end (pattern)); - return kmp ( corpus_first, corpus_last ); - } - - template - typename boost::disable_if_c< - boost::is_same::value, - std::pair::type, typename boost::range_iterator::type> > - ::type - knuth_morris_pratt_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) - { - knuth_morris_pratt kmp ( pat_first, pat_last ); - return kmp (boost::begin (corpus), boost::end (corpus)); - } - - template - std::pair::type, typename boost::range_iterator::type> - knuth_morris_pratt_search ( CorpusRange &corpus, const PatternRange &pattern ) - { - typedef typename boost::range_iterator::type pattern_iterator; - knuth_morris_pratt kmp ( boost::begin(pattern), boost::end (pattern)); - return kmp (boost::begin (corpus), boost::end (corpus)); - } - - - // Creator functions -- take a pattern range, return an object - template - boost::algorithm::knuth_morris_pratt::type> - make_knuth_morris_pratt ( const Range &r ) { - return boost::algorithm::knuth_morris_pratt - ::type> (boost::begin(r), boost::end(r)); - } - - template - boost::algorithm::knuth_morris_pratt::type> - make_knuth_morris_pratt ( Range &r ) { - return boost::algorithm::knuth_morris_pratt - ::type> (boost::begin(r), boost::end(r)); - } -}} - -#endif // BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP diff --git a/boost/algorithm/sort_subrange.hpp b/boost/algorithm/sort_subrange.hpp deleted file mode 100644 index 7fb2cb55d011706c4c9d0e9c627e0861118a7f5d..0000000000000000000000000000000000000000 --- a/boost/algorithm/sort_subrange.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (c) Marshall Clow 2008-2012. - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Revision history: - 28 Sep 2015 mtc First version - -*/ - -/// \file sort_subrange.hpp -/// \brief Sort a subrange -/// \author Marshall Clow -/// -/// Suggested by Sean Parent in his CppCon 2015 keynote - -#ifndef BOOST_ALGORITHM_SORT_SUBRANGE_HPP -#define BOOST_ALGORITHM_SORT_SUBRANGE_HPP - -#include // For std::less -#include // For std::iterator_traits -#include // For nth_element and partial_sort - -#include -#include - -namespace boost { namespace algorithm { - -/// \fn sort_subrange ( T const& val, -/// Iterator first, Iterator last, -/// Iterator sub_first, Iterator sub_last, -/// Pred p ) -/// \brief Sort the subrange [sub_first, sub_last) that is inside -/// the range [first, last) as if you had sorted the entire range. -/// -/// \param first The start of the larger range -/// \param last The end of the larger range -/// \param sub_first The start of the sub range -/// \param sub_last The end of the sub range -/// \param p A predicate to use to compare the values. -/// p ( a, b ) returns a boolean. -/// - template - void sort_subrange ( - Iterator first, Iterator last, - Iterator sub_first, Iterator sub_last, - Pred p) - { - if (sub_first == sub_last) return; // the empty sub-range is already sorted. - - if (sub_first != first) { // sub-range is at the start, don't need to partition - (void) std::nth_element(first, sub_first, last, p); - ++sub_first; - } - std::partial_sort(sub_first, sub_last, last, p); - } - - - - template - void sort_subrange (Iterator first, Iterator last, Iterator sub_first, Iterator sub_last) - { - typedef typename std::iterator_traits::value_type value_type; - return sort_subrange(first, last, sub_first, sub_last, std::less()); - } - -/// range versions? - - -/// \fn partition_subrange ( T const& val, -/// Iterator first, Iterator last, -/// Iterator sub_first, Iterator sub_last, -/// Pred p ) -/// \brief Gather the elements of the subrange [sub_first, sub_last) that is -/// inside the range [first, last) as if you had sorted the entire range. -/// -/// \param first The start of the larger range -/// \param last The end of the larger range -/// \param sub_first The start of the sub range -/// \param sub_last The end of the sub range -/// \param p A predicate to use to compare the values. -/// p ( a, b ) returns a boolean. -/// - template - void partition_subrange ( - Iterator first, Iterator last, - Iterator sub_first, Iterator sub_last, - Pred p) - { - if (sub_first != first) { - (void) std::nth_element(first, sub_first, last, p); - ++sub_first; - } - - if (sub_last != last) - (void) std::nth_element(sub_first, sub_last, last, p); - } - - template - void partition_subrange (Iterator first, Iterator last, Iterator sub_first, Iterator sub_last) - { - typedef typename std::iterator_traits::value_type value_type; - return partition_subrange(first, last, sub_first, sub_last, std::less()); - } - -}} - -#endif // BOOST_ALGORITHM_SORT_SUBRANGE_HPP diff --git a/boost/algorithm/string.hpp b/boost/algorithm/string.hpp deleted file mode 100644 index 0771517396465dc1b2d98beb3222159aca9a636a..0000000000000000000000000000000000000000 --- a/boost/algorithm/string.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Boost string_algo library string_algo.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-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/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_ALGO_HPP -#define BOOST_STRING_ALGO_HPP - -/*! \file - Cumulative include for string_algo library -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#endif // BOOST_STRING_ALGO_HPP diff --git a/boost/algorithm/string/case_conv.hpp b/boost/algorithm/string/case_conv.hpp deleted file mode 100644 index 683340b8ec8d7d039dfc1cbfbbf63a6aadc8a448..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/case_conv.hpp +++ /dev/null @@ -1,176 +0,0 @@ -// Boost string_algo library case_conv.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CASE_CONV_HPP -#define BOOST_STRING_CASE_CONV_HPP - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -/*! \file - Defines sequence case-conversion algorithms. - Algorithms convert each element in the input sequence to the - desired case using provided locales. -*/ - -namespace boost { - namespace algorithm { - -// to_lower -----------------------------------------------// - - //! Convert to lower case - /*! - Each element of the input sequence is converted to lower - case. The result is a copy of the input converted to lower case. - It is returned as a sequence or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input range - \param Loc A locale used for conversion - \return - An output iterator pointing just after the last inserted character or - a copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - - */ - template - inline OutputIteratorT - to_lower_copy( - OutputIteratorT Output, - const RangeT& Input, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::detail::transform_range_copy( - Output, - ::boost::as_literal(Input), - ::boost::algorithm::detail::to_lowerF< - typename range_value::type >(Loc)); - } - - //! Convert to lower case - /*! - \overload - */ - template - inline SequenceT to_lower_copy( - const SequenceT& Input, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::detail::transform_range_copy( - Input, - ::boost::algorithm::detail::to_lowerF< - typename range_value::type >(Loc)); - } - - //! Convert to lower case - /*! - Each element of the input sequence is converted to lower - case. The input sequence is modified in-place. - - \param Input A range - \param Loc a locale used for conversion - */ - template - inline void to_lower( - WritableRangeT& Input, - const std::locale& Loc=std::locale()) - { - ::boost::algorithm::detail::transform_range( - ::boost::as_literal(Input), - ::boost::algorithm::detail::to_lowerF< - typename range_value::type >(Loc)); - } - -// to_upper -----------------------------------------------// - - //! Convert to upper case - /*! - Each element of the input sequence is converted to upper - case. The result is a copy of the input converted to upper case. - It is returned as a sequence or copied to the output iterator - - \param Output An output iterator to which the result will be copied - \param Input An input range - \param Loc A locale used for conversion - \return - An output iterator pointing just after the last inserted character or - a copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template - inline OutputIteratorT - to_upper_copy( - OutputIteratorT Output, - const RangeT& Input, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::detail::transform_range_copy( - Output, - ::boost::as_literal(Input), - ::boost::algorithm::detail::to_upperF< - typename range_value::type >(Loc)); - } - - //! Convert to upper case - /*! - \overload - */ - template - inline SequenceT to_upper_copy( - const SequenceT& Input, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::detail::transform_range_copy( - Input, - ::boost::algorithm::detail::to_upperF< - typename range_value::type >(Loc)); - } - - //! Convert to upper case - /*! - Each element of the input sequence is converted to upper - case. The input sequence is modified in-place. - - \param Input An input range - \param Loc a locale used for conversion - */ - template - inline void to_upper( - WritableRangeT& Input, - const std::locale& Loc=std::locale()) - { - ::boost::algorithm::detail::transform_range( - ::boost::as_literal(Input), - ::boost::algorithm::detail::to_upperF< - typename range_value::type >(Loc)); - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::to_lower; - using algorithm::to_lower_copy; - using algorithm::to_upper; - using algorithm::to_upper_copy; - -} // namespace boost - -#endif // BOOST_STRING_CASE_CONV_HPP diff --git a/boost/algorithm/string/classification.hpp b/boost/algorithm/string/classification.hpp deleted file mode 100644 index ca43602d47207d960ac8ab23152f64c823afc298..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/classification.hpp +++ /dev/null @@ -1,312 +0,0 @@ -// Boost string_algo library classification.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CLASSIFICATION_HPP -#define BOOST_STRING_CLASSIFICATION_HPP - -#include -#include -#include -#include -#include -#include - - -/*! \file - Classification predicates are included in the library to give - some more convenience when using algorithms like \c trim() and \c all(). - They wrap functionality of STL classification functions ( e.g. \c std::isspace() ) - into generic functors. -*/ - -namespace boost { - namespace algorithm { - -// classification functor generator -------------------------------------// - - //! is_classified predicate - /*! - Construct the \c is_classified predicate. This predicate holds if the input is - of specified \c std::ctype category. - - \param Type A \c std::ctype category - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_classified(std::ctype_base::mask Type, const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(Type, Loc); - } - - //! is_space predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::space category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_space(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::space, Loc); - } - - //! is_alnum predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::alnum category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_alnum(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::alnum, Loc); - } - - //! is_alpha predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::alpha category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_alpha(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::alpha, Loc); - } - - //! is_cntrl predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::cntrl category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_cntrl(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::cntrl, Loc); - } - - //! is_digit predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::digit category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_digit(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::digit, Loc); - } - - //! is_graph predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::graph category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_graph(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::graph, Loc); - } - - //! is_lower predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::lower category. - - \param Loc A locale used for classification - \return An instance of \c is_classified predicate - */ - inline detail::is_classifiedF - is_lower(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::lower, Loc); - } - - //! is_print predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::print category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_print(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::print, Loc); - } - - //! is_punct predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::punct category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_punct(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::punct, Loc); - } - - //! is_upper predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::upper category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_upper(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::upper, Loc); - } - - //! is_xdigit predicate - /*! - Construct the \c is_classified predicate for the \c ctype_base::xdigit category. - - \param Loc A locale used for classification - \return An instance of the \c is_classified predicate - */ - inline detail::is_classifiedF - is_xdigit(const std::locale& Loc=std::locale()) - { - return detail::is_classifiedF(std::ctype_base::xdigit, Loc); - } - - //! is_any_of predicate - /*! - Construct the \c is_any_of predicate. The predicate holds if the input - is included in the specified set of characters. - - \param Set A set of characters to be recognized - \return An instance of the \c is_any_of predicate - */ - template - inline detail::is_any_ofF< - BOOST_STRING_TYPENAME range_value::type> - is_any_of( const RangeT& Set ) - { - iterator_range::type> lit_set(boost::as_literal(Set)); - return detail::is_any_ofF::type>(lit_set); - } - - //! is_from_range predicate - /*! - Construct the \c is_from_range predicate. The predicate holds if the input - is included in the specified range. (i.e. From <= Ch <= To ) - - \param From The start of the range - \param To The end of the range - \return An instance of the \c is_from_range predicate - */ - template - inline detail::is_from_rangeF is_from_range(CharT From, CharT To) - { - return detail::is_from_rangeF(From,To); - } - - // predicate combinators ---------------------------------------------------// - - //! predicate 'and' composition predicate - /*! - Construct the \c class_and predicate. This predicate can be used - to logically combine two classification predicates. \c class_and holds, - if both predicates return true. - - \param Pred1 The first predicate - \param Pred2 The second predicate - \return An instance of the \c class_and predicate - */ - template - inline detail::pred_andF - operator&&( - const predicate_facade& Pred1, - const predicate_facade& Pred2 ) - { - // Doing the static_cast with the pointer instead of the reference - // is a workaround for some compilers which have problems with - // static_cast's of template references, i.e. CW8. /grafik/ - return detail::pred_andF( - *static_cast(&Pred1), - *static_cast(&Pred2) ); - } - - //! predicate 'or' composition predicate - /*! - Construct the \c class_or predicate. This predicate can be used - to logically combine two classification predicates. \c class_or holds, - if one of the predicates return true. - - \param Pred1 The first predicate - \param Pred2 The second predicate - \return An instance of the \c class_or predicate - */ - template - inline detail::pred_orF - operator||( - const predicate_facade& Pred1, - const predicate_facade& Pred2 ) - { - // Doing the static_cast with the pointer instead of the reference - // is a workaround for some compilers which have problems with - // static_cast's of template references, i.e. CW8. /grafik/ - return detail::pred_orF( - *static_cast(&Pred1), - *static_cast(&Pred2)); - } - - //! predicate negation operator - /*! - Construct the \c class_not predicate. This predicate represents a negation. - \c class_or holds if of the predicates return false. - - \param Pred The predicate to be negated - \return An instance of the \c class_not predicate - */ - template - inline detail::pred_notF - operator!( const predicate_facade& Pred ) - { - // Doing the static_cast with the pointer instead of the reference - // is a workaround for some compilers which have problems with - // static_cast's of template references, i.e. CW8. /grafik/ - return detail::pred_notF(*static_cast(&Pred)); - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::is_classified; - using algorithm::is_space; - using algorithm::is_alnum; - using algorithm::is_alpha; - using algorithm::is_cntrl; - using algorithm::is_digit; - using algorithm::is_graph; - using algorithm::is_lower; - using algorithm::is_upper; - using algorithm::is_print; - using algorithm::is_punct; - using algorithm::is_xdigit; - using algorithm::is_any_of; - using algorithm::is_from_range; - -} // namespace boost - -#endif // BOOST_STRING_PREDICATE_HPP diff --git a/boost/algorithm/string/compare.hpp b/boost/algorithm/string/compare.hpp deleted file mode 100644 index 734303a9a99c2e16dfc5138c724dadc0a29627da..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/compare.hpp +++ /dev/null @@ -1,199 +0,0 @@ -// Boost string_algo library compare.hpp header file -------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_COMPARE_HPP -#define BOOST_STRING_COMPARE_HPP - -#include -#include - -/*! \file - Defines element comparison predicates. Many algorithms in this library can - take an additional argument with a predicate used to compare elements. - This makes it possible, for instance, to have case insensitive versions - of the algorithms. -*/ - -namespace boost { - namespace algorithm { - - // is_equal functor -----------------------------------------------// - - //! is_equal functor - /*! - Standard STL equal_to only handle comparison between arguments - of the same type. This is a less restrictive version which wraps operator ==. - */ - struct is_equal - { - //! Function operator - /*! - Compare two operands for equality - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - return Arg1==Arg2; - } - }; - - //! case insensitive version of is_equal - /*! - Case insensitive comparison predicate. Comparison is done using - specified locales. - */ - struct is_iequal - { - //! Constructor - /*! - \param Loc locales used for comparison - */ - is_iequal( const std::locale& Loc=std::locale() ) : - m_Loc( Loc ) {} - - //! Function operator - /*! - Compare two operands. Case is ignored. - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper(Arg1)==std::toupper(Arg2); - #else - return std::toupper(Arg1,m_Loc)==std::toupper(Arg2,m_Loc); - #endif - } - - private: - std::locale m_Loc; - }; - - // is_less functor -----------------------------------------------// - - //! is_less functor - /*! - Convenient version of standard std::less. Operation is templated, therefore it is - not required to specify the exact types upon the construction - */ - struct is_less - { - //! Functor operation - /*! - Compare two operands using > operator - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - return Arg1 - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper(Arg1)(Arg1,m_Loc)(Arg2,m_Loc); - #endif - } - - private: - std::locale m_Loc; - }; - - // is_not_greater functor -----------------------------------------------// - - //! is_not_greater functor - /*! - Convenient version of standard std::not_greater_to. Operation is templated, therefore it is - not required to specify the exact types upon the construction - */ - struct is_not_greater - { - //! Functor operation - /*! - Compare two operands using > operator - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - return Arg1<=Arg2; - } - }; - - - //! case insensitive version of is_not_greater - /*! - Case insensitive comparison predicate. Comparison is done using - specified locales. - */ - struct is_not_igreater - { - //! Constructor - /*! - \param Loc locales used for comparison - */ - is_not_igreater( const std::locale& Loc=std::locale() ) : - m_Loc( Loc ) {} - - //! Function operator - /*! - Compare two operands. Case is ignored. - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper(Arg1)<=std::toupper(Arg2); - #else - return std::toupper(Arg1,m_Loc)<=std::toupper(Arg2,m_Loc); - #endif - } - - private: - std::locale m_Loc; - }; - - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::is_equal; - using algorithm::is_iequal; - using algorithm::is_less; - using algorithm::is_iless; - using algorithm::is_not_greater; - using algorithm::is_not_igreater; - -} // namespace boost - - -#endif // BOOST_STRING_COMPARE_HPP diff --git a/boost/algorithm/string/concept.hpp b/boost/algorithm/string/concept.hpp deleted file mode 100644 index 17e8349596bd3602426ceaa770ee1f338f46f5b4..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/concept.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Boost string_algo library concept.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CONCEPT_HPP -#define BOOST_STRING_CONCEPT_HPP - -#include -#include -#include -#include - -/*! \file - Defines concepts used in string_algo library -*/ - -namespace boost { - namespace algorithm { - - //! Finder concept - /*! - Defines the Finder concept. Finder is a functor which selects - an arbitrary part of a string. Search is performed on - the range specified by starting and ending iterators. - - Result of the find operation must be convertible to iterator_range. - */ - template - struct FinderConcept - { - private: - typedef iterator_range range; - public: - void constraints() - { - // Operation - r=(*pF)(i,i); - } - private: - range r; - IteratorT i; - FinderT* pF; - }; // Finder_concept - - - //! Formatter concept - /*! - Defines the Formatter concept. Formatter is a functor, which - takes a result from a finder operation and transforms it - in a specific way. - - Result must be a container supported by container_traits, - or a reference to it. - */ - template - struct FormatterConcept - { - public: - void constraints() - { - // Operation - ::boost::begin((*pFo)( (*pF)(i,i) )); - ::boost::end((*pFo)( (*pF)(i,i) )); - } - private: - IteratorT i; - FinderT* pF; - FormatterT *pFo; - }; // FormatterConcept; - - } // namespace algorithm -} // namespace boost - - - - -#endif // BOOST_STRING_CONCEPT_HPP diff --git a/boost/algorithm/string/config.hpp b/boost/algorithm/string/config.hpp deleted file mode 100644 index 559750ac8aaaabf98b236e90cb9d77472f1f5808..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/config.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Boost string_algo library config.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CONFIG_HPP -#define BOOST_STRING_CONFIG_HPP - -#include -#include - -#ifdef BOOST_STRING_DEDUCED_TYPENAME -# error "macro already defined!" -#endif - -#define BOOST_STRING_TYPENAME BOOST_DEDUCED_TYPENAME - -// Metrowerks workaround -#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x -#pragma parse_func_templ off -#endif - -#endif // BOOST_STRING_CONFIG_HPP diff --git a/boost/algorithm/string/constants.hpp b/boost/algorithm/string/constants.hpp deleted file mode 100644 index 6ed70effcae6aa143c0fd4e9f30674ee7e524bf4..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/constants.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Boost string_algo library constants.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CONSTANTS_HPP -#define BOOST_STRING_CONSTANTS_HPP - -namespace boost { - namespace algorithm { - - //! Token compression mode - /*! - Specifies token compression mode for the token_finder. - */ - enum token_compress_mode_type - { - token_compress_on, //!< Compress adjacent tokens - token_compress_off //!< Do not compress adjacent tokens - }; - - } // namespace algorithm - - // pull the names to the boost namespace - using algorithm::token_compress_on; - using algorithm::token_compress_off; - -} // namespace boost - -#endif // BOOST_STRING_CONSTANTS_HPP - diff --git a/boost/algorithm/string/detail/case_conv.hpp b/boost/algorithm/string/detail/case_conv.hpp deleted file mode 100644 index 233912ca0f201d957894dde4fde7c309e7140660..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/case_conv.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// Boost string_algo library string_funct.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP -#define BOOST_STRING_CASE_CONV_DETAIL_HPP - -#include -#include -#include - -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// case conversion functors -----------------------------------------------// - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - // a tolower functor - template - struct to_lowerF - { - typedef CharT argument_type; - typedef CharT result_type; - // Constructor - to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {} - - // Operation - CharT operator ()( CharT Ch ) const - { - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::tolower( static_cast::type> ( Ch )); - #else - return std::tolower( Ch, *m_Loc ); - #endif - } - private: - const std::locale* m_Loc; - }; - - // a toupper functor - template - struct to_upperF - { - typedef CharT argument_type; - typedef CharT result_type; - // Constructor - to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {} - - // Operation - CharT operator ()( CharT Ch ) const - { - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper( static_cast::type> ( Ch )); - #else - return std::toupper( Ch, *m_Loc ); - #endif - } - private: - const std::locale* m_Loc; - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - -// algorithm implementation ------------------------------------------------------------------------- - - // Transform a range - template - OutputIteratorT transform_range_copy( - OutputIteratorT Output, - const RangeT& Input, - FunctorT Functor) - { - return std::transform( - ::boost::begin(Input), - ::boost::end(Input), - Output, - Functor); - } - - // Transform a range (in-place) - template - void transform_range( - const RangeT& Input, - FunctorT Functor) - { - std::transform( - ::boost::begin(Input), - ::boost::end(Input), - ::boost::begin(Input), - Functor); - } - - template - inline SequenceT transform_range_copy( - const RangeT& Input, - FunctorT Functor) - { - return SequenceT( - ::boost::make_transform_iterator( - ::boost::begin(Input), - Functor), - ::boost::make_transform_iterator( - ::boost::end(Input), - Functor)); - } - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_CASE_CONV_DETAIL_HPP diff --git a/boost/algorithm/string/detail/classification.hpp b/boost/algorithm/string/detail/classification.hpp deleted file mode 100644 index 704d9d20ff45aa691426baa95c748e3f5aed6b88..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/classification.hpp +++ /dev/null @@ -1,353 +0,0 @@ -// Boost string_algo library classification.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP -#define BOOST_STRING_CLASSIFICATION_DETAIL_HPP - -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// classification functors -----------------------------------------------// - - // is_classified functor - struct is_classifiedF : - public predicate_facade - { - // Boost.ResultOf support - typedef bool result_type; - - // Constructor from a locale - is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) : - m_Type(Type), m_Locale(Loc) {} - // Operation - template - bool operator()( CharT Ch ) const - { - return std::use_facet< std::ctype >(m_Locale).is( m_Type, Ch ); - } - - #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x582) && !defined(_USE_OLD_RW_STL) - template<> - bool operator()( char const Ch ) const - { - return std::use_facet< std::ctype >(m_Locale).is( m_Type, Ch ); - } - #endif - - private: - std::ctype_base::mask m_Type; - std::locale m_Locale; - }; - - - // is_any_of functor - /* - returns true if the value is from the specified set - */ - template - struct is_any_ofF : - public predicate_facade > - { - private: - // set cannot operate on const value-type - typedef typename ::boost::remove_const::type set_value_type; - - public: - // Boost.ResultOf support - typedef bool result_type; - - // Constructor - template - is_any_ofF( const RangeT& Range ) : m_Size(0) - { - // Prepare storage - m_Storage.m_dynSet=0; - - std::size_t Size=::boost::distance(Range); - m_Size=Size; - set_value_type* Storage=0; - - if(use_fixed_storage(m_Size)) - { - // Use fixed storage - Storage=&m_Storage.m_fixSet[0]; - } - else - { - // Use dynamic storage - m_Storage.m_dynSet=new set_value_type[m_Size]; - Storage=m_Storage.m_dynSet; - } - - // Use fixed storage - ::std::copy(::boost::begin(Range), ::boost::end(Range), Storage); - ::std::sort(Storage, Storage+m_Size); - } - - // Copy constructor - is_any_ofF(const is_any_ofF& Other) : m_Size(Other.m_Size) - { - // Prepare storage - m_Storage.m_dynSet=0; - const set_value_type* SrcStorage=0; - set_value_type* DestStorage=0; - - if(use_fixed_storage(m_Size)) - { - // Use fixed storage - DestStorage=&m_Storage.m_fixSet[0]; - SrcStorage=&Other.m_Storage.m_fixSet[0]; - } - else - { - // Use dynamic storage - m_Storage.m_dynSet=new set_value_type[m_Size]; - DestStorage=m_Storage.m_dynSet; - SrcStorage=Other.m_Storage.m_dynSet; - } - - // Use fixed storage - ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); - } - - // Destructor - ~is_any_ofF() - { - if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) - { - delete [] m_Storage.m_dynSet; - } - } - - // Assignment - is_any_ofF& operator=(const is_any_ofF& Other) - { - // Handle self assignment - if(this==&Other) return *this; - - // Prepare storage - const set_value_type* SrcStorage; - set_value_type* DestStorage; - - if(use_fixed_storage(Other.m_Size)) - { - // Use fixed storage - DestStorage=&m_Storage.m_fixSet[0]; - SrcStorage=&Other.m_Storage.m_fixSet[0]; - - // Delete old storage if was present - if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) - { - delete [] m_Storage.m_dynSet; - } - - // Set new size - m_Size=Other.m_Size; - } - else - { - // Other uses dynamic storage - SrcStorage=Other.m_Storage.m_dynSet; - - // Check what kind of storage are we using right now - if(use_fixed_storage(m_Size)) - { - // Using fixed storage, allocate new - set_value_type* pTemp=new set_value_type[Other.m_Size]; - DestStorage=pTemp; - m_Storage.m_dynSet=pTemp; - m_Size=Other.m_Size; - } - else - { - // Using dynamic storage, check if can reuse - if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size - bool operator()( Char2T Ch ) const - { - const set_value_type* Storage= - (use_fixed_storage(m_Size)) - ? &m_Storage.m_fixSet[0] - : m_Storage.m_dynSet; - - return ::std::binary_search(Storage, Storage+m_Size, Ch); - } - private: - // check if the size is eligible for fixed storage - static bool use_fixed_storage(std::size_t size) - { - return size<=sizeof(set_value_type*)*2; - } - - - private: - // storage - // The actual used storage is selected on the type - union - { - set_value_type* m_dynSet; - set_value_type m_fixSet[sizeof(set_value_type*)*2]; - } - m_Storage; - - // storage size - ::std::size_t m_Size; - }; - - // is_from_range functor - /* - returns true if the value is from the specified range. - (i.e. x>=From && x>=To) - */ - template - struct is_from_rangeF : - public predicate_facade< is_from_rangeF > - { - // Boost.ResultOf support - typedef bool result_type; - - // Constructor - is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {} - - // Operation - template - bool operator()( Char2T Ch ) const - { - return ( m_From <= Ch ) && ( Ch <= m_To ); - } - - private: - CharT m_From; - CharT m_To; - }; - - // class_and composition predicate - template - struct pred_andF : - public predicate_facade< pred_andF > - { - public: - - // Boost.ResultOf support - typedef bool result_type; - - // Constructor - pred_andF( Pred1T Pred1, Pred2T Pred2 ) : - m_Pred1(Pred1), m_Pred2(Pred2) {} - - // Operation - template - bool operator()( CharT Ch ) const - { - return m_Pred1(Ch) && m_Pred2(Ch); - } - - private: - Pred1T m_Pred1; - Pred2T m_Pred2; - }; - - // class_or composition predicate - template - struct pred_orF : - public predicate_facade< pred_orF > - { - public: - // Boost.ResultOf support - typedef bool result_type; - - // Constructor - pred_orF( Pred1T Pred1, Pred2T Pred2 ) : - m_Pred1(Pred1), m_Pred2(Pred2) {} - - // Operation - template - bool operator()( CharT Ch ) const - { - return m_Pred1(Ch) || m_Pred2(Ch); - } - - private: - Pred1T m_Pred1; - Pred2T m_Pred2; - }; - - // class_not composition predicate - template< typename PredT > - struct pred_notF : - public predicate_facade< pred_notF > - { - public: - // Boost.ResultOf support - typedef bool result_type; - - // Constructor - pred_notF( PredT Pred ) : m_Pred(Pred) {} - - // Operation - template - bool operator()( CharT Ch ) const - { - return !m_Pred(Ch); - } - - private: - PredT m_Pred; - }; - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP diff --git a/boost/algorithm/string/detail/find_format.hpp b/boost/algorithm/string/detail/find_format.hpp deleted file mode 100644 index b39875024cf85d41334fcc922a6945a8d20939c5..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/find_format.hpp +++ /dev/null @@ -1,204 +0,0 @@ -// Boost string_algo library find_format.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_FORMAT_DETAIL_HPP -#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP - -#include -#include -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// find_format_copy (iterator variant) implementation -------------------------------// - - template< - typename OutputIteratorT, - typename InputT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline OutputIteratorT find_format_copy_impl2( - OutputIteratorT Output, - const InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult, - const FormatResultT& FormatResult ) - { - typedef find_format_store< - BOOST_STRING_TYPENAME - range_const_iterator::type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - if ( !M ) - { - // Match not found - return original sequence - Output = std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); - return Output; - } - - // Copy the beginning of the sequence - Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output ); - // Format find result - // Copy formatted result - Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output ); - // Copy the rest of the sequence - Output = std::copy( M.end(), ::boost::end(Input), Output ); - - return Output; - } - - template< - typename OutputIteratorT, - typename InputT, - typename FormatterT, - typename FindResultT > - inline OutputIteratorT find_format_copy_impl( - OutputIteratorT Output, - const InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult ) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_copy_impl2( - Output, - Input, - Formatter, - FindResult, - Formatter(FindResult) ); - } else { - return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); - } - } - - -// find_format_copy implementation --------------------------------------------------// - - template< - typename InputT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline InputT find_format_copy_impl2( - const InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult, - const FormatResultT& FormatResult) - { - typedef find_format_store< - BOOST_STRING_TYPENAME - range_const_iterator::type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - if ( !M ) - { - // Match not found - return original sequence - return InputT( Input ); - } - - InputT Output; - // Copy the beginning of the sequence - boost::algorithm::detail::insert( Output, ::boost::end(Output), ::boost::begin(Input), M.begin() ); - // Copy formatted result - boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() ); - // Copy the rest of the sequence - boost::algorithm::detail::insert( Output, ::boost::end(Output), M.end(), ::boost::end(Input) ); - - return Output; - } - - template< - typename InputT, - typename FormatterT, - typename FindResultT > - inline InputT find_format_copy_impl( - const InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_copy_impl2( - Input, - Formatter, - FindResult, - Formatter(FindResult) ); - } else { - return Input; - } - } - - // replace implementation ----------------------------------------------------// - - template< - typename InputT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline void find_format_impl2( - InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult, - const FormatResultT& FormatResult) - { - typedef find_format_store< - BOOST_STRING_TYPENAME - range_iterator::type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - if ( !M ) - { - // Search not found - return original sequence - return; - } - - // Replace match - ::boost::algorithm::detail::replace( Input, M.begin(), M.end(), M.format_result() ); - } - - template< - typename InputT, - typename FormatterT, - typename FindResultT > - inline void find_format_impl( - InputT& Input, - FormatterT Formatter, - const FindResultT& FindResult) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - ::boost::algorithm::detail::find_format_impl2( - Input, - Formatter, - FindResult, - Formatter(FindResult) ); - } - } - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FIND_FORMAT_DETAIL_HPP diff --git a/boost/algorithm/string/detail/find_format_all.hpp b/boost/algorithm/string/detail/find_format_all.hpp deleted file mode 100644 index 52930c83ad8bc5efa95f7226226b342cb27fce88..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/find_format_all.hpp +++ /dev/null @@ -1,273 +0,0 @@ -// Boost string_algo library find_format_all.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP -#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP - -#include -#include -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// find_format_all_copy (iterator variant) implementation ---------------------------// - - template< - typename OutputIteratorT, - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline OutputIteratorT find_format_all_copy_impl2( - OutputIteratorT Output, - const InputT& Input, - FinderT Finder, - FormatterT Formatter, - const FindResultT& FindResult, - const FormatResultT& FormatResult ) - { - typedef BOOST_STRING_TYPENAME - range_const_iterator::type input_iterator_type; - - typedef find_format_store< - input_iterator_type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - // Initialize last match - input_iterator_type LastMatch=::boost::begin(Input); - - // Iterate through all matches - while( M ) - { - // Copy the beginning of the sequence - Output = std::copy( LastMatch, M.begin(), Output ); - // Copy formatted result - Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output ); - - // Proceed to the next match - LastMatch=M.end(); - M=Finder( LastMatch, ::boost::end(Input) ); - } - - // Copy the rest of the sequence - Output = std::copy( LastMatch, ::boost::end(Input), Output ); - - return Output; - } - - template< - typename OutputIteratorT, - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT > - inline OutputIteratorT find_format_all_copy_impl( - OutputIteratorT Output, - const InputT& Input, - FinderT Finder, - FormatterT Formatter, - const FindResultT& FindResult ) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_all_copy_impl2( - Output, - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); - } else { - return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); - } - } - - // find_format_all_copy implementation ----------------------------------------------// - - template< - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline InputT find_format_all_copy_impl2( - const InputT& Input, - FinderT Finder, - FormatterT Formatter, - const FindResultT& FindResult, - const FormatResultT& FormatResult) - { - typedef BOOST_STRING_TYPENAME - range_const_iterator::type input_iterator_type; - - typedef find_format_store< - input_iterator_type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - // Initialize last match - input_iterator_type LastMatch=::boost::begin(Input); - - // Output temporary - InputT Output; - - // Iterate through all matches - while( M ) - { - // Copy the beginning of the sequence - boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, M.begin() ); - // Copy formatted result - boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() ); - - // Proceed to the next match - LastMatch=M.end(); - M=Finder( LastMatch, ::boost::end(Input) ); - } - - // Copy the rest of the sequence - ::boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, ::boost::end(Input) ); - - return Output; - } - - template< - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT > - inline InputT find_format_all_copy_impl( - const InputT& Input, - FinderT Finder, - FormatterT Formatter, - const FindResultT& FindResult) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_all_copy_impl2( - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); - } else { - return Input; - } - } - - // find_format_all implementation ------------------------------------------------// - - template< - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT, - typename FormatResultT > - inline void find_format_all_impl2( - InputT& Input, - FinderT Finder, - FormatterT Formatter, - FindResultT FindResult, - FormatResultT FormatResult) - { - typedef BOOST_STRING_TYPENAME - range_iterator::type input_iterator_type; - typedef find_format_store< - input_iterator_type, - FormatterT, - FormatResultT > store_type; - - // Create store for the find result - store_type M( FindResult, FormatResult, Formatter ); - - // Instantiate replacement storage - std::deque< - BOOST_STRING_TYPENAME range_value::type> Storage; - - // Initialize replacement iterators - input_iterator_type InsertIt=::boost::begin(Input); - input_iterator_type SearchIt=::boost::begin(Input); - - while( M ) - { - // process the segment - InsertIt=process_segment( - Storage, - Input, - InsertIt, - SearchIt, - M.begin() ); - - // Adjust search iterator - SearchIt=M.end(); - - // Copy formatted replace to the storage - ::boost::algorithm::detail::copy_to_storage( Storage, M.format_result() ); - - // Find range for a next match - M=Finder( SearchIt, ::boost::end(Input) ); - } - - // process the last segment - InsertIt=::boost::algorithm::detail::process_segment( - Storage, - Input, - InsertIt, - SearchIt, - ::boost::end(Input) ); - - if ( Storage.empty() ) - { - // Truncate input - ::boost::algorithm::detail::erase( Input, InsertIt, ::boost::end(Input) ); - } - else - { - // Copy remaining data to the end of input - ::boost::algorithm::detail::insert( Input, ::boost::end(Input), Storage.begin(), Storage.end() ); - } - } - - template< - typename InputT, - typename FinderT, - typename FormatterT, - typename FindResultT > - inline void find_format_all_impl( - InputT& Input, - FinderT Finder, - FormatterT Formatter, - FindResultT FindResult) - { - if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - ::boost::algorithm::detail::find_format_all_impl2( - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); - } - } - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP diff --git a/boost/algorithm/string/detail/find_format_store.hpp b/boost/algorithm/string/detail/find_format_store.hpp deleted file mode 100644 index b9f4a88d912459d488f17743a77e55cdbfc42387..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/find_format_store.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// Boost string_algo library find_format_store.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP -#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP - -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// temporary format and find result storage --------------------------------// - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - template< - typename ForwardIteratorT, - typename FormatterT, - typename FormatResultT > - class find_format_store : - public iterator_range - { - public: - // typedefs - typedef iterator_range base_type; - typedef FormatterT formatter_type; - typedef FormatResultT format_result_type; - - public: - // Construction - find_format_store( - const base_type& FindResult, - const format_result_type& FormatResult, - const formatter_type& Formatter ) : - base_type(FindResult), - m_FormatResult(FormatResult), - m_Formatter(Formatter) {} - - // Assignment - template< typename FindResultT > - find_format_store& operator=( FindResultT FindResult ) - { - iterator_range::operator=(FindResult); - if( !this->empty() ) { - m_FormatResult=m_Formatter(FindResult); - } - - return *this; - } - - // Retrieve format result - const format_result_type& format_result() - { - return m_FormatResult; - } - - private: - format_result_type m_FormatResult; - const formatter_type& m_Formatter; - }; - - template - bool check_find_result(InputT&, FindResultT& FindResult) - { - typedef BOOST_STRING_TYPENAME - range_const_iterator::type input_iterator_type; - iterator_range ResultRange(FindResult); - return !ResultRange.empty(); - } - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP diff --git a/boost/algorithm/string/detail/find_iterator.hpp b/boost/algorithm/string/detail/find_iterator.hpp deleted file mode 100644 index 4f90a98fc02ef7096be267b04e137af34dcba820..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/find_iterator.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// Boost string_algo library find_iterator.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP -#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP - -#include -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// find_iterator base -----------------------------------------------// - - // Find iterator base - template - class find_iterator_base - { - protected: - // typedefs - typedef IteratorT input_iterator_type; - typedef iterator_range match_type; - typedef function2< - match_type, - input_iterator_type, - input_iterator_type> finder_type; - - protected: - // Protected construction/destruction - - // Default constructor - find_iterator_base() {} - // Copy construction - find_iterator_base( const find_iterator_base& Other ) : - m_Finder(Other.m_Finder) {} - - // Constructor - template - find_iterator_base( FinderT Finder, int ) : - m_Finder(Finder) {} - - // Destructor - ~find_iterator_base() {} - - // Find operation - match_type do_find( - input_iterator_type Begin, - input_iterator_type End ) const - { - if (!m_Finder.empty()) - { - return m_Finder(Begin,End); - } - else - { - return match_type(End,End); - } - } - - // Check - bool is_null() const - { - return m_Finder.empty(); - } - - private: - // Finder - finder_type m_Finder; - }; - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP diff --git a/boost/algorithm/string/detail/finder.hpp b/boost/algorithm/string/detail/finder.hpp deleted file mode 100644 index a2a958212de3f23c44438abc16f9da3b46d4fe44..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/finder.hpp +++ /dev/null @@ -1,639 +0,0 @@ -// Boost string_algo library finder.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FINDER_DETAIL_HPP -#define BOOST_STRING_FINDER_DETAIL_HPP - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - - -// find first functor -----------------------------------------------// - - // find a subsequence in the sequence ( functor ) - /* - Returns a pair marking the subsequence in the sequence. - If the find fails, functor returns - */ - template - struct first_finderF - { - typedef SearchIteratorT search_iterator_type; - - // Construction - template< typename SearchT > - first_finderF( const SearchT& Search, PredicateT Comp ) : - m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} - first_finderF( - search_iterator_type SearchBegin, - search_iterator_type SearchEnd, - PredicateT Comp ) : - m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - typedef iterator_range result_type; - typedef ForwardIteratorT input_iterator_type; - - // Outer loop - for(input_iterator_type OuterIt=Begin; - OuterIt!=End; - ++OuterIt) - { - // Sanity check - if( boost::empty(m_Search) ) - return result_type( End, End ); - - input_iterator_type InnerIt=OuterIt; - search_iterator_type SubstrIt=m_Search.begin(); - for(; - InnerIt!=End && SubstrIt!=m_Search.end(); - ++InnerIt,++SubstrIt) - { - if( !( m_Comp(*InnerIt,*SubstrIt) ) ) - break; - } - - // Substring matching succeeded - if ( SubstrIt==m_Search.end() ) - return result_type( OuterIt, InnerIt ); - } - - return result_type( End, End ); - } - - private: - iterator_range m_Search; - PredicateT m_Comp; - }; - -// find last functor -----------------------------------------------// - - // find the last match a subsequence in the sequence ( functor ) - /* - Returns a pair marking the subsequence in the sequence. - If the find fails, returns - */ - template - struct last_finderF - { - typedef SearchIteratorT search_iterator_type; - typedef first_finderF< - search_iterator_type, - PredicateT> first_finder_type; - - // Construction - template< typename SearchT > - last_finderF( const SearchT& Search, PredicateT Comp ) : - m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} - last_finderF( - search_iterator_type SearchBegin, - search_iterator_type SearchEnd, - PredicateT Comp ) : - m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - typedef iterator_range result_type; - - if( boost::empty(m_Search) ) - return result_type( End, End ); - - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return findit( Begin, End, category() ); - } - - private: - // forward iterator - template< typename ForwardIteratorT > - iterator_range - findit( - ForwardIteratorT Begin, - ForwardIteratorT End, - std::forward_iterator_tag ) const - { - typedef iterator_range result_type; - - first_finder_type first_finder( - m_Search.begin(), m_Search.end(), m_Comp ); - - result_type M=first_finder( Begin, End ); - result_type Last=M; - - while( M ) - { - Last=M; - M=first_finder( ::boost::end(M), End ); - } - - return Last; - } - - // bidirectional iterator - template< typename ForwardIteratorT > - iterator_range - findit( - ForwardIteratorT Begin, - ForwardIteratorT End, - std::bidirectional_iterator_tag ) const - { - typedef iterator_range result_type; - typedef ForwardIteratorT input_iterator_type; - - // Outer loop - for(input_iterator_type OuterIt=End; - OuterIt!=Begin; ) - { - input_iterator_type OuterIt2=--OuterIt; - - input_iterator_type InnerIt=OuterIt2; - search_iterator_type SubstrIt=m_Search.begin(); - for(; - InnerIt!=End && SubstrIt!=m_Search.end(); - ++InnerIt,++SubstrIt) - { - if( !( m_Comp(*InnerIt,*SubstrIt) ) ) - break; - } - - // Substring matching succeeded - if( SubstrIt==m_Search.end() ) - return result_type( OuterIt2, InnerIt ); - } - - return result_type( End, End ); - } - - private: - iterator_range m_Search; - PredicateT m_Comp; - }; - -// find n-th functor -----------------------------------------------// - - // find the n-th match of a subsequence in the sequence ( functor ) - /* - Returns a pair marking the subsequence in the sequence. - If the find fails, returns - */ - template - struct nth_finderF - { - typedef SearchIteratorT search_iterator_type; - typedef first_finderF< - search_iterator_type, - PredicateT> first_finder_type; - typedef last_finderF< - search_iterator_type, - PredicateT> last_finder_type; - - // Construction - template< typename SearchT > - nth_finderF( - const SearchT& Search, - int Nth, - PredicateT Comp) : - m_Search(::boost::begin(Search), ::boost::end(Search)), - m_Nth(Nth), - m_Comp(Comp) {} - nth_finderF( - search_iterator_type SearchBegin, - search_iterator_type SearchEnd, - int Nth, - PredicateT Comp) : - m_Search(SearchBegin, SearchEnd), - m_Nth(Nth), - m_Comp(Comp) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - if(m_Nth>=0) - { - return find_forward(Begin, End, m_Nth); - } - else - { - return find_backward(Begin, End, -m_Nth); - } - - } - - private: - // Implementation helpers - template< typename ForwardIteratorT > - iterator_range - find_forward( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N) const - { - typedef iterator_range result_type; - - // Sanity check - if( boost::empty(m_Search) ) - return result_type( End, End ); - - // Instantiate find functor - first_finder_type first_finder( - m_Search.begin(), m_Search.end(), m_Comp ); - - result_type M( Begin, Begin ); - - for( unsigned int n=0; n<=N; ++n ) - { - // find next match - M=first_finder( ::boost::end(M), End ); - - if ( !M ) - { - // Subsequence not found, return - return M; - } - } - - return M; - } - - template< typename ForwardIteratorT > - iterator_range - find_backward( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N) const - { - typedef iterator_range result_type; - - // Sanity check - if( boost::empty(m_Search) ) - return result_type( End, End ); - - // Instantiate find functor - last_finder_type last_finder( - m_Search.begin(), m_Search.end(), m_Comp ); - - result_type M( End, End ); - - for( unsigned int n=1; n<=N; ++n ) - { - // find next match - M=last_finder( Begin, ::boost::begin(M) ); - - if ( !M ) - { - // Subsequence not found, return - return M; - } - } - - return M; - } - - - private: - iterator_range m_Search; - int m_Nth; - PredicateT m_Comp; - }; - -// find head/tail implementation helpers ---------------------------// - - template - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::forward_iterator_tag ) - { - typedef ForwardIteratorT input_iterator_type; - typedef iterator_range result_type; - - input_iterator_type It=Begin; - for( - unsigned int Index=0; - Index - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::random_access_iterator_tag ) - { - typedef iterator_range result_type; - - if ( (End<=Begin) || ( static_cast(End-Begin) < N ) ) - return result_type( Begin, End ); - - return result_type(Begin,Begin+N); - } - - // Find head implementation - template - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N ) - { - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return ::boost::algorithm::detail::find_head_impl( Begin, End, N, category() ); - } - - template< typename ForwardIteratorT > - iterator_range - find_tail_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::forward_iterator_tag ) - { - typedef ForwardIteratorT input_iterator_type; - typedef iterator_range result_type; - - unsigned int Index=0; - input_iterator_type It=Begin; - input_iterator_type It2=Begin; - - // Advance It2 by N increments - for( Index=0; Index - iterator_range - find_tail_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::bidirectional_iterator_tag ) - { - typedef ForwardIteratorT input_iterator_type; - typedef iterator_range result_type; - - input_iterator_type It=End; - for( - unsigned int Index=0; - Index - iterator_range - find_tail_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::random_access_iterator_tag ) - { - typedef iterator_range result_type; - - if ( (End<=Begin) || ( static_cast(End-Begin) < N ) ) - return result_type( Begin, End ); - - return result_type( End-N, End ); - } - - // Operation - template< typename ForwardIteratorT > - iterator_range - find_tail_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N ) - { - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return ::boost::algorithm::detail::find_tail_impl( Begin, End, N, category() ); - } - - - -// find head functor -----------------------------------------------// - - - // find a head in the sequence ( functor ) - /* - This functor find a head of the specified range. For - a specified N, the head is a subsequence of N starting - elements of the range. - */ - struct head_finderF - { - // Construction - head_finderF( int N ) : m_N(N) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - if(m_N>=0) - { - return ::boost::algorithm::detail::find_head_impl( Begin, End, m_N ); - } - else - { - iterator_range Res= - ::boost::algorithm::detail::find_tail_impl( Begin, End, -m_N ); - - return ::boost::make_iterator_range(Begin, Res.begin()); - } - } - - private: - int m_N; - }; - -// find tail functor -----------------------------------------------// - - - // find a tail in the sequence ( functor ) - /* - This functor find a tail of the specified range. For - a specified N, the head is a subsequence of N starting - elements of the range. - */ - struct tail_finderF - { - // Construction - tail_finderF( int N ) : m_N(N) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - if(m_N>=0) - { - return ::boost::algorithm::detail::find_tail_impl( Begin, End, m_N ); - } - else - { - iterator_range Res= - ::boost::algorithm::detail::find_head_impl( Begin, End, -m_N ); - - return ::boost::make_iterator_range(Res.end(), End); - } - } - - private: - int m_N; - }; - -// find token functor -----------------------------------------------// - - // find a token in a sequence ( functor ) - /* - This find functor finds a token specified be a predicate - in a sequence. It is equivalent of std::find algorithm, - with an exception that it return range instead of a single - iterator. - - If bCompress is set to true, adjacent matching tokens are - concatenated into one match. - */ - template< typename PredicateT > - struct token_finderF - { - // Construction - token_finderF( - PredicateT Pred, - token_compress_mode_type eCompress=token_compress_off ) : - m_Pred(Pred), m_eCompress(eCompress) {} - - // Operation - template< typename ForwardIteratorT > - iterator_range - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - typedef iterator_range result_type; - - ForwardIteratorT It=std::find_if( Begin, End, m_Pred ); - - if( It==End ) - { - return result_type( End, End ); - } - else - { - ForwardIteratorT It2=It; - - if( m_eCompress==token_compress_on ) - { - // Find first non-matching character - while( It2!=End && m_Pred(*It2) ) ++It2; - } - else - { - // Advance by one position - ++It2; - } - - return result_type( It, It2 ); - } - } - - private: - PredicateT m_Pred; - token_compress_mode_type m_eCompress; - }; - -// find range functor -----------------------------------------------// - - // find a range in the sequence ( functor ) - /* - This functor actually does not perform any find operation. - It always returns given iterator range as a result. - */ - template - struct range_finderF - { - typedef ForwardIterator1T input_iterator_type; - typedef iterator_range result_type; - - // Construction - range_finderF( - input_iterator_type Begin, - input_iterator_type End ) : m_Range(Begin, End) {} - - range_finderF(const iterator_range& Range) : - m_Range(Range) {} - - // Operation - template< typename ForwardIterator2T > - iterator_range - operator()( - ForwardIterator2T, - ForwardIterator2T ) const - { -#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) - return iterator_range(this->m_Range); -#else - return m_Range; -#endif - } - - private: - iterator_range m_Range; - }; - - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FINDER_DETAIL_HPP diff --git a/boost/algorithm/string/detail/finder_regex.hpp b/boost/algorithm/string/detail/finder_regex.hpp deleted file mode 100644 index 9cb01cfaf136b617d0f3b55765d13e35d589076a..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/finder_regex.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// Boost string_algo library find_regex.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FINDER_REGEX_DETAIL_HPP -#define BOOST_STRING_FINDER_REGEX_DETAIL_HPP - -#include -#include - -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// regex find functor -----------------------------------------------// - - // regex search result - template - struct regex_search_result : - public iterator_range - { - typedef regex_search_result type; - typedef iterator_range base_type; - typedef BOOST_STRING_TYPENAME base_type::value_type value_type; - typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type; - typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator; - typedef BOOST_STRING_TYPENAME base_type::iterator iterator; - typedef boost::match_results match_results_type; - - // Construction - - // Construction from the match result - regex_search_result( const match_results_type& MatchResults ) : - base_type( MatchResults[0].first, MatchResults[0].second ), - m_MatchResults( MatchResults ) {} - - // Construction of empty match. End iterator has to be specified - regex_search_result( IteratorT End ) : - base_type( End, End ) {} - - regex_search_result( const regex_search_result& Other ) : - base_type( Other.begin(), Other.end() ), - m_MatchResults( Other.m_MatchResults ) {} - - // Assignment - regex_search_result& operator=( const regex_search_result& Other ) - { - base_type::operator=( Other ); - m_MatchResults=Other.m_MatchResults; - return *this; - } - - // Match result retrieval - const match_results_type& match_results() const - { - return m_MatchResults; - } - - private: - // Saved match result - match_results_type m_MatchResults; - }; - - // find_regex - /* - Regex based search functor - */ - template - struct find_regexF - { - typedef RegExT regex_type; - typedef const RegExT& regex_reference_type; - - // Construction - find_regexF( regex_reference_type Rx, match_flag_type MatchFlags = match_default ) : - m_Rx(Rx), m_MatchFlags(MatchFlags) {} - - // Operation - template< typename ForwardIteratorT > - regex_search_result - operator()( - ForwardIteratorT Begin, - ForwardIteratorT End ) const - { - typedef ForwardIteratorT input_iterator_type; - typedef regex_search_result result_type; - - // instantiate match result - match_results result; - // search for a match - if ( ::boost::regex_search( Begin, End, result, m_Rx, m_MatchFlags ) ) - { - // construct a result - return result_type( result ); - } - else - { - // empty result - return result_type( End ); - } - } - - private: - regex_reference_type m_Rx; // Regexp - match_flag_type m_MatchFlags; // match flags - }; - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FIND_DETAIL_HPP diff --git a/boost/algorithm/string/detail/formatter.hpp b/boost/algorithm/string/detail/formatter.hpp deleted file mode 100644 index c071822f2ac498b8f57dd1b2ad755d60025b8217..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/formatter.hpp +++ /dev/null @@ -1,119 +0,0 @@ -// Boost string_algo library formatter.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FORMATTER_DETAIL_HPP -#define BOOST_STRING_FORMATTER_DETAIL_HPP - - -#include -#include -#include -#include - -#include - -// generic replace functors -----------------------------------------------// - -namespace boost { - namespace algorithm { - namespace detail { - -// const format functor ----------------------------------------------------// - - // constant format functor - template - struct const_formatF - { - private: - typedef BOOST_STRING_TYPENAME - range_const_iterator::type format_iterator; - typedef iterator_range result_type; - - public: - // Construction - const_formatF(const RangeT& Format) : - m_Format(::boost::begin(Format), ::boost::end(Format)) {} - - // Operation -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - template - result_type& operator()(const Range2T&) - { - return m_Format; - } -#endif - - template - const result_type& operator()(const Range2T&) const - { - return m_Format; - } - - private: - result_type m_Format; - }; - -// identity format functor ----------------------------------------------------// - - // identity format functor - template - struct identity_formatF - { - // Operation - template< typename Range2T > - const RangeT& operator()(const Range2T& Replace) const - { - return RangeT(::boost::begin(Replace), ::boost::end(Replace)); - } - }; - -// empty format functor ( used by erase ) ------------------------------------// - - // empty format functor - template< typename CharT > - struct empty_formatF - { - template< typename ReplaceT > - empty_container operator()(const ReplaceT&) const - { - return empty_container(); - } - }; - -// dissect format functor ----------------------------------------------------// - - // dissect format functor - template - struct dissect_formatF - { - public: - // Construction - dissect_formatF(FinderT Finder) : - m_Finder(Finder) {} - - // Operation - template - inline iterator_range< - BOOST_STRING_TYPENAME range_const_iterator::type> - operator()(const RangeT& Replace) const - { - return m_Finder(::boost::begin(Replace), ::boost::end(Replace)); - } - - private: - FinderT m_Finder; - }; - - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FORMATTER_DETAIL_HPP diff --git a/boost/algorithm/string/detail/formatter_regex.hpp b/boost/algorithm/string/detail/formatter_regex.hpp deleted file mode 100644 index 5f26407bed8e09d84350f8788913aa3708164376..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/formatter_regex.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Boost string_algo library formatter_regex.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP -#define BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP - -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// regex format functor -----------------------------------------// - - // regex format functor - template - struct regex_formatF - { - private: - typedef StringT result_type; - typedef BOOST_STRING_TYPENAME StringT::value_type char_type; - - public: - // Construction - regex_formatF( const StringT& Fmt, match_flag_type Flags=format_default ) : - m_Fmt(Fmt), m_Flags( Flags ) {} - - template - result_type operator()( - const regex_search_result& Replace ) const - { - if ( Replace.empty() ) - { - return result_type(); - } - else - { - return Replace.match_results().format( m_Fmt, m_Flags ); - } - } - private: - const StringT& m_Fmt; - match_flag_type m_Flags; - }; - - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_FORMATTER_DETAIL_HPP diff --git a/boost/algorithm/string/detail/predicate.hpp b/boost/algorithm/string/detail/predicate.hpp deleted file mode 100644 index 5acf3cc6633015b207fb499943fccc06b79145b9..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/predicate.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Boost string_algo library predicate.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP -#define BOOST_STRING_PREDICATE_DETAIL_HPP - -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// ends_with predicate implementation ----------------------------------// - - template< - typename ForwardIterator1T, - typename ForwardIterator2T, - typename PredicateT> - inline bool ends_with_iter_select( - ForwardIterator1T Begin, - ForwardIterator1T End, - ForwardIterator2T SubBegin, - ForwardIterator2T SubEnd, - PredicateT Comp, - std::bidirectional_iterator_tag) - { - ForwardIterator1T it=End; - ForwardIterator2T pit=SubEnd; - for(;it!=Begin && pit!=SubBegin;) - { - if( !(Comp(*(--it),*(--pit))) ) - return false; - } - - return pit==SubBegin; - } - - template< - typename ForwardIterator1T, - typename ForwardIterator2T, - typename PredicateT> - inline bool ends_with_iter_select( - ForwardIterator1T Begin, - ForwardIterator1T End, - ForwardIterator2T SubBegin, - ForwardIterator2T SubEnd, - PredicateT Comp, - std::forward_iterator_tag) - { - if ( SubBegin==SubEnd ) - { - // empty subsequence check - return true; - } - - iterator_range Result - =last_finder( - ::boost::make_iterator_range(SubBegin, SubEnd), - Comp)(Begin, End); - - return !Result.empty() && Result.end()==End; - } - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_PREDICATE_DETAIL_HPP diff --git a/boost/algorithm/string/detail/replace_storage.hpp b/boost/algorithm/string/detail/replace_storage.hpp deleted file mode 100644 index db35e4c53be8518a683a1f8c637b1ba2154c7436..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/replace_storage.hpp +++ /dev/null @@ -1,159 +0,0 @@ -// Boost string_algo library replace_storage.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP -#define BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP - -#include -#include -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// storage handling routines -----------------------------------------------// - - template< typename StorageT, typename OutputIteratorT > - inline OutputIteratorT move_from_storage( - StorageT& Storage, - OutputIteratorT DestBegin, - OutputIteratorT DestEnd ) - { - OutputIteratorT OutputIt=DestBegin; - - while( !Storage.empty() && OutputIt!=DestEnd ) - { - *OutputIt=Storage.front(); - Storage.pop_front(); - ++OutputIt; - } - - return OutputIt; - } - - template< typename StorageT, typename WhatT > - inline void copy_to_storage( - StorageT& Storage, - const WhatT& What ) - { - Storage.insert( Storage.end(), ::boost::begin(What), ::boost::end(What) ); - } - - -// process segment routine -----------------------------------------------// - - template< bool HasStableIterators > - struct process_segment_helper - { - // Optimized version of process_segment for generic sequence - template< - typename StorageT, - typename InputT, - typename ForwardIteratorT > - ForwardIteratorT operator()( - StorageT& Storage, - InputT& /*Input*/, - ForwardIteratorT InsertIt, - ForwardIteratorT SegmentBegin, - ForwardIteratorT SegmentEnd ) - { - // Copy data from the storage until the beginning of the segment - ForwardIteratorT It=::boost::algorithm::detail::move_from_storage( Storage, InsertIt, SegmentBegin ); - - // 3 cases are possible : - // a) Storage is empty, It==SegmentBegin - // b) Storage is empty, It!=SegmentBegin - // c) Storage is not empty - - if( Storage.empty() ) - { - if( It==SegmentBegin ) - { - // Case a) everything is grand, just return end of segment - return SegmentEnd; - } - else - { - // Case b) move the segment backwards - return std::copy( SegmentBegin, SegmentEnd, It ); - } - } - else - { - // Case c) -> shift the segment to the left and keep the overlap in the storage - while( It!=SegmentEnd ) - { - // Store value into storage - Storage.push_back( *It ); - // Get the top from the storage and put it here - *It=Storage.front(); - Storage.pop_front(); - - // Advance - ++It; - } - - return It; - } - } - }; - - template<> - struct process_segment_helper< true > - { - // Optimized version of process_segment for list-like sequence - template< - typename StorageT, - typename InputT, - typename ForwardIteratorT > - ForwardIteratorT operator()( - StorageT& Storage, - InputT& Input, - ForwardIteratorT InsertIt, - ForwardIteratorT SegmentBegin, - ForwardIteratorT SegmentEnd ) - - { - // Call replace to do the job - ::boost::algorithm::detail::replace( Input, InsertIt, SegmentBegin, Storage ); - // Empty the storage - Storage.clear(); - // Iterators were not changed, simply return the end of segment - return SegmentEnd; - } - }; - - // Process one segment in the replace_all algorithm - template< - typename StorageT, - typename InputT, - typename ForwardIteratorT > - inline ForwardIteratorT process_segment( - StorageT& Storage, - InputT& Input, - ForwardIteratorT InsertIt, - ForwardIteratorT SegmentBegin, - ForwardIteratorT SegmentEnd ) - { - return - process_segment_helper< - has_stable_iterators::value>()( - Storage, Input, InsertIt, SegmentBegin, SegmentEnd ); - } - - - } // namespace detail - } // namespace algorithm -} // namespace boost - -#endif // BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP diff --git a/boost/algorithm/string/detail/sequence.hpp b/boost/algorithm/string/detail/sequence.hpp deleted file mode 100644 index dc47409115f65dd292cb051f3fcfd31a1b446d7f..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/sequence.hpp +++ /dev/null @@ -1,200 +0,0 @@ -// Boost string_algo library sequence.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_DETAIL_SEQUENCE_HPP -#define BOOST_STRING_DETAIL_SEQUENCE_HPP - -#include -#include -#include -#include -#include - -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// insert helpers -------------------------------------------------// - - template< typename InputT, typename ForwardIteratorT > - inline void insert( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator At, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - Input.insert( At, Begin, End ); - } - - template< typename InputT, typename InsertT > - inline void insert( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator At, - const InsertT& Insert ) - { - ::boost::algorithm::detail::insert( Input, At, ::boost::begin(Insert), ::boost::end(Insert) ); - } - -// erase helper ---------------------------------------------------// - - // Erase a range in the sequence - /* - Returns the iterator pointing just after the erase subrange - */ - template< typename InputT > - inline typename InputT::iterator erase( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To ) - { - return Input.erase( From, To ); - } - -// replace helper implementation ----------------------------------// - - // Optimized version of replace for generic sequence containers - // Assumption: insert and erase are expensive - template< bool HasConstTimeOperations > - struct replace_const_time_helper - { - template< typename InputT, typename ForwardIteratorT > - void operator()( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - // Copy data to the container ( as much as possible ) - ForwardIteratorT InsertIt=Begin; - BOOST_STRING_TYPENAME InputT::iterator InputIt=From; - for(; InsertIt!=End && InputIt!=To; InsertIt++, InputIt++ ) - { - *InputIt=*InsertIt; - } - - if ( InsertIt!=End ) - { - // Replace sequence is longer, insert it - Input.insert( InputIt, InsertIt, End ); - } - else - { - if ( InputIt!=To ) - { - // Replace sequence is shorter, erase the rest - Input.erase( InputIt, To ); - } - } - } - }; - - template<> - struct replace_const_time_helper< true > - { - // Const-time erase and insert methods -> use them - template< typename InputT, typename ForwardIteratorT > - void operator()( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To ); - if ( Begin!=End ) - { - if(!Input.empty()) - { - Input.insert( At, Begin, End ); - } - else - { - Input.insert( Input.begin(), Begin, End ); - } - } - } - }; - - // No native replace method - template< bool HasNative > - struct replace_native_helper - { - template< typename InputT, typename ForwardIteratorT > - void operator()( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - replace_const_time_helper< - boost::mpl::and_< - has_const_time_insert, - has_const_time_erase >::value >()( - Input, From, To, Begin, End ); - } - }; - - // Container has native replace method - template<> - struct replace_native_helper< true > - { - template< typename InputT, typename ForwardIteratorT > - void operator()( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - Input.replace( From, To, Begin, End ); - } - }; - -// replace helper -------------------------------------------------// - - template< typename InputT, typename ForwardIteratorT > - inline void replace( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - replace_native_helper< has_native_replace::value >()( - Input, From, To, Begin, End ); - } - - template< typename InputT, typename InsertT > - inline void replace( - InputT& Input, - BOOST_STRING_TYPENAME InputT::iterator From, - BOOST_STRING_TYPENAME InputT::iterator To, - const InsertT& Insert ) - { - if(From!=To) - { - ::boost::algorithm::detail::replace( Input, From, To, ::boost::begin(Insert), ::boost::end(Insert) ); - } - else - { - ::boost::algorithm::detail::insert( Input, From, ::boost::begin(Insert), ::boost::end(Insert) ); - } - } - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_DETAIL_SEQUENCE_HPP diff --git a/boost/algorithm/string/detail/trim.hpp b/boost/algorithm/string/detail/trim.hpp deleted file mode 100644 index 1233e49d3010894bd6252a09cfbaf0ee4380c12e..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/trim.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// Boost string_algo library trim.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_TRIM_DETAIL_HPP -#define BOOST_STRING_TRIM_DETAIL_HPP - -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// trim iterator helper -----------------------------------------------// - - template< typename ForwardIteratorT, typename PredicateT > - inline ForwardIteratorT trim_end_iter_select( - ForwardIteratorT InBegin, - ForwardIteratorT InEnd, - PredicateT IsSpace, - std::forward_iterator_tag ) - { - ForwardIteratorT TrimIt=InBegin; - - for( ForwardIteratorT It=InBegin; It!=InEnd; ++It ) - { - if ( !IsSpace(*It) ) - { - TrimIt=It; - ++TrimIt; - } - } - - return TrimIt; - } - - template< typename ForwardIteratorT, typename PredicateT > - inline ForwardIteratorT trim_end_iter_select( - ForwardIteratorT InBegin, - ForwardIteratorT InEnd, - PredicateT IsSpace, - std::bidirectional_iterator_tag ) - { - for( ForwardIteratorT It=InEnd; It!=InBegin; ) - { - if ( !IsSpace(*(--It)) ) - return ++It; - } - - return InBegin; - } - // Search for first non matching character from the beginning of the sequence - template< typename ForwardIteratorT, typename PredicateT > - inline ForwardIteratorT trim_begin( - ForwardIteratorT InBegin, - ForwardIteratorT InEnd, - PredicateT IsSpace ) - { - ForwardIteratorT It=InBegin; - for(; It!=InEnd; ++It ) - { - if (!IsSpace(*It)) - return It; - } - - return It; - } - - // Search for first non matching character from the end of the sequence - template< typename ForwardIteratorT, typename PredicateT > - inline ForwardIteratorT trim_end( - ForwardIteratorT InBegin, - ForwardIteratorT InEnd, - PredicateT IsSpace ) - { - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return ::boost::algorithm::detail::trim_end_iter_select( InBegin, InEnd, IsSpace, category() ); - } - - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_TRIM_DETAIL_HPP diff --git a/boost/algorithm/string/detail/util.hpp b/boost/algorithm/string/detail/util.hpp deleted file mode 100644 index 7844b6723cc6154a50a3ffa232cf00f95288e0bd..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/detail/util.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// Boost string_algo library util.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_UTIL_DETAIL_HPP -#define BOOST_STRING_UTIL_DETAIL_HPP - -#include -#include -#include - -namespace boost { - namespace algorithm { - namespace detail { - -// empty container -----------------------------------------------// - - // empty_container - /* - This class represents always empty container, - containing elements of type CharT. - - It is supposed to be used in a const version only - */ - template< typename CharT > - struct empty_container - { - typedef empty_container type; - typedef CharT value_type; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type& reference; - typedef const value_type& const_reference; - typedef const value_type* iterator; - typedef const value_type* const_iterator; - - - // Operations - const_iterator begin() const - { - return reinterpret_cast(0); - } - - const_iterator end() const - { - return reinterpret_cast(0); - } - - bool empty() const - { - return false; - } - - size_type size() const - { - return 0; - } - }; - -// bounded copy algorithm -----------------------------------------------// - - // Bounded version of the std::copy algorithm - template - inline OutputIteratorT bounded_copy( - InputIteratorT First, - InputIteratorT Last, - OutputIteratorT DestFirst, - OutputIteratorT DestLast ) - { - InputIteratorT InputIt=First; - OutputIteratorT OutputIt=DestFirst; - for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ ) - { - *OutputIt=*InputIt; - } - - return OutputIt; - } - -// iterator range utilities -----------------------------------------// - - // copy range functor - template< - typename SeqT, - typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator > - struct copy_iterator_rangeF - { - typedef iterator_range argument_type; - typedef SeqT result_type; - SeqT operator()( const iterator_range& Range ) const - { - return copy_range(Range); - } - }; - - } // namespace detail - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_UTIL_DETAIL_HPP diff --git a/boost/algorithm/string/erase.hpp b/boost/algorithm/string/erase.hpp deleted file mode 100644 index 6883790978323a742bb995206ea9de562f0587d2..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/erase.hpp +++ /dev/null @@ -1,844 +0,0 @@ -// Boost string_algo library erase.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_ERASE_HPP -#define BOOST_STRING_ERASE_HPP - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file - Defines various erase algorithms. Each algorithm removes - part(s) of the input according to a searching criteria. -*/ - -namespace boost { - namespace algorithm { - -// erase_range -------------------------------------------------------// - - //! Erase range algorithm - /*! - Remove the given range from the input. The result is a modified copy of - the input. It is returned as a sequence or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input sequence - \param SearchRange A range in the input to be removed - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template - inline OutputIteratorT erase_range_copy( - OutputIteratorT Output, - const RangeT& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_const_iterator::type>& SearchRange ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase range algorithm - /*! - \overload - */ - template - inline SequenceT erase_range_copy( - const SequenceT& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_const_iterator::type>& SearchRange ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase range algorithm - /*! - Remove the given range from the input. - The input sequence is modified in-place. - - \param Input An input sequence - \param SearchRange A range in the input to be removed - */ - template - inline void erase_range( - SequenceT& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_iterator::type>& SearchRange ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_first --------------------------------------------------------// - - //! Erase first algorithm - /*! - Remove the first occurrence of the substring from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT erase_first_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase first algorithm - /*! - \overload - */ - template - inline SequenceT erase_first_copy( - const SequenceT& Input, - const RangeT& Search ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase first algorithm - /*! - Remove the first occurrence of the substring from the input. - The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for. - */ - template - inline void erase_first( - SequenceT& Input, - const RangeT& Search ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_first ( case insensitive ) ------------------------------------// - - //! Erase first algorithm ( case insensitive ) - /*! - Remove the first occurrence of the substring from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT ierase_first_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase first algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ierase_first_copy( - const SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase first algorithm ( case insensitive ) - /*! - Remove the first occurrence of the substring from the input. - The input sequence is modified in-place. Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Loc A locale used for case insensitive comparison - */ - template - inline void ierase_first( - SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_last --------------------------------------------------------// - - //! Erase last algorithm - /*! - Remove the last occurrence of the substring from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for. - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT erase_last_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase last algorithm - /*! - \overload - */ - template - inline SequenceT erase_last_copy( - const SequenceT& Input, - const RangeT& Search ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase last algorithm - /*! - Remove the last occurrence of the substring from the input. - The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for - */ - template - inline void erase_last( - SequenceT& Input, - const RangeT& Search ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_last ( case insensitive ) ------------------------------------// - - //! Erase last algorithm ( case insensitive ) - /*! - Remove the last occurrence of the substring from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT ierase_last_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase last algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ierase_last_copy( - const SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase last algorithm ( case insensitive ) - /*! - Remove the last occurrence of the substring from the input. - The input sequence is modified in-place. Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Loc A locale used for case insensitive comparison - */ - template - inline void ierase_last( - SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_nth --------------------------------------------------------------------// - - //! Erase nth algorithm - /*! - Remove the Nth occurrence of the substring in the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT erase_nth_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - int Nth ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase nth algorithm - /*! - \overload - */ - template - inline SequenceT erase_nth_copy( - const SequenceT& Input, - const RangeT& Search, - int Nth ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase nth algorithm - /*! - Remove the Nth occurrence of the substring in the input. - The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for. - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - */ - template - inline void erase_nth( - SequenceT& Input, - const RangeT& Search, - int Nth ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_nth ( case insensitive ) ---------------------------------------------// - - //! Erase nth algorithm ( case insensitive ) - /*! - Remove the Nth occurrence of the substring in the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for. - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT ierase_nth_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - int Nth, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase nth algorithm - /*! - \overload - */ - template - inline SequenceT ierase_nth_copy( - const SequenceT& Input, - const RangeT& Search, - int Nth, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), - empty_formatter(Input) ); - } - - //! Erase nth algorithm - /*! - Remove the Nth occurrence of the substring in the input. - The input sequence is modified in-place. Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for. - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Loc A locale used for case insensitive comparison - */ - template - inline void ierase_nth( - SequenceT& Input, - const RangeT& Search, - int Nth, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - -// erase_all --------------------------------------------------------// - - //! Erase all algorithm - /*! - Remove all the occurrences of the string from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - - \param Output An output iterator to which the result will be copied - \param Input An input sequence - \param Search A substring to be searched for. - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT erase_all_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase all algorithm - /*! - \overload - */ - template - inline SequenceT erase_all_copy( - const SequenceT& Input, - const RangeT& Search ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase all algorithm - /*! - Remove all the occurrences of the string from the input. - The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for. - */ - template - inline void erase_all( - SequenceT& Input, - const RangeT& Search ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_all ( case insensitive ) ------------------------------------// - - //! Erase all algorithm ( case insensitive ) - /*! - Remove all the occurrences of the string from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT ierase_all_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase all algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ierase_all_copy( - const SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - - //! Erase all algorithm ( case insensitive ) - /*! - Remove all the occurrences of the string from the input. - The input sequence is modified in-place. Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for. - \param Loc A locale used for case insensitive comparison - */ - template - inline void ierase_all( - SequenceT& Input, - const RangeT& Search, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::empty_formatter(Input) ); - } - -// erase_head --------------------------------------------------------------------// - - //! Erase head algorithm - /*! - Remove the head from the input. The head is a prefix of a sequence of given size. - If the sequence is shorter then required, the whole string is - considered to be the head. The result is a modified copy of the input. - It is returned as a sequence or copied to the output iterator. - - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param N Length of the head. - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT> - inline OutputIteratorT erase_head_copy( - OutputIteratorT Output, - const RangeT& Input, - int N ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase head algorithm - /*! - \overload - */ - template - inline SequenceT erase_head_copy( - const SequenceT& Input, - int N ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase head algorithm - /*! - Remove the head from the input. The head is a prefix of a sequence of given size. - If the sequence is shorter then required, the whole string is - considered to be the head. The input sequence is modified in-place. - - \param Input An input string - \param N Length of the head - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - */ - template - inline void erase_head( - SequenceT& Input, - int N ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - -// erase_tail --------------------------------------------------------------------// - - //! Erase tail algorithm - /*! - Remove the tail from the input. The tail is a suffix of a sequence of given size. - If the sequence is shorter then required, the whole string is - considered to be the tail. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param N Length of the tail. - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT> - inline OutputIteratorT erase_tail_copy( - OutputIteratorT Output, - const RangeT& Input, - int N ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::tail_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase tail algorithm - /*! - \overload - */ - template - inline SequenceT erase_tail_copy( - const SequenceT& Input, - int N ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::tail_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase tail algorithm - /*! - Remove the tail from the input. The tail is a suffix of a sequence of given size. - If the sequence is shorter then required, the whole string is - considered to be the tail. The input sequence is modified in-place. - - \param Input An input string - \param N Length of the tail - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - */ - template - inline void erase_tail( - SequenceT& Input, - int N ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::tail_finder(N), - ::boost::algorithm::empty_formatter( Input ) ); - } - - } // namespace algorithm - - // pull names into the boost namespace - using algorithm::erase_range_copy; - using algorithm::erase_range; - using algorithm::erase_first_copy; - using algorithm::erase_first; - using algorithm::ierase_first_copy; - using algorithm::ierase_first; - using algorithm::erase_last_copy; - using algorithm::erase_last; - using algorithm::ierase_last_copy; - using algorithm::ierase_last; - using algorithm::erase_nth_copy; - using algorithm::erase_nth; - using algorithm::ierase_nth_copy; - using algorithm::ierase_nth; - using algorithm::erase_all_copy; - using algorithm::erase_all; - using algorithm::ierase_all_copy; - using algorithm::ierase_all; - using algorithm::erase_head_copy; - using algorithm::erase_head; - using algorithm::erase_tail_copy; - using algorithm::erase_tail; - -} // namespace boost - - -#endif // BOOST_ERASE_HPP diff --git a/boost/algorithm/string/find.hpp b/boost/algorithm/string/find.hpp deleted file mode 100644 index f2c2926b5097b2d2070a0e8b8a5a50a2a2518ff3..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/find.hpp +++ /dev/null @@ -1,334 +0,0 @@ -// Boost string_algo library find.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_HPP -#define BOOST_STRING_FIND_HPP - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file - Defines a set of find algorithms. The algorithms are searching - for a substring of the input. The result is given as an \c iterator_range - delimiting the substring. -*/ - -namespace boost { - namespace algorithm { - -// Generic find -----------------------------------------------// - - //! Generic find algorithm - /*! - Search the input using the given finder. - - \param Input A string which will be searched. - \param Finder Finder object used for searching. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c RangeT::iterator or - \c RangeT::const_iterator, depending on the constness of - the input parameter. - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find( - RangeT& Input, - const FinderT& Finder) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - - return Finder(::boost::begin(lit_input),::boost::end(lit_input)); - } - -// find_first -----------------------------------------------// - - //! Find first algorithm - /*! - Search for the first occurrence of the substring in the input. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c RangeT::iterator or - \c RangeT::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_first( - Range1T& Input, - const Range2T& Search) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search)); - } - - //! Find first algorithm ( case insensitive ) - /*! - Search for the first occurrence of the substring in the input. - Searching is case insensitive. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \param Loc A locale used for case insensitive comparison - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - ifind_first( - Range1T& Input, - const Range2T& Search, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search,is_iequal(Loc))); - } - -// find_last -----------------------------------------------// - - //! Find last algorithm - /*! - Search for the last occurrence of the substring in the input. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_last( - Range1T& Input, - const Range2T& Search) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search)); - } - - //! Find last algorithm ( case insensitive ) - /*! - Search for the last match a string in the input. - Searching is case insensitive. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \param Loc A locale used for case insensitive comparison - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - ifind_last( - Range1T& Input, - const Range2T& Search, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search, is_iequal(Loc))); - } - -// find_nth ----------------------------------------------------------------------// - - //! Find n-th algorithm - /*! - Search for the n-th (zero-indexed) occurrence of the substring in the - input. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \param Nth An index (zero-indexed) of the match to be found. - For negative N, the matches are counted from the end of string. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_nth( - Range1T& Input, - const Range2T& Search, - int Nth) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth)); - } - - //! Find n-th algorithm ( case insensitive ). - /*! - Search for the n-th (zero-indexed) occurrence of the substring in the - input. Searching is case insensitive. - - \param Input A string which will be searched. - \param Search A substring to be searched for. - \param Nth An index (zero-indexed) of the match to be found. - For negative N, the matches are counted from the end of string. - \param Loc A locale used for case insensitive comparison - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - ifind_nth( - Range1T& Input, - const Range2T& Search, - int Nth, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth,is_iequal(Loc))); - } - -// find_head ----------------------------------------------------------------------// - - //! Find head algorithm - /*! - Get the head of the input. Head is a prefix of the string of the - given size. If the input is shorter then required, whole input is considered - to be the head. - - \param Input An input string - \param N Length of the head - For N>=0, at most N characters are extracted. - For N<0, at most size(Input)-|N| characters are extracted. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c Range1T::iterator or - \c Range1T::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_head( - RangeT& Input, - int N) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::head_finder(N)); - } - -// find_tail ----------------------------------------------------------------------// - - //! Find tail algorithm - /*! - Get the tail of the input. Tail is a suffix of the string of the - given size. If the input is shorter then required, whole input is considered - to be the tail. - - \param Input An input string - \param N Length of the tail. - For N>=0, at most N characters are extracted. - For N<0, at most size(Input)-|N| characters are extracted. - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c RangeT::iterator or - \c RangeT::const_iterator, depending on the constness of - the input parameter. - - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_tail( - RangeT& Input, - int N) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::tail_finder(N)); - } - -// find_token --------------------------------------------------------------------// - - //! Find token algorithm - /*! - Look for a given token in the string. Token is a character that matches the - given predicate. - If the "token compress mode" is enabled, adjacent tokens are considered to be one match. - - \param Input A input string. - \param Pred A unary predicate to identify a token - \param eCompress Enable/Disable compressing of adjacent tokens - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c RangeT::iterator or - \c RangeT::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type> - find_token( - RangeT& Input, - PredicateT Pred, - token_compress_mode_type eCompress=token_compress_off) - { - return ::boost::algorithm::find(Input, ::boost::algorithm::token_finder(Pred, eCompress)); - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::find; - using algorithm::find_first; - using algorithm::ifind_first; - using algorithm::find_last; - using algorithm::ifind_last; - using algorithm::find_nth; - using algorithm::ifind_nth; - using algorithm::find_head; - using algorithm::find_tail; - using algorithm::find_token; - -} // namespace boost - - -#endif // BOOST_STRING_FIND_HPP diff --git a/boost/algorithm/string/find_format.hpp b/boost/algorithm/string/find_format.hpp deleted file mode 100644 index 0e84a4ee68ab715e269f5dc742df63a64eaad576..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/find_format.hpp +++ /dev/null @@ -1,287 +0,0 @@ -// Boost string_algo library find_format.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_FORMAT_HPP -#define BOOST_STRING_FIND_FORMAT_HPP - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file - Defines generic replace algorithms. Each algorithm replaces - part(s) of the input. The part to be replaced is looked up using a Finder object. - Result of finding is then used by a Formatter object to generate the replacement. -*/ - -namespace boost { - namespace algorithm { - -// generic replace -----------------------------------------------------------------// - - //! Generic replace algorithm - /*! - Use the Finder to search for a substring. Use the Formatter to format - this substring and replace it in the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input sequence - \param Finder A Finder object used to search for a match to be replaced - \param Formatter A Formatter object used to format a match - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename FinderT, - typename FormatterT> - inline OutputIteratorT find_format_copy( - OutputIteratorT Output, - const RangeT& Input, - FinderT Finder, - FormatterT Formatter ) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - iterator_range::type> lit_input(::boost::as_literal(Input)); - - return detail::find_format_copy_impl( - Output, - lit_input, - Formatter, - Finder( ::boost::begin(lit_input), ::boost::end(lit_input) ) ); - } - - //! Generic replace algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename FinderT, - typename FormatterT> - inline SequenceT find_format_copy( - const SequenceT& Input, - FinderT Finder, - FormatterT Formatter ) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - return detail::find_format_copy_impl( - Input, - Formatter, - Finder(::boost::begin(Input), ::boost::end(Input))); - } - - //! Generic replace algorithm - /*! - Use the Finder to search for a substring. Use the Formatter to format - this substring and replace it in the input. The input is modified in-place. - - \param Input An input sequence - \param Finder A Finder object used to search for a match to be replaced - \param Formatter A Formatter object used to format a match - */ - template< - typename SequenceT, - typename FinderT, - typename FormatterT> - inline void find_format( - SequenceT& Input, - FinderT Finder, - FormatterT Formatter) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - detail::find_format_impl( - Input, - Formatter, - Finder(::boost::begin(Input), ::boost::end(Input))); - } - - -// find_format_all generic ----------------------------------------------------------------// - - //! Generic replace all algorithm - /*! - Use the Finder to search for a substring. Use the Formatter to format - this substring and replace it in the input. Repeat this for all matching - substrings. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input sequence - \param Finder A Finder object used to search for a match to be replaced - \param Formatter A Formatter object used to format a match - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename FinderT, - typename FormatterT> - inline OutputIteratorT find_format_all_copy( - OutputIteratorT Output, - const RangeT& Input, - FinderT Finder, - FormatterT Formatter) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - iterator_range::type> lit_input(::boost::as_literal(Input)); - - return detail::find_format_all_copy_impl( - Output, - lit_input, - Finder, - Formatter, - Finder(::boost::begin(lit_input), ::boost::end(lit_input))); - } - - //! Generic replace all algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename FinderT, - typename FormatterT > - inline SequenceT find_format_all_copy( - const SequenceT& Input, - FinderT Finder, - FormatterT Formatter ) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - return detail::find_format_all_copy_impl( - Input, - Finder, - Formatter, - Finder( ::boost::begin(Input), ::boost::end(Input) ) ); - } - - //! Generic replace all algorithm - /*! - Use the Finder to search for a substring. Use the Formatter to format - this substring and replace it in the input. Repeat this for all matching - substrings.The input is modified in-place. - - \param Input An input sequence - \param Finder A Finder object used to search for a match to be replaced - \param Formatter A Formatter object used to format a match - */ - template< - typename SequenceT, - typename FinderT, - typename FormatterT > - inline void find_format_all( - SequenceT& Input, - FinderT Finder, - FormatterT Formatter ) - { - // Concept check - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_const_iterator::type> - )); - BOOST_CONCEPT_ASSERT(( - FormatterConcept< - FormatterT, - FinderT,BOOST_STRING_TYPENAME range_const_iterator::type> - )); - - detail::find_format_all_impl( - Input, - Finder, - Formatter, - Finder(::boost::begin(Input), ::boost::end(Input))); - - } - - } // namespace algorithm - - // pull the names to the boost namespace - using algorithm::find_format_copy; - using algorithm::find_format; - using algorithm::find_format_all_copy; - using algorithm::find_format_all; - -} // namespace boost - - -#endif // BOOST_STRING_FIND_FORMAT_HPP diff --git a/boost/algorithm/string/find_iterator.hpp b/boost/algorithm/string/find_iterator.hpp deleted file mode 100644 index 5a52d92e41b683de2616f4ffbce0515f83f32272..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/find_iterator.hpp +++ /dev/null @@ -1,388 +0,0 @@ -// Boost string_algo library find_iterator.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-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/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FIND_ITERATOR_HPP -#define BOOST_STRING_FIND_ITERATOR_HPP - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -/*! \file - Defines find iterator classes. Find iterator repeatedly applies a Finder - to the specified input string to search for matches. Dereferencing - the iterator yields the current match or a range between the last and the current - match depending on the iterator used. -*/ - -namespace boost { - namespace algorithm { - -// find_iterator -----------------------------------------------// - - //! find_iterator - /*! - Find iterator encapsulates a Finder and allows - for incremental searching in a string. - Each increment moves the iterator to the next match. - - Find iterator is a readable forward traversal iterator. - - Dereferencing the iterator yields an iterator_range delimiting - the current match. - */ - template - class find_iterator : - public iterator_facade< - find_iterator, - const iterator_range, - forward_traversal_tag >, - private detail::find_iterator_base - { - private: - // facade support - friend class ::boost::iterator_core_access; - - private: - // typedefs - - typedef detail::find_iterator_base base_type; - typedef BOOST_STRING_TYPENAME - base_type::input_iterator_type input_iterator_type; - typedef BOOST_STRING_TYPENAME - base_type::match_type match_type; - - public: - //! Default constructor - /*! - Construct null iterator. All null iterators are equal. - - \post eof()==true - */ - find_iterator() {} - - //! Copy constructor - /*! - Construct a copy of the find_iterator - */ - find_iterator( const find_iterator& Other ) : - base_type(Other), - m_Match(Other.m_Match), - m_End(Other.m_End) {} - - //! Constructor - /*! - Construct new find_iterator for a given finder - and a range. - */ - template - find_iterator( - IteratorT Begin, - IteratorT End, - FinderT Finder ) : - detail::find_iterator_base(Finder,0), - m_Match(Begin,Begin), - m_End(End) - { - increment(); - } - - //! Constructor - /*! - Construct new find_iterator for a given finder - and a range. - */ - template - find_iterator( - RangeT& Col, - FinderT Finder ) : - detail::find_iterator_base(Finder,0) - { - iterator_range::type> lit_col(::boost::as_literal(Col)); - m_Match=::boost::make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); - m_End=::boost::end(lit_col); - - increment(); - } - - private: - // iterator operations - - // dereference - const match_type& dereference() const - { - return m_Match; - } - - // increment - void increment() - { - m_Match=this->do_find(m_Match.end(),m_End); - } - - // comparison - bool equal( const find_iterator& Other ) const - { - bool bEof=eof(); - bool bOtherEof=Other.eof(); - - return bEof || bOtherEof ? bEof==bOtherEof : - ( - m_Match==Other.m_Match && - m_End==Other.m_End - ); - } - - public: - // operations - - //! Eof check - /*! - Check the eof condition. Eof condition means that - there is nothing more to be searched i.e. find_iterator - is after the last match. - */ - bool eof() const - { - return - this->is_null() || - ( - m_Match.begin() == m_End && - m_Match.end() == m_End - ); - } - - private: - // Attributes - match_type m_Match; - input_iterator_type m_End; - }; - - //! find iterator construction helper - /*! - * Construct a find iterator to iterate through the specified string - */ - template - inline find_iterator< - BOOST_STRING_TYPENAME range_iterator::type> - make_find_iterator( - RangeT& Collection, - FinderT Finder) - { - return find_iterator::type>( - Collection, Finder); - } - -// split iterator -----------------------------------------------// - - //! split_iterator - /*! - Split iterator encapsulates a Finder and allows - for incremental searching in a string. - Unlike the find iterator, split iterator iterates - through gaps between matches. - - Find iterator is a readable forward traversal iterator. - - Dereferencing the iterator yields an iterator_range delimiting - the current match. - */ - template - class split_iterator : - public iterator_facade< - split_iterator, - const iterator_range, - forward_traversal_tag >, - private detail::find_iterator_base - { - private: - // facade support - friend class ::boost::iterator_core_access; - - private: - // typedefs - - typedef detail::find_iterator_base base_type; - typedef BOOST_STRING_TYPENAME - base_type::input_iterator_type input_iterator_type; - typedef BOOST_STRING_TYPENAME - base_type::match_type match_type; - - public: - //! Default constructor - /*! - Construct null iterator. All null iterators are equal. - - \post eof()==true - */ - split_iterator() : - m_Next(), - m_End(), - m_bEof(true) - {} - - //! Copy constructor - /*! - Construct a copy of the split_iterator - */ - split_iterator( const split_iterator& Other ) : - base_type(Other), - m_Match(Other.m_Match), - m_Next(Other.m_Next), - m_End(Other.m_End), - m_bEof(Other.m_bEof) - {} - - //! Constructor - /*! - Construct new split_iterator for a given finder - and a range. - */ - template - split_iterator( - IteratorT Begin, - IteratorT End, - FinderT Finder ) : - detail::find_iterator_base(Finder,0), - m_Match(Begin,Begin), - m_Next(Begin), - m_End(End), - m_bEof(false) - { - // force the correct behavior for empty sequences and yield at least one token - if(Begin!=End) - { - increment(); - } - } - //! Constructor - /*! - Construct new split_iterator for a given finder - and a collection. - */ - template - split_iterator( - RangeT& Col, - FinderT Finder ) : - detail::find_iterator_base(Finder,0), - m_bEof(false) - { - iterator_range::type> lit_col(::boost::as_literal(Col)); - m_Match=make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); - m_Next=::boost::begin(lit_col); - m_End=::boost::end(lit_col); - - // force the correct behavior for empty sequences and yield at least one token - if(m_Next!=m_End) - { - increment(); - } - } - - - private: - // iterator operations - - // dereference - const match_type& dereference() const - { - return m_Match; - } - - // increment - void increment() - { - match_type FindMatch=this->do_find( m_Next, m_End ); - - if(FindMatch.begin()==m_End && FindMatch.end()==m_End) - { - if(m_Match.end()==m_End) - { - // Mark iterator as eof - m_bEof=true; - } - } - - m_Match=match_type( m_Next, FindMatch.begin() ); - m_Next=FindMatch.end(); - } - - // comparison - bool equal( const split_iterator& Other ) const - { - bool bEof=eof(); - bool bOtherEof=Other.eof(); - - return bEof || bOtherEof ? bEof==bOtherEof : - ( - m_Match==Other.m_Match && - m_Next==Other.m_Next && - m_End==Other.m_End - ); - } - - public: - // operations - - //! Eof check - /*! - Check the eof condition. Eof condition means that - there is nothing more to be searched i.e. find_iterator - is after the last match. - */ - bool eof() const - { - return this->is_null() || m_bEof; - } - - private: - // Attributes - match_type m_Match; - input_iterator_type m_Next; - input_iterator_type m_End; - bool m_bEof; - }; - - //! split iterator construction helper - /*! - * Construct a split iterator to iterate through the specified collection - */ - template - inline split_iterator< - BOOST_STRING_TYPENAME range_iterator::type> - make_split_iterator( - RangeT& Collection, - FinderT Finder) - { - return split_iterator::type>( - Collection, Finder); - } - - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::find_iterator; - using algorithm::make_find_iterator; - using algorithm::split_iterator; - using algorithm::make_split_iterator; - -} // namespace boost - - -#endif // BOOST_STRING_FIND_ITERATOR_HPP diff --git a/boost/algorithm/string/finder.hpp b/boost/algorithm/string/finder.hpp deleted file mode 100644 index 93f7ec304a087754950c3f96fbc2cf667d32d988..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/finder.hpp +++ /dev/null @@ -1,270 +0,0 @@ -// Boost string_algo library finder.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FINDER_HPP -#define BOOST_STRING_FINDER_HPP - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file - Defines Finder generators. Finder object is a functor which is able to - find a substring matching a specific criteria in the input. - Finders are used as a pluggable components for replace, find - and split facilities. This header contains generator functions - for finders provided in this library. -*/ - -namespace boost { - namespace algorithm { - -// Finder generators ------------------------------------------// - - //! "First" finder - /*! - Construct the \c first_finder. The finder searches for the first - occurrence of the string in a given input. - The result is given as an \c iterator_range delimiting the match. - - \param Search A substring to be searched for. - \param Comp An element comparison predicate - \return An instance of the \c first_finder object - */ - template - inline detail::first_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - is_equal> - first_finder( const RangeT& Search ) - { - return - detail::first_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - is_equal>( ::boost::as_literal(Search), is_equal() ) ; - } - - //! "First" finder - /*! - \overload - */ - template - inline detail::first_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - PredicateT> - first_finder( - const RangeT& Search, PredicateT Comp ) - { - return - detail::first_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - PredicateT>( ::boost::as_literal(Search), Comp ); - } - - //! "Last" finder - /*! - Construct the \c last_finder. The finder searches for the last - occurrence of the string in a given input. - The result is given as an \c iterator_range delimiting the match. - - \param Search A substring to be searched for. - \param Comp An element comparison predicate - \return An instance of the \c last_finder object - */ - template - inline detail::last_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - is_equal> - last_finder( const RangeT& Search ) - { - return - detail::last_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - is_equal>( ::boost::as_literal(Search), is_equal() ); - } - //! "Last" finder - /*! - \overload - */ - template - inline detail::last_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - PredicateT> - last_finder( const RangeT& Search, PredicateT Comp ) - { - return - detail::last_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - PredicateT>( ::boost::as_literal(Search), Comp ) ; - } - - //! "Nth" finder - /*! - Construct the \c nth_finder. The finder searches for the n-th (zero-indexed) - occurrence of the string in a given input. - The result is given as an \c iterator_range delimiting the match. - - \param Search A substring to be searched for. - \param Nth An index of the match to be find - \param Comp An element comparison predicate - \return An instance of the \c nth_finder object - */ - template - inline detail::nth_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - is_equal> - nth_finder( - const RangeT& Search, - int Nth) - { - return - detail::nth_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - is_equal>( ::boost::as_literal(Search), Nth, is_equal() ) ; - } - //! "Nth" finder - /*! - \overload - */ - template - inline detail::nth_finderF< - BOOST_STRING_TYPENAME range_const_iterator::type, - PredicateT> - nth_finder( - const RangeT& Search, - int Nth, - PredicateT Comp ) - { - return - detail::nth_finderF< - BOOST_STRING_TYPENAME - range_const_iterator::type, - PredicateT>( ::boost::as_literal(Search), Nth, Comp ); - } - - //! "Head" finder - /*! - Construct the \c head_finder. The finder returns a head of a given - input. The head is a prefix of a string up to n elements in - size. If an input has less then n elements, whole input is - considered a head. - The result is given as an \c iterator_range delimiting the match. - - \param N The size of the head - \return An instance of the \c head_finder object - */ - inline detail::head_finderF - head_finder( int N ) - { - return detail::head_finderF(N); - } - - //! "Tail" finder - /*! - Construct the \c tail_finder. The finder returns a tail of a given - input. The tail is a suffix of a string up to n elements in - size. If an input has less then n elements, whole input is - considered a head. - The result is given as an \c iterator_range delimiting the match. - - \param N The size of the head - \return An instance of the \c tail_finder object - */ - inline detail::tail_finderF - tail_finder( int N ) - { - return detail::tail_finderF(N); - } - - //! "Token" finder - /*! - Construct the \c token_finder. The finder searches for a token - specified by a predicate. It is similar to std::find_if - algorithm, with an exception that it return a range of - instead of a single iterator. - - If "compress token mode" is enabled, adjacent matching tokens are - concatenated into one match. Thus the finder can be used to - search for continuous segments of characters satisfying the - given predicate. - - The result is given as an \c iterator_range delimiting the match. - - \param Pred An element selection predicate - \param eCompress Compress flag - \return An instance of the \c token_finder object - */ - template< typename PredicateT > - inline detail::token_finderF - token_finder( - PredicateT Pred, - token_compress_mode_type eCompress=token_compress_off ) - { - return detail::token_finderF( Pred, eCompress ); - } - - //! "Range" finder - /*! - Construct the \c range_finder. The finder does not perform - any operation. It simply returns the given range for - any input. - - \param Begin Beginning of the range - \param End End of the range - \param Range The range. - \return An instance of the \c range_finger object - */ - template< typename ForwardIteratorT > - inline detail::range_finderF - range_finder( - ForwardIteratorT Begin, - ForwardIteratorT End ) - { - return detail::range_finderF( Begin, End ); - } - - //! "Range" finder - /*! - \overload - */ - template< typename ForwardIteratorT > - inline detail::range_finderF - range_finder( iterator_range Range ) - { - return detail::range_finderF( Range ); - } - - } // namespace algorithm - - // pull the names to the boost namespace - using algorithm::first_finder; - using algorithm::last_finder; - using algorithm::nth_finder; - using algorithm::head_finder; - using algorithm::tail_finder; - using algorithm::token_finder; - using algorithm::range_finder; - -} // namespace boost - - -#endif // BOOST_STRING_FINDER_HPP diff --git a/boost/algorithm/string/formatter.hpp b/boost/algorithm/string/formatter.hpp deleted file mode 100644 index de8681bc3f5bb47f3faa57fb55e40de250f57839..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/formatter.hpp +++ /dev/null @@ -1,120 +0,0 @@ -// Boost string_algo library formatter.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_FORMATTER_HPP -#define BOOST_STRING_FORMATTER_HPP - -#include -#include -#include -#include - -#include - -/*! \file - Defines Formatter generators. Formatter is a functor which formats - a string according to given parameters. A Formatter works - in conjunction with a Finder. A Finder can provide additional information - for a specific Formatter. An example of such a cooperation is regex_finder - and regex_formatter. - - Formatters are used as pluggable components for replace facilities. - This header contains generator functions for the Formatters provided in this library. -*/ - -namespace boost { - namespace algorithm { - -// generic formatters ---------------------------------------------------------------// - - //! Constant formatter - /*! - Constructs a \c const_formatter. Const formatter always returns - the same value, regardless of the parameter. - - \param Format A predefined value used as a result for formatting - \return An instance of the \c const_formatter object. - */ - template - inline detail::const_formatF< - iterator_range< - BOOST_STRING_TYPENAME range_const_iterator::type> > - const_formatter(const RangeT& Format) - { - return detail::const_formatF< - iterator_range< - BOOST_STRING_TYPENAME range_const_iterator::type> >(::boost::as_literal(Format)); - } - - //! Identity formatter - /*! - Constructs an \c identity_formatter. Identity formatter always returns - the parameter. - - \return An instance of the \c identity_formatter object. - */ - template - inline detail::identity_formatF< - iterator_range< - BOOST_STRING_TYPENAME range_const_iterator::type> > - identity_formatter() - { - return detail::identity_formatF< - iterator_range< - BOOST_STRING_TYPENAME range_const_iterator::type> >(); - } - - //! Empty formatter - /*! - Constructs an \c empty_formatter. Empty formatter always returns an empty - sequence. - - \param Input container used to select a correct value_type for the - resulting empty_container<>. - \return An instance of the \c empty_formatter object. - */ - template - inline detail::empty_formatF< - BOOST_STRING_TYPENAME range_value::type> - empty_formatter(const RangeT&) - { - return detail::empty_formatF< - BOOST_STRING_TYPENAME range_value::type>(); - } - - //! Empty formatter - /*! - Constructs a \c dissect_formatter. Dissect formatter uses a specified finder - to extract a portion of the formatted sequence. The first finder's match is returned - as a result - - \param Finder a finder used to select a portion of the formatted sequence - \return An instance of the \c dissect_formatter object. - */ - template - inline detail::dissect_formatF< FinderT > - dissect_formatter(const FinderT& Finder) - { - return detail::dissect_formatF(Finder); - } - - - } // namespace algorithm - - // pull the names to the boost namespace - using algorithm::const_formatter; - using algorithm::identity_formatter; - using algorithm::empty_formatter; - using algorithm::dissect_formatter; - -} // namespace boost - - -#endif // BOOST_FORMATTER_HPP diff --git a/boost/algorithm/string/iter_find.hpp b/boost/algorithm/string/iter_find.hpp deleted file mode 100644 index 10424abc749ebcb9e14f88ac437be3bbcc964c35..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/iter_find.hpp +++ /dev/null @@ -1,193 +0,0 @@ -// Boost string_algo library iter_find.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_ITER_FIND_HPP -#define BOOST_STRING_ITER_FIND_HPP - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file - Defines generic split algorithms. Split algorithms can be - used to divide a sequence into several part according - to a given criteria. Result is given as a 'container - of containers' where elements are copies or references - to extracted parts. - - There are two algorithms provided. One iterates over matching - substrings, the other one over the gaps between these matches. -*/ - -namespace boost { - namespace algorithm { - -// iterate find ---------------------------------------------------// - - //! Iter find algorithm - /*! - This algorithm executes a given finder in iteration on the input, - until the end of input is reached, or no match is found. - Iteration is done using built-in find_iterator, so the real - searching is performed only when needed. - In each iteration new match is found and added to the result. - - \param Result A 'container container' to contain the result of search. - Both outer and inner container must have constructor taking a pair - of iterators as an argument. - Typical type of the result is - \c std::vector> - (each element of such a vector will container a range delimiting - a match). - \param Input A container which will be searched. - \param Finder A Finder object used for searching - \return A reference to the result - - \note Prior content of the result will be overwritten. - */ - template< - typename SequenceSequenceT, - typename RangeT, - typename FinderT > - inline SequenceSequenceT& - iter_find( - SequenceSequenceT& Result, - RangeT& Input, - FinderT Finder ) - { - BOOST_CONCEPT_ASSERT(( - FinderConcept< - FinderT, - BOOST_STRING_TYPENAME range_iterator::type> - )); - - iterator_range::type> lit_input(::boost::as_literal(Input)); - - typedef BOOST_STRING_TYPENAME - range_iterator::type input_iterator_type; - typedef find_iterator find_iterator_type; - typedef detail::copy_iterator_rangeF< - BOOST_STRING_TYPENAME - range_value::type, - input_iterator_type> copy_range_type; - - input_iterator_type InputEnd=::boost::end(lit_input); - - typedef transform_iterator - transform_iter_type; - - transform_iter_type itBegin= - ::boost::make_transform_iterator( - find_iterator_type( ::boost::begin(lit_input), InputEnd, Finder ), - copy_range_type()); - - transform_iter_type itEnd= - ::boost::make_transform_iterator( - find_iterator_type(), - copy_range_type()); - - SequenceSequenceT Tmp(itBegin, itEnd); - - Result.swap(Tmp); - return Result; - } - -// iterate split ---------------------------------------------------// - - //! Split find algorithm - /*! - This algorithm executes a given finder in iteration on the input, - until the end of input is reached, or no match is found. - Iteration is done using built-in find_iterator, so the real - searching is performed only when needed. - Each match is used as a separator of segments. These segments are then - returned in the result. - - \param Result A 'container container' to contain the result of search. - Both outer and inner container must have constructor taking a pair - of iterators as an argument. - Typical type of the result is - \c std::vector> - (each element of such a vector will container a range delimiting - a match). - \param Input A container which will be searched. - \param Finder A finder object used for searching - \return A reference to the result - - \note Prior content of the result will be overwritten. - */ - template< - typename SequenceSequenceT, - typename RangeT, - typename FinderT > - inline SequenceSequenceT& - iter_split( - SequenceSequenceT& Result, - RangeT& Input, - FinderT Finder ) - { - BOOST_CONCEPT_ASSERT(( - FinderConcept::type> - )); - - iterator_range::type> lit_input(::boost::as_literal(Input)); - - typedef BOOST_STRING_TYPENAME - range_iterator::type input_iterator_type; - typedef split_iterator find_iterator_type; - typedef detail::copy_iterator_rangeF< - BOOST_STRING_TYPENAME - range_value::type, - input_iterator_type> copy_range_type; - - input_iterator_type InputEnd=::boost::end(lit_input); - - typedef transform_iterator - transform_iter_type; - - transform_iter_type itBegin= - ::boost::make_transform_iterator( - find_iterator_type( ::boost::begin(lit_input), InputEnd, Finder ), - copy_range_type() ); - - transform_iter_type itEnd= - ::boost::make_transform_iterator( - find_iterator_type(), - copy_range_type() ); - - SequenceSequenceT Tmp(itBegin, itEnd); - - Result.swap(Tmp); - return Result; - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::iter_find; - using algorithm::iter_split; - -} // namespace boost - - -#endif // BOOST_STRING_ITER_FIND_HPP diff --git a/boost/algorithm/string/join.hpp b/boost/algorithm/string/join.hpp deleted file mode 100644 index b871eb44f6941c25b6f00e70b3d26ec2d28bd3f1..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/join.hpp +++ /dev/null @@ -1,145 +0,0 @@ -// Boost string_algo library join.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_JOIN_HPP -#define BOOST_STRING_JOIN_HPP - -#include -#include -#include -#include - -/*! \file - Defines join algorithm. - - Join algorithm is a counterpart to split algorithms. - It joins strings from a 'list' by adding user defined separator. - Additionally there is a version that allows simple filtering - by providing a predicate. -*/ - -namespace boost { - namespace algorithm { - -// join --------------------------------------------------------------// - - //! Join algorithm - /*! - This algorithm joins all strings in a 'list' into one long string. - Segments are concatenated by given separator. - - \param Input A container that holds the input strings. It must be a container-of-containers. - \param Separator A string that will separate the joined segments. - \return Concatenated string. - - \note This function provides the strong exception-safety guarantee - */ - template< typename SequenceSequenceT, typename Range1T> - inline typename range_value::type - join( - const SequenceSequenceT& Input, - const Range1T& Separator) - { - // Define working types - typedef typename range_value::type ResultT; - typedef typename range_const_iterator::type InputIteratorT; - - // Parse input - InputIteratorT itBegin=::boost::begin(Input); - InputIteratorT itEnd=::boost::end(Input); - - // Construct container to hold the result - ResultT Result; - - // Append first element - if(itBegin!=itEnd) - { - detail::insert(Result, ::boost::end(Result), *itBegin); - ++itBegin; - } - - for(;itBegin!=itEnd; ++itBegin) - { - // Add separator - detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); - // Add element - detail::insert(Result, ::boost::end(Result), *itBegin); - } - - return Result; - } - -// join_if ----------------------------------------------------------// - - //! Conditional join algorithm - /*! - This algorithm joins all strings in a 'list' into one long string. - Segments are concatenated by given separator. Only segments that - satisfy the predicate will be added to the result. - - \param Input A container that holds the input strings. It must be a container-of-containers. - \param Separator A string that will separate the joined segments. - \param Pred A segment selection predicate - \return Concatenated string. - - \note This function provides the strong exception-safety guarantee - */ - template< typename SequenceSequenceT, typename Range1T, typename PredicateT> - inline typename range_value::type - join_if( - const SequenceSequenceT& Input, - const Range1T& Separator, - PredicateT Pred) - { - // Define working types - typedef typename range_value::type ResultT; - typedef typename range_const_iterator::type InputIteratorT; - - // Parse input - InputIteratorT itBegin=::boost::begin(Input); - InputIteratorT itEnd=::boost::end(Input); - - // Construct container to hold the result - ResultT Result; - - // Roll to the first element that will be added - while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin; - // Add this element - if(itBegin!=itEnd) - { - detail::insert(Result, ::boost::end(Result), *itBegin); - ++itBegin; - } - - for(;itBegin!=itEnd; ++itBegin) - { - if(Pred(*itBegin)) - { - // Add separator - detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); - // Add element - detail::insert(Result, ::boost::end(Result), *itBegin); - } - } - - return Result; - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::join; - using algorithm::join_if; - -} // namespace boost - - -#endif // BOOST_STRING_JOIN_HPP - diff --git a/boost/algorithm/string/predicate.hpp b/boost/algorithm/string/predicate.hpp deleted file mode 100644 index 0879829b5a46a9fed3caf40e16423bebab6d04dd..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/predicate.hpp +++ /dev/null @@ -1,475 +0,0 @@ -// Boost string_algo library predicate.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_PREDICATE_HPP -#define BOOST_STRING_PREDICATE_HPP - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/*! \file boost/algorithm/string/predicate.hpp - Defines string-related predicates. - The predicates determine whether a substring is contained in the input string - under various conditions: a string starts with the substring, ends with the - substring, simply contains the substring or if both strings are equal. - Additionaly the algorithm \c all() checks all elements of a container to satisfy a - condition. - - All predicates provide the strong exception guarantee. -*/ - -namespace boost { - namespace algorithm { - -// starts_with predicate -----------------------------------------------// - - //! 'Starts with' predicate - /*! - This predicate holds when the test string is a prefix of the Input. - In other words, if the input starts with the test. - When the optional predicate is specified, it is used for character-wise - comparison. - - \param Input An input sequence - \param Test A test sequence - \param Comp An element comparison predicate - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool starts_with( - const Range1T& Input, - const Range2T& Test, - PredicateT Comp) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - iterator_range::type> lit_test(::boost::as_literal(Test)); - - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator1T; - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator2T; - - Iterator1T InputEnd=::boost::end(lit_input); - Iterator2T TestEnd=::boost::end(lit_test); - - Iterator1T it=::boost::begin(lit_input); - Iterator2T pit=::boost::begin(lit_test); - for(; - it!=InputEnd && pit!=TestEnd; - ++it,++pit) - { - if( !(Comp(*it,*pit)) ) - return false; - } - - return pit==TestEnd; - } - - //! 'Starts with' predicate - /*! - \overload - */ - template - inline bool starts_with( - const Range1T& Input, - const Range2T& Test) - { - return ::boost::algorithm::starts_with(Input, Test, is_equal()); - } - - //! 'Starts with' predicate ( case insensitive ) - /*! - This predicate holds when the test string is a prefix of the Input. - In other words, if the input starts with the test. - Elements are compared case insensitively. - - \param Input An input sequence - \param Test A test sequence - \param Loc A locale used for case insensitive comparison - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool istarts_with( - const Range1T& Input, - const Range2T& Test, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::starts_with(Input, Test, is_iequal(Loc)); - } - - -// ends_with predicate -----------------------------------------------// - - //! 'Ends with' predicate - /*! - This predicate holds when the test string is a suffix of the Input. - In other words, if the input ends with the test. - When the optional predicate is specified, it is used for character-wise - comparison. - - - \param Input An input sequence - \param Test A test sequence - \param Comp An element comparison predicate - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool ends_with( - const Range1T& Input, - const Range2T& Test, - PredicateT Comp) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - iterator_range::type> lit_test(::boost::as_literal(Test)); - - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator1T; - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return detail:: - ends_with_iter_select( - ::boost::begin(lit_input), - ::boost::end(lit_input), - ::boost::begin(lit_test), - ::boost::end(lit_test), - Comp, - category()); - } - - - //! 'Ends with' predicate - /*! - \overload - */ - template - inline bool ends_with( - const Range1T& Input, - const Range2T& Test) - { - return ::boost::algorithm::ends_with(Input, Test, is_equal()); - } - - //! 'Ends with' predicate ( case insensitive ) - /*! - This predicate holds when the test container is a suffix of the Input. - In other words, if the input ends with the test. - Elements are compared case insensitively. - - \param Input An input sequence - \param Test A test sequence - \param Loc A locale used for case insensitive comparison - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool iends_with( - const Range1T& Input, - const Range2T& Test, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::ends_with(Input, Test, is_iequal(Loc)); - } - -// contains predicate -----------------------------------------------// - - //! 'Contains' predicate - /*! - This predicate holds when the test container is contained in the Input. - When the optional predicate is specified, it is used for character-wise - comparison. - - \param Input An input sequence - \param Test A test sequence - \param Comp An element comparison predicate - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool contains( - const Range1T& Input, - const Range2T& Test, - PredicateT Comp) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - iterator_range::type> lit_test(::boost::as_literal(Test)); - - if (::boost::empty(lit_test)) - { - // Empty range is contained always - return true; - } - - // Use the temporary variable to make VACPP happy - bool bResult=(::boost::algorithm::first_finder(lit_test,Comp)(::boost::begin(lit_input), ::boost::end(lit_input))); - return bResult; - } - - //! 'Contains' predicate - /*! - \overload - */ - template - inline bool contains( - const Range1T& Input, - const Range2T& Test) - { - return ::boost::algorithm::contains(Input, Test, is_equal()); - } - - //! 'Contains' predicate ( case insensitive ) - /*! - This predicate holds when the test container is contained in the Input. - Elements are compared case insensitively. - - \param Input An input sequence - \param Test A test sequence - \param Loc A locale used for case insensitive comparison - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool icontains( - const Range1T& Input, - const Range2T& Test, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::contains(Input, Test, is_iequal(Loc)); - } - -// equals predicate -----------------------------------------------// - - //! 'Equals' predicate - /*! - This predicate holds when the test container is equal to the - input container i.e. all elements in both containers are same. - When the optional predicate is specified, it is used for character-wise - comparison. - - \param Input An input sequence - \param Test A test sequence - \param Comp An element comparison predicate - \return The result of the test - - \note This is a two-way version of \c std::equal algorithm - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool equals( - const Range1T& Input, - const Range2T& Test, - PredicateT Comp) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - iterator_range::type> lit_test(::boost::as_literal(Test)); - - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator1T; - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator2T; - - Iterator1T InputEnd=::boost::end(lit_input); - Iterator2T TestEnd=::boost::end(lit_test); - - Iterator1T it=::boost::begin(lit_input); - Iterator2T pit=::boost::begin(lit_test); - for(; - it!=InputEnd && pit!=TestEnd; - ++it,++pit) - { - if( !(Comp(*it,*pit)) ) - return false; - } - - return (pit==TestEnd) && (it==InputEnd); - } - - //! 'Equals' predicate - /*! - \overload - */ - template - inline bool equals( - const Range1T& Input, - const Range2T& Test) - { - return ::boost::algorithm::equals(Input, Test, is_equal()); - } - - //! 'Equals' predicate ( case insensitive ) - /*! - This predicate holds when the test container is equal to the - input container i.e. all elements in both containers are same. - Elements are compared case insensitively. - - \param Input An input sequence - \param Test A test sequence - \param Loc A locale used for case insensitive comparison - \return The result of the test - - \note This is a two-way version of \c std::equal algorithm - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool iequals( - const Range1T& Input, - const Range2T& Test, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::equals(Input, Test, is_iequal(Loc)); - } - -// lexicographical_compare predicate -----------------------------// - - //! Lexicographical compare predicate - /*! - This predicate is an overload of std::lexicographical_compare - for range arguments - - It check whether the first argument is lexicographically less - then the second one. - - If the optional predicate is specified, it is used for character-wise - comparison - - \param Arg1 First argument - \param Arg2 Second argument - \param Pred Comparison predicate - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool lexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2, - PredicateT Pred) - { - iterator_range::type> lit_arg1(::boost::as_literal(Arg1)); - iterator_range::type> lit_arg2(::boost::as_literal(Arg2)); - - return std::lexicographical_compare( - ::boost::begin(lit_arg1), - ::boost::end(lit_arg1), - ::boost::begin(lit_arg2), - ::boost::end(lit_arg2), - Pred); - } - - //! Lexicographical compare predicate - /*! - \overload - */ - template - inline bool lexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2) - { - return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_less()); - } - - //! Lexicographical compare predicate (case-insensitive) - /*! - This predicate is an overload of std::lexicographical_compare - for range arguments. - It check whether the first argument is lexicographically less - then the second one. - Elements are compared case insensitively - - - \param Arg1 First argument - \param Arg2 Second argument - \param Loc A locale used for case insensitive comparison - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool ilexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2, - const std::locale& Loc=std::locale()) - { - return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_iless(Loc)); - } - - -// all predicate -----------------------------------------------// - - //! 'All' predicate - /*! - This predicate holds it all its elements satisfy a given - condition, represented by the predicate. - - \param Input An input sequence - \param Pred A predicate - \return The result of the test - - \note This function provides the strong exception-safety guarantee - */ - template - inline bool all( - const RangeT& Input, - PredicateT Pred) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - - typedef BOOST_STRING_TYPENAME - range_const_iterator::type Iterator1T; - - Iterator1T InputEnd=::boost::end(lit_input); - for( Iterator1T It=::boost::begin(lit_input); It!=InputEnd; ++It) - { - if (!Pred(*It)) - return false; - } - - return true; - } - - } // namespace algorithm - - // pull names to the boost namespace - using algorithm::starts_with; - using algorithm::istarts_with; - using algorithm::ends_with; - using algorithm::iends_with; - using algorithm::contains; - using algorithm::icontains; - using algorithm::equals; - using algorithm::iequals; - using algorithm::all; - using algorithm::lexicographical_compare; - using algorithm::ilexicographical_compare; - -} // namespace boost - - -#endif // BOOST_STRING_PREDICATE_HPP diff --git a/boost/algorithm/string/predicate_facade.hpp b/boost/algorithm/string/predicate_facade.hpp deleted file mode 100644 index a9753fc2ae61e7d813dbd4528cdddb8c5a55542e..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/predicate_facade.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Boost string_algo library predicate_facade.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_PREDICATE_FACADE_HPP -#define BOOST_STRING_PREDICATE_FACADE_HPP - -#include - -/* - \file boost/algorith/string/predicate_facade.hpp - This file contains predicate_facade definition. This template class is used - to identify classification predicates, so they can be combined using - composition operators. -*/ - -namespace boost { - namespace algorithm { - -// predicate facade ------------------------------------------------------// - - //! Predicate facade - /*! - This class allows to recognize classification - predicates, so that they can be combined using - composition operators. - Every classification predicate must be derived from this class. - */ - template - struct predicate_facade {}; - - } // namespace algorithm -} // namespace boost - - -#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP diff --git a/boost/algorithm/string/regex.hpp b/boost/algorithm/string/regex.hpp deleted file mode 100644 index a6c7c60ae8dbafbdb8cd7ccb6a671b5ba79f9e49..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/regex.hpp +++ /dev/null @@ -1,646 +0,0 @@ -// Boost string_algo library regex.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_REGEX_HPP -#define BOOST_STRING_REGEX_HPP - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/*! \file - Defines regex variants of the algorithms. -*/ - -namespace boost { - namespace algorithm { - -// find_regex -----------------------------------------------// - - //! Find regex algorithm - /*! - Search for a substring matching the given regex in the input. - - \param Input A container which will be searched. - \param Rx A regular expression - \param Flags Regex options - \return - An \c iterator_range delimiting the match. - Returned iterator is either \c RangeT::iterator or - \c RangeT::const_iterator, depending on the constness of - the input parameter. - - \note This function provides the strong exception-safety guarantee - */ - template< - typename RangeT, - typename CharT, - typename RegexTraitsT> - inline iterator_range< - BOOST_STRING_TYPENAME range_iterator::type > - find_regex( - RangeT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - iterator_range::type> lit_input(::boost::as_literal(Input)); - - return ::boost::algorithm::regex_finder(Rx,Flags)( - ::boost::begin(lit_input), ::boost::end(lit_input) ); - } - -// replace_regex --------------------------------------------------------------------// - - //! Replace regex algorithm - /*! - Search for a substring matching given regex and format it with - the specified format. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Rx A regular expression - \param Format Regex format definition - \param Flags Regex options - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline OutputIteratorT replace_regex_copy( - OutputIteratorT Output, - const RangeT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - - //! Replace regex algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline SequenceT replace_regex_copy( - const SequenceT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - - //! Replace regex algorithm - /*! - Search for a substring matching given regex and format it with - the specified format. The input string is modified in-place. - - \param Input An input string - \param Rx A regular expression - \param Format Regex format definition - \param Flags Regex options - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline void replace_regex( - SequenceT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - -// replace_all_regex --------------------------------------------------------------------// - - //! Replace all regex algorithm - /*! - Format all substrings, matching given regex, with the specified format. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Rx A regular expression - \param Format Regex format definition - \param Flags Regex options - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline OutputIteratorT replace_all_regex_copy( - OutputIteratorT Output, - const RangeT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - - //! Replace all regex algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline SequenceT replace_all_regex_copy( - const SequenceT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - - //! Replace all regex algorithm - /*! - Format all substrings, matching given regex, with the specified format. - The input string is modified in-place. - - \param Input An input string - \param Rx A regular expression - \param Format Regex format definition - \param Flags Regex options - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT, - typename FormatStringTraitsT, typename FormatStringAllocatorT > - inline void replace_all_regex( - SequenceT& Input, - const basic_regex& Rx, - const std::basic_string& Format, - match_flag_type Flags=match_default | format_default ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::regex_formatter( Format, Flags ) ); - } - -// erase_regex --------------------------------------------------------------------// - - //! Erase regex algorithm - /*! - Remove a substring matching given regex from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Rx A regular expression - \param Flags Regex options - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename CharT, - typename RegexTraitsT > - inline OutputIteratorT erase_regex_copy( - OutputIteratorT Output, - const RangeT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase regex algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT > - inline SequenceT erase_regex_copy( - const SequenceT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase regex algorithm - /*! - Remove a substring matching given regex from the input. - The input string is modified in-place. - - \param Input An input string - \param Rx A regular expression - \param Flags Regex options - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT > - inline void erase_regex( - SequenceT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - -// erase_all_regex --------------------------------------------------------------------// - - //! Erase all regex algorithm - /*! - Erase all substrings, matching given regex, from the input. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Rx A regular expression - \param Flags Regex options - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename RangeT, - typename CharT, - typename RegexTraitsT > - inline OutputIteratorT erase_all_regex_copy( - OutputIteratorT Output, - const RangeT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase all regex algorithm - /*! - \overload - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT > - inline SequenceT erase_all_regex_copy( - const SequenceT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - - //! Erase all regex algorithm - /*! - Erase all substrings, matching given regex, from the input. - The input string is modified in-place. - - \param Input An input string - \param Rx A regular expression - \param Flags Regex options - */ - template< - typename SequenceT, - typename CharT, - typename RegexTraitsT> - inline void erase_all_regex( - SequenceT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::regex_finder( Rx, Flags ), - ::boost::algorithm::empty_formatter( Input ) ); - } - -// find_all_regex ------------------------------------------------------------------// - - //! Find all regex algorithm - /*! - This algorithm finds all substrings matching the give regex - in the input. - - Each part is copied and added as a new element to the output container. - Thus the result container must be able to hold copies - of the matches (in a compatible structure like std::string) or - a reference to it (e.g. using the iterator range class). - Examples of such a container are \c std::vector - or \c std::list> - - \param Result A container that can hold copies of references to the substrings. - \param Input A container which will be searched. - \param Rx A regular expression - \param Flags Regex options - \return A reference to the result - - \note Prior content of the result will be overwritten. - - \note This function provides the strong exception-safety guarantee - */ - template< - typename SequenceSequenceT, - typename RangeT, - typename CharT, - typename RegexTraitsT > - inline SequenceSequenceT& find_all_regex( - SequenceSequenceT& Result, - const RangeT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::iter_find( - Result, - Input, - ::boost::algorithm::regex_finder(Rx,Flags) ); - } - -// split_regex ------------------------------------------------------------------// - - //! Split regex algorithm - /*! - Tokenize expression. This function is equivalent to C strtok. Input - sequence is split into tokens, separated by separators. Separator - is an every match of the given regex. - Each part is copied and added as a new element to the output container. - Thus the result container must be able to hold copies - of the matches (in a compatible structure like std::string) or - a reference to it (e.g. using the iterator range class). - Examples of such a container are \c std::vector - or \c std::list> - - \param Result A container that can hold copies of references to the substrings. - \param Input A container which will be searched. - \param Rx A regular expression - \param Flags Regex options - \return A reference to the result - - \note Prior content of the result will be overwritten. - - \note This function provides the strong exception-safety guarantee - */ - template< - typename SequenceSequenceT, - typename RangeT, - typename CharT, - typename RegexTraitsT > - inline SequenceSequenceT& split_regex( - SequenceSequenceT& Result, - const RangeT& Input, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - return ::boost::algorithm::iter_split( - Result, - Input, - ::boost::algorithm::regex_finder(Rx,Flags) ); - } - -// join_if ------------------------------------------------------------------// - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - //! Conditional join algorithm - /*! - This algorithm joins all strings in a 'list' into one long string. - Segments are concatenated by given separator. Only segments that - match the given regular expression will be added to the result - - This is a specialization of join_if algorithm. - - \param Input A container that holds the input strings. It must be a container-of-containers. - \param Separator A string that will separate the joined segments. - \param Rx A regular expression - \param Flags Regex options - \return Concatenated string. - - \note This function provides the strong exception-safety guarantee - */ - template< - typename SequenceSequenceT, - typename Range1T, - typename CharT, - typename RegexTraitsT > - inline typename range_value::type - join_if( - const SequenceSequenceT& Input, - const Range1T& Separator, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - // Define working types - typedef typename range_value::type ResultT; - typedef typename range_const_iterator::type InputIteratorT; - - // Parse input - InputIteratorT itBegin=::boost::begin(Input); - InputIteratorT itEnd=::boost::end(Input); - - // Construct container to hold the result - ResultT Result; - - - // Roll to the first element that will be added - while( - itBegin!=itEnd && - !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; - - // Add this element - if(itBegin!=itEnd) - { - detail::insert(Result, ::boost::end(Result), *itBegin); - ++itBegin; - } - - for(;itBegin!=itEnd; ++itBegin) - { - if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) - { - // Add separator - detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); - // Add element - detail::insert(Result, ::boost::end(Result), *itBegin); - } - } - - return Result; - } - -#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - //! Conditional join algorithm - /*! - This algorithm joins all strings in a 'list' into one long string. - Segments are concatenated by given separator. Only segments that - match the given regular expression will be added to the result - - This is a specialization of join_if algorithm. - - \param Input A container that holds the input strings. It must be a container-of-containers. - \param Separator A string that will separate the joined segments. - \param Rx A regular expression - \param Flags Regex options - \return Concatenated string. - - \note This function provides the strong exception-safety guarantee - */ - template< - typename SequenceSequenceT, - typename Range1T, - typename CharT, - typename RegexTraitsT > - inline typename range_value::type - join_if_regex( - const SequenceSequenceT& Input, - const Range1T& Separator, - const basic_regex& Rx, - match_flag_type Flags=match_default ) - { - // Define working types - typedef typename range_value::type ResultT; - typedef typename range_const_iterator::type InputIteratorT; - - // Parse input - InputIteratorT itBegin=::boost::begin(Input); - InputIteratorT itEnd=::boost::end(Input); - - // Construct container to hold the result - ResultT Result; - - - // Roll to the first element that will be added - while( - itBegin!=itEnd && - !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; - - // Add this element - if(itBegin!=itEnd) - { - detail::insert(Result, ::boost::end(Result), *itBegin); - ++itBegin; - } - - for(;itBegin!=itEnd; ++itBegin) - { - if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) - { - // Add separator - detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); - // Add element - detail::insert(Result, ::boost::end(Result), *itBegin); - } - } - - return Result; - } - - -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - } // namespace algorithm - - // pull names into the boost namespace - using algorithm::find_regex; - using algorithm::replace_regex; - using algorithm::replace_regex_copy; - using algorithm::replace_all_regex; - using algorithm::replace_all_regex_copy; - using algorithm::erase_regex; - using algorithm::erase_regex_copy; - using algorithm::erase_all_regex; - using algorithm::erase_all_regex_copy; - using algorithm::find_all_regex; - using algorithm::split_regex; - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - using algorithm::join_if; -#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - using algorithm::join_if_regex; -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -} // namespace boost - - -#endif // BOOST_STRING_REGEX_HPP diff --git a/boost/algorithm/string/regex_find_format.hpp b/boost/algorithm/string/regex_find_format.hpp deleted file mode 100644 index 409afc2ba0c4ba9192b181e11ad29a0c1a77738e..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/regex_find_format.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Boost string_algo library regex_find_format.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2003. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_REGEX_FIND_FORMAT_HPP -#define BOOST_STRING_REGEX_FIND_FORMAT_HPP - -#include -#include -#include -#include - -/*! \file - Defines the \c regex_finder and \c regex_formatter generators. These two functors - are designed to work together. \c regex_formatter uses additional information - about a match contained in the regex_finder search result. -*/ - -namespace boost { - namespace algorithm { - -// regex_finder -----------------------------------------------// - - //! "Regex" finder - /*! - Construct the \c regex_finder. Finder uses the regex engine to search - for a match. - Result is given in \c regex_search_result. This is an extension - of the iterator_range. In addition it contains match results - from the \c regex_search algorithm. - - \param Rx A regular expression - \param MatchFlags Regex search options - \return An instance of the \c regex_finder object - */ - template< - typename CharT, - typename RegexTraitsT> - inline detail::find_regexF< basic_regex > - regex_finder( - const basic_regex& Rx, - match_flag_type MatchFlags=match_default ) - { - return detail:: - find_regexF< - basic_regex >( Rx, MatchFlags ); - } - -// regex_formater ---------------------------------------------// - - //! Regex formatter - /*! - Construct the \c regex_formatter. Regex formatter uses the regex engine to - format a match found by the \c regex_finder. - This formatted it designed to closely cooperate with \c regex_finder. - - \param Format Regex format definition - \param Flags Format flags - \return An instance of the \c regex_formatter functor - */ - template< - typename CharT, - typename TraitsT, typename AllocT > - inline detail::regex_formatF< std::basic_string< CharT, TraitsT, AllocT > > - regex_formatter( - const std::basic_string& Format, - match_flag_type Flags=format_default ) - { - return - detail::regex_formatF< std::basic_string >( - Format, - Flags ); - } - - } // namespace algorithm - - // pull the names to the boost namespace - using algorithm::regex_finder; - using algorithm::regex_formatter; - -} // namespace boost - - -#endif // BOOST_STRING_REGEX_FIND_FORMAT_HPP diff --git a/boost/algorithm/string/replace.hpp b/boost/algorithm/string/replace.hpp deleted file mode 100644 index 2adb031c59ab07f350527fbcb207dfb5572602de..0000000000000000000000000000000000000000 --- a/boost/algorithm/string/replace.hpp +++ /dev/null @@ -1,926 +0,0 @@ -// Boost string_algo library replace.hpp header file ---------------------------// - -// Copyright Pavol Droba 2002-2006. -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/ for updates, documentation, and revision history. - -#ifndef BOOST_STRING_REPLACE_HPP -#define BOOST_STRING_REPLACE_HPP - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/*! \file - Defines various replace algorithms. Each algorithm replaces - part(s) of the input according to set of searching and replace criteria. -*/ - -namespace boost { - namespace algorithm { - -// replace_range --------------------------------------------------------------------// - - //! Replace range algorithm - /*! - Replace the given range in the input string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param SearchRange A range in the input to be substituted - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT replace_range_copy( - OutputIteratorT Output, - const Range1T& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_const_iterator::type>& SearchRange, - const Range2T& Format) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::const_formatter(Format)); - } - - //! Replace range algorithm - /*! - \overload - */ - template - inline SequenceT replace_range_copy( - const SequenceT& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_const_iterator::type>& SearchRange, - const RangeT& Format) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::const_formatter(Format)); - } - - //! Replace range algorithm - /*! - Replace the given range in the input string. - The input sequence is modified in-place. - - \param Input An input string - \param SearchRange A range in the input to be substituted - \param Format A substitute string - */ - template - inline void replace_range( - SequenceT& Input, - const iterator_range< - BOOST_STRING_TYPENAME - range_iterator::type>& SearchRange, - const RangeT& Format) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::range_finder(SearchRange), - ::boost::algorithm::const_formatter(Format)); - } - -// replace_first --------------------------------------------------------------------// - - //! Replace first algorithm - /*! - Replace the first match of the search substring in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT replace_first_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace first algorithm - /*! - \overload - */ - template - inline SequenceT replace_first_copy( - const SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace first algorithm - /*! - replace the first match of the search substring in the input - with the format string. The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - */ - template - inline void replace_first( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_first ( case insensitive ) ---------------------------------------------// - - //! Replace first algorithm ( case insensitive ) - /*! - Replace the first match of the search substring in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT ireplace_first_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace first algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ireplace_first_copy( - const SequenceT& Input, - const Range2T& Search, - const Range1T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace first algorithm ( case insensitive ) - /*! - Replace the first match of the search substring in the input - with the format string. Input sequence is modified in-place. - Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - */ - template - inline void ireplace_first( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_last --------------------------------------------------------------------// - - //! Replace last algorithm - /*! - Replace the last match of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT replace_last_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace last algorithm - /*! - \overload - */ - template - inline SequenceT replace_last_copy( - const SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace last algorithm - /*! - Replace the last match of the search string in the input - with the format string. Input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - */ - template - inline void replace_last( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::last_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_last ( case insensitive ) -----------------------------------------------// - - //! Replace last algorithm ( case insensitive ) - /*! - Replace the last match of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT ireplace_last_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace last algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ireplace_last_copy( - const SequenceT& Input, - const Range1T& Search, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace last algorithm ( case insensitive ) - /*! - Replace the last match of the search string in the input - with the format string.The input sequence is modified in-place. - Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - */ - template - inline void ireplace_last( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::last_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_nth --------------------------------------------------------------------// - - //! Replace nth algorithm - /*! - Replace an Nth (zero-indexed) match of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT replace_nth_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - int Nth, - const Range3T& Format ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace nth algorithm - /*! - \overload - */ - template - inline SequenceT replace_nth_copy( - const SequenceT& Input, - const Range1T& Search, - int Nth, - const Range2T& Format ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace nth algorithm - /*! - Replace an Nth (zero-indexed) match of the search string in the input - with the format string. Input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Format A substitute string - */ - template - inline void replace_nth( - SequenceT& Input, - const Range1T& Search, - int Nth, - const Range2T& Format ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::nth_finder(Search, Nth), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_nth ( case insensitive ) -----------------------------------------------// - - //! Replace nth algorithm ( case insensitive ) - /*! - Replace an Nth (zero-indexed) match of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT ireplace_nth_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - int Nth, - const Range3T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace nth algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ireplace_nth_copy( - const SequenceT& Input, - const Range1T& Search, - int Nth, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace nth algorithm ( case insensitive ) - /*! - Replace an Nth (zero-indexed) match of the search string in the input - with the format string. Input sequence is modified in-place. - Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Nth An index of the match to be replaced. The index is 0-based. - For negative N, matches are counted from the end of string. - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - */ - template - inline void ireplace_nth( - SequenceT& Input, - const Range1T& Search, - int Nth, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_all --------------------------------------------------------------------// - - //! Replace all algorithm - /*! - Replace all occurrences of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT replace_all_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace all algorithm - /*! - \overload - */ - template - inline SequenceT replace_all_copy( - const SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace all algorithm - /*! - Replace all occurrences of the search string in the input - with the format string. The input sequence is modified in-place. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - */ - template - inline void replace_all( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::first_finder(Search), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_all ( case insensitive ) -----------------------------------------------// - - //! Replace all algorithm ( case insensitive ) - /*! - Replace all occurrences of the search string in the input - with the format string. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - Searching is case insensitive. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T, - typename Range3T> - inline OutputIteratorT ireplace_all_copy( - OutputIteratorT Output, - const Range1T& Input, - const Range2T& Search, - const Range3T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_all_copy( - Output, - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace all algorithm ( case insensitive ) - /*! - \overload - */ - template - inline SequenceT ireplace_all_copy( - const SequenceT& Input, - const Range1T& Search, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - return ::boost::algorithm::find_format_all_copy( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace all algorithm ( case insensitive ) - /*! - Replace all occurrences of the search string in the input - with the format string.The input sequence is modified in-place. - Searching is case insensitive. - - \param Input An input string - \param Search A substring to be searched for - \param Format A substitute string - \param Loc A locale used for case insensitive comparison - */ - template - inline void ireplace_all( - SequenceT& Input, - const Range1T& Search, - const Range2T& Format, - const std::locale& Loc=std::locale() ) - { - ::boost::algorithm::find_format_all( - Input, - ::boost::algorithm::first_finder(Search, is_iequal(Loc)), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_head --------------------------------------------------------------------// - - //! Replace head algorithm - /*! - Replace the head of the input with the given format string. - The head is a prefix of a string of given size. - If the sequence is shorter then required, whole string if - considered to be the head. - The result is a modified copy of the input. It is returned as a sequence - or copied to the output iterator. - - \param Output An output iterator to which the result will be copied - \param Input An input string - \param N Length of the head. - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - \param Format A substitute string - \return An output iterator pointing just after the last inserted character or - a modified copy of the input - - \note The second variant of this function provides the strong exception-safety guarantee - */ - template< - typename OutputIteratorT, - typename Range1T, - typename Range2T> - inline OutputIteratorT replace_head_copy( - OutputIteratorT Output, - const Range1T& Input, - int N, - const Range2T& Format ) - { - return ::boost::algorithm::find_format_copy( - Output, - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace head algorithm - /*! - \overload - */ - template - inline SequenceT replace_head_copy( - const SequenceT& Input, - int N, - const RangeT& Format ) - { - return ::boost::algorithm::find_format_copy( - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::const_formatter(Format) ); - } - - //! Replace head algorithm - /*! - Replace the head of the input with the given format string. - The head is a prefix of a string of given size. - If the sequence is shorter then required, the whole string is - considered to be the head. The input sequence is modified in-place. - - \param Input An input string - \param N Length of the head. - For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. - \param Format A substitute string - */ - template - inline void replace_head( - SequenceT& Input, - int N, - const RangeT& Format ) - { - ::boost::algorithm::find_format( - Input, - ::boost::algorithm::head_finder(N), - ::boost::algorithm::const_formatter(Format) ); - } - -// replace_tail --------------------------------------------------------------------// - - //! Replace tail algorithm - /*! - Replace the tail of the input with the given format string. - The tail is a suffix of a string of given size. - If the sequence is shorter then required, whole string is -