Improve API doc of Random classes (#602)
authorPeter Kovacs <kpeter@inf.elte.hu>
Sat, 17 Feb 2018 23:55:16 +0100
changeset 138004f57dad1b07
parent 1379 db1d342a1087
child 1389 57167d92e96c
Improve API doc of Random classes (#602)
lemon/random.h
     1.1 --- a/lemon/random.h	Thu Oct 08 13:48:09 2015 +0200
     1.2 +++ b/lemon/random.h	Sat Feb 17 23:55:16 2018 +0100
     1.3 @@ -111,7 +111,6 @@
     1.4        static const Word loMask = (1u << 31) - 1;
     1.5        static const Word hiMask = ~loMask;
     1.6  
     1.7 -
     1.8        static Word tempering(Word rnd) {
     1.9          rnd ^= (rnd >> 11);
    1.10          rnd ^= (rnd << 7) & 0x9D2C5680u;
    1.11 @@ -243,7 +242,6 @@
    1.12  
    1.13      private:
    1.14  
    1.15 -
    1.16        void fillState() {
    1.17          static const Word mask[2] = { 0x0ul, RandomTraits<Word>::mask };
    1.18          static const Word loMask = RandomTraits<Word>::loMask;
    1.19 @@ -271,7 +269,6 @@
    1.20  
    1.21        }
    1.22  
    1.23 -
    1.24        Word *current;
    1.25        Word state[length];
    1.26  
    1.27 @@ -471,12 +468,12 @@
    1.28      ///
    1.29      /// The Mersenne Twister is a twisted generalized feedback
    1.30      /// shift-register generator of Matsumoto and Nishimura. The period
    1.31 -    /// of this generator is \f$ 2^{19937} - 1 \f$ and it is
    1.32 +    /// of this generator is \f$ 2^{19937} - 1\f$ and it is
    1.33      /// equi-distributed in 623 dimensions for 32-bit numbers. The time
    1.34      /// performance of this generator is comparable to the commonly used
    1.35      /// generators.
    1.36      ///
    1.37 -    /// This is a template version implementation both 32-bit and
    1.38 +    /// This is a template implementation of both 32-bit and
    1.39      /// 64-bit architecture optimized versions. The generators differ
    1.40      /// sligthly in the initialization and generation phase so they
    1.41      /// produce two completly different sequences.
    1.42 @@ -485,15 +482,19 @@
    1.43      /// Random, \ref Random32 or \ref Random64.
    1.44      ///
    1.45      /// The generator gives back random numbers of serveral types. To
    1.46 -    /// get a random number from a range of a floating point type you
    1.47 +    /// get a random number from a range of a floating point type, you
    1.48      /// can use one form of the \c operator() or the \c real() member
    1.49      /// function. If you want to get random number from the {0, 1, ...,
    1.50 -    /// n-1} integer range use the \c operator[] or the \c integer()
    1.51 +    /// n-1} integer range, use the \c operator[] or the \c integer()
    1.52      /// method. And to get random number from the whole range of an
    1.53 -    /// integer type you can use the argumentless \c integer() or \c
    1.54 -    /// uinteger() functions. After all you can get random bool with
    1.55 -    /// equal chance of true and false or given probability of true
    1.56 -    /// result with the \c boolean() member functions.
    1.57 +    /// integer type, you can use the argumentless \c integer() or
    1.58 +    /// \c uinteger() functions. Finally, you can get random bool with
    1.59 +    /// equal chance of true and false or with given probability of true
    1.60 +    /// result using the \c boolean() member functions.
    1.61 +    ///
    1.62 +    /// Various non-uniform distributions are also supported: normal (Gauss),
    1.63 +    /// exponential, gamma, Poisson, etc.; and a few two-dimensional
    1.64 +    /// distributions, too.
    1.65      ///
    1.66      ///\code
    1.67      /// // The commented code is identical to the other
    1.68 @@ -513,13 +514,11 @@
    1.69      /// bool h = rnd.boolean(0.8);            // P(h = true) = 0.8
    1.70      ///\endcode
    1.71      ///
    1.72 -    /// LEMON provides a global instance of the random number
    1.73 -    /// generator which name is \ref lemon::rnd "rnd". Usually it is a
    1.74 -    /// good programming convenience to use this global generator to get
    1.75 -    /// random numbers.
    1.76 +    /// LEMON provides a global instance of the random number generator:
    1.77 +    /// \ref lemon::rnd "rnd". In most cases, it is a good practice
    1.78 +    /// to use this global generator to get random numbers.
    1.79      ///
    1.80      /// \sa \ref Random, \ref Random32 or \ref Random64.
    1.81 -    ///
    1.82      template<class Word>
    1.83      class Random {
    1.84      private:
    1.85 @@ -644,9 +643,9 @@
    1.86          return true;
    1.87        }
    1.88  
    1.89 -      /// \brief Seding from process id and time
    1.90 +      /// \brief Seeding from process id and time
    1.91        ///
    1.92 -      /// Seding from process id and time. This function uses the
    1.93 +      /// Seeding from process id and time. This function uses the
    1.94        /// current process id and the current time for initialize the
    1.95        /// random sequence.
    1.96        /// \return Currently always \c true.
    1.97 @@ -942,7 +941,7 @@
    1.98  
    1.99        ///@}
   1.100  
   1.101 -      ///\name Two Dimensional Distributions
   1.102 +      ///\name Two-Dimensional Distributions
   1.103        ///
   1.104        ///@{
   1.105  
   1.106 @@ -960,7 +959,7 @@
   1.107          } while(V1*V1+V2*V2>=1);
   1.108          return dim2::Point<double>(V1,V2);
   1.109        }
   1.110 -      /// A kind of two dimensional normal (Gauss) distribution
   1.111 +      /// A kind of two-dimensional normal (Gauss) distribution
   1.112  
   1.113        /// This function provides a turning symmetric two-dimensional distribution.
   1.114        /// Both coordinates are of standard normal distribution, but they are not
   1.115 @@ -979,7 +978,7 @@
   1.116          double W=std::sqrt(-2*std::log(S)/S);
   1.117          return dim2::Point<double>(W*V1,W*V2);
   1.118        }
   1.119 -      /// A kind of two dimensional exponential distribution
   1.120 +      /// A kind of two-dimensional exponential distribution
   1.121  
   1.122        /// This function provides a turning symmetric two-dimensional distribution.
   1.123        /// The x-coordinate is of conditionally exponential distribution
   1.124 @@ -1008,49 +1007,48 @@
   1.125    ///
   1.126    /// \brief Mersenne Twister random number generator
   1.127    ///
   1.128 -  /// This class implements either the 32 bit or the 64 bit version of
   1.129 +  /// This class implements either the 32-bit or the 64-bit version of
   1.130    /// the Mersenne Twister random number generator algorithm
   1.131 -  /// depending the the system architecture.
   1.132 +  /// depending on the system architecture.
   1.133    /// 
   1.134 -  /// For the API description, see its base class \ref
   1.135 -  /// _random_bits::Random
   1.136 +  /// For the API description, see its base class
   1.137 +  /// \ref _random_bits::Random.
   1.138    ///
   1.139    /// \sa \ref _random_bits::Random
   1.140    typedef _random_bits::Random<unsigned long> Random;
   1.141 +
   1.142    /// \ingroup misc
   1.143    ///
   1.144 -  /// \brief Mersenne Twister random number generator (32 bit version)
   1.145 +  /// \brief Mersenne Twister random number generator (32-bit version)
   1.146    ///
   1.147 -  /// This class implements the 32 bit version of the Mersenne Twister
   1.148 +  /// This class implements the 32-bit version of the Mersenne Twister
   1.149    /// random number generator algorithm. It is recommended to be used
   1.150    /// when someone wants to make sure that the \e same pseudo random
   1.151    /// sequence will be generated on every platfrom.
   1.152    ///
   1.153 -  /// For the API description, see its base class \ref
   1.154 -  /// _random_bits::Random
   1.155 +  /// For the API description, see its base class
   1.156 +  /// \ref _random_bits::Random.
   1.157    ///
   1.158    /// \sa \ref _random_bits::Random
   1.159 +  typedef _random_bits::Random<unsigned int> Random32;
   1.160  
   1.161 -  typedef _random_bits::Random<unsigned int> Random32;
   1.162    /// \ingroup misc
   1.163    ///
   1.164 -  /// \brief Mersenne Twister random number generator (64 bit version)
   1.165 +  /// \brief Mersenne Twister random number generator (64-bit version)
   1.166    ///
   1.167 -  /// This class implements the 64 bit version of the Mersenne Twister
   1.168 -  /// random number generator algorithm. (Even though it will run
   1.169 -  /// on 32 bit architectures, too.) It is recommended to ber used when
   1.170 +  /// This class implements the 64-bit version of the Mersenne Twister
   1.171 +  /// random number generator algorithm. (Even though it runs
   1.172 +  /// on 32-bit architectures, too.) It is recommended to be used when
   1.173    /// someone wants to make sure that the \e same pseudo random sequence
   1.174    /// will be generated on every platfrom.
   1.175    ///
   1.176 -  /// For the API description, see its base class \ref
   1.177 -  /// _random_bits::Random
   1.178 +  /// For the API description, see its base class
   1.179 +  /// \ref _random_bits::Random.
   1.180    ///
   1.181    /// \sa \ref _random_bits::Random
   1.182    typedef _random_bits::Random<unsigned long long> Random64;
   1.183  
   1.184 -
   1.185    extern Random rnd;
   1.186 -
   1.187    
   1.188  }
   1.189