Simbody 3.7
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
29namespace SimTK {
30
55public:
56 class Uniform;
57 class Gaussian;
58 class RandomImpl;
63 void setSeed(int seed);
67 Real getValue() const;
71 void fillArray(Real array[], int length) const;
72protected:
73 RandomImpl* impl;
81 RandomImpl& getImpl();
85 const RandomImpl& getConstImpl() const;
86private:
87 // Suppress copy constructor and copy assignment.
88 Random(const Random& r);
89 Random operator=(const Random& r);
90};
91
97public:
98 class UniformImpl;
114 Real getMin() const;
122 Real getMax() const;
127protected:
128 UniformImpl& getImpl();
129 const UniformImpl& getConstImpl() const;
130private:
131 // Must suppress here if base class members are suppressed.
132 Uniform(const Uniform& r);
133 Uniform operator=(const Uniform& r);
134};
135
142public:
143 class GaussianImpl;
155 Real getMean() const;
167 void setStdDev(Real stddev);
168protected:
169 GaussianImpl& getImpl();
170 const GaussianImpl& getConstImpl() const;
171private:
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_
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:224
Includes internal headers providing declarations for the basic SimTK Core classes.
This is a subclass of Random that generates numbers according to a Gaussian distribution with a speci...
Definition: Random.h:141
const GaussianImpl & getConstImpl() const
void setStdDev(Real stddev)
Set the standard deviation of the Gaussian distribution.
GaussianImpl & getImpl()
void setMean(Real mean)
Set the mean of the Gaussian distribution.
Real getMean() const
Get the mean of the Gaussian distribution.
Real getStdDev() const
Get the standard deviation of the Gaussian distribution.
Gaussian()
Create a new random number generator that produces values according to a Gaussian distribution with m...
Gaussian(Real mean, Real stddev)
Create a new random number generator that produces values according to a Gaussian distribution with t...
This is a subclass of Random that generates numbers uniformly distributed within a specified range.
Definition: Random.h:96
void setMin(Real min)
Set the lower end of the range in which values are uniformly distributed.
Uniform(Real min, Real max)
Create a new random number generator that produces values uniformly distributed between min (inclusiv...
Real getMax() const
Get the upper end of the range in which values are uniformly distributed.
const UniformImpl & getConstImpl() const
Uniform()
Create a new random number generator that produces values uniformly distributed between 0 (inclusive)...
int getIntValue()
Get a random integer, uniformly distributed between 0 (inclusive) and max (exclusive).
void setMax(Real max)
Set the upper end of the range in which values are uniformly distributed.
Real getMin() const
Get the lower end of the range in which values are uniformly distributed.
UniformImpl & getImpl()
This class defines the interface for pseudo-random number generators.
Definition: Random.h:54
Real getValue() const
Get the next value in the pseudo-random sequence.
Random()
This constructor should never be invoked directly.
RandomImpl & getImpl()
Get the internal object which implements the random number generator.
void setSeed(int seed)
Reinitialize this random number generator with a new seed value.
RandomImpl * impl
Definition: Random.h:73
const RandomImpl & getConstImpl() const
Get a constant reference to the internal object which implements the random number generator.
void fillArray(Real array[], int length) const
Fill an array with values from the pseudo-random sequence.
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
ELEM min(const VectorBase< ELEM > &v)
Definition: VectorMath.h:178
ELEM mean(const VectorBase< ELEM > &v)
Definition: VectorMath.h:324
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