Changeset 359


Ignore:
Timestamp:
Aug 4, 2005, 11:38:47 AM (18 years ago)
Author:
Peter
Message:

moved inline implementations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/utility/random_singleton.h

    r358 r359  
    4141    /// @see uniform_int_min() and uniform_int_max().
    4242    ///
    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_ )); }
    4445
    4546
     
    4748    /// distribution between [ 0, 1 [.
    4849    ///
    49     inline double uniform_double() const;
    50 
     50    inline double uniform_double() const
     51    { return gsl_rng_uniform( r_ ); }
    5152
    5253    ///
     
    5859    /// \f$ f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}\f$
    5960    ///
    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 ); }
    6163
    6264
     
    6769    /// \frac{1}{\mu}e^{-\frac{x}{\mu}}\f$.
    6870    ///
    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
    7174
    7275    ///
     
    8285    /// @See uniform_int()!
    8386    ///
    84     inline u_long uniform_min() const;
    85  
     87    inline u_long uniform_min() const
     88    { return gsl_rng_min( r_ ); }
    8689
    8790    ///
    8891    /// @See uniform_int()!
    8992    ///
    90     inline u_long uniform_max() const;
    91 
     93    inline u_long uniform_max() const
     94    { return gsl_rng_max( r_ ); }
    9295
    9396    ///
    9497    /// Return seed to user for documentation purposes.
    9598    ///
    96     inline int seed() const;
     99    inline int seed() const
     100    { return gsl_rng_default_seed; }
    97101
    98102    ///
     
    108112    ///
    109113    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 ); }
    112116
    113117    ///
     
    117121    /// @see general_distribution_prob
    118122    ///
    119     inline size_t rnd_discrete();
    120 
     123    inline size_t rnd_discrete()
     124    { return gsl_ran_discrete( r_, gen_ );}
    121125
    122126    ///
     
    124128    /// returns the one used.
    125129    ///
    126     std::string generator_type(void) const;
     130    std::string generator_type(void) const
     131    { return static_cast<std::string>( gsl_rng_name( r_ ) ); }
    127132
    128133    ///
     
    164169  };
    165170
    166 double random_singleton::exponential( const double& mu ) const
    167 {
    168   return gsl_ran_exponential( r_, mu );
    169 }
    170 
    171 
    172 double random_singleton::gaussian( const double& sigma ) const
    173 {
    174   return gsl_ran_gaussian( r_, sigma );
    175 }
    176 
    177 
    178 inline std::string random_singleton::generator_type() const
    179 {
    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() const
    191 {
    192   return gsl_rng_default_seed;
    193 }
    194 
    195 
    196 double random_singleton::uniform_double() const
    197 {
    198   return gsl_rng_uniform( r_ );
    199 }
    200 
    201 
    202 u_long random_singleton::uniform_int(const u_long n) const
    203 {
    204     return ( n ? gsl_rng_uniform_int(r_,n) : gsl_rng_get( r_ ));
    205 }
    206 
    207 
    208 u_long random_singleton::uniform_min() const
    209 {
    210   return gsl_rng_min( r_ );
    211 }
    212 
    213 
    214 u_long random_singleton::uniform_max() const
    215 {
    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 
    226171}} // of namespace utility and namespace theplu
    227172
Note: See TracChangeset for help on using the changeset viewer.