const.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. #ifdef UNK
  61. #if 1
  62. double MACHEP = 1.11022302462515654042E-16; /* 2**-53 */
  63. #else
  64. double MACHEP = 1.38777878078144567553E-17; /* 2**-56 */
  65. #endif
  66. double UFLOWTHRESH = 2.22507385850720138309E-308; /* 2**-1022 */
  67. #ifdef DENORMAL
  68. double MAXLOG = 7.09782712893383996732E2; /* log(MAXNUM) */
  69. /* double MINLOG = -7.44440071921381262314E2; */ /* log(2**-1074) */
  70. double MINLOG = -7.451332191019412076235E2; /* log(2**-1075) */
  71. #else
  72. double MAXLOG = 7.08396418532264106224E2; /* log 2**1022 */
  73. double MINLOG = -7.08396418532264106224E2; /* log 2**-1022 */
  74. #endif
  75. double MAXNUM = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */
  76. double PI = 3.14159265358979323846; /* pi */
  77. double PIO2 = 1.57079632679489661923; /* pi/2 */
  78. double PIO4 = 7.85398163397448309616E-1; /* pi/4 */
  79. double SQRT2 = 1.41421356237309504880; /* sqrt(2) */
  80. double SQRTH = 7.07106781186547524401E-1; /* sqrt(2)/2 */
  81. double LOG2E = 1.4426950408889634073599; /* 1/log(2) */
  82. double SQ2OPI = 7.9788456080286535587989E-1; /* sqrt( 2/pi ) */
  83. double LOGE2 = 6.93147180559945309417E-1; /* log(2) */
  84. double LOGSQ2 = 3.46573590279972654709E-1; /* log(2)/2 */
  85. double THPIO4 = 2.35619449019234492885; /* 3*pi/4 */
  86. double TWOOPI = 6.36619772367581343075535E-1; /* 2/pi */
  87. #ifdef INFINITIES
  88. double INFINITY = 1.0 / 0.0; /* 99e999; */
  89. #else
  90. double INFINITY = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */
  91. #endif
  92. #ifdef NANS
  93. double NAN = 1.0 / 0.0 - 1.0 / 0.0;
  94. #else
  95. double NAN = 0.0;
  96. #endif
  97. #ifdef MINUSZERO
  98. double NEGZERO = -0.0;
  99. #else
  100. double NEGZERO = 0.0;
  101. #endif
  102. #endif
  103. #ifdef IBMPC
  104. /* 2**-53 = 1.11022302462515654042E-16 */
  105. unsigned short MACHEP[4] = {0x0000, 0x0000, 0x0000, 0x3ca0};
  106. unsigned short UFLOWTHRESH[4] = {0x0000, 0x0000, 0x0000, 0x0010};
  107. #ifdef DENORMAL
  108. /* log(MAXNUM) = 7.09782712893383996732224E2 */
  109. unsigned short MAXLOG[4] = {0x39ef, 0xfefa, 0x2e42, 0x4086};
  110. /* log(2**-1074) = - -7.44440071921381262314E2 */
  111. /*unsigned short MINLOG[4] = {0x71c3,0x446d,0x4385,0xc087};*/
  112. unsigned short MINLOG[4] = {0x3052, 0xd52d, 0x4910, 0xc087};
  113. #else
  114. /* log(2**1022) = 7.08396418532264106224E2 */
  115. unsigned short MAXLOG[4] = {0xbcd2, 0xdd7a, 0x232b, 0x4086};
  116. /* log(2**-1022) = - 7.08396418532264106224E2 */
  117. unsigned short MINLOG[4] = {0xbcd2, 0xdd7a, 0x232b, 0xc086};
  118. #endif
  119. /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */
  120. unsigned short MAXNUM[4] = {0xffff, 0xffff, 0xffff, 0x7fef};
  121. unsigned short PI[4] = {0x2d18, 0x5444, 0x21fb, 0x4009};
  122. unsigned short PIO2[4] = {0x2d18, 0x5444, 0x21fb, 0x3ff9};
  123. unsigned short PIO4[4] = {0x2d18, 0x5444, 0x21fb, 0x3fe9};
  124. unsigned short SQRT2[4] = {0x3bcd, 0x667f, 0xa09e, 0x3ff6};
  125. unsigned short SQRTH[4] = {0x3bcd, 0x667f, 0xa09e, 0x3fe6};
  126. unsigned short LOG2E[4] = {0x82fe, 0x652b, 0x1547, 0x3ff7};
  127. unsigned short SQ2OPI[4] = {0x3651, 0x33d4, 0x8845, 0x3fe9};
  128. unsigned short LOGE2[4] = {0x39ef, 0xfefa, 0x2e42, 0x3fe6};
  129. unsigned short LOGSQ2[4] = {0x39ef, 0xfefa, 0x2e42, 0x3fd6};
  130. unsigned short THPIO4[4] = {0x21d2, 0x7f33, 0xd97c, 0x4002};
  131. unsigned short TWOOPI[4] = {0xc883, 0x6dc9, 0x5f30, 0x3fe4};
  132. #ifdef INFINITIES
  133. unsigned short INFINITY[4] = {0x0000, 0x0000, 0x0000, 0x7ff0};
  134. #else
  135. unsigned short INFINITY[4] = {0xffff, 0xffff, 0xffff, 0x7fef};
  136. #endif
  137. #ifdef NANS
  138. unsigned short NAN[4] = {0x0000, 0x0000, 0x0000, 0x7ffc};
  139. #else
  140. unsigned short NAN[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  141. #endif
  142. #ifdef MINUSZERO
  143. unsigned short NEGZERO[4] = {0x0000, 0x0000, 0x0000, 0x8000};
  144. #else
  145. unsigned short NEGZERO[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  146. #endif
  147. #endif
  148. #ifdef MIEEE
  149. /* 2**-53 = 1.11022302462515654042E-16 */
  150. unsigned short MACHEP[4] = {0x3ca0, 0x0000, 0x0000, 0x0000};
  151. unsigned short UFLOWTHRESH[4] = {0x0010, 0x0000, 0x0000, 0x0000};
  152. #ifdef DENORMAL
  153. /* log(2**1024) = 7.09782712893383996843E2 */
  154. unsigned short MAXLOG[4] = {0x4086, 0x2e42, 0xfefa, 0x39ef};
  155. /* log(2**-1074) = - -7.44440071921381262314E2 */
  156. /* unsigned short MINLOG[4] = {0xc087,0x4385,0x446d,0x71c3}; */
  157. unsigned short MINLOG[4] = {0xc087, 0x4910, 0xd52d, 0x3052};
  158. #else
  159. /* log(2**1022) = 7.08396418532264106224E2 */
  160. unsigned short MAXLOG[4] = {0x4086, 0x232b, 0xdd7a, 0xbcd2};
  161. /* log(2**-1022) = - 7.08396418532264106224E2 */
  162. unsigned short MINLOG[4] = {0xc086, 0x232b, 0xdd7a, 0xbcd2};
  163. #endif
  164. /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */
  165. unsigned short MAXNUM[4] = {0x7fef, 0xffff, 0xffff, 0xffff};
  166. unsigned short PI[4] = {0x4009, 0x21fb, 0x5444, 0x2d18};
  167. unsigned short PIO2[4] = {0x3ff9, 0x21fb, 0x5444, 0x2d18};
  168. unsigned short PIO4[4] = {0x3fe9, 0x21fb, 0x5444, 0x2d18};
  169. unsigned short SQRT2[4] = {0x3ff6, 0xa09e, 0x667f, 0x3bcd};
  170. unsigned short SQRTH[4] = {0x3fe6, 0xa09e, 0x667f, 0x3bcd};
  171. unsigned short LOG2E[4] = {0x3ff7, 0x1547, 0x652b, 0x82fe};
  172. unsigned short SQ2OPI[4] = {0x3fe9, 0x8845, 0x33d4, 0x3651};
  173. unsigned short LOGE2[4] = {0x3fe6, 0x2e42, 0xfefa, 0x39ef};
  174. unsigned short LOGSQ2[4] = {0x3fd6, 0x2e42, 0xfefa, 0x39ef};
  175. unsigned short THPIO4[4] = {0x4002, 0xd97c, 0x7f33, 0x21d2};
  176. unsigned short TWOOPI[4] = {0x3fe4, 0x5f30, 0x6dc9, 0xc883};
  177. #ifdef INFINITIES
  178. unsigned short INFINITY[4] = {0x7ff0, 0x0000, 0x0000, 0x0000};
  179. #else
  180. unsigned short INFINITY[4] = {0x7fef, 0xffff, 0xffff, 0xffff};
  181. #endif
  182. #ifdef NANS
  183. unsigned short NAN[4] = {0x7ff8, 0x0000, 0x0000, 0x0000};
  184. #else
  185. unsigned short NAN[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  186. #endif
  187. #ifdef MINUSZERO
  188. unsigned short NEGZERO[4] = {0x8000, 0x0000, 0x0000, 0x0000};
  189. #else
  190. unsigned short NEGZERO[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  191. #endif
  192. #endif
  193. #ifdef DEC
  194. /* 2**-56 = 1.38777878078144567553E-17 */
  195. unsigned short MACHEP[4] = {0022200, 0000000, 0000000, 0000000};
  196. unsigned short UFLOWTHRESH[4] = {0x0080, 0x0000, 0x0000, 0x0000};
  197. /* log 2**127 = 88.029691931113054295988 */
  198. unsigned short MAXLOG[4] = {
  199. 041660,
  200. 007463,
  201. 0143742,
  202. 025733,
  203. };
  204. /* log 2**-128 = -88.72283911167299960540 */
  205. unsigned short MINLOG[4] = {
  206. 0141661,
  207. 071027,
  208. 0173721,
  209. 0147572,
  210. };
  211. /* 2**127 = 1.701411834604692317316873e38 */
  212. unsigned short MAXNUM[4] = {
  213. 077777,
  214. 0177777,
  215. 0177777,
  216. 0177777,
  217. };
  218. unsigned short PI[4] = {
  219. 040511,
  220. 007732,
  221. 0121041,
  222. 064302,
  223. };
  224. unsigned short PIO2[4] = {
  225. 040311,
  226. 007732,
  227. 0121041,
  228. 064302,
  229. };
  230. unsigned short PIO4[4] = {
  231. 040111,
  232. 007732,
  233. 0121041,
  234. 064302,
  235. };
  236. unsigned short SQRT2[4] = {
  237. 040265,
  238. 002363,
  239. 031771,
  240. 0157145,
  241. };
  242. unsigned short SQRTH[4] = {
  243. 040065,
  244. 002363,
  245. 031771,
  246. 0157144,
  247. };
  248. unsigned short LOG2E[4] = {
  249. 040270,
  250. 0125073,
  251. 024534,
  252. 013761,
  253. };
  254. unsigned short SQ2OPI[4] = {
  255. 040114,
  256. 041051,
  257. 0117241,
  258. 0131204,
  259. };
  260. unsigned short LOGE2[4] = {
  261. 040061,
  262. 071027,
  263. 0173721,
  264. 0147572,
  265. };
  266. unsigned short LOGSQ2[4] = {
  267. 037661,
  268. 071027,
  269. 0173721,
  270. 0147572,
  271. };
  272. unsigned short THPIO4[4] = {
  273. 040426,
  274. 0145743,
  275. 0174631,
  276. 007222,
  277. };
  278. unsigned short TWOOPI[4] = {
  279. 040042,
  280. 0174603,
  281. 067116,
  282. 042025,
  283. };
  284. /* Approximate infinity by MAXNUM. */
  285. unsigned short INFINITY[4] = {
  286. 077777,
  287. 0177777,
  288. 0177777,
  289. 0177777,
  290. };
  291. unsigned short NAN[4] = {0000000, 0000000, 0000000, 0000000};
  292. #ifdef MINUSZERO
  293. unsigned short NEGZERO[4] = {0000000, 0000000, 0000000, 0100000};
  294. #else
  295. unsigned short NEGZERO[4] = {0000000, 0000000, 0000000, 0000000};
  296. #endif
  297. #endif
  298. #ifndef UNK
  299. extern unsigned short MACHEP[];
  300. extern unsigned short UFLOWTHRESH[];
  301. extern unsigned short MAXLOG[];
  302. extern unsigned short UNDLOG[];
  303. extern unsigned short MINLOG[];
  304. extern unsigned short MAXNUM[];
  305. extern unsigned short PI[];
  306. extern unsigned short PIO2[];
  307. extern unsigned short PIO4[];
  308. extern unsigned short SQRT2[];
  309. extern unsigned short SQRTH[];
  310. extern unsigned short LOG2E[];
  311. extern unsigned short SQ2OPI[];
  312. extern unsigned short LOGE2[];
  313. extern unsigned short LOGSQ2[];
  314. extern unsigned short THPIO4[];
  315. extern unsigned short TWOOPI[];
  316. extern unsigned short INFINITY[];
  317. extern unsigned short NAN[];
  318. extern unsigned short NEGZERO[];
  319. #endif