Ignore:
Timestamp:
Dec 26, 2006, 10:56:26 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Addresses #170.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/random/random.h

    r706 r718  
    9898    /// generator can return.
    9999    ///
    100     inline u_long max(void) const { return gsl_rng_max(rng_); }
     100    u_long max(void) const;
    101101
    102102    ///
     
    104104    /// generator can return.
    105105    ///
    106     inline u_long min(void) const { return gsl_rng_min(rng_); }
     106    u_long min(void) const;
    107107
    108108    ///
    109109    /// @brief Returns the name of the random number generator
    110110    ///
    111     inline std::string name(void) const { return gsl_rng_name(rng_); }
     111    std::string name(void) const;
    112112
    113113    ///
    114114    /// @return const pointer to underlying GSL random generator.
    115115    ///
    116     inline const gsl_rng* rng(void) const { return rng_; }
     116    const gsl_rng* rng(void) const;
    117117
    118118    ///
     
    125125    /// @see seed_from_devurandom
    126126    ///
    127     inline void seed(u_long s) const { gsl_rng_set(rng_,s); }
     127    void seed(u_long s) const;
    128128
    129129    ///
     
    168168    /// @return const pointer to underlying GSL random generator.
    169169    ///
    170     inline const gsl_rng* rng(void) const { return rng_; }
    171 
     170    const gsl_rng* rng(void) const;
    172171
    173172  private:
     
    209208    /// @see seed_from_devurandom, RNG::seed_from_devurandom, RNG::seed
    210209    ///
    211     inline void seed(u_long s) const { rng_->seed(s); }
     210    void seed(u_long s) const;
    212211
    213212    ///
     
    256255    /// @return A random number.
    257256    ///
    258     inline u_long
    259     operator()(void) const { return gsl_ran_discrete(rng_->rng(), gen_); }
     257    u_long operator()(void) const;
    260258
    261259  private:
     
    281279    /// @brief Default constructor.
    282280    ///
    283     DiscreteUniform(void) : range_(rng_->max()) {}
     281    DiscreteUniform(void);
    284282
    285283    ///
     
    296294    /// functionality will not return).
    297295    ///
    298     DiscreteUniform(const u_long n) : range_(n)
    299     { if ( range_>rng_->max() ) range_=rng_->max(); }
     296    DiscreteUniform(const u_long n);
    300297
    301298    ///
     
    304301    /// likely. n is set in constructor.
    305302    ///
    306     inline u_long
    307     operator()(void) const { return gsl_rng_uniform_int(rng_->rng(), range_); }
     303    u_long operator()(void) const;
    308304
    309305    ///
     
    312308    /// likely.
    313309    ///
    314     inline u_long operator()(const u_long n) const
    315     { return gsl_rng_uniform_int(rng_->rng(), n); }
     310    u_long operator()(const u_long n) const;
    316311
    317312  private:
     
    347342    /// @return A Poisson distributed number.
    348343    ///
    349     inline u_long
    350     operator()(void) const { return gsl_ran_poisson(rng_->rng(), m_); }
    351 
    352     ///
    353     /// @return A Poisson distributed number with expectation value \a
    354     /// m
     344    u_long operator()(void) const;
     345
     346    ///
     347    /// @return A Poisson distributed number with expectation value
     348    /// \a m
    355349    ///
    356350    /// @note this operator ignores parameters set in Constructor
    357351    ///
    358     inline u_long
    359     operator()(const double m) const { return gsl_ran_poisson(rng_->rng(), m); }
     352    u_long operator()(const double m) const;
    360353
    361354  private:
     
    393386    /// @see seed_from_devurandom, RNG::seed_from_devurandom, RNG::seed
    394387    ///
    395     inline void seed(u_long s) const { rng_->seed(s); }
     388    void seed(u_long s) const;
    396389
    397390    ///
     
    414407  };
    415408
     409  // ContinuousUniform is declared before ContinuousGeneral to avoid
     410  // forward declaration
    416411  ///
    417412  /// @brief Uniform distribution
     
    427422  {
    428423  public:
    429     inline double operator()(void) const { return gsl_rng_uniform(rng_->rng());}
     424    double operator()(void) const;
    430425  };
    431426
     
    451446    /// @return A random number.
    452447    ///
    453     inline double operator()(void) const
    454     { return hist_.observation_value(discrete_())+(u_()-0.5)*hist_.spacing(); }
     448    double operator()(void) const;
    455449
    456450  private:
     
    476470    /// @param m is the expectation value of the distribution.
    477471    ///
    478     inline Exponential(const double m=1);
     472    Exponential(const double m=1);
    479473
    480474    ///
    481475    /// @return A random number from exponential distribution.
    482476    ///
    483     inline double
    484     operator()(void) const { return gsl_ran_exponential(rng_->rng(), m_); }
     477    double operator()(void) const;
    485478
    486479    ///
     
    490483    /// @note This operator ignores parameters given in constructor.
    491484    ///
    492     inline double operator()(const double m) const
    493     { return gsl_ran_exponential(rng_->rng(), m); }
     485    double operator()(const double m) const;
    494486
    495487  private:
     
    524516    /// @return A random Gaussian number
    525517    ///
    526     inline double
    527     operator()(void) const { return gsl_ran_gaussian(rng_->rng(), s_)+m_; }
     518    double operator()(void) const;
    528519
    529520    ///
     
    533524    /// @note this operator ignores parameters given in Constructor
    534525    ///
    535     inline double
    536     operator()(const double s) const { return gsl_ran_gaussian(rng_->rng(), s); }
     526    double operator()(const double s) const;
    537527
    538528    ///
     
    542532    /// @note this operator ignores parameters given in Constructor
    543533    ///
    544     inline double operator()(const double s, const double m) const
    545     { return gsl_ran_gaussian(rng_->rng(), s)+m; }
     534    double operator()(const double s, const double m) const;
    546535
    547536  private:
Note: See TracChangeset for help on using the changeset viewer.