| 1 |
/* NUMmachar.c |
| 2 |
* |
| 3 |
* Copyright (C) 1994-2019 David Weenink |
| 4 |
* |
| 5 |
* This code 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 (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/* |
| 20 |
djmw 20020812 GPL header |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "NUMmachar.h" |
| 24 |
#include "melder.h" |
| 25 |
|
| 26 |
#include "NUMlapack.h" |
| 27 |
|
| 28 |
static struct structmachar_Table machar_table; |
| 29 |
|
| 30 |
/* |
| 31 |
Floating point properties: |
| 32 |
|
| 33 |
NR LAPACK dlamch |
| 34 |
ibeta base 'B' base of the machine |
| 35 |
it t 'N' number of (base) digits in the mantissa |
| 36 |
machep |
| 37 |
eps prec 'P' eps*base ('quantization step') |
| 38 |
negep |
| 39 |
epsneg eps 'E' relative machine precision ('quantization error') |
| 40 |
iexp |
| 41 |
minexp emin 'M' minimum exponent before (gradual) underflow |
| 42 |
xmin rmin 'U' underflow threshold - base**(emin-1) |
| 43 |
maxexp emax 'U' largest exponent before overflow |
| 44 |
xmax rmax 'O' overflow threshold - (base**emax)*(1-eps) |
| 45 |
irnd rnd 'R' 1 when rounding occurs in addition, 0 otherwise |
| 46 |
ngrd |
| 47 |
sfmin 'S' safe minimum, such that 1/sfmin does not overflow |
| 48 |
*/ |
| 49 |
|
| 50 |
double dlamch_(const char *cmach); // blas |
| 51 |
|
| 52 |
void NUMmachar () { |
| 53 |
if (NUMfpp) |
| 54 |
return; |
| 55 |
|
| 56 |
NUMfpp = & machar_table; |
| 57 |
|
| 58 |
NUMfpp -> base = (int) NUMlapack_dlamch_ ("Base"); |
| 59 |
NUMfpp -> t = (int) NUMlapack_dlamch_ ("Number of digits in mantissa"); |
| 60 |
NUMfpp -> emin = (int) NUMlapack_dlamch_ ("Minimum exponent"); |
| 61 |
NUMfpp -> emax = (int) NUMlapack_dlamch_ ("Largest exponent"); |
| 62 |
NUMfpp -> rnd = (int) NUMlapack_dlamch_ ("Rounding mode"); |
| 63 |
NUMfpp -> prec = NUMlapack_dlamch_ ("Precision"); |
| 64 |
NUMfpp -> eps = NUMlapack_dlamch_ ("Epsilon"); |
| 65 |
NUMfpp -> rmin = NUMlapack_dlamch_ ("Underflow threshold"); |
| 66 |
NUMfpp -> sfmin = NUMlapack_dlamch_ ("Safe minimum"); |
| 67 |
NUMfpp -> rmax = NUMlapack_dlamch_ ("Overflow threshold"); |
| 68 |
} |
| 69 |
|
| 70 |
/* End of file NUMmachar.c */ |