Back porting commit 81563e019fa4
authordeba
Thu, 20 Mar 2008 16:25:47 +0000
changeset 25969c00e972cdfd
parent 2595 1cbd377bffb3
child 2597 91e2b6a4b96e
Back porting commit 81563e019fa4
lemon/random.h
test/random_test.cc
     1.1 --- a/lemon/random.h	Thu Mar 20 11:38:01 2008 +0000
     1.2 +++ b/lemon/random.h	Thu Mar 20 16:25:47 2008 +0000
     1.3 @@ -578,6 +578,26 @@
     1.4        return *this;
     1.5      }
     1.6  
     1.7 +    /// \brief Seeding random sequence
     1.8 +    ///
     1.9 +    /// Seeding the random sequence. The current number type will be
    1.10 +    /// converted to the architecture word type.
    1.11 +    template <typename Number>
    1.12 +    void seed(Number seed) { 
    1.13 +      _random_bits::Initializer<Number, Word>::init(core, seed);
    1.14 +    }
    1.15 +
    1.16 +    /// \brief Seeding random sequence
    1.17 +    ///
    1.18 +    /// Seeding the random sequence. The given range should contain
    1.19 +    /// any number type and the numbers will be converted to the
    1.20 +    /// architecture word type.
    1.21 +    template <typename Iterator>
    1.22 +    void seed(Iterator begin, Iterator end) { 
    1.23 +      typedef typename std::iterator_traits<Iterator>::value_type Number;
    1.24 +      _random_bits::Initializer<Number, Word>::init(core, begin, end);
    1.25 +    }
    1.26 +
    1.27      /// \brief Returns a random real number from the range [0, 1)
    1.28      ///
    1.29      /// It returns a random real number from the range [0, 1). The
     2.1 --- a/test/random_test.cc	Thu Mar 20 11:38:01 2008 +0000
     2.2 +++ b/test/random_test.cc	Thu Mar 20 16:25:47 2008 +0000
     2.3 @@ -33,4 +33,9 @@
     2.4    a=rnd.gamma(4);
     2.5    //Does gamma work with integer k?
     2.6    a=rnd.gamma(4.0,0);
     2.7 +
     2.8 +  lemon::rnd.seed(100);
     2.9 +  lemon::rnd.seed(seed_array, seed_array + 
    2.10 +		  (sizeof(seed_array) / sizeof(seed_array[0])));
    2.11 +  return 0;
    2.12  }