VTK
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 
72 #ifndef vtkMersenneTwister_h
73 #define vtkMersenneTwister_h
74 
75 #include "vtkCommonCoreModule.h" // For export macro
76 #include "vtkRandomSequence.h"
77 
78 class vtkMersenneTwisterInternals;
79 
80 class VTKCOMMONCORE_EXPORT vtkMersenneTwister : public vtkRandomSequence
81 {
82 public:
83  typedef vtkTypeUInt32 SequenceId;
84 
86 
89  static vtkMersenneTwister* New();
91  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
98  void Initialize(vtkTypeUInt32 seed) override
99  {this->InitializeSequence(0,seed);}
100 
108  SequenceId InitializeNewSequence(vtkTypeUInt32 seed, int p=521);
109 
116  void InitializeSequence(SequenceId id, vtkTypeUInt32 seed, int p=521);
117 
122  virtual double GetValue(SequenceId id);
123 
128  double GetValue() override { return this->GetValue(0); }
129 
135  virtual void Next(SequenceId id);
136 
142  void Next() override { return this->Next(0); }
143 
144 protected:
146  ~vtkMersenneTwister() override;
147 
148  vtkMersenneTwisterInternals* Internal;
149 
150 private:
151  vtkMersenneTwister(const vtkMersenneTwister&) = delete;
152  void operator=(const vtkMersenneTwister&) = delete;
153 };
154 
155 #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