lemon/random.h
changeset 2261 c52b572c294f
parent 2245 f09b1ea5c249
child 2285 8c5c4b5ae31c
equal deleted inserted replaced
3:a84599dd1a57 4:d4b4ea5e3fd4
   511         core.copyState(other.core);
   511         core.copyState(other.core);
   512       }
   512       }
   513       return *this;
   513       return *this;
   514     }
   514     }
   515 
   515 
   516     /// \brief Returns a random real number
   516     /// \brief Returns a random real number from the range [0, 1)
   517     ///
   517     ///
   518     /// It returns a random real number from the range [0, 1). The
   518     /// It returns a random real number from the range [0, 1). The
   519     /// default Number type is double.
   519     /// default Number type is double.
   520     template <typename Number>
   520     template <typename Number>
   521     Number real() {
   521     Number real() {
   524 
   524 
   525     double real() {
   525     double real() {
   526       return real<double>();
   526       return real<double>();
   527     }
   527     }
   528 
   528 
   529     /// \brief Returns a random real number
   529     /// \brief Returns a random real number the range [0, b)
   530     ///
   530     ///
   531     /// It returns a random real number from the range [0, b).
   531     /// It returns a random real number from the range [0, b).
   532     template <typename Number>
   532     template <typename Number>
   533     Number real(Number b) { 
   533     Number real(Number b) { 
   534       return real<Number>() * b; 
   534       return real<Number>() * b; 
   535     }
   535     }
   536 
   536 
   537     /// \brief Returns a random real number
   537     /// \brief Returns a random real number from the range [a, b)
   538     ///
   538     ///
   539     /// It returns a random real number from the range [a, b).
   539     /// It returns a random real number from the range [a, b).
   540     template <typename Number>
   540     template <typename Number>
   541     Number real(Number a, Number b) { 
   541     Number real(Number a, Number b) { 
   542       return real<Number>() * (b - a) + a; 
   542       return real<Number>() * (b - a) + a; 
   543     }
   543     }
   544 
   544 
   545     /// \brief Returns a random real number
   545     /// \brief Returns a random real number from the range [0, 1)
   546     ///
   546     ///
   547     /// It returns a random double from the range [0, 1).
   547     /// It returns a random double from the range [0, 1).
   548     double operator()() {
   548     double operator()() {
   549       return real<double>();
   549       return real<double>();
   550     }
   550     }
   551 
   551 
   552     /// \brief Returns a random real number
   552     /// \brief Returns a random real number from the range [0, b)
   553     ///
   553     ///
   554     /// It returns a random real number from the range [0, b).
   554     /// It returns a random real number from the range [0, b).
   555     template <typename Number>
   555     template <typename Number>
   556     Number operator()(Number b) { 
   556     Number operator()(Number b) { 
   557       return real<Number>() * b; 
   557       return real<Number>() * b; 
   558     }
   558     }
   559 
   559 
   560     /// \brief Returns a random real number
   560     /// \brief Returns a random real number from the range [a, b)
   561     ///
   561     ///
   562     /// It returns a random real number from the range [a, b).
   562     /// It returns a random real number from the range [a, b).
   563     template <typename Number>
   563     template <typename Number>
   564     Number operator()(Number a, Number b) { 
   564     Number operator()(Number a, Number b) { 
   565       return real<Number>() * (b - a) + a; 
   565       return real<Number>() * (b - a) + a;