$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64283 - in sandbox/SOC/2010/quasi_random: boost/random/detail libs/random/example libs/random/test
From: jvd_at_[hidden]
Date: 2010-07-23 02:25:00
Author: qrng
Date: 2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
New Revision: 64283
URL: http://svn.boost.org/trac/boost/changeset/64283
Log:
Dropped the identity_distribution idea
Removed:
   sandbox/SOC/2010/quasi_random/boost/random/detail/identity_distribution.hpp
Binary files modified: 
   sandbox/SOC/2010/quasi_random/libs/random/example/out-faure.png
   sandbox/SOC/2010/quasi_random/libs/random/example/out-niederreiter_base2.png
   sandbox/SOC/2010/quasi_random/libs/random/example/out-sobol.png
Text files modified: 
   sandbox/SOC/2010/quasi_random/libs/random/example/qrng_images.cpp |    32 ++++++++++----------------------        
   sandbox/SOC/2010/quasi_random/libs/random/test/d_star.hpp         |    13 ++++++-------                           
   sandbox/SOC/2010/quasi_random/libs/random/test/discrepancy.cpp    |    29 +++++++++++------------------           
   sandbox/SOC/2010/quasi_random/libs/random/test/gsl_validate.cpp   |     2 --                                      
   4 files changed, 27 insertions(+), 49 deletions(-)
Deleted: sandbox/SOC/2010/quasi_random/boost/random/detail/identity_distribution.hpp
==============================================================================
--- sandbox/SOC/2010/quasi_random/boost/random/detail/identity_distribution.hpp	2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
+++ (empty file)
@@ -1,35 +0,0 @@
-// Copyright Justinas Vygintas Daugmaudis, 2010.
-// Use, modification and distribution is subject to the
-// Boost Software License, Version 1.0. (See accompanying
-// file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
-
-#ifndef BOOST_IDENTITY_DISTRIBUTION_HPP_INCLUDED
-#define BOOST_IDENTITY_DISTRIBUTION_HPP_INCLUDED
-
-namespace boost {
-
-namespace random {
-
-namespace detail {
-
-// To be used when no transformation of a sequence is required
-struct identity_distribution
-{
-  // makes compatible with result_of<>
-  template<typename FArgs>
-  struct result;
-
-  template<typename F, typename Engine>
-  struct result<F(Engine)>
-  {
-    typedef typename Engine::result_type type;
-  };
-
-  template<typename Engine>
-  typename Engine::result_type operator()(Engine& gen) const
-  { return gen(); }
-};
-
-}}} // namespace boost::random::detail
-
-#endif // BOOST_IDENTITY_DISTRIBUTION_HPP_INCLUDED
Modified: sandbox/SOC/2010/quasi_random/libs/random/example/out-faure.png
==============================================================================
Binary files. No diff available.
Modified: sandbox/SOC/2010/quasi_random/libs/random/example/out-niederreiter_base2.png
==============================================================================
Binary files. No diff available.
Modified: sandbox/SOC/2010/quasi_random/libs/random/example/out-sobol.png
==============================================================================
Binary files. No diff available.
Modified: sandbox/SOC/2010/quasi_random/libs/random/example/qrng_images.cpp
==============================================================================
--- sandbox/SOC/2010/quasi_random/libs/random/example/qrng_images.cpp	(original)
+++ sandbox/SOC/2010/quasi_random/libs/random/example/qrng_images.cpp	2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
@@ -3,9 +3,8 @@
 // Boost Software License, Version 1.0. (See accompanying
 // file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
 
-
-#include <boost/random/sobol.hpp>
 #include <boost/random/niederreiter_base2.hpp>
+#include <boost/random/sobol.hpp>
 #include <boost/random/faure.hpp>
 
 #include <boost/random/uniform_real.hpp>
@@ -17,7 +16,7 @@
 using namespace boost::gil;
 
 // Models a Unary Function
-template <typename Qrng, typename Distribution, typename P>   // Models PixelValueConcept
+template <typename QEngine, typename P>   // Models PixelValueConcept
 struct pixelnoise_fn {
   typedef point2<ptrdiff_t>    point_t;
 
@@ -33,7 +32,7 @@
   point_t                       _img_size;
   std::vector<point_t>          _random_points;
 
-  static const int MAX_ITER=6000;        // max number of iterations
+  static const int MAX_ITER=20000;        // max number of iterations
 
   pixelnoise_fn() {}
   pixelnoise_fn(const point_t& sz, const value_type& in_color) : _pnt_color(in_color), _img_size(sz) { gen_random(); }
@@ -47,28 +46,17 @@
 private:
   void gen_random()
   {
-    Qrng gen;
-    Distribution d;
+    QEngine gen;
+    boost::uniform_real<> d;
     for( int i = 0; i < MAX_ITER; ++i )
       _random_points.push_back( point_t( _img_size.x * d(gen), _img_size.y * d(gen) ) );
   }
 };
 
-// To be used in place of uniform_real, where scaling is not necessary
-template<typename T = double>
-struct identity_distribution
-{
-  typedef T result_type;
-  template<typename QRNG>
-  result_type operator()(QRNG& q) const
-  { return q(); }
-};
-
-
-template<typename Qrng, typename Distribution>
+template<typename QEngine>
 void output_image(const char* img_name)
 {
-  typedef pixelnoise_fn<Qrng, Distribution, rgb8_pixel_t> deref_t;
+  typedef pixelnoise_fn<QEngine, rgb8_pixel_t> deref_t;
   typedef typename deref_t::point_t  point_t;
   typedef virtual_2d_locator<deref_t,false> locator_t;
   typedef image_view<locator_t> my_virt_view_t;
@@ -83,8 +71,8 @@
 
 int main()
 {
-  output_image<boost::sobol_4d, boost::uniform_real<> >("out-sobol.png");
-  output_image<boost::niederreiter_base2_4d, boost::uniform_real<> >("out-niederreiter_base2.png");
-  output_image<boost::faure_4d, identity_distribution<> >("out-faure.png");
+  output_image<boost::sobol_2d>("out-sobol.png");
+  output_image<boost::niederreiter_base2_2d>("out-niederreiter_base2.png");
+  output_image<boost::faure_2d>("out-faure.png");
   return 0;
 }
Modified: sandbox/SOC/2010/quasi_random/libs/random/test/d_star.hpp
==============================================================================
--- sandbox/SOC/2010/quasi_random/libs/random/test/d_star.hpp	(original)
+++ sandbox/SOC/2010/quasi_random/libs/random/test/d_star.hpp	2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
@@ -14,7 +14,6 @@
 #include <boost/pool/pool.hpp>
 #include <boost/shared_array.hpp>
 #include <boost/random/uniform_real.hpp>
-#include <boost/utility/result_of.hpp>
 
 // The time required to compute the star discrepancy of a sequence of points
 // in a multidimensional unit cube is prohibitive and the best known upper
@@ -123,7 +122,7 @@
 };
 
 
-// An s-dimensional table of values that are stored consecutively in the
+// An table of values that are stored consecutively in the
 // memory area pointed by the given pointer.
 // The table is strictly read-only.
 template<typename T>
@@ -657,12 +656,12 @@
 // Accepts a pseudo-random number generator
 template<typename Engine, typename Distribution>
 inline typename detail::star_discrepancy<
-  typename boost::result_of<Distribution(Engine)>::type
+  typename Distribution::result_type
 >::bounds_t
 d_star(Engine& eng, Distribution d, std::size_t dimension, std::size_t n,
-    typename boost::result_of<Distribution(Engine)>::type epsilon)
+    typename Distribution::result_type epsilon)
 {
-  typedef typename boost::result_of<Distribution(Engine)>::type value_t;
+  typedef typename Distribution::result_type value_t;
   detail::star_discrepancy<value_t> discr(eng, d, dimension, n, epsilon);
   return discr.compute();
 }
@@ -670,10 +669,10 @@
 // Accepts a quasi-random number generator and distribution
 template<typename QEngine, typename Distribution>
 inline typename detail::star_discrepancy<
-  typename boost::result_of<Distribution(QEngine)>::type
+  typename Distribution::result_type
 >::bounds_t
 d_star(QEngine& q, Distribution d, std::size_t n,
-    typename boost::result_of<Distribution(QEngine)>::type epsilon)
+    typename Distribution::result_type epsilon)
 {
   return d_star(q, d, q.dimension(), n, epsilon);
 }
Modified: sandbox/SOC/2010/quasi_random/libs/random/test/discrepancy.cpp
==============================================================================
--- sandbox/SOC/2010/quasi_random/libs/random/test/discrepancy.cpp	(original)
+++ sandbox/SOC/2010/quasi_random/libs/random/test/discrepancy.cpp	2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
@@ -11,10 +11,6 @@
 
 #include <boost/random/mersenne_twister.hpp>
 
-#include <boost/random/detail/identity_distribution.hpp>
-
-#include <boost/utility/result_of.hpp>
-
 #define BOOST_TEST_MAIN
 #include <boost/test/unit_test.hpp>
 #include <boost/test/unit_test_log.hpp>
@@ -72,18 +68,16 @@
 }
 
 
-template<typename QEngine, typename Distribution, typename Bounds>
+template<typename QEngine, typename Bounds, typename T>
 inline void check_discrepancy(const char* name,
-    Distribution d,
-    std::size_t n_vectors,
-    typename boost::result_of<Distribution(QEngine)>::type epsilon,
+    std::size_t n_vectors, T epsilon,
     Bounds mersenne_twister_discrepancy)
 {
   QEngine q; // default-construct
 
   BOOST_TEST_MESSAGE( "Testing " << name << "[" << q.dimension() << "]" );
 
-  Bounds qrng_discrepancy = d_star(q, d, n_vectors, epsilon);
+  Bounds qrng_discrepancy = d_star(q, n_vectors, epsilon);
   BOOST_CHECK_LT( qrng_discrepancy.first, mersenne_twister_discrepancy.first );
   BOOST_CHECK_LE( qrng_discrepancy.second, mersenne_twister_discrepancy.second );
 }
@@ -105,25 +99,24 @@
   BOOST_REQUIRE( eps > 0 && eps < 1 );
   BOOST_TEST_MESSAGE( "Starting tests in dimension " << D << " with sample size " << n_vectors << ", epsilon=" << eps );
 
-  boost::uniform_real<value_t> u;
-
   // Compute the discrepancy of the Mersenne twister pseudo-random number generator
   bounds_t mt_discrepancy;
   {
     boost::mt19937 mt;
+    boost::uniform_real<value_t> u;
 
     BOOST_TEST_MESSAGE( "Computing discrepancy bounds for mt19937[" << D << "]" );
     mt_discrepancy = d_star(mt, u, D, n_vectors, eps);
   }
 
-#define UNIT_TEST_CHECK_QRNG_DISCREPANCY(N, U) \
-  check_discrepancy<N>(#N, U, n_vectors, eps, mt_discrepancy); \
+#define UNIT_TEST_CHECK_QRNG_DISCREPANCY(N) \
+  check_discrepancy<N>(#N, n_vectors, eps, mt_discrepancy); \
 /**/
 
   // Compare the discrepancy of quasi-random number generators against the Mersenne twister discrepancy
-  UNIT_TEST_CHECK_QRNG_DISCREPANCY(niederreiter_base2_t, u);
-  UNIT_TEST_CHECK_QRNG_DISCREPANCY(sobol_t, u);
-  UNIT_TEST_CHECK_QRNG_DISCREPANCY(faure_t, boost::random::detail::identity_distribution());
+  UNIT_TEST_CHECK_QRNG_DISCREPANCY(niederreiter_base2_t);
+  UNIT_TEST_CHECK_QRNG_DISCREPANCY(sobol_t);
+  UNIT_TEST_CHECK_QRNG_DISCREPANCY(faure_t);
 
 #undef UNIT_TEST_CHECK_QRNG_DISCREPANCY
 }
@@ -151,9 +144,9 @@
   compare_qrng_discrepancy<5>(  100,    0.06  );
   compare_qrng_discrepancy<6>(   60,    0.08  );
   compare_qrng_discrepancy<7>(   60,    0.15  );
-  compare_qrng_discrepancy<8>(  100,    0.4   );
+  compare_qrng_discrepancy<8>(  3000,    0.3   );
   compare_qrng_discrepancy<9> (  60,    0.5   );
-  compare_qrng_discrepancy<10>(  80,    0.3   ); // mersenne twister has good discrepancy from dim 10. :-)
+  compare_qrng_discrepancy<10>(  80,    0.3   );
   compare_qrng_discrepancy<11>(  500,   0.4   );
   compare_qrng_discrepancy<12>(  500,   0.5   );
 
Modified: sandbox/SOC/2010/quasi_random/libs/random/test/gsl_validate.cpp
==============================================================================
--- sandbox/SOC/2010/quasi_random/libs/random/test/gsl_validate.cpp	(original)
+++ sandbox/SOC/2010/quasi_random/libs/random/test/gsl_validate.cpp	2010-07-23 02:24:59 EDT (Fri, 23 Jul 2010)
@@ -3,8 +3,6 @@
 // Boost Software License, Version 1.0. (See accompanying
 // file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
 
-#include "identity_distribution.hpp"
-
 #include <boost/random/niederreiter_base2.hpp>
 #include <boost/random/sobol.hpp>
 #include <boost/random/faure.hpp>