Simbody
3.4 (development)
|
00001 #ifndef SimTK_SimTKCOMMON_RANDOM_H_ 00002 #define SimTK_SimTKCOMMON_RANDOM_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm): SimTKcommon * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2007-12 Stanford University and the Authors. * 00013 * Authors: Peter Eastman * 00014 * Contributors: * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00027 #include "SimTKcommon/basics.h" 00028 00029 namespace SimTK { 00030 00054 class SimTK_SimTKCOMMON_EXPORT Random { 00055 public: 00056 class Uniform; 00057 class Gaussian; 00058 class RandomImpl; 00059 ~Random(); 00063 void setSeed(int seed); 00067 Real getValue() const; 00071 void fillArray(Real array[], int length) const; 00072 protected: 00073 RandomImpl* impl; 00077 Random(); 00081 RandomImpl& getImpl(); 00085 const RandomImpl& getConstImpl() const; 00086 private: 00087 // Suppress copy constructor and copy assignment. 00088 Random(const Random& r); 00089 Random operator=(const Random& r); 00090 }; 00091 00096 class SimTK_SimTKCOMMON_EXPORT Random::Uniform : public Random { 00097 public: 00098 class UniformImpl; 00102 Uniform(); 00106 Uniform(Real min, Real max); 00110 int getIntValue(); 00114 Real getMin() const; 00118 void setMin(Real min); 00122 Real getMax() const; 00126 void setMax(Real max); 00127 protected: 00128 UniformImpl& getImpl(); 00129 const UniformImpl& getConstImpl() const; 00130 private: 00131 // Must suppress here if base class members are suppressed. 00132 Uniform(const Uniform& r); 00133 Uniform operator=(const Uniform& r); 00134 }; 00135 00141 class SimTK_SimTKCOMMON_EXPORT Random::Gaussian : public Random { 00142 public: 00143 class GaussianImpl; 00147 Gaussian(); 00151 Gaussian(Real mean, Real stddev); 00155 Real getMean() const; 00159 void setMean(Real mean); 00163 Real getStdDev() const; 00167 void setStdDev(Real stddev); 00168 protected: 00169 GaussianImpl& getImpl(); 00170 const GaussianImpl& getConstImpl() const; 00171 private: 00172 // Must suppress here if base class members are suppressed. 00173 Gaussian(const Gaussian& r); 00174 Gaussian operator=(const Gaussian& r); 00175 }; 00176 00177 } // namespace SimTK 00178 00179 #endif // SimTK_SimTKCOMMON_RANDOM_H_