Simbody  3.6
Random.h
Go to the documentation of this file.
1 #ifndef SimTK_SimTKCOMMON_RANDOM_H_
2 #define SimTK_SimTKCOMMON_RANDOM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKcommon *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2007-12 Stanford University and the Authors. *
13  * Authors: Peter Eastman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
27 #include "SimTKcommon/basics.h"
28 
29 namespace SimTK {
30 
55 public:
56  class Uniform;
57  class Gaussian;
58  class RandomImpl;
59  ~Random();
63  void setSeed(int seed);
67  Real getValue() const;
71  void fillArray(Real array[], int length) const;
72 protected:
73  RandomImpl* impl;
77  Random();
81  RandomImpl& getImpl();
85  const RandomImpl& getConstImpl() const;
86 private:
87  // Suppress copy constructor and copy assignment.
88  Random(const Random& r);
89  Random operator=(const Random& r);
90 };
91 
97 public:
98  class UniformImpl;
102  Uniform();
106  Uniform(Real min, Real max);
110  int getIntValue();
114  Real getMin() const;
118  void setMin(Real min);
122  Real getMax() const;
126  void setMax(Real max);
127 protected:
128  UniformImpl& getImpl();
129  const UniformImpl& getConstImpl() const;
130 private:
131  // Must suppress here if base class members are suppressed.
132  Uniform(const Uniform& r);
133  Uniform operator=(const Uniform& r);
134 };
135 
142 public:
143  class GaussianImpl;
147  Gaussian();
151  Gaussian(Real mean, Real stddev);
155  Real getMean() const;
159  void setMean(Real mean);
163  Real getStdDev() const;
167  void setStdDev(Real stddev);
168 protected:
169  GaussianImpl& getImpl();
170  const GaussianImpl& getConstImpl() const;
171 private:
172  // Must suppress here if base class members are suppressed.
173  Gaussian(const Gaussian& r);
174  Gaussian operator=(const Gaussian& r);
175 };
176 
177 } // namespace SimTK
178 
179 #endif // SimTK_SimTKCOMMON_RANDOM_H_
RandomImpl * impl
Definition: Random.h:73
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:224
This is a subclass of Random that generates numbers uniformly distributed within a specified range...
Definition: Random.h:96
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
ELEM min(const VectorBase< ELEM > &v)
Definition: VectorMath.h:178
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:606
ELEM mean(const VectorBase< ELEM > &v)
Definition: VectorMath.h:324
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
This class defines the interface for pseudo-random number generators.
Definition: Random.h:54
This is a subclass of Random that generates numbers according to a Gaussian distribution with a speci...
Definition: Random.h:141
Includes internal headers providing declarations for the basic SimTK Core classes.