alternative Standard Libary  0.29.8
std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag > Template-Klassenreferenz

#include <subtract_with_carry_engine.hpp>

Öffentliche Typen

using result_type = UIntType
 

Öffentliche Methoden

 subtract_with_carry_engine (size_t sd=default_seed)
 
void seed (size_t sd=default_seed)
 
void discard (unsigned long long z)
 
result_type last ()
 
result_type operator() ()
 

Öffentliche, statische Methoden

static constexpr result_type min ()
 
static constexpr result_type max ()
 

Statische öffentliche Attribute

static constexpr size_t default_seed = 19780503u
 

Ausführliche Beschreibung

template<class UIntType, size_t word_size, size_t short_lag, size_t long_lag>
class std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >

Dokumentation der benutzerdefinierten Datentypen

◆ result_type

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
using std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::result_type = UIntType

Beschreibung der Konstruktoren und Destruktoren

◆ subtract_with_carry_engine()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::subtract_with_carry_engine ( size_t  sd = default_seed)
inline
57  {
58  seed(sd);
59  }
void seed(size_t sd=default_seed)
Definition: subtract_with_carry_engine.hpp:61

Dokumentation der Elementfunktionen

◆ discard()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
void std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::discard ( unsigned long long  z)
inline
71  {
72  for (; z != 0ULL; --z)
73  (*this).operator ()();
74  }

◆ last()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
result_type std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::last ( )
inline
75  {
76  return m_xlast;
77  }

◆ max()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
static constexpr result_type std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::max ( )
inlinestatic
94 { return (UIntType(1) << word_size) - 1; }

◆ min()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
static constexpr result_type std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::min ( )
inlinestatic
93 { return 0; }

◆ operator()()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
result_type std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::operator() ( )
inline
78  {
79  int short_index = m_p - short_lag;
80  short_index += (short_index < 0) ? long_lag : 0;
81  if (m_x[short_index] >= m_x[m_p] + m_carry) {
82  m_xlast = m_x[short_index] - m_x[m_p] - m_carry;
83  m_carry = 0;
84  } else {
85  m_xlast = modulus - m_x[m_p] - m_carry + m_x[short_index];
86  m_carry = 1;
87  }
88  m_x[m_p] = m_xlast; ++m_p;
89  if(m_p >= long_lag)
90  m_p = 0;
91  return m_xlast;
92  }

◆ seed()

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
void std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::seed ( size_t  sd = default_seed)
inline
61  {
62  linear_congruential_engine<result_type,
63  40014u, 0u, 2147483563u> e(sd == 0u ? default_seed : sd);
64 
65  result_type mds = (UIntType(1) << word_size);
66  for(size_t i = 0; i < long_lag; ++i)
67  m_x[i] = internal::mod<result_type, 1, 0, mds>(e());
68  m_carry = (m_x[long_lag-1] == 0);
69  m_p = 0;
70  }
UIntType result_type
Definition: subtract_with_carry_engine.hpp:54
static constexpr size_t default_seed
Definition: subtract_with_carry_engine.hpp:55

Dokumentation der Datenelemente

◆ default_seed

template<class UIntType , size_t word_size, size_t short_lag, size_t long_lag>
constexpr size_t std::subtract_with_carry_engine< UIntType, word_size, short_lag, long_lag >::default_seed = 19780503u
static

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: