COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r482 r487  
    345345    };
    346346
    347     template <typename Result, int exp, bool pos = (exp >= 0)>
     347    template <typename Result, int exp>
    348348    struct ShiftMultiplier {
    349       static const Result multiplier() {
    350         Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
    351         res *= res;
    352         if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
    353         return res;
    354       }
    355     };
    356 
    357     template <typename Result, int exp>
    358     struct ShiftMultiplier<Result, exp, false> {
    359349      static const Result multiplier() {
    360350        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
     
    366356
    367357    template <typename Result>
    368     struct ShiftMultiplier<Result, 0, true> {
     358    struct ShiftMultiplier<Result, 0> {
    369359      static const Result multiplier() {
    370360        return static_cast<Result>(1.0);
     
    373363
    374364    template <typename Result>
    375     struct ShiftMultiplier<Result, -20, true> {
     365    struct ShiftMultiplier<Result, 20> {
    376366      static const Result multiplier() {
    377367        return static_cast<Result>(1.0/1048576.0);
     
    380370
    381371    template <typename Result>
    382     struct ShiftMultiplier<Result, -32, true> {
     372    struct ShiftMultiplier<Result, 32> {
    383373      static const Result multiplier() {
    384         return static_cast<Result>(1.0/424967296.0);
     374        return static_cast<Result>(1.0/4294967296.0);
    385375      }
    386376    };
    387377
    388378    template <typename Result>
    389     struct ShiftMultiplier<Result, -53, true> {
     379    struct ShiftMultiplier<Result, 53> {
    390380      static const Result multiplier() {
    391381        return static_cast<Result>(1.0/9007199254740992.0);
     
    394384
    395385    template <typename Result>
    396     struct ShiftMultiplier<Result, -64, true> {
     386    struct ShiftMultiplier<Result, 64> {
    397387      static const Result multiplier() {
    398388        return static_cast<Result>(1.0/18446744073709551616.0);
     
    414404
    415405      static Result convert(RandomCore<Word>& rnd) {
    416         return Shifting<Result, - shift - rest>::
     406        return Shifting<Result, shift + rest>::
    417407          shift(static_cast<Result>(rnd() >> (bits - rest)));
    418408      }
     
    424414
    425415      static Result convert(RandomCore<Word>& rnd) {
    426         return Shifting<Result, - shift - bits>::
     416        return Shifting<Result, shift + bits>::
    427417          shift(static_cast<Result>(rnd())) +
    428418          RealConversion<Result, Word, rest-bits, shift + bits>::
Note: See TracChangeset for help on using the changeset viewer.