const.cpp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /* const.c
  2. *
  3. * Globally declared constants
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * extern double nameofconstant;
  10. *
  11. *
  12. *
  13. *
  14. * DESCRIPTION:
  15. *
  16. * This file contains a number of mathematical constants and
  17. * also some needed size parameters of the computer arithmetic.
  18. * The values are supplied as arrays of hexadecimal integers
  19. * for IEEE arithmetic; arrays of octal constants for DEC
  20. * arithmetic; and in a normal decimal scientific notation for
  21. * other machines. The particular notation used is determined
  22. * by a symbol (DEC, IBMPC, or UNK) defined in the include file
  23. * mconf.h.
  24. *
  25. * The default size parameters are as follows.
  26. *
  27. * For DEC and UNK modes:
  28. * MACHEP = 1.38777878078144567553E-17 2**-56
  29. * MAXLOG = 8.8029691931113054295988E1 log(2**127)
  30. * MINLOG = -8.872283911167299960540E1 log(2**-128)
  31. * MAXNUM = 1.701411834604692317316873e38 2**127
  32. *
  33. * For IEEE arithmetic (IBMPC):
  34. * MACHEP = 1.11022302462515654042E-16 2**-53
  35. * MAXLOG = 7.09782712893383996843E2 log(2**1024)
  36. * MINLOG = -7.08396418532264106224E2 log(2**-1022)
  37. * MAXNUM = 1.7976931348623158E308 2**1024
  38. *
  39. * The global symbols for mathematical constants are
  40. * PI = 3.14159265358979323846 pi
  41. * PIO2 = 1.57079632679489661923 pi/2
  42. * PIO4 = 7.85398163397448309616E-1 pi/4
  43. * SQRT2 = 1.41421356237309504880 sqrt(2)
  44. * SQRTH = 7.07106781186547524401E-1 sqrt(2)/2
  45. * LOG2E = 1.4426950408889634073599 1/log(2)
  46. * SQ2OPI = 7.9788456080286535587989E-1 sqrt( 2/pi )
  47. * LOGE2 = 6.93147180559945309417E-1 log(2)
  48. * LOGSQ2 = 3.46573590279972654709E-1 log(2)/2
  49. * THPIO4 = 2.35619449019234492885 3*pi/4
  50. * TWOOPI = 6.36619772367581343075535E-1 2/pi
  51. *
  52. * These lists are subject to change.
  53. */
  54. /* const.c */
  55. /*
  56. Cephes Math Library Release 2.3: March, 1995
  57. Copyright 1984, 1995 by Stephen L. Moshier
  58. */
  59. #include "mconf.h"
  60. #include <stdlib.h>
  61. #include <stdio.h>
  62. #ifdef UNK
  63. #if 1
  64. double MACHEP = 1.11022302462515654042E-16; /* 2**-53 */
  65. #else
  66. double MACHEP = 1.38777878078144567553E-17; /* 2**-56 */
  67. #endif
  68. double UFLOWTHRESH = 2.22507385850720138309E-308; /* 2**-1022 */
  69. #ifdef DENORMAL
  70. double MAXLOG = 7.09782712893383996732E2; /* log(MAXNUM) */
  71. /* double MINLOG = -7.44440071921381262314E2; */ /* log(2**-1074) */
  72. double MINLOG = -7.451332191019412076235E2; /* log(2**-1075) */
  73. #else
  74. double MAXLOG = 7.08396418532264106224E2; /* log 2**1022 */
  75. double MINLOG = -7.08396418532264106224E2; /* log 2**-1022 */
  76. #endif
  77. double MAXNUM = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */
  78. double PI = 3.14159265358979323846; /* pi */
  79. double PIO2 = 1.57079632679489661923; /* pi/2 */
  80. double PIO4 = 7.85398163397448309616E-1; /* pi/4 */
  81. double SQRT2 = 1.41421356237309504880; /* sqrt(2) */
  82. double SQRTH = 7.07106781186547524401E-1; /* sqrt(2)/2 */
  83. double LOG2E = 1.4426950408889634073599; /* 1/log(2) */
  84. double SQ2OPI = 7.9788456080286535587989E-1; /* sqrt( 2/pi ) */
  85. double LOGE2 = 6.93147180559945309417E-1; /* log(2) */
  86. double LOGSQ2 = 3.46573590279972654709E-1; /* log(2)/2 */
  87. double THPIO4 = 2.35619449019234492885; /* 3*pi/4 */
  88. double TWOOPI = 6.36619772367581343075535E-1; /* 2/pi */
  89. #ifdef INFINITIES
  90. //double INFINITY = 1.0/0.0; /* 99e999; */
  91. double INFINITY = atof("infinity"); /* 99e999; */
  92. #else
  93. double INFINITY = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */
  94. #endif
  95. #ifdef NANS
  96. double NAN =atof("infinity") - atof("infinity");
  97. #else
  98. double NAN = 0.0;
  99. #endif
  100. #ifdef MINUSZERO
  101. double NEGZERO = -0.0;
  102. #else
  103. double NEGZERO = 0.0;
  104. #endif
  105. #endif
  106. #ifdef IBMPC
  107. /* 2**-53 = 1.11022302462515654042E-16 */
  108. unsigned short MACHEP[4] = {0x0000,0x0000,0x0000,0x3ca0};
  109. unsigned short UFLOWTHRESH[4] = {0x0000,0x0000,0x0000,0x0010};
  110. #ifdef DENORMAL
  111. /* log(MAXNUM) = 7.09782712893383996732224E2 */
  112. unsigned short MAXLOG[4] = {0x39ef,0xfefa,0x2e42,0x4086};
  113. /* log(2**-1074) = - -7.44440071921381262314E2 */
  114. /*unsigned short MINLOG[4] = {0x71c3,0x446d,0x4385,0xc087};*/
  115. unsigned short MINLOG[4] = {0x3052,0xd52d,0x4910,0xc087};
  116. #else
  117. /* log(2**1022) = 7.08396418532264106224E2 */
  118. unsigned short MAXLOG[4] = {0xbcd2,0xdd7a,0x232b,0x4086};
  119. /* log(2**-1022) = - 7.08396418532264106224E2 */
  120. unsigned short MINLOG[4] = {0xbcd2,0xdd7a,0x232b,0xc086};
  121. #endif
  122. /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */
  123. unsigned short MAXNUM[4] = {0xffff,0xffff,0xffff,0x7fef};
  124. unsigned short PI[4] = {0x2d18,0x5444,0x21fb,0x4009};
  125. unsigned short PIO2[4] = {0x2d18,0x5444,0x21fb,0x3ff9};
  126. unsigned short PIO4[4] = {0x2d18,0x5444,0x21fb,0x3fe9};
  127. unsigned short SQRT2[4] = {0x3bcd,0x667f,0xa09e,0x3ff6};
  128. unsigned short SQRTH[4] = {0x3bcd,0x667f,0xa09e,0x3fe6};
  129. unsigned short LOG2E[4] = {0x82fe,0x652b,0x1547,0x3ff7};
  130. unsigned short SQ2OPI[4] = {0x3651,0x33d4,0x8845,0x3fe9};
  131. unsigned short LOGE2[4] = {0x39ef,0xfefa,0x2e42,0x3fe6};
  132. unsigned short LOGSQ2[4] = {0x39ef,0xfefa,0x2e42,0x3fd6};
  133. unsigned short THPIO4[4] = {0x21d2,0x7f33,0xd97c,0x4002};
  134. unsigned short TWOOPI[4] = {0xc883,0x6dc9,0x5f30,0x3fe4};
  135. #ifdef INFINITIES
  136. unsigned short INFINITY[4] = {0x0000,0x0000,0x0000,0x7ff0};
  137. #else
  138. unsigned short INFINITY[4] = {0xffff,0xffff,0xffff,0x7fef};
  139. #endif
  140. #ifdef NANS
  141. unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x7ffc};
  142. #else
  143. unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000};
  144. #endif
  145. #ifdef MINUSZERO
  146. unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x8000};
  147. #else
  148. unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000};
  149. #endif
  150. #endif
  151. #ifdef MIEEE
  152. /* 2**-53 = 1.11022302462515654042E-16 */
  153. unsigned short MACHEP[4] = {0x3ca0,0x0000,0x0000,0x0000};
  154. unsigned short UFLOWTHRESH[4] = {0x0010,0x0000,0x0000,0x0000};
  155. #ifdef DENORMAL
  156. /* log(2**1024) = 7.09782712893383996843E2 */
  157. unsigned short MAXLOG[4] = {0x4086,0x2e42,0xfefa,0x39ef};
  158. /* log(2**-1074) = - -7.44440071921381262314E2 */
  159. /* unsigned short MINLOG[4] = {0xc087,0x4385,0x446d,0x71c3}; */
  160. unsigned short MINLOG[4] = {0xc087,0x4910,0xd52d,0x3052};
  161. #else
  162. /* log(2**1022) = 7.08396418532264106224E2 */
  163. unsigned short MAXLOG[4] = {0x4086,0x232b,0xdd7a,0xbcd2};
  164. /* log(2**-1022) = - 7.08396418532264106224E2 */
  165. unsigned short MINLOG[4] = {0xc086,0x232b,0xdd7a,0xbcd2};
  166. #endif
  167. /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */
  168. unsigned short MAXNUM[4] = {0x7fef,0xffff,0xffff,0xffff};
  169. unsigned short PI[4] = {0x4009,0x21fb,0x5444,0x2d18};
  170. unsigned short PIO2[4] = {0x3ff9,0x21fb,0x5444,0x2d18};
  171. unsigned short PIO4[4] = {0x3fe9,0x21fb,0x5444,0x2d18};
  172. unsigned short SQRT2[4] = {0x3ff6,0xa09e,0x667f,0x3bcd};
  173. unsigned short SQRTH[4] = {0x3fe6,0xa09e,0x667f,0x3bcd};
  174. unsigned short LOG2E[4] = {0x3ff7,0x1547,0x652b,0x82fe};
  175. unsigned short SQ2OPI[4] = {0x3fe9,0x8845,0x33d4,0x3651};
  176. unsigned short LOGE2[4] = {0x3fe6,0x2e42,0xfefa,0x39ef};
  177. unsigned short LOGSQ2[4] = {0x3fd6,0x2e42,0xfefa,0x39ef};
  178. unsigned short THPIO4[4] = {0x4002,0xd97c,0x7f33,0x21d2};
  179. unsigned short TWOOPI[4] = {0x3fe4,0x5f30,0x6dc9,0xc883};
  180. #ifdef INFINITIES
  181. unsigned short INFINITY[4] = {0x7ff0,0x0000,0x0000,0x0000};
  182. #else
  183. unsigned short INFINITY[4] = {0x7fef,0xffff,0xffff,0xffff};
  184. #endif
  185. #ifdef NANS
  186. unsigned short NAN[4] = {0x7ff8,0x0000,0x0000,0x0000};
  187. #else
  188. unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000};
  189. #endif
  190. #ifdef MINUSZERO
  191. unsigned short NEGZERO[4] = {0x8000,0x0000,0x0000,0x0000};
  192. #else
  193. unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000};
  194. #endif
  195. #endif
  196. #ifdef DEC
  197. /* 2**-56 = 1.38777878078144567553E-17 */
  198. unsigned short MACHEP[4] = {0022200,0000000,0000000,0000000};
  199. unsigned short UFLOWTHRESH[4] = {0x0080,0x0000,0x0000,0x0000};
  200. /* log 2**127 = 88.029691931113054295988 */
  201. unsigned short MAXLOG[4] = {041660,007463,0143742,025733,};
  202. /* log 2**-128 = -88.72283911167299960540 */
  203. unsigned short MINLOG[4] = {0141661,071027,0173721,0147572,};
  204. /* 2**127 = 1.701411834604692317316873e38 */
  205. unsigned short MAXNUM[4] = {077777,0177777,0177777,0177777,};
  206. unsigned short PI[4] = {040511,007732,0121041,064302,};
  207. unsigned short PIO2[4] = {040311,007732,0121041,064302,};
  208. unsigned short PIO4[4] = {040111,007732,0121041,064302,};
  209. unsigned short SQRT2[4] = {040265,002363,031771,0157145,};
  210. unsigned short SQRTH[4] = {040065,002363,031771,0157144,};
  211. unsigned short LOG2E[4] = {040270,0125073,024534,013761,};
  212. unsigned short SQ2OPI[4] = {040114,041051,0117241,0131204,};
  213. unsigned short LOGE2[4] = {040061,071027,0173721,0147572,};
  214. unsigned short LOGSQ2[4] = {037661,071027,0173721,0147572,};
  215. unsigned short THPIO4[4] = {040426,0145743,0174631,007222,};
  216. unsigned short TWOOPI[4] = {040042,0174603,067116,042025,};
  217. /* Approximate infinity by MAXNUM. */
  218. unsigned short INFINITY[4] = {077777,0177777,0177777,0177777,};
  219. unsigned short NAN[4] = {0000000,0000000,0000000,0000000};
  220. #ifdef MINUSZERO
  221. unsigned short NEGZERO[4] = {0000000,0000000,0000000,0100000};
  222. #else
  223. unsigned short NEGZERO[4] = {0000000,0000000,0000000,0000000};
  224. #endif
  225. #endif
  226. #ifndef UNK
  227. extern unsigned short MACHEP[];
  228. extern unsigned short UFLOWTHRESH[];
  229. extern unsigned short MAXLOG[];
  230. extern unsigned short UNDLOG[];
  231. extern unsigned short MINLOG[];
  232. extern unsigned short MAXNUM[];
  233. extern unsigned short PI[];
  234. extern unsigned short PIO2[];
  235. extern unsigned short PIO4[];
  236. extern unsigned short SQRT2[];
  237. extern unsigned short SQRTH[];
  238. extern unsigned short LOG2E[];
  239. extern unsigned short SQ2OPI[];
  240. extern unsigned short LOGE2[];
  241. extern unsigned short LOGSQ2[];
  242. extern unsigned short THPIO4[];
  243. extern unsigned short TWOOPI[];
  244. extern unsigned short INFINITY[];
  245. extern unsigned short NAN[];
  246. extern unsigned short NEGZERO[];
  247. #endif