BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Numeric.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Math/Numeric.h
6 //! @brief Defines constants and "almost equal" in namespace Numeric.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_BASE_MATH_NUMERIC_H
21 #define BORNAGAIN_BASE_MATH_NUMERIC_H
22 
23 #include <limits>
24 
25 //! Floating-point approximations.
26 
27 namespace Numeric {
28 
29 double GetAbsoluteDifference(double a, double b);
30 
31 double GetRelativeDifference(double a, double b);
32 
33 double GetLogDifference(double a, double b);
34 
35 } // namespace Numeric
36 
37 #endif // BORNAGAIN_BASE_MATH_NUMERIC_H
38 #endif // USER_API
Floating-point approximations.
Definition: Numeric.cpp:20
double GetRelativeDifference(double a, double b)
Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases.
Definition: Numeric.cpp:29
double GetAbsoluteDifference(double a, double b)
Returns the absolute value of the difference between a and b.
Definition: Numeric.cpp:23
double GetLogDifference(double a, double b)
Returns the difference of the logarithm; input values are truncated at the minimum positive value.
Definition: Numeric.cpp:41