Changeset 359
- Timestamp:
- Aug 4, 2005, 11:38:47 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/utility/random_singleton.h
r358 r359 41 41 /// @see uniform_int_min() and uniform_int_max(). 42 42 /// 43 inline u_long uniform_int(const u_long n=0) const; 43 inline u_long uniform_int(const u_long n=0) const 44 { return ( n ? gsl_rng_uniform_int(r_,n) : gsl_rng_get( r_ )); } 44 45 45 46 … … 47 48 /// distribution between [ 0, 1 [. 48 49 /// 49 inline double uniform_double() const ;50 50 inline double uniform_double() const 51 { return gsl_rng_uniform( r_ ); } 51 52 52 53 /// … … 58 59 /// \f$ f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}\f$ 59 60 /// 60 inline double gaussian( const double& sigma=1 ) const; 61 inline double gaussian( const double& sigma=1 ) const 62 { return gsl_ran_gaussian( r_, sigma ); } 61 63 62 64 … … 67 69 /// \frac{1}{\mu}e^{-\frac{x}{\mu}}\f$. 68 70 /// 69 inline double exponential( const double& mu=1 ) const; 70 71 inline double exponential( const double& mu=1 ) const 72 { return gsl_ran_exponential( r_, mu ); } 73 71 74 72 75 /// … … 82 85 /// @See uniform_int()! 83 86 /// 84 inline u_long uniform_min() const ;85 87 inline u_long uniform_min() const 88 { return gsl_rng_min( r_ ); } 86 89 87 90 /// 88 91 /// @See uniform_int()! 89 92 /// 90 inline u_long uniform_max() const ;91 93 inline u_long uniform_max() const 94 { return gsl_rng_max( r_ ); } 92 95 93 96 /// 94 97 /// Return seed to user for documentation purposes. 95 98 /// 96 inline int seed() const; 99 inline int seed() const 100 { return gsl_rng_default_seed; } 97 101 98 102 /// … … 108 112 /// 109 113 inline void general_distribution_prob( const size_t& k, 110 const double* p ) ;111 114 const double* p ) 115 { gen_ = gsl_ran_discrete_preproc( k, p ); } 112 116 113 117 /// … … 117 121 /// @see general_distribution_prob 118 122 /// 119 inline size_t rnd_discrete() ;120 123 inline size_t rnd_discrete() 124 { return gsl_ran_discrete( r_, gen_ );} 121 125 122 126 /// … … 124 128 /// returns the one used. 125 129 /// 126 std::string generator_type(void) const; 130 std::string generator_type(void) const 131 { return static_cast<std::string>( gsl_rng_name( r_ ) ); } 127 132 128 133 /// … … 164 169 }; 165 170 166 double random_singleton::exponential( const double& mu ) const167 {168 return gsl_ran_exponential( r_, mu );169 }170 171 172 double random_singleton::gaussian( const double& sigma ) const173 {174 return gsl_ran_gaussian( r_, sigma );175 }176 177 178 inline std::string random_singleton::generator_type() const179 {180 return static_cast<std::string>( gsl_rng_name( r_ ) );181 }182 183 184 size_t random_singleton::rnd_discrete()185 {186 return gsl_ran_discrete( r_, gen_ );187 }188 189 190 int random_singleton::seed() const191 {192 return gsl_rng_default_seed;193 }194 195 196 double random_singleton::uniform_double() const197 {198 return gsl_rng_uniform( r_ );199 }200 201 202 u_long random_singleton::uniform_int(const u_long n) const203 {204 return ( n ? gsl_rng_uniform_int(r_,n) : gsl_rng_get( r_ ));205 }206 207 208 u_long random_singleton::uniform_min() const209 {210 return gsl_rng_min( r_ );211 }212 213 214 u_long random_singleton::uniform_max() const215 {216 return gsl_rng_max( r_ );217 }218 219 220 void random_singleton::general_distribution_prob( const size_t& k,221 const double* p )222 {223 gen_ = gsl_ran_discrete_preproc( k, p );224 }225 226 171 }} // of namespace utility and namespace theplu 227 172
Note: See TracChangeset
for help on using the changeset viewer.