Mantid
Loading...
Searching...
No Matches
FloatingPointComparison.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//-----------------------------------------------------------------------------
10// Includes
11//-----------------------------------------------------------------------------
12#include "MantidKernel/DllConfig.h"
13
14#include <type_traits>
15
16namespace Mantid {
17namespace Kernel {
19template <typename T> MANTID_KERNEL_DLL bool equals(T const x, T const y);
20template <typename T> MANTID_KERNEL_DLL inline bool equals(T const x, T const y, std::true_type);
21template <typename T> MANTID_KERNEL_DLL inline bool equals(T const x, T const y, std::false_type);
23template <typename T> MANTID_KERNEL_DLL bool ltEquals(T const x, T const y);
25template <typename T> MANTID_KERNEL_DLL bool gtEquals(T const x, T const y);
27template <typename T> MANTID_KERNEL_DLL T absoluteDifference(T const x, T const y);
29template <typename T> MANTID_KERNEL_DLL T relativeDifference(T const x, T const y);
31template <typename T, typename S = T>
32MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance);
33template <typename T, typename S = T>
34MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance, std::false_type);
35template <typename T, typename S = T>
36MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance, std::true_type);
38template <typename T, typename S = T>
39MANTID_KERNEL_DLL bool withinRelativeDifference(T const x, T const y, S const tolerance);
40template <typename T, typename S = T>
41MANTID_KERNEL_DLL inline bool withinRelativeDifference(T const x, T const y, S const tolerance, std::false_type);
42template <typename T, typename S = T>
43MANTID_KERNEL_DLL inline bool withinRelativeDifference(T const x, T const y, S const tolerance, std::true_type);
44} // namespace Kernel
45} // namespace Mantid
double tolerance
MANTID_KERNEL_DLL bool withinRelativeDifference(T const x, T const y, S const tolerance)
Test whether x, y are within relative tolerance tol.
MANTID_KERNEL_DLL bool equals(T const x, T const y)
Test for equality of doubles using compiler-defined precision.
MANTID_KERNEL_DLL bool gtEquals(T const x, T const y)
Test whether x>=y within machine precision.
MANTID_KERNEL_DLL T absoluteDifference(T const x, T const y)
Calculate absolute difference between x, y.
MANTID_KERNEL_DLL T relativeDifference(T const x, T const y)
Calculate relative difference between x, y.
MANTID_KERNEL_DLL bool ltEquals(T const x, T const y)
Test whether x<=y within machine precision.
MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance)
Test whether x, y are within absolute tolerance tol.
Helper class which provides the Collimation Length for SANS instruments.