VTK  9.2.6
vtkMersenneTwister.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMersenneTwister.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 =========================================================================*/
14 
15 /*
16  Copyright (C) 2001-2009 Makoto Matsumoto and Takuji Nishimura.
17  Copyright (C) 2009 Mutsuo Saito
18  All rights reserved.
19 
20  Redistribution and use in source and binary forms, with or without
21  modification, are permitted provided that the following conditions are
22  met:
23 
24  * Redistributions of source code must retain the above copyright
25  notice, this list of conditions and the following disclaimer.
26  * Redistributions in binary form must reproduce the above
27  copyright notice, this list of conditions and the following
28  disclaimer in the documentation and/or other materials provided
29  with the distribution.
30 
31  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43 
71 #ifndef vtkMersenneTwister_h
72 #define vtkMersenneTwister_h
73 
74 #include "vtkCommonCoreModule.h" // For export macro
75 #include "vtkRandomSequence.h"
76 
77 class vtkMersenneTwisterInternals;
78 
79 class VTKCOMMONCORE_EXPORT vtkMersenneTwister : public vtkRandomSequence
80 {
81 public:
82  typedef vtkTypeUInt32 SequenceId;
83 
85 
88  static vtkMersenneTwister* New();
90  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
97  void Initialize(vtkTypeUInt32 seed) override { this->InitializeSequence(0, seed); }
98 
106  SequenceId InitializeNewSequence(vtkTypeUInt32 seed, int p = 521);
107 
114  void InitializeSequence(SequenceId id, vtkTypeUInt32 seed, int p = 521);
115 
120  virtual double GetValue(SequenceId id);
121 
126  double GetValue() override { return this->GetValue(0); }
127 
133  virtual void Next(SequenceId id);
134 
140  void Next() override { return this->Next(0); }
141 
142 protected:
144  ~vtkMersenneTwister() override;
145 
146  vtkMersenneTwisterInternals* Internal;
147 
148 private:
149  vtkMersenneTwister(const vtkMersenneTwister&) = delete;
150  void operator=(const vtkMersenneTwister&) = delete;
151 };
152 
153 #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:39
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