Skip to content

Commit

Permalink
🔥 Remove canonical() method
Browse files Browse the repository at this point in the history
  • Loading branch information
heavywatal committed Nov 29, 2017
1 parent 2ec713f commit 758995d
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions sfmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@
namespace wtl {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////

namespace {
union bits64_t {
uint64_t as_uint64_t;
uint32_t as_uint32_t[2];
double as_double;

bits64_t(uint64_t x): as_uint64_t{x} {}
bits64_t(uint32_t x, uint32_t y): as_uint32_t{x, y} {}

// Use 52 bits to make double [0.0, 1.0)
double as_canonical() const {
bits64_t exponent_zero = (as_uint64_t >> 2) | 0x3ff0'0000'0000'0000;
return exponent_zero.as_double - 1.0;
}
};
}

class sfmt19937 {
public:
typedef uint32_t result_type;
Expand All @@ -50,15 +33,6 @@ class sfmt19937 {
return sfmt_genrand_uint32(&state_);
}

// [0.0, 1.0)
double canonical() {
return std::generate_canonical<double, std::numeric_limits<double>::digits>(*this);
}
// possible implementation
double _canonical() {
return bits64_t(this->operator()(), this->operator()()).as_canonical();
}

void seed(const result_type s) {
sfmt_init_gen_rand(&state_, s);
}
Expand Down Expand Up @@ -95,15 +69,6 @@ class sfmt19937_64 {
return sfmt_genrand_uint64(&state_);
}

// [0.0, 1.0)
double canonical() {
return std::generate_canonical<double, std::numeric_limits<double>::digits>(*this);
}
// possible implementation
double _canonical() {
return bits64_t(this->operator()()).as_canonical();
}

void seed(const result_type s) {
sfmt_init_gen_rand(&state_, s);
}
Expand Down

0 comments on commit 758995d

Please sign in to comment.