const.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. * math.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 <math.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] = {041660,007463,0143742,025733,};
  199. /* log 2**-128 = -88.72283911167299960540 */
  200. unsigned short MINLOG[4] = {0141661,071027,0173721,0147572,};
  201. /* 2**127 = 1.701411834604692317316873e38 */
  202. unsigned short MAXNUM[4] = {077777,0177777,0177777,0177777,};
  203. unsigned short PI[4] = {040511,007732,0121041,064302,};
  204. unsigned short PIO2[4] = {040311,007732,0121041,064302,};
  205. unsigned short PIO4[4] = {040111,007732,0121041,064302,};
  206. unsigned short SQRT2[4] = {040265,002363,031771,0157145,};
  207. unsigned short SQRTH[4] = {040065,002363,031771,0157144,};
  208. unsigned short LOG2E[4] = {040270,0125073,024534,013761,};
  209. unsigned short SQ2OPI[4] = {040114,041051,0117241,0131204,};
  210. unsigned short LOGE2[4] = {040061,071027,0173721,0147572,};
  211. unsigned short LOGSQ2[4] = {037661,071027,0173721,0147572,};
  212. unsigned short THPIO4[4] = {040426,0145743,0174631,007222,};
  213. unsigned short TWOOPI[4] = {040042,0174603,067116,042025,};
  214. /* Approximate infinity by MAXNUM. */
  215. unsigned short INFINITY[4] = {077777,0177777,0177777,0177777,};
  216. unsigned short NAN[4] = {0000000,0000000,0000000,0000000};
  217. #ifdef MINUSZERO
  218. unsigned short NEGZERO[4] = {0000000,0000000,0000000,0100000};
  219. #else
  220. unsigned short NEGZERO[4] = {0000000,0000000,0000000,0000000};
  221. #endif
  222. #endif
  223. #ifndef UNK
  224. extern unsigned short MACHEP[];
  225. extern unsigned short UFLOWTHRESH[];
  226. extern unsigned short MAXLOG[];
  227. extern unsigned short UNDLOG[];
  228. extern unsigned short MINLOG[];
  229. extern unsigned short MAXNUM[];
  230. extern unsigned short PI[];
  231. extern unsigned short PIO2[];
  232. extern unsigned short PIO4[];
  233. extern unsigned short SQRT2[];
  234. extern unsigned short SQRTH[];
  235. extern unsigned short LOG2E[];
  236. extern unsigned short SQ2OPI[];
  237. extern unsigned short LOGE2[];
  238. extern unsigned short LOGSQ2[];
  239. extern unsigned short THPIO4[];
  240. extern unsigned short TWOOPI[];
  241. extern unsigned short INFINITY[];
  242. extern unsigned short NAN[];
  243. extern unsigned short NEGZERO[];
  244. #endif