MCL
A C++ library mirroring some of the most common Matlab functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
randomop.h
Go to the documentation of this file.
1 /*
2  MCL
3  Copyright (c) 2012-18, Enzo De Sena
4  All rights reserved.
5 
6  Authors: Enzo De Sena, enzodesena@gmail.com
7  */
8 
9 #ifndef MCL_RANDOMGENERATOR_H
10 #define MCL_RANDOMGENERATOR_H
11 
12 
13 // Using TR1 and old c++ library
14 
15 #include "mcltypes.h"
16 #include <vector>
17 #include <random>
18 
19 namespace mcl {
24 public:
26 
27  RandomGenerator(unsigned int seed);
28 
33  std::vector<Real> Randn(const Int size);
34 
39  std::vector<Real> Rand(const Int size);
40 
45  Real Rand() { return Rand(1)[0]; }
46 
51  Int RandInt(const Int& minimum, const Int& maximum);
52 
54  void SetSeed(unsigned int seed) { generator_.seed(seed); }
55 
59  static bool Test();
60 private:
61  std::default_random_engine generator_;
62  std::normal_distribution<double> distribution_norm_;
63  std::uniform_real_distribution<double> distribution_uniform_;
64 
65 
66 };
67 
68 } // namespace mcl
69 
70 
71 
72 #endif