Changeset 1380:04f57dad1b07 in lemon for lemon/random.h
 Timestamp:
 02/17/18 23:55:16 (4 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/random.h
r1379 r1380 111 111 static const Word loMask = (1u << 31)  1; 112 112 static const Word hiMask = ~loMask; 113 114 113 115 114 static Word tempering(Word rnd) { … … 243 242 244 243 private: 245 246 244 247 245 void fillState() { … … 272 270 } 273 271 274 275 272 Word *current; 276 273 Word state[length]; … … 472 469 /// The Mersenne Twister is a twisted generalized feedback 473 470 /// shiftregister generator of Matsumoto and Nishimura. The period 474 /// of this generator is \f$ 2^{19937}  1 471 /// of this generator is \f$ 2^{19937}  1\f$ and it is 475 472 /// equidistributed in 623 dimensions for 32bit numbers. The time 476 473 /// performance of this generator is comparable to the commonly used 477 474 /// generators. 478 475 /// 479 /// This is a template version implementationboth 32bit and476 /// This is a template implementation of both 32bit and 480 477 /// 64bit architecture optimized versions. The generators differ 481 478 /// sligthly in the initialization and generation phase so they … … 486 483 /// 487 484 /// The generator gives back random numbers of serveral types. To 488 /// get a random number from a range of a floating point type you485 /// get a random number from a range of a floating point type, you 489 486 /// can use one form of the \c operator() or the \c real() member 490 487 /// function. If you want to get random number from the {0, 1, ..., 491 /// n1} integer range use the \c operator[] or the \c integer()488 /// n1} integer range, use the \c operator[] or the \c integer() 492 489 /// method. And to get random number from the whole range of an 493 /// integer type you can use the argumentless \c integer() or \c 494 /// uinteger() functions. After all you can get random bool with 495 /// equal chance of true and false or given probability of true 496 /// result with the \c boolean() member functions. 490 /// integer type, you can use the argumentless \c integer() or 491 /// \c uinteger() functions. Finally, you can get random bool with 492 /// equal chance of true and false or with given probability of true 493 /// result using the \c boolean() member functions. 494 /// 495 /// Various nonuniform distributions are also supported: normal (Gauss), 496 /// exponential, gamma, Poisson, etc.; and a few twodimensional 497 /// distributions, too. 497 498 /// 498 499 ///\code … … 514 515 ///\endcode 515 516 /// 516 /// LEMON provides a global instance of the random number 517 /// generator which name is \ref lemon::rnd "rnd". Usually it is a 518 /// good programming convenience to use this global generator to get 519 /// random numbers. 517 /// LEMON provides a global instance of the random number generator: 518 /// \ref lemon::rnd "rnd". In most cases, it is a good practice 519 /// to use this global generator to get random numbers. 520 520 /// 521 521 /// \sa \ref Random, \ref Random32 or \ref Random64. 522 ///523 522 template<class Word> 524 523 class Random { … … 645 644 } 646 645 647 /// \brief Se ding from process id and time648 /// 649 /// Se ding from process id and time. This function uses the646 /// \brief Seeding from process id and time 647 /// 648 /// Seeding from process id and time. This function uses the 650 649 /// current process id and the current time for initialize the 651 650 /// random sequence. … … 943 942 ///@} 944 943 945 ///\name Two 944 ///\name TwoDimensional Distributions 946 945 /// 947 946 ///@{ … … 961 960 return dim2::Point<double>(V1,V2); 962 961 } 963 /// A kind of two 962 /// A kind of twodimensional normal (Gauss) distribution 964 963 965 964 /// This function provides a turning symmetric twodimensional distribution. … … 980 979 return dim2::Point<double>(W*V1,W*V2); 981 980 } 982 /// A kind of two 981 /// A kind of twodimensional exponential distribution 983 982 984 983 /// This function provides a turning symmetric twodimensional distribution. … … 1009 1008 /// \brief Mersenne Twister random number generator 1010 1009 /// 1011 /// This class implements either the 32 bit or the 64bit version of1010 /// This class implements either the 32bit or the 64bit version of 1012 1011 /// the Mersenne Twister random number generator algorithm 1013 /// depending thethe system architecture.1012 /// depending on the system architecture. 1014 1013 /// 1015 /// For the API description, see its base class \ref1016 /// _random_bits::Random1014 /// For the API description, see its base class 1015 /// \ref _random_bits::Random. 1017 1016 /// 1018 1017 /// \sa \ref _random_bits::Random 1019 1018 typedef _random_bits::Random<unsigned long> Random; 1019 1020 1020 /// \ingroup misc 1021 1021 /// 1022 /// \brief Mersenne Twister random number generator (32 1022 /// \brief Mersenne Twister random number generator (32bit version) 1023 1023 /// 1024 /// This class implements the 32 1024 /// This class implements the 32bit version of the Mersenne Twister 1025 1025 /// random number generator algorithm. It is recommended to be used 1026 1026 /// when someone wants to make sure that the \e same pseudo random 1027 1027 /// sequence will be generated on every platfrom. 1028 1028 /// 1029 /// For the API description, see its base class \ref1030 /// _random_bits::Random1029 /// For the API description, see its base class 1030 /// \ref _random_bits::Random. 1031 1031 /// 1032 1032 /// \sa \ref _random_bits::Random 1033 1034 1033 typedef _random_bits::Random<unsigned int> Random32; 1034 1035 1035 /// \ingroup misc 1036 1036 /// 1037 /// \brief Mersenne Twister random number generator (64 1037 /// \brief Mersenne Twister random number generator (64bit version) 1038 1038 /// 1039 /// This class implements the 64 1040 /// random number generator algorithm. (Even though it will run1041 /// on 32 bit architectures, too.) It is recommended to berused when1039 /// This class implements the 64bit version of the Mersenne Twister 1040 /// random number generator algorithm. (Even though it runs 1041 /// on 32bit architectures, too.) It is recommended to be used when 1042 1042 /// someone wants to make sure that the \e same pseudo random sequence 1043 1043 /// will be generated on every platfrom. 1044 1044 /// 1045 /// For the API description, see its base class \ref1046 /// _random_bits::Random1045 /// For the API description, see its base class 1046 /// \ref _random_bits::Random. 1047 1047 /// 1048 1048 /// \sa \ref _random_bits::Random 1049 1049 typedef _random_bits::Random<unsigned long long> Random64; 1050 1050 1051 1052 1051 extern Random rnd; 1053 1054 1052 1055 1053 }
Note: See TracChangeset
for help on using the changeset viewer.