source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Blitz/blitz/numinquire.h@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 6.5 KB
RevLine 
[658]1/***************************************************************************
2 * blitz/numinquire.h Numeric inquiry functions
3 *
4 * $Id: numinquire.h,v 1.1.1.1 1999-11-26 16:37:04 ansari Exp $
5 *
6 * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * Suggestions: blitz-suggest@cybervision.com
19 * Bugs: blitz-bugs@cybervision.com
20 *
21 * For more information, please see the Blitz++ Home Page:
22 * http://seurat.uwaterloo.ca/blitz/
23 *
24 ***************************************************************************
25 * $Log: not supported by cvs2svn $
26 * Revision 1.1.1.1 1999/04/09 17:59:02 ansari
27 * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
28 *
29 * Revision 1.2 1998/03/14 00:04:47 tveldhui
30 * 0.2-alpha-05
31 *
32 * Revision 1.1 1997/07/16 14:51:20 tveldhui
33 * Update: Alpha release 0.2 (Arrays)
34 *
35 */
36
37/*
38 * These numeric inquiry functions are provided as an alternative
39 * to the somewhat klunky numeric_limits<T>::yadda_yadda syntax.
40 * Where a similar Fortran 90 function exists, the same name has
41 * been used.
42 *
43 * The argument in all cases is a dummy of the appropriate type
44 * (double, int, etc.)
45 *
46 * These functions assume that numeric_limits<T> has been specialized
47 * for the appropriate case. If not, the results are not useful.
48 */
49
50#ifndef BZ_NUMINQUIRE_H
51#define BZ_NUMINQUIRE_H
52
53#ifndef BZ_HAVE_NUMERIC_LIMITS
54 #error <blitz/numinquire.h> requires <limits> from the ISO/ANSI C++ standard (you may need to rerun the compiler/bzconfig script)
55#endif
56
57#include <limits>
58
59#ifndef BZ_RANGE_H
60 #include <blitz/range.h>
61#endif
62
63BZ_NAMESPACE(blitz)
64
65/*
66 * This traits class provides zero and one values for numeric
67 * types. This was previously a template function with specializations,
68 * but the specializations were causing multiply-defined symbols
69 * at link time. TV 980226
70 */
71
72template<class T_numtype>
73struct _bz_OneZeroTraits {
74 static inline T_numtype zero() { return 0; }
75 static inline T_numtype one() { return 1; }
76};
77
78#ifdef BZ_HAVE_COMPLEX
79
80template<>
81struct _bz_OneZeroTraits<complex<float> > {
82 static inline complex<float> zero() { return complex<float>(0.0f,0.0f); }
83 static inline complex<float> one() { return complex<float>(1.0f,0.0f); }
84};
85
86template<>
87struct _bz_OneZeroTraits<complex<double> > {
88 static inline complex<double> zero() { return complex<double>(0.0,0.0); }
89 static inline complex<double> one() { return complex<double>(1.0,0.0); }
90};
91
92template<>
93struct _bz_OneZeroTraits<complex<long double> > {
94 static inline complex<long double> zero()
95 { return complex<long double>(0.0,0.0); }
96
97 static inline complex<long double> one()
98 { return complex<long double>(1.0,0.0); }
99};
100
101#endif // BZ_HAVE_COMPLEX
102
103template<class T>
104inline T zero(T)
105{
106 return _bz_OneZeroTraits<T>::zero();
107}
108
109template<class T>
110inline T one(T)
111{
112 return _bz_OneZeroTraits<T>::one();
113}
114
115template<class T>
116inline int digits(T)
117{
118 return numeric_limits<T>::digits;
119}
120
121template<class T>
122inline int digits10(T)
123{
124 return numeric_limits<T>::digits10;
125}
126
127template<class T>
128inline T epsilon(T) BZ_THROW
129{
130 return numeric_limits<T>::epsilon();
131}
132
133template<class T>
134inline T huge(T) BZ_THROW
135{
136 return numeric_limits<T>::max();
137}
138
139template<class T>
140inline T tiny(T) BZ_THROW
141{
142 return numeric_limits<T>::min();
143}
144
145template<class T>
146inline int max_exponent(T)
147{
148 return numeric_limits<T>::max_exponent;
149}
150
151template<class T>
152inline int min_exponent(T)
153{
154 return numeric_limits<T>::min_exponent;
155}
156
157template<class T>
158inline int min_exponent10(T)
159{
160 return numeric_limits<T>::min_exponent10;
161}
162
163template<class T>
164inline int max_exponent10(T)
165{
166 return numeric_limits<T>::max_exponent10;
167}
168
169template<class T>
170inline int precision(T)
171{
172 return numeric_limits<T>::digits10;
173}
174
175template<class T>
176inline int radix(T)
177{
178 return numeric_limits<T>::radix;
179}
180
181template<class T>
182inline Range range(T)
183{
184 return Range(numeric_limits<T>::min_exponent10,
185 numeric_limits<T>::max_exponent10);
186}
187
188template<class T>
189inline bool is_signed(T)
190{
191 return numeric_limits<T>::is_signed;
192}
193
194template<class T>
195inline bool is_integer(T)
196{
197 return numeric_limits<T>::is_integer;
198}
199
200template<class T>
201inline bool is_exact(T)
202{
203 return numeric_limits<T>::is_exact;
204}
205
206template<class T>
207inline T round_error(T) BZ_THROW
208{
209 return numeric_limits<T>::round_error();
210}
211
212template<class T>
213inline bool has_infinity(T)
214{
215 return numeric_limits<T>::has_infinity;
216}
217
218template<class T>
219inline bool has_quiet_NaN(T)
220{
221 return numeric_limits<T>::has_quiet_NaN;
222}
223
224template<class T>
225inline bool has_signaling_NaN(T)
226{
227 return numeric_limits<T>::has_signaling_NaN;
228}
229
230// Provided for non-US english users
231template<class T>
232inline bool has_signalling_NaN(T)
233{
234 return numeric_limits<T>::has_signaling_NaN;
235}
236
237template<class T>
238inline bool has_denorm(T)
239{
240 return numeric_limits<T>::has_denorm;
241}
242
243template<class T>
244inline bool has_denorm_loss(T)
245{
246 return numeric_limits<T>::has_denorm_loss;
247}
248
249template<class T>
250inline T infinity(T) BZ_THROW
251{
252 return numeric_limits<T>::infinity();
253}
254
255template<class T>
256inline T quiet_NaN(T) BZ_THROW
257{
258 return numeric_limits<T>::quiet_NaN();
259}
260
261template<class T>
262inline T signaling_NaN(T) BZ_THROW
263{
264 return numeric_limits<T>::signaling_NaN();
265}
266
267template<class T>
268inline T signalling_NaN(T) BZ_THROW
269{
270 return numeric_limits<T>::signaling_NaN();
271}
272
273template<class T>
274inline T denorm_min(T) BZ_THROW
275{
276 return numeric_limits<T>::denorm_min();
277}
278
279template<class T>
280inline bool is_iec559(T)
281{
282 return numeric_limits<T>::is_iec559;
283}
284
285template<class T>
286inline bool is_bounded(T)
287{
288 return numeric_limits<T>::is_bounded;
289}
290
291template<class T>
292inline bool is_modulo(T)
293{
294 return numeric_limits<T>::is_modulo;
295}
296
297template<class T>
298inline bool traps(T)
299{
300 return numeric_limits<T>::traps;
301}
302
303template<class T>
304inline bool tinyness_before(T)
305{
306 return numeric_limits<T>::tinyness_before;
307}
308
309template<class T>
310inline std::float_round_style round_style(T)
311{
312 return numeric_limits<T>::round_style;
313}
314
315BZ_NAMESPACE_END
316
317#endif // BZ_NUMINQUIRE_H
318
Note: See TracBrowser for help on using the repository browser.