-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reduction in number of times prog says warning you're in gas. Cust…
…omizable now too * Better explanation in analysis.hh comment of rootNEST's mode 1, which needs 2 files * End-user flexibility in expanding S1 window, for extremely long pulses * Removal in NEST.cpp of strange code that used variable Nph without initialization * Re-tabbing in NEST.cpp's GetS1() including for "} else {" for greater clarity * Rounding error corrected that allowed the number of excitons to exceed total photons * Removed unnecessary else statements in ValidityTests.cpp due to presence of return
- Loading branch information
szydagis
committed
Mar 6, 2021
1 parent
a6616e0
commit b28c0cd
Showing
4 changed files
with
81 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
|
||
#include "ValidityTests.hh" | ||
|
||
using namespace std; | ||
|
||
bool ValidityTests::nearlyEqual(double a, double b, double epsilon) { | ||
// Handles cases of equality statements for floats | ||
|
||
// Handles cases of equality statements for floats | ||
if (a == b) { // shortcut, handles infinities | ||
return true; | ||
} else { | ||
double absA = fabs(a); | ||
double absB = fabs(b); | ||
double diff = fabs(a - b); | ||
|
||
if (a == 0 || b == 0 || (absA + absB < DBL_MIN)) { | ||
// a or b is zero or both are extremely close to it | ||
// relative error is less meaningful here | ||
return diff < (epsilon * DBL_MIN); | ||
} else // use relative error | ||
return diff / fmin((absA + absB), DBL_MAX) < epsilon; | ||
return true; | ||
} | ||
double absA = fabs(a); | ||
double absB = fabs(b); | ||
double diff = fabs(a - b); | ||
|
||
if (a == 0 || b == 0 || (absA + absB < DBL_MIN)) { | ||
// a or b is zero or both are extremely close to it | ||
// relative error is less meaningful here | ||
return diff < (epsilon * DBL_MIN); | ||
} // use relative error | ||
return diff / fmin((absA + absB), DBL_MAX) < epsilon; | ||
|
||
} |