VTK  9.4.20241222
vtkMersenneTwister.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (C) 2001-2009 Makoto Matsumoto and Takuji Nishimura
3// SPDX-FileCopyrightText: Copyright (C) 2009 Mutsuo Saito
4// SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
32#ifndef vtkMersenneTwister_h
33#define vtkMersenneTwister_h
34
35#include "vtkCommonCoreModule.h" // For export macro
36#include "vtkRandomSequence.h"
37
38VTK_ABI_NAMESPACE_BEGIN
39class vtkMersenneTwisterInternals;
40
41class VTKCOMMONCORE_EXPORT vtkMersenneTwister : public vtkRandomSequence
42{
43public:
44 typedef vtkTypeUInt32 SequenceId;
45
47
52 void PrintSelf(ostream& os, vtkIndent indent) override;
54
59 void Initialize(vtkTypeUInt32 seed) override { this->InitializeSequence(0, seed); }
60
68 SequenceId InitializeNewSequence(vtkTypeUInt32 seed, int p = 521);
69
76 void InitializeSequence(SequenceId id, vtkTypeUInt32 seed, int p = 521);
77
82 virtual double GetValue(SequenceId id);
83
88 double GetValue() override { return this->GetValue(0); }
89
95 virtual void Next(SequenceId id);
96
102 void Next() override { return this->Next(0); }
103
104protected:
107
108 vtkMersenneTwisterInternals* Internal;
109
110private:
111 vtkMersenneTwister(const vtkMersenneTwister&) = delete;
112 void operator=(const vtkMersenneTwister&) = delete;
113};
114
115VTK_ABI_NAMESPACE_END
116#endif // #ifndef vtkMersenneTwister_h
a simple class to control print indentation
Definition vtkIndent.h:108
Generator for Mersenne Twister pseudorandom numbers.
virtual void Next(SequenceId id)
Move to the next number in random sequence id.
vtkMersenneTwisterInternals * Internal
void Next() override
Move to the next number in random sequence <0>.
static vtkMersenneTwister * New()
Standard methods for instantiation, type information, and printing.
void InitializeSequence(SequenceId id, vtkTypeUInt32 seed, int p=521)
Initialize a sequence as in InitializeNewSequence(), but additionally pass an id to associate with th...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
virtual double GetValue(SequenceId id)
Current value.
double GetValue() override
Current value.
void Initialize(vtkTypeUInt32 seed) override
Satisfy general API of vtkRandomSequence superclass.
SequenceId InitializeNewSequence(vtkTypeUInt32 seed, int p=521)
Initialize a new Mersenne Twister sequence, given a) a seed and b) a Mersenne exponent (p s....
~vtkMersenneTwister() override
Generate a sequence of random numbers.