gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Bugfix in Random (#173) - operator()s always return a double now - the faulty real<Num>(Num) and real<Num>(Num,Num) have been removed
0 1 0
default
1 file changed with 4 insertions and 22 deletions:
↑ Collapse diff ↑
Ignore white space 16 line context
... ...
@@ -687,59 +687,41 @@
687 687
    Number real() {
688 688
      return _random_bits::RealConversion<Number, Word>::convert(core);
689 689
    }
690 690

	
691 691
    double real() {
692 692
      return real<double>();
693 693
    }
694 694

	
695
    /// \brief Returns a random real number the range [0, b)
696
    ///
697
    /// It returns a random real number from the range [0, b).
698
    template <typename Number>
699
    Number real(Number b) {
700
      return real<Number>() * b;
701
    }
702

	
703
    /// \brief Returns a random real number from the range [a, b)
704
    ///
705
    /// It returns a random real number from the range [a, b).
706
    template <typename Number>
707
    Number real(Number a, Number b) {
708
      return real<Number>() * (b - a) + a;
709
    }
710

	
711 695
    /// @}
712 696

	
713 697
    ///\name Uniform distributions
714 698
    ///
715 699
    /// @{
716 700

	
717 701
    /// \brief Returns a random real number from the range [0, 1)
718 702
    ///
719 703
    /// It returns a random double from the range [0, 1).
720 704
    double operator()() {
721 705
      return real<double>();
722 706
    }
723 707

	
724 708
    /// \brief Returns a random real number from the range [0, b)
725 709
    ///
726 710
    /// It returns a random real number from the range [0, b).
727
    template <typename Number>
728
    Number operator()(Number b) {
729
      return real<Number>() * b;
711
    double operator()(double b) {
712
      return real<double>() * b;
730 713
    }
731 714

	
732 715
    /// \brief Returns a random real number from the range [a, b)
733 716
    ///
734 717
    /// It returns a random real number from the range [a, b).
735
    template <typename Number>
736
    Number operator()(Number a, Number b) {
737
      return real<Number>() * (b - a) + a;
718
    double operator()(double a, double b) {
719
      return real<double>() * (b - a) + a;
738 720
    }
739 721

	
740 722
    /// \brief Returns a random integer from a range
741 723
    ///
742 724
    /// It returns a random integer from the range {0, 1, ..., b - 1}.
743 725
    template <typename Number>
744 726
    Number integer(Number b) {
745 727
      return _random_bits::Mapping<Number, Word>::map(core, b);
0 comments (0 inline)