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#include "MantidKernel/V3D.h"
14
15namespace Mantid {
16namespace Kernel {
18template <typename T> MANTID_KERNEL_DLL bool equals(T const x, T const y);
19template <typename T> MANTID_KERNEL_DLL inline bool equals(T const x, T const y, std::true_type);
20template <typename T> MANTID_KERNEL_DLL inline bool equals(T const x, T const y, std::false_type);
22template <typename T> MANTID_KERNEL_DLL bool ltEquals(T const x, T const y);
24template <typename T> MANTID_KERNEL_DLL bool gtEquals(T const x, T const y);
26template <typename T> MANTID_KERNEL_DLL T absoluteDifference(T const x, T const y);
28template <typename T> MANTID_KERNEL_DLL T relativeDifference(T const x, T const y);
30template <typename T, typename S = T>
31MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance);
32template <typename T, typename S = T>
33MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance, std::false_type);
34template <typename T, typename S = T>
35MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance, std::true_type);
37template <typename T, typename S = T>
38MANTID_KERNEL_DLL bool withinRelativeDifference(T const x, T const y, S const tolerance);
39template <typename T, typename S = T>
40MANTID_KERNEL_DLL inline bool withinRelativeDifference(T const x, T const y, S const tolerance, std::false_type);
41template <typename T, typename S = T>
42MANTID_KERNEL_DLL inline bool withinRelativeDifference(T const x, T const y, S const tolerance, std::true_type);
43} // namespace Kernel
44} // 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.