subtract_with_carry_01 クラス
更新 : 2007 年 11 月
浮動小数点のキャリー付き減算アルゴリズムによってランダム シーケンスを生成します。
template<class RealType,
int W, int S, int R>
class subtract_with_carry_01 {
public:
typedef RealType result_type;
static const int word_size = W;
static const int short_lag = S;
static const int long_lag = R;
subtract_with_carry_01();
explicit subtract_with_carry_01(unsigned long x0);
template<class Gen>
subtract_with_carry_01(Gen& gen);
subtract_with_carry_01(const subtract_with_carry_01& right);
subtract_with_carry_01(subtract_with_carry_01& right);
void seed(unsigned long x0 = 19780503UL);
template<class Gen>
void seed(Gen& gen);
result_type min() const;
result_type max() const;
result_type operator()();
};
パラメータ
RealType
結果の浮動小数点型。W
W エンジン パラメータ。S
S エンジン パラメータ。R
R エンジン パラメータ。
解説
このテンプレート クラスは、ユーザーによって指定された浮動小数点型の値を、回帰関係 x(i) = (x(i - R) - x(i - S) - cy(i - 1)) mod 1 を使って生成する単体エンジンを表します。cy(i) は、x(i - S) - x(i - R) - cy(i - 1) < 0 の場合は 2-W という値を保持し、それ以外の場合は 0 を保持します。エンジンの状態は、operator() が少なくとも R 回呼び出された場合は、返された最後の R 値になります。それ以外の場合は、返された M 値と、シードの最後の R - M 値になります。
テンプレートの引数 RealType には、W 小数ビット付きの値を保持するのに十分な大きさが必要です。テンプレートの引数 S および R の値は 0 を超えること、また、S は R 未満であることが必要です。
必要条件
ヘッダー : <random>
名前空間 : std::tr1