OpenANN
1.1.0
An open source library for artificial neural networks.
Main Page
Classes
Files
List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
OpenANN
util
AssertionMacros.h
Go to the documentation of this file.
1
#ifndef OPENANN_UTIL_ASSERTION_MACROS_H_
2
#define OPENANN_UTIL_ASSERTION_MACROS_H_
3
4
#ifndef NDEBUG
5
6
#include <
OpenANN/io/Logger.h
>
7
#include <cassert>
8
#include <cmath>
9
#include <iostream>
10
11
namespace
OpenANN
12
{
13
14
template
<
class
T>
15
bool
equals
(
T
a,
T
b,
T
delta)
16
{
17
return
std::fabs(a - b) <= delta;
18
}
19
20
template
<
class
T>
21
bool
isNaN
(
T
value)
22
{
23
return
std::isnan(value);
24
}
25
26
template
<
class
T>
27
bool
isInf
(
T
value)
28
{
29
return
std::isinf(value);
30
}
31
32
}
// namespace OpenANN
33
34
#define OPENANN_CHECK(x) assert(x)
35
36
#define OPENANN_CHECK_EQUALS(x, y) \
37
{ \
38
if(!((x) == (y))) \
39
{ \
40
OPENANN_TRACE((x)); \
41
OPENANN_TRACE("!="); \
42
OPENANN_TRACE((y)); \
43
} \
44
assert((x) == (y)); \
45
}
46
47
#define OPENANN_CHECK_NOT_EQUALS(x, y) \
48
assert((x) != (y))
49
50
#define OPENANN_CHECK_EQUALS_DELTA(x, y, delta) \
51
assert(OpenANN::equals((x),(y), (delta)))
52
53
#define OPENANN_CHECK_WITHIN(x, min, max) \
54
assert(((min) <= (x)) && ((x) <= (max)));
55
56
#define OPENANN_CHECK_NAN(value) \
57
if(OpenANN::isNaN(value)) { \
58
OPENANN_TRACE("nan"); \
59
OPENANN_CHECK(!OpenANN::isNaN(value)); \
60
}
61
62
#define OPENANN_CHECK_INF(value) \
63
if(OpenANN::isInf(value)) { \
64
OPENANN_TRACE("inf"); \
65
OPENANN_CHECK(!OpenANN::isInf(value)); \
66
}
67
68
#define OPENANN_CHECK_INF_AND_NAN(value) \
69
OPENANN_CHECK_INF(value); \
70
OPENANN_CHECK_NAN(value);
71
72
#else // NDEBUG
73
#define OPENANN_CHECK(x)
74
#define OPENANN_CHECK_EQUALS(x, y)
75
#define OPENANN_CHECK_NOT_EQUALS(x, y)
76
#define OPENANN_CHECK_EQUALS_DELTA(x, y, delta)
77
#define OPENANN_CHECK_WITHIN(x, min, max)
78
#define OPENANN_CHECK_NAN(value)
79
#define OPENANN_CHECK_INF(value)
80
#define OPENANN_CHECK_INF_AND_NAN(value)
81
#endif // NDEBUG
82
83
#endif // OPENANN_UTIL_ASSERTION_MACROS_H_
Generated on Wed Jul 9 2014 08:57:52 for OpenANN by
1.8.4