Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68784 - trunk/libs/random/test
From: steven_at_[hidden]
Date: 2011-02-11 15:14:07


Author: steven_watanabe
Date: 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
New Revision: 68784
URL: http://svn.boost.org/trac/boost/changeset/68784

Log:
Make sure all engines are tested. Kill validate.cpp, since its functionality is now covered by the main generator tests.
Added:
   trunk/libs/random/test/test_knuth_b.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci1279.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci19937.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci2281.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci23209.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci3217.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci4423.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci44497.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci9689.cpp (contents, props changed)
   trunk/libs/random/test/test_ranlux24_base.cpp (contents, props changed)
   trunk/libs/random/test/test_ranlux48_base.cpp (contents, props changed)
Removed:
   trunk/libs/random/test/validate.cpp
Text files modified:
   trunk/libs/random/test/Jamfile.v2 | 24 +++++++++++++++++++++---
   trunk/libs/random/test/test_generator.ipp | 2 +-
   2 files changed, 22 insertions(+), 4 deletions(-)

Modified: trunk/libs/random/test/Jamfile.v2
==============================================================================
--- trunk/libs/random/test/Jamfile.v2 (original)
+++ trunk/libs/random/test/Jamfile.v2 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -13,7 +13,6 @@
 run random_test.cpp ;
 run test_const_mod.cpp /boost//unit_test_framework ;
 run ../example/random_demo.cpp ;
-run validate.cpp ;
 run test_random_device.cpp /boost//random : : : <link>static : test_random_device ;
 run test_random_device.cpp /boost//random : : : <link>shared : test_random_device_dll ;
 
@@ -25,8 +24,6 @@
 run test_mt19937_64.cpp /boost//unit_test_framework ;
 run test_ecuyer1988.cpp /boost//unit_test_framework ;
 run test_hellekalek1995.cpp /boost//unit_test_framework ;
-run test_lagged_fibonacci.cpp /boost//unit_test_framework ;
-run test_lagged_fibonacci607.cpp /boost//unit_test_framework ;
 run test_linear_feedback_shift.cpp /boost//unit_test_framework ;
 run test_taus88.cpp /boost//unit_test_framework ;
 run test_kreutzer1986.cpp /boost//unit_test_framework ;
@@ -38,8 +35,29 @@
 run test_ranlux64_3.cpp /boost//unit_test_framework ;
 run test_ranlux64_3_01.cpp /boost//unit_test_framework ;
 run test_ranlux64_4_01.cpp /boost//unit_test_framework ;
+run test_ranlux24_base.cpp /boost//unit_test_framework ;
 run test_ranlux24.cpp /boost//unit_test_framework ;
+run test_ranlux48_base.cpp /boost//unit_test_framework ;
 run test_ranlux48.cpp /boost//unit_test_framework ;
+run test_knuth_b.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci607.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci1279.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci2281.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci3217.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci4423.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci9689.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci19937.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci23209.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci44497.cpp /boost//unit_test_framework ;
+
+# Disable by default. These don't add much and the larger
+# ones can overflow the stack.
+explicit test_lagged_fibonacci1279 test_lagged_fibonacci2281
+ test_lagged_fibonacci2281 test_lagged_fibonacci3217
+ test_lagged_fibonacci4423 test_lagged_fibonacci9689
+ test_lagged_fibonacci19937 test_lagged_fibonacci23209
+ test_lagged_fibonacci44497 ;
 
 run test_seed_seq.cpp /boost//unit_test_framework ;
 

Modified: trunk/libs/random/test/test_generator.ipp
==============================================================================
--- trunk/libs/random/test/test_generator.ipp (original)
+++ trunk/libs/random/test/test_generator.ipp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -88,7 +88,7 @@
    
 BOOST_AUTO_TEST_CASE(test_iterator_seed)
 {
- const std::vector<int> v(9999u, 0x41);
+ const std::vector<int> v(std::max(std::size_t(9999u), sizeof(BOOST_RANDOM_URNG) / 4), 0x41);
     std::vector<int>::const_iterator it = v.begin();
     std::vector<int>::const_iterator it_end = v.end();
     BOOST_RANDOM_URNG urng(it, it_end);

Added: trunk/libs/random/test/test_knuth_b.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_knuth_b.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,19 @@
+/* test_knuth_b.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/shuffle_order.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::knuth_b
+// validation from the C++0x draft (n3090)
+#define BOOST_RANDOM_VALIDATION_VALUE 1112339016
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci1279.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci1279.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci1279.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci1279
+#define BOOST_RANDOM_VALIDATION_VALUE 0.56576990947654049
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci19937.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci19937.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci19937.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci19937
+#define BOOST_RANDOM_VALIDATION_VALUE 0.21779661133680173
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci2281.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci2281.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci2281.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci2281
+#define BOOST_RANDOM_VALIDATION_VALUE 0.85870032418398168
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci23209.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci23209.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci23209.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci23209
+#define BOOST_RANDOM_VALIDATION_VALUE 0.98718042717052668
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci3217.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci3217.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci3217.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci3217
+#define BOOST_RANDOM_VALIDATION_VALUE 0.29923216793615537
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci4423.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci4423.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci4423.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci4423
+#define BOOST_RANDOM_VALIDATION_VALUE 0.39798595467394815
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci44497.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci44497.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci44497.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci44497
+#define BOOST_RANDOM_VALIDATION_VALUE 0.86191789886161496
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci9689.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci9689.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci9689.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci9689
+#define BOOST_RANDOM_VALIDATION_VALUE 0.22728966337376244
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_ranlux24_base.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_ranlux24_base.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,18 @@
+/* test_ranlux24_base.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux24_base
+// validation from the C++0x draft (n3126).
+#define BOOST_RANDOM_VALIDATION_VALUE 7937952
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_ranlux48_base.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_ranlux48_base.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,19 @@
+/* test_ranlux48_base.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux48_base
+// validation from the C++0x draft (n3126).
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(61839128582725)
+
+#include "test_generator.ipp"

Deleted: trunk/libs/random/test/validate.cpp
==============================================================================
--- trunk/libs/random/test/validate.cpp 2011-02-11 15:13:48 EST (Fri, 11 Feb 2011)
+++ (empty file)
@@ -1,101 +0,0 @@
-/* boost validate.cpp
- *
- * Copyright Jens Maurer 2000
- * Copyright Steven Watanabe 2010-2011
- * Distributed under the Boost Software License, Version 1.0. (See
- * accompanying file LICENSE_1_0.txt or copy at
- * http://www.boost.org/LICENSE_1_0.txt)
- *
- * $Id$
- */
-
-#include <cmath>
-#include <boost/random.hpp>
-#include <boost/config.hpp>
-
-#include <boost/test/test_tools.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
-
-/*
- * Validate correct implementation
- */
-
-template<class PRNG>
-typename PRNG::result_type validation_value()
-{
- PRNG rng;
- for(int i = 0; i < 9999; i++)
- rng();
- return rng();
-}
-
-int test_main(int, char*[])
-{
- // own run
- BOOST_CHECK_EQUAL(validation_value<boost::mt11213b>(), 3809585648U);
-
- // validation by experiment from mt19937.c
- BOOST_CHECK_EQUAL(validation_value<boost::mt19937>(), 4123659995U);
-
-#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
- // validation from the C++0x draft (n3090)
- BOOST_CHECK_EQUAL(validation_value<boost::mt19937_64>(), UINT64_C(9981545732273789042));
-#endif
-
- // validation values from the publications
- BOOST_CHECK_EQUAL(validation_value<boost::minstd_rand0>(), 1043618065);
-
- // validation values from the publications
- BOOST_CHECK_EQUAL(validation_value<boost::minstd_rand>(), 399268537);
-
-#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
- // by experiment from lrand48()
- BOOST_CHECK_EQUAL(validation_value<boost::rand48>(), 1993516219);
-#endif
-
- // ????
- BOOST_CHECK_EQUAL(validation_value<boost::taus88>(), 3535848941U);
-
- // ????
- BOOST_CHECK_EQUAL(validation_value<boost::ecuyer1988>(), 2060321752);
-
- // validation by experiment from Harry Erwin's generator.h (private e-mail)
- BOOST_CHECK_EQUAL(validation_value<boost::kreutzer1986>(), 139726);
-
- // validation from the C++0x draft (n3090)
- BOOST_CHECK_EQUAL(validation_value<boost::random::knuth_b>(), 1112339016);
-
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci607>(), 0.401269, 1e-5);
-
- // principal operation validated with CLHEP, values by experiment
- BOOST_CHECK_EQUAL(validation_value<boost::ranlux3>(), 5957620);
- BOOST_CHECK_EQUAL(validation_value<boost::ranlux4>(), 8587295);
-
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux3_01>(), 5957620/std::pow(2.0f,24), 1e-6);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux4_01>(), 8587295/std::pow(2.0f,24), 1e-6);
-
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux64_3_01>(), 0.838413, 1e-6);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux64_4_01>(), 0.59839, 1e-6);
-
- BOOST_CHECK_EQUAL(validation_value<boost::random::ranlux24>(), 9901578);
-
-#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
- BOOST_CHECK_EQUAL(validation_value<boost::random::ranlux48>(), UINT64_C(249142670248501));
-#endif
-
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci607>(), 0.40126853196520074, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci1279>(), 0.56576990947654049, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci2281>(), 0.85870032418398168, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci3217>(), 0.29923216793615537, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci4423>(), 0.39798595467394815, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci9689>(), 0.22728966337376244, 1e-14);
-
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci19937>(), 0.21779661133680173, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci23209>(), 0.98718042717052668, 1e-14);
- BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci44497>(), 0.86191789886161496, 1e-14);
-
- typedef boost::random::lagged_fibonacci_engine<boost::uint32_t, 24, 607, 273> lagged_fibonacci;
- BOOST_CHECK_EQUAL(validation_value<lagged_fibonacci>(), 3543833);
-
- return 0;
-}


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