Index: lemon/hypercube_graph.h
===================================================================
--- lemon/hypercube_graph.h	(revision 2229)
+++ lemon/hypercube_graph.h	(revision 2242)
@@ -261,6 +261,6 @@
     /// dim2::Point<double> base[DIM];
     /// for (int k = 0; k < DIM; ++k) {
-    ///   base[k].x = random.getReal();
-    ///   base[k].y = random.getReal();
+    ///   base[k].x = rnd();
+    ///   base[k].y = rnd();
     /// } 
     /// HyperCubeGraph::HyperMap<dim2::Point<double> > 
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 2230)
+++ lemon/random.h	(revision 2242)
@@ -21,4 +21,6 @@
 
 #include <algorithm>
+#include <iterator>
+#include <vector>
 
 #include <ctime>
@@ -34,5 +36,372 @@
 namespace lemon {
 
-#if WORD_BIT == 32
+  namespace _random_bits {
+    
+    template <typename _Word, int _bits = std::numeric_limits<_Word>::digits>
+    struct RandomTraits {};
+
+    template <typename _Word>
+    struct RandomTraits<_Word, 32> {
+
+      typedef _Word Word;
+      static const int bits = 32;
+
+      static const int length = 624;
+      static const int shift = 397;
+      
+      static const Word mul = 0x6c078965u;
+      static const Word arrayInit = 0x012BD6AAu;
+      static const Word arrayMul1 = 0x0019660Du;
+      static const Word arrayMul2 = 0x5D588B65u;
+
+      static const Word mask = 0x9908B0DFu;
+      static const Word loMask = (1u << 31) - 1;
+      static const Word hiMask = ~loMask;
+
+
+      static Word tempering(Word rnd) {
+        rnd ^= (rnd >> 11);
+        rnd ^= (rnd << 7) & 0x9D2C5680u;
+        rnd ^= (rnd << 15) & 0xEFC60000u;
+        rnd ^= (rnd >> 18);
+        return rnd;
+      }
+
+    };
+
+    template <typename _Word>
+    struct RandomTraits<_Word, 64> {
+
+      typedef _Word Word;
+      static const int bits = 64;
+
+      static const int length = 312;
+      static const int shift = 156;
+
+      static const Word mul = (Word)0x5851F42Du << 32 | (Word)0x4C957F2Du;
+      static const Word arrayInit = (Word)0x00000000u << 32 |(Word)0x012BD6AAu;
+      static const Word arrayMul1 = (Word)0x369DEA0Fu << 32 |(Word)0x31A53F85u;
+      static const Word arrayMul2 = (Word)0x27BB2EE6u << 32 |(Word)0x87B0B0FDu;
+
+      static const Word mask = (Word)0xB5026F5Au << 32 | (Word)0xA96619E9u;
+      static const Word loMask = ((Word)1u << 31) - 1;
+      static const Word hiMask = ~loMask;
+
+      static Word tempering(Word rnd) {
+        rnd ^= (rnd >> 29) & ((Word)0x55555555u << 32 | (Word)0x55555555u);
+        rnd ^= (rnd << 17) & ((Word)0x71D67FFFu << 32 | (Word)0xEDA60000u);
+        rnd ^= (rnd << 37) & ((Word)0xFFF7EEE0u << 32 | (Word)0x00000000u);
+        rnd ^= (rnd >> 43);
+        return rnd;
+      }
+
+    };
+
+    template <typename _Word>
+    class RandomCore {
+    public:
+
+      typedef _Word Word;
+
+    private:
+
+      static const int bits = RandomTraits<Word>::bits;
+
+      static const int length = RandomTraits<Word>::length;
+      static const int shift = RandomTraits<Word>::shift;
+
+    public:
+
+      void initState() {
+        static const Word seedArray[4] = {
+          0x12345u, 0x23456u, 0x34567u, 0x45678u
+        };
+    
+        initState(seedArray, seedArray + 4);
+      }
+
+      void initState(Word seed) {
+
+        static const Word mul = RandomTraits<Word>::mul;
+
+        current = state; 
+
+        Word *curr = state + length - 1;
+        curr[0] = seed; --curr;
+        for (int i = 1; i < length; ++i) {
+          curr[0] = (mul * ( curr[1] ^ (curr[1] >> (bits - 2)) ) + i);
+          --curr;
+        }
+      }
+
+      template <typename Iterator>
+      void initState(Iterator begin, Iterator end) {
+
+        static const Word init = RandomTraits<Word>::arrayInit;
+        static const Word mul1 = RandomTraits<Word>::arrayMul1;
+        static const Word mul2 = RandomTraits<Word>::arrayMul2;
+
+
+        Word *curr = state + length - 1; --curr;
+        Iterator it = begin; int cnt = 0;
+        int num;
+
+        initState(init);
+
+        num = length > end - begin ? length : end - begin;
+        while (num--) {
+          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1)) 
+            + *it + cnt;
+          ++it; ++cnt;
+          if (it == end) {
+            it = begin; cnt = 0;
+          }
+          if (curr == state) {
+            curr = state + length - 1; curr[0] = state[0];
+          }
+          --curr;
+        }
+
+        num = length - 1; cnt = length - (curr - state) - 1;
+        while (num--) {
+          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul2))
+            - cnt;
+          --curr; ++cnt;
+          if (curr == state) {
+            curr = state + length - 1; curr[0] = state[0]; --curr;
+            cnt = 1;
+          }
+        }
+        
+        state[length - 1] = (Word)1 << (bits - 1);
+      }
+      
+      void copyState(const RandomCore& other) {
+        std::copy(other.state, other.state + length, state);
+        current = state + (other.current - other.state);
+      }
+
+      Word operator()() {
+        if (current == state) fillState();
+        --current;
+        Word rnd = *current;
+        return RandomTraits<Word>::tempering(rnd);
+      }
+
+    private:
+
+  
+      void fillState() {
+        static const Word mask[2] = { 0x0ul, RandomTraits<Word>::mask };
+        static const Word loMask = RandomTraits<Word>::loMask;
+        static const Word hiMask = RandomTraits<Word>::hiMask;
+
+        current = state + length; 
+
+        register Word *curr = state + length - 1;
+        register long num;
+      
+        num = length - shift;
+        while (num--) {
+          curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
+            curr[- shift] ^ mask[curr[-1] & 1ul];
+          --curr;
+        }
+        num = shift - 1;
+        while (num--) {
+          curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
+            curr[length - shift] ^ mask[curr[-1] & 1ul];
+          --curr;
+        }
+        curr[0] = (((curr[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
+          curr[length - shift] ^ mask[curr[length - 1] & 1ul];
+
+      }
+
+  
+      Word *current;
+      Word state[length];
+      
+    };
+
+
+    template <typename Result, 
+              int shift = (std::numeric_limits<Result>::digits + 1) / 2>
+    struct Masker {
+      static Result mask(const Result& result) {
+        return Masker<Result, (shift + 1) / 2>::
+          mask((Result)(result | (result >> shift)));
+      }
+    };
+    
+    template <typename Result>
+    struct Masker<Result, 1> {
+      static Result mask(const Result& result) {
+        return (Result)(result | (result >> 1));
+      }
+    };
+
+    template <typename Result, typename Word, 
+              int rest = std::numeric_limits<Result>::digits, int shift = 0, 
+              bool last = rest <= std::numeric_limits<Word>::digits>
+    struct IntConversion {
+      static const int bits = std::numeric_limits<Word>::digits;
+    
+      static Result convert(RandomCore<Word>& rnd) {
+        return (Result)(rnd() >> (bits - rest)) << shift;
+      }
+      
+    }; 
+
+    template <typename Result, typename Word, int rest, int shift> 
+    struct IntConversion<Result, Word, rest, shift, false> {
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return ((Result)rnd() << shift) | 
+          IntConversion<Result, Word, rest - bits, shift + bits>::convert(rnd);
+      }
+    };
+
+
+    template <typename Result, typename Word,
+              bool one_word = std::numeric_limits<Word>::digits < 
+                              std::numeric_limits<Result>::digits>
+    struct Mapping {
+      static Result map(RandomCore<Word>& rnd, const Result& bound) {
+        Word max = (Word)(bound - 1);
+        Result mask = Masker<Result>::mask(bound - 1);
+        Result num;
+        do {
+          num = IntConversion<Result, Word>::convert(rnd) & mask; 
+        } while (num > max);
+        return num;
+      }
+    };
+
+    template <typename Result, typename Word>
+    struct Mapping<Result, Word, false> {
+      static Result map(RandomCore<Word>& rnd, const Result& bound) {
+        Word max = (Word)(bound - 1);
+        Word mask = Masker<Word, (std::numeric_limits<Result>::digits + 1) / 2>
+          ::mask(max);
+        Word num;
+        do {
+          num = rnd() & mask;
+        } while (num > max);
+        return num;
+      }
+    };
+
+    template <typename Result, int exp, bool pos = (exp >= 0)>
+    struct ShiftMultiplier {
+      static const Result multiplier() {
+        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
+        res *= res;
+        if ((exp & 1) == 1) res *= (Result)2.0;
+        return res; 
+      }
+    };
+
+    template <typename Result, int exp>
+    struct ShiftMultiplier<Result, exp, false> {
+      static const Result multiplier() {
+        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
+        res *= res;
+        if ((exp & 1) == 1) res *= (Result)0.5;
+        return res; 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, 0, true> {
+      static const Result multiplier() {
+        return (Result)1.0; 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -20, true> {
+      static const Result multiplier() {
+        return (Result)(1.0/1048576.0); 
+      }
+    };
+    
+    template <typename Result>
+    struct ShiftMultiplier<Result, -32, true> {
+      static const Result multiplier() {
+        return (Result)(1.0/424967296.0); 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -53, true> {
+      static const Result multiplier() {
+        return (Result)(1.0/9007199254740992.0); 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -64, true> {
+      static const Result multiplier() {
+        return (Result)(1.0/18446744073709551616.0); 
+      }
+    };
+
+    template <typename Result, int exp>
+    struct Shifting {
+      static Result shift(const Result& result) {
+        return result * ShiftMultiplier<Result, exp>::multiplier();
+      }
+    };
+
+    template <typename Result, typename Word,
+              int rest = std::numeric_limits<Result>::digits, int shift = 0, 
+              bool last = rest <= std::numeric_limits<Word>::digits>
+    struct RealConversion{ 
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return Shifting<Result, - shift - rest>::
+          shift((Result)(rnd() >> (bits - rest)));
+      }
+    };
+
+    template <typename Result, typename Word, int rest, int shift>
+    struct RealConversion<Result, Word, rest, shift, false> { 
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return Shifting<Result, - shift - bits>::shift((Result)rnd()) +
+          RealConversion<Result, Word, rest-bits, shift + bits>::convert(rnd);
+      }
+    };
+
+    template <typename Result, typename Word>
+    struct Initializer {
+
+      template <typename Iterator>
+      static void init(RandomCore<Word>& rnd, Iterator begin, Iterator end) {
+        std::vector<Word> ws;
+        for (Iterator it = begin; it != end; ++it) {
+          ws.push_back((Word)*it);
+        }
+        rnd.initState(ws.begin(), ws.end());
+      }
+
+      template <typename Iterator>
+      static void init(RandomCore<Word>& rnd, Result seed) {
+        rnd.initState(seed);
+      }
+    };
+
+    template <typename Word>
+    struct BoolConversion {
+      static bool convert(RandomCore<Word>& rnd) {
+        return (rnd() & 1) == 1;
+      }
+    };
+
+  }
 
   /// \ingroup misc
@@ -41,29 +410,77 @@
   ///
   /// The Mersenne Twister is a twisted generalized feedback
-  /// shift-register generator of Matsumoto and Nishimura. The period of
-  /// this generator is \f$ 2^{19937} - 1 \f$ and it is equi-distributed in
-  /// 623 dimensions. The time performance of this generator is comparable
-  /// to the commonly used generators.
+  /// shift-register generator of Matsumoto and Nishimura. The period
+  /// of this generator is \f$ 2^{19937} - 1 \f$ and it is
+  /// equi-distributed in 623 dimensions for 32-bit numbers. The time
+  /// performance of this generator is comparable to the commonly used
+  /// generators.
+  ///
+  /// This implementation is specialized for both 32-bit and 64-bit
+  /// architectures. The generators differ sligthly in the
+  /// initialization and generation phase so they produce two
+  /// completly different sequences.
+  ///
+  /// The generator gives back random numbers of serveral types. To
+  /// get a random number from a range of a floating point type you
+  /// can use one form of the \c operator(). If you want to get random
+  /// number from a the {0, 1, ..., n-1} integer range use the \c
+  /// operator[]. And to get random number from the whole range of an
+  /// integer type you can use the \c integer() or \c uinteger()
+  /// functions. After all you can get random bool with equal chance
+  /// or given probability with the \c boolean() member function.
+  ///
+  ///\code
+  /// int a = rnd[100000];                  // 0..99999
+  /// int b = rnd.uinteger<int>();          // 0 .. 2^31 - 1
+  /// int c = rnd.integer<int>();           // - 2^31 .. 2^31 - 1
+  /// double d = rnd();                     // [0.0, 1.0)
+  /// double e = rnd(100.0);                // [0.0, 100.0)
+  /// double f = rnd(1.0, 2.0);             // [1.0, 2.0)
+  /// bool g = rnd.boolean();               // P(g = true) = 0.5
+  /// bool h = rnd.boolean(0.8);            // P(h = true) = 0.8
+  ///\endcode
+  ///
+  /// The lemon provides a global instance of the random number generator
+  /// which name is \c rnd. Usually it is a good programming convenience
+  /// to use this global generator to get random numbers.
   ///
   /// \author Balazs Dezso
   class Random {
-
-    static const int length = 624;
-    static const int shift = 397;
+  private:
+
+#if WORD_BIT == 32
+    typedef unsigned int Word;
+#elif WORD_BIT == 64
+    typedef unsigned long Word;
+#endif
+    
+    _random_bits::RandomCore<Word> core;
 
   public:
 
-    static const unsigned long min = 0ul;
-    static const unsigned long max = ~0ul;
-  
     /// \brief Constructor
     ///
-    /// Constructor with time dependent seeding.
-    Random() { initState(std::time(0)); }
+    /// Constructor with constant seeding.
+    Random() { core.initState(); }
 
     /// \brief Constructor
     ///
-    /// Constructor
-    Random(unsigned long seed) { initState(seed); }
+    /// Constructor with seed. The current number type will be converted
+    /// to the architecture word type.
+    template <typename Number>
+    Random(Number seed) { 
+      _random_bits::Initializer<Number, Word>::init(core, seed);
+    }
+
+    /// \brief Constructor
+    ///
+    /// Constructor with array seeding. The given range should contain
+    /// any number type and the numbers will be converted to the
+    /// architecture word type.
+    template <typename Iterator>
+    Random(Iterator begin, Iterator end) { 
+      typedef typename std::iterator_traits<Iterator>::value_type Number;
+      _random_bits::Initializer<Number, Word>::init(core, begin, end);
+    }
 
     /// \brief Copy constructor
@@ -71,7 +488,6 @@
     /// Copy constructor. The generated sequence will be identical to
     /// the other sequence.
-    Random(const Random& other) { 
-      std::copy(other.state, other.state + length, state);
-      current = state + (other.current - other.state);
+    Random(const Random& other) {
+      core.copyState(other.core);
     }
 
@@ -82,427 +498,92 @@
     Random& operator=(const Random& other) {
       if (&other != this) {
-        std::copy(other.state, other.state + length, state);
-        current = state + (other.current - other.state);
+        core.copyState(other.core);
       }
       return *this;
     }
 
-    /// \brief Returns an unsigned random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{32} - 1\} \f$.
-    unsigned long getUnsigned() {
-      if (current == state) fillState();
-      --current;
-      unsigned long rnd = *current;
-      rnd ^= (rnd >> 11);
-      rnd ^= (rnd << 7) & 0x9D2C5680ul;
-      rnd ^= (rnd << 15) & 0xEFC60000ul;
-      rnd ^= (rnd >> 18);
-      return rnd;
-    }
-
-    /// \brief Returns a random number
-    ///
-    /// It returns an integer random number from the range 
-    /// \f$ \{-2^{31}, \dots, 2^{31} - 1\} \f$.
-    long getInt() {
-      return (long)getUnsigned();
-    }
-    
-    /// \brief Returns an unsigned integer random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{31} - 1\} \f$.
-    long getNatural() {
-      return (long)(getUnsigned() >> 1);
-    }
-
+    /// \brief Returns a random real number
+    ///
+    /// It returns a random real number from the range [0, 1). The default
+    /// result type of this function is double.
+    template <typename Number>
+    Number operator()() {
+      return _random_bits::RealConversion<Number, Word>::convert(core);
+    }
+
+    double operator()() {
+      return operator()<double>();
+    }
+
+    /// \brief Returns a random real number
+    ///
+    /// It returns a random real number from the range [0, b).
+    template <typename Number>
+    Number operator()(Number b) { 
+      return operator()<Number>() * b; 
+    }
+
+    /// \brief Returns a random real number
+    ///
+    /// It returns a random real number from the range [a, b).
+    template <typename Number>
+    Number operator()(Number a, Number b) { 
+      return operator()<Number>() * (b - a) + a; 
+    }
+
+    /// \brief Returns a random integer from a range
+    ///
+    /// It returns a random integer from the range {0, 1, ..., bound - 1}.
+    template <typename Number>
+    Number operator[](const Number& bound) {
+      return _random_bits::Mapping<Number, Word>::map(core, bound);
+    }
+
+    /// \brief Returns a random non-negative integer
+    ///
+    /// It returns a random non-negative integer uniformly from the
+    /// whole range of the current \c Number type.  The default result
+    /// type of this function is unsigned int.
+    template <typename Number>
+    Number uinteger() {
+      return _random_bits::IntConversion<Number, Word>::convert(core);
+    }
+
+    unsigned int uinteger() {
+      return uinteger<unsigned int>();
+    }
+
+    /// \brief Returns a random integer
+    ///
+    /// It returns a random integer uniformly from the whole range of
+    /// the current \c Number type. The default result type of this
+    /// function is int.
+    template <typename Number>
+    Number integer() {
+      static const int nb = std::numeric_limits<Number>::digits + 
+        (std::numeric_limits<Number>::is_signed ? 1 : 0);
+      return _random_bits::IntConversion<Number, Word, nb>::convert(core);
+    }
+
+    int integer() {
+      return integer<int>();
+    }
+    
     /// \brief Returns a random bool
     ///
-    /// It returns a random bool.
-    bool getBool() {
-      return (bool)(getUnsigned() & 1);
-    }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$. The double will have 32 significant bits.
-    double getReal() {
-      return std::ldexp((double)getUnsigned(), -32);
-    }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$. The double will have 53 significant bits,
-    /// but it is slower than the \c getReal().
-    double getPrecReal() {
-      return std::ldexp((double)(getUnsigned() >> 5), -27) + 
-        std::ldexp((double)(getUnsigned() >> 6), -53);
-    }
-
-    /// \brief Returns an unsigned random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    unsigned long getUnsigned(unsigned long n) {
-      unsigned long mask = n - 1, rnd;
-      mask |= mask >> 1;
-      mask |= mask >> 2;
-      mask |= mask >> 4;
-      mask |= mask >> 8;
-      mask |= mask >> 16;
-      do rnd = getUnsigned() & mask; while (rnd >= n);
-      return rnd;
-    }
-
-    /// \brief Returns a random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    long getInt(long n) {
-      long mask = n - 1, rnd;
-      mask |= mask >> 1;
-      mask |= mask >> 2;
-      mask |= mask >> 4;
-      mask |= mask >> 8;
-      mask |= mask >> 16;
-      do rnd = getUnsigned() & mask; while (rnd >= n);
-      return rnd;
-    }
-
-  private:
-
-    void initState(unsigned long seed) {
-      static const unsigned long mul = 0x6c078965ul;
-
-      current = state; 
-
-      unsigned long *curr = state + length - 1;
-      curr[0] = seed; --curr;
-      for (int i = 1; i < length; ++i) {
-        curr[0] = (mul * ( curr[1] ^ (curr[1] >> 30) ) + i);
-        --curr;
-      }
-    }
-  
-    void fillState() {
-      static const unsigned long mask[2] = { 0x0ul, 0x9908B0DFul };
-      static const unsigned long loMask = (1ul << 31) - 1;
-      static const unsigned long hiMask = ~loMask;
-
-      current = state + length; 
-
-      register unsigned long *curr = state + length - 1;
-      register long num;
-      
-      num = length - shift;
-      while (num--) {
-        curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
-          curr[- shift] ^ mask[curr[-1] & 1ul];
-        --curr;
-      }
-      num = shift - 1;
-      while (num--) {
-        curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
-          curr[length - shift] ^ mask[curr[-1] & 1ul];
-        --curr;
-      }
-      curr[0] = (((curr[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
-        curr[length - shift] ^ mask[curr[length - 1] & 1ul];
-
-    }
-  
-    unsigned long *current;
-    unsigned long state[length];
+    /// It returns a random bool
+    bool boolean() {
+      return _random_bits::BoolConversion<Word>::convert(core);
+    }
+
+    /// \brief Returns a random bool
+    ///
+    /// It returns a random bool with given probability of true result
+    bool boolean(double p) {
+      return operator()() < p;
+    }
     
   };
 
-#elif WORD_BIT == 64
-
-  /// \ingroup misc
-  ///
-  /// \brief Mersenne Twister random number generator
-  ///
-  /// The Mersenne Twister is a twisted generalized feedback
-  /// shift-register generator of Matsumoto and Nishimura. The period of
-  /// this generator is \f$ 2^{19937} - 1 \f$ and it is equi-distributed in
-  /// 311 dimensions. The time performance of this generator is comparable
-  /// to the commonly used generators.
-  class Random {
-
-    static const int length = 312;
-    static const int shift = 156;
-
-  public:
-
-    static const unsigned long min = 0ul;
-    static const unsigned long max = ~0ul;
-  
-    /// \brief Constructor
-    ///
-    /// Constructor with time dependent seeding.
-    Random() { initState(std::time(0)); }
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    Random(unsigned long seed) { initState(seed); }
-
-    /// \brief Copy constructor
-    ///
-    /// Copy constructor. The generated sequence will be identical to
-    /// the other sequence.
-    Random(const Random& other) { 
-      std::copy(other.state, other.state + length, state);
-      current = state + (other.current - other.state);
-    }
-
-    /// \brief Assign operator
-    ///
-    /// Assign operator. The generated sequence will be identical to
-    /// the other sequence.
-    Random& operator=(const Random& other) {
-      if (&other != this) {
-        std::copy(other.state, other.state + length, state);
-        current = state + (other.current - other.state);
-      }
-      return *this;
-    }
-
-    /// \brief Returns an unsigned random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{64} - 1\} \f$.
-    unsigned long getUnsigned() {
-      if (current == state) fillState();
-      --current;
-      unsigned long rnd = *current;
-      rnd ^= (rnd >> 29) & 0x5555555555555555ul;
-      rnd ^= (rnd << 17) & 0x71D67FFFEDA60000ul;
-      rnd ^= (rnd << 37) & 0xFFF7EEE000000000ul;
-      rnd ^= (rnd >> 43);
-      return rnd;
-    }
-
-    /// \brief Returns a random number
-    ///
-    /// It returns an integer random number from the range 
-    /// \f$ \{-2^{63}, \dots, 2^{63} - 1\} \f$.
-    long getInt() {
-      return (long)getUnsigned();
-    }
-    
-    /// \brief Returns an unsigned integer random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{63} - 1\} \f$.
-    long getNatural() {
-      return (long)(getUnsigned() >> 1);
-    }
-
-    /// \brief Returns a random bool
-    ///
-    /// It returns a random bool.
-    bool getBool() {
-      return (bool)(getUnsigned() & 1);
-    }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$.
-    double getReal() {
-      return std::ldexp((double)(getUnsigned() >> 11), -53);
-    }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$. This function is identical to the \c getReal().
-    double getPrecReal() {
-      return getReal();
-    }
-
-    /// \brief Returns an unsigned random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    unsigned long getUnsigned(unsigned long n) {
-      unsigned long mask = n - 1, rnd;
-      mask |= mask >> 1;
-      mask |= mask >> 2;
-      mask |= mask >> 4;
-      mask |= mask >> 8;
-      mask |= mask >> 16;
-      mask |= mask >> 32;
-      do rnd = getUnsigned() & mask; while (rnd >= n);
-      return rnd;
-    }
-
-    /// \brief Returns a random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    long getInt(long n) {
-      long mask = n - 1, rnd;
-      mask |= mask >> 1;
-      mask |= mask >> 2;
-      mask |= mask >> 4;
-      mask |= mask >> 8;
-      mask |= mask >> 16;
-      mask |= mask >> 32;
-      do rnd = getUnsigned() & mask; while (rnd >= n);
-      return rnd;
-    }
-
-  private:
-
-    void initState(unsigned long seed) {
-
-      static const unsigned long mul = 0x5851F42D4C957F2Dul;
-
-      current = state; 
-
-      unsigned long *curr = state + length - 1;
-      curr[0] = seed; --curr;
-      for (int i = 1; i < length; ++i) {
-        curr[0] = (mul * ( curr[1] ^ (curr[1] >> 62) ) + i);
-        --curr;
-      }
-    }
-  
-    void fillState() {
-      static const unsigned long mask[2] = { 0x0ul, 0xB5026F5AA96619E9ul };
-      static const unsigned long loMask = (1ul << 31) - 1;
-      static const unsigned long hiMask = ~loMask;
-
-      current = state + length; 
-
-      register unsigned long *curr = state + length - 1;
-      register int num;
-      
-      num = length - shift;
-      while (num--) {
-        curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
-          curr[- shift] ^ mask[curr[-1] & 1ul];
-        --curr;
-      }
-      num = shift - 1;
-      while (num--) {
-        curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
-          curr[length - shift] ^ mask[curr[-1] & 1ul];
-        --curr;
-      }
-      curr[0] = (((curr[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
-        curr[length - shift] ^ mask[curr[length - 1] & 1ul];
-
-    }
-  
-    unsigned long *current;
-    unsigned long state[length];
-    
-  };
-
-#else
-
-  /// \ingroup misc
-  ///
-  /// \brief Mersenne Twister random number generator
-  ///
-  /// The Mersenne Twister is a twisted generalized feedback
-  /// shift-register generator of Matsumoto and Nishimura. There is
-  /// two different implementation in the Lemon library, one for
-  /// 32-bit processors and one for 64-bit processors. The period of
-  /// the generated sequence is \f$ 2^{19937} - 1 \f$, the generated
-  /// sequence of 32-bit random numbers is equi-distributed in 623
-  /// dimensions. The time performance of this generator is comparable
-  /// to the commonly used generators.
-  class Random {
-  public:
-
-    static const unsigned long min = 0ul;
-    static const unsigned long max = ~0ul;
-  
-    /// \brief Constructor
-    ///
-    /// Constructor with time dependent seeding.
-    Random() {}
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    Random(unsigned long seed) {}
-
-    /// \brief Copy constructor
-    ///
-    /// Copy constructor. The generated sequence will be identical to
-    /// the other sequence.
-    Random(const Random& other) {}
-
-    /// \brief Assign operator
-    ///
-    /// Assign operator. The generated sequence will be identical to
-    /// the other sequence.
-    Random& operator=(const Random& other) { return *this; }
-
-    /// \brief Returns an unsigned random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{64} - 1\} \f$ for 64-bit processors and from
-    /// \f$ \{0, 1, \dots, 2^{32} - 1\} \f$ for 32-bit processors.
-    unsigned long getUnsigned() { return 0ul; }
-
-    /// \brief Returns a random number
-    ///
-    /// It returns an integer random number from the range 
-    /// \f$ \{-2^{63}, \dots, 2^{63} - 1\} \f$ for 64-bit processors and from
-    /// \f$ \{-2^{31}, \dots, 2^{31} - 1\} \f$ for 32-bit processors.
-    long getInt() { return 0l; }
-    
-    /// \brief Returns an unsigned integer random number
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, 2^{63} - 1\} \f$ for 64-bit processors and
-    /// from \f$ \{0, 1, \dots, 2^{31} - 1\} \f$ for 32-bit processors.
-    long getNatural() { return 0l; }
-
-    /// \brief Returns a random bool
-    ///
-    /// It returns a random bool.
-    bool getBool() { return false; }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$. For 32-bit processors the generated random
-    /// number will just have 32 significant bits.
-    double getReal() { return 0.0; }
-
-    /// \brief Returns a real random number
-    ///
-    /// It returns a real random number from the range 
-    /// \f$ [0, 1) \f$. This function returns random numbers with 53
-    /// significant bits for 32-bit processors. For 64-bit processors
-    /// it is identical to the \c getReal().
-    double getPrecReal() { return 0.0; }
-
-    /// \brief Returns an unsigned random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    unsigned long getUnsigned(unsigned long n) { return 0; }
-
-    /// \brief Returns a random number from a given range
-    ///
-    /// It returns an unsigned integer random number from the range 
-    /// \f$ \{0, 1, \dots, n - 1\} \f$.
-    long getInt(long n) { return 0; }
-
-  };
-
-#endif
 
   /// \brief Global random number generator instance
Index: lemon/simann.h
===================================================================
--- lemon/simann.h	(revision 2229)
+++ lemon/simann.h	(revision 2242)
@@ -258,5 +258,5 @@
     bool accept() {
       double cost_diff = simann->getCurrCost() - simann->getPrevCost();
-      return (rnd.getReal() <= exp(-(cost_diff / temp)));
+      return (rnd() <= exp(-(cost_diff / temp)));
     }
     /// \brief Destructor.
@@ -366,5 +366,5 @@
       else {
         double cost_diff = simann->getCurrCost() - simann->getPrevCost();
-        return (rnd.getReal() <= exp(-(cost_diff / temp)));
+        return (rnd() <= exp(-(cost_diff / temp)));
       }
     }
