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 
66 #ifndef vtkMersenneTwister_h
67 #define vtkMersenneTwister_h
68 
69 #include "vtkCommonCoreModule.h" // For export macro
70 #include "vtkRandomSequence.h"
71 
72 class vtkMersenneTwisterInternals;
73 
74 class VTKCOMMONCORE_EXPORT vtkMersenneTwister : public vtkRandomSequence
75 {
76 public:
77  typedef vtkTypeUInt32 SequenceId;
78 
80  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
81 
82  static vtkMersenneTwister* New();
83 
91  SequenceId InitializeNewSequence(vtkTypeUInt32 seed, int p=521);
92 
99  void InitializeSequence(SequenceId id, vtkTypeUInt32 seed, int p=521);
100 
105  virtual double GetValue(SequenceId id);
106 
111  double GetValue() VTK_OVERRIDE { return this->GetValue(0); }
112 
118  virtual void Next(SequenceId id);
119 
125  void Next() VTK_OVERRIDE { return this->Next(0); }
126 
127 protected:
129  ~vtkMersenneTwister() VTK_OVERRIDE;
130 
131  vtkMersenneTwisterInternals* Internal;
132 
133 private:
134  vtkMersenneTwister(const vtkMersenneTwister&) VTK_DELETE_FUNCTION;
135  void operator=(const vtkMersenneTwister&) VTK_DELETE_FUNCTION;
136 };
137 
138 #endif // #ifndef vtkMersenneTwister_h
Generator for Mersenne Twister pseudorandom numbers.
Sequence of random numbers.
virtual void Next()=0
Move to the next number in the random sequence.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual double GetValue()=0
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...