Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52003 - in sandbox/improved_fast_gauss_transform: boost/math/ifgt boost/math/ifgt/bandwidth boost/math/ifgt/cluster_radius boost/math/ifgt/crtp boost/math/ifgt/cutoff_radius boost/math/ifgt/detail boost/math/ifgt/exact boost/math/ifgt/exact/detail boost/math/ifgt/fast boost/math/ifgt/fast/detail boost/math/ifgt/for_each boost/math/ifgt/for_each/detail boost/math/ifgt/functor boost/math/ifgt/truncation_degree libs/math/ifgt/doc libs/math/ifgt/src/example
From: erwann.rogard_at_[hidden]
Date: 2009-03-26 18:29:22


Author: e_r
Date: 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
New Revision: 52003
URL: http://svn.boost.org/trac/boost/changeset/52003

Log:
Cleaner dir structure
Added:
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/bandwidth/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/bandwidth/normal_plug_in.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_radius/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_radius/at_max_degree.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/accumulator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/none.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/rydg.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/evaluator_common.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/normal_kernel_properties.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/zscore.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/accumulator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contribution.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contributions_evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/accumulator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_call_center.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/clusters_evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients_evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/evaluator.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/find_nearest_cluster.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/accumulate.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/detail/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/detail/make_traits.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/evaluate.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/front_insert_1.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/gauss_transform.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/nadaraya_watson.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/rozenblatt_parzen.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/gauss_transform.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/nadaraya_watson.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/rozenblatt_parzen.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/keyword.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/constant.hpp (contents, props changed)
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/properties.hpp (contents, props changed)
Removed:
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/accumulator_base.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_gauss_transform.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_nadaraya_watson_estimate.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_wrapper.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_call_center.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/clusters_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_none.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_rydg.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_base.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_common.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_accumulator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contribution.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contributions_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_accumulator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_evaluator.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/find_nearest_cluster.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate_rest_weights.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_evaluate.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_rozenblatt_parzen_estimate.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/normal_kernel_properties.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_bandwidth.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_parameter_given_max_degree.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/rest_weights_wrapper.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/tag.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/traits.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree_constant.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_properties.hpp
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/zscore.hpp
Text files modified:
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/benchmark.hpp | 25 ++-
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/divider.hpp | 2
   sandbox/improved_fast_gauss_transform/boost/math/ifgt/include.hpp | 41 +++---
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/doc/readme.txt | 228 ++++++++++++++++++---------------------
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.cpp | 22 ++-
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.cpp | 37 +++--
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.cpp | 20 +-
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.cpp | 34 +++--
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.cpp | 26 ++--
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.cpp | 7
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.cpp | 10
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.cpp | 30 ++--
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.cpp | 18 +-
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.cpp | 32 ++---
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.cpp | 27 ++--
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.cpp | 54 ++++----
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.cpp | 67 +++++------
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/main.cpp | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.cpp | 10
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.h | 2
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.cpp | 8
   sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.h | 2
   35 files changed, 361 insertions(+), 369 deletions(-)

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/accumulator_base.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/accumulator_base.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,23 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/accumulator_base.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_ACCUMULATOR_BASE_HPP_ER_2009
-#define BOOST_MATH_IFGT_ACCUMULATOR_BASE_HPP_ER_2009
-
-namespace boost{namespace math{namespace ifgt{
-
- template<typename Derived>
- struct accumulator_base{};
-
- // For now these two are just informative
- template<typename Derived>
- struct exact_accumulator_base : accumulator_base<Derived>{};
-
- template<typename Derived>
- struct fast_accumulator_base : accumulator_base<Derived>{};
-
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/bandwidth/normal_plug_in.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/bandwidth/normal_plug_in.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////////
+// normal_plug_in.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_BANDWIDTH_NORMAL_PLUG_IN_HPP_ER_2009
+#define BOOST_MATH_IFGT_BANDWIDTH_NORMAL_PLUG_IN_HPP_ER_2009
+#include <cmath>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+// \warning the sart(2)*sigma adjustmnent is needed so that
+// the kernel is exp(-||(x-y)/h||^2) = exp(-(1/2)||(x-y)/sigma||^2)
+template<std::size_t Dimension, typename RealType = double>
+struct bandwidth_normal_plug_in{
+ typedef RealType value_type;
+
+ //Minimizes statistical error for density estimation under normality
+ static value_type find(
+ value_type sigma,
+ std::size_t count
+ );
+ ///Assumes sigma = 1;
+ static value_type find(
+ std::size_t count);
+
+};
+
+template<std::size_t Dimension, typename RealType>
+typename bandwidth_normal_plug_in<Dimension,RealType>::value_type
+bandwidth_normal_plug_in<Dimension,RealType>::find(
+ value_type sigma, std::size_t count){
+ static const value_type sqrt2 = sqrt(2.0);
+ static const value_type d = (value_type)(Dimension);
+ static const value_type e = -(value_type)(1)/((value_type)(d+4));
+ value_type n = (value_type)(count);
+ value_type a = (n * (value_type)(2+d))/ ((value_type)(4));
+ return sigma * std::pow( a, e ) * sqrt2;
+}
+
+template<std::size_t Dimension, typename RealType>
+typename bandwidth_normal_plug_in<Dimension,RealType>::value_type
+bandwidth_normal_plug_in<Dimension,RealType>::find(
+std::size_t count){
+ return find(
+ (value_type)(1),
+ count);
+}
+
+}
+}
+}
+#endif

Modified: sandbox/improved_fast_gauss_transform/boost/math/ifgt/benchmark.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/benchmark.hpp (original)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/benchmark.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -17,9 +17,11 @@
 #include <boost/static_assert.hpp>
 #include <boost/assign/std/vector.hpp>
 #include <boost/math/distributions/normal.hpp>
+
 #include <boost/random/mersenne_twister.hpp>
 #include <boost/random/normal_distribution.hpp>
 #include <boost/random/variate_generator.hpp>
+
 #include <boost/ref.hpp>
 #include <boost/function.hpp>
 #include <boost/format.hpp>
@@ -27,7 +29,11 @@
 #include <boost/algorithm/l2_distance_squared.hpp>
 #include <boost/iterator/vector2matrix_iterator.hpp>
 #include <boost/algorithm/l2_norm.hpp>
-#include <boost/math/ifgt/include.hpp>
+#include <boost/math/ifgt/for_each/accumulate.hpp>
+#include <boost/math/ifgt/for_each/nadaraya_watson.hpp>
+#include <boost/math/ifgt/for_each/gauss_transform.hpp>
+#include <boost/math/ifgt/for_each/rozenblatt_parzen.hpp>
+#include <boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp>
 #include <boost/math/ifgt/detail/product_pdf.hpp>
 namespace boost{namespace math{namespace ifgt{
 template<
@@ -148,9 +154,10 @@
         update_w(train_x_,train_w_);
         // accumulate
         timer_.restart();
- ifgt::for_each(
+ //w[1] --> {w[0]=1,w[1]}
+ ifgt::for_each_weight_front_insert_1_accumulate(
             train_x_,
- ifgt::make_rest_weights_wrapper(train_w_),//w[1] --> {w[0]=1,w[1]}
+ train_w_,
             acc
         );
         acc_time_per_1e3_train_count_.push_back(
@@ -162,8 +169,7 @@
     template<typename Eval>
     void estimate_pdf(Eval& eval){//by Rozenblatt--Parzen
         timer_.restart();
- ifgt::for_each(test_x_,est_pdf_,eval,
- ifgt::call<ifgt::rozenblatt_parzen_estimate>());
+ ifgt::for_each_rozenblatt_parzen(test_x_,est_pdf_,eval);
         eval_rp_time_per_1e3_test_count_.push_back(
             timer_.elapsed() * 1e3/test_count
         );
@@ -179,8 +185,7 @@
     template<typename Eval>
     void estimate_w(Eval& eval){//by Nadaraya--Watson
         timer_.restart();
- ifgt::for_each(test_x_,est_w_,eval,
- ifgt::call<ifgt::nadaraya_watson_estimate>());
+ ifgt::for_each_nadaraya_watson(test_x_,est_w_,eval);
         eval_nw_time_per_1e3_test_count_.push_back(
                 timer_.elapsed() * 1e3/test_count
         );
@@ -193,9 +198,9 @@
     }
 
     void notation(std::ostream& os)const{
- os << "M: # evaluated" << std::endl;
- os << "N: # accumulated" << std::endl;
- os << "err0(a,b) = max {|a - b|:m=0,...,M-1 }" << std::endl;
+ os << "M: # evaluated" << std::endl;
+ os << "N: # accumulated" << std::endl;
+ os << "err0(a,b) = max {|a - b|:m=0,...,M-1 }" << std::endl;
         os << "err1(a,b) = sqrt sum {|a - b|^2:m=0,...,M-1 } / M"<< std::endl;
         os << "e0_rp : err0(rp(y), pdf(y)) " << std::endl;
         os << "e1_rp : err1(rp(y), pdf(y)) " << std::endl;

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_gauss_transform.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_gauss_transform.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,38 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/call_gauss_transform.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CALL_GAUSS_TRANSFORM_HPP_ER_2009
-#define BOOST_MATH_IFGT_CALL_GAUSS_TRANSFORM_HPP_ER_2009
-#include <stdexcept>
-#include <boost/math/ifgt/evaluator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- template<typename Evaluator>
- class gauss_transform{
- public:
- typedef Evaluator evaluator_type;
- struct stride_traits{
- typedef mpl::size_t<evaluator_type::source_size> stride0_type;
- typedef mpl::size_t<evaluator_type::weight_size> stride1_type;
- };
- typedef typename evaluator_type::value_type value_type;
- template<typename Common>
- gauss_transform(const evaluator_base<Common,Evaluator>& e)
- :eval_(static_cast<const Evaluator&>(e)){}
- gauss_transform(const gauss_transform& that) : eval_(that.eval){}
-
- template<typename R0,typename R1>
- void operator()(const R0& targets,R1& ranges_out)const{
- eval_.gauss_transform(targets,ranges_out);
- };
-
- private:
- gauss_transform& operator=(const gauss_transform& that);
- const Evaluator& eval_;
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_nadaraya_watson_estimate.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_nadaraya_watson_estimate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,49 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/call_nadaraya_watson_estimate.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CALL_NADARAYA_WATSON_ESTIMATE_HPP_ER_2009
-#define BOOST_MATH_IFGT_CALL_NADARAYA_WATSON_ESTIMATE_HPP_ER_2009
-#include <stdexcept>
-#include <boost/mpl/size_t.hpp>
-#include <boost/math/ifgt/evaluator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename Evaluator>
-class nadaraya_watson_estimate{
- public:
- typedef Evaluator evaluator_type;
- struct stride_traits{
- typedef mpl::size_t<evaluator_type::source_size> stride0_type;
- typedef mpl::size_t<evaluator_type::weight_size-1> stride1_type;
- };
- typedef typename evaluator_type::value_type value_type;
-
- template<typename Common>
- nadaraya_watson_estimate(const evaluator_base<Common,Evaluator>& e)
- :eval_(static_cast<const Evaluator&>(e)){}
- nadaraya_watson_estimate(const nadaraya_watson_estimate& that)
- : eval_(that.eval){}
-
- template<typename R0,typename R1>
- void operator()(const R0& targets,R1 ranges_out)const{
- eval_.nadaraya_watson_estimate(targets,ranges_out);
- };
-
- private:
- nadaraya_watson_estimate& operator=(
- const nadaraya_watson_estimate& that);
- const Evaluator& eval_;
-};
-
-template<typename C,typename E>
-nadaraya_watson_estimate<E>
-make_nadaraya_watson_estimate(const evaluator_base<C,E>& e){
- typedef nadaraya_watson_estimate<E> result_type;
- return result_type(e);
-}
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,44 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/call_rozenblatt_parzen_estimate.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CALL_ROZENBLATT_PARZEN_HPP_ER_2009
-#define BOOST_MATH_IFGT_CALL_ROZENBLATT_PARZEN_HPP_ER_2009
-#include <stdexcept>
-#include <boost/math/ifgt/evaluator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename Evaluator>
-struct rozenblatt_parzen_estimate{
- typedef typename Evaluator::value_type value_type;
- public:
- template<typename Common>
- rozenblatt_parzen_estimate(const evaluator_base<Common,Evaluator>& e)
- :eval_(static_cast<const Evaluator&>(e)){}
-
- rozenblatt_parzen_estimate(
- const rozenblatt_parzen_estimate& that)
- : eval_(that.eval_){}
-
- template<typename R0>
- value_type operator()(const R0& target)const{
- return eval_.rozenblatt_parzen_estimate(target);
- };
-
- private:
- rozenblatt_parzen_estimate& operator=(
- const rozenblatt_parzen_estimate& that);
- const Evaluator& eval_;
-};
-
-template<typename C,typename E>
-rozenblatt_parzen_estimate<E>
-make_rozenblatt_parzen_estimate(const evaluator_base<C,E>& e){
- typedef rozenblatt_parzen_estimate<E> result_type;
- return result_type(e);
-}
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_wrapper.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/call_wrapper.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,19 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/call_wrapper.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CALL_WRAPPER_HPP_ER_2009
-#define BOOST_MATH_IFGT_CALL_WRAPPER_HPP_ER_2009
-#include <boost/mpl/assert.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- /// For use by for_each_evaluator
- template<template<typename> class Method>
- struct call{
- call(){};
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,306 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/cluster.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CLUSTER_HPP_ER_2009
-#define BOOST_MATH_IFGT_CLUSTER_HPP_ER_2009
-#include <algorithm>
-#include <functional>
-#include <iterator>
-#include <vector>
-#include <cmath>
-#include <boost/range.hpp>
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/iterator/zip_iterator.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/algorithm/l2_norm.hpp>
-#include <boost/math/monomials.hpp>
-#include <boost/math/multi_indexes_derived.hpp>
-#include <boost/math/ifgt/zscore.hpp>
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/math/ifgt/coefficients.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/normal_kernel_properties.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- // A cluster is characterized by
- // - A center
- // - A bandwidth
- // - A collection of coefficients (one for each weight sequence)
-
- /// apply<TruncationDegreePolicy,T>::type
- template<
- unsigned SourceSize,
- unsigned WeightSize,
- typename TruncationDegreePolicy
- = truncation_degree_constant<mpl::_1>,
- typename Cont = std::vector<double> >
- class cluster{
- typedef monomials<Cont> monoms_type;
- typedef typename monoms_type::result_type monoms_result_type;
- typedef coefficients<SourceSize,Cont> coeffs_type;
- typedef std::vector<coeffs_type> coll_coeffs_type;
- typedef typename coll_coeffs_type::iterator coll_coeffs_iter_type;
-
- public:
- // C++ Standard (now) allows initialization of const static data
- // members of an integral type inside their class.
- static const std::size_t source_size = SourceSize;
- static const std::size_t weight_size = WeightSize;
- typedef Cont center_type;
- typedef const center_type& result_of_center_type;
- typedef typename monoms_type::value_type value_type;
- typedef coeffs_type coefficients_type;
- typedef coll_coeffs_type collection_coefficients_type;
- typedef const collection_coefficients_type&
- result_of_collection_coefficients_type;
- typedef std::size_t sources_count_type;
- typedef normal_kernel_properties<source_size,value_type> rpp_type;
- typedef typename mpl::apply<TruncationDegreePolicy,value_type>::type
- truncation_degree_policy_type;
-
- template<typename ArgPack>
- cluster(const ArgPack& arg)
- :center_(source_size),
- bandwidth_(arg[tag::bandwidth]),
- max_radius_(arg[tag::max_cluster_radius]),
- truncation_degree_policy_(arg),
- inv_nc_((value_type)(1)/rpp_type::normalizing_constant(bandwidth())),
- source_radius_((value_type)(0)),
- radius_((value_type)(0)),
- sources_count_(0),
- coll_coeffs_(weight_size){
- BOOST_ASSERT(size(arg[tag::center])-source_size==0);
- copy(
- begin(arg[tag::center]),
- end(arg[tag::center]),
- begin(center_)
- );
- }
-
- template<typename R>
- cluster(
- const R& center,
- value_type bandwidth_val,//cannot name it bandiwth coz mf
- value_type max_radius,
- const truncation_degree_policy_type& truncation_degree_policy)
- :center_(source_size),
- bandwidth_(bandwidth_val),
- max_radius_(max_radius),
- truncation_degree_policy_(truncation_degree_policy),
- inv_nc_((value_type)(1)/rpp_type::normalizing_constant(bandwidth())),
- source_radius_((value_type)(0)),
- radius_((value_type)(0)),
- sources_count_(0),
- coll_coeffs_(weight_size){
- BOOST_ASSERT(size(center)-source_size==0);
- copy(
- begin(center),
- end(center),
- begin(center_)
- );
- }
-
- cluster(const cluster& that)
- :center_(that.source_size),
- bandwidth_(that.bandwidth_),
- max_radius_(that.max_radius_),
- truncation_degree_policy_(that.truncation_degree_policy_),
- inv_nc_(that.inv_nc_),
- source_radius_(that.source_radius_),
- radius_(that.radius_),
- sources_count_(that.sources_count_),
- coll_coeffs_(that.coll_coeffs_){
- copy(
- begin(that.center_),
- end(that.center_),
- begin(center_)
- );
- }
-
- cluster& operator=(const cluster& that){
- if(&that!=this){
- center_ = that.center_;
- bandwidth_ = that.bandwidth_;
- max_radius_ = that.max_radius_;
- truncation_degree_policy_ = that.truncation_degree_policy_;
- inv_nc_ = that.inv_nc_;
- source_radius_ = that.source_radius_;
- radius_ = that.radius_;
- sources_count_ = that.sources_count_;
- coll_coeffs_ = that.coll_coeffs_;
- }
- return *this;
- }
-
- result_of_center_type center()const{ return center_; }
- value_type bandwidth()const{ return bandwidth_; }
- /// Maximum allowed cluster radius
- value_type max_radius()const{ return max_radius_; }
-
- value_type inverse_normalizing_constant()const{ return inv_nc_; }
-
- /// Maximum radius among collected sources
- value_type radius()const{ return radius_; }
- /// Number of sources collected
- sources_count_type sources_count()const{ return sources_count_; }
-
- /// Radius of the source in the last argument that was passed
- value_type source_radius()const{ return source_radius_; }
- bool source_radius_is_zero()const{
- return source_radius() == (value_type)(0);
- }
- bool source_radius_exceeds_max_radius()const{
- return (source_radius() > max_radius());
- }
-
- result_of_collection_coefficients_type
- collection_coefficients()const{return coll_coeffs_; }
-
- template<typename R0,typename R1>
- bool operator()(const R0& source, const R1& weight){
- typedef std::vector<unsigned> degrees_type;
- typedef zscore<center_type> zscore_type;
- typedef l2_norm_squared sqnorm_type;
- static degrees_type degrees(weight_size,0);
- //static zscore_type zscore(center());//not safe
- static Cont zscore_val(source_size);
- static sqnorm_type sqnorm;
- zscore_type zscore(center());
- zscore(source,bandwidth(),zscore_val);
-
- value_type zscore_sqnorm = sqnorm(zscore_val);
- source_radius_ = sqrt(zscore_sqnorm) * bandwidth();
- bool do_collect = !(
- source_radius_is_zero()
- || source_radius_exceeds_max_radius() );
-
- if(do_collect){
- truncation_degree_policy_(
- *this, source_radius(), weight, degrees);
- (*this)(zscore_val, zscore_sqnorm, weight, degrees);
- }
- return do_collect;
- }
-
- // TODO check that
- // range_iterator<R2>::type::value_type == unsigned
- /// Returns true if source collected, false otherwise
- template<typename R0,typename R1,typename R2>
- void operator()(
- const R0& zscore_val,
- value_type zscore_sqnorm,
- const R1& weight,
- const R2& degrees
- ){
- typedef range_iterator<R0> ir0_type;
- typedef range_iterator<R1> ir1_type;
- typedef range_iterator<R2> ir2_type;
- typedef typename ir0_type::type iter0_type;
- typedef typename ir1_type::type iter1_type;
- typedef typename ir2_type::type iter2_type;
- typedef typename iter0_type::value_type value0_type;
- typedef typename iter1_type::value_type value1_type;
- typedef typename iter2_type::value_type value2_type;
- BOOST_MPL_ASSERT((is_same<value0_type,value_type>));
- BOOST_MPL_ASSERT((is_same<value1_type,value_type>));
- BOOST_MPL_ASSERT((is_same<value2_type,unsigned>));
- //static Cont zscore_val(source_size);
- static Cont consts(source_size);
- static monomials<Cont> monoms;
- BOOST_ASSERT(size(zscore_val)-source_size==0);
- BOOST_ASSERT(size(weight)-weight_size==0);
- BOOST_ASSERT(size(degrees)-weight_size==0);
- BOOST_ASSERT(zscore_sqnorm!=((value_type)(0)));
-
- unsigned local_max_degree
- = (*std::max_element(
- begin(degrees),
- end(degrees)));
-
- monoms(zscore_val,local_max_degree);
-
- for_each(
- make_zip_iterator(
- make_tuple(
- begin(weight),
- begin(coll_coeffs_),
- begin(degrees)
- )
- ),
- make_zip_iterator(
- make_tuple(
- end(weight),
- end(coll_coeffs_),
- end(degrees)
- )
- ),
- op_factory::make(monoms(),zscore_sqnorm)
- );
-
- radius_
- = (radius()<source_radius())
- ? source_radius() : radius();
-
- ++sources_count_;
- }
- //TODO remove. Necessary for temporary fix in copy constructor
- // of derived classes
- const truncation_degree_policy_type& truncation_degree_policy()const{
- return truncation_degree_policy_;}
-
- private:
- template<typename Mons>
- class op{
- public:
- typedef tuple<
- const value_type&,
- coeffs_type&,
- const unsigned&> argument_type;
- typedef void result_type;
- typedef
- typename range_iterator<const Mons>::type mons_ir_type;
- op(const Mons& mons,value_type zscore_sqnorm)
- :zscore_sqnorm_(zscore_sqnorm),mons_(mons){}
- op(const op& that)
- :zscore_sqnorm_(that.zscore_sqnorm_),mons_(that.mons_){}
-
- void operator()(argument_type t){
- value_type w = t.template get<0>();
- coeffs_type& coeffs = t.template get<1>();
- unsigned degree = t.template get<2>();
- coeffs(zscore_sqnorm_,mons_,w,degree);
- }
- private:
- op& operator=(const op& that);
- value_type zscore_sqnorm_;
- const Mons& mons_;
- };//op
- struct op_factory{
- template<typename Mons>
- static op<Mons> make(const Mons& mons,value_type zscore_sqnorm){
- return op<Mons>(mons,zscore_sqnorm);
- }
- };
- center_type center_;
- value_type bandwidth_;
- value_type max_radius_;
- truncation_degree_policy_type truncation_degree_policy_;
- value_type inv_nc_;
-
- value_type source_radius_;
- value_type radius_;
- sources_count_type sources_count_;
- coll_coeffs_type coll_coeffs_;
- };
-
-
-}}}
-
-
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_call_center.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_call_center.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,21 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/cluster_call_center.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CLUSTER_CALL_CENTER_HPP_ER_2009
-#define BOOST_MATH_IFGT_CLUSTER_CALL_CENTER_HPP_ER_2009
-namespace boost{namespace math{namespace ifgt{
- template<typename Cc>
- struct cluster_call_center{
- typedef typename Cc::center_type center_type;
- typedef const center_type& result_type;
- typedef const Cc& argument_type;
- cluster_call_center(){}
- result_type operator()(argument_type arg)const{
- return arg.center();
- }
- };
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,141 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/cluster_evalutor.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CLUSTER_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_CLUSTER_EVALUATOR_HPP_ER_2009
-#include <stdexcept>
-#include <algorithm>
-#include <boost/range.hpp>
-#include <boost/bind.hpp>
-#include <boost/mpl/assert.hpp>
-#include <boost/mpl/apply.hpp>
-#include <boost/mpl/placeholders.hpp>
-#include <boost/utility.hpp>
-#include <boost/type_traits/remove_cv.hpp>
-#include <boost/type_traits/remove_reference.hpp>
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/utility/dont_care.hpp>
-#include <boost/math/ifgt/coefficients_evaluator.hpp>
-#include <boost/iterator/range_same.hpp>
-
-namespace boost{ namespace math{namespace ifgt{
-
- // cluster_evaluator takes a target and a range_out in its constructor
- // remember that a cluster contains as many coefficients as
- // weight sequences. The job of cluster_evaluator
- // is to apply coefficients_evaluator to each
- // coefficients and *add* the results to range_out
-
- // \warning adds to range_out
- // \warning The cutoff_radius_policy is passed by reference for efficiency
- // R ForwarRange (that of the target)
- // apply<CutoffRadiusPolicy,X>::type
- template<
- typename R,
- typename RangeOut,
- typename CutoffRadiusPolicy>
- class cluster_evaluator{
- public:
- typedef typename range_value<R>::type value_type;
- typedef RangeOut& ref_range_out_type;
- private:
- typedef typename mpl::apply<CutoffRadiusPolicy,value_type>::type
- cutoff_radius_policy_type;
- typedef const cutoff_radius_policy_type&
- cref_cutoff_radius_policy_type;
- public:
- template<typename ArgPack>
- cluster_evaluator(const ArgPack& args)
- :range_out_(args[tag::range_out]),
- coeffs_evaluator_(args[tag::target]),
- cutoff_radius_policy_(args[tag::cutoff_radius_policy]){
- // Do not replace by cutoff_radius_policy_(args)
- }
-
- //TODO remove
- cluster_evaluator(
- const R& target,
- ref_range_out_type range_out,
- cref_cutoff_radius_policy_type cutoff_radius_policy)
- :range_out_(range_out),
- coeffs_evaluator_(target),
- cutoff_radius_policy_(cutoff_radius_policy){}
-
- cluster_evaluator(const cluster_evaluator& that)
- :range_out_(that.range_out_),
- coeffs_evaluator_(that.coeffs_evaluator_),
- cutoff_radius_policy_(that.cutoff_radius_policy_){}
-
- template<typename Cluster>
- void operator()(const Cluster& cluster){
- static range_same policy;
- return this->operator()(cluster, policy);
- }
-
- template<typename Cluster,typename SubsetRangePolicy>
- void operator()(const Cluster& cluster,
- const SubsetRangePolicy& subset_range_policy){
- typedef typename Cluster::coefficients_type coeffs_type;
- typedef SubsetRangePolicy subset_range_policy_type;
- //compile warning:
- //"comparison between signed and unsigned integer expressions|"
- //why? source_size() is also a size_type
- BOOST_ASSERT(
- coeffs_evaluator_.target_size() - size(cluster.center()) == 0 );
-
- value_type cutoff_radius = cutoff_radius_policy_(cluster);
-
- typedef typename
- Cluster::result_of_collection_coefficients_type arg_type;
-
- typedef typename result_of<
- subset_range_policy_type(arg_type)>::type subset_type;
-
- subset_type subset
- = subset_range_policy(cluster.collection_coefficients());
-
- BOOST_ASSERT(size(subset) ==size(range_out_));
-
- typename coeffs_type::result_type (coeffs_type::*f)() const =
- &coeffs_type::operator();
-
- std::transform(
- begin(subset),
- end(subset),
- begin(range_out_),
- begin(range_out_),
- bind(
- std::plus<value_type>(),
- bind(
- ref(coeffs_evaluator_),
- cutoff_radius,
- cref(cluster.center()),
- cluster.bandwidth(),
- cluster.inverse_normalizing_constant(),
- bind(
- f,
- _1
- ),
- bind(
- &coeffs_type::max_degree,
- _1
- )
- ),
- _2
- )
- );
- }
-
- private:
- cluster_evaluator& operator=(const cluster_evaluator& that);
- cluster_evaluator();
- typedef coefficients_evaluator<R> coeffs_evaluator_type;
- ref_range_out_type range_out_;
- coeffs_evaluator_type coeffs_evaluator_;
- cutoff_radius_policy_type cutoff_radius_policy_;
- };
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_radius/at_max_degree.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/cluster_radius/at_max_degree.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,176 @@
+//////////////////////////////////////////////////////////////////////////////
+// at_max_degree.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_OPTIMAL_PARAMETER_GIVEN_MAX_DEGREE_HPP_ER_2009
+#define BOOST_MATH_IFGT_OPTIMAL_PARAMETER_GIVEN_MAX_DEGREE_HPP_ER_2009
+#include <stdexcept>
+#include <boost/math/ifgt/detail/divider.hpp>
+#include <boost/math/ifgt/cutoff_radius/rydg.hpp>
+#include <boost/math/ifgt/cluster_radius/at_max_degree.hpp>
+#include <boost/math/ifgt/truncation_degree/properties.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+
+/// Finds optimal max cluster radius recursively,
+/// given a cutoff radius policy and a maximum degree p.
+// P0 : CutoffRadiusPolicy
+// P1 : UpdatePolicy
+template<
+ typename RealType,
+ template<typename> class P0 = cutoff_radius::rydg, //TODO lambda
+ template<typename> class P1 = divider //TODO lambda
+>
+class cluster_radius_at_max_degree{
+ typedef P0<RealType> p_0_t;
+ typedef P1<RealType> p_1_t;
+ public:
+ typedef RealType value_type;
+ typedef std::size_t size_type;
+ template<typename ArgPack> cluster_radius_at_max_degree(
+ const ArgPack& arg);
+ cluster_radius_at_max_degree(
+ const cluster_radius_at_max_degree& that);
+ cluster_radius_at_max_degree&
+ operator=(const cluster_radius_at_max_degree& that);
+
+ value_type error_tolerance()const{return error_tol_; };
+ unsigned max_degree()const{ return max_degree_; };
+ value_type bandwidth()const{return bandwidth_; };//models ClusterPolicy
+ size_type max_recursions()const{ return max_recursions_; }
+
+ /// Set parameters
+ void operator()(
+ unsigned max_degree,
+ value_type bandwidth,
+ value_type start_cluster_radius_over_bandwidth = 2.0,
+ size_type max_recursions = 20);
+
+ /// Output
+ value_type cutoff_radius()const{ return cutoff_radius_; }
+ //models ClusterPolicy
+ value_type max_radius()const{ return max_cluster_radius_; }
+ value_type error()const { return error_; }
+ size_type recursions()const{ return recursions_; }
+
+ private:
+ void call_impl();
+ value_type error_tol_;
+ p_0_t p_0_;
+ p_1_t p_1_;
+ value_type bandwidth_;
+ unsigned max_degree_;
+ size_type max_recursions_;
+ value_type cutoff_radius_;
+ value_type max_cluster_radius_;
+ value_type error_;
+ size_type recursions_;
+};
+
+template<typename RealType,template<typename> class P0,
+template<typename> class P1>
+template<typename ArgPack>
+cluster_radius_at_max_degree<RealType,P0,
+P1>::cluster_radius_at_max_degree(
+ const ArgPack& arg)
+:error_tol_(arg[kwd<>::error_tolerance]),
+p_0_(arg),
+p_1_(arg),
+bandwidth_(0.0),
+max_degree_(0.0),
+max_recursions_(0),
+cutoff_radius_(0.0),
+max_cluster_radius_(0.0),
+error_(0.0),
+recursions_(0){}
+
+template<typename RealType,template<typename> class P0,
+template<typename> class P1>
+cluster_radius_at_max_degree<RealType,P0,
+P1>::cluster_radius_at_max_degree(
+const cluster_radius_at_max_degree& that)
+:error_tol_(that.error_tol_),
+p_0_(that.p_0_),
+p_1_(that.p_1_),
+bandwidth_(that.bandwidth_),
+max_degree_(that.max_degree_),
+max_recursions_(0),
+cutoff_radius_(that.cutoff_radius_),
+max_cluster_radius_(that.max_cluster_radius_),
+error_(that.error_),
+recursions_(0){}
+
+template<typename RealType, template<typename> class P0,
+template<typename> class P1>
+typename
+cluster_radius_at_max_degree<RealType,P0,
+P1>::cluster_radius_at_max_degree&
+cluster_radius_at_max_degree<RealType,P0,
+P1>::operator=(
+ const cluster_radius_at_max_degree& that){
+ if(&that!=this){
+ error_tol_ = that.error_tol_;
+ p_0_ = that.p_0_;
+ p_1_ = that.p_1_;
+ bandwidth_ = that.bandwidth_;
+ max_degree_ = that.max_degree_;
+ max_recursions_ = that.max_recursions_;
+ cutoff_radius_ = that.cutoff_radius_;
+ max_cluster_radius_ = that.max_cluster_radius_;
+ error_ = that.error_;
+ recursions_ = that.recursions_;
+ }
+ return *this;
+};
+
+template<typename RealType,template<typename> class P0,
+template<typename> class P1>
+void cluster_radius_at_max_degree<RealType,P0,
+P1>::operator()(
+ unsigned max_degree,
+ value_type bandwidth,
+ value_type start_cluster_radius_over_bandwidth,
+ size_type max_recursions ){
+ bandwidth_ = bandwidth;
+ max_degree_ = max_degree;
+ max_recursions_ = max_recursions;
+ recursions_ = 0;
+ max_cluster_radius_ = start_cluster_radius_over_bandwidth
+ /this->bandwidth();
+ call_impl();
+};
+
+template<typename RealType,template<typename> class P0,
+template<typename> class P1>
+void cluster_radius_at_max_degree<RealType,P0,
+P1>::call_impl(){
+ ++recursions_;
+ cutoff_radius_ = p_0_(*this);
+ error_ = truncation_degree::properties::max_error_bound(
+ max_degree(), bandwidth(),
+ max_radius(), cutoff_radius()
+ );
+
+ if(recursions()<max_recursions()){
+ if(error()>error_tolerance()){
+ max_cluster_radius_ = p_1_(max_radius());
+ ++recursions_;
+ call_impl();
+ }
+ }else{
+ std::string str = "cluster_radius_at_max_degree";
+ str += "max number of recursions exceeded";
+ throw std::runtime_error(str);
+ }
+}
+
+
+}//ifgt
+}//math
+}//boost
+
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/clusters_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/clusters_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,89 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/clusters_evaluator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CLUSTERS_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_CLUSTERS_EVALUATOR_HPP_ER_2009
-#include <algorithm>
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/range.hpp>
-#include <boost/math/ifgt/cluster_evaluator.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- // Adds to a range the result from evaluating each cluster
- template<
- typename RealType,
- typename CutoffRadiusPolicy
- >
- class clusters_evaluator{
- public:
- typedef RealType value_type;
- typedef typename mpl::apply<CutoffRadiusPolicy,value_type>::type
- cluster_radius_policy_type;
- template<typename ArgPack>
- clusters_evaluator(const ArgPack& args):cluster_radius_policy_(args){}
-
- // make sure policy's default constructor is disabled
- // if necessary
- // so that compile error here
- clusters_evaluator(){}
-
- clusters_evaluator(const cluster_radius_policy_type&
- cluster_radius_policy)
- : cluster_radius_policy_(cluster_radius_policy){}
- clusters_evaluator(const clusters_evaluator& that)
- :cluster_radius_policy_(that.cluster_radius_policy_){}
-
- clusters_evaluator& operator=(const clusters_evaluator& that){
- if(&that!=this){
- cluster_radius_policy_ = that.cluster_radius_policy_;
- }
- return *this;
- }
-
- template<typename R0,typename R1,typename R2>
- void operator()(
- const R0& target,const R1& clusters,R2& range_out)const{
- static range_same policy;
- return this->operator()(
- target, clusters, range_out, policy
- );
- }
-
- //\warning adds to range_out
- template<typename R0,typename R1,typename R2,
- typename SubsetRangePolicy>
- void operator()(
- const R0& target,const R1& clusters,R2& range_out,
- const SubsetRangePolicy& subset_range_policy)const{
- typedef typename range_value<R0>::type value0_type;
- typedef typename range_value<R1>::type cluster_type;
- typedef typename cluster_type::value_type value1_type;
- typedef typename range_value<R2>::type value2_type;
- BOOST_MPL_ASSERT((is_same<value0_type,value_type>));
- BOOST_MPL_ASSERT((is_same<value1_type,value_type>));
- BOOST_MPL_ASSERT((is_same<value2_type,value_type>));
- typedef cluster_evaluator<R0,R2,CutoffRadiusPolicy> eval_type;
-
- eval_type eval(target, range_out, cluster_radius_policy_);
-
- for_each(
- begin(clusters),
- end(clusters),
- bind<void>(
- ref(eval),//not cref because eval modifies range_out
- _1,
- cref(subset_range_policy)
- )
- );
- };
-
- private:
- cluster_radius_policy_type cluster_radius_policy_;
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,150 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/coefficients.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_SOURCE_COEFFICIENTS_HPP_ER_2009
-#define BOOST_MATH_IFGT_SOURCE_COEFFICIENTS_HPP_ER_2009
-#include <algorithm>
-#include <functional>
-#include <iterator>
-#include <vector>
-#include <cmath>
-#include <boost/range.hpp>
-#include <boost/range/value_type.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/iterator/zip_iterator.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/math/monomials.hpp>
-#include <boost/math/multi_indexes_derived.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- // coefficients keeps a set of coefficients and a max_degree
- // Each time (zsqn, monoms, w,p) is passed to the object,
- // the coefficients {C_\alpha:\alpha_0+...+\alpha_{SourceSz-1}<=p}
- // are updated.
- // Specifically,
- // C_{\alpha} +=
- // 2^{\alpha}/\alpha! * w exp(-zsqn ) * z^alpha
- // The z^alpha's are the elements in monoms
- // zsqn represents || z ||_2^2
- //
- // The reason for this set up (zsqn and monoms passed to the object)
- // is that this operation may be repeated
- // for different weight sequences (one coefficients for each).
-
- template<unsigned SourceSz,typename Cont = std::vector<double> >
- class coefficients{
- typedef typename Cont::value_type value_type;
- typedef multi_indexes_derived<SourceSz,multi_power2divfact_op>
- mult_p2df;
- typedef typename mult_p2df::iter_range_type p2df_ir_type;
- typedef
- typename range_iterator<p2df_ir_type>::type p2df_iter_type;
- typedef
- typename range_value<p2df_ir_type>::type p2df_value_type;
- public:
- typedef Cont coefficients_type;
- typedef const coefficients_type& result_type;
-
- coefficients():max_degree_(0){}
- coefficients(const coefficients& that)
- :max_degree_(that.max_degree_),coeffs_(that.coeffs_){}
- coefficients& operator=(const coefficients& that){
- if(&that!=this){
- max_degree_ = that.max_degree_;
- coeffs_ = that.coeffs_;
- }
- return *this;
- }
-
- unsigned max_degree()const{ return max_degree_; }
-
- result_type operator()()const{ return coeffs_; }
-
- template<typename R>
- void operator()(
- value_type zscore_sqnorm,
- const R& monomials,
- value_type weight,
- unsigned degree
- ){
- typedef typename range_iterator<const R>::type monoms_iter_type;
- typedef typename range_value<R>::type monoms_value_type;
-
- value_type c = exp(-zscore_sqnorm) * weight;
- p2df_ir_type p2df_ir = mult_p2df::get(degree);
- std::size_t adv_by
- = monomials_properties<>::number_degree_less_than(
- degree,SourceSz);
- if(adv_by>((std::size_t)(size(coeffs_)))){
- coeffs_.resize(adv_by,(value_type)(0));
- }
-
- BOOST_ASSERT( adv_by <= ((std::size_t)(size(monomials))) );
- BOOST_ASSERT( adv_by <= ((std::size_t)(size(p2df_ir))) );
- monoms_iter_type m_e = begin(monomials);
- p2df_iter_type p2df_e =
- begin(p2df_ir);
- std::advance(m_e,adv_by);
- std::advance(p2df_e,adv_by);
-
- inner_op<monoms_value_type> io(c);
-
- transform(
- make_zip_iterator(
- make_tuple(
- begin(monomials),
- begin(p2df_ir)
- )
- ),
- make_zip_iterator(
- make_tuple(
- m_e,
- p2df_e
- )
- ),
- begin(coeffs_),
- begin(coeffs_),
- bind(
- std::plus<value_type>(),
- bind(
- io,//ref?
- _1
- ),
- _2
- )
- );
-
- if(max_degree()<degree){max_degree_ = degree;}
- }
-
- private:
- template<typename V>
- struct inner_op{
- typedef tuple<
- const V&,const p2df_value_type&> argument_type;
-
- typedef V result_type;
- explicit inner_op(result_type c_):c(c_){}
- inner_op(const inner_op& that):c(that.c){}
- inner_op& operator=(const inner_op& that){
- if(&that!=this){ c=that.c;}
- return *this;}
- result_type operator()(argument_type t){
- const V& mon = t.template get<0>();
- const p2df_value_type& p2df = t.template get<1>();
-
- return mon * ((result_type)(p2df)) * c;
- }
- result_type c;
- };//inner_op
-
- unsigned max_degree_;
- coefficients_type coeffs_;
- };
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/coefficients_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,154 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/coefficients_evaluator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_COLLECTED_SOURCES_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_COLLECTED_SOURCES_EVALUATOR_HPP_ER_2009
-#include <vector>
-#include <functional>
-#include <iterator>
-#include <cmath>
-#include <numeric>
-#include <stdexcept>
-#include <iostream> //TODO remove
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/range.hpp>
-#include <boost/math/ifgt/zscore.hpp>
-#include <boost/math/monomials_properties.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- // coefficients_evaluator keeps a ref to a target
- // each time a (coefficients,center,bandwidth) is passed to it,
- // it returns the gauss transform, if the target
- // is within a cutoff radius, 0 otherwise
- //
- // This class is primarly intended for use within clusters_evaluator.hpp
-
- /// R0 ForwardRange (that of the target)
- template<typename R0>
- class coefficients_evaluator{
-
- typedef typename range_value<R0>::type value_type;
- typedef std::vector<value_type> vec_type;
- typedef typename range_size<R0>::type target_size_type;
- public:
- typedef value_type result_type;
- coefficients_evaluator(const R0& target):target_(target){}
-
- coefficients_evaluator(const coefficients_evaluator& that)
- :target_(that.target_){}
-
- const R0& target()const{return target_; }
- target_size_type target_size()const{return size(target()); }
-
- template<typename R1,typename Coeffs>
- result_type operator()(
- result_type cutoff_radius,
- const R1& center,
- result_type bandwidth,
- result_type inv_nc,
- const Coeffs& coeffs
- ){
- return (*this)(
- cutoff_radius,
- center,
- bandwidth,
- inv_nc,
- coeffs(),
- coeffs.max_degree()
- );
- }
-
- template<typename R1,typename R2>
- result_type operator()(
- //ignore target if dist to center less than:
- result_type cutoff_radius,
- const R1& center,
- result_type bandwidth,
- result_type inv_nc,
- const R2& coefficients,
- unsigned degree
- )const{
- typedef typename range_value<R0>::type value0_type;
- typedef typename range_value<R1>::type value1_type;
- typedef typename range_value<R2>::type value2_type;
- //TODO check that value0_type == ValueType, likewise 1,2
- BOOST_MPL_ASSERT((is_same<value_type,value1_type>));
- BOOST_MPL_ASSERT((is_same<value_type,value2_type>));
- BOOST_ASSERT((target_size_type)(size(center))==target_size());
- {
- unsigned n = monomials_properties<>::number_degree_less_than(
- degree,(unsigned)(target_size())
- );
- BOOST_ASSERT((size(coefficients)-n>=0)||(degree == 0));
- }
-
- result_type res = (result_type)(0);
- if(degree>0){
-
- static vec_type zscore_val(target_size());
- static monomials<vec_type> monoms;
- typedef zscore<vec_type> zscore_type;
- {
- zscore_type zscore(center);
- zscore(target(),bandwidth,zscore_val);
- }
-
- result_type zscore_sqnorm = std::inner_product(
- begin(zscore_val),
- end(zscore_val),
- begin(zscore_val),
- (result_type)(0)
- );
-
- //TODO rename target_radius
- result_type sq_d = zscore_sqnorm * (bandwidth * bandwidth);
-
- // (sq_d<cutoff_radius * cutoff_radius) should suffice
- // but (sq_d<cutoff_radius) necessary in case the client
- // (usually cluster_evaluator) returns
- // cutoff_radius = highest()
- if( (sq_d<cutoff_radius)
- || (sq_d<cutoff_radius * cutoff_radius) ){
- result_type gauss_kernel
- = inv_nc * exp(-zscore_sqnorm);
- monoms(zscore_val,degree);
- res = std::inner_product(
- begin(coefficients),
- end(coefficients),
- begin(monoms()),
- (result_type)(0),
- std::plus<result_type>(),
- bind(
- std::multiplies<result_type>(),
- gauss_kernel,
- bind(
- std::multiplies<result_type>(),
- _1,
- _2
- )
- )
- );
- }
- }
- return res;
- }
- private:
- coefficients_evaluator& operator=(
- const coefficients_evaluator& that);
- const R0& target_;
- };
-
- template<typename R0>
- coefficients_evaluator<R0>
- make_coefficients_evaluator(const R0& target){
- return coefficients_evaluator<R0>(target);
- }
-
-}}}
-
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/accumulator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/accumulator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+// accumulator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CRTP_ACCUMULATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_CRTP_ACCUMULATOR_HPP_ER_2009
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace crtp{
+
+ template<typename Derived>
+ struct accumulator{};
+
+
+}
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/crtp/evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+// evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CRTP_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_CRTP_EVALUATOR_HPP_ER_2009
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace crtp{
+
+ template<typename Derived>
+ struct evaluator{};
+
+}
+}
+}
+}
+
+#endif // EVALUATOR_HPP_INCLUDED

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/none.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/none.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+// none.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CUTOFF_RADIUS_NONE_HPP_ER_2009
+#define BOOST_MATH_IFGT_CUTOFF_RADIUS_NONE_HPP_ER_2009
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/limits.hpp>
+#include <boost/utility/dont_care.hpp>
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace cutoff_radius{
+ // Models CutoffRadiusPolicy
+ // This policy imposes no cutoff radius i.e. all clusters are used
+ // \warning the cutoff squared may be nan
+ template<typename RealType>
+ struct none{
+ typedef RealType result_type;
+ // TODO what for?
+ typedef RealType first_argument_type;
+ typedef RealType second_argument_type;
+ none(utility::dont_care){}
+ none(){}
+ template<typename Cluster>
+ result_type operator()(const Cluster& cluster)const{
+ static const result_type res
+ = numeric::bounds<result_type>::highest();
+ return res;
+ }
+ };
+
+}
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/rydg.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius/rydg.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,90 @@
+//////////////////////////////////////////////////////////////////////////////
+// rydg.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CUTOFF_RADIUS_RYDG_HPP_ER_2009
+#define BOOST_MATH_IFGT_CUTOFF_RADIUS_RYDG_HPP_ER_2009
+#include <cmath>
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace cutoff_radius{
+
+ // Models CutoffRadiusPolicy
+ // Raykar2006a stands for Raykar et al. See Section 4.1:
+ // Automatically choosing the cut off radius for each cluster
+ template<typename RealType>
+ class rydg{
+ public:
+ typedef RealType result_type;
+ // TODO what for?
+ typedef RealType first_argument_type;
+ typedef RealType second_argument_type;
+ private:
+ static result_type default_max_distance_source_target(){
+ static const result_type r
+ = numeric::bounds<result_type>::highest();
+ return r;
+ }
+ public:
+
+ /// Suggestion: error_tolerance be in relation to the standard dev
+ /// of weight, sigma. Say sigma/1e3.
+ template<typename ArgPack>
+ rydg(const ArgPack& args)
+ :error_tol_(args[kwd<>::error_tolerance]),
+ max_dist_source_target_(
+ args[kwd<>::max_distance_source_target
+ |default_max_distance_source_target()]){}
+
+ rydg(
+ result_type error_tol,
+ result_type max_dist_source_target
+ ):error_tol_(error_tol),
+ max_dist_source_target_(max_dist_source_target){}
+
+ // default copy/assignement should work
+
+ /// epsilon (Raykar2006a)
+ result_type error_tolerance()const{ return error_tol_; }
+ /// R in Raykar2006a
+ result_type max_distance_source_target()const{
+ return max_dist_source_target_; }
+
+ /// Returns r_y^k (Raykar2006a)
+ template<typename Cluster>
+ result_type operator()(const Cluster& cluster)const{
+ return
+ this->operator()(cluster.bandwidth(),cluster.max_radius());
+ }
+
+ private:
+ /// Arguments: h and r_x^k (Raykar2006a)
+ result_type operator()(
+ result_type bandwidth,
+ result_type max_radius
+ )const{
+ static result_type c
+ = sqrt(log((result_type)(1)/error_tolerance()));
+
+ result_type a = max_distance_source_target();
+ result_type b = bandwidth * c;
+ result_type d = (a<b)? a : b;
+
+ return max_radius + d;
+ }
+ rydg();//dont implement
+ result_type error_tol_;
+ result_type max_dist_source_target_;
+ };
+
+}//cutoff_radius
+}//ifgt
+}//math
+}//boost
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_none.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_none.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,32 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/cutoff_radius_non.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CUTOFF_RADIUS_NONE_HPP_ER_2009
-#define BOOST_MATH_IFGT_CUTOFF_RADIUS_NONE_HPP_ER_2009
-#include <boost/numeric/conversion/bounds.hpp>
-#include <boost/limits.hpp>
-#include <boost/utility/dont_care.hpp>
-
-namespace boost{namespace math{namespace ifgt{
- // Models CutoffRadiusPolicy
- // This policy imposes no cutoff radius i.e. all clusters are used
- // \warning the cutoff squared may be nan
- template<typename RealType>
- struct cutoff_radius_none{
- typedef RealType result_type;
- typedef RealType first_argument_type;
- typedef RealType second_argument_type;
- cutoff_radius_none(utility::dont_care){}
- cutoff_radius_none(){}
- template<typename Cluster>
- result_type operator()(const Cluster& cluster)const{
- static const result_type res
- = numeric::bounds<result_type>::highest();
- return res;
- }
- };
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_rydg.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/cutoff_radius_rydg.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,82 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/cutoff_radius_rydg.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_CUTOFF_RADIUS_RYDG_HPP_ER_2009
-#define BOOST_MATH_IFGT_CUTOFF_RADIUS_RYDG_HPP_ER_2009
-#include <cmath>
-#include <boost/numeric/conversion/bounds.hpp>
-
-namespace boost{namespace math{namespace ifgt{
-
- // Models CutoffRadiusPolicy
- // Raykar2006a stands for Raykar et al. See Section 4.1:
- // Automatically choosing the cut off radius for each cluster
- template<typename RealType>
- class cutoff_radius_rydg{
- public:
- typedef RealType result_type;
- typedef RealType first_argument_type;
- typedef RealType second_argument_type;
- private:
- static result_type default_max_distance_source_target(){
- static const result_type r
- = numeric::bounds<result_type>::highest();
- return r;
- }
- public:
-
- /// Suggestion: error_tolerance be in relation to the standard dev
- /// of weight, sigma. Say sigma/1e3.
- template<typename ArgPack>
- cutoff_radius_rydg(const ArgPack& args)
- :error_tol_(args[tag::error_tolerance]),
- max_dist_source_target_(
- args[tag::max_distance_source_target
- |default_max_distance_source_target()]){}
-
- cutoff_radius_rydg(
- result_type error_tol,
- result_type max_dist_source_target
- ):error_tol_(error_tol),
- max_dist_source_target_(max_dist_source_target){}
-
- // default copy/assignement should work
-
- /// epsilon (Raykar2006a)
- result_type error_tolerance()const{ return error_tol_; }
- /// R in Raykar2006a
- result_type max_distance_source_target()const{
- return max_dist_source_target_; }
-
- /// Returns r_y^k (Raykar2006a)
- template<typename Cluster>
- result_type operator()(const Cluster& cluster)const{
- return
- this->operator()(cluster.bandwidth(),cluster.max_radius());
- }
-
- private:
- /// Arguments: h and r_x^k (Raykar2006a)
- result_type operator()(
- result_type bandwidth,
- result_type max_radius
- )const{
- static result_type c
- = sqrt(log((result_type)(1)/error_tolerance()));
-
- result_type a = max_distance_source_target();
- result_type b = bandwidth * c;
- result_type d = (a<b)? a : b;
-
- return max_radius + d;
- }
- cutoff_radius_rydg();//dont implement
- result_type error_tol_;
- result_type max_dist_source_target_;
- };
-
-}}}
-#endif

Modified: sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/divider.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/divider.hpp (original)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/divider.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -13,7 +13,7 @@
         public:
         typedef RealType value_type;
         template<typename ArgPack>
- divider(const ArgPack arg):x_(arg[tag::divide_by|(value_type)(2)]){}
+ divider(const ArgPack arg):x_(arg[kwd<>::divide_by|(value_type)(2)]){}
         divider(const divider& that):x_(that.x_){}
         divider& operator=(const divider& that){
             if(&that!=this){

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/evaluator_common.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/evaluator_common.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+// evaluator_common.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_EVALUATOR_COMMON_HPP_ER_2009
+#define BOOST_MATH_IFGT_EVALUATOR_COMMON_HPP_ER_2009
+#include <boost/math/ifgt/keyword.hpp>
+namespace boost{namespace math{namespace ifgt{
+
+template<typename Accumulator>
+class evaluator_common{
+ public:
+ typedef Accumulator accumulator_type;
+ typedef typename accumulator_type::value_type value_type;
+ typedef typename accumulator_type::sources_count_type
+ sources_count_type;
+ typedef const accumulator_type& result_of_accumulator_type;
+
+ static const std::size_t source_size = accumulator_type::source_size;
+ static const std::size_t weight_size = accumulator_type::weight_size;
+
+ template<typename ArgPack>
+ evaluator_common(const ArgPack& arg):acc_(arg[kwd<>::accumulator]){}
+
+ evaluator_common(const evaluator_common& that):acc_(that.acc_){}
+
+ sources_count_type sources_count()const{
+ return this->acc_.sources_count(); }
+ result_of_accumulator_type accumulator()const{ return this->acc_; }
+ private:
+ evaluator_common& operator=(const evaluator_common& that);
+ evaluator_common();
+ const accumulator_type& acc_;
+};
+
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/normal_kernel_properties.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/normal_kernel_properties.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////
+// normal_kernel_properties.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_NORMAL_KERNEL_PROPERTIES_HPP_ER_2009
+#define BOOST_MATH_IFGT_NORMAL_KERNEL_PROPERTIES_HPP_ER_2009
+#include <cmath>
+namespace boost{namespace math{namespace ifgt{
+ // Normal kernel : exp(-(1/2)||(x-y)/sigma||^2) (2*pi*sigma^2)^(-d/2)
+ // Note that the bandwidth is h = sqrt(2) * sigma
+ template<unsigned SourceSz,typename RealType = double>
+ struct normal_kernel_properties{
+ typedef RealType value_type;
+ static const std::size_t source_size = SourceSz;
+ static value_type
+ pi(){
+ static value_type
+ val = 3.14159265358979323846264338327950288419716939937510;
+ return val;
+ }
+ static value_type normalizing_constant(
+ value_type sigma
+ ){
+ static value_type d = (value_type)(SourceSz);
+ static value_type sqrt2pi = sqrt((value_type)(2)*pi());
+ return std::pow(sigma*sqrt2pi,d);
+ }
+ static value_type normalizing_constant(
+ value_type sigma,
+ std::size_t n
+ ){
+ return (value_type)(n) * normalizing_constant(sigma);
+ }
+ };
+
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/zscore.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/detail/zscore.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+// zscore.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_ZSCORE_HPP_ER_2009
+#define BOOST_MATH_ZSCORE_HPP_ER_2009
+#include <algorithm>
+#include <functional>
+#include <stdexcept>
+#include <boost/range.hpp>
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+namespace boost{namespace math{
+
+ /// Maps x,y,h to (x-y)/h
+ template<typename R0>
+ class zscore{
+ typedef typename range_iterator<R0>::type iter_type;
+ public:
+ typedef typename iter_type::value_type value_type;
+ zscore(const R0& center_):center(center_){}
+ zscore(const zscore& that):center(that.zscore){}
+
+ template<typename R1,typename RealType>
+ void operator()(const R1& source,RealType bandwidth,R0& out){
+ BOOST_ASSERT(size(source)==size(center));
+
+ std::transform(
+ begin(source),
+ end(source),
+ begin(center),
+ begin(out),
+ bind(
+ std::divides<value_type>(),
+ bind(
+ std::minus<value_type>(),
+ _1,
+ _2
+ ),
+ (value_type)(bandwidth)
+ )
+ );
+ }
+ private:
+ zscore& operator=(const zscore& that);
+ zscore();
+ const R0& center;
+ };
+
+ template<typename R0>
+ zscore<R0> make_zscore(const R0& center){return zscore<R0>(center);}
+}}
+
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_base.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_base.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,149 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/evaluator_base.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EVALUATOR_BASE_HPP_ER_2009
-#define BOOST_MATH_IFGT_EVALUATOR_BASE_HPP_ER_2009
-#include <functional>
-#include <cmath>
-#include <vector>
-#include <algorithm>
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/utility.hpp>
-#include <boost/iterator/range_left.hpp>
-#include <boost/iterator/range_right.hpp>
-#include <boost/iterator/range_same.hpp>
-#include <boost/math/ifgt/tag.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename Common,typename Derived>
-class evaluator_base : public Common{
- typedef Common common_type;
-
- public:
- typedef typename Common::value_type value_type;
- static const std::size_t weight_size = Common::weight_size;
-
- static const value_type default_nadaraya_watson_check_tolerance(){
- static value_type val = 1e-15;
- return val; };
-
- template<typename ArgPack>
- evaluator_base(const ArgPack& arg)
- :common_type(arg),
- nadaraya_watson_check_tolerance_(arg[
- tag::nadaraya_watson_check_tolerance
- |default_nadaraya_watson_check_tolerance()]){}
-
- evaluator_base(const evaluator_base& that)
- :common_type(that),nadaraya_watson_check_tolerance_(
- that.nadaraya_watson_check_tolerance_){};
-
- evaluator_base& operator=(const evaluator_base& that){
- if(&that!=this){
- common_type::operator=(that);
- nadaraya_watson_check_tolerance_
- = that.nadaraya_watson_check_tolerance_;
- }
- return *this;
- }
-
- /// \warning adds to range_out
- template<typename R0,typename R1>
- void gauss_transform(const R0& target,R1& range_out)const{
- static range_same policy;
- return this->gauss_transform(target,range_out,policy);
- };
-
- /// \warning adds to range_out
- template<typename R0,typename R1,typename SubsetRangePolicy>
- void gauss_transform(
- const R0& target,
- R1& range_out,
- const SubsetRangePolicy& policy
- )const{
- const Derived& self = static_cast<const Derived&>(*this);
- return self.call_impl(target,range_out,policy);
- };
-
- template<typename R0>
- value_type rozenblatt_parzen_estimate(const R0& target)const{
- typedef std::vector<value_type> range_type;
- typedef range_left<1> policy_type;
- static range_type range(1);
- static policy_type policy;
- range[0] = (value_type)(0);
- this->gauss_transform(target,range,policy);
- value_type count = (value_type)(this->sources_count());
- range[0]/=count;
- return range[0];
- };
-
- /// Requires weight[0]==1
- /// Initializes range_out to zero and writes NW to it
- template<typename R0,typename R1>
- void nadaraya_watson_estimate(
- const R0& target,R1& range_out)const{
- typedef std::vector<value_type> range_type;
- typedef range_right<weight_size-1> policy_type;
- typedef typename result_of<policy_type(const range_type&)>::type
- range_right_type;
- static range_type range(weight_size);
- static policy_type policy;
- BOOST_ASSERT(size(range_out)-(weight_size-1)==0);
- std::fill(
- begin(range),
- end(range),
- (value_type)(0)
- );
- this->gauss_transform(target,range);
- value_type denom = range[0];
-
- range_right_type range_right = policy(range);
- BOOST_ASSERT(size(range_right)-(weight_size-1)==0);
- std::transform(
- begin(range_right), end(range_right),
- begin(range_out),
- bind(std::divides<value_type>(), _1, denom)
- );
- };
-
- /// Writes rozenblatt_parzen to range_out[0]
- /// and NW to {range_out[j]:j=1,...,J-1}
- /// Less practical but more efficient than each separately.
- template<typename R0,typename R1>
- void rozenblatt_parzen_and_nadaraya_watson_estimate(
- const R0& target,R1& range_out)const{
- typedef std::vector<value_type> range_type;
- typedef range_right<weight_size-1> policy_type;
- typedef typename range_iterator<R1>::type iter1_type;
- typedef typename result_of<policy_type(const range_type&)>::type
- range_right_type;
- static range_type range(weight_size);
- static policy_type policy;
- std::fill(begin(range),end(range),(value_type)(0));
- this->gauss_transform(target,range);
- BOOST_ASSERT(size(range_out)-weight_size==0);
- value_type denom = range[0];
- value_type count = (value_type)(this->sources_count());;
- iter1_type iter1 = begin(range_out);
- (*iter1) = denom / count;
- std::advance(iter1,1);
- range_right_type range_right = policy(range);
- std::transform(
- begin(range_right), end(range_right), iter1,
- bind(std::divides<value_type>(), _1, denom)
- );
- };
-
- private:
- evaluator_base();
- value_type nadaraya_watson_check_tolerance_;
-
-};
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_common.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/evaluator_common.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,39 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/evaluator_common.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EVALUATOR_COMMON_HPP_ER_2009
-#define BOOST_MATH_IFGT_EVALUATOR_COMMON_HPP_ER_2009
-#include <boost/math/ifgt/tag.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename Accumulator>
-class evaluator_common{
- public:
- typedef Accumulator accumulator_type;
- typedef typename accumulator_type::value_type value_type;
- typedef typename accumulator_type::sources_count_type
- sources_count_type;
- typedef const accumulator_type& result_of_accumulator_type;
-
- static const std::size_t source_size = accumulator_type::source_size;
- static const std::size_t weight_size = accumulator_type::weight_size;
-
- template<typename ArgPack>
- evaluator_common(const ArgPack& arg):acc_(arg[tag::accumulator]){}
-
- evaluator_common(const evaluator_common& that):acc_(that.acc_){}
-
- sources_count_type sources_count()const{
- return this->acc_.sources_count(); }
- result_of_accumulator_type accumulator()const{ return this->acc_; }
- private:
- evaluator_common& operator=(const evaluator_common& that);
- evaluator_common();
- const accumulator_type& acc_;
-};
-
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/accumulator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/accumulator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,150 @@
+//////////////////////////////////////////////////////////////////////////////
+// accumulator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_EXACT_ACCUMULATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_EXACT_ACCUMULATOR_HPP_ER_2009
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <iterator>
+#include <vector>
+#include <cmath>
+#include <boost/range.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/iterator/zip_iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/crtp/accumulator.hpp>
+#include <boost/math/ifgt/exact/detail/contribution.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace exact{
+
+ template<
+ unsigned SourceSz,
+ unsigned WeightSize,
+ typename Cont = std::vector<double> >
+ class accumulator
+ : public crtp::accumulator<
+ accumulator<SourceSz,WeightSize,Cont>
+ >{
+ public:
+ typedef exact::contribution<SourceSz,WeightSize,Cont>
+ contribution_type;
+ typedef std::vector<contribution_type> contributions_type;
+ typedef typename contribution_type::value_type value_type;
+ typedef typename contributions_type::size_type size_type;
+ static const std::size_t source_size = SourceSz;
+ static const std::size_t weight_size = WeightSize;
+ typedef size_type sources_count_type;
+ typedef const contributions_type& cref_contributions_type;
+
+ accumulator(value_type bandwidth);
+ template<typename ArgPack> accumulator(const ArgPack& arg);
+ accumulator(const accumulator&);
+ accumulator& operator=(const accumulator&);
+
+ // Access
+ value_type active_bandwidth()const; //>models Accumulator
+ cref_contributions_type contributions()const;
+ sources_count_type sources_count()const;
+
+ // Update
+ void set(value_type bandwidth);
+
+ // Primarily intended for use internally
+ template<typename R0,typename R1>
+ void push_back_contribution(
+ const R0& source, const R1& weight,value_type bandwidth);
+
+ /// models Accumulator
+ template<typename R0,typename R1>
+ void operator()(const R0& source, const R1& weight);
+
+ private:
+ accumulator();//dont implem
+ static size_type default_contributions_reserve_size(){
+ static size_type sz = 1e4; return sz; }
+ value_type bandwidth_;
+ contributions_type contributions_;
+ };
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ accumulator<SourceSz,WeightSize, Cont>::accumulator(
+ value_type bandwidth):bandwidth_(bandwidth),contributions_(){
+ contributions_.reserve(default_contributions_reserve_size());
+ }
+
+ //TODO replace unsigned SourceSz by std::size_t SourceSz
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ template<typename ArgPack>
+ accumulator<SourceSz,WeightSize, Cont>::accumulator(
+ const ArgPack& arg):bandwidth_(arg[kwd<>::bandwidth]),
+ contributions_(){
+ contributions_.reserve(arg[kwd<>::contributions_reserve_size|
+ default_contributions_reserve_size()]);
+ }
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ accumulator<SourceSz,WeightSize, Cont>::accumulator(
+ const accumulator& that):bandwidth_(that.bandwidth_),
+ contributions_(that.contributions_){}
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ typename accumulator<SourceSz,WeightSize, Cont>::accumulator&
+ accumulator<SourceSz,WeightSize, Cont>::operator=(
+ const accumulator& that){
+ if(&that!=this){
+ bandwidth_ = that.bandwidth_;
+ contributions_ = that.contributions_; }
+ return *this; }
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ typename accumulator<SourceSz,WeightSize, Cont>::value_type
+ accumulator<SourceSz,WeightSize, Cont>::active_bandwidth()const{
+ return bandwidth_; };
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ typename
+ accumulator<SourceSz,WeightSize, Cont>::cref_contributions_type
+ accumulator<SourceSz,WeightSize, Cont>::contributions()const{
+ return contributions_; };
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ typename accumulator<SourceSz,WeightSize, Cont>::sources_count_type
+ accumulator<SourceSz,WeightSize, Cont>::sources_count()const{
+ return contributions_.size();
+ }
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ void accumulator<SourceSz,WeightSize, Cont>::set(
+ value_type bandwidth){ bandwidth_ = bandwidth; };
+
+ template<unsigned SourceSz, unsigned WeightSize, typename Cont>
+ template<typename R0,typename R1>
+ void accumulator<SourceSz,WeightSize, Cont>
+ ::push_back_contribution(
+ const R0& source,
+ const R1& weight,
+ value_type bandwidth){
+ contributions_.push_back(
+ contribution_type(source,weight,bandwidth)
+ );
+ }
+
+ template<unsigned SourceSz,unsigned WeightSize, typename Cont>
+ template<typename R0,typename R1>
+ void accumulator<SourceSz,WeightSize, Cont>::operator()(
+ const R0& source, const R1& weight){
+ push_back_contribution(source,weight,active_bandwidth()); }
+
+}//exact
+}//ifgt
+}//math
+}//boost
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contribution.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contribution.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,164 @@
+//////////////////////////////////////////////////////////////////////////////
+// contribution.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_EXACT_CONTRIBUTION_HPP_ER_2009
+#define BOOST_MATH_IFGT_EXACT_CONTRIBUTION_HPP_ER_2009
+#include <algorithm>
+#include <functional>
+#include <numeric>
+#include <cmath>
+#include <stdexcept>
+#include <boost/range.hpp>
+#include <boost/assert.hpp>
+#include <boost/utility.hpp>
+#include <boost/algorithm/l2_distance_squared.hpp>
+#include <boost/math/ifgt//detail/normal_kernel_properties.hpp>
+#include <boost/iterator/range_same.hpp>
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace exact{
+
+ // A source, weight, and bandwidth
+ // and associated operations.
+ template<
+ unsigned SourceSz,
+ unsigned WeightSz,
+ typename Cont = std::vector<double> > //TODO add cutoff radius policy
+ class contribution{
+ public:
+ typedef typename Cont::value_type value_type;
+ typedef Cont source_type;
+ typedef Cont weight_type;
+ static const std::size_t source_size = SourceSz;
+ static const std::size_t weight_size = WeightSz;
+ template<typename R0,typename R1>
+ contribution(
+ const R0& source,
+ const R1& weight,
+ value_type bandwidth
+ ):
+ source_(source_size),
+ weight_(weight_size),
+ bandwidth_(bandwidth)
+ {
+ BOOST_ASSERT(size(source_)-source_size==0);
+ BOOST_ASSERT(size(weight_)-weight_size==0);
+
+ copy(
+ begin(source),
+ end(source),
+ begin(source_)
+ );
+
+ copy(
+ begin(weight),
+ end(weight),
+ begin(weight_)
+ );
+ }
+
+ contribution(const contribution& that)
+ : source_(that.source_),
+ weight_(that.weight_),
+ bandwidth_(that.bandwidth_){}
+
+ contribution& operator=(
+ const contribution& that){
+ if(&that!=this){
+ source_ = that.source_;
+ weight_ = that.weight_;
+ bandwidth_ = that.bandwidth_;
+ }
+ return *this;
+ }
+
+ const source_type& source()const{ return source_; }
+ const source_type& weight()const{ return weight_; }
+ value_type bandwidth()const{ return bandwidth_; }
+ value_type normalizing_constant()const{
+ static value_type sqrt2 = sqrt((value_type)(2));
+ typedef normal_kernel_properties<
+ source_size,value_type> nkp_type;
+ static value_type result
+ = nkp_type::normalizing_constant(bandwidth()/sqrt2);
+ return result;
+ }
+ template<typename R>
+ value_type unnormalized_gauss_kernel(const R& target)const{
+ BOOST_ASSERT(size(target)-source_size==0);
+ typedef l2_distance_squared::type dist_type;
+ static dist_type dist;
+ static value_type squared_bandwidth
+ = (bandwidth() * bandwidth());
+ value_type zscore_sqnorm
+ = ( dist(source_,target) / squared_bandwidth );
+ return exp(-zscore_sqnorm);
+ };
+
+ template<typename R>
+ value_type gauss_kernel(const R& target)const{
+ return (unnormalized_gauss_kernel(target)/normalizing_constant());
+ };
+
+ template<typename R0,typename R1>
+ void evaluate(const R0& target,R1& range_out)const{
+ static range_same policy;
+ return evaluate(target,range_out,policy);
+ }
+ /// \warning *adds* to range_out
+ template<typename R0,typename R1,typename SubsetRangePolicy>
+ void evaluate(const R0& target,R1& range_out,
+ const SubsetRangePolicy& policy)const{
+
+
+ value_type gk = gauss_kernel(target);
+
+ typedef const weight_type& arg_type;
+ typedef typename result_of<SubsetRangePolicy(arg_type)>::type
+ subset_type;
+ subset_type subset = policy(weight_);
+
+ BOOST_ASSERT(
+ size(subset)==size(range_out)
+ );
+
+ transform(
+ begin(subset),
+ end(subset),
+ begin(range_out),
+ begin(range_out),
+ bind(
+ std::plus<value_type>(),
+ bind(
+ std::multiplies<value_type>(),
+ _1,
+ gk
+ ),
+ _2
+ )
+ );
+ }
+
+ template<typename R0>
+ value_type
+ nadaraya_watson_normalizing_constant(const R0& target)const{
+ return gauss_kernel(target);
+ }
+
+ private:
+ contribution();//dont implement
+ source_type source_;
+ weight_type weight_;
+ value_type bandwidth_;
+ };
+
+}
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contributions_evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/detail/contributions_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,81 @@
+//////////////////////////////////////////////////////////////////////////////
+// contributions_evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_EXACT_CONTRIBUTIONS_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_EXACT_CONTRIBUTIONS_EVALUATOR_HPP_ER_2009
+#include <algorithm>
+#include <boost/range.hpp>
+#include <boost/ref.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/bind.hpp>
+#include <boost/ref.hpp>
+#include <boost/math/ifgt/exact/detail/contribution.hpp>
+
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace exact{
+ //\warning adds to range_out
+ template<typename R0>
+ class contributions_evaluator{
+ typedef R0 contributions_type;
+ typedef typename range_value<R0>::type contribution_type;
+ public:
+ contributions_evaluator(
+ const contributions_type& contributions
+ ):contributions_(contributions){}
+
+ contributions_evaluator(
+ const contributions_evaluator& that)
+ :contributions_(that.contributions_){}
+
+ template<typename R1,typename R2>
+ void operator()(const R1& target,R2& range_out)const{
+ typedef range_same policy_type;
+ static policy_type policy;
+ return this->operator()(target,range_out,policy);
+ }
+
+ // \warning *adds* to range_out
+ template<typename R1,typename R2,typename SubsetRangePolicy>
+ void operator()(const R1& target,R2& range_out,
+ const SubsetRangePolicy& policy)const{
+ void (contribution_type::*f) (
+ const R1&,R2&,const SubsetRangePolicy&) const
+ = &contribution_type::evaluate;
+ for_each(
+ begin(contributions_),
+ end(contributions_),
+ bind(
+ f,
+ _1,
+ cref(target),
+ ref(range_out),
+ cref(policy)
+ )
+ );
+ }
+
+ private:
+ contributions_evaluator&
+ operator=(const contributions_evaluator& that);
+ contributions_evaluator();
+ const contributions_type& contributions_;
+ };
+
+ template<typename R0>
+ contributions_evaluator<R0>
+ make_contributions_evaluator(
+ const R0& contributions
+ ){
+ return contributions_evaluator<R0>(contributions);
+ }
+
+}
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact/evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////////
+// evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_EXACT_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_EXACT_EVALUATOR_HPP_ER_2009
+#include <boost/math/ifgt/detail/evaluator_common.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/math/ifgt/exact/detail/contributions_evaluator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace exact{
+//template<typename ExactAccumulator>
+//class exact_evaluator : public evaluator_base<
+// evaluator_common<ExactAccumulator>,
+// exact_evaluator<ExactAccumulator>
+// >{
+template<typename ExactAccumulator>
+class evaluator :
+ public evaluator_common<ExactAccumulator>,
+ public crtp::evaluator<evaluator<ExactAccumulator> >
+ {
+
+ typedef evaluator_common<ExactAccumulator> super_t;
+ public:
+
+ template<typename ArgPack>
+ evaluator(const ArgPack& arg) :
+ super_t(arg){}
+
+ evaluator(const evaluator& that) :
+ super_t(that){}
+
+ // TODO privatize
+ template<typename R0,typename R1,typename SubsetRangePolicy>
+ void call_impl(const R0& target,R1& range_out,
+ const SubsetRangePolicy& policy)const{
+ make_contributions_evaluator(
+ (this->accumulator()).contributions()
+ )(target, range_out,policy);
+ }
+
+ private:
+ evaluator& operator=(const evaluator& that);
+ evaluator();
+};
+
+}//exact
+}//ifgt
+}//math
+}//boost
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_accumulator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_accumulator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,141 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/exact_accumulator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EXACT_ACCUMULATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_EXACT_ACCUMULATOR_HPP_ER_2009
-#include <vector>
-#include <algorithm>
-#include <functional>
-#include <iterator>
-#include <vector>
-#include <cmath>
-#include <boost/range.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/iterator/zip_iterator.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/math/ifgt/accumulator_base.hpp>
-#include <boost/math/ifgt/exact_contribution.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- template<
- unsigned SourceSz,
- unsigned WeightSize,
- typename Cont = std::vector<double> >
- class exact_accumulator
- : public exact_accumulator_base<
- exact_accumulator<SourceSz,WeightSize,Cont> >{
- public:
- typedef exact_contribution<SourceSz,WeightSize,Cont>
- contribution_type;
- typedef std::vector<contribution_type> contributions_type;
- typedef typename contribution_type::value_type value_type;
- typedef typename contributions_type::size_type size_type;
- static const std::size_t source_size = SourceSz;
- static const std::size_t weight_size = WeightSize;
- typedef size_type sources_count_type;
- typedef const contributions_type& cref_contributions_type;
-
- exact_accumulator(value_type bandwidth);
- template<typename ArgPack> exact_accumulator(const ArgPack& arg);
- exact_accumulator(const exact_accumulator&);
- exact_accumulator& operator=(const exact_accumulator&);
-
- // Access
- value_type active_bandwidth()const; //>models Accumulator
- cref_contributions_type contributions()const;
- sources_count_type sources_count()const;
-
- // Update
- void set(value_type bandwidth);
-
- // Primarily intended for use internally
- template<typename R0,typename R1>
- void push_back_contribution(
- const R0& source, const R1& weight,value_type bandwidth);
-
- /// models Accumulator
- template<typename R0,typename R1>
- void operator()(const R0& source, const R1& weight);
-
- private:
- exact_accumulator();//dont implem
- static size_type default_contributions_reserve_size(){
- static size_type sz = 1e4; return sz; }
- value_type bandwidth_;
- contributions_type contributions_;
- };
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- exact_accumulator<SourceSz,WeightSize, Cont>::exact_accumulator(
- value_type bandwidth):bandwidth_(bandwidth),contributions_(){
- contributions_.reserve(default_contributions_reserve_size());
- }
-
- //TODO replace unsigned SourceSz by std::size_t SourceSz
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- template<typename ArgPack>
- exact_accumulator<SourceSz,WeightSize, Cont>::exact_accumulator(
- const ArgPack& arg):bandwidth_(arg[tag::bandwidth]),
- contributions_(){
- contributions_.reserve(arg[tag::contributions_reserve_size|
- default_contributions_reserve_size()]);
- }
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- exact_accumulator<SourceSz,WeightSize, Cont>::exact_accumulator(
- const exact_accumulator& that):bandwidth_(that.bandwidth_),
- contributions_(that.contributions_){}
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- typename exact_accumulator<SourceSz,WeightSize, Cont>::exact_accumulator&
- exact_accumulator<SourceSz,WeightSize, Cont>::operator=(
- const exact_accumulator& that){
- if(&that!=this){
- bandwidth_ = that.bandwidth_;
- contributions_ = that.contributions_; }
- return *this; }
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- typename exact_accumulator<SourceSz,WeightSize, Cont>::value_type
- exact_accumulator<SourceSz,WeightSize, Cont>::active_bandwidth()const{
- return bandwidth_; };
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- typename exact_accumulator<SourceSz,WeightSize, Cont>::cref_contributions_type
- exact_accumulator<SourceSz,WeightSize, Cont>::contributions()const{
- return contributions_; };
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- typename exact_accumulator<SourceSz,WeightSize, Cont>::sources_count_type
- exact_accumulator<SourceSz,WeightSize, Cont>::sources_count()const{
- return contributions_.size();
- }
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- void exact_accumulator<SourceSz,WeightSize, Cont>::set(
- value_type bandwidth){ bandwidth_ = bandwidth; };
-
- template<unsigned SourceSz, unsigned WeightSize, typename Cont>
- template<typename R0,typename R1>
- void exact_accumulator<SourceSz,WeightSize, Cont>::push_back_contribution(
- const R0& source,
- const R1& weight,
- value_type bandwidth){
- contributions_.push_back(
- contribution_type(source,weight,bandwidth)
- );
- }
-
- template<unsigned SourceSz,unsigned WeightSize, typename Cont>
- template<typename R0,typename R1>
- void exact_accumulator<SourceSz,WeightSize, Cont>::operator()(
- const R0& source, const R1& weight){
- push_back_contribution(source,weight,active_bandwidth()); }
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contribution.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contribution.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,156 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/exact_contribution.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EXACT_CONTRIBUTION_HPP_ER_2009
-#define BOOST_MATH_IFGT_EXACT_CONTRIBUTION_HPP_ER_2009
-#include <algorithm>
-#include <functional>
-#include <numeric>
-#include <cmath>
-#include <stdexcept>
-#include <boost/range.hpp>
-#include <boost/assert.hpp>
-#include <boost/utility.hpp>
-#include <boost/algorithm/l2_distance_squared.hpp>
-#include <boost/math/ifgt/normal_kernel_properties.hpp>
-#include <boost/iterator/range_same.hpp>
-
-namespace boost{namespace math{namespace ifgt{
-
- // A source, weight, and bandwidth
- // and associated operations.
- template<
- unsigned SourceSz,
- unsigned WeightSz,
- typename Cont = std::vector<double> > //TODO add cutoff radius policy
- class exact_contribution{
- public:
- typedef typename Cont::value_type value_type;
- typedef Cont source_type;
- typedef Cont weight_type;
- static const std::size_t source_size = SourceSz;
- static const std::size_t weight_size = WeightSz;
- template<typename R0,typename R1>
- exact_contribution(
- const R0& source,
- const R1& weight,
- value_type bandwidth
- ):
- source_(source_size),
- weight_(weight_size),
- bandwidth_(bandwidth)
- {
- BOOST_ASSERT(size(source_)-source_size==0);
- BOOST_ASSERT(size(weight_)-weight_size==0);
-
- copy(
- begin(source),
- end(source),
- begin(source_)
- );
-
- copy(
- begin(weight),
- end(weight),
- begin(weight_)
- );
- }
-
- exact_contribution(const exact_contribution& that)
- : source_(that.source_),
- weight_(that.weight_),
- bandwidth_(that.bandwidth_){}
-
- exact_contribution& operator=(
- const exact_contribution& that){
- if(&that!=this){
- source_ = that.source_;
- weight_ = that.weight_;
- bandwidth_ = that.bandwidth_;
- }
- return *this;
- }
-
- const source_type& source()const{ return source_; }
- const source_type& weight()const{ return weight_; }
- value_type bandwidth()const{ return bandwidth_; }
- value_type normalizing_constant()const{
- static value_type sqrt2 = sqrt((value_type)(2));
- typedef normal_kernel_properties<
- source_size,value_type> nkp_type;
- static value_type result
- = nkp_type::normalizing_constant(bandwidth()/sqrt2);
- return result;
- }
- template<typename R>
- value_type unnormalized_gauss_kernel(const R& target)const{
- BOOST_ASSERT(size(target)-source_size==0);
- typedef l2_distance_squared::type dist_type;
- static dist_type dist;
- static value_type squared_bandwidth
- = (bandwidth() * bandwidth());
- value_type zscore_sqnorm
- = ( dist(source_,target) / squared_bandwidth );
- return exp(-zscore_sqnorm);
- };
-
- template<typename R>
- value_type gauss_kernel(const R& target)const{
- return (unnormalized_gauss_kernel(target)/normalizing_constant());
- };
-
- template<typename R0,typename R1>
- void evaluate(const R0& target,R1& range_out)const{
- static range_same policy;
- return evaluate(target,range_out,policy);
- }
- /// \warning *adds* to range_out
- template<typename R0,typename R1,typename SubsetRangePolicy>
- void evaluate(const R0& target,R1& range_out,
- const SubsetRangePolicy& policy)const{
- value_type gk = gauss_kernel(target);
-
- typedef const weight_type& arg_type;
- typedef typename result_of<SubsetRangePolicy(arg_type)>::type
- subset_type;
- subset_type subset = policy(weight_);
-
- BOOST_ASSERT(
- size(subset)==size(range_out)
- );
-
- transform(
- begin(subset),
- end(subset),
- begin(range_out),
- begin(range_out),
- bind(
- std::plus<value_type>(),
- bind(
- std::multiplies<value_type>(),
- _1,
- gk
- ),
- _2
- )
- );
- }
-
- template<typename R0>
- value_type
- nadaraya_watson_normalizing_constant(const R0& target)const{
- return gauss_kernel(target);
- }
-
- private:
- exact_contribution();//dont implement
- source_type source_;
- weight_type weight_;
- value_type bandwidth_;
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contributions_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_contributions_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,76 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/exact_contributions_evaluator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EXACT_CONTRIBUTIONS_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_EXACT_CONTRIBUTIONS_EVALUATOR_HPP_ER_2009
-#include <algorithm>
-#include <boost/range.hpp>
-#include <boost/ref.hpp>
-#include <boost/range/value_type.hpp>
-#include <boost/bind.hpp>
-#include <boost/ref.hpp>
-#include <boost/math/ifgt/exact_contribution.hpp>
-
-namespace boost{namespace math{namespace ifgt{
-
- //\warning adds to range_out
- template<typename R0>
- class exact_contributions_evaluator{
- typedef R0 contributions_type;
- typedef typename range_value<R0>::type contribution_type;
- public:
- exact_contributions_evaluator(
- const contributions_type& contributions
- ):contributions_(contributions){}
-
- exact_contributions_evaluator(
- const exact_contributions_evaluator& that)
- :contributions_(that.contributions_){}
-
- template<typename R1,typename R2>
- void operator()(const R1& target,R2& range_out)const{
- typedef range_same policy_type;
- static policy_type policy;
- return this->operator()(target,range_out,policy);
- }
-
- // \warning *adds* to range_out
- template<typename R1,typename R2,typename SubsetRangePolicy>
- void operator()(const R1& target,R2& range_out,
- const SubsetRangePolicy& policy)const{
- void (contribution_type::*f) (
- const R1&,R2&,const SubsetRangePolicy&) const
- = &contribution_type::evaluate;
- for_each(
- begin(contributions_),
- end(contributions_),
- bind(
- f,
- _1,
- cref(target),
- ref(range_out),
- cref(policy)
- )
- );
- }
-
- private:
- exact_contributions_evaluator&
- operator=(const exact_contributions_evaluator& that);
- exact_contributions_evaluator();
- const contributions_type& contributions_;
- };
-
- template<typename R0>
- exact_contributions_evaluator<R0>
- make_exact_contributions_evaluator(
- const R0& contributions
- ){
- return exact_contributions_evaluator<R0>(contributions);
- }
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/exact_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,47 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/exact_evaluator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_EXACT_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_EXACT_EVALUATOR_HPP_ER_2009
-#include <boost/math/ifgt/evaluator_common.hpp>
-#include <boost/math/ifgt/evaluator_base.hpp>
-#include <boost/math/ifgt/exact_contributions_evaluator.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename ExactAccumulator>
-class exact_evaluator : public evaluator_base<
- evaluator_common<ExactAccumulator>,
- exact_evaluator<ExactAccumulator>
- >{
- typedef exact_evaluator<ExactAccumulator> self_type;
- typedef evaluator_common<ExactAccumulator> c_type;
- typedef evaluator_base<c_type,self_type> base_type;
- //typedef typename base_type::value_type value_type;
- public:
-
- template<typename ArgPack>
- exact_evaluator(const ArgPack& arg) :
- base_type(arg){}
-
- exact_evaluator(const exact_evaluator& that) :
- base_type(that){}
-
- // TODO privatize
- template<typename R0,typename R1,typename SubsetRangePolicy>
- void call_impl(const R0& target,R1& range_out,
- const SubsetRangePolicy& policy)const{
- make_exact_contributions_evaluator(
- (this->accumulator()).contributions()
- )(target, range_out,policy);
- }
-
- private:
- exact_evaluator& operator=(const exact_evaluator& that);
- exact_evaluator();
-};
-
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/accumulator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/accumulator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,264 @@
+//////////////////////////////////////////////////////////////////////////////
+// accumulator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FAST_ACCUMULATOR_IMPL_HPP_ER_2009
+#define BOOST_MATH_IFGT_FAST_ACCUMULATOR_IMPL_HPP_ER_2009
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <numeric>
+#include <boost/range.hpp>
+#include <boost/bind.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/apply.hpp>
+#include <iostream> //TODO remove
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/fast/find_nearest_cluster.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/cutoff_radius/none.hpp>
+#include <boost/math/ifgt/crtp/accumulator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace fast{
+
+
+ // accumulator maintains a set of clusters, which is split
+ // into an inactive and an active range. each time a (source,weight)
+ // is passed to the object, only the active range is updated
+ // i.e. either the source is collected at the nearest cluster within
+ // that range,
+ // or the a new cluster is added to the active range,
+ // or the source is ignored if it equals the center of nearest cluster.
+ // each time (bandwith,max_radius) is reset, the beginning
+ // of the active range is to the end of the clusters range.
+ // This (optional) feature is useful in applications where the bandwidth
+ // is modified (usually decreased) in a piecewise-constant fashion.
+ // The client can also use push_back_cluster to add a center
+ // to the active range
+
+ /// apply<FindClusterPolicy,Cluster>::type
+ template<
+ typename Cluster,
+ typename FindClusterPolicy
+ = find_nearest_cluster<mpl::_1, l2_distance_squared>
+ >
+ class accumulator:
+ public crtp::accumulator<
+ accumulator<Cluster,FindClusterPolicy> >{
+ public:
+ typedef Cluster cluster_type;
+ typedef typename cluster_type::center_type center_type;
+ typedef typename cluster_type::value_type value_type;
+ typedef typename cluster_type::coefficients_type
+ coefficients_type;
+ typedef typename cluster_type::collection_coefficients_type
+ collection_coefficients_type;
+ static const std::size_t source_size = cluster_type::source_size;
+ static const std::size_t weight_size = cluster_type::weight_size;
+ private:
+ typedef std::vector<cluster_type> clusters_type;
+ typedef typename clusters_type::size_type size_type;
+ static size_type default_clusters_reserve_size(){
+ static size_type sz = 1000; return sz; }
+ typedef typename clusters_type::difference_type diff_type;
+ typedef range_iterator<clusters_type> ri_type;
+ typedef typename ri_type::type iter_type;
+ typedef iterator_range<iter_type> active_range_type;
+ typedef typename cluster_type::truncation_degree_policy_type
+ truncation_degree_policy_type;
+ public:
+ typedef typename cluster_type::sources_count_type
+ sources_count_type;
+
+ //Construct
+ accumulator();
+ template<typename ArgPack>
+ accumulator(const ArgPack& args);
+ accumulator(const accumulator& that);
+ //Assign
+ accumulator& operator=(const accumulator& that);
+
+ /// Triggers a new active range
+ void set(value_type bandwidth,value_type max_radius);
+ void set_truncation_degree_policy(
+ const truncation_degree_policy_type& arg);
+
+ //Access
+ value_type active_bandwidth()const;
+ value_type active_max_radius()const;
+ const clusters_type& clusters()const;
+ sources_count_type sources_count()const;
+
+ //Update
+ /// Used internally, but passing clusters directly also allowed.
+ template<typename R>
+ void push_back_cluster(const R& center);
+
+ template<typename R0,typename R1>
+ bool operator()(const R0& source, const R1& weight);
+
+ private:
+ active_range_type active_range();
+ diff_type active_dist_to_;
+ value_type active_bandwidth_;
+ value_type active_max_radius_;
+ truncation_degree_policy_type truncation_degree_policy_;
+ clusters_type clusters_;
+ };
+
+ template<typename Cluster, typename FindClusterPolicy>
+ accumulator<Cluster,FindClusterPolicy>::accumulator()
+ : active_dist_to_((diff_type)(0)),
+ active_bandwidth_((value_type)(0)),
+ active_max_radius_((value_type)(0)),
+ //make sure gen comp error if deflt constr inexistant
+ truncation_degree_policy_(),
+ clusters_()
+ { clusters_.reserve(default_clusters_reserve_size()); }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ template<typename ArgPack>
+ accumulator<Cluster,FindClusterPolicy>::accumulator(
+ const ArgPack& args)
+ : active_dist_to_((diff_type)(0)),
+ active_bandwidth_(args[kwd<>::bandwidth|(value_type)(0)]),
+ active_max_radius_(args[kwd<>::max_cluster_radius|(value_type)(0)]),
+ truncation_degree_policy_(args){
+ clusters_.reserve(
+ args[kwd<>::clusters_reserve_size
+ |default_clusters_reserve_size()]);
+ }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ accumulator<Cluster,FindClusterPolicy>::accumulator(
+ const accumulator& that)
+ : active_dist_to_(that.active_dist_to_),
+ active_bandwidth_(that.active_bandwidth_),
+ active_max_radius_(that.active_max_radius_),
+ clusters_(that.clusters_){}
+
+ template<typename Cluster,typename FindClusterPolicy>
+ typename accumulator<Cluster,
+ FindClusterPolicy>::accumulator&
+ accumulator<Cluster,FindClusterPolicy>::operator=(
+ const accumulator& that){
+ if(&that!=this){
+ active_dist_to_ = that.active_dist_to_;
+ active_bandwidth_ = that.active_bandwidth_;
+ active_max_radius_ = that.active_max_radius_;
+ clusters_ = that.clusters_;
+ }
+ return *this;
+ }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ void accumulator<Cluster,FindClusterPolicy>::set(
+ value_type bandwidth,value_type max_radius){
+ active_bandwidth_ = bandwidth;
+ active_max_radius_ = max_radius;
+ active_dist_to_
+ = std::distance(begin(clusters_), end(clusters_));
+ }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ void
+ accumulator<Cluster,
+ FindClusterPolicy>::set_truncation_degree_policy(
+ const truncation_degree_policy_type& truncation_degree_policy){
+ truncation_degree_policy_ = truncation_degree_policy;
+ }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ typename accumulator<Cluster,FindClusterPolicy>::value_type
+ accumulator<Cluster,FindClusterPolicy>::active_bandwidth()const{
+ return active_bandwidth_; }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ typename accumulator<Cluster,FindClusterPolicy>::value_type
+ accumulator<Cluster,FindClusterPolicy>::active_max_radius()const{
+ return active_max_radius_; }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ typename accumulator<Cluster,
+ FindClusterPolicy>::active_range_type
+ accumulator<Cluster,FindClusterPolicy>::active_range(){
+ iter_type i = begin(clusters_);
+ std::advance(i,active_dist_to_);
+ return active_range_type(i,end(clusters_));
+ }
+
+ template<typename Cluster, typename FindClusterPolicy>
+ const typename accumulator<Cluster,
+ FindClusterPolicy>::clusters_type&
+ accumulator<Cluster,FindClusterPolicy>::clusters()const{
+ return clusters_; }
+
+ template<typename Cluster,typename FindClusterPolicy>
+ typename accumulator<Cluster,
+ FindClusterPolicy>::sources_count_type
+ accumulator<Cluster,FindClusterPolicy>::sources_count()const{
+ return std::accumulate(
+ begin(clusters_),
+ end(clusters_),
+ (sources_count_type)(0),
+ bind(
+ std::plus<value_type>(),
+ _1,
+ bind(
+ &cluster_type::sources_count,
+ _2
+ )
+ )
+ );
+ }
+
+ template<typename Cluster, typename FindClusterPolicy>
+ template<typename R>
+ void accumulator<Cluster,FindClusterPolicy
+ >::push_back_cluster(const R& center){
+ clusters_.push_back(cluster_type(
+ center,
+ active_bandwidth(),
+ active_max_radius(),
+ truncation_degree_policy_
+ ));
+ }
+
+ template<typename Cluster, typename FindClusterPolicy>
+ template<typename R0,typename R1>
+ bool accumulator<Cluster,FindClusterPolicy>::operator()(
+ const R0& source, const R1& weight){
+ static bool is_collected = false;
+ static active_range_type local_active_range = active_range();
+ if(active_bandwidth()>(value_type)(0)){
+ local_active_range = active_range();
+ if(empty(local_active_range)){
+ push_back_cluster(source);
+ }else{
+ typedef typename mpl::apply<FindClusterPolicy,
+ active_range_type>::type find_nc_type;
+
+ // TODO assigning local_active_range
+ // and creating a new find_nc on each call maybe costly
+ find_nc_type find_nc(local_active_range);
+ iter_type nn = find_nc(source);
+ is_collected = (*nn)(source,weight);
+ if(nn->source_radius_exceeds_max_radius()){
+ BOOST_ASSERT(!is_collected);
+ push_back_cluster(source);
+ }
+ }
+ }else{
+ throw std::runtime_error("accumulator::collect");
+ }
+ return is_collected;
+ }
+}//fast
+}//ifgt
+}//math
+}//boost
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,306 @@
+//////////////////////////////////////////////////////////////////////////////
+// cluster.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CLUSTER_HPP_ER_2009
+#define BOOST_MATH_IFGT_CLUSTER_HPP_ER_2009
+#include <algorithm>
+#include <functional>
+#include <iterator>
+#include <vector>
+#include <cmath>
+#include <boost/range.hpp>
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/iterator/zip_iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/algorithm/l2_norm.hpp>
+#include <boost/math/monomials.hpp>
+#include <boost/math/multi_indexes_derived.hpp>
+#include <boost/math/ifgt/detail/zscore.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/fast/detail/coefficients.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt//detail/normal_kernel_properties.hpp>
+namespace boost{namespace math{namespace ifgt{
+
+ // A cluster is characterized by
+ // - A center
+ // - A bandwidth
+ // - A collection of coefficients (one for each weight sequence)
+
+ /// apply<TruncationDegreePolicy,T>::type
+ template<
+ unsigned SourceSize,
+ unsigned WeightSize,
+ typename TruncationDegreePolicy
+ = truncation_degree::constant<mpl::_1>,
+ typename Cont = std::vector<double> >
+ class cluster{
+ typedef monomials<Cont> monoms_type;
+ typedef typename monoms_type::result_type monoms_result_type;
+ typedef coefficients<SourceSize,Cont> coeffs_type;
+ typedef std::vector<coeffs_type> coll_coeffs_type;
+ typedef typename coll_coeffs_type::iterator coll_coeffs_iter_type;
+
+ public:
+ // C++ Standard (now) allows initialization of const static data
+ // members of an integral type inside their class.
+ static const std::size_t source_size = SourceSize;
+ static const std::size_t weight_size = WeightSize;
+ typedef Cont center_type;
+ typedef const center_type& result_of_center_type;
+ typedef typename monoms_type::value_type value_type;
+ typedef coeffs_type coefficients_type;
+ typedef coll_coeffs_type collection_coefficients_type;
+ typedef const collection_coefficients_type&
+ result_of_collection_coefficients_type;
+ typedef std::size_t sources_count_type;
+ typedef normal_kernel_properties<source_size,value_type> rpp_type;
+ typedef typename mpl::apply<TruncationDegreePolicy,value_type>::type
+ truncation_degree_policy_type;
+
+ template<typename ArgPack>
+ cluster(const ArgPack& arg)
+ :center_(source_size),
+ bandwidth_(arg[kwd<>::bandwidth]),
+ max_radius_(arg[kwd<>::max_cluster_radius]),
+ truncation_degree_policy_(arg),
+ inv_nc_((value_type)(1)/rpp_type::normalizing_constant(bandwidth())),
+ source_radius_((value_type)(0)),
+ radius_((value_type)(0)),
+ sources_count_(0),
+ coll_coeffs_(weight_size){
+ BOOST_ASSERT(size(arg[kwd<>::center])-source_size==0);
+ copy(
+ begin(arg[kwd<>::center]),
+ end(arg[kwd<>::center]),
+ begin(center_)
+ );
+ }
+
+ template<typename R>
+ cluster(
+ const R& center,
+ value_type bandwidth_val,//cannot name it bandiwth coz mf
+ value_type max_radius,
+ const truncation_degree_policy_type& truncation_degree_policy)
+ :center_(source_size),
+ bandwidth_(bandwidth_val),
+ max_radius_(max_radius),
+ truncation_degree_policy_(truncation_degree_policy),
+ inv_nc_((value_type)(1)/rpp_type::normalizing_constant(bandwidth())),
+ source_radius_((value_type)(0)),
+ radius_((value_type)(0)),
+ sources_count_(0),
+ coll_coeffs_(weight_size){
+ BOOST_ASSERT(size(center)-source_size==0);
+ copy(
+ begin(center),
+ end(center),
+ begin(center_)
+ );
+ }
+
+ cluster(const cluster& that)
+ :center_(that.source_size),
+ bandwidth_(that.bandwidth_),
+ max_radius_(that.max_radius_),
+ truncation_degree_policy_(that.truncation_degree_policy_),
+ inv_nc_(that.inv_nc_),
+ source_radius_(that.source_radius_),
+ radius_(that.radius_),
+ sources_count_(that.sources_count_),
+ coll_coeffs_(that.coll_coeffs_){
+ copy(
+ begin(that.center_),
+ end(that.center_),
+ begin(center_)
+ );
+ }
+
+ cluster& operator=(const cluster& that){
+ if(&that!=this){
+ center_ = that.center_;
+ bandwidth_ = that.bandwidth_;
+ max_radius_ = that.max_radius_;
+ truncation_degree_policy_ = that.truncation_degree_policy_;
+ inv_nc_ = that.inv_nc_;
+ source_radius_ = that.source_radius_;
+ radius_ = that.radius_;
+ sources_count_ = that.sources_count_;
+ coll_coeffs_ = that.coll_coeffs_;
+ }
+ return *this;
+ }
+
+ result_of_center_type center()const{ return center_; }
+ value_type bandwidth()const{ return bandwidth_; }
+ /// Maximum allowed cluster radius
+ value_type max_radius()const{ return max_radius_; }
+
+ value_type inverse_normalizing_constant()const{ return inv_nc_; }
+
+ /// Maximum radius among collected sources
+ value_type radius()const{ return radius_; }
+ /// Number of sources collected
+ sources_count_type sources_count()const{ return sources_count_; }
+
+ /// Radius of the source in the last argument that was passed
+ value_type source_radius()const{ return source_radius_; }
+ bool source_radius_is_zero()const{
+ return source_radius() == (value_type)(0);
+ }
+ bool source_radius_exceeds_max_radius()const{
+ return (source_radius() > max_radius());
+ }
+
+ result_of_collection_coefficients_type
+ collection_coefficients()const{return coll_coeffs_; }
+
+ template<typename R0,typename R1>
+ bool operator()(const R0& source, const R1& weight){
+ typedef std::vector<unsigned> degrees_type;
+ typedef zscore<center_type> zscore_type;
+ typedef l2_norm_squared sqnorm_type;
+ static degrees_type degrees(weight_size,0);
+ //static zscore_type zscore(center());//not safe
+ static Cont zscore_val(source_size);
+ static sqnorm_type sqnorm;
+ zscore_type zscore(center());
+ zscore(source,bandwidth(),zscore_val);
+
+ value_type zscore_sqnorm = sqnorm(zscore_val);
+ source_radius_ = sqrt(zscore_sqnorm) * bandwidth();
+ bool do_collect = !(
+ source_radius_is_zero()
+ || source_radius_exceeds_max_radius() );
+
+ if(do_collect){
+ truncation_degree_policy_(
+ *this, source_radius(), weight, degrees);
+ (*this)(zscore_val, zscore_sqnorm, weight, degrees);
+ }
+ return do_collect;
+ }
+
+ // TODO check that
+ // range_iterator<R2>::type::value_type == unsigned
+ /// Returns true if source collected, false otherwise
+ template<typename R0,typename R1,typename R2>
+ void operator()(
+ const R0& zscore_val,
+ value_type zscore_sqnorm,
+ const R1& weight,
+ const R2& degrees
+ ){
+ typedef range_iterator<R0> ir0_type;
+ typedef range_iterator<R1> ir1_type;
+ typedef range_iterator<R2> ir2_type;
+ typedef typename ir0_type::type iter0_type;
+ typedef typename ir1_type::type iter1_type;
+ typedef typename ir2_type::type iter2_type;
+ typedef typename iter0_type::value_type value0_type;
+ typedef typename iter1_type::value_type value1_type;
+ typedef typename iter2_type::value_type value2_type;
+ BOOST_MPL_ASSERT((is_same<value0_type,value_type>));
+ BOOST_MPL_ASSERT((is_same<value1_type,value_type>));
+ BOOST_MPL_ASSERT((is_same<value2_type,unsigned>));
+ //static Cont zscore_val(source_size);
+ static Cont consts(source_size);
+ static monomials<Cont> monoms;
+ BOOST_ASSERT(size(zscore_val)-source_size==0);
+ BOOST_ASSERT(size(weight)-weight_size==0);
+ BOOST_ASSERT(size(degrees)-weight_size==0);
+ BOOST_ASSERT(zscore_sqnorm!=((value_type)(0)));
+
+ unsigned local_max_degree
+ = (*std::max_element(
+ begin(degrees),
+ end(degrees)));
+
+ monoms(zscore_val,local_max_degree);
+
+ for_each(
+ make_zip_iterator(
+ make_tuple(
+ begin(weight),
+ begin(coll_coeffs_),
+ begin(degrees)
+ )
+ ),
+ make_zip_iterator(
+ make_tuple(
+ end(weight),
+ end(coll_coeffs_),
+ end(degrees)
+ )
+ ),
+ op_factory::make(monoms(),zscore_sqnorm)
+ );
+
+ radius_
+ = (radius()<source_radius())
+ ? source_radius() : radius();
+
+ ++sources_count_;
+ }
+ //TODO remove. Necessary for temporary fix in copy constructor
+ // of derived classes
+ const truncation_degree_policy_type& truncation_degree_policy()const{
+ return truncation_degree_policy_;}
+
+ private:
+ template<typename Mons>
+ class op{
+ public:
+ typedef tuple<
+ const value_type&,
+ coeffs_type&,
+ const unsigned&> argument_type;
+ typedef void result_type;
+ typedef
+ typename range_iterator<const Mons>::type mons_ir_type;
+ op(const Mons& mons,value_type zscore_sqnorm)
+ :zscore_sqnorm_(zscore_sqnorm),mons_(mons){}
+ op(const op& that)
+ :zscore_sqnorm_(that.zscore_sqnorm_),mons_(that.mons_){}
+
+ void operator()(argument_type t){
+ value_type w = t.template get<0>();
+ coeffs_type& coeffs = t.template get<1>();
+ unsigned degree = t.template get<2>();
+ coeffs(zscore_sqnorm_,mons_,w,degree);
+ }
+ private:
+ op& operator=(const op& that);
+ value_type zscore_sqnorm_;
+ const Mons& mons_;
+ };//op
+ struct op_factory{
+ template<typename Mons>
+ static op<Mons> make(const Mons& mons,value_type zscore_sqnorm){
+ return op<Mons>(mons,zscore_sqnorm);
+ }
+ };
+ center_type center_;
+ value_type bandwidth_;
+ value_type max_radius_;
+ truncation_degree_policy_type truncation_degree_policy_;
+ value_type inv_nc_;
+
+ value_type source_radius_;
+ value_type radius_;
+ sources_count_type sources_count_;
+ coll_coeffs_type coll_coeffs_;
+ };
+
+
+}}}
+
+
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_call_center.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_call_center.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// cluster_call_center.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CLUSTER_CALL_CENTER_HPP_ER_2009
+#define BOOST_MATH_IFGT_CLUSTER_CALL_CENTER_HPP_ER_2009
+namespace boost{namespace math{namespace ifgt{
+ template<typename Cc>
+ struct cluster_call_center{
+ typedef typename Cc::center_type center_type;
+ typedef const center_type& result_type;
+ typedef const Cc& argument_type;
+ cluster_call_center(){}
+ result_type operator()(argument_type arg)const{
+ return arg.center();
+ }
+ };
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/cluster_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,141 @@
+//////////////////////////////////////////////////////////////////////////////
+// cluster_evalutor.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CLUSTER_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_CLUSTER_EVALUATOR_HPP_ER_2009
+#include <stdexcept>
+#include <algorithm>
+#include <boost/range.hpp>
+#include <boost/bind.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/utility.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/utility/dont_care.hpp>
+#include <boost/math/ifgt/fast/detail/coefficients_evaluator.hpp>
+#include <boost/iterator/range_same.hpp>
+
+namespace boost{ namespace math{namespace ifgt{
+
+ // cluster_evaluator takes a target and a range_out in its constructor
+ // remember that a cluster contains as many coefficients as
+ // weight sequences. The job of cluster_evaluator
+ // is to apply coefficients_evaluator to each
+ // coefficients and *add* the results to range_out
+
+ // \warning adds to range_out
+ // \warning The cutoff_radius_policy is passed by reference for efficiency
+ // R ForwarRange (that of the target)
+ // apply<CutoffRadiusPolicy,X>::type
+ template<
+ typename R,
+ typename RangeOut,
+ typename CutoffRadiusPolicy>
+ class cluster_evaluator{
+ public:
+ typedef typename range_value<R>::type value_type;
+ typedef RangeOut& ref_range_out_type;
+ private:
+ typedef typename mpl::apply<CutoffRadiusPolicy,value_type>::type
+ cutoff_radius_policy_type;
+ typedef const cutoff_radius_policy_type&
+ cref_cutoff_radius_policy_type;
+ public:
+ template<typename ArgPack>
+ cluster_evaluator(const ArgPack& args)
+ :range_out_(args[kwd<>::range_out]),
+ coeffs_evaluator_(args[kwd<>::target]),
+ cutoff_radius_policy_(args[kwd<>::cutoff_radius_policy]){
+ // Do not replace by cutoff_radius_policy_(args)
+ }
+
+ //TODO remove
+ cluster_evaluator(
+ const R& target,
+ ref_range_out_type range_out,
+ cref_cutoff_radius_policy_type cutoff_radius_policy)
+ :range_out_(range_out),
+ coeffs_evaluator_(target),
+ cutoff_radius_policy_(cutoff_radius_policy){}
+
+ cluster_evaluator(const cluster_evaluator& that)
+ :range_out_(that.range_out_),
+ coeffs_evaluator_(that.coeffs_evaluator_),
+ cutoff_radius_policy_(that.cutoff_radius_policy_){}
+
+ template<typename Cluster>
+ void operator()(const Cluster& cluster){
+ static range_same policy;
+ return this->operator()(cluster, policy);
+ }
+
+ template<typename Cluster,typename SubsetRangePolicy>
+ void operator()(const Cluster& cluster,
+ const SubsetRangePolicy& subset_range_policy){
+ typedef typename Cluster::coefficients_type coeffs_type;
+ typedef SubsetRangePolicy subset_range_policy_type;
+ //compile warning:
+ //"comparison between signed and unsigned integer expressions|"
+ //why? source_size() is also a size_type
+ BOOST_ASSERT(
+ coeffs_evaluator_.target_size() - size(cluster.center()) == 0 );
+
+ value_type cutoff_radius = cutoff_radius_policy_(cluster);
+
+ typedef typename
+ Cluster::result_of_collection_coefficients_type arg_type;
+
+ typedef typename result_of<
+ subset_range_policy_type(arg_type)>::type subset_type;
+
+ subset_type subset
+ = subset_range_policy(cluster.collection_coefficients());
+
+ BOOST_ASSERT(size(subset) ==size(range_out_));
+
+ typename coeffs_type::result_type (coeffs_type::*f)() const =
+ &coeffs_type::operator();
+
+ std::transform(
+ begin(subset),
+ end(subset),
+ begin(range_out_),
+ begin(range_out_),
+ bind(
+ std::plus<value_type>(),
+ bind(
+ ref(coeffs_evaluator_),
+ cutoff_radius,
+ cref(cluster.center()),
+ cluster.bandwidth(),
+ cluster.inverse_normalizing_constant(),
+ bind(
+ f,
+ _1
+ ),
+ bind(
+ &coeffs_type::max_degree,
+ _1
+ )
+ ),
+ _2
+ )
+ );
+ }
+
+ private:
+ cluster_evaluator& operator=(const cluster_evaluator& that);
+ cluster_evaluator();
+ typedef coefficients_evaluator<R> coeffs_evaluator_type;
+ ref_range_out_type range_out_;
+ coeffs_evaluator_type coeffs_evaluator_;
+ cutoff_radius_policy_type cutoff_radius_policy_;
+ };
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/clusters_evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/clusters_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,89 @@
+//////////////////////////////////////////////////////////////////////////////
+// clusters_evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_CLUSTERS_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_CLUSTERS_EVALUATOR_HPP_ER_2009
+#include <algorithm>
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/range.hpp>
+#include <boost/math/ifgt/fast//detail/cluster_evaluator.hpp>
+namespace boost{namespace math{namespace ifgt{
+
+ // Adds to a range the result from evaluating each cluster
+ template<
+ typename RealType,
+ typename CutoffRadiusPolicy
+ >
+ class clusters_evaluator{
+ public:
+ typedef RealType value_type;
+ typedef typename mpl::apply<CutoffRadiusPolicy,value_type>::type
+ cluster_radius_policy_type;
+ template<typename ArgPack>
+ clusters_evaluator(const ArgPack& args):cluster_radius_policy_(args){}
+
+ // make sure policy's default constructor is disabled
+ // if necessary
+ // so that compile error here
+ clusters_evaluator(){}
+
+ clusters_evaluator(const cluster_radius_policy_type&
+ cluster_radius_policy)
+ : cluster_radius_policy_(cluster_radius_policy){}
+ clusters_evaluator(const clusters_evaluator& that)
+ :cluster_radius_policy_(that.cluster_radius_policy_){}
+
+ clusters_evaluator& operator=(const clusters_evaluator& that){
+ if(&that!=this){
+ cluster_radius_policy_ = that.cluster_radius_policy_;
+ }
+ return *this;
+ }
+
+ template<typename R0,typename R1,typename R2>
+ void operator()(
+ const R0& target,const R1& clusters,R2& range_out)const{
+ static range_same policy;
+ return this->operator()(
+ target, clusters, range_out, policy
+ );
+ }
+
+ //\warning adds to range_out
+ template<typename R0,typename R1,typename R2,
+ typename SubsetRangePolicy>
+ void operator()(
+ const R0& target,const R1& clusters,R2& range_out,
+ const SubsetRangePolicy& subset_range_policy)const{
+ typedef typename range_value<R0>::type value0_type;
+ typedef typename range_value<R1>::type cluster_type;
+ typedef typename cluster_type::value_type value1_type;
+ typedef typename range_value<R2>::type value2_type;
+ BOOST_MPL_ASSERT((is_same<value0_type,value_type>));
+ BOOST_MPL_ASSERT((is_same<value1_type,value_type>));
+ BOOST_MPL_ASSERT((is_same<value2_type,value_type>));
+ typedef cluster_evaluator<R0,R2,CutoffRadiusPolicy> eval_type;
+
+ eval_type eval(target, range_out, cluster_radius_policy_);
+
+ for_each(
+ begin(clusters),
+ end(clusters),
+ bind<void>(
+ ref(eval),//not cref because eval modifies range_out
+ _1,
+ cref(subset_range_policy)
+ )
+ );
+ };
+
+ private:
+ cluster_radius_policy_type cluster_radius_policy_;
+ };
+
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,150 @@
+//////////////////////////////////////////////////////////////////////////////
+// coefficients.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_SOURCE_COEFFICIENTS_HPP_ER_2009
+#define BOOST_MATH_IFGT_SOURCE_COEFFICIENTS_HPP_ER_2009
+#include <algorithm>
+#include <functional>
+#include <iterator>
+#include <vector>
+#include <cmath>
+#include <boost/range.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/iterator/zip_iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/math/monomials.hpp>
+#include <boost/math/multi_indexes_derived.hpp>
+namespace boost{namespace math{namespace ifgt{
+
+ // coefficients keeps a set of coefficients and a max_degree
+ // Each time (zsqn, monoms, w,p) is passed to the object,
+ // the coefficients {C_\alpha:\alpha_0+...+\alpha_{SourceSz-1}<=p}
+ // are updated.
+ // Specifically,
+ // C_{\alpha} +=
+ // 2^{\alpha}/\alpha! * w exp(-zsqn ) * z^alpha
+ // The z^alpha's are the elements in monoms
+ // zsqn represents || z ||_2^2
+ //
+ // The reason for this set up (zsqn and monoms passed to the object)
+ // is that this operation may be repeated
+ // for different weight sequences (one coefficients for each).
+
+ template<unsigned SourceSz,typename Cont = std::vector<double> >
+ class coefficients{
+ typedef typename Cont::value_type value_type;
+ typedef multi_indexes_derived<SourceSz,multi_power2divfact_op>
+ mult_p2df;
+ typedef typename mult_p2df::iter_range_type p2df_ir_type;
+ typedef
+ typename range_iterator<p2df_ir_type>::type p2df_iter_type;
+ typedef
+ typename range_value<p2df_ir_type>::type p2df_value_type;
+ public:
+ typedef Cont coefficients_type;
+ typedef const coefficients_type& result_type;
+
+ coefficients():max_degree_(0){}
+ coefficients(const coefficients& that)
+ :max_degree_(that.max_degree_),coeffs_(that.coeffs_){}
+ coefficients& operator=(const coefficients& that){
+ if(&that!=this){
+ max_degree_ = that.max_degree_;
+ coeffs_ = that.coeffs_;
+ }
+ return *this;
+ }
+
+ unsigned max_degree()const{ return max_degree_; }
+
+ result_type operator()()const{ return coeffs_; }
+
+ template<typename R>
+ void operator()(
+ value_type zscore_sqnorm,
+ const R& monomials,
+ value_type weight,
+ unsigned degree
+ ){
+ typedef typename range_iterator<const R>::type monoms_iter_type;
+ typedef typename range_value<R>::type monoms_value_type;
+
+ value_type c = exp(-zscore_sqnorm) * weight;
+ p2df_ir_type p2df_ir = mult_p2df::get(degree);
+ std::size_t adv_by
+ = monomials_properties<>::number_degree_less_than(
+ degree,SourceSz);
+ if(adv_by>((std::size_t)(size(coeffs_)))){
+ coeffs_.resize(adv_by,(value_type)(0));
+ }
+
+ BOOST_ASSERT( adv_by <= ((std::size_t)(size(monomials))) );
+ BOOST_ASSERT( adv_by <= ((std::size_t)(size(p2df_ir))) );
+ monoms_iter_type m_e = begin(monomials);
+ p2df_iter_type p2df_e =
+ begin(p2df_ir);
+ std::advance(m_e,adv_by);
+ std::advance(p2df_e,adv_by);
+
+ inner_op<monoms_value_type> io(c);
+
+ transform(
+ make_zip_iterator(
+ make_tuple(
+ begin(monomials),
+ begin(p2df_ir)
+ )
+ ),
+ make_zip_iterator(
+ make_tuple(
+ m_e,
+ p2df_e
+ )
+ ),
+ begin(coeffs_),
+ begin(coeffs_),
+ bind(
+ std::plus<value_type>(),
+ bind(
+ io,//ref?
+ _1
+ ),
+ _2
+ )
+ );
+
+ if(max_degree()<degree){max_degree_ = degree;}
+ }
+
+ private:
+ template<typename V>
+ struct inner_op{
+ typedef tuple<
+ const V&,const p2df_value_type&> argument_type;
+
+ typedef V result_type;
+ explicit inner_op(result_type c_):c(c_){}
+ inner_op(const inner_op& that):c(that.c){}
+ inner_op& operator=(const inner_op& that){
+ if(&that!=this){ c=that.c;}
+ return *this;}
+ result_type operator()(argument_type t){
+ const V& mon = t.template get<0>();
+ const p2df_value_type& p2df = t.template get<1>();
+
+ return mon * ((result_type)(p2df)) * c;
+ }
+ result_type c;
+ };//inner_op
+
+ unsigned max_degree_;
+ coefficients_type coeffs_;
+ };
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients_evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/detail/coefficients_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,155 @@
+//////////////////////////////////////////////////////////////////////////////
+// coefficients_evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_COLLECTED_SOURCES_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_COLLECTED_SOURCES_EVALUATOR_HPP_ER_2009
+#include <vector>
+#include <functional>
+#include <iterator>
+#include <cmath>
+#include <numeric>
+#include <stdexcept>
+#include <iostream> //TODO remove
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/range.hpp>
+#include <boost/math/ifgt/detail/zscore.hpp>
+#include <boost/math/monomials_properties.hpp>
+namespace boost{namespace math{namespace ifgt{
+
+ // coefficients_evaluator keeps a ref to a target
+ // each time a (coefficients,center,bandwidth) is passed to it,
+ // it returns the gauss transform, if the target
+ // is within a cutoff radius, 0 otherwise
+ //
+ // This class is primarly intended for use within clusters_evaluator.hpp
+
+ /// R0 ForwardRange (that of the target)
+ template<typename R0>
+ class coefficients_evaluator{
+
+ typedef typename range_value<R0>::type value_type;
+ typedef std::vector<value_type> vec_type;
+ typedef typename range_size<R0>::type target_size_type;
+ public:
+ typedef value_type result_type;
+ coefficients_evaluator(const R0& target):target_(target){}
+
+ coefficients_evaluator(const coefficients_evaluator& that)
+ :target_(that.target_){}
+
+ const R0& target()const{return target_; }
+ target_size_type target_size()const{return size(target()); }
+
+ template<typename R1,typename Coeffs>
+ result_type operator()(
+ result_type cutoff_radius,
+ const R1& center,
+ result_type bandwidth,
+ result_type inv_nc,
+ const Coeffs& coeffs
+ ){
+ return (*this)(
+ cutoff_radius,
+ center,
+ bandwidth,
+ inv_nc,
+ coeffs(),
+ coeffs.max_degree()
+ );
+ }
+
+ template<typename R1,typename R2>
+ result_type operator()(
+ //ignore target if dist to center less than:
+ result_type cutoff_radius,
+ const R1& center,
+ result_type bandwidth,
+ result_type inv_nc,
+ const R2& coefficients,
+ unsigned degree
+ )const{
+ typedef typename range_value<R0>::type value0_type;
+ typedef typename range_value<R1>::type value1_type;
+ typedef typename range_value<R2>::type value2_type;
+ //TODO check that value0_type == ValueType, likewise 1,2
+ BOOST_MPL_ASSERT((is_same<value_type,value1_type>));
+ BOOST_MPL_ASSERT((is_same<value_type,value2_type>));
+ BOOST_ASSERT((target_size_type)(size(center))==target_size());
+ {
+ unsigned n = monomials_properties<>::number_degree_less_than(
+ degree,(unsigned)(target_size())
+ );
+ BOOST_ASSERT((size(coefficients)-n>=0)||(degree == 0));
+ }
+
+ result_type res = (result_type)(0);
+ if(degree>0){
+
+ static vec_type zscore_val(target_size());
+ static monomials<vec_type> monoms;
+ typedef zscore<vec_type> zscore_type;
+ {
+ zscore_type zscore(center);
+ zscore(target(),bandwidth,zscore_val);
+ }
+
+ result_type zscore_sqnorm = std::inner_product(
+ begin(zscore_val),
+ end(zscore_val),
+ begin(zscore_val),
+ (result_type)(0)
+ );
+
+ //TODO rename target_radius
+ result_type sq_d = zscore_sqnorm * (bandwidth * bandwidth);
+
+ // Previously, which is wrong
+ // if( (sq_d<cutoff_radius)
+ // || (sq_d<cutoff_radius * cutoff_radius) ){
+ // Takes of the case cutoff_radius = highest()
+
+ result_type squared_cutoff = cutoff_radius * cutoff_radius;
+ if( sq_d< squared_cutoff ){
+ result_type gauss_kernel
+ = inv_nc * exp(-zscore_sqnorm);
+ monoms(zscore_val,degree);
+ res = std::inner_product(
+ begin(coefficients),
+ end(coefficients),
+ begin(monoms()),
+ (result_type)(0),
+ std::plus<result_type>(),
+ bind(
+ std::multiplies<result_type>(),
+ gauss_kernel,
+ bind(
+ std::multiplies<result_type>(),
+ _1,
+ _2
+ )
+ )
+ );
+ }
+ }
+ return res;
+ }
+ private:
+ coefficients_evaluator& operator=(
+ const coefficients_evaluator& that);
+ const R0& target_;
+ };
+
+ template<typename R0>
+ coefficients_evaluator<R0>
+ make_coefficients_evaluator(const R0& target){
+ return coefficients_evaluator<R0>(target);
+ }
+
+}}}
+
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/evaluator.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,68 @@
+//////////////////////////////////////////////////////////////////////////////
+// evaluator.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FAST_EVALUATOR_HPP_ER_2009
+#define BOOST_MATH_IFGT_FAST_EVALUATOR_HPP_ER_2009
+#include <stdexcept>
+#include <boost/math/ifgt/cutoff_radius/none.hpp>
+#include <boost/math/ifgt/fast/detail/clusters_evaluator.hpp>
+#include <boost/math/ifgt/detail/evaluator_common.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace fast{
+
+ //evaluator_base<
+ // evaluator_common<FastAccumulator>,
+ // fast_evaluator<
+ // FastAccumulator,
+ // CutoffRadiusPolicy>
+ //>
+
+ template<
+ typename FastAccumulator,
+ typename CutoffRadiusPolicy = cutoff_radius::none<mpl::_1>
+ >
+ class evaluator :
+ public evaluator_common<FastAccumulator>,
+ public crtp::evaluator<
+ evaluator<FastAccumulator,CutoffRadiusPolicy>
+ >
+ {
+ typedef evaluator_common<FastAccumulator> super_t;
+ typedef clusters_evaluator<
+ typename super_t::value_type,
+ CutoffRadiusPolicy
+ > eval_type;
+
+ public:
+
+ template<typename ArgPack>
+ evaluator(const ArgPack& arg) : super_t(arg),eval_(arg){}
+
+ evaluator(const evaluator& that)
+ :super_t(that),eval_(that.eval_){}
+
+ //TODO find a way to privatize
+ template<typename R0,typename R1,typename SubsetRangePolicy>
+ void call_impl(const R0& target, R1& range_out,
+ const SubsetRangePolicy& policy)const{
+ return eval_(
+ target,this->accumulator().clusters(),range_out,policy);
+ }
+
+ private:
+ evaluator& operator=(const evaluator& that);
+ evaluator();
+ eval_type eval_;
+ };
+
+}//fast
+}//ifgt
+}//math
+}//boost
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/find_nearest_cluster.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast/find_nearest_cluster.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////////
+// find_nearest_cluster.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FIND_NEAREST_CLUSTER_HPP_ER_2009
+#define BOOST_MATH_IFGT_FIND_NEAREST_CLUSTER_HPP_ER_2009
+#include <cmath>
+#include <stdexcept>
+#include <boost/function.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/algorithm/find_nearest_neighbor.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/math/ifgt/fast/detail/cluster.hpp>
+#include <boost/math/ifgt/fast/detail/cluster_call_center.hpp>
+
+namespace boost{namespace math{namespace ifgt{
+ template<typename R, typename Distance = l2_distance_squared>
+ class find_nearest_cluster{
+ typedef range_iterator<R> ri_type;
+ public:
+ typedef typename ri_type::type iter_type;
+ typedef typename range_value<R>::type cluster_type;
+
+ find_nearest_cluster(R& clusters):clusters_(clusters){}
+ find_nearest_cluster(const find_nearest_cluster& that)
+ :clusters_(that.clusters_){}
+ template<typename R0>
+ iter_type operator()(const R0& source){
+ typedef cluster_call_center<cluster_type> f_type;
+ typedef transform_iterator<f_type,iter_type>
+ iter_t_type;
+ typedef iterator_range<iter_t_type> ir_type;
+ f_type f;
+ ir_type ir(
+ iter_t_type(begin(clusters_),f),
+ iter_t_type(end(clusters_),f)
+ );
+
+ typedef find_nearest_neighbor<ir_type,Distance> find_type;
+
+ iter_type nn = find_type(ir)(source).base();
+ return nn;
+ }
+ private:
+ find_nearest_cluster& operator=(const find_nearest_cluster& that);
+ R& clusters_;
+ };
+
+}}}
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_accumulator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_accumulator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,258 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/fast_accumulator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FAST_ACCUMULATOR_IMPL_HPP_ER_2009
-#define BOOST_MATH_IFGT_FAST_ACCUMULATOR_IMPL_HPP_ER_2009
-#include <algorithm>
-#include <vector>
-#include <functional>
-#include <numeric>
-#include <boost/range.hpp>
-#include <boost/bind.hpp>
-#include <boost/mpl/placeholders.hpp>
-#include <boost/mpl/apply.hpp>
-#include <iostream> //TODO remove
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/math/ifgt/find_nearest_cluster.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
-#include <boost/math/ifgt/accumulator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-
- // fast_accumulator maintains a set of clusters, which is split
- // into an inactive and an active range. each time a (source,weight)
- // is passed to the object, only the active range is updated
- // i.e. either the source is collected at the nearest cluster within
- // that range,
- // or the a new cluster is added to the active range,
- // or the source is ignored if it equals the center of nearest cluster.
- // each time (bandwith,max_radius) is reset, the beginning
- // of the active range is to the end of the clusters range.
- // This (optional) feature is useful in applications where the bandwidth
- // is modified (usually decreased) in a piecewise-constant fashion.
- // The client can also use push_back_cluster to add a center
- // to the active range
-
- /// apply<FindClusterPolicy,Cluster>::type
- template<
- typename Cluster,
- typename FindClusterPolicy
- = find_nearest_cluster<mpl::_1, l2_distance_squared>
- >
- class fast_accumulator:
- public fast_accumulator_base<
- fast_accumulator<Cluster,FindClusterPolicy> >{
- public:
- typedef Cluster cluster_type;
- typedef typename cluster_type::center_type center_type;
- typedef typename cluster_type::value_type value_type;
- typedef typename cluster_type::coefficients_type
- coefficients_type;
- typedef typename cluster_type::collection_coefficients_type
- collection_coefficients_type;
- static const std::size_t source_size = cluster_type::source_size;
- static const std::size_t weight_size = cluster_type::weight_size;
- private:
- typedef std::vector<cluster_type> clusters_type;
- typedef typename clusters_type::size_type size_type;
- static size_type default_clusters_reserve_size(){
- static size_type sz = 1000; return sz; }
- typedef typename clusters_type::difference_type diff_type;
- typedef range_iterator<clusters_type> ri_type;
- typedef typename ri_type::type iter_type;
- typedef iterator_range<iter_type> active_range_type;
- typedef typename cluster_type::truncation_degree_policy_type
- truncation_degree_policy_type;
- public:
- typedef typename cluster_type::sources_count_type sources_count_type;
-
- //Construct
- fast_accumulator();
- template<typename ArgPack>
- fast_accumulator(const ArgPack& args);
- fast_accumulator(const fast_accumulator& that);
- //Assign
- fast_accumulator& operator=(const fast_accumulator& that);
-
- /// Triggers a new active range
- void set(value_type bandwidth,value_type max_radius);
- void set_truncation_degree_policy(
- const truncation_degree_policy_type& arg);
-
- //Access
- value_type active_bandwidth()const;
- value_type active_max_radius()const;
- const clusters_type& clusters()const;
- sources_count_type sources_count()const;
-
- //Update
- /// Used internally, but passing clusters directly also allowed.
- template<typename R>
- void push_back_cluster(const R& center);
-
- template<typename R0,typename R1>
- bool operator()(const R0& source, const R1& weight);
-
- private:
- active_range_type active_range();
- diff_type active_dist_to_;
- value_type active_bandwidth_;
- value_type active_max_radius_;
- truncation_degree_policy_type truncation_degree_policy_;
- clusters_type clusters_;
- };
-
- template<typename Cluster, typename FindClusterPolicy>
- fast_accumulator<Cluster,FindClusterPolicy>::fast_accumulator()
- : active_dist_to_((diff_type)(0)),
- active_bandwidth_((value_type)(0)),
- active_max_radius_((value_type)(0)),
- //make sure gen comp error if deflt constr inexistant
- truncation_degree_policy_(),
- clusters_()
- { clusters_.reserve(default_clusters_reserve_size()); }
-
- template<typename Cluster,typename FindClusterPolicy>
- template<typename ArgPack>
- fast_accumulator<Cluster,FindClusterPolicy>::fast_accumulator(
- const ArgPack& args)
- : active_dist_to_((diff_type)(0)),
- active_bandwidth_(args[tag::bandwidth|(value_type)(0)]),
- active_max_radius_(args[tag::max_cluster_radius|(value_type)(0)]),
- truncation_degree_policy_(args){
- clusters_.reserve(
- args[tag::clusters_reserve_size
- |default_clusters_reserve_size()]);
- }
-
- template<typename Cluster,typename FindClusterPolicy>
- fast_accumulator<Cluster,FindClusterPolicy>::fast_accumulator(
- const fast_accumulator& that)
- : active_dist_to_(that.active_dist_to_),
- active_bandwidth_(that.active_bandwidth_),
- active_max_radius_(that.active_max_radius_),
- clusters_(that.clusters_){}
-
- template<typename Cluster,typename FindClusterPolicy>
- typename fast_accumulator<Cluster,
- FindClusterPolicy>::fast_accumulator&
- fast_accumulator<Cluster,FindClusterPolicy>::operator=(
- const fast_accumulator& that){
- if(&that!=this){
- active_dist_to_ = that.active_dist_to_;
- active_bandwidth_ = that.active_bandwidth_;
- active_max_radius_ = that.active_max_radius_;
- clusters_ = that.clusters_;
- }
- return *this;
- }
-
- template<typename Cluster,typename FindClusterPolicy>
- void fast_accumulator<Cluster,FindClusterPolicy>::set(
- value_type bandwidth,value_type max_radius){
- active_bandwidth_ = bandwidth;
- active_max_radius_ = max_radius;
- active_dist_to_
- = std::distance(begin(clusters_), end(clusters_));
- }
-
- template<typename Cluster,typename FindClusterPolicy>
- void
- fast_accumulator<Cluster,
- FindClusterPolicy>::set_truncation_degree_policy(
- const truncation_degree_policy_type& truncation_degree_policy){
- truncation_degree_policy_ = truncation_degree_policy;
- }
-
- template<typename Cluster,typename FindClusterPolicy>
- typename fast_accumulator<Cluster,FindClusterPolicy>::value_type
- fast_accumulator<Cluster,FindClusterPolicy>::active_bandwidth()const{
- return active_bandwidth_; }
-
- template<typename Cluster,typename FindClusterPolicy>
- typename fast_accumulator<Cluster,FindClusterPolicy>::value_type
- fast_accumulator<Cluster,FindClusterPolicy>::active_max_radius()const{
- return active_max_radius_; }
-
- template<typename Cluster,typename FindClusterPolicy>
- typename fast_accumulator<Cluster,
- FindClusterPolicy>::active_range_type
- fast_accumulator<Cluster,FindClusterPolicy>::active_range(){
- iter_type i = begin(clusters_);
- std::advance(i,active_dist_to_);
- return active_range_type(i,end(clusters_));
- }
-
- template<typename Cluster, typename FindClusterPolicy>
- const typename fast_accumulator<Cluster,
- FindClusterPolicy>::clusters_type&
- fast_accumulator<Cluster,FindClusterPolicy>::clusters()const{
- return clusters_; }
-
- template<typename Cluster,typename FindClusterPolicy>
- typename fast_accumulator<Cluster,
- FindClusterPolicy>::sources_count_type
- fast_accumulator<Cluster,FindClusterPolicy>::sources_count()const{
- return std::accumulate(
- begin(clusters_),
- end(clusters_),
- (sources_count_type)(0),
- bind(
- std::plus<value_type>(),
- _1,
- bind(
- &cluster_type::sources_count,
- _2
- )
- )
- );
- }
-
- template<typename Cluster, typename FindClusterPolicy>
- template<typename R>
- void fast_accumulator<Cluster,FindClusterPolicy
- >::push_back_cluster(const R& center){
- clusters_.push_back(cluster_type(
- center,
- active_bandwidth(),
- active_max_radius(),
- truncation_degree_policy_
- ));
- }
-
- template<typename Cluster, typename FindClusterPolicy>
- template<typename R0,typename R1>
- bool fast_accumulator<Cluster,FindClusterPolicy>::operator()(
- const R0& source, const R1& weight){
- static bool is_collected = false;
- static active_range_type local_active_range = active_range();
- if(active_bandwidth()>(value_type)(0)){
- local_active_range = active_range();
- if(empty(local_active_range)){
- push_back_cluster(source);
- }else{
- typedef typename mpl::apply<FindClusterPolicy,
- active_range_type>::type find_nc_type;
-
- // TODO assigning local_active_range
- // and creating a new find_nc on each call maybe costly
- find_nc_type find_nc(local_active_range);
- iter_type nn = find_nc(source);
- is_collected = (*nn)(source,weight);
- if(nn->source_radius_exceeds_max_radius()){
- BOOST_ASSERT(!is_collected);
- push_back_cluster(source);
- }
- }
- }else{
- throw std::runtime_error("fast_accumulator::collect");
- }
- return is_collected;
- }
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_evaluator.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/fast_evaluator.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,58 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/fast_evaluator.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FAST_EVALUATOR_HPP_ER_2009
-#define BOOST_MATH_IFGT_FAST_EVALUATOR_HPP_ER_2009
-#include <stdexcept>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
-#include <boost/math/ifgt/clusters_evaluator.hpp>
-#include <boost/math/ifgt/evaluator_common.hpp>
-#include <boost/math/ifgt/evaluator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- template<
- typename FastAccumulator,
- typename CutoffRadiusPolicy = cutoff_radius_none<mpl::_1>
- >
- class fast_evaluator : public
- evaluator_base<
- evaluator_common<FastAccumulator>,
- fast_evaluator<
- FastAccumulator,
- CutoffRadiusPolicy>
- >{
-
- typedef fast_evaluator<FastAccumulator,CutoffRadiusPolicy> self_type;
- typedef evaluator_common<FastAccumulator> c_type;
- typedef evaluator_base<c_type,self_type> base_type;
-// typedef typename base_type::value_type value_type;
- typedef clusters_evaluator<typename fast_evaluator::value_type,
- CutoffRadiusPolicy> eval_type;
-
- public:
-
- template<typename ArgPack>
- fast_evaluator(const ArgPack& arg) : base_type(arg),eval_(arg){}
-
- fast_evaluator(const fast_evaluator& that)
- :base_type(that),eval_(that.eval_){}
-
- //TODO find a way to privatize
- template<typename R0,typename R1,typename SubsetRangePolicy>
- void call_impl(const R0& target, R1& range_out,
- const SubsetRangePolicy& policy)const{
- return eval_(
- target,this->accumulator().clusters(),range_out,policy);
- }
-
- private:
- fast_evaluator& operator=(const fast_evaluator& that);
- fast_evaluator();
- eval_type eval_;
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/find_nearest_cluster.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/find_nearest_cluster.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,53 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/find_nearest_cluster.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FIND_NEAREST_CLUSTER_HPP_ER_2009
-#define BOOST_MATH_IFGT_FIND_NEAREST_CLUSTER_HPP_ER_2009
-#include <cmath>
-#include <stdexcept>
-#include <boost/function.hpp>
-#include <boost/range/value_type.hpp>
-#include <boost/mpl/assert.hpp>
-#include <boost/algorithm/find_nearest_neighbor.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/math/ifgt/cluster.hpp>
-#include <boost/math/ifgt/cluster_call_center.hpp>
-
-namespace boost{namespace math{namespace ifgt{
- template<typename R, typename Distance = l2_distance_squared>
- class find_nearest_cluster{
- typedef range_iterator<R> ri_type;
- public:
- typedef typename ri_type::type iter_type;
- typedef typename range_value<R>::type cluster_type;
-
- find_nearest_cluster(R& clusters):clusters_(clusters){}
- find_nearest_cluster(const find_nearest_cluster& that)
- :clusters_(that.clusters_){}
- template<typename R0>
- iter_type operator()(const R0& source){
- typedef cluster_call_center<cluster_type> f_type;
- typedef transform_iterator<f_type,iter_type>
- iter_t_type;
- typedef iterator_range<iter_t_type> ir_type;
- f_type f;
- ir_type ir(
- iter_t_type(begin(clusters_),f),
- iter_t_type(end(clusters_),f)
- );
-
- typedef find_nearest_neighbor<ir_type,Distance> find_type;
-
- iter_type nn = find_type(ir)(source).base();
- return nn;
- }
- private:
- find_nearest_cluster& operator=(const find_nearest_cluster& that);
- R& clusters_;
- };
-
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/accumulate.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/accumulate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////////
+// accumulate.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_HPP_ER_2009
+#define BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_HPP_ER_2009
+#include <boost/mpl/size.hpp>
+#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
+#include <boost/math/ifgt/crtp/accumulator.hpp>
+#include <boost/math/ifgt/for_each/detail/make_traits.hpp>
+
+namespace boost{namespace math{namespace ifgt{
+
+ template<typename R0, typename R1, typename D>
+ void for_each_accumulate(
+ const R0& sources,
+ const R1& weights,
+ crtp::accumulator<D>& d
+ ){
+
+ typedef make_traits<D,D::source_size,D::weight_size> traits;
+ typedef for_each_over_2_vector2matrix<traits> for_each_type;
+ D& d_ = static_cast<D&>(d);
+ for_each_type f(d_);
+ f(sources,weights);
+ };
+
+}}}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/detail/make_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/detail/make_traits.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+// make_traits.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_MAKE_TRAITS_HPP_ER_2009
+#define BOOST_MATH_IFGT_MAKE_TRAITS_HPP_ER_2009
+#include <boost/mpl/size_t.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+
+template<typename T, std::size_t stride0, std::size_t stride1>
+struct make_traits{
+ typedef T type;
+ typedef mpl::size_t<stride0> stride0_type;
+ typedef mpl::size_t<stride1> stride1_type;
+};
+
+
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/evaluate.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/evaluate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+// evaluate.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_IFGT_FOR_EACH_EVALUATE_HPP_ER_2009
+#define BOOST_IFGT_FOR_EACH_EVALUATE_HPP_ER_2009
+#include <algorithm>
+#include <boost/ref.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
+#include <boost/math/ifgt/for_each/detail/make_traits.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+// Usage: for_each_evaluate<M>(targets,ranges_out,e)
+// M : method for evaluating : meta::gauss_transform, meta::nadaraya_watson
+template<
+ typename M,
+ typename R0, typename R1,
+ typename D
+>
+void for_each_evaluate(
+ const R0& targets,//t[0][0],...,t[0][D],...,t[n-1][0],...,t[n-1][D]
+ R1& ranges_out, //r[0][0],...,r[0][J-1],...,r[n-1][0],...,r[n-1][J-1]
+ const crtp::evaluator<D>& e
+){
+ typedef typename mpl::apply1<M,D>::type call_type;
+ typedef make_traits<
+ call_type,
+ call_type::stride0,
+ call_type::stride1
+ > traits;
+
+ typedef for_each_over_2_vector2matrix<traits> for_each_type;
+ const D& e_ = static_cast<const D&>(e);
+ call_type call(e_);
+ for_each_type f( call );
+ f(targets,ranges_out);
+}
+
+
+
+}//ifgt
+}//math
+}//boost
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/front_insert_1.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/front_insert_1.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////////
+// front_insert_1.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FOR_EACH_FRONT_INSERT_1_HPP_ER_2009
+#define BOOST_MATH_IFGT_FOR_EACH_FRONT_INSERT_1_HPP_ER_2009
+#include <boost/range.hpp>
+#include <boost/iterator/insert_element_every_n_step_iterator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+ template<typename std::size_t final_weight_size,typename R1>
+ typename
+ result_of_make_range_insert_element_every_n_step<const R1>::type
+ for_each_front_insert_1(const R1& range_rest_weight){
+ typedef typename range_value<R1>::type value_type;
+ return make_range_insert_element_every_n_step(
+ range_rest_weight,
+ static_cast<value_type>(1),
+ final_weight_size - 1
+ );
+ }
+
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/gauss_transform.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/gauss_transform.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////////
+// gauss_transform.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_IFGT_FOR_EACH_GAUSS_TRANSFORM_HPP_ER_2009
+#define BOOST_IFGT_FOR_EACH_GAUSS_TRANSFORM_HPP_ER_2009
+#include <algorithm>
+#include <boost/ref.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
+#include <boost/iterator/range_same.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/math/ifgt/functor/gauss_transform.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+// Evaluates each target using a method and writes to a set of ranges
+// Usage: for_each<M>(targets,ranges_out,e)
+template<
+ typename R0, typename R1,
+ typename D
+>
+void for_each_gauss_transform(
+ const R0& targets,//t[0][0],...,t[0][D],...,t[n-1][0],...,t[n-1][D]
+ R1& ranges_out, //r[0][0],...,r[0][J-1],...,r[n-1][0],...,r[n-1][J-1]
+ const crtp::evaluator<D>& e
+){
+ typedef meta::gauss_transform<> meta_t;
+ return for_each_evaluate<meta_t>(
+ targets,
+ ranges_out,
+ e
+ );
+}
+
+
+}//ifgt
+}//math
+}//boost
+
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/nadaraya_watson.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/nadaraya_watson.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////////
+// nadaraya_watson.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_IFGT_FOR_EACH_NADARAYA_WATSON_HPP_ER_2009
+#define BOOST_IFGT_FOR_EACH_NADARAYA_WATSON_HPP_ER_2009
+#include <algorithm>
+#include <boost/ref.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/math/ifgt/functor/nadaraya_watson.hpp>
+#include <boost/math/ifgt/for_each/evaluate.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+// Evaluates each target using a method and writes to a set of ranges
+// Usage: for_each<M>(targets,ranges_out,e)
+template<
+ typename R0, typename R1,
+ typename D
+>
+void for_each_nadaraya_watson(
+ const R0& targets,//t[0][0],...,t[0][D],...,t[n-1][0],...,t[n-1][D]
+ R1& ranges_out, //r[0][0],...,r[0][J-1],...,r[n-1][0],...,r[n-1][J-1]
+ const crtp::evaluator<D>& e
+){
+ typedef meta::nadaraya_watson<> meta_t;
+ return for_each_evaluate<meta_t>(
+ targets,
+ ranges_out,
+ e
+ );
+}
+
+}//ifgt
+}//math
+}//boost
+
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/rozenblatt_parzen.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/rozenblatt_parzen.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+// rozenblatt_parzen.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_IFGT_FOR_EACH_ROZENBLATT_PARZEN_HPP_ER_2009
+#define BOOST_IFGT_FOR_EACH_ROZENBLATT_PARZEN_HPP_ER_2009
+#include <algorithm>
+#include <boost/ref.hpp>
+#include <boost/range.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/iterator/vector2matrix_iterator.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/math/ifgt/functor/rozenblatt_parzen.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+template<typename R0,typename R1,typename D>
+void for_each_rozenblatt_parzen(
+ const R0& targets,//t[0][0],...,t[0][D],...,t[n-1][0],...,t[n-1][D]
+ R1& ranges_out, //r[0],...,r[n-1]
+ const crtp::evaluator<D>& e
+){
+ const std::size_t stride = D::source_size;
+ const D& e_ = static_cast<const D&>(e);
+ std::transform(
+ make_vector2matrix_iterator(begin(targets),stride),
+ make_end_vector2matrix_iterator(begin(targets),end(targets),
+ stride),
+ begin(ranges_out),
+ make_rozenblatt_parzen(e_)
+ );
+}
+
+
+}//ifgt
+}//math
+}//boost
+
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////////
+// weight_front_insert_1_accumulate.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FOR_EACH_WEIGHT_FRONT_INSERT_1_ACCUMULATE_HPP_ER_2009
+#define BOOST_MATH_IFGT_FOR_EACH_WEIGHT_FRONT_INSERT_1_ACCUMULATE_HPP_ER_2009
+#include <boost/range.hpp>
+#include <boost/math/ifgt/crtp/accumulator.hpp>
+#include <boost/math/ifgt/for_each/accumulate.hpp>
+#include <boost/math/ifgt/for_each/front_insert_1.hpp>
+
+namespace boost{namespace math{namespace ifgt{
+
+ template<typename R0, typename R1, typename D>
+ void for_each_weight_front_insert_1_accumulate(
+ const R0& sources,
+ const R1& weights,
+ crtp::accumulator<D>& d
+ ){
+ return
+ for_each_accumulate(
+ sources,
+ for_each_front_insert_1<D::weight_size>(weights),
+ d
+ );
+ }
+
+}}}
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,28 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/for_each_accumulate.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_HPP_ER_2009
-#define BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_HPP_ER_2009
-#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
-#include <boost/math/ifgt/traits.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- template<typename R0, typename R1, typename Acc>
- void for_each(
- const R0& sources,
- const R1& weights,
- accumulator_base<Acc>& acc
- ){
- typedef Acc derived_type;
- typedef traits<derived_type> the_traits;
- typedef for_each_over_2_vector2matrix<the_traits> for_each_type;
- derived_type& derived = static_cast<derived_type&>(acc);
- for_each_type f(derived);
- f(sources,weights);
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate_rest_weights.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_accumulate_rest_weights.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,36 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/for_each_accumulate_rest_weights.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_REST_WEIGHTS_HPP_ER_2009
-#define BOOST_MATH_IFGT_FOR_EACH_ACCUMULATE_REST_WEIGHTS_HPP_ER_2009
-#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
-#include <boost/iterator/insert_element_every_n_step_iterator.hpp>
-#include <boost/math/ifgt/for_each_accumulate.hpp>
-#include <boost/math/ifgt/rest_weights_wrapper.hpp>
-
-namespace boost{namespace math{namespace ifgt{
-
- template<typename R0, typename R1, typename Acc>
- void for_each(
- const R0& sources,
- const rest_weights_wrapper<R1>& rw,
- accumulator_base<Acc>& acc
- ){
-
- typedef typename result_of_make_range_insert_element_every_n_step<
- const R1>::type weights_type;
- std::size_t n = Acc::weight_size - 1;
- BOOST_ASSERT(n>0);
- weights_type weights = make_range_insert_element_every_n_step(
- rw(),
- 1.0,
- n
- );
- for_each(sources,weights,acc);
- }
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_evaluate.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_evaluate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,34 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/for_each_evaluate.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_IFGT_FOR_EACH_EVALUATE_HPP_ER_2009
-#define BOOST_IFGT_FOR_EACH_EVALUATE_HPP_ER_2009
-#include <algorithm>
-#include <boost/ref.hpp>
-#include <boost/iterator/for_each_over_2_vector2matrix.hpp>
-#include <boost/math/ifgt/traits.hpp>
-#include <boost/math/ifgt/evaluator_base.hpp>
-#include <boost/math/ifgt/call_wrapper.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<
- typename R0, typename R1,
- typename Common, typename Derived,template<typename> class Method>
-void for_each(
- const R0& targets,
- R1& ranges_out,
- const evaluator_base<Common,Derived>& e,
- const call<Method>& method
-){
- typedef Method<Derived> call_type;
- typedef ifgt::call_traits<call_type> traits;
- typedef for_each_over_2_vector2matrix<traits> for_each_type;
- call_type call(e);
- for_each_type f( call );
- f(targets,ranges_out);
-}
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_rozenblatt_parzen_estimate.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/for_each_rozenblatt_parzen_estimate.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,34 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/for_each_rozenblatt_parzen_estimate.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_FOR_EACH_ROZENBLATT_PARZEN_ESTIMATE_HPP_ER_2009
-#define BOOST_MATH_IFGT_FOR_EACH_ROZENBLATT_PARZEN_ESTIMATE_HPP_ER_2009
-#include <algorithm>
-#include <boost/bind.hpp>
-#include <boost/ref.hpp>
-#include <boost/iterator/vector2matrix_iterator.hpp>
-#include <boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp>
-#include <boost/math/ifgt/call_wrapper.hpp>
-#include <boost/math/ifgt/evaluator_base.hpp>
-namespace boost{namespace math{namespace ifgt{
-template<typename R0, typename R1, typename Common,typename Derived>
-void for_each(
- const R0& targets,
- R1& ranges_out,
- const evaluator_base<Common,Derived>& e,
- const call<rozenblatt_parzen_estimate>& method
-){
- const std::size_t stride = Derived::source_size;
- transform(
- make_vector2matrix_iterator(begin(targets),stride),
- make_end_vector2matrix_iterator(begin(targets),end(targets),
- stride),
- begin(ranges_out),
- make_rozenblatt_parzen_estimate(e)
- );
-}
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/gauss_transform.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/gauss_transform.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,74 @@
+//////////////////////////////////////////////////////////////////////////////
+// gauss_transform.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FUNCTOR_GAUSS_TRANSFORM_HPP_ER_2009
+#define BOOST_MATH_IFGT_FUNCTOR_GAUSS_TRANSFORM_HPP_ER_2009
+#include <vector>
+#include <boost/assert.hpp>
+#include <boost/iterator/range_same.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/size_t.hpp>
+#include <boost/iterator/range_result_size.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+namespace impl{
+ // P : SubsetRangePolicy
+ template<typename D,typename P>
+ class gauss_transform{
+ public:
+ typedef void result_type;
+ static const std::size_t weight_size = D::weight_size;
+ static const std::size_t stride0 = D::source_size;
+ static const std::size_t stride1
+ = range_result_size<P,weight_size>::type::value;
+
+ gauss_transform(const D& e)
+ :eval_(e),policy_(P()){}
+
+// gauss_transform(const D& e,const P& pol)
+// :eval_(e),policy_(pol){}
+
+ gauss_transform(const gauss_transform& that)
+ : eval_(that.eval_),policy_(that.policy_){}
+
+ // Warning : adds to range_out
+ template<typename R0,typename R1>
+ void operator()(const R0& target,R1& range_out)const{
+ eval_.call_impl(target,range_out,policy_);
+ }
+
+ private:
+ gauss_transform& operator=(const gauss_transform& that);
+ const D& eval_;
+ P policy_;
+ };
+}
+namespace meta{
+ template<typename P = range_same>
+ struct gauss_transform{
+ template<typename D>
+ struct apply{
+ typedef impl::gauss_transform<D,P> type;
+ };
+ };
+}
+
+template<typename D>
+typename mpl::apply1<meta::gauss_transform<>,D>::type
+make_gauss_transform(const D& e){
+ typedef typename mpl::apply1<meta::gauss_transform<>,D>::type
+ result_type;
+ return result_type(e);
+}
+
+}//ifgt
+}//math
+}//boost
+
+#endif // GAUSS_TRANSFORM_HPP_INCLUDED

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/nadaraya_watson.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/nadaraya_watson.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,108 @@
+//////////////////////////////////////////////////////////////////////////////
+// nadaraya_watson.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FUNCTOR_NADARAYA_WATSON_HPP_ER_2009
+#define BOOST_MATH_IFGT_FUNCTOR_NADARAYA_WATSON_HPP_ER_2009
+#include <vector>
+#include <algorithm>
+#include <boost/mpl/size_t.hpp>
+#include <boost/mpl/prior.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/iterator/range_result.hpp>
+#include <boost/iterator/range_result_size.hpp>
+#include <boost/iterator/range_right.hpp>
+#include <boost/iterator/range_same.hpp>
+#include <boost/math/ifgt/functor/gauss_transform.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/utility/result_of.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace impl{
+
+ // P models SubsetRangePolicy (for now not used)
+ // TODO Make use of P
+ template<typename D,typename P = mpl::void_>
+ class nadaraya_watson{
+ typedef typename D::value_type value_type;
+ static const std::size_t weight_size = D::weight_size;
+
+ public:
+ typedef void result_type;
+ static const std::size_t stride0 = D::source_size;
+ static const std::size_t stride1 = weight_size-1;
+
+ nadaraya_watson(const D& e)
+ :eval_(e){}
+
+// nadaraya_watson(const D& e,const P& pol)
+// :eval_(e){}
+
+ nadaraya_watson(const nadaraya_watson& that) : eval_(that.eval_){}
+
+ // Requires weight[0]==1
+ // Initializes range_out to zero and writes NW to it
+ template<typename R0,typename R1>
+ void operator()(const R0& target,R1& range_out)const{
+ typedef std::vector<value_type> range_type;
+ typedef range_right<weight_size-1> policy_type;
+ typedef typename boost::result_of<
+ policy_type(const range_type&)>::type
+ rest_type;
+ static range_type range(weight_size);
+ static policy_type policy;
+ BOOST_ASSERT(size(range_out)-(weight_size-1)==0);
+ std::fill(
+ begin(range),
+ end(range),
+ (value_type)(0)
+ );
+ typedef typename
+ mpl::apply1<meta::gauss_transform<range_same>,D>::type gt_t;
+ gt_t gt(eval_);
+ gt(target,range);
+ value_type denom = range[0];
+ rest_type rest = policy(range);
+ BOOST_ASSERT(size(rest)-(weight_size-1)==0);
+ std::transform(
+ begin(rest),
+ end(rest),
+ begin(range_out),
+ bind(std::divides<value_type>(), _1, denom)
+ );
+ }
+
+
+ private:
+ nadaraya_watson& operator=(const nadaraya_watson& that);
+ const D& eval_;
+ };
+}
+namespace meta{
+ template<typename P = mpl::void_>
+ struct nadaraya_watson{
+ template<typename D>
+ struct apply : mpl::identity<impl::nadaraya_watson<D,P> >{};
+ };
+}
+
+template<typename D>
+typename mpl::apply1<meta::nadaraya_watson<>,D>::type
+make_nadaraya_watson(const D& e){
+ typedef typename
+ mpl::apply1<meta::nadaraya_watson<>,D>::type result_type;
+ return result_type(e);
+}
+
+}//ifgt
+}//math
+}//boost
+
+#endif // NADARAYA_WATSON_ESTIMATE_HPP_INCLUDED

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/rozenblatt_parzen.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/functor/rozenblatt_parzen.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,76 @@
+//////////////////////////////////////////////////////////////////////////////
+// rozenblatt_parzen.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_FUNCTOR_ROZENBLATT_PARZEN_HPP_ER_2009
+#define BOOST_MATH_IFGT_FUNCTOR_ROZENBLATT_PARZEN_HPP_ER_2009
+#include <stdexcept>
+#include <vector>
+#include <algorithm>
+#include <boost/assert.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/size_t.hpp>
+#include <boost/iterator/range_result_size.hpp>
+#include <boost/iterator/range_right.hpp>
+#include <boost/iterator/range_left.hpp>
+#include <boost/math/ifgt/crtp/evaluator.hpp>
+#include <boost/math/ifgt/functor/gauss_transform.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+
+
+ template<typename D>
+ class rozenblatt_parzen{
+ public:
+ typedef typename D::value_type result_type;
+
+ rozenblatt_parzen(const D& e)
+ :eval_(e){}
+
+ rozenblatt_parzen(const rozenblatt_parzen& that)
+ : eval_(that.eval_){}
+
+ rozenblatt_parzen& operator=(
+ const rozenblatt_parzen& that){
+ BOOST_ASSERT(&that!=this);
+ }
+
+
+ template<typename R0>
+ result_type operator()(const R0& target)const{
+ typedef std::vector<result_type> range_type;
+ typedef range_left<1> policy_type;
+ typedef meta::gauss_transform<policy_type> meta_gauss;
+ typedef typename mpl::apply1<meta_gauss,D>::type gt_t;
+ static range_type range(1);
+ range[0] = static_cast<result_type>(0);
+ gt_t gt(eval_);
+ gt(target,range);
+ result_type count
+ = static_cast<result_type>(eval_.sources_count());
+ range[0]/=count;
+ return range[0];
+ }
+
+ private:
+ rozenblatt_parzen();
+
+ const D& eval_;
+ };
+
+
+template<typename D>
+rozenblatt_parzen<D>
+make_rozenblatt_parzen(const D& e){
+ typedef rozenblatt_parzen<D> result_type;
+ return result_type(e);
+}
+
+}
+}
+}
+
+#endif

Modified: sandbox/improved_fast_gauss_transform/boost/math/ifgt/include.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/include.hpp (original)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/include.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,28 +1,29 @@
 //////////////////////////////////////////////////////////////////////////////
-// ifgt/include.hpp
+// include.hpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #ifndef BOOST_MATH_IFGT_INCLUDE_HPP_ER_2009
 #define BOOST_MATH_IFGT_INCLUDE_HPP_ER_2009
-#include <boost/math/ifgt/call_gauss_transform.hpp>
-#include <boost/math/ifgt/call_nadaraya_watson_estimate.hpp>
-#include <boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp>
-#include <boost/math/ifgt/call_wrapper.hpp>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
-#include <boost/math/ifgt/cutoff_radius_rydg.hpp>
-#include <boost/math/ifgt/exact_accumulator.hpp>
-#include <boost/math/ifgt/exact_evaluator.hpp>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/fast_evaluator.hpp>
-#include <boost/math/ifgt/find_nearest_cluster.hpp>
-#include <boost/math/ifgt/for_each_accumulate.hpp>
-#include <boost/math/ifgt/for_each_accumulate_rest_weights.hpp>
-#include <boost/math/ifgt/for_each_evaluate.hpp>
-#include <boost/math/ifgt/for_each_rozenblatt_parzen_estimate.hpp>
-#include <boost/math/ifgt/optimal_bandwidth.hpp>
-#include <boost/math/ifgt/optimal_parameter_given_max_degree.hpp>
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
+#include <boost/math/ifgt/benchmark.hpp>
+#include <boost/math/ifgt/bandwidth/normal_plug_in.hpp>
+#include <boost/math/ifgt/cutoff_radius/none.hpp>
+#include <boost/math/ifgt/cutoff_radius/rydg.hpp>
+#include <boost/math/ifgt/cluster_radius/at_max_degree.hpp>
+#include <boost/math/ifgt/exact/accumulator.hpp>
+#include <boost/math/ifgt/exact/evaluator.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/fast/evaluator.hpp>
+#include <boost/math/ifgt/fast/find_nearest_cluster.hpp>
+#include <boost/math/ifgt/for_each/accumulate.hpp>
+#include <boost/math/ifgt/for_each/evaluate.hpp>
+#include <boost/math/ifgt/for_each/front_insert_1.hpp>
+#include <boost/math/ifgt/for_each/rozenblatt_parzen.hpp>
+#include <boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp>
+#include <boost/math/ifgt/functor/gauss_transform.hpp>
+#include <boost/math/ifgt/functor/nadaraya_watson.hpp>
+#include <boost/math/ifgt/functor/rozenblatt_parzen.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
 #endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/keyword.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/keyword.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,159 @@
+//////////////////////////////////////////////////////////////////////////////
+// keyword.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_KEYWORD_HPP_ER_2009
+#define BOOST_MATH_IFGT_KEYWORD_HPP_ER_2009
+#include <boost/parameter/parameters.hpp>
+#include <boost/parameter/keyword.hpp>
+namespace boost{namespace math{namespace ifgt{
+namespace tag{
+ template<typename Id> struct bandwidth_{};
+ template<typename Id> struct max_cluster_radius_{};
+ template<typename Id> struct degree_{};
+ template<typename Id> struct clusters_{};
+ template<typename Id> struct center_{};
+ template<typename Id> struct target_{};
+ template<typename Id> struct range_out_{};
+ template<typename Id> struct error_tolerance_{};
+ template<typename Id> struct max_distance_source_target_{};
+ template<typename Id> struct cutoff_radius_policy_{};
+ template<typename Id> struct clusters_reserve_size_{};
+ template<typename Id> struct contributions_reserve_size_{};
+ template<typename Id> struct accumulator_{};
+ template<typename Id> struct nadaraya_watson_check_tolerance_{};
+ template<typename Id> struct divide_by_{};
+}
+namespace{
+ template<typename Id = mpl::void_>
+ struct kwd{
+
+ static
+ ::boost::parameter::keyword<tag::bandwidth_<Id> >& bandwidth;
+ static
+ ::boost::parameter::keyword<tag::max_cluster_radius_<Id> >&
+ max_cluster_radius;
+ static
+ ::boost::parameter::keyword<tag::degree_<Id> >& degree;
+ static
+ ::boost::parameter::keyword<tag::clusters_<Id> >& clusters;
+ static
+ ::boost::parameter::keyword<tag::center_<Id> >& center;
+ static
+ ::boost::parameter::keyword<tag::target_<Id> >& target;
+ static
+ ::boost::parameter::keyword<tag::range_out_<Id> >& range_out;
+ static
+ ::boost::parameter::keyword<tag::error_tolerance_<Id> >&
+ error_tolerance;
+ static
+ ::boost::parameter::keyword<
+ tag::max_distance_source_target_<Id> >&
+ max_distance_source_target;
+ static
+ ::boost::parameter::keyword<
+ tag::cutoff_radius_policy_<Id> >&
+ cutoff_radius_policy;
+ static
+ ::boost::parameter::keyword<tag::clusters_reserve_size_<Id> >&
+ clusters_reserve_size;
+ static
+ ::boost::parameter::keyword<
+ tag::contributions_reserve_size_<Id> >&
+ contributions_reserve_size;
+ static
+ ::boost::parameter::keyword<tag::divide_by_<Id> >&
+ divide_by;
+ static
+ ::boost::parameter::keyword<tag::accumulator_<Id> >&
+ accumulator;
+
+ static
+ ::boost::parameter::keyword<
+ tag::nadaraya_watson_check_tolerance_<Id> >&
+ nadaraya_watson_check_tolerance;
+
+ };
+
+ template<typename Id>
+ ::boost::parameter::keyword<tag::bandwidth_<Id> >&
+ kwd<Id>::bandwidth
+ = ::boost::parameter::keyword<tag::bandwidth_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::max_cluster_radius_<Id> >&
+ kwd<Id>::max_cluster_radius
+ =
+ ::boost::parameter::keyword<
+ tag::max_cluster_radius_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::degree_<Id> >&
+ kwd<Id>::degree
+ = ::boost::parameter::keyword<tag::degree_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::clusters_<Id> >&
+ kwd<Id>::clusters
+ = ::boost::parameter::keyword<tag::clusters_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::center_<Id> >&
+ kwd<Id>::center
+ = ::boost::parameter::keyword<tag::center_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::target_<Id> >&
+ kwd<Id>::target
+ = ::boost::parameter::keyword<tag::target_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::range_out_<Id> >&
+ kwd<Id>::range_out
+ = ::boost::parameter::keyword<tag::range_out_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::error_tolerance_<Id> >&
+ kwd<Id>::error_tolerance
+ = ::boost::parameter::keyword<tag::error_tolerance_<Id>
+ >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::max_distance_source_target_<Id>
+ >&
+ kwd<Id>::max_distance_source_target
+ =
+ ::boost::parameter::keyword<tag::max_distance_source_target_<Id>
+ >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::cutoff_radius_policy_<Id> >&
+ kwd<Id>::cutoff_radius_policy
+ = ::boost::parameter::keyword<tag::cutoff_radius_policy_<Id>
+ >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::clusters_reserve_size_<Id> >&
+ kwd<Id>::clusters_reserve_size
+ = ::boost::parameter::keyword<tag::clusters_reserve_size_<Id>
+ >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::contributions_reserve_size_<Id>
+ >&
+ kwd<Id>::contributions_reserve_size
+ =
+ ::boost::parameter::keyword<tag::contributions_reserve_size_<Id>
+ >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::divide_by_<Id> >&
+ kwd<Id>::divide_by
+ = ::boost::parameter::keyword<
+ tag::divide_by_<Id> >::get();
+ template<typename Id>
+ ::boost::parameter::keyword<tag::accumulator_<Id> >&
+ kwd<Id>::accumulator
+ = ::boost::parameter::keyword<tag::accumulator_<Id> >::get();
+
+ template<typename Id>
+ ::boost::parameter::keyword<
+ tag::nadaraya_watson_check_tolerance_<Id> >&
+ kwd<Id>::nadaraya_watson_check_tolerance
+ = ::boost::parameter::keyword<
+ tag::nadaraya_watson_check_tolerance_<Id> >::get();
+}//anonymous
+}//ifgt
+}//math
+}//boost
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/normal_kernel_properties.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/normal_kernel_properties.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,39 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/normal_kernel_properties.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_NORMAL_KERNEL_PROPERTIES_HPP_ER_2009
-#define BOOST_MATH_IFGT_NORMAL_KERNEL_PROPERTIES_HPP_ER_2009
-#include <cmath>
-namespace boost{namespace math{namespace ifgt{
- // Normal kernel : exp(-(1/2)||(x-y)/sigma||^2) (2*pi*sigma^2)^(-d/2)
- // Note that the bandwidth is h = sqrt(2) * sigma
- template<unsigned SourceSz,typename RealType = double>
- struct normal_kernel_properties{
- typedef RealType value_type;
- static const std::size_t source_size = SourceSz;
- static value_type
- pi(){
- static value_type
- val = 3.14159265358979323846264338327950288419716939937510;
- return val;
- }
- static value_type normalizing_constant(
- value_type sigma
- ){
- static value_type d = (value_type)(SourceSz);
- static value_type sqrt2pi = sqrt((value_type)(2)*pi());
- return std::pow(sigma*sqrt2pi,d);
- }
- static value_type normalizing_constant(
- value_type sigma,
- std::size_t n
- ){
- return (value_type)(n) * normalizing_constant(sigma);
- }
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_bandwidth.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_bandwidth.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,48 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/optimal_bandwidth.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_OPTIMAL_BANDWIDTH_FOR_DENSITY_ESTIMATION_UNDER_NORMALITY_HPP_ER_2009
-#define BOOST_MATH_IFGT_OPTIMAL_BANDWIDTH_FOR_DENSITY_ESTIMATION_UNDER_NORMALITY_HPP_ER_2009
-#include <cmath>
-namespace boost{namespace math{namespace ifgt{
-// \warning the sart(2)*sigma adjustmnent is needed so that
-// the kernel is exp(-||(x-y)/h||^2) = exp(-(1/2)||(x-y)/sigma||^2)
-template<std::size_t Dimension, typename RealType = double>
-struct optimal_bandwidth{
- typedef RealType value_type;
- static value_type for_density_estimation_under_normality(
- value_type sigma,
- std::size_t count
- );
- ///Assumes sigma = 1;
- static value_type for_density_estimation_under_normality(
- std::size_t count);
-
-};
-
-template<std::size_t Dimension, typename RealType>
-typename optimal_bandwidth<Dimension,RealType>::value_type
-optimal_bandwidth<Dimension,RealType>::for_density_estimation_under_normality(
- value_type sigma, std::size_t count){
- static const value_type sqrt2 = sqrt(2.0);
- static const value_type d = (value_type)(Dimension);
- static const value_type e = -(value_type)(1)/((value_type)(d+4));
- value_type n = (value_type)(count);
- value_type a = (n * (value_type)(2+d))/ ((value_type)(4));
- return sigma * std::pow( a, e ) * sqrt2;
-}
-
-template<std::size_t Dimension, typename RealType>
-typename optimal_bandwidth<Dimension,RealType>::value_type
-optimal_bandwidth<Dimension,RealType>::for_density_estimation_under_normality(
-std::size_t count){
- return for_density_estimation_under_normality(
- (value_type)(1),
- count);
-}
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_parameter_given_max_degree.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/optimal_parameter_given_max_degree.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,167 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/optimal_parameter_given_max_degree.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_OPTIMAL_PARAMETER_GIVEN_MAX_DEGREE_HPP_ER_2009
-#define BOOST_MATH_IFGT_OPTIMAL_PARAMETER_GIVEN_MAX_DEGREE_HPP_ER_2009
-#include <stdexcept>
-#include <boost/math/ifgt/detail/divider.hpp>
-#include <boost/math/ifgt/cutoff_radius_rydg.hpp>
-#include <boost/math/ifgt/truncation_properties.hpp>
-namespace boost{ namespace math{ namespace ifgt{
-
-/// Finds optimal max cluster radius recursively,
-/// given a cutoff radius policy and a maximum degree p.
-template<
- typename RealType,
- template<typename> class CutoffRadiusPolicy = cutoff_radius_rydg, //TODO lambda
- template<typename> class UpdatePolicy = divider //TODO lambda
->
-class optimal_parameter_given_max_degree{
- typedef CutoffRadiusPolicy<RealType> cutoff_radius_policy_type;
- typedef UpdatePolicy<RealType> update_policy_type;
- public:
- typedef RealType value_type;
- typedef std::size_t size_type;
- template<typename ArgPack> optimal_parameter_given_max_degree(
- const ArgPack& arg);
- optimal_parameter_given_max_degree(
- const optimal_parameter_given_max_degree& that);
- optimal_parameter_given_max_degree&
- operator=(const optimal_parameter_given_max_degree& that);
-
- value_type error_tolerance()const{return error_tol_; };
- unsigned max_degree()const{ return max_degree_; };
- value_type bandwidth()const{return bandwidth_; };//models ClusterPolicy
- size_type max_recursions()const{ return max_recursions_; }
-
- /// Set parameters
- void operator()(
- unsigned max_degree,
- value_type bandwidth,
- value_type start_cluster_radius_over_bandwidth = 2.0,
- size_type max_recursions = 20);
-
- /// Output
- value_type cutoff_radius()const{ return cutoff_radius_; }
- //models ClusterPolicy
- value_type max_radius()const{ return max_cluster_radius_; }
- value_type error()const { return error_; }
- size_type recursions()const{ return recursions_; }
-
- private:
- void call_impl();
- value_type error_tol_;
- cutoff_radius_policy_type cutoff_radius_policy_;
- update_policy_type update_policy_;
- value_type bandwidth_;
- unsigned max_degree_;
- size_type max_recursions_;
- value_type cutoff_radius_;
- value_type max_cluster_radius_;
- value_type error_;
- size_type recursions_;
-};
-
-template<typename RealType,template<typename> class CutoffRadiusPolicy,
-template<typename> class UpdatePolicy>
-template<typename ArgPack>
-optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::optimal_parameter_given_max_degree(
- const ArgPack& arg)
-:error_tol_(arg[tag::error_tolerance]),
-cutoff_radius_policy_(arg),
-update_policy_(arg),
-bandwidth_(0.0),
-max_degree_(0.0),
-max_recursions_(0),
-cutoff_radius_(0.0),
-max_cluster_radius_(0.0),
-error_(0.0),
-recursions_(0){}
-
-template<typename RealType,template<typename> class CutoffRadiusPolicy,
-template<typename> class UpdatePolicy>
-optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::optimal_parameter_given_max_degree(
-const optimal_parameter_given_max_degree& that)
-:error_tol_(that.error_tol_),
-cutoff_radius_policy_(that.cutoff_radius_policy_),
-update_policy_(that.update_policy_),
-bandwidth_(that.bandwidth_),
-max_degree_(that.max_degree_),
-max_recursions_(0),
-cutoff_radius_(that.cutoff_radius_),
-max_cluster_radius_(that.max_cluster_radius_),
-error_(that.error_),
-recursions_(0){}
-
-template<typename RealType, template<typename> class CutoffRadiusPolicy,
-template<typename> class UpdatePolicy>
-typename
-optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::optimal_parameter_given_max_degree&
-optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::operator=(
- const optimal_parameter_given_max_degree& that){
- if(&that!=this){
- error_tol_ = that.error_tol_;
- cutoff_radius_policy_ = that.cutoff_radius_policy_;
- update_policy_ = that.update_policy_;
- bandwidth_ = that.bandwidth_;
- max_degree_ = that.max_degree_;
- max_recursions_ = that.max_recursions_;
- cutoff_radius_ = that.cutoff_radius_;
- max_cluster_radius_ = that.max_cluster_radius_;
- error_ = that.error_;
- recursions_ = that.recursions_;
- }
- return *this;
-};
-
-template<typename RealType,template<typename> class CutoffRadiusPolicy,
-template<typename> class UpdatePolicy>
-void optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::operator()(
- unsigned max_degree,
- value_type bandwidth,
- value_type start_cluster_radius_over_bandwidth,
- size_type max_recursions ){
- bandwidth_ = bandwidth;
- max_degree_ = max_degree;
- max_recursions_ = max_recursions;
- recursions_ = 0;
- max_cluster_radius_ = start_cluster_radius_over_bandwidth
- /this->bandwidth();
- call_impl();
-};
-
-template<typename RealType,template<typename> class CutoffRadiusPolicy,
-template<typename> class UpdatePolicy>
-void optimal_parameter_given_max_degree<RealType,CutoffRadiusPolicy,
-UpdatePolicy>::call_impl(){
- ++recursions_;
- cutoff_radius_ = cutoff_radius_policy_(*this);
- error_ = truncation_properties::max_error_bound(
- max_degree(), bandwidth(),
- max_radius(), cutoff_radius()
- );
-
- if(recursions()<max_recursions()){
- if(error()>error_tolerance()){
- max_cluster_radius_ = update_policy_(max_radius());
- ++recursions_;
- call_impl();
- }
- }else{
- std::string str = "optimal_parameter_given_max_degree";
- str += "max number of recursions exceeded";
- throw std::runtime_error(str);
- }
-}
-
-}}}
-
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/rest_weights_wrapper.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/rest_weights_wrapper.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,28 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/rest_weights_wrapper.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_REST_WEIGHTS_WRAPPER_HPP_ER_2009
-#define BOOST_MATH_IFGT_REST_WEIGHTS_WRAPPER_HPP_ER_2009
-namespace boost{namespace math{namespace ifgt{
- /// This wrapper indicates that each weight in the sequence
- /// has yet to be prepend by one in order to be NW compliant.
- template<typename R1>
- class rest_weights_wrapper{
- public:
- rest_weights_wrapper(const R1& r):r_(r){}
- rest_weights_wrapper(const rest_weights_wrapper& that):r_(that.r_){}
- const R1& operator()()const{ return r_; }
- private:
- rest_weights_wrapper();
- const R1& r_;
- };
- template<typename R1>
- rest_weights_wrapper<R1> make_rest_weights_wrapper(const R1& r){
- typedef rest_weights_wrapper<R1> result_type;
- return result_type(r);
- }
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/tag.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/tag.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,96 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/tag.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_TAG_HPP_ER_2009
-#define BOOST_MATH_IFGT_TAG_HPP_ER_2009
-#include <boost/parameter/parameters.hpp>
-#include <boost/parameter/keyword.hpp>
-namespace boost{namespace math{namespace ifgt{
-namespace{
- struct bandwidth_{};
- struct max_cluster_radius_{};
- struct degree_{};
- struct clusters_{};
- struct center_{};
- struct target_{};
- struct range_out_{};
- struct error_tolerance_{};
- struct max_distance_source_target_{};
- struct cutoff_radius_policy_{};
- struct clusters_reserve_size_{};
- struct contributions_reserve_size_{};
- struct accumulator_{};
- struct nadaraya_watson_check_tolerance_{};
- struct divide_by_{};
-}
-namespace tag{
-
- static
- ::boost::parameter::keyword<bandwidth_>& bandwidth
- = ::boost::parameter::keyword<bandwidth_>::get();
- static
- ::boost::parameter::keyword<max_cluster_radius_>&
- max_cluster_radius
- =
- ::boost::parameter::keyword<max_cluster_radius_>::get();
- static
- ::boost::parameter::keyword<degree_>& degree
- = ::boost::parameter::keyword<degree_>::get();
- static
- ::boost::parameter::keyword<clusters_>& clusters
- = ::boost::parameter::keyword<clusters_>::get();
- static
- ::boost::parameter::keyword<center_>& center
- = ::boost::parameter::keyword<center_>::get();
- static
- ::boost::parameter::keyword<target_>& target
- = ::boost::parameter::keyword<target_>::get();
- static
- ::boost::parameter::keyword<range_out_>& range_out
- = ::boost::parameter::keyword<range_out_>::get();
- static
- ::boost::parameter::keyword<error_tolerance_>& error_tolerance
- = ::boost::parameter::keyword<error_tolerance_>::get();
- static
- ::boost::parameter::keyword<max_distance_source_target_>&
- max_distance_source_target
- =
- ::boost::parameter::keyword<max_distance_source_target_>::get();
- static
- ::boost::parameter::keyword<cutoff_radius_policy_>&
- cutoff_radius_policy
- = ::boost::parameter::keyword<cutoff_radius_policy_>::get();
- static
- ::boost::parameter::keyword<clusters_reserve_size_>&
- clusters_reserve_size
- = ::boost::parameter::keyword<clusters_reserve_size_>::get();
- static
- ::boost::parameter::keyword<contributions_reserve_size_>&
- contributions_reserve_size
- =
- ::boost::parameter::keyword<contributions_reserve_size_>::get();
- static
- ::boost::parameter::keyword<divide_by_>&
- divide_by
- = ::boost::parameter::keyword<
- divide_by_>::get();
- static
- ::boost::parameter::keyword<accumulator_>&
- accumulator
- = ::boost::parameter::keyword<accumulator_>::get();
-
- static
- ::boost::parameter::keyword<nadaraya_watson_check_tolerance_>&
- nadaraya_watson_check_tolerance
- = ::boost::parameter::keyword<
- nadaraya_watson_check_tolerance_>::get();
-// All this works as is, but
-// defining instead a keyword within say struct my_struct{}
-// has caused compile error "multiple definitions of tag::my_struct::keyword".
-// I have used defs within structs before w/o pbs (though templates) so why?
-}
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/traits.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/traits.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,29 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/traits.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_TRAITS_HPP_ER_2009
-#define BOOST_MATH_IFGT_TRAITS_HPP_ER_2009
-#include <boost/mpl/size_t.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-template<typename T>
-struct stride_traits{
- typedef mpl::size_t<T::source_size> stride0_type;
- typedef mpl::size_t<T::weight_size> stride1_type;
-};
-
-///These traits are for use by for_each_over_vector2matrix
-template<typename T>
-struct traits : public stride_traits<T>{
- typedef T type;
-};
-
-template<typename T>
-struct call_traits : T::stride_traits{
- typedef T type;
-};
-}}}
-#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/constant.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/constant.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////////
+// constant.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_TRUNCATION_DEGREE_CONSTANT_HPP_ER_2009
+#define BOOST_MATH_IFGT_TRUNCATION_DEGREE_CONSTANT_HPP_ER_2009
+#include <algorithm>
+#include <boost/range.hpp>
+#include <boost/parameter/parameters.hpp>
+#include <boost/parameter/keyword.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace truncation_degree{
+
+ /// Models TruncationDegreesPolicy
+ template<typename RealType = double>
+ class constant{
+ public:
+ typedef RealType value_type;
+
+ constant():p_(20){}
+ explicit constant(unsigned p):p_(p){}
+ //default copy/assign should be fine
+
+ template<typename ArgPack>
+ constant(const ArgPack& args)
+ :p_(args[kwd<>::degree|20]){}
+
+ unsigned degree()const{return p_;}
+
+ template<typename Cluster,typename R0,typename R1>
+ void operator()(
+ const Cluster& cluster,
+ value_type radius_source_to_center,
+ const R0& weight,
+ R1& degrees
+ ){
+ std::fill(
+ begin(degrees),
+ end(degrees),
+ degree()
+ );
+ }
+ private:
+ unsigned p_;
+ };
+}
+}
+}
+}
+#endif

Added: sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/properties.hpp
==============================================================================
--- (empty file)
+++ sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree/properties.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,164 @@
+//////////////////////////////////////////////////////////////////////////////
+// properties.hpp
+// (C) Copyright 2009 Erwann Rogard
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_MATH_IFGT_TRUNCATION_PROPERTIES_HPP_ER_2009
+#define BOOST_MATH_IFGT_TRUNCATION_PROPERTIES_HPP_ER_2009
+#include <cmath>
+#include <boost/math/special_functions/factorials.hpp>
+namespace boost{
+namespace math{
+namespace ifgt{
+namespace truncation_degree{
+
+struct properties{
+ public:
+ //assumes weight = 1
+ template<typename RealType>
+ static RealType log_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType target_to_center_distance
+ );
+ template<typename RealType>
+ static RealType error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType target_to_center_distance
+ );
+ template<typename RealType>
+ static RealType worst_target_to_center_distance(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance
+ );
+ template<typename RealType>
+ static RealType worst_target_to_center_distance(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+ );
+ template<typename RealType>
+ static RealType max_log_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+ );
+ template<typename RealType>
+ static RealType max_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+ );
+
+};
+
+template<typename RealType>
+RealType properties::log_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType target_to_center_distance
+){
+ typedef RealType value_type;
+ value_type p = max_degree;
+ value_type h = bandwidth;
+ value_type rx = source_to_center_distance;
+ value_type ry = target_to_center_distance;
+ value_type result =
+ max_degree * (
+ log(2)
+ + log(rx)
+ + log(ry)
+ - 2 * log(h )
+ ) - log ( factorial<value_type>(p) );
+ result -= std::pow( (rx - ry)/h, 2 );
+ return result;
+}
+
+template<typename RealType>
+RealType properties::error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType target_to_center_distance
+){
+ return exp(log_error_bound(
+ max_degree,
+ bandwidth,
+ source_to_center_distance,
+ target_to_center_distance
+ ));
+}
+
+template<typename RealType>
+RealType
+properties::worst_target_to_center_distance(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance
+){
+ typedef RealType value_type;
+ value_type p = max_degree;
+ value_type h = bandwidth;
+ value_type rx = source_to_center_distance;
+ value_type result
+ = ( rx + sqrt(std::pow(rx,2) + 2 * p * std::pow(h,2)) )
+ /((value_type)(2));
+ return result;
+}
+
+template<typename RealType>
+RealType
+properties::worst_target_to_center_distance(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+){
+ typedef RealType value_type;
+ value_type result = worst_target_to_center_distance(
+ max_degree, bandwidth, source_to_center_distance);
+
+ return (result<cutoff_radius)? result : cutoff_radius;
+}
+
+template<typename RealType>
+RealType properties::max_log_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+){
+ typedef RealType value_type;
+ value_type wry =
+ worst_target_to_center_distance(
+ max_degree, bandwidth, source_to_center_distance, cutoff_radius);
+ return log_error_bound(
+ max_degree, bandwidth, source_to_center_distance, wry);
+}
+
+template<typename RealType>
+RealType properties::max_error_bound(
+ unsigned max_degree,
+ RealType bandwidth,
+ RealType source_to_center_distance,
+ RealType cutoff_radius
+){
+ return exp(
+ max_log_error_bound(
+ max_degree, bandwidth, source_to_center_distance, cutoff_radius));
+}
+
+}//truncation_degree
+}//ifgt
+}//math
+}//boost
+#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree_constant.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_degree_constant.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,50 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/truncation_degree_constant.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_ASSIGN_DEGREES_CONSTANT_HPP_ER_2009
-#define BOOST_MATH_IFGT_ASSIGN_DEGREES_CONSTANT_HPP_ER_2009
-#include <algorithm>
-#include <boost/range.hpp>
-#include <boost/parameter/parameters.hpp>
-#include <boost/parameter/keyword.hpp>
-#include <boost/math/ifgt/tag.hpp>
-namespace boost{namespace math{namespace ifgt{
-
- /// Models TruncationDegreesPolicy
- template<typename RealType = double>
- class truncation_degree_constant{
- public:
- typedef RealType value_type;
-
- truncation_degree_constant():p_(20){}
- explicit truncation_degree_constant(unsigned p):p_(p){}
- //default copy/assign should be fine
-
- template<typename ArgPack>
- truncation_degree_constant(const ArgPack& args)
- :p_(args[tag::degree|20]){}
-
- unsigned degree()const{return p_;}
-
- template<typename Cluster,typename R0,typename R1>
- void operator()(
- const Cluster& cluster,
- value_type radius_source_to_center,
- const R0& weight,
- R1& degrees
- ){
- std::fill(
- begin(degrees),
- end(degrees),
- degree()
- );
- }
- private:
- unsigned p_;
- };
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_properties.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/truncation_properties.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,158 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/truncation_properties.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_IFGT_TRUNCATION_PROPERTIES_HPP_ER_2009
-#define BOOST_MATH_IFGT_TRUNCATION_PROPERTIES_HPP_ER_2009
-#include <cmath>
-#include <boost/math/special_functions/factorials.hpp>
-namespace boost{namespace math{namespace ifgt{
-
-struct truncation_properties{
- public:
- //assumes weight = 1
- template<typename RealType>
- static RealType log_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType target_to_center_distance
- );
- template<typename RealType>
- static RealType error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType target_to_center_distance
- );
- template<typename RealType>
- static RealType worst_target_to_center_distance(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance
- );
- template<typename RealType>
- static RealType worst_target_to_center_distance(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
- );
- template<typename RealType>
- static RealType max_log_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
- );
- template<typename RealType>
- static RealType max_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
- );
-
-};
-
-template<typename RealType>
-RealType truncation_properties::log_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType target_to_center_distance
-){
- typedef RealType value_type;
- value_type p = max_degree;
- value_type h = bandwidth;
- value_type rx = source_to_center_distance;
- value_type ry = target_to_center_distance;
- value_type result =
- max_degree * (
- log(2)
- + log(rx)
- + log(ry)
- - 2 * log(h )
- ) - log ( factorial<value_type>(p) );
- result -= std::pow( (rx - ry)/h, 2 );
- return result;
-}
-
-template<typename RealType>
-RealType truncation_properties::error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType target_to_center_distance
-){
- return exp(log_error_bound(
- max_degree,
- bandwidth,
- source_to_center_distance,
- target_to_center_distance
- ));
-}
-
-template<typename RealType>
-RealType
-truncation_properties::worst_target_to_center_distance(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance
-){
- typedef RealType value_type;
- value_type p = max_degree;
- value_type h = bandwidth;
- value_type rx = source_to_center_distance;
- value_type result
- = ( rx + sqrt(std::pow(rx,2) + 2 * p * std::pow(h,2)) )
- /((value_type)(2));
- return result;
-}
-
-template<typename RealType>
-RealType
-truncation_properties::worst_target_to_center_distance(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
-){
- typedef RealType value_type;
- value_type result = worst_target_to_center_distance(
- max_degree, bandwidth, source_to_center_distance);
-
- return (result<cutoff_radius)? result : cutoff_radius;
-}
-
-template<typename RealType>
-RealType truncation_properties::max_log_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
-){
- typedef RealType value_type;
- value_type wry =
- worst_target_to_center_distance(
- max_degree, bandwidth, source_to_center_distance, cutoff_radius);
- return log_error_bound(
- max_degree, bandwidth, source_to_center_distance, wry);
-}
-
-template<typename RealType>
-RealType truncation_properties::max_error_bound(
- unsigned max_degree,
- RealType bandwidth,
- RealType source_to_center_distance,
- RealType cutoff_radius
-){
- return exp(
- max_log_error_bound(
- max_degree, bandwidth, source_to_center_distance, cutoff_radius));
-}
-
-}}}
-#endif

Deleted: sandbox/improved_fast_gauss_transform/boost/math/ifgt/zscore.hpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/boost/math/ifgt/zscore.hpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
+++ (empty file)
@@ -1,56 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// ifgt/zscore.hpp
-// (C) Copyright 2009 Erwann Rogard
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_MATH_ZSCORE_HPP_ER_2009
-#define BOOST_MATH_ZSCORE_HPP_ER_2009
-#include <algorithm>
-#include <functional>
-#include <stdexcept>
-#include <boost/range.hpp>
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-namespace boost{namespace math{
-
- /// Maps x,y,h to (x-y)/h
- template<typename R0>
- class zscore{
- typedef typename range_iterator<R0>::type iter_type;
- public:
- typedef typename iter_type::value_type value_type;
- zscore(const R0& center_):center(center_){}
- zscore(const zscore& that):center(that.zscore){}
-
- template<typename R1,typename RealType>
- void operator()(const R1& source,RealType bandwidth,R0& out){
- BOOST_ASSERT(size(source)==size(center));
-
- std::transform(
- begin(source),
- end(source),
- begin(center),
- begin(out),
- bind(
- std::divides<value_type>(),
- bind(
- std::minus<value_type>(),
- _1,
- _2
- ),
- (value_type)(bandwidth)
- )
- );
- }
- private:
- zscore& operator=(const zscore& that);
- zscore();
- const R0& center;
- };
-
- template<typename R0>
- zscore<R0> make_zscore(const R0& center){return zscore<R0>(center);}
-}}
-
-#endif

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/doc/readme.txt
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/doc/readme.txt (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/doc/readme.txt 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -38,10 +38,11 @@
 
 The compiler search path must include
 boost_1_37_0
-boost/sandbox/miscellanea_iterator_facade
-boost/sandbox/miscellanea_algorithm
-boost/sandbox/monomials_horner_rule
-boost/sandbox/improved_fast_gauss_transform
+sandbox/miscellanea_iterator_facade
+sandbox/miscellanea_algorithm
+sandbox/monomials_horner_rule
+sandbox/improved_fast_gauss_transform
+sandbox/conditionally_specified_distribution/utility
 
 ///////////////
 / Conventions /
@@ -81,7 +82,6 @@
 nw(y) Nadaray Watson estimate rp(y) / rp(y)|w=1
 
 
-
 The quantity nw(y) and rp(y) is an estimate of E[w|x=y].
 In the special case that w=1, rp(y) is an estimate of pdf(x=y).
 The quantity nw(y) and rp(y) is an estimate of E[w|x=y].
@@ -153,7 +153,7 @@
 {z^a:|a|< p+1}, for z=(x-c)/h, and z=(y-c)/h, respectively. For efficiency,
 Hoerner's rule is used.
 
-* Number of clusters (or maximum cluster radius), K
+* Cluster radius (equivalently K)
 
 Given h, Raykar2006a, Section 4.3 provide an algorithm that find the optimal
 K, equivalently rx. This relies on certain assumptions and we have not
@@ -176,53 +176,29 @@
 We may want to evaluate the gt only for a subset of {j=0,...,J-1}. For
 that reason, evaluators take a subset range policy.
 
-//////////
-/ Design /
-//////////
+/////////
+/ Usage /
+/////////
 
-Our two main concepts are Accumulator and Evaluator. The first takes
-care of accumulating training data in a sequential fashion:
- a(source,weight)
-The second, usually built upon the former (by const ref) takes care of
-evaluating gt(y):
- e(target,range_out).
-Each of Accumulator and Evaluator inherit from a base class with corres-
-ponding names (CRTP), for overload resolution purposes (e.g. for_each) or to
-provide additional functionality (e.g. rp(y) and nw(y) in the case
-of an evaluator).
-
-The operations of accumulating and evaluating can be vectorized:
- for_each(sources,weights,a)
- for_each(targets,ranges_out,e,call<method>())
-where each of sources,weights, targets, and ranges_out are "flattened"
-matrices. To be able to use Nadaray Watson, we need to prepend
-each weight with 1:
- for_each(sources,make_rest_weights_wrapper(w),a)
-
-Models of Accumulator include fast_accumulator and exact_accumulator.
-The former finds the nearest among a set of active clusters and forwards the
-job of collecting data to that cluster.
-
-The template class cluster is parameterized by a degree truncation policy,
-models of which include degree_truncation_rydg.
-
-Models of Evaluator include fast_evaluator and exact_evaluator. Naturally,
-a fast_evaluator is built around a fast_accumulator. It is parameterized by
-a cutoff radius policy, a model of which is cutoff_radius_rydg.
-
-End user classes may contain deeply nested components. Therefore,
-for convenience, their constructor takes an argument pack
-(see the Boost Parameter library) which is passed down into the class
-components. For example:
+An Accumulator (fast or exact) is constructed using Boost.Parameter:
      A a((
- tag::bandwidth = h,
- tag::max_cluster_radius = rx,
- tag::degree = p
+ kwd<>::bandwidth = h,
+ kwd<>::max_cluster_radius = rx,
+ kwd<>::degree = p
         )
     );
-
-Instead of template template parameters we use lambda
-expressions to make it easier to allow, for example, G<F<X,_1>,Y>
+A new contribution is passed to an Accumulator (either exact or fast):
+ a(source,weight)
+For convenience, this operation can be vectorized:
+ for_each_accumulate(sources,weights,a)
+ for_each_weight_front_insert_1_accumulate(sources,weights,a)
+The insertion of 1 is needed for NW.
+An Evaluator (fast or exact) is created around an accumulator:
+ e(a);
+Whose interface comprises free functions such as:
+for_each_gauss_transform(targets,ranges_out,e)
+for_each_nadaraya_watson(targets,ranges_out,e)
+for_each_rozenblatt_parzen(targets,ranges_out,e)
 
 //////////////
 / Concepts /
@@ -235,7 +211,7 @@
 
 Accumulator (A)
 Associated types:
- A has public base accumulator_base<A>
+ A derives from crtp::accumulator<A>
     A::value_type
     A::sources_count_type
 Valid expressions: let a an lvalue of A, and source and weight those
@@ -245,7 +221,7 @@
     active_bandwidth() value_type
     sources_count() sources_count_type
     e(source, weight) void
-Models: fast_accumulator.hpp, exact_accumulator.hpp
+Models: fast/accumulator.hpp, exact/accumulator.hpp
 
 Evaluator (E), e an lvalue of E, C a type,
     E has public base evaluator_base<C,E>
@@ -280,93 +256,97 @@
 SubsetRangePolicy (S),
 Associated types: R0 a ForwardRange,
    R= result_of<S(R0)>::type (another ForwardRange)
-
 Valid expressions:
     f(r0) returns an lvalue of R
 
 ////////////////////
 / Files /
 ////////////////////
-
-* accumulator_base.hpp
-* benchmark.hpp
-* call_gauss_transform.hpp
-* call_nadaraya_watson_estimate.hpp
-* call_rozenblatt_parzen_estimate.hpp
-* call_wrapper.hpp
-* cluster.hpp
- vars: x, h, {{b:a}:j}
- arg: x, {w:j},{p:j}
- effect: updates {{b:a}:j}
-* cluster_call_center.hpp
-* cluster_evaluator.hpp
- vars: t, {out:j}
- arg: C
- effect: adds {gt(t):j} to {out:j}
-* clusters_evaluator.hpp
- arg: t, {C},{out:j}
- effect: iterates over {C} and adds {gt(t):j} to {out:j}
-* coefficients.hpp
- var: {b:a}
- arg: ({zx^a},w)
- effect: updates {b:a}
-* coefficients_evaluator.hpp
- var: t
- arg: r, cc,h, {b:a}
- out: gt(t)
-* cutoff_radius_none.hpp
-* cutoff_radius_rydg.hpp
-* evaluator_base.hpp
-* evaluator_common.hpp
-* exact_accumulator.hpp
-* exact_contribution.hpp
- var: x, {w:j}, h
- member: evaluate
- arg: t, out
- effect: adds {gt(t):j} to out
-* exact_contributions_evaluator.hpp
-* exact_evaluator.hpp
-* fast_accumulator.hpp
-* fast_evaluator.hpp
-* find_nearest_cluster.hpp:
- var: {cc}
- arg: x
- out: cc nearest to x
-* for_each_accumulate.hpp
-* for_each_evaluator.hpp
-* include.hpp
-* monomials.hpp:
- arg: x, p
- out: {x^a: |a|=p}
-* monomials_properties.hpp
-* multi_factorial.hpp
- deprecated: redundant with multi_indexes_derived.
-* multi_indexes.hpp
- member: get
- arg: p
- out: {a:|a|=p}
-* multi_indexes_derived.hpp
-* optimal_bandwidth.hpp
-* optimal_parameter_given_max_degree.hpp
-* normal_kernel_properties.hpp
-* tag.hpp
-* traits.hpp
-* truncation_degree_constant.hpp
-* truncation_properties.hpp
+/benchmark.hpp
+/bandwdith
+ /normal_plug_in.hpp
+/crtp
+ /accumulator.hpp
+ /evaluator.hpp
+/cluster_radius
+ /at_max_degree.hpp
+/cutoff_radius
+ /none.hpp
+ /rydg.hpp
+/detail
+ /normal_kernel_properties.hpp
+ /evaluator_common.hpp
+/exact
+ /accumulator.hpp
+ /detail
+ /contribution.hpp
+ var: x, {w:j}, h
+ member: evaluate
+ arg: t, out
+ effect: adds {gt(t):j} to out
+ /contributions_evaluator.hpp
+ /evaluator.hpp
+/fast
+ /detail
+ /cluster.hpp
+ vars: x, h, {{b:a}:j}
+ arg: x, {w:j},{p:j}
+ effect: updates {{b:a}:j}
+ /cluster_call_center.hpp
+ /cluster_evaluator.hpp
+ vars: t, {out:j}
+ arg: C
+ effect: adds {gt(t):j} to {out:j}
+ /clusters_evaluator.hpp
+ arg: t, {C},{out:j}
+ effect: iterates over {C} and adds {gt(t):j} to {out:j}
+ /coefficients.hpp
+ var: {b:a}
+ arg: ({zx^a},w)
+ effect: updates {b:a}
+ /coefficients_evaluator.hpp
+ var: t
+ arg: r, cc,h, {b:a}
+ out: gt(t)
+
+ /accumulator.hpp
+ /evaluator.hpp
+ /find_nearest_cluster.hpp:
+ var: {cc}
+ arg: x
+ out: cc nearest to x
+/for_each
+ /accumulate.hpp
+ /evaluate.hpp
+/functor
+ /evaluate.hpp
+ /gauss_transform.hpp
+ /nadaraya_watson_estimate.hpp
+ /rozenblatt_parzen_estimate.hpp
+/include.hpp
+/keyword.hpp
+/truncation_degree
+ /constant.hpp
+ /properties.hpp
 
 ////////
 / TODO /
 ////////
-This is an early version that begs for safeguards, optimization and testing.
+More testing.
 
-As far as design:
-- Customize the exact gauss transform by
-adding a policy for the cutoff radius as well.
-- Add helper classes to predict how parameters affect resource
+Design:
+- Add cutoff radius policy to exact::evaluator
+- Predict how parameters affect resource
 requirement (memory, in particular, easily becomes a problem) and precision.
 - For now, the bandwidth is optimized only in a statistical sense as a
 function of N. What is needed is a per-computation-time optimization.
-- Optimal p, K (see remark in Algorithm)
+- Optimal p and K, simulatneaously
+
+///////////
+/ History /
+///////////
+
+March 24th, 2009 : Simplified the interface.
 
 /////////////
 / Reference /

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,15 +1,21 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/benchmark_exact.cpp
+// benchmark_exact.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #include <boost/math/ifgt/benchmark.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/exact/accumulator.hpp>
+#include <boost/math/ifgt/fast/evaluator.hpp>
+#include <boost/math/ifgt/exact/evaluator.hpp>
+#include <boost/math/ifgt/bandwidth/normal_plug_in.hpp>
 #include <libs/math/ifgt/src/example/benchmark_exact.h>
 void example_benchmark_exact(){
     std::cout << " -> example_benchmark_exact" << std::endl;
     std::string str =
- "pdf(x) = prod{N(x[d]|0,1),d=0,...,D} estimated by Rozenblatt-Parzen";
+ "pdf(x) = prod{N(x[d]|0,1),d=0,...,D}";
+ str+= "estimated by Rozenblatt-Parzen";
     str+= "and f(x) = norm(x) = sqrt(x[0]^2+...+x[D]^2) by Nadaraya-Watson";
     std::cout << str << std::endl;
 
@@ -50,9 +56,9 @@
         wdim,
         pdf_fun_type,
         w_fun_type> bench_type;
- typedef ifgt::optimal_bandwidth<sdim,value_type> opt_bandwidth_type;
- typedef ifgt::exact_accumulator<sdim,wdim,var_type> exact_acc_type;
- typedef ifgt::exact_evaluator<exact_acc_type> exact_eval_type;
+ typedef ifgt::bandwidth_normal_plug_in<sdim,value_type> opt_bandwidth_type;
+ typedef ifgt::exact::accumulator<sdim,wdim,var_type> exact_acc_type;
+ typedef ifgt::exact::evaluator<exact_acc_type> exact_eval_type;
 
     //pdf
     // Data generator
@@ -69,15 +75,15 @@
     std::cout << "dim(w) = " << wdim << std::endl;
 
     value_type opt_h
- = opt_bandwidth_type::for_density_estimation_under_normality(
+ = opt_bandwidth_type::find(
         sigma,all_train_count);
     opt_h *= bandwidth_adjust; //override
 
     std::cout << "bandwidth ="
         << opt_h << std::endl;
 
- exact_acc_type exact_acc((ifgt::tag::bandwidth = opt_h ));
- exact_eval_type exact_eval((ifgt::tag::accumulator = exact_acc));
+ exact_acc_type exact_acc((ifgt::kwd<>::bandwidth = opt_h ));
+ exact_eval_type exact_eval((ifgt::kwd<>::accumulator = exact_acc));
 
     bench.notation(std::cout);
     bench.header(std::cout); std::cout << std::endl;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_exact.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/benchmark_exact.h
+// benchmark_exact.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,11 +1,14 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/benchmark_fast.cpp
+// benchmark_fast.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #include <boost/range.hpp>
-#include <boost/math/ifgt/benchmark.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/math/ifgt/include.hpp>
 #include <libs/math/ifgt/src/example/benchmark_fast.h>
 void example_benchmark_fast(){
     std::cout << " -> example_benchmark_fast" << std::endl;
@@ -68,22 +71,22 @@
         wdim,
         pdf_fun_type,
         w_fun_type> bench_type;
- typedef ifgt::optimal_bandwidth<sdim,value_type> opt_bandwidth_type;
+ typedef ifgt::bandwidth_normal_plug_in<sdim,value_type> opt_bandwidth_type;
     //fast types
- typedef ifgt::optimal_parameter_given_max_degree<value_type>
+ typedef ifgt::cluster_radius_at_max_degree<value_type>
                                                               opt_pars_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<sdim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
                                                               find_type;
- typedef ifgt::fast_accumulator<cluster_type,find_type> fast_acc_type;
+ typedef ifgt::fast::accumulator<cluster_type,find_type> fast_acc_type;
     typedef mpl::if_<
         mpl::bool_<do_cutoff_rydg>,
- mpl::identity<ifgt::cutoff_radius_rydg<mpl::_1> >,
- mpl::identity<ifgt::cutoff_radius_none<mpl::_1> >
+ mpl::identity<ifgt::cutoff_radius::rydg<mpl::_1> >,
+ mpl::identity<ifgt::cutoff_radius::none<mpl::_1> >
>::type cutoff_policy;
 
- typedef ifgt::fast_evaluator<fast_acc_type,cutoff_policy> fast_eval_type;
+ typedef ifgt::fast::evaluator<fast_acc_type,cutoff_policy> fast_eval_type;
 
     //pdf
     // Data generator
@@ -100,12 +103,12 @@
     std::cout << "dim(w) = " << wdim << std::endl;
 
     value_type opt_h
- = opt_bandwidth_type::for_density_estimation_under_normality(
+ = opt_bandwidth_type::find(
         sigma,all_train_count);
     opt_h *= bandwidth_adjust; //override
 
     //fast specific parameters
- opt_pars_type opt_pars((ifgt::tag::error_tolerance = error_tol));
+ opt_pars_type opt_pars((ifgt::kwd<>::error_tolerance = error_tol));
     opt_pars(max_p, opt_h, start_rx_div_h, max_recursions);
     value_type max_rx = opt_pars.max_radius();
 
@@ -114,15 +117,15 @@
 
     fast_acc_type fast_acc(
         (
- ifgt::tag::bandwidth = opt_h,
- ifgt::tag::max_cluster_radius = max_rx,
- ifgt::tag::degree = max_p,
- ifgt::tag::error_tolerance = error_tol
+ ifgt::kwd<>::bandwidth = opt_h,
+ ifgt::kwd<>::max_cluster_radius = max_rx,
+ ifgt::kwd<>::degree = max_p,
+ ifgt::kwd<>::error_tolerance = error_tol
         )
     );
     fast_eval_type fast_eval((
- ifgt::tag::accumulator = fast_acc,
- ifgt::tag::error_tolerance = error_tol));
+ ifgt::kwd<>::accumulator = fast_acc,
+ ifgt::kwd<>::error_tolerance = error_tol));
 
     bench.notation(std::cout);
     std::cout << "K : # clusters" << std::endl;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/benchmark_fast.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/benchmark_fast.h
+// benchmark_fast.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/cluster.cpp
+// cluster.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -12,7 +12,8 @@
 #include <boost/mpl/placeholders.hpp>
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
-#include <boost/math/ifgt/cluster.hpp>
+#include <boost/parameter/keyword.hpp>
+#include <boost/math/ifgt/include.hpp>
 #include <libs/math/ifgt/src/example/cluster.h>
 
 void example_cluster(){
@@ -27,13 +28,14 @@
     const unsigned wdim = 2;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
- typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
-
+ typedef ifgt::kwd<> kwd_t;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
+ typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef std::vector<unsigned> ints_type;
     typedef cluster_type::coefficients_type coeffs_type;
     typedef cluster_type::collection_coefficients_type coll_coeffs_type;
 
+
     const value_type bandwidth = 0.1;
     const value_type max_cluster_radius = 1.0;
     const unsigned degree = 20;
@@ -49,10 +51,10 @@
     }
 
     cluster_type cluster(
- (tag::center=center,
- tag::bandwidth=bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree) );
+ (kwd_t::center=center,
+ kwd_t::bandwidth=bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree) );
 
     cluster_type cluster_cpy(cluster);
 

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example//cluster.h
+// /cluster.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/cluster_evaluator.cpp
+// cluster_evaluator.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -12,11 +12,11 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <boost/mpl/placeholders.hpp>
-#include <boost/math/ifgt/cluster.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/cluster_evaluator.hpp>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
-#include <boost/math/ifgt/tag.hpp>
+#include <boost/math/ifgt/fast/detail/cluster.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/fast//detail/cluster_evaluator.hpp>
+#include <boost/math/ifgt/cutoff_radius/none.hpp>
+#include <boost/math/ifgt/keyword.hpp>
 #include <libs/math/ifgt/src/example/cluster_evaluator.h>
 void example_cluster_evaluator(){
     std::cout << "-> cluster_evaluator" << std::endl;
@@ -30,14 +30,16 @@
     typedef double value_type;
     typedef std::vector<value_type> var_type;
 
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::kwd<> kwd_t;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
 
     typedef cluster_type::coefficients_type coeffs_type;
     typedef cluster_type::collection_coefficients_type coll_coeffs_type;
- typedef ifgt::cutoff_radius_none<value_type> cutoff_policy_type;
+ typedef ifgt::cutoff_radius::none<value_type> cutoff_policy_type;
     typedef ifgt::cluster_evaluator<
- var_type,var_type,ifgt::cutoff_radius_none<mpl::_1> > cluster_eval_type;
+ var_type,var_type,ifgt::cutoff_radius::none<mpl::_1> >
+ cluster_eval_type;
 
     const value_type bandwidth = 0.1;
     const value_type max_cluster_radius = 1.0;
@@ -57,10 +59,10 @@
     }
 
     cluster_type cluster((
- tag::center = center,
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::center = center,
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
     ) );
     std::cout << "before?" << std::endl;
     cluster(source,weight);
@@ -71,9 +73,9 @@
     cutoff_policy_type cutoff_policy;
     cluster_eval_type cluster_eval(
         (
- tag::range_out = range_out,
- tag::target = target,
- tag::cutoff_radius_policy = cutoff_policy
+ kwd_t::range_out = range_out,
+ kwd_t::target = target,
+ kwd_t::cutoff_radius_policy = cutoff_policy
         )
     );
 

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/cluster_evaluator.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/cluster_evaluator.h
+// cluster_evaluator.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/clusters_evaluator.cpp
+// clusters_evaluator.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -9,10 +9,11 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <iostream>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/clusters_evaluator.hpp>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/fast/detail/clusters_evaluator.hpp>
+#include <boost/math/ifgt/cutoff_radius/none.hpp>
 #include <libs/math/ifgt/src/example/clusters_evaluator.h>
 
 void example_clusters_evaluator(){
@@ -27,13 +28,12 @@
     const unsigned int wdim = 2;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
                                                                 find_type;
-
- typedef ifgt::fast_accumulator<cluster_type,find_type> acc_type;
-
+ typedef ifgt::fast::accumulator<cluster_type,find_type> acc_type;
+ typedef ifgt::kwd<> kwd_t;
     value_type bandwidth = 0.1;
     value_type max_cluster_radius = 1.0;
     unsigned degree = 20;
@@ -56,9 +56,9 @@
     }
 
     acc_type acc((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
 
@@ -85,7 +85,7 @@
 
 
     typedef ifgt::clusters_evaluator<
- value_type,ifgt::cutoff_radius_none<mpl::_1> > clusters_evaluator_type;
+ value_type,ifgt::cutoff_radius::none<mpl::_1> > clusters_evaluator_type;
 
 
     clusters_evaluator_type clusters_evaluator;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/clusters_evaluator.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/clusters_evaluator.h
+// clusters_evaluator.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/coefficients.cpp
+// coefficients.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -12,8 +12,8 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <boost/math/monomials.hpp>
-#include <boost/math/ifgt/zscore.hpp>
-#include <boost/math/ifgt/coefficients.hpp>
+#include <boost/math/ifgt/detail/zscore.hpp>
+#include <boost/math/ifgt/fast/detail/coefficients.hpp>
 #include <libs/math/ifgt/src/example/coefficients.h>
 
 void example_coefficients(){
@@ -24,7 +24,6 @@
     typedef std::vector<value_type> var_type;
     typedef std::vector<unsigned> ints_type;
     typedef math::ifgt::coefficients<dim> coeffs_type;
-
     double bandwidth = 0.1;
     int degree = 5;
     var_type center;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/coefficients.h
+// coefficients.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/coefficients_evaluator.cpp
+// coefficients_evaluator.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -12,10 +12,10 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <boost/math/monomials.hpp>
-#include <boost/math/ifgt/zscore.hpp>
-#include <boost/math/ifgt/normal_kernel_properties.hpp>
-#include <boost/math/ifgt/coefficients.hpp>
-#include <boost/math/ifgt/coefficients_evaluator.hpp>
+#include <boost/math/ifgt/detail/zscore.hpp>
+#include <boost/math/ifgt//detail/normal_kernel_properties.hpp>
+#include <boost/math/ifgt/fast/detail/coefficients.hpp>
+#include <boost/math/ifgt/fast/detail/coefficients_evaluator.hpp>
 #include <libs/math/ifgt/src/example/coefficients_evaluator.h>
 
 void example_coefficients_evaluator(){

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/coefficients_evaluator.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/coefficients_evaluator.h
+// coefficients_evaluator.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/exact_gauss_transform.cpp
+// exact_gauss_transform.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -8,11 +8,8 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <iostream>
-#include <boost/math/ifgt/tag.hpp>
-#include <boost/math/ifgt/exact_contribution.hpp>
-#include <boost/math/ifgt/exact_accumulator.hpp>
-#include <boost/math/ifgt/exact_contributions_evaluator.hpp>
-#include <boost/math/ifgt/exact_evaluator.hpp>
+#include <boost/math/ifgt/include.hpp>
+#include <boost/math/ifgt/exact/detail/contributions_evaluator.hpp>
 #include <libs/math/ifgt/src/example/exact_gauss_transform.h>
 
 void example_exact_gauss_transform(){
@@ -29,10 +26,11 @@
     typedef double value_type;
     typedef std::vector<double> var_type;
     typedef std::vector<unsigned> ints_type;
- typedef ifgt::exact_contribution<dim,wdim,var_type> exact_contrib_type;
+ typedef ifgt::exact::contribution<dim,wdim,var_type> exact_contrib_type;
     typedef std::vector<exact_contrib_type> contributions_type;
- typedef ifgt::exact_accumulator<dim,wdim,var_type> exact_acc_type;
- typedef ifgt::exact_evaluator<exact_acc_type> exact_eval_type;
+ typedef ifgt::exact::accumulator<dim,wdim,var_type> exact_acc_type;
+ typedef ifgt::exact::evaluator<exact_acc_type> exact_eval_type;
+ typedef ifgt::kwd<> kwd_t;
 
     const double bandwidth = 0.5;
     var_type center0;
@@ -57,14 +55,15 @@
     var_type range_out1(dim,(value_type)(0));
 
     exact_acc_type exact_acc(
- (tag::bandwidth = bandwidth, tag::contributions_reserve_size = 2));
+ (kwd_t::bandwidth
+ = bandwidth, kwd_t::contributions_reserve_size = 2));
     exact_acc(center0,weight);
     exact_acc(center1,weight);
     exact_acc(center2,weight);
     exact_acc(source1,weight);
     exact_acc(source2,weight);
 
- make_exact_contributions_evaluator(exact_acc.contributions())(
+ ifgt::exact::make_contributions_evaluator(exact_acc.contributions())(
         target,range_out0);
 
     std::cout << "gauss transform" << std::endl;
@@ -75,8 +74,8 @@
         std::ostream_iterator<value_type>(std::cout," ")
     ); std::cout << std::endl;
 
- exact_eval_type exact_eval((tag::accumulator = exact_acc));
- exact_eval.gauss_transform(target,range_out1);
+ exact_eval_type exact_eval((kwd_t::accumulator = exact_acc));
+ ifgt::make_gauss_transform(exact_eval)(target,range_out1);
 
     std::cout << "(exact evaluator)" << std::endl;
     copy(
@@ -99,13 +98,14 @@
         ); std::cout << std::endl;
         std::cout << "(exact_eval.accumulator().)" << std::endl;
         copy(
- boost::begin(exact_eval.accumulator().contributions()[0].source()),
+ boost::begin(
+ exact_eval.accumulator().contributions()[0].source()),
             boost::end(exact_eval.accumulator().contributions()[0].source()),
             std::ostream_iterator<value_type>(std::cout, " ")
         ); std::cout << std::endl;
     //<-
 
- value_type hat_pdf = exact_eval.rozenblatt_parzen_estimate(target);
+ value_type hat_pdf = ifgt::make_rozenblatt_parzen(exact_eval)(target);
     std::cout << "rp estimate" << hat_pdf << std::endl;
 
     std::cout << "<-" << std::endl;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/exact_gauss_transform.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/exact_gauss_transform.h
+// exact_gauss_transform.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/fast_accumulator.cpp
+// fast_accumulator.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -9,8 +9,8 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <iostream>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
 #include <libs/math/ifgt/src/example/fast_accumulator.h>
 void example_fast_accumulator(){
     std::cout << "-> example_fast_accumulator" << std::endl;
@@ -22,12 +22,12 @@
     const unsigned int dim = 2;
     const unsigned int wdim = 2;
     typedef std::vector<double> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
                                                                 find_type;
-
- typedef ifgt::fast_accumulator<cluster_type,find_type> acc_type;
+ typedef ifgt::kwd<> kwd_t;
+ typedef ifgt::fast::accumulator<cluster_type,find_type> acc_type;
 
     double bandwidth = 0.1;
     double max_cluster_radius = 1.0;
@@ -49,9 +49,9 @@
     }
 
     acc_type acc((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
 

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_accumulator.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/fast_accumulator.h
+// fast_accumulator.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/fast_evaluator.cpp
+// fast_evaluator.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -7,13 +7,9 @@
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
 #include <iostream>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/cutoff_radius_none.hpp>
-#include <boost/math/ifgt/fast_evaluator.hpp>
+#include <boost/math/ifgt/include.hpp>
 #include <libs/math/ifgt/src/example/fast_evaluator.h>
 
-
 void example_fast_evaluator(){
 
     std::cout << "-> example_fast_evaluator" << std::endl;
@@ -26,12 +22,12 @@
     const unsigned int wdim = 2;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
                                                                 find_type;
- typedef ifgt::fast_accumulator<cluster_type,find_type> acc_type;
-
+ typedef ifgt::fast::accumulator<cluster_type,find_type> acc_type;
+ typedef ifgt::kwd<> kwd_t;
     value_type bandwidth = 0.1;
     value_type max_cluster_radius = 1.0;
     unsigned degree = 20;
@@ -54,9 +50,9 @@
     }
 
     acc_type acc((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
 
@@ -69,13 +65,13 @@
         << "sources_count = " << acc.sources_count()
         << std::endl;
 
- typedef ifgt::fast_evaluator<acc_type,
- ifgt::cutoff_radius_none<mpl::_1> > eval_type;
- eval_type eval((tag::accumulator = acc));
+ typedef ifgt::fast::evaluator<acc_type,
+ ifgt::cutoff_radius::none<mpl::_1> > eval_type;
+ eval_type eval((kwd_t::accumulator = acc));
 
     var_type range_out(wdim);
 
- eval.gauss_transform(target,range_out);
+ ifgt::make_gauss_transform(eval)(target,range_out);
 
     std::cout << "gauss_transform =" << std::endl;
     std::copy(
@@ -84,11 +80,11 @@
         std::ostream_iterator<value_type>(std::cout, " ")
     );
 
- value_type rpe = eval.rozenblatt_parzen_estimate(target);
+ value_type rpe = ifgt::make_rozenblatt_parzen(eval)(target);
     std::cout << "rozenblatt_parzen_estimate =" << rpe << std::endl;
 
     var_type range_out_nw(wdim-1);
- eval.nadaraya_watson_estimate(target,range_out_nw); //wrong size
+ ifgt::make_nadaraya_watson(eval)(target,range_out_nw); //wrong size
 
     std::cout << "nadaya_watson_estimate =" << std::endl;
     std::copy(

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/fast_evaluator.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/fast_evaluator.h
+// fast_evaluator.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/find_nearest_cluster.cpp
+// find_nearest_cluster.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -11,8 +11,9 @@
 #include <iostream>
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
-#include <boost/math/ifgt/cluster.hpp>
-#include <boost/math/ifgt/find_nearest_cluster.hpp>
+#include <boost/math/ifgt/keyword.hpp>
+#include <boost/math/ifgt/fast/detail/cluster.hpp>
+#include <boost/math/ifgt/fast/find_nearest_cluster.hpp>
 #include <libs/math/ifgt/src/example/find_nearest_cluster.h>
 
 void example_find_nearest_cluster(){
@@ -27,12 +28,12 @@
     const unsigned wdim = 2;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef std::vector<cluster_type> clusters_type;
     typedef boost::l2_distance_squared dist_type;
     typedef ifgt::find_nearest_cluster<clusters_type,dist_type> find_nc_type;
-
+ typedef ifgt::kwd<> kwd_t;
     typedef cluster_type::coefficients_type coeffs_type;
     typedef cluster_type::collection_coefficients_type coll_coeffs_type;
 
@@ -61,17 +62,17 @@
             trunc_degree_type(degree)));
     clusters.push_back(
         cluster_type((
- tag::center = center1,
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::center = center1,
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )));
     clusters.push_back(
         cluster_type((
- tag::center = center2,
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::center = center2,
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )));
 
     find_nc_type find_nc(clusters);

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/find_nearest_cluster.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/find_nearest_cluster.h
+// find_nearest_cluster.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/for_each_accumulate.cpp
+// for_each_accumulate.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -8,11 +8,11 @@
 #include <iostream>
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
-#include <boost/math/ifgt/exact_accumulator.hpp>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/for_each_accumulate.hpp>
-#include <boost/math/ifgt/for_each_accumulate_rest_weights.hpp>
+#include <boost/math/ifgt/exact/accumulator.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/for_each/accumulate.hpp>
+#include <boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp>
 #include <libs/math/ifgt/src/example/for_each_accumulate.h>
 
 void example_for_each_accumulate(){
@@ -24,14 +24,14 @@
 
     const unsigned int dim = 2;
     const unsigned int wdim = 2;
- typedef std::vector<double> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
- typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
+ typedef std::vector<double> var_type;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
+ typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
- find_type;
-
- typedef ifgt::fast_accumulator<cluster_type,find_type> fast_acc_type;
- typedef ifgt::exact_accumulator<dim,wdim,var_type> exact_acc_type;
+ find_type;
+ typedef ifgt::kwd<> kwd_t;
+ typedef ifgt::fast::accumulator<cluster_type,find_type> fast_acc_type;
+ typedef ifgt::exact::accumulator<dim,wdim,var_type> exact_acc_type;
 
 
     double bandwidth = 0.1;
@@ -66,38 +66,38 @@
     std::cout << "sources count" << std::endl;
 
     fast_acc_type fast_acc((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
- ifgt::for_each(sources,weights,fast_acc);
+ ifgt::for_each_accumulate(sources,weights,fast_acc);
     std::cout
         << "fast (weights) " << fast_acc.sources_count()
         << std::endl;
 
     fast_acc_type fast_acc2((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
- ifgt::for_each(sources,
- ifgt::make_rest_weights_wrapper(r_weights),fast_acc2);
+ ifgt::for_each_weight_front_insert_1_accumulate(sources,
+ r_weights,fast_acc2);
     std::cout
         << "fast (rest weights) " << fast_acc2.sources_count()
         << std::endl;
 
- exact_acc_type exact_acc((tag::bandwidth = bandwidth));
- ifgt::for_each(sources,weights,exact_acc);
+ exact_acc_type exact_acc((kwd_t::bandwidth = bandwidth));
+ ifgt::for_each_accumulate(sources,weights,exact_acc);
 
     std::cout
         << "exact (weights) " << exact_acc.sources_count()
         << std::endl;
 
- exact_acc_type exact_racc((tag::bandwidth = bandwidth));
- ifgt::for_each(sources,
- ifgt::make_rest_weights_wrapper(r_weights),exact_racc);
+ exact_acc_type exact_racc((kwd_t::bandwidth = bandwidth));
+ ifgt::for_each_weight_front_insert_1_accumulate(sources,
+ r_weights,exact_racc);
 
     std::cout
         << "exact (rest weights) " << exact_racc.sources_count()

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_accumulate.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/for_each_accumulate.h
+// for_each_accumulate.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/for_each_evaluate.cpp
+// for_each_evaluate.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -8,18 +8,18 @@
 #include <iostream>
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
-#include <boost/math/ifgt/exact_accumulator.hpp>
-#include <boost/math/ifgt/fast_accumulator.hpp>
-#include <boost/math/ifgt/fast_evaluator.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/for_each_accumulate_rest_weights.hpp>
-#include <boost/math/ifgt/for_each_evaluate.hpp>
-#include <boost/math/ifgt/call_wrapper.hpp>
-#include <boost/math/ifgt/call_gauss_transform.hpp>
-#include <boost/math/ifgt/call_rozenblatt_parzen_estimate.hpp>
-#include <boost/math/ifgt/call_nadaraya_watson_estimate.hpp>
-#include <boost/math/ifgt/for_each_rozenblatt_parzen_estimate.hpp>
-#include <boost/math/ifgt/for_each_evaluate.hpp>
+#include <boost/math/ifgt/exact/accumulator.hpp>
+#include <boost/math/ifgt/fast/accumulator.hpp>
+#include <boost/math/ifgt/fast/evaluator.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/for_each/weight_front_insert_1_accumulate.hpp>
+#include <boost/math/ifgt/for_each/evaluate.hpp>
+#include <boost/math/ifgt/for_each/gauss_transform.hpp>
+#include <boost/math/ifgt/for_each/nadaraya_watson.hpp>
+#include <boost/math/ifgt/functor/gauss_transform.hpp>
+#include <boost/math/ifgt/functor/rozenblatt_parzen.hpp>
+#include <boost/math/ifgt/functor/nadaraya_watson.hpp>
+#include <boost/math/ifgt/for_each/rozenblatt_parzen.hpp>
 #include <libs/math/ifgt/src/example/for_each_evaluate.h>
 
 void example_for_each_evaluate(){
@@ -34,13 +34,13 @@
     const unsigned int wdim = 2;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
- typedef ifgt::truncation_degree_constant<mpl::_1> trunc_degree;
+ typedef ifgt::truncation_degree::constant<mpl::_1> trunc_degree;
     typedef ifgt::cluster<dim,wdim,trunc_degree,var_type> cluster_type;
     typedef ifgt::find_nearest_cluster<mpl::_1, boost::l2_distance_squared>
                                                                 find_type;
-
- typedef ifgt::fast_accumulator<cluster_type,find_type> fast_acc_type;
- typedef ifgt::exact_accumulator<dim,wdim,var_type> exact_acc_type;
+ typedef ifgt::kwd<> kwd_t;
+ typedef ifgt::fast::accumulator<cluster_type,find_type> fast_acc_type;
+ typedef ifgt::exact::accumulator<dim,wdim,var_type> exact_acc_type;
 
 
     value_type bandwidth = 0.1;
@@ -63,16 +63,16 @@
     }
 
     fast_acc_type fast_acc((
- tag::bandwidth = bandwidth,
- tag::max_cluster_radius = max_cluster_radius,
- tag::degree = degree
+ kwd_t::bandwidth = bandwidth,
+ kwd_t::max_cluster_radius = max_cluster_radius,
+ kwd_t::degree = degree
         )
     );
 
- ifgt::for_each(sources,weights,fast_acc);
+ ifgt::for_each_accumulate(sources,weights,fast_acc);
 
- exact_acc_type exact_acc((tag::bandwidth = bandwidth));
- ifgt::for_each(sources,weights,exact_acc);
+ exact_acc_type exact_acc((kwd_t::bandwidth = bandwidth));
+ ifgt::for_each_accumulate(sources,weights,exact_acc);
 
     var_type targets;
     {
@@ -86,18 +86,17 @@
     var_type::size_type targets_count = boost::size(targets)/dim;
 
 
- typedef ifgt::cutoff_radius_none<mpl::_1> cutoff_policy_type;
- typedef ifgt::fast_evaluator<fast_acc_type, cutoff_policy_type>
+ typedef ifgt::cutoff_radius::none<mpl::_1> cutoff_policy_type;
+ typedef ifgt::fast::evaluator<fast_acc_type, cutoff_policy_type>
                                                             fast_eval_type;
- fast_eval_type eval((tag::accumulator = fast_acc));
+ fast_eval_type eval((kwd_t::accumulator = fast_acc));
 
     var_type ranges_out( targets_count * wdim);
     std::cout << "gauss_transform->" << std::endl;
- ifgt::for_each(
+ ifgt::for_each_gauss_transform(
         targets,
         ranges_out,
- eval,
- ifgt::call<ifgt::gauss_transform>()
+ eval
     );
     copy(
         boost::begin(ranges_out),
@@ -108,11 +107,10 @@
     std::cout << "rozenblatt_parzen_estimate->" << std::endl;
 
     var_type rp_out( targets_count * 1);
- ifgt::for_each(
+ ifgt::for_each_rozenblatt_parzen(
         targets,
         rp_out,
- eval,
- ifgt::call<ifgt::rozenblatt_parzen_estimate>()
+ eval
     );
     copy(
         boost::begin(rp_out),
@@ -123,11 +121,10 @@
 
     var_type nw_out( targets_count * (wdim-1) );
     std::cout << "nadaraya_watston_estimate->" << std::endl;
- ifgt::for_each(
+ ifgt::for_each_nadaraya_watson(
         targets,
         nw_out,
- eval,
- ifgt::call<ifgt::nadaraya_watson_estimate>()
+ eval
     );
     copy(
         boost::begin(nw_out),

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/for_each_evaluate.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/for_each_evaluate.h
+// for_each_evaluate.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/main.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/main.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/main.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/main.cpp
+// main.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/truncation_degree_constant.cpp
+// truncation_degree_constant.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -9,8 +9,8 @@
 #include <iostream>
 #include <boost/assign/std/vector.hpp>
 #include <boost/range.hpp>
-#include <boost/math/ifgt/truncation_degree_constant.hpp>
-#include <boost/math/ifgt/tag.hpp>
+#include <boost/math/ifgt/truncation_degree/constant.hpp>
+#include <boost/math/ifgt/keyword.hpp>
 #include <libs/math/ifgt/src/example/truncation_degree_constant.h>
 void example_truncation_degree_constant(){
     std::cout << "-> example_truncation_degree_constant" << std::endl;
@@ -20,7 +20,7 @@
     const unsigned degree = 5;
     const unsigned dim = 2;
 
- typedef truncation_degree_constant<> truncation_degree_type;
+ typedef truncation_degree::constant<> truncation_degree_type;
     typedef std::vector<unsigned> degrees_type;
     typedef double value_type;
     typedef std::vector<value_type> var_type;
@@ -28,7 +28,7 @@
     value_type bandwidth = 0.1;
     value_type sqrt_dist_source_to_center = 0.1;
 
- truncation_degree_type a((tag::degree = degree));
+ truncation_degree_type a((kwd<>::degree = degree));
 
     var_type weight;
     {

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_degree_constant.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/truncation_degree_constant.h
+// truncation_degree_constant.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.cpp
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.cpp (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.cpp 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example/truncation_properties.cpp
+// truncation_properties.cpp
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file
@@ -17,8 +17,8 @@
     namespace ifgt = math::ifgt;
     typedef double value_type;
     typedef std::vector<value_type> vec_type;
- typedef ifgt::truncation_properties prop_type;
- typedef ifgt::optimal_parameter_given_max_degree<value_type>
+ typedef ifgt::truncation_degree::properties prop_type;
+ typedef ifgt::cluster_radius_at_max_degree<value_type>
                                                         opt_pars_type;
 
     value_type h = 0.5; //Raykar2006 probably meant h=0.5 in Figure 6
@@ -27,7 +27,7 @@
     value_type eps = 1e-3;
 // unsigned max_p = 40;
     unsigned n = 100;
- opt_pars_type opt_pars((ifgt::tag::error_tolerance = eps));
+ opt_pars_type opt_pars((ifgt::kwd<>::error_tolerance = eps));
 
     value_type log10 = log((value_type)(10));
     vec_type wry;

Modified: sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.h
==============================================================================
--- sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.h (original)
+++ sandbox/improved_fast_gauss_transform/libs/math/ifgt/src/example/truncation_properties.h 2009-03-26 18:29:11 EDT (Thu, 26 Mar 2009)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// example/truncation_properties.h
+// truncation_properties.h
 // (C) Copyright 2009 Erwann Rogard
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0. (See accompanying file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk