ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
AtlasTest
TestTools
TestTools
FLOATassert.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
#ifndef TESTTOOLS_FLOATASSERT_H
7
#define TESTTOOLS_FLOATASSERT_H
8
9
#include <iostream>
10
#include <cassert>
11
#include <cfloat>
12
#include <cmath>
13
14
15
namespace
Athena_test
{
16
inline
17
bool
floatEQ
(
float
lhs,
float
rhs) {
18
return
fabs(lhs-rhs)<=FLT_EPSILON;
19
}
20
inline
21
bool
floatNEQ
(
float
lhs,
float
rhs) {
22
return
fabs(lhs-rhs)>FLT_EPSILON;
23
}
24
25
inline
26
bool
isEqual
(
double
x1,
double
x2,
double
thresh = 1e-6)
27
{
28
double
den = std::abs(x1+x2);
29
if
(den < thresh)
return
true
;
30
double
diff
= std::abs (x1-x2) / den;
31
if
(
diff
< thresh)
32
return
true
;
33
std::cout <<
"Match failure: "
<< x1 <<
" "
<< x2 <<
" ("
<<
diff
<<
")\n"
;
34
return
false
;
35
}
36
37
}
38
39
#define FLOAT_NEQassert( LHS, RHS ) assert(Athena_test::floatNEQ(LHS, RHS));
40
#define FLOAT_EQassert( LHS, RHS ) assert(Athena_test::floatEQ(LHS, RHS));
41
42
#endif
diff
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition
Jet.cxx:631
Athena_test
functions & macros to test the difference between floats
Definition
InitGaudiGoogleTest.h:30
Athena_test::floatEQ
bool floatEQ(float lhs, float rhs)
Definition
FLOATassert.h:17
Athena_test::floatNEQ
bool floatNEQ(float lhs, float rhs)
Definition
FLOATassert.h:21
Athena_test::isEqual
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition
FLOATassert.h:26
Generated on
for ATLAS Offline Software by
1.17.0