Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <random> |
| 11 | |
| 12 | // template<class UIntType, size_t w, size_t s, size_t r> |
| 13 | // class subtract_with_carry_engine |
| 14 | // { |
| 15 | // public: |
| 16 | // // types |
| 17 | // typedef UIntType result_type; |
Howard Hinnant | a0eaf60 | 2010-08-22 00:42:21 +0000 | [diff] [blame^] | 18 | // |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | // // engine characteristics |
| 20 | // static constexpr size_t word_size = w; |
| 21 | // static constexpr size_t short_lag = s; |
| 22 | // static constexpr size_t long_lag = r; |
| 23 | // static constexpr result_type min() { return 0; } |
| 24 | // static constexpr result_type max() { return m-1; } |
| 25 | // static constexpr result_type default_seed = 19780503u; |
| 26 | |
| 27 | #include <random> |
| 28 | #include <type_traits> |
| 29 | #include <cassert> |
| 30 | |
| 31 | void |
| 32 | test1() |
| 33 | { |
| 34 | typedef std::ranlux24_base E; |
| 35 | static_assert((E::word_size == 24), ""); |
| 36 | static_assert((E::short_lag == 10), ""); |
| 37 | static_assert((E::long_lag == 24), ""); |
| 38 | /*static_*/assert((E::min() == 0)/*, ""*/); |
| 39 | /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/); |
| 40 | static_assert((E::default_seed == 19780503u), ""); |
| 41 | } |
| 42 | |
| 43 | void |
| 44 | test2() |
| 45 | { |
| 46 | typedef std::ranlux48_base E; |
| 47 | static_assert((E::word_size == 48), ""); |
| 48 | static_assert((E::short_lag == 5), ""); |
| 49 | static_assert((E::long_lag == 12), ""); |
| 50 | /*static_*/assert((E::min() == 0)/*, ""*/); |
| 51 | /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/); |
| 52 | static_assert((E::default_seed == 19780503u), ""); |
| 53 | } |
| 54 | |
| 55 | int main() |
| 56 | { |
| 57 | test1(); |
| 58 | test2(); |
| 59 | } |