source: src/RandomNumbers/RandomNumberEngine_Encapsulation.hpp@ 47d041

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 47d041 was 0275ad, checked in by Frederik Heber <heber@…>, 14 years ago

Final step in Random numbers is done ...

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * RandomNumberEngine_Encapsulation.hpp
3 *
4 * Created on: Jan 01, 2011
5 * Author: heber
6 */
7
8#ifndef RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
9#define RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <typeinfo>
17
18#include <boost/nondet_random.hpp>
19#include <boost/random.hpp>
20#include <boost/random/additive_combine.hpp>
21#include <boost/random/discard_block.hpp>
22#include <boost/random/inversive_congruential.hpp>
23#include <boost/random/lagged_fibonacci.hpp>
24#include <boost/random/linear_congruential.hpp>
25#include <boost/random/linear_feedback_shift.hpp>
26#include <boost/random/mersenne_twister.hpp>
27#include <boost/random/random_number_generator.hpp>
28#include <boost/random/ranlux.hpp>
29#include <boost/random/shuffle_output.hpp>
30#include <boost/random/subtract_with_carry.hpp>
31#include <boost/random/xor_combine.hpp>
32
33#include "CodePatterns/ManipulableClone.hpp"
34#include "RandomNumberEngine.hpp"
35
36class RandomNumberEngineFactory;
37
38#include "RandomNumberEngine_Parameters.hpp"
39
40/** Template class that encapsulates the random number engines from
41 * random::boost.
42 *
43 *
44 * We need one template parameters:
45 * -# the engine - generates uniform random numbers
46 */
47template <class engine>
48class RandomNumberEngine_Encapsulation :
49 public RandomNumberEngine,
50 public ManipulableClone<RandomNumberEngine, RandomNumberEngine_Parameters>
51{
52 /**
53 * Factory is friend such that it can access private cstor when filling its
54 * table
55 */
56 friend class RandomNumberEngineFactory;
57
58public:
59 /** Getter for the whole set of possible parameters.
60 *
61 * @return filled instance of RandomNumberEngine_Parameters
62 */
63 RandomNumberEngine_Parameters* getParameterSet() const
64 {
65 RandomNumberEngine_Parameters *params = new RandomNumberEngine_Parameters();
66 params->getParameters(this);
67 return params;
68 }
69
70 /** Set the engine's seed.
71 *
72 * @param _seed seed to set to
73 */
74 void seed(unsigned int _seed) {
75 value_seed = _seed;
76 engine_type.seed(value_seed);
77 }
78
79 /** Getter for the engine's seed.
80 *
81 * @return seed
82 */
83 unsigned int getseed() const {
84 return value_seed;
85 }
86
87 /** Getter for smallest value the engine produces.
88 *
89 * @return smallest value
90 */
91 double min() const {
92 return engine_type.min();
93 }
94
95 /** Getter for largest value the engine produces.
96 *
97 * @return largest value
98 */
99 double max() const {
100 return engine_type.max();
101 }
102
103 /** Getter for the type name of the internal engine.
104 *
105 */
106 std::string name() {
107 return typeid(engine_type).name();
108 }
109
110 /** Getter for the engine instance.
111 *
112 * @return reference to instance
113 */
114 engine& getEngine() {
115 return engine_type;
116 }
117
118 /** Clones the current instance.
119 *
120 * Implementation of Clone pattern.
121 *
122 * @return interface reference to cloned instance
123 */
124 RandomNumberEngine* clone() const {
125 RandomNumberEngine_Parameters *params = getParameterSet();
126 RandomNumberEngine* MyClone = new RandomNumberEngine_Encapsulation<engine>(*params);
127 //MyClone->seed(getseed());
128 return MyClone;
129 }
130
131 /** Clones and manipulates the current instance.
132 *
133 * Implementation of ManipulableClone pattern.
134 *
135 * @param _params set of parameters to instantiate manipulated clone with
136 * @return interface reference to cloned&manipulated instance
137 */
138 ManipulableClone<RandomNumberEngine, RandomNumberEngine_Parameters>*
139 manipulatedclone(const RandomNumberEngine_Parameters &_params) const {
140 RandomNumberEngine_Encapsulation<engine>* MyClone = NULL;
141 MyClone = new RandomNumberEngine_Encapsulation<engine>();
142 MyClone->value_seed = _params.seed;
143 MyClone->seed(_params.seed);
144 return MyClone;
145 }
146
147protected:
148 /** Constructor that instantiates a specific random number generator and
149 * distribution.
150 * @param _engine_type instance of the desired engine
151 */
152 RandomNumberEngine_Encapsulation() :
153 value_seed(1)
154 {}
155
156 /** Constructor that instantiates a specific random number generator and
157 * distribution.
158 * @param _engine_type instance of the desired engine
159 */
160 RandomNumberEngine_Encapsulation(const RandomNumberEngine_Parameters &_params) :
161 value_seed(_params.seed)
162 {}
163
164 /** Destructor of the class.
165 *
166 */
167 virtual ~RandomNumberEngine_Encapsulation() {}
168private:
169 engine engine_type;
170 unsigned int value_seed;
171};
172
173#endif /* RANDOMNUMBERENGINE_ENCAPSULATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.