testvect.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /* Test vectors for math functions.
  2. See C9X section F.9.
  3. On some systems it may be necessary to modify the default exception
  4. settings of the floating point arithmetic unit. */
  5. /*
  6. Cephes Math Library Release 2.7: May, 1998
  7. Copyright 1998 by Stephen L. Moshier
  8. */
  9. #include <stdio.h>
  10. int isfinitel (long double);
  11. /* Some compilers will not accept these expressions. */
  12. #define ZINF 1
  13. #define ZMINF 2
  14. #define ZNANL 3
  15. #define ZPIL 4
  16. #define ZPIO2L 4
  17. extern long double INFINITYL, NANL, NEGZEROL;
  18. long double MINFL;
  19. extern long double PIL, PIO2L, PIO4L, MACHEPL;
  20. long double MPIL;
  21. long double MPIO2L;
  22. long double MPIO4L;
  23. long double THPIO4L = 2.35619449019234492884698L;
  24. long double MTHPIO4L = -2.35619449019234492884698L;
  25. long double SQRT2L = 1.414213562373095048802E0L;
  26. long double SQRTHL = 7.071067811865475244008E-1L;
  27. long double ZEROL = 0.0L;
  28. long double HALFL = 0.5L;
  29. long double MHALFL = -0.5L;
  30. long double ONEL = 1.0L;
  31. long double MONEL = -1.0L;
  32. long double TWOL = 2.0L;
  33. long double MTWOL = -2.0L;
  34. long double THREEL = 3.0L;
  35. long double MTHREEL = -3.0L;
  36. /* Functions of one variable. */
  37. long double logl (long double);
  38. long double expl (long double);
  39. long double atanl (long double);
  40. long double sinl (long double);
  41. long double cosl (long double);
  42. long double tanl (long double);
  43. long double acosl (long double);
  44. long double asinl (long double);
  45. long double acoshl (long double);
  46. long double asinhl (long double);
  47. long double atanhl (long double);
  48. long double sinhl (long double);
  49. long double coshl (long double);
  50. long double tanhl (long double);
  51. long double exp2l (long double);
  52. long double expm1l (long double);
  53. long double log10l (long double);
  54. long double log1pl (long double);
  55. long double log2l (long double);
  56. long double fabsl (long double);
  57. long double erfl (long double);
  58. long double erfcl (long double);
  59. long double gammal (long double);
  60. long double lgaml (long double);
  61. long double floorl (long double);
  62. long double ceill (long double);
  63. long double cbrtl (long double);
  64. struct oneargument
  65. {
  66. char *name; /* Name of the function. */
  67. long double (*func) (long double);
  68. long double *arg1;
  69. long double *answer;
  70. int thresh; /* Error report threshold. */
  71. };
  72. #if 0
  73. {"sinl", sinl, 32767.L, 1.8750655394138942394239E-1L, 0},
  74. {"cosl", cosl, 32767.L, 9.8226335176928229845654E-1L, 0},
  75. {"tanl", tanl, 32767.L, 1.9089234430221485740826E-1L, 0},
  76. {"sinl", sinl, 8388607.L, 9.9234509376961249835628E-1L, 0},
  77. {"cosl", cosl, 8388607.L, -1.2349580912475928183718E-1L, 0},
  78. {"tanl", tanl, 8388607.L, -8.0354556223613614748329E0L, 0},
  79. {"sinl", sinl, 2147483647.L, -7.2491655514455639054829E-1L, 0},
  80. {"cosl", cosl, 2147483647.L, -6.8883669187794383467976E-1L, 0},
  81. {"tanl", tanl, 2147483647.L, 1.0523779637351339136698E0L, 0},
  82. {"sinl", sinl, PIO4L, 7.0710678118654752440084E-1L, 0},
  83. {"cosl", cosl, PIO2L, -2.50827880633416613471e-20L, 0},
  84. #endif
  85. struct oneargument test1[] =
  86. {
  87. {"atanl", atanl, &ONEL, &PIO4L, 0},
  88. {"sinl", sinl, &PIO2L, &ONEL, 0},
  89. {"cosl", cosl, &PIO4L, &SQRTHL, 0},
  90. {"acosl", acosl, &NANL, &NANL, 0},
  91. {"acosl", acosl, &ONEL, &ZEROL, 0},
  92. {"acosl", acosl, &TWOL, &NANL, 0},
  93. {"acosl", acosl, &MTWOL, &NANL, 0},
  94. {"asinl", asinl, &NANL, &NANL, 0},
  95. {"asinl", asinl, &ZEROL, &ZEROL, 0},
  96. {"asinl", asinl, &NEGZEROL, &NEGZEROL, 0},
  97. {"asinl", asinl, &TWOL, &NANL, 0},
  98. {"asinl", asinl, &MTWOL, &NANL, 0},
  99. {"atanl", atanl, &NANL, &NANL, 0},
  100. {"atanl", atanl, &ZEROL, &ZEROL, 0},
  101. {"atanl", atanl, &NEGZEROL, &NEGZEROL, 0},
  102. {"atanl", atanl, &INFINITYL, &PIO2L, 0},
  103. {"atanl", atanl, &MINFL, &MPIO2L, 0},
  104. {"cosl", cosl, &NANL, &NANL, 0},
  105. {"cosl", cosl, &ZEROL, &ONEL, 0},
  106. {"cosl", cosl, &NEGZEROL, &ONEL, 0},
  107. {"cosl", cosl, &INFINITYL, &NANL, 0},
  108. {"cosl", cosl, &MINFL, &NANL, 0},
  109. {"sinl", sinl, &NANL, &NANL, 0},
  110. {"sinl", sinl, &NEGZEROL, &NEGZEROL, 0},
  111. {"sinl", sinl, &ZEROL, &ZEROL, 0},
  112. {"sinl", sinl, &INFINITYL, &NANL, 0},
  113. {"sinl", sinl, &MINFL, &NANL, 0},
  114. {"tanl", tanl, &NANL, &NANL, 0},
  115. {"tanl", tanl, &ZEROL, &ZEROL, 0},
  116. {"tanl", tanl, &NEGZEROL, &NEGZEROL, 0},
  117. {"tanl", tanl, &INFINITYL, &NANL, 0},
  118. {"tanl", tanl, &MINFL, &NANL, 0},
  119. {"acoshl", acoshl, &NANL, &NANL, 0},
  120. {"acoshl", acoshl, &ONEL, &ZEROL, 0},
  121. {"acoshl", acoshl, &INFINITYL, &INFINITYL, 0},
  122. {"acoshl", acoshl, &HALFL, &NANL, 0},
  123. {"acoshl", acoshl, &MONEL, &NANL, 0},
  124. {"asinhl", asinhl, &NANL, &NANL, 0},
  125. {"asinhl", asinhl, &ZEROL, &ZEROL, 0},
  126. {"asinhl", asinhl, &NEGZEROL, &NEGZEROL, 0},
  127. {"asinhl", asinhl, &INFINITYL, &INFINITYL, 0},
  128. {"asinhl", asinhl, &MINFL, &MINFL, 0},
  129. {"atanhl", atanhl, &NANL, &NANL, 0},
  130. {"atanhl", atanhl, &ZEROL, &ZEROL, 0},
  131. {"atanhl", atanhl, &NEGZEROL, &NEGZEROL, 0},
  132. {"atanhl", atanhl, &ONEL, &INFINITYL, 0},
  133. {"atanhl", atanhl, &MONEL, &MINFL, 0},
  134. {"atanhl", atanhl, &TWOL, &NANL, 0},
  135. {"atanhl", atanhl, &MTWOL, &NANL, 0},
  136. {"coshl", coshl, &NANL, &NANL, 0},
  137. {"coshl", coshl, &ZEROL, &ONEL, 0},
  138. {"coshl", coshl, &NEGZEROL, &ONEL, 0},
  139. {"coshl", coshl, &INFINITYL, &INFINITYL, 0},
  140. {"coshl", coshl, &MINFL, &INFINITYL, 0},
  141. {"sinhl", sinhl, &NANL, &NANL, 0},
  142. {"sinhl", sinhl, &ZEROL, &ZEROL, 0},
  143. {"sinhl", sinhl, &NEGZEROL, &NEGZEROL, 0},
  144. {"sinhl", sinhl, &INFINITYL, &INFINITYL, 0},
  145. {"sinhl", sinhl, &MINFL, &MINFL, 0},
  146. {"tanhl", tanhl, &NANL, &NANL, 0},
  147. {"tanhl", tanhl, &ZEROL, &ZEROL, 0},
  148. {"tanhl", tanhl, &NEGZEROL, &NEGZEROL, 0},
  149. {"tanhl", tanhl, &INFINITYL, &ONEL, 0},
  150. {"tanhl", tanhl, &MINFL, &MONEL, 0},
  151. {"expl", expl, &NANL, &NANL, 0},
  152. {"expl", expl, &ZEROL, &ONEL, 0},
  153. {"expl", expl, &NEGZEROL, &ONEL, 0},
  154. {"expl", expl, &INFINITYL, &INFINITYL, 0},
  155. {"expl", expl, &MINFL, &ZEROL, 0},
  156. {"exp2l", exp2l, &NANL, &NANL, 0},
  157. {"exp2l", exp2l, &ZEROL, &ONEL, 0},
  158. {"exp2l", exp2l, &NEGZEROL, &ONEL, 0},
  159. {"exp2l", exp2l, &INFINITYL, &INFINITYL, 0},
  160. {"exp2l", exp2l, &MINFL, &ZEROL, 0},
  161. {"expm1l", expm1l, &NANL, &NANL, 0},
  162. {"expm1l", expm1l, &ZEROL, &ZEROL, 0},
  163. {"expm1l", expm1l, &NEGZEROL, &NEGZEROL, 0},
  164. {"expm1l", expm1l, &INFINITYL, &INFINITYL, 0},
  165. {"expm1l", expm1l, &MINFL, &MONEL, 0},
  166. {"logl", logl, &NANL, &NANL, 0},
  167. {"logl", logl, &ZEROL, &MINFL, 0},
  168. {"logl", logl, &NEGZEROL, &MINFL, 0},
  169. {"logl", logl, &ONEL, &ZEROL, 0},
  170. {"logl", logl, &MONEL, &NANL, 0},
  171. {"logl", logl, &INFINITYL, &INFINITYL, 0},
  172. {"log10l", log10l, &NANL, &NANL, 0},
  173. {"log10l", log10l, &ZEROL, &MINFL, 0},
  174. {"log10l", log10l, &NEGZEROL, &MINFL, 0},
  175. {"log10l", log10l, &ONEL, &ZEROL, 0},
  176. {"log10l", log10l, &MONEL, &NANL, 0},
  177. {"log10l", log10l, &INFINITYL, &INFINITYL, 0},
  178. {"log1pl", log1pl, &NANL, &NANL, 0},
  179. {"log1pl", log1pl, &ZEROL, &ZEROL, 0},
  180. {"log1pl", log1pl, &NEGZEROL, &NEGZEROL, 0},
  181. {"log1pl", log1pl, &MONEL, &MINFL, 0},
  182. {"log1pl", log1pl, &MTWOL, &NANL, 0},
  183. {"log1pl", log1pl, &INFINITYL, &INFINITYL, 0},
  184. {"log2l", log2l, &NANL, &NANL, 0},
  185. {"log2l", log2l, &ZEROL, &MINFL, 0},
  186. {"log2l", log2l, &NEGZEROL, &MINFL, 0},
  187. {"log2l", log2l, &MONEL, &NANL, 0},
  188. {"log2l", log2l, &INFINITYL, &INFINITYL, 0},
  189. /* {"fabsl", fabsl, &NANL, &NANL, 0}, */
  190. {"fabsl", fabsl, &ONEL, &ONEL, 0},
  191. {"fabsl", fabsl, &MONEL, &ONEL, 0},
  192. {"fabsl", fabsl, &ZEROL, &ZEROL, 0},
  193. {"fabsl", fabsl, &NEGZEROL, &ZEROL, 0},
  194. {"fabsl", fabsl, &INFINITYL, &INFINITYL, 0},
  195. {"fabsl", fabsl, &MINFL, &INFINITYL, 0},
  196. {"cbrtl", cbrtl, &NANL, &NANL, 0},
  197. {"cbrtl", cbrtl, &ZEROL, &ZEROL, 0},
  198. {"cbrtl", cbrtl, &NEGZEROL, &NEGZEROL, 0},
  199. {"cbrtl", cbrtl, &INFINITYL, &INFINITYL, 0},
  200. {"cbrtl", cbrtl, &MINFL, &MINFL, 0},
  201. {"erfl", erfl, &NANL, &NANL, 0},
  202. {"erfl", erfl, &ZEROL, &ZEROL, 0},
  203. {"erfl", erfl, &NEGZEROL, &NEGZEROL, 0},
  204. {"erfl", erfl, &INFINITYL, &ONEL, 0},
  205. {"erfl", erfl, &MINFL, &MONEL, 0},
  206. {"erfcl", erfcl, &NANL, &NANL, 0},
  207. {"erfcl", erfcl, &INFINITYL, &ZEROL, 0},
  208. {"erfcl", erfcl, &MINFL, &TWOL, 0},
  209. {"gammal", gammal, &NANL, &NANL, 0},
  210. {"gammal", gammal, &INFINITYL, &INFINITYL, 0},
  211. {"gammal", gammal, &MONEL, &NANL, 0},
  212. {"gammal", gammal, &ZEROL, &NANL, 0},
  213. {"gammal", gammal, &MINFL, &NANL, 0},
  214. {"lgaml", lgaml, &NANL, &NANL, 0},
  215. {"lgaml", lgaml, &INFINITYL, &INFINITYL, 0},
  216. {"lgaml", lgaml, &MONEL, &INFINITYL, 0},
  217. {"lgaml", lgaml, &ZEROL, &INFINITYL, 0},
  218. {"lgaml", lgaml, &MINFL, &INFINITYL, 0},
  219. {"ceill", ceill, &NANL, &NANL, 0},
  220. {"ceill", ceill, &ZEROL, &ZEROL, 0},
  221. {"ceill", ceill, &NEGZEROL, &NEGZEROL, 0},
  222. {"ceill", ceill, &INFINITYL, &INFINITYL, 0},
  223. {"ceill", ceill, &MINFL, &MINFL, 0},
  224. {"floorl", floorl, &NANL, &NANL, 0},
  225. {"floorl", floorl, &ZEROL, &ZEROL, 0},
  226. {"floorl", floorl, &NEGZEROL, &NEGZEROL, 0},
  227. {"floorl", floorl, &INFINITYL, &INFINITYL, 0},
  228. {"floorl", floorl, &MINFL, &MINFL, 0},
  229. {"null", NULL, &ZEROL, &ZEROL, 0},
  230. };
  231. /* Functions of two variables. */
  232. long double atan2l (long double, long double);
  233. long double powl (long double, long double);
  234. struct twoarguments
  235. {
  236. char *name; /* Name of the function. */
  237. long double (*func) (long double, long double);
  238. long double *arg1;
  239. long double *arg2;
  240. long double *answer;
  241. int thresh;
  242. };
  243. struct twoarguments test2[] =
  244. {
  245. {"atan2l", atan2l, &ZEROL, &ONEL, &ZEROL, 0},
  246. {"atan2l", atan2l, &NEGZEROL, &ONEL,&NEGZEROL, 0},
  247. {"atan2l", atan2l, &ZEROL, &ZEROL, &ZEROL, 0},
  248. {"atan2l", atan2l, &NEGZEROL, &ZEROL, &NEGZEROL, 0},
  249. {"atan2l", atan2l, &ZEROL, &MONEL, &PIL, 0},
  250. {"atan2l", atan2l, &NEGZEROL, &MONEL, &MPIL, 0},
  251. {"atan2l", atan2l, &ZEROL, &NEGZEROL, &PIL, 0},
  252. {"atan2l", atan2l, &NEGZEROL, &NEGZEROL, &MPIL, 0},
  253. {"atan2l", atan2l, &ONEL, &ZEROL, &PIO2L, 0},
  254. {"atan2l", atan2l, &ONEL, &NEGZEROL, &PIO2L, 0},
  255. {"atan2l", atan2l, &MONEL, &ZEROL, &MPIO2L, 0},
  256. {"atan2l", atan2l, &MONEL, &NEGZEROL, &MPIO2L, 0},
  257. {"atan2l", atan2l, &ONEL, &INFINITYL, &ZEROL, 0},
  258. {"atan2l", atan2l, &MONEL, &INFINITYL, &NEGZEROL, 0},
  259. {"atan2l", atan2l, &INFINITYL, &ONEL, &PIO2L, 0},
  260. {"atan2l", atan2l, &INFINITYL, &MONEL, &PIO2L, 0},
  261. {"atan2l", atan2l, &MINFL, &ONEL, &MPIO2L, 0},
  262. {"atan2l", atan2l, &MINFL, &MONEL, &MPIO2L, 0},
  263. {"atan2l", atan2l, &ONEL, &MINFL, &PIL, 0},
  264. {"atan2l", atan2l, &MONEL, &MINFL, &MPIL, 0},
  265. {"atan2l", atan2l, &INFINITYL, &INFINITYL, &PIO4L, 0},
  266. {"atan2l", atan2l, &MINFL, &INFINITYL, &MPIO4L, 0},
  267. {"atan2l", atan2l, &INFINITYL, &MINFL, &THPIO4L, 0},
  268. {"atan2l", atan2l, &MINFL, &MINFL, &MTHPIO4L, 0},
  269. {"atan2l", atan2l, &ONEL, &ONEL, &PIO4L, 0},
  270. {"atan2l", atan2l, &NANL, &ONEL, &NANL, 0},
  271. {"atan2l", atan2l, &ONEL, &NANL, &NANL, 0},
  272. {"atan2l", atan2l, &NANL, &NANL, &NANL, 0},
  273. {"powl", powl, &ONEL, &ZEROL, &ONEL, 0},
  274. {"powl", powl, &ONEL, &NEGZEROL, &ONEL, 0},
  275. {"powl", powl, &MONEL, &ZEROL, &ONEL, 0},
  276. {"powl", powl, &MONEL, &NEGZEROL, &ONEL, 0},
  277. {"powl", powl, &INFINITYL, &ZEROL, &ONEL, 0},
  278. {"powl", powl, &INFINITYL, &NEGZEROL, &ONEL, 0},
  279. {"powl", powl, &NANL, &ZEROL, &ONEL, 0},
  280. {"powl", powl, &NANL, &NEGZEROL, &ONEL, 0},
  281. {"powl", powl, &TWOL, &INFINITYL, &INFINITYL, 0},
  282. {"powl", powl, &MTWOL, &INFINITYL, &INFINITYL, 0},
  283. {"powl", powl, &HALFL, &INFINITYL, &ZEROL, 0},
  284. {"powl", powl, &MHALFL, &INFINITYL, &ZEROL, 0},
  285. {"powl", powl, &TWOL, &MINFL, &ZEROL, 0},
  286. {"powl", powl, &MTWOL, &MINFL, &ZEROL, 0},
  287. {"powl", powl, &HALFL, &MINFL, &INFINITYL, 0},
  288. {"powl", powl, &MHALFL, &MINFL, &INFINITYL, 0},
  289. {"powl", powl, &INFINITYL, &HALFL, &INFINITYL, 0},
  290. {"powl", powl, &INFINITYL, &TWOL, &INFINITYL, 0},
  291. {"powl", powl, &INFINITYL, &MHALFL, &ZEROL, 0},
  292. {"powl", powl, &INFINITYL, &MTWOL, &ZEROL, 0},
  293. {"powl", powl, &MINFL, &THREEL, &MINFL, 0},
  294. {"powl", powl, &MINFL, &TWOL, &INFINITYL, 0},
  295. {"powl", powl, &MINFL, &MTHREEL, &NEGZEROL, 0},
  296. {"powl", powl, &MINFL, &MTWOL, &ZEROL, 0},
  297. {"powl", powl, &NANL, &ONEL, &NANL, 0},
  298. {"powl", powl, &ONEL, &NANL, &NANL, 0},
  299. {"powl", powl, &NANL, &NANL, &NANL, 0},
  300. {"powl", powl, &ONEL, &INFINITYL, &NANL, 0},
  301. {"powl", powl, &MONEL, &INFINITYL, &NANL, 0},
  302. {"powl", powl, &ONEL, &MINFL, &NANL, 0},
  303. {"powl", powl, &MONEL, &MINFL, &NANL, 0},
  304. {"powl", powl, &MTWOL, &HALFL, &NANL, 0},
  305. {"powl", powl, &ZEROL, &MTHREEL, &INFINITYL, 0},
  306. {"powl", powl, &NEGZEROL, &MTHREEL, &MINFL, 0},
  307. {"powl", powl, &ZEROL, &MHALFL, &INFINITYL, 0},
  308. {"powl", powl, &NEGZEROL, &MHALFL, &INFINITYL, 0},
  309. {"powl", powl, &ZEROL, &THREEL, &ZEROL, 0},
  310. {"powl", powl, &NEGZEROL, &THREEL, &NEGZEROL, 0},
  311. {"powl", powl, &ZEROL, &HALFL, &ZEROL, 0},
  312. {"powl", powl, &NEGZEROL, &HALFL, &ZEROL, 0},
  313. {"null", NULL, &ZEROL, &ZEROL, &ZEROL, 0},
  314. };
  315. /* Integer functions of one variable. */
  316. int isnanl (long double);
  317. int signbitl (long double);
  318. struct intans
  319. {
  320. char *name; /* Name of the function. */
  321. int (*func) (long double);
  322. long double *arg1;
  323. int ianswer;
  324. };
  325. struct intans test3[] =
  326. {
  327. {"isfinitel", isfinitel, &ZEROL, 1},
  328. {"isfinitel", isfinitel, &INFINITYL, 0},
  329. {"isfinitel", isfinitel, &MINFL, 0},
  330. {"isnanl", isnanl, &NANL, 1},
  331. {"isnanl", isnanl, &INFINITYL, 0},
  332. {"isnanl", isnanl, &ZEROL, 0},
  333. {"isnanl", isnanl, &NEGZEROL, 0},
  334. {"signbitl", signbitl, &NEGZEROL, 1},
  335. {"signbitl", signbitl, &MONEL, 1},
  336. {"signbitl", signbitl, &ZEROL, 0},
  337. {"signbitl", signbitl, &ONEL, 0},
  338. {"signbitl", signbitl, &MINFL, 1},
  339. {"signbitl", signbitl, &INFINITYL, 0},
  340. {"null", NULL, &ZEROL, 0},
  341. };
  342. static volatile long double x1;
  343. static volatile long double x2;
  344. static volatile long double y;
  345. static volatile long double answer;
  346. int
  347. main ()
  348. {
  349. int i, nerrors, k, ianswer, ntests;
  350. long double (*fun1) (long double);
  351. long double (*fun2) (long double, long double);
  352. int (*fun3) (long double);
  353. long double e;
  354. union
  355. {
  356. long double d;
  357. char c[12];
  358. } u, v;
  359. /* This masks off fpu exceptions on i386. */
  360. /* setfpu(0x137f); */
  361. nerrors = 0;
  362. ntests = 0;
  363. MINFL = -INFINITYL;
  364. MPIL = -PIL;
  365. MPIO2L = -PIO2L;
  366. MPIO4L = -PIO4L;
  367. i = 0;
  368. for (;;)
  369. {
  370. fun1 = test1[i].func;
  371. if (fun1 == NULL)
  372. break;
  373. x1 = *(test1[i].arg1);
  374. y = (*(fun1)) (x1);
  375. answer = *(test1[i].answer);
  376. if (test1[i].thresh == 0)
  377. {
  378. v.d = answer;
  379. u.d = y;
  380. if (memcmp(u.c, v.c, 10) != 0)
  381. {
  382. /* O.K. if both are NaNs of some sort. */
  383. if (isnanl(v.d) && isnanl(u.d))
  384. goto nxttest1;
  385. goto wrongone;
  386. }
  387. else
  388. goto nxttest1;
  389. }
  390. if (y != answer)
  391. {
  392. e = y - answer;
  393. if (answer != 0.0L)
  394. e = e / answer;
  395. if (e < 0)
  396. e = -e;
  397. if (e > test1[i].thresh * MACHEPL)
  398. {
  399. wrongone:
  400. printf ("%s (%.20Le) = %.20Le\n should be %.20Le\n",
  401. test1[i].name, x1, y, answer);
  402. nerrors += 1;
  403. }
  404. }
  405. nxttest1:
  406. ntests += 1;
  407. i += 1;
  408. }
  409. i = 0;
  410. for (;;)
  411. {
  412. fun2 = test2[i].func;
  413. if (fun2 == NULL)
  414. break;
  415. x1 = *(test2[i].arg1);
  416. x2 = *(test2[i].arg2);
  417. y = (*(fun2)) (x1, x2);
  418. answer = *(test2[i].answer);
  419. if (test2[i].thresh == 0)
  420. {
  421. v.d = answer;
  422. u.d = y;
  423. if (memcmp(u.c, v.c, 10) != 0)
  424. {
  425. /* O.K. if both are NaNs of some sort. */
  426. if (isnanl(v.d) && isnanl(u.d))
  427. goto nxttest2;
  428. goto wrongtwo;
  429. }
  430. else
  431. goto nxttest2;
  432. }
  433. if (y != answer)
  434. {
  435. e = y - answer;
  436. if (answer != 0.0L)
  437. e = e / answer;
  438. if (e < 0)
  439. e = -e;
  440. if (e > test2[i].thresh * MACHEPL)
  441. {
  442. wrongtwo:
  443. printf ("%s (%.20Le, %.20Le) = %.20Le\n should be %.20Le\n",
  444. test2[i].name, x1, x2, y, answer);
  445. nerrors += 1;
  446. }
  447. }
  448. nxttest2:
  449. ntests += 1;
  450. i += 1;
  451. }
  452. i = 0;
  453. for (;;)
  454. {
  455. fun3 = test3[i].func;
  456. if (fun3 == NULL)
  457. break;
  458. x1 = *(test3[i].arg1);
  459. k = (*(fun3)) (x1);
  460. ianswer = test3[i].ianswer;
  461. if (k != ianswer)
  462. {
  463. printf ("%s (%.20Le) = %d\n should be. %d\n",
  464. test3[i].name, x1, k, ianswer);
  465. nerrors += 1;
  466. }
  467. ntests += 1;
  468. i += 1;
  469. }
  470. printf ("testvect: %d errors in %d tests\n", nerrors, ntests);
  471. exit (0);
  472. }