[Lemon-commits] deba: r3480 - in lemon/trunk: lemon test
Lemon SVN
svn at lemon.cs.elte.hu
Thu Mar 20 17:25:48 CET 2008
Author: deba
Date: Thu Mar 20 17:25:47 2008
New Revision: 3480
Modified:
lemon/trunk/lemon/random.h
lemon/trunk/test/random_test.cc
Log:
Back porting commit 81563e019fa4
Modified: lemon/trunk/lemon/random.h
==============================================================================
--- lemon/trunk/lemon/random.h (original)
+++ lemon/trunk/lemon/random.h Thu Mar 20 17:25:47 2008
@@ -578,6 +578,26 @@
return *this;
}
+ /// \brief Seeding random sequence
+ ///
+ /// Seeding the random sequence. The current number type will be
+ /// converted to the architecture word type.
+ template <typename Number>
+ void seed(Number seed) {
+ _random_bits::Initializer<Number, Word>::init(core, seed);
+ }
+
+ /// \brief Seeding random sequence
+ ///
+ /// Seeding the random sequence. The given range should contain
+ /// any number type and the numbers will be converted to the
+ /// architecture word type.
+ template <typename Iterator>
+ void seed(Iterator begin, Iterator end) {
+ typedef typename std::iterator_traits<Iterator>::value_type Number;
+ _random_bits::Initializer<Number, Word>::init(core, begin, end);
+ }
+
/// \brief Returns a random real number from the range [0, 1)
///
/// It returns a random real number from the range [0, 1). The
Modified: lemon/trunk/test/random_test.cc
==============================================================================
--- lemon/trunk/test/random_test.cc (original)
+++ lemon/trunk/test/random_test.cc Thu Mar 20 17:25:47 2008
@@ -33,4 +33,9 @@
a=rnd.gamma(4);
//Does gamma work with integer k?
a=rnd.gamma(4.0,0);
+
+ lemon::rnd.seed(100);
+ lemon::rnd.seed(seed_array, seed_array +
+ (sizeof(seed_array) / sizeof(seed_array[0])));
+ return 0;
}
More information about the Lemon-commits
mailing list