mt
Main Page
Modules
Classes
Files
File List
All
Classes
Files
Functions
Enumerations
Groups
Pages
mt
basic_scalar_traits.h
1
/***************************************************************************
2
* Copyright (C) 2006 by Adolfo Rodriguez *
3
* adolfo.rodriguez@upc.edu *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
20
22
23
// HEADER GUARD
24
#ifndef MT_BASIC_SCALAR_TRAITS_H
25
#define MT_BASIC_SCALAR_TRAITS_H
26
27
// C++ STANDARD HEADERS
28
#include <limits>
29
30
32
33
namespace
mt
34
{
35
36
// USING DECLARATIONS/DIRECTIVES
37
39
41
42
43
template
<
class
T>
44
class
BasicScalarTraits
45
{
46
public
:
47
48
// TYPES
49
51
enum
ToleranceType
52
{
53
ABSOLUTE,
54
RELATIVE
55
};
56
57
58
// ACCESS
59
61
static
T
getTol
();
62
65
static
T
getTestTol
();
66
68
static
typename
BasicScalarTraits<T>::ToleranceType
getTolType
();
69
71
static
size_t
getWidth
();
72
77
static
void
setTol
(
const
T& x);
78
80
static
void
setTolType
(
const
ToleranceType
& type);
81
82
83
private
:
84
85
// MEMBERS
86
88
static
T m_tol;
89
92
static
T m_test_tol;
93
95
static
ToleranceType
m_tol_type;
96
98
static
size_t
m_width;
99
};
100
101
103
104
template
<
class
T>
inline
105
T
BasicScalarTraits<T>::getTol
()
106
{
107
return
m_tol;
108
}
109
110
template
<
class
T>
inline
111
T
BasicScalarTraits<T>::getTestTol
()
112
{
113
return
m_test_tol;
114
}
115
116
117
template
<
class
T>
inline
118
typename
BasicScalarTraits<T>::ToleranceType
BasicScalarTraits<T>::getTolType
()
119
{
120
return
m_tol_type;
121
}
122
123
124
template
<
class
T>
inline
125
size_t
BasicScalarTraits<T>::getWidth
()
126
{
127
return
m_width;
128
}
129
130
131
template
<
class
T>
inline
132
void
BasicScalarTraits<T>::setTol
(
const
T& x)
133
{
134
m_tol = std::abs(x);
135
m_test_tol = m_tol + 2.0 * std::numeric_limits<T>::epsilon();
136
}
137
138
139
template
<
class
T>
inline
140
void
BasicScalarTraits<T>::setTolType
(
const
ToleranceType
& type)
141
{
142
m_tol_type = type;
143
}
144
145
146
// STATIC MEMBER INITIALIZATION
147
148
template
<
class
T>
149
T
BasicScalarTraits<T>::m_tol
=
static_cast<
T
>
(0.0001);
150
151
template
<
class
T>
152
T
BasicScalarTraits<T>::m_test_tol
= 2.0 * std::numeric_limits<T>::epsilon() +
153
BasicScalarTraits<T>::m_tol
;
154
155
template
<
class
T>
156
typename
BasicScalarTraits<T>::ToleranceType
157
BasicScalarTraits<T>::m_tol_type
=
BasicScalarTraits<T>::ABSOLUTE
;
158
159
template
<
class
T>
160
size_t
BasicScalarTraits<T>::m_width
= 6;
161
162
}
// mt
163
164
#endif // MT_BASIC_SCALAR_TRAITS_H
Generated on Wed Oct 23 2013 10:30:12 for mt by
1.8.1.2