COIN-OR::LEMON - Graph Library

Changeset 102:81563e019fa4 in lemon-main


Ignore:
Timestamp:
03/20/08 17:15:35 (17 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Seeding random sequence

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r92 r102  
    576576    }
    577577
     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
    578598    /// \brief Returns a random real number from the range [0, 1)
    579599    ///
  • test/random_test.cc

    r92 r102  
    2525///
    2626
     27int seed_array[] = {1, 2};
     28
    2729int main()
    2830{
     
    3537  a=lemon::rnd.gamma(4.0,0);
    3638  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;
    3745}
Note: See TracChangeset for help on using the changeset viewer.