MaMiCo 1.2
Loading...
Searching...
No Matches
RandomNumberService.h
1// Copyright (C) 2015 Technische Universitaet Muenchen
2// This file is part of the Mamico project. For conditions of distribution
3// and use, please see the copyright notice in Mamico's main folder, or at
4// www5.in.tum.de/mamico
5#ifndef _MOLECULARDYNAMICS_SERVICES_RANDOMNUMBERSERVICE_H_
6#define _MOLECULARDYNAMICS_SERVICES_RANDOMNUMBERSERVICE_H_
7
8#include "tarch/TarchDefinitions.h"
9#include "tarch/la/Vector.h"
10#include <iostream>
11
12namespace tarch {
13namespace utils {
15}
16} // namespace tarch
17
18namespace tarch {
19// These helper functions are neither accurate nor fast!
20// Generally, std::sin(), std::cos() and log() should be preferred in almost all cases!
21// However, these functions provide reproducibility - independent of std::sin() implementation / compiler / system
22// Thus, they can be helpful for debugging in some cases, where bitwise reproducible results are required
23
24double simple_sin(double x);
25double simple_cos(double x);
26double simple_log(double x);
27} // namespace tarch
28
29#if (TARCH_DEBUG == TARCH_YES)
30#define TARCH_SIN tarch::simple_sin
31#define TARCH_COS tarch::simple_cos
32#define TARCH_LOG tarch::simple_log
33#else
34#define TARCH_SIN std::sin
35#define TARCH_COS std::cos
36#define TARCH_LOG std::log
37#endif
38
43public:
44 static RandomNumberService& getInstance();
45
46 void init(bool fixSeed = false);
47
48 void shutdown();
49
51 double getUniformRandomNumber() const;
52
55
56 bool tarchDebugIsOn() const;
57
58private:
59 RandomNumberService() {}
61
62 tarch::la::Vector<2, double> _randomNumbers;
63
64 bool _isFirstRandomNumber;
65 bool _isInitialized{false};
66};
67#endif // _MOLECULARDYNAMICS_SERVICES_RANDOMNUMBERSERVICE_H_
Definition Vector.h:25
Definition RandomNumberService.h:42
Definition Configuration.h:11