Changeset 3894


Ignore:
Timestamp:
Mar 27, 2020, 12:02:16 PM (2 months ago)
Author:
Peter
Message:

extend DiscreteUniform? so it fulfills the requirements for UniformRandomNumberGenerator? concept in boost. Add a DiscreteDistribution? that can be used as to connect RNG in yat with random distribution classes in boost. refs 858 and #869

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r3883 r3894  
    8787  test/ncc.test \
    8888  test/negative_binomial.test \
     89  test/negative_binomial_distribution.test \
    8990  test/nni.test test/normalization.test \
    9091  test/ostream_iterator.test \
  • trunk/yat/random/Makefile.am

    r3454 r3894  
    2323
    2424nobase_include_HEADERS += $(srcdir)/yat/random/copy_k_of_n.h
     25nobase_include_HEADERS += $(srcdir)/yat/random/Distribution.h
    2526nobase_include_HEADERS += $(srcdir)/yat/random/random.h
  • trunk/yat/random/random.cc

    r3792 r3894  
    314314    }
    315315    return gsl_rng_uniform_int(rng_->rng(),n);
     316  }
     317
     318
     319  unsigned long int DiscreteUniform::min(void) const
     320  {
     321    return range_ ? 0 : rng_->min();
     322  }
     323
     324
     325  unsigned long int DiscreteUniform::max(void) const
     326  {
     327    return range_ ? (range_-1) : rng_->max();
    316328  }
    317329
  • trunk/yat/random/random.h

    r3893 r3894  
    451451    unsigned long operator()(unsigned long n) const;
    452452
     453    /**
     454       For n>0 the min value is 0. For n=0 (default) the min value
     455       is RNG::min(), typically zero but depending on generator in use.
     456
     457       \return smallest possible value
     458
     459       \since New in yat 0.18
     460     */
     461    unsigned long int min(void) const;
     462
     463    /**
     464       For n>0 the max value is n-1. For n=0 (default) the max value
     465       is RNG::max().
     466
     467       \return maximal value that class returns
     468
     469       \since New in yat 0.18
     470     */
     471    unsigned long int max(void) const;
     472
    453473  private:
    454474    unsigned long range_;
Note: See TracChangeset for help on using the changeset viewer.