YARP
Yet Another Robot Platform
RandnScalar.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_MATH_RANDNSCALAR_H
8 #define YARP_MATH_RANDNSCALAR_H
9 
10 #include <yarp/math/RandScalar.h>
11 #include <yarp/math/api.h>
12 
13 namespace yarp {
14  namespace math {
15  class RandnScalar;
16  }
17 }
18 
24 {
25  void *impl;
26  long seed;
27 
28  double y[2]; // required by the boxmuller transform
29  bool executeBoxMuller; // boxMuller transform generates two mubers at the time, this flag determines when to re-use previous.
30 
31 private:
32  RandnScalar(const RandnScalar &l);
33 
38  inline void boxMuller();
39 public:
43  RandnScalar();
44  ~RandnScalar();
45 
50  RandnScalar(int seed);
51 
56  void init();
57 
63  void init (int seed);
64 
65  long getSeed ()
66  { return seed; }
67 
75  double get(double u=0.0, double sigma=1.0);
76 };
77 
78 #endif // YARP_MATH_RANDNSCALAR_H
A random number generator, normal distribution.
Definition: RandnScalar.h:24
double get(double u=0.0, double sigma=1.0)
Generate a randomly generated number, drawn from a normal distribution.
Definition: RandnScalar.cpp:55
RandnScalar()
Constructor.
Definition: RandnScalar.cpp:22
void init()
Initialize the generator.
Definition: RandnScalar.cpp:40
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_math_API
Definition: api.h:17