ITK  5.4.0
Insight Toolkit
itkNormalVariateGenerator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkNormalVariateGenerator_h
19 #define itkNormalVariateGenerator_h
20 
21 #include "itkObjectFactory.h"
23 #include "ITKStatisticsExport.h"
24 
25 namespace itk
26 {
27 namespace Statistics
28 {
98 class ITKStatistics_EXPORT NormalVariateGenerator : public RandomVariateGeneratorBase
99 {
100 public:
106 
108  itkOverrideGetNameOfClassMacro(NormalVariateGenerator);
109 
111  itkNewMacro(Self);
112 
114  void
115  Initialize(int randomSeed);
116 
118  double
119  GetVariate() override;
120 
121 protected:
123  ~NormalVariateGenerator() override;
124  void
125  PrintSelf(std::ostream & os, Indent indent) const override;
126 
128  double
129  FastNorm();
130 
131 private:
132  static inline int
133  SignedShiftXOR(int irs)
134  {
135  // shifting of signed integer gives undefined results, explicitly
136  // cast to unsigned to get expected ( if two complement
137  // representation ) results.
138  auto uirs = static_cast<unsigned int>(irs);
139  return static_cast<int>((irs <= 0) ? ((uirs << 1) ^ 333556017) : (uirs << 1));
140  }
141 
142  double m_Scale{};
143  double m_Rscale{};
144  double m_Rcons{};
145 
146  static constexpr int m_ELEN{ 7 };
147  // LEN must be 2 ** ELEN
148  static constexpr int m_LEN{ 128 };
149  static constexpr int m_LMASK{ 4 * (m_LEN - 1) };
150  static constexpr int m_TLEN{ 8 * m_LEN };
151 
152  int m_Gaussfaze{};
153  int * m_Gausssave{};
154 
155  double m_GScale{};
156 
157  int m_Vec1[m_TLEN]{};
158  int m_Nslew{};
159  int m_Irs{};
160  int m_Lseed{};
161  double m_Chic1{};
162  double m_Chic2{};
163  double m_ActualRSD{};
164 }; // end of class
165 } // end of namespace Statistics
166 } // end of namespace itk
167 #endif
itkObjectFactory.h
itk::Statistics::NormalVariateGenerator::SignedShiftXOR
static int SignedShiftXOR(int irs)
Definition: itkNormalVariateGenerator.h:133
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::RandomVariateGeneratorBase
Defines common interfaces for random variate generators.
Definition: itkRandomVariateGeneratorBase.h:33
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::Statistics::NormalVariateGenerator
Normal random variate generator.
Definition: itkNormalVariateGenerator.h:98
itkRandomVariateGeneratorBase.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24