VTK  9.3.1
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 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkMersenneTwisterInternals;
40 
41 class VTKCOMMONCORE_EXPORT vtkMersenneTwister : public vtkRandomSequence
42 {
43 public:
44  typedef vtkTypeUInt32 SequenceId;
45 
47 
50  static vtkMersenneTwister* New();
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 
104 protected:
106  ~vtkMersenneTwister() override;
107 
108  vtkMersenneTwisterInternals* Internal;
109 
110 private:
111  vtkMersenneTwister(const vtkMersenneTwister&) = delete;
112  void operator=(const vtkMersenneTwister&) = delete;
113 };
114 
115 VTK_ABI_NAMESPACE_END
116 #endif // #ifndef vtkMersenneTwister_h
Generator for Mersenne Twister pseudorandom numbers.
void Initialize(vtkTypeUInt32 seed) override
Satisfy general API of vtkRandomSequence superclass.
Generate a sequence of random numbers.
virtual void Next()=0
Move to the next number in the random sequence.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
virtual double GetValue()=0
Return the current value.
a simple class to control print indentation
Definition: vtkIndent.h:28
double GetValue() override
Current value.
vtkTypeUInt32 SequenceId
void Next() override
Move to the next number in random sequence <0>.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkMersenneTwisterInternals * Internal