YARP
Yet Another Robot Platform
RandnScalar.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_MATH_RANDNSCALAR_H
11 #define YARP_MATH_RANDNSCALAR_H
12 
13 #include <yarp/math/RandScalar.h>
14 #include <yarp/math/api.h>
15 
16 namespace yarp {
17  namespace math {
18  class RandnScalar;
19  }
20 }
21 
27 {
28  void *impl;
29  long seed;
30 
31  double y[2]; // required by the boxmuller transform
32  bool executeBoxMuller; // boxMuller transform generates two mubers at the time, this flag determines when to re-use previous.
33 
34 private:
35  RandnScalar(const RandnScalar &l);
36 
41  inline void boxMuller();
42 public:
46  RandnScalar();
47  ~RandnScalar();
48 
53  RandnScalar(int seed);
54 
59  void init();
60 
66  void init (int seed);
67 
68  long getSeed ()
69  { return seed; }
70 
78  double get(double u=0.0, double sigma=1.0);
79 };
80 
81 #endif // YARP_MATH_RANDNSCALAR_H
yarp::math::RandnScalar::RandnScalar
RandnScalar()
Constructor.
Definition: RandnScalar.cpp:25
RandScalar.h
yarp::math::RandnScalar::~RandnScalar
~RandnScalar()
Definition: RandnScalar.cpp:37
yarp::math::RandnScalar::init
void init()
Initialize the generator.
Definition: RandnScalar.cpp:43
yarp::math::RandnScalar::getSeed
long getSeed()
Definition: RandnScalar.h:68
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::math::RandnScalar::get
double get(double u=0.0, double sigma=1.0)
Generate a randomly generated number, drawn from a normal distribution.
Definition: RandnScalar.cpp:58
YARP_math_API
#define YARP_math_API
Definition: api.h:18
yarp::math::RandnScalar
A random number generator, normal distribution.
Definition: RandnScalar.h:27
api.h