File indexing completed on 2025-08-05 08:19:07
0001
0002
0003
0004
0005
0006 #ifndef RANDOM_H
0007 #define RANDOM_H
0008
0009 #include <limits>
0010 #include <random>
0011
0012 #include <boost/math/constants/constants.hpp>
0013
0014 #include "fwd_decl.h"
0015
0016 namespace trento { namespace random {
0017
0018
0019 using Engine = std::mt19937_64;
0020
0021
0022 extern Engine engine;
0023
0024
0025 template <typename RealType = double>
0026 inline RealType canonical() {
0027 return std::generate_canonical
0028 <RealType, std::numeric_limits<RealType>::digits>
0029 (engine);
0030 }
0031
0032
0033 template <typename RealType = double>
0034 inline double cos_theta() {
0035 return 2 * canonical<RealType>() - 1;
0036 }
0037
0038
0039 template <typename RealType = double>
0040 inline double phi() {
0041 return math::constants::two_pi<RealType>() * canonical<RealType>();
0042 }
0043
0044 }}
0045
0046 #endif