MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
tarch
utils
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
12
namespace
tarch
{
13
namespace
utils {
14
class
RandomNumberService
;
15
}
16
}
// namespace tarch
17
18
namespace
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
24
double
simple_sin(
double
x);
25
double
simple_cos(
double
x);
26
double
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
42
class
tarch::utils::RandomNumberService
{
43
public
:
44
static
RandomNumberService& getInstance();
45
46
void
init(
bool
fixSeed =
false
);
47
48
void
shutdown();
49
51
double
getUniformRandomNumber
()
const
;
52
54
double
getGaussianRandomNumber
();
55
56
bool
tarchDebugIsOn()
const
;
57
58
private
:
59
RandomNumberService() {}
60
~RandomNumberService
() {}
61
62
tarch::la::Vector<2, double>
_randomNumbers;
63
64
bool
_isFirstRandomNumber;
65
bool
_isInitialized{
false
};
66
};
67
#endif
// _MOLECULARDYNAMICS_SERVICES_RANDOMNUMBERSERVICE_H_
tarch::la::Vector
Definition
Vector.h:25
tarch::utils::RandomNumberService
Definition
RandomNumberService.h:42
tarch::utils::RandomNumberService::getGaussianRandomNumber
double getGaussianRandomNumber()
tarch::utils::RandomNumberService::getUniformRandomNumber
double getUniformRandomNumber() const
tarch
Definition
Configuration.h:11
Generated by
1.17.0