Version: SMASH-1.8
numerics.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright (c) 2014-2018
4
* SMASH Team
5
*
6
* GNU General Public License (GPLv3 or later)
7
*
8
*/
9
10
#ifndef SRC_INCLUDE_NUMERICS_H_
11
#define SRC_INCLUDE_NUMERICS_H_
12
13
#include <cmath>
14
#include "
constants.h
"
15
25
namespace
smash
{
41
template
<
typename
N>
42
bool
almost_equal
(
const
N x,
const
N y) {
43
return
(std::abs(x - y) <= N(
really_small
) ||
44
std::abs(x - y) <=
45
N(0.5 *
really_small
) * (std::abs(x) + std::abs(y)));
46
}
61
template
<
typename
N>
62
bool
almost_equal_physics
(
const
N x,
const
N y) {
63
return
(std::abs(x - y) <= N(
small_number
) ||
64
std::abs(x - y) <=
65
N(0.5 *
small_number
) * (std::abs(x) + std::abs(y)));
66
}
67
68
}
// namespace smash
69
70
#endif // SRC_INCLUDE_NUMERICS_H_
smash
Definition:
action.h:24
smash::small_number
constexpr double small_number
Physical error tolerance.
Definition:
constants.h:48
smash::really_small
constexpr double really_small
Numerical error tolerance.
Definition:
constants.h:37
smash::almost_equal
bool almost_equal(const N x, const N y)
Checks two numbers for relative approximate equality.
Definition:
numerics.h:42
smash::almost_equal_physics
bool almost_equal_physics(const N x, const N y)
Same as smash::almost_equal, but for physical checks like energy-momentum conservation small_number i...
Definition:
numerics.h:62
constants.h
src
include
smash
numerics.h
Impressum
Data privacy protection
Generated on Tue Apr 7 2020 13:50:11 for SMASH by
Doxygen
1.8.16