git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More debugscript things, sanity fading fast
[ipdf/code.git]
/
src
/
paranoidnumber.h
diff --git
a/src/paranoidnumber.h
b/src/paranoidnumber.h
index
e57d00c
..
3a38286
100644
(file)
--- a/
src/paranoidnumber.h
+++ b/
src/paranoidnumber.h
@@
-12,19
+12,21
@@
#include <cassert> // it's going to be ok
#include <set>
#include <cassert> // it's going to be ok
#include <set>
-#define PARANOID_DIGIT_T
double
// we could theoretically replace this with a template
+#define PARANOID_DIGIT_T
float
// we could theoretically replace this with a template
// but let's not do that...
//#define PARANOID_CACHE_RESULTS
//#define PARANOID_USE_ARENA
// but let's not do that...
//#define PARANOID_CACHE_RESULTS
//#define PARANOID_USE_ARENA
-#define PARANOID_SIZE_LIMIT 0
+#define PARANOID_SIZE_LIMIT
1
0
// Define to compare all ops against double ops and check within epsilon
// Define to compare all ops against double ops and check within epsilon
-#define PARANOID_COMPARE_EPSILON 1e-6
+//#define PARANOID_COMPARE_EPSILON 1e-
+#ifdef PARANOID_COMPARE_EPSILON
#define CompareForSanity(...) ParanoidNumber::CompareForSanityEx(__func__, __FILE__, __LINE__, __VA_ARGS__)
#define CompareForSanity(...) ParanoidNumber::CompareForSanityEx(__func__, __FILE__, __LINE__, __VA_ARGS__)
+#endif
namespace IPDF
{
namespace IPDF
{
@@
-87,7
+89,7
@@
namespace IPDF
ParanoidNumber(PARANOID_DIGIT_T value=0) : m_value(value), m_next()
{
#ifdef PARANOID_SIZE_LIMIT
ParanoidNumber(PARANOID_DIGIT_T value=0) : m_value(value), m_next()
{
#ifdef PARANOID_SIZE_LIMIT
- m_size =
0
;
+ m_size =
1
;
#endif
#ifdef PARANOID_CACHE_RESULTS
m_cached_result = value;
#endif
#ifdef PARANOID_CACHE_RESULTS
m_cached_result = value;
@@
-233,8
+235,11
@@
namespace IPDF
std::string Str() const;
std::string Str() const;
+ #ifdef PARANOID_COMPARE_EPSILON
inline void CompareForSanityEx(const char * func, const char * file, int line, const digit_t & compare, const digit_t & arg, const digit_t & eps = PARANOID_COMPARE_EPSILON)
{
inline void CompareForSanityEx(const char * func, const char * file, int line, const digit_t & compare, const digit_t & arg, const digit_t & eps = PARANOID_COMPARE_EPSILON)
{
+ if (!SanityCheck())
+ Fatal("This is insane!");
if (fabs(Digit() - compare) > eps)
{
Error("Called via %s(%lf) (%s:%d)", func, arg, file, line);
if (fabs(Digit() - compare) > eps)
{
Error("Called via %s(%lf) (%s:%d)", func, arg, file, line);
@@
-242,7
+247,7
@@
namespace IPDF
Fatal("This: %.30lf vs Expected: %.30lf", Digit(), compare);
}
}
Fatal("This: %.30lf vs Expected: %.30lf", Digit(), compare);
}
}
-
+ #endif
std::string PStr() const;
std::string PStr() const;
UCC
git Repository :: git.ucc.asn.au