Rand.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_MATH_RAND_HH_
18 #define IGNITION_MATH_RAND_HH_
19 
20 #include <random>
21 #include <cmath>
22 #include <cstdint>
23 #include <ignition/math/Helpers.hh>
24 #include <ignition/math/config.hh>
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  inline namespace IGNITION_MATH_VERSION_NAMESPACE
31  {
34  typedef std::mt19937 GeneratorType;
37  typedef std::uniform_real_distribution<double> UniformRealDist;
40  typedef std::normal_distribution<double> NormalRealDist;
43  typedef std::uniform_int_distribution<int32_t> UniformIntDist;
44 
47  class IGNITION_MATH_VISIBLE Rand
48  {
52  public: static void Seed(unsigned int _seed);
53 
57  public: static unsigned int Seed();
58 
62  public: static double DblUniform(double _min = 0, double _max = 1);
63 
67  public: static double DblNormal(double _mean = 0, double _sigma = 1);
68 
72  public: static int32_t IntUniform(int _min, int _max);
73 
77  public: static int32_t IntNormal(int _mean, int _sigma);
78 
81  private: static uint32_t &SeedMutable();
82 
85  private: static GeneratorType &RandGenerator();
86  };
87  }
88  }
89 }
90 #endif
std::uniform_real_distribution< double > UniformRealDist
Definition: Rand.hh:37
std::normal_distribution< double > NormalRealDist
Definition: Rand.hh:40
Random number generator class.
Definition: Rand.hh:47
std::uniform_int_distribution< int32_t > UniformIntDist
Definition: Rand.hh:43
std::mt19937 GeneratorType
Definition: Rand.hh:34
Definition: Angle.hh:39