gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Seeding random sequence
0 2 0
default
2 files changed with 28 insertions and 0 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -575,6 +575,26 @@
575 575
      return *this;
576 576
    }
577 577

	
578
    /// \brief Seeding random sequence
579
    ///
580
    /// Seeding the random sequence. The current number type will be
581
    /// converted to the architecture word type.
582
    template <typename Number>
583
    void seed(Number seed) { 
584
      _random_bits::Initializer<Number, Word>::init(core, seed);
585
    }
586

	
587
    /// \brief Seeding random sequence
588
    ///
589
    /// Seeding the random sequence. The given range should contain
590
    /// any number type and the numbers will be converted to the
591
    /// architecture word type.
592
    template <typename Iterator>
593
    void seed(Iterator begin, Iterator end) { 
594
      typedef typename std::iterator_traits<Iterator>::value_type Number;
595
      _random_bits::Initializer<Number, Word>::init(core, begin, end);
596
    }
597

	
578 598
    /// \brief Returns a random real number from the range [0, 1)
579 599
    ///
580 600
    /// It returns a random real number from the range [0, 1). The
Ignore white space 6 line context
... ...
@@ -24,6 +24,8 @@
24 24
///\todo To be extended
25 25
///
26 26

	
27
int seed_array[] = {1, 2};
28

	
27 29
int main()
28 30
{
29 31
  double a=lemon::rnd();
... ...
@@ -34,4 +36,10 @@
34 36
  //Does gamma work with integer k?
35 37
  a=lemon::rnd.gamma(4.0,0);
36 38
  a=lemon::rnd.poisson(.5);
39

	
40
  lemon::rnd.seed(100);
41
  lemon::rnd.seed(seed_array, seed_array + 
42
		  (sizeof(seed_array) / sizeof(seed_array[0])));
43

	
44
  return 0;
37 45
}
0 comments (0 inline)