NUMmachar.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* NUMmachar.c
  2. *
  3. * Copyright (C) 1994-2011 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. djmw 20020812 GPL header
  20. */
  21. #include "NUMmachar.h"
  22. #include "melder.h"
  23. #ifndef _NUMcblas_h_
  24. #include "NUMcblas.h"
  25. #endif
  26. static struct structmachar_Table machar_table;
  27. machar_Table NUMfpp = NULL;
  28. /*
  29. Floating point properties:
  30. NR LAPACK dlamch
  31. ibeta base 'B' base of the machine
  32. it t 'N' number of (base) digits in the mantissa
  33. machep
  34. eps prec 'P' eps*base ('quantization step')
  35. negep
  36. epsneg eps 'E' relative machine precision ('quantization error')
  37. iexp
  38. minexp emin 'M' minimum exponent before (gradual) underflow
  39. xmin rmin 'U' underflow threshold - base**(emin-1)
  40. maxexp emax 'U' largest exponent before overflow
  41. xmax rmax 'O' overflow threshold - (base**emax)*(1-eps)
  42. irnd rnd 'R' 1 when rounding occurs in addition, 0 otherwise
  43. ngrd
  44. sfmin 'S' safe minimum, such that 1/sfmin does not overflow
  45. */
  46. void NUMmachar () {
  47. if (NUMfpp) {
  48. return;
  49. }
  50. NUMfpp = & machar_table;
  51. NUMfpp -> base = (int) NUMblas_dlamch ("Base");
  52. NUMfpp -> t = (int) NUMblas_dlamch ("Number of digits in mantissa");
  53. NUMfpp -> emin = (int) NUMblas_dlamch ("Minimum exponent");
  54. NUMfpp -> emax = (int) NUMblas_dlamch ("Largest exponent");
  55. NUMfpp -> rnd = (int) NUMblas_dlamch ("Rounding mode");
  56. NUMfpp -> prec = NUMblas_dlamch ("Precision");
  57. NUMfpp -> eps = NUMblas_dlamch ("Epsilon");
  58. NUMfpp -> rmin = NUMblas_dlamch ("Underflow threshold");
  59. NUMfpp -> sfmin = NUMblas_dlamch ("Safe minimum");
  60. NUMfpp -> rmax = NUMblas_dlamch ("Overflow threshold");
  61. }
  62. /* End of file NUMmachar.c */