3.2.3
Main Page
Modules
Data Structures
Files
File List
Globals
kernel
util
float.c
1
/*
2
* Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
3
*
4
* This program is free software; you can redistribute it and/or modify it under
5
* the terms of the GNU General Public License as published by the Free Software
6
* Foundation; either version 2 of the License, or (at your option) any later
7
* version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
* details.
13
*
14
* You should have received a copy of the GNU General Public License along with
15
* this program; if not, write to the Free Software Foundation, Inc., 51
16
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
*/
18
19
/* $Id: util.c 3483 2010-04-23 19:02:34Z keiner $ */
20
21
#include "infft.h"
22
23
R X(float_property)(
const
float_property p)
24
{
25
const
R base = FLT_RADIX;
26
const
R eps = EPSILON;
27
const
R t = MANT_DIG;
28
const
R emin = MIN_EXP;
29
const
R emax = MAX_EXP;
30
const
R prec = eps * base;
31
static
R rmin = K(1.0);
32
static
R rmax = K(1.0);
33
const
R rnd = FLTROUND;
34
static
R sfmin = K(-1.0);
35
static
short
first = TRUE;
36
37
if
(first)
38
{
39
/* Compute rmin */
40
{
41
const
INT n = 1 - MIN_EXP;
42
INT i;
43
for
(i = 0; i < n; i++)
44
rmin /= base;
45
}
46
47
/* Compute rmax */
48
{
49
INT i;
50
rmax -= eps;
51
for
(i = 0; i < emax; i++)
52
rmax *= base;
53
}
54
55
/* Compute sfmin */
56
{
57
R small = K(1.0) / rmax;
58
sfmin = rmin;
59
if
(small >= sfmin)
60
sfmin = small * (eps + K(1.0));
61
}
62
63
first = FALSE;
64
}
65
66
if
(p == NFFT_EPSILON)
67
return
eps;
68
else
if
(p == NFFT_SAFE_MIN)
69
return
sfmin;
70
else
if
(p == NFFT_BASE)
71
return
base;
72
else
if
(p == NFFT_PRECISION)
73
return
prec;
74
else
if
(p == NFFT_MANT_DIG)
75
return
t;
76
else
if
(p == NFFT_FLTROUND)
77
return
rnd;
78
else
if
(p == NFFT_E_MIN)
79
return
emin;
80
else
if
(p == NFFT_R_MIN)
81
return
rmin;
82
else
if
(p == NFFT_E_MAX)
83
return
emax;
84
else
if
(p == NFFT_R_MAX)
85
return
rmax;
86
else
87
CK(0
/* cannot happen */
);
88
89
return
K(-1.0);
90
}
/* dlamch_ */
Generated on Tue Apr 30 2013 by Doxygen 1.8.1