#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
Include dependency graph for paranoia.c:

Go to the source code of this file.
Defines | |
| #define | Chopped 2 |
| #define | Defect 2 |
| #define | FABS(x) fabs(x) |
| #define | Failure 0 |
| #define | False 0 |
| #define | Flaw 3 |
| #define | FLOAT double |
| #define | FLOOR(x) floor(x) |
| #define | KEYBOARD 0 |
| #define | LOG(x) log(x) |
| #define | No 0 |
| #define | NOPAUSE |
| #define | Other 0 |
| #define | POW(x, y) pow(x,y) |
| #define | Rounded 1 |
| #define | Serious 1 |
| #define | SQRT(x) sqrt(x) |
| #define | True 1 |
| #define | Yes 1 |
Typedefs | |
| typedef int | Class |
| typedef int | Guard |
| typedef char | Message |
| typedef int | Rounding |
| typedef void(* | Sig_type )() |
Functions | |
| BadCond (int K, char *T) | |
| Characteristics () | |
| double | fabs () |
| double | floor () |
| Heading () | |
| History () | |
| Instructions () | |
| IsYeqX () | |
| double | log () |
| main () | |
| msglist (char **s) | |
| NewD () | |
| notify (char *s) | |
| Pause () | |
| double | pow (double x, double y) |
| double | pow () |
| PrintIfNPositive () | |
| FLOAT | Random () |
| void | sigfpe (i) |
| FLOAT | Sign (FLOAT X) |
| FLOAT | Sign () |
| double | sqrt () |
| SqXMinX (int ErrKind) | |
| SR3750 () | |
| SR3980 () | |
| TstCond (int K, int Valid, char *T) | |
| TstPtUf () | |
Variables | |
| FLOAT | A1 |
| FLOAT | AInvrse |
| int | Anomaly |
| FLOAT | BInvrse |
| FLOAT | BMinusU2 |
| int | Break |
| FLOAT | C |
| char | ch [8] |
| FLOAT | CInvrse |
| FLOAT | D |
| int | Done |
| FLOAT | E0 |
| FLOAT | E1 |
| FLOAT | E3 |
| FLOAT | E9 |
| FLOAT | Eight = 8.0 |
| int | ErrCnt [4] |
| FLOAT | Exp2 |
| FLOAT | F6 |
| FLOAT | F9 |
| FLOAT | Five = 5.0 |
| FLOAT | Four = 4.0 |
| FLOAT | FourD |
| int | fpecount |
| Guard | GAddSub |
| Guard | GDiv |
| Guard | GMult |
| FLOAT | H |
| FLOAT | Half = 0.5 |
| FLOAT | HInvrse |
| int | I |
| int | IEEE |
| int | Indx |
| FLOAT | J |
| int | M |
| FLOAT | MaxSqEr |
| int | Milestone |
| FLOAT | MinSqEr |
| FLOAT | MinusOne = -1.0 |
| int | Monot |
| FLOAT | MyZero |
| int | N |
| int | N1 |
| FLOAT | Nine = 9.0 |
| int | NotMonot |
| int | NoTrials = 20 |
| FLOAT | One = 1.0 |
| FLOAT | OneAndHalf = 1.5 |
| FLOAT | OneUlp |
| jmp_buf | ovfl_buf |
| int | PageNo |
| FLOAT | Precision |
| FLOAT | PseudoZero |
| FLOAT | Q |
| FLOAT | Q9 |
| FLOAT | R |
| Rounding | RAddSub |
| FLOAT | Radix |
| FLOAT | RadixD2 |
| FLOAT | Random1 |
| FLOAT | Random2 |
| FLOAT | Random9 |
| Rounding | RDiv |
| Rounding | RMult |
| Rounding | RSqrt |
| FLOAT | S |
| Sig_type | sigsave |
| FLOAT | SqEr |
| int | SqRWrng |
| FLOAT | StickyBit |
| FLOAT | T |
| FLOAT | Third |
| FLOAT | ThirtyTwo = 32.0 |
| FLOAT | Three = 3.0 |
| FLOAT | TwentySeven = 27.0 |
| FLOAT | Two = 2.0 |
| FLOAT | TwoForty = 240.0 |
| FLOAT | U1 |
| FLOAT | U2 |
| int | UfNGrad |
| FLOAT | UfThold |
| FLOAT | Underflow |
| FLOAT | V |
| FLOAT | V0 |
| FLOAT | V9 |
| FLOAT | W |
| FLOAT | X |
| FLOAT | X1 |
| FLOAT | X2 |
| FLOAT | X8 |
| FLOAT | Y |
| FLOAT | Y1 |
| FLOAT | Y2 |
| FLOAT | Z |
| FLOAT | Z1 |
| FLOAT | Z2 |
| FLOAT | Z9 |
| FLOAT | Zero = 0.0 |
|
|
Definition at line 278 of file paranoia.c. |
|
|
Definition at line 282 of file paranoia.c. |
|
|
Definition at line 234 of file paranoia.c. |
|
|
Definition at line 284 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 267 of file paranoia.c. Referenced by GLW_SetMode(), install_grabs(), and main(). |
|
|
Definition at line 281 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 233 of file paranoia.c. Referenced by asgncode(), constant(), do_type(), emittype(), eqtype(), hasproto(), outtype(), postfix(), primary(), promote(), prtype(), Random(), Sign(), specifier(), SqXMinX(), tracevalue(), ttob(), type_init(), typestring(), typeuid(), uid2type(), vtoa(), and xxinit(). |
|
|
Definition at line 235 of file paranoia.c. |
|
|
Definition at line 245 of file paranoia.c. |
|
|
Definition at line 236 of file paranoia.c. |
|
|
Definition at line 277 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 2 of file paranoia.c. |
|
|
Definition at line 280 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 237 of file paranoia.c. |
|
|
Definition at line 279 of file paranoia.c. |
|
|
Definition at line 283 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 238 of file paranoia.c. |
|
|
Definition at line 268 of file paranoia.c. Referenced by GLW_SetMode(), and install_grabs(). |
|
|
Definition at line 276 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 285 of file paranoia.c. |
|
|
Definition at line 285 of file paranoia.c. |
|
|
Definition at line 286 of file paranoia.c. |
|
|
Definition at line 285 of file paranoia.c. |
|
|
Definition at line 242 of file paranoia.c. |
|
||||||||||||
|
Definition at line 1876 of file paranoia.c. References ErrCnt, printf(), and T. Referenced by IsYeqX(), main(), SqXMinX(), TstCond(), and TstPtUf(). 01879 {
01880 static char *msg[] = { "FAILURE", "SERIOUS DEFECT", "DEFECT", "FLAW" };
01881
01882 ErrCnt [K] = ErrCnt [K] + 1;
01883 printf("%s: %s", msg[K], T);
01884 }
|
Here is the call graph for this function:

|
|
Definition at line 2119 of file paranoia.c. References msglist(). Referenced by main(). 02120 {
02121 static char *chars[] = {
02122 "Running this program should reveal these characteristics:",
02123 " Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...",
02124 " Precision = number of significant digits carried.",
02125 " U2 = Radix/Radix^Precision = One Ulp",
02126 "\t(OneUlpnit in the Last Place) of 1.000xxx .",
02127 " U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .",
02128 " Adequacy of guard digits for Mult., Div. and Subt.",
02129 " Whether arithmetic is chopped, correctly rounded, or something else",
02130 "\tfor Mult., Div., Add/Subt. and Sqrt.",
02131 " Whether a Sticky Bit used correctly for rounding.",
02132 " UnderflowThreshold = an underflow threshold.",
02133 " E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.",
02134 " V = an overflow threshold, roughly.",
02135 " V0 tells, roughly, whether Infinity is represented.",
02136 " Comparisions are checked for consistency with subtraction",
02137 "\tand for contamination with pseudo-zeros.",
02138 " Sqrt is tested. Y^X is not tested.",
02139 " Extra-precise subexpressions are revealed but NOT YET tested.",
02140 " Decimal-Binary conversion is NOT YET tested for accuracy.",
02141 0};
02142
02143 msglist(chars);
02144 }
|
Here is the call graph for this function:

|
|
|
|
Definition at line 2091 of file paranoia.c. References head, and msglist(). Referenced by main(). 02092 {
02093 static char *head[] = {
02094 "Users are invited to help debug and augment this program so it will",
02095 "cope with unanticipated and newly uncovered arithmetic pathologies.\n",
02096 "Please send suggestions and interesting results to",
02097 "\tRichard Karpinski",
02098 "\tComputer Center U-76",
02099 "\tUniversity of California",
02100 "\tSan Francisco, CA 94143-0704, USA\n",
02101 "In doing so, please include the following information:",
02102 #ifdef Single
02103 "\tPrecision:\tsingle;",
02104 #else
02105 "\tPrecision:\tdouble;",
02106 #endif
02107 "\tVersion:\t10 February 1989;",
02108 "\tComputer:\n",
02109 "\tCompiler:\n",
02110 "\tOptimization level:\n",
02111 "\tOther relevant compiler options:",
02112 0};
02113
02114 msglist(head);
02115 }
|
Here is the call graph for this function:

|
|
Definition at line 2146 of file paranoia.c. References msglist(). Referenced by main(). 02148 { /* History */
02149 /* Converted from Brian Wichmann's Pascal version to C by Thos Sumner,
02150 with further massaging by David M. Gay. */
02151
02152 static char *hist[] = {
02153 "The program attempts to discriminate among",
02154 " FLAWs, like lack of a sticky bit,",
02155 " Serious DEFECTs, like lack of a guard digit, and",
02156 " FAILUREs, like 2+2 == 5 .",
02157 "Failures may confound subsequent diagnoses.\n",
02158 "The diagnostic capabilities of this program go beyond an earlier",
02159 "program called `MACHAR', which can be found at the end of the",
02160 "book `Software Manual for the Elementary Functions' (1980) by",
02161 "W. J. Cody and W. Waite. Although both programs try to discover",
02162 "the Radix, Precision and range (over/underflow thresholds)",
02163 "of the arithmetic, this program tries to cope with a wider variety",
02164 "of pathologies, and to say how well the arithmetic is implemented.",
02165 "\nThe program is based upon a conventional radix representation for",
02166 "floating-point numbers, but also allows logarithmic encoding",
02167 "as used by certain early WANG machines.\n",
02168 "BASIC version of this program (C) 1983 by Prof. W. M. Kahan;",
02169 "see source comments for more history.",
02170 0};
02171
02172 msglist(hist);
02173 }
|
Here is the call graph for this function:

|
|
Definition at line 2072 of file paranoia.c. References msglist(). Referenced by main(). 02073 {
02074 static char *instr[] = {
02075 "Lest this program stop prematurely, i.e. before displaying\n",
02076 " `END OF TEST',\n",
02077 "try to persuade the computer NOT to terminate execution when an",
02078 "error like Over/Underflow or Division by Zero occurs, but rather",
02079 "to persevere with a surrogate value after, perhaps, displaying some",
02080 "warning. If persuasion avails naught, don't despair but run this",
02081 "program anyway to see how many milestones it passes, and then",
02082 "amend it to make further progress.\n",
02083 "Answer questions with Y, y, N or n (unless otherwise indicated).\n",
02084 0};
02085
02086 msglist(instr);
02087 }
|
Here is the call graph for this function:

|
|
Definition at line 1960 of file paranoia.c. References BadCond(), Defect, N, printf(), Q, X, Y, Z, and Zero. Referenced by main(), and SR3980(). 01961 {
01962 if (Y != X) {
01963 if (N <= 0) {
01964 if (Z == Zero && Q <= Zero)
01965 printf("WARNING: computing\n");
01966 else BadCond(Defect, "computing\n");
01967 printf("\t(%.17e) ^ (%.17e)\n", Z, Q);
01968 printf("\tyielded %.17e;\n", Y);
01969 printf("\twhich compared unequal to correct %.17e ;\n",
01970 X);
01971 printf("\t\tthey differ by %.17e .\n", Y - X);
01972 }
01973 N = N + 1; /* ... count discrepancies. */
01974 }
01975 }
|
Here is the call graph for this function:

|
|
Referenced by pow(). |
|
|
Definition at line 342 of file paranoia.c. References A1, AInvrse, Anomaly, BadCond(), BInvrse, BMinusU2, Break, C, ch, Characteristics(), CInvrse, D, Defect, Done, E0, E1, E3, E9, Eight, ErrCnt, Exp2, F6, F9, FABS, Failure, False, fflush(), Five, Flaw, FLOOR, Four, FourD, fpecount, GAddSub, GDiv, GMult, H, Half, Heading(), HInvrse, History(), i, I, IEEE, Indx, Instructions(), IsYeqX(), J, KEYBOARD, LOG, M, MaxSqEr, Milestone, MinSqEr, MinusOne, Monot, MyZero, N, N1, NewD(), Nine, No, notify(), NotMonot, NoTrials, One, OneAndHalf, OneUlp, Other, ovfl_buf, PageNo, Pause(), POW, Precision, printf(), PrintIfNPositive(), PseudoZero, Q, R, RAddSub, Radix, RadixD2, Random(), Random1, Random2, Random9, RDiv, read(), RMult, RSqrt, S, Serious, setjmp(), sigfpe(), SIGFPE, Sign, signal, sigsave, SqEr, SQRT, SqRWrng, SqXMinX(), SR3750(), SR3980(), stdout, StickyBit, T, Third, ThirtyTwo, Three, TstCond(), TstPtUf(), TwentySeven, Two, TwoForty, U1, U2, UfNGrad, UfThold, Underflow, V, V0, V9, W, X, X1, X8, Y, Y1, Y2, Yes, Z, Z1, Z2, Z9, and Zero. 00343 {
00344 #ifdef mc
00345 char *out;
00346 ieee_flags("set", "precision", "double", &out);
00347 #endif
00348 /* First two assignments use integer right-hand sides. */
00349 Zero = 0;
00350 One = 1;
00351 Two = One + One;
00352 Three = Two + One;
00353 Four = Three + One;
00354 Five = Four + One;
00355 Eight = Four + Four;
00356 Nine = Three * Three;
00357 TwentySeven = Nine * Three;
00358 ThirtyTwo = Four * Eight;
00359 TwoForty = Four * Five * Three * Four;
00360 MinusOne = -One;
00361 Half = One / Two;
00362 OneAndHalf = One + Half;
00363 ErrCnt[Failure] = 0;
00364 ErrCnt[Serious] = 0;
00365 ErrCnt[Defect] = 0;
00366 ErrCnt[Flaw] = 0;
00367 PageNo = 1;
00368 /*=============================================*/
00369 Milestone = 0;
00370 /*=============================================*/
00371 #ifndef NOSIGNAL
00372 signal(SIGFPE, sigfpe);
00373 #endif
00374 Instructions();
00375 Pause();
00376 Heading();
00377 Pause();
00378 Characteristics();
00379 Pause();
00380 History();
00381 Pause();
00382 /*=============================================*/
00383 Milestone = 7;
00384 /*=============================================*/
00385 printf("Program is now RUNNING tests on small integers:\n");
00386
00387 TstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero)
00388 && (One > Zero) && (One + One == Two),
00389 "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2");
00390 Z = - Zero;
00391 if (Z != 0.0) {
00392 ErrCnt[Failure] = ErrCnt[Failure] + 1;
00393 printf("Comparison alleges that -0.0 is Non-zero!\n");
00394 U1 = 0.001;
00395 Radix = 1;
00396 TstPtUf();
00397 }
00398 TstCond (Failure, (Three == Two + One) && (Four == Three + One)
00399 && (Four + Two * (- Two) == Zero)
00400 && (Four - Three - One == Zero),
00401 "3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0");
00402 TstCond (Failure, (MinusOne == (0 - One))
00403 && (MinusOne + One == Zero ) && (One + MinusOne == Zero)
00404 && (MinusOne + FABS(One) == Zero)
00405 && (MinusOne + MinusOne * MinusOne == Zero),
00406 "-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0");
00407 TstCond (Failure, Half + MinusOne + Half == Zero,
00408 "1/2 + (-1) + 1/2 != 0");
00409 /*=============================================*/
00410 /*SPLIT
00411 part2();
00412 part3();
00413 part4();
00414 part5();
00415 part6();
00416 part7();
00417 part8();
00418 }
00419 #include "paranoia.h"
00420 part2(){
00421 */
00422 Milestone = 10;
00423 /*=============================================*/
00424 TstCond (Failure, (Nine == Three * Three)
00425 && (TwentySeven == Nine * Three) && (Eight == Four + Four)
00426 && (ThirtyTwo == Eight * Four)
00427 && (ThirtyTwo - TwentySeven - Four - One == Zero),
00428 "9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0");
00429 TstCond (Failure, (Five == Four + One) &&
00430 (TwoForty == Four * Five * Three * Four)
00431 && (TwoForty / Three - Four * Four * Five == Zero)
00432 && ( TwoForty / Four - Five * Three * Four == Zero)
00433 && ( TwoForty / Five - Four * Three * Four == Zero),
00434 "5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48");
00435 if (ErrCnt[Failure] == 0) {
00436 printf("-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n");
00437 printf("\n");
00438 }
00439 printf("Searching for Radix and Precision.\n");
00440 W = One;
00441 do {
00442 W = W + W;
00443 Y = W + One;
00444 Z = Y - W;
00445 Y = Z - One;
00446 } while (MinusOne + FABS(Y) < Zero);
00447 /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/
00448 Precision = Zero;
00449 Y = One;
00450 do {
00451 Radix = W + Y;
00452 Y = Y + Y;
00453 Radix = Radix - W;
00454 } while ( Radix == Zero);
00455 if (Radix < Two) Radix = One;
00456 printf("Radix = %f .\n", Radix);
00457 if (Radix != 1) {
00458 W = One;
00459 do {
00460 Precision = Precision + One;
00461 W = W * Radix;
00462 Y = W + One;
00463 } while ((Y - W) == One);
00464 }
00465 /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1
00466 ...*/
00467 U1 = One / W;
00468 U2 = Radix * U1;
00469 printf("Closest relative separation found is U1 = %.7e .\n\n", U1);
00470 printf("Recalculating radix and precision\n ");
00471
00472 /*save old values*/
00473 E0 = Radix;
00474 E1 = U1;
00475 E9 = U2;
00476 E3 = Precision;
00477
00478 X = Four / Three;
00479 Third = X - One;
00480 F6 = Half - Third;
00481 X = F6 + F6;
00482 X = FABS(X - Third);
00483 if (X < U2) X = U2;
00484
00485 /*... now X = (unknown no.) ulps of 1+...*/
00486 do {
00487 U2 = X;
00488 Y = Half * U2 + ThirtyTwo * U2 * U2;
00489 Y = One + Y;
00490 X = Y - One;
00491 } while ( ! ((U2 <= X) || (X <= Zero)));
00492
00493 /*... now U2 == 1 ulp of 1 + ... */
00494 X = Two / Three;
00495 F6 = X - Half;
00496 Third = F6 + F6;
00497 X = Third - Half;
00498 X = FABS(X + F6);
00499 if (X < U1) X = U1;
00500
00501 /*... now X == (unknown no.) ulps of 1 -... */
00502 do {
00503 U1 = X;
00504 Y = Half * U1 + ThirtyTwo * U1 * U1;
00505 Y = Half - Y;
00506 X = Half + Y;
00507 Y = Half - X;
00508 X = Half + Y;
00509 } while ( ! ((U1 <= X) || (X <= Zero)));
00510 /*... now U1 == 1 ulp of 1 - ... */
00511 if (U1 == E1) printf("confirms closest relative separation U1 .\n");
00512 else printf("gets better closest relative separation U1 = %.7e .\n", U1);
00513 W = One / U1;
00514 F9 = (Half - U1) + Half;
00515 Radix = FLOOR(0.01 + U2 / U1);
00516 if (Radix == E0) printf("Radix confirmed.\n");
00517 else printf("MYSTERY: recalculated Radix = %.7e .\n", Radix);
00518 TstCond (Defect, Radix <= Eight + Eight,
00519 "Radix is too big: roundoff problems");
00520 TstCond (Flaw, (Radix == Two) || (Radix == 10)
00521 || (Radix == One), "Radix is not as good as 2 or 10");
00522 /*=============================================*/
00523 Milestone = 20;
00524 /*=============================================*/
00525 TstCond (Failure, F9 - Half < Half,
00526 "(1-U1)-1/2 < 1/2 is FALSE, prog. fails?");
00527 X = F9;
00528 I = 1;
00529 Y = X - Half;
00530 Z = Y - Half;
00531 TstCond (Failure, (X != One)
00532 || (Z == Zero), "Comparison is fuzzy,X=1 but X-1/2-1/2 != 0");
00533 X = One + U2;
00534 I = 0;
00535 /*=============================================*/
00536 Milestone = 25;
00537 /*=============================================*/
00538 /*... BMinusU2 = nextafter(Radix, 0) */
00539 BMinusU2 = Radix - One;
00540 BMinusU2 = (BMinusU2 - U2) + One;
00541 /* Purify Integers */
00542 if (Radix != One) {
00543 X = - TwoForty * LOG(U1) / LOG(Radix);
00544 Y = FLOOR(Half + X);
00545 if (FABS(X - Y) * Four < One) X = Y;
00546 Precision = X / TwoForty;
00547 Y = FLOOR(Half + Precision);
00548 if (FABS(Precision - Y) * TwoForty < Half) Precision = Y;
00549 }
00550 if ((Precision != FLOOR(Precision)) || (Radix == One)) {
00551 printf("Precision cannot be characterized by an Integer number\n");
00552 printf("of significant digits but, by itself, this is a minor flaw.\n");
00553 }
00554 if (Radix == One)
00555 printf("logarithmic encoding has precision characterized solely by U1.\n");
00556 else printf("The number of significant digits of the Radix is %f .\n",
00557 Precision);
00558 TstCond (Serious, U2 * Nine * Nine * TwoForty < One,
00559 "Precision worse than 5 decimal figures ");
00560 /*=============================================*/
00561 Milestone = 30;
00562 /*=============================================*/
00563 /* Test for extra-precise subepressions */
00564 X = FABS(((Four / Three - One) - One / Four) * Three - One / Four);
00565 do {
00566 Z2 = X;
00567 X = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One;
00568 } while ( ! ((Z2 <= X) || (X <= Zero)));
00569 X = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four);
00570 do {
00571 Z1 = Z;
00572 Z = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1))
00573 + One / Two)) + One / Two;
00574 } while ( ! ((Z1 <= Z) || (Z <= Zero)));
00575 do {
00576 do {
00577 Y1 = Y;
00578 Y = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half
00579 )) + Half;
00580 } while ( ! ((Y1 <= Y) || (Y <= Zero)));
00581 X1 = X;
00582 X = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9;
00583 } while ( ! ((X1 <= X) || (X <= Zero)));
00584 if ((X1 != Y1) || (X1 != Z1)) {
00585 BadCond(Serious, "Disagreements among the values X1, Y1, Z1,\n");
00586 printf("respectively %.7e, %.7e, %.7e,\n", X1, Y1, Z1);
00587 printf("are symptoms of inconsistencies introduced\n");
00588 printf("by extra-precise evaluation of arithmetic subexpressions.\n");
00589 notify("Possibly some part of this");
00590 if ((X1 == U1) || (Y1 == U1) || (Z1 == U1)) printf(
00591 "That feature is not tested further by this program.\n") ;
00592 }
00593 else {
00594 if ((Z1 != U1) || (Z2 != U2)) {
00595 if ((Z1 >= U1) || (Z2 >= U2)) {
00596 BadCond(Failure, "");
00597 notify("Precision");
00598 printf("\tU1 = %.7e, Z1 - U1 = %.7e\n",U1,Z1-U1);
00599 printf("\tU2 = %.7e, Z2 - U2 = %.7e\n",U2,Z2-U2);
00600 }
00601 else {
00602 if ((Z1 <= Zero) || (Z2 <= Zero)) {
00603 printf("Because of unusual Radix = %f", Radix);
00604 printf(", or exact rational arithmetic a result\n");
00605 printf("Z1 = %.7e, or Z2 = %.7e ", Z1, Z2);
00606 notify("of an\nextra-precision");
00607 }
00608 if (Z1 != Z2 || Z1 > Zero) {
00609 X = Z1 / U1;
00610 Y = Z2 / U2;
00611 if (Y > X) X = Y;
00612 Q = - LOG(X);
00613 printf("Some subexpressions appear to be calculated extra\n");
00614 printf("precisely with about %g extra B-digits, i.e.\n",
00615 (Q / LOG(Radix)));
00616 printf("roughly %g extra significant decimals.\n",
00617 Q / LOG(10.));
00618 }
00619 printf("That feature is not tested further by this program.\n");
00620 }
00621 }
00622 }
00623 Pause();
00624 /*=============================================*/
00625 /*SPLIT
00626 }
00627 #include "paranoia.h"
00628 part3(){
00629 */
00630 Milestone = 35;
00631 /*=============================================*/
00632 if (Radix >= Two) {
00633 X = W / (Radix * Radix);
00634 Y = X + One;
00635 Z = Y - X;
00636 T = Z + U2;
00637 X = T - Z;
00638 TstCond (Failure, X == U2,
00639 "Subtraction is not normalized X=Y,X+Z != Y+Z!");
00640 if (X == U2) printf(
00641 "Subtraction appears to be normalized, as it should be.");
00642 }
00643 printf("\nChecking for guard digit in *, /, and -.\n");
00644 Y = F9 * One;
00645 Z = One * F9;
00646 X = F9 - Half;
00647 Y = (Y - Half) - X;
00648 Z = (Z - Half) - X;
00649 X = One + U2;
00650 T = X * Radix;
00651 R = Radix * X;
00652 X = T - Radix;
00653 X = X - Radix * U2;
00654 T = R - Radix;
00655 T = T - Radix * U2;
00656 X = X * (Radix - One);
00657 T = T * (Radix - One);
00658 if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes;
00659 else {
00660 GMult = No;
00661 TstCond (Serious, False,
00662 "* lacks a Guard Digit, so 1*X != X");
00663 }
00664 Z = Radix * U2;
00665 X = One + Z;
00666 Y = FABS((X + Z) - X * X) - U2;
00667 X = One - U2;
00668 Z = FABS((X - U2) - X * X) - U1;
00669 TstCond (Failure, (Y <= Zero)
00670 && (Z <= Zero), "* gets too many final digits wrong.\n");
00671 Y = One - U2;
00672 X = One + U2;
00673 Z = One / Y;
00674 Y = Z - X;
00675 X = One / Three;
00676 Z = Three / Nine;
00677 X = X - Z;
00678 T = Nine / TwentySeven;
00679 Z = Z - T;
00680 TstCond(Defect, X == Zero && Y == Zero && Z == Zero,
00681 "Division lacks a Guard Digit, so error can exceed 1 ulp\nor 1/3 and 3/9 and 9/27 may disagree");
00682 Y = F9 / One;
00683 X = F9 - Half;
00684 Y = (Y - Half) - X;
00685 X = One + U2;
00686 T = X / One;
00687 X = T - X;
00688 if ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes;
00689 else {
00690 GDiv = No;
00691 TstCond (Serious, False,
00692 "Division lacks a Guard Digit, so X/1 != X");
00693 }
00694 X = One / (One + U2);
00695 Y = X - Half - Half;
00696 TstCond (Serious, Y < Zero,
00697 "Computed value of 1/1.000..1 >= 1");
00698 X = One - U2;
00699 Y = One + Radix * U2;
00700 Z = X * Radix;
00701 T = Y * Radix;
00702 R = Z / Radix;
00703 StickyBit = T / Radix;
00704 X = R - X;
00705 Y = StickyBit - Y;
00706 TstCond (Failure, X == Zero && Y == Zero,
00707 "* and/or / gets too many last digits wrong");
00708 Y = One - U1;
00709 X = One - F9;
00710 Y = One - Y;
00711 T = Radix - U2;
00712 Z = Radix - BMinusU2;
00713 T = Radix - T;
00714 if ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes;
00715 else {
00716 GAddSub = No;
00717 TstCond (Serious, False,
00718 "- lacks Guard Digit, so cancellation is obscured");
00719 }
00720 if (F9 != One && F9 - One >= Zero) {
00721 BadCond(Serious, "comparison alleges (1-U1) < 1 although\n");
00722 printf(" subtraction yields (1-U1) - 1 = 0 , thereby vitiating\n");
00723 printf(" such precautions against division by zero as\n");
00724 printf(" ... if (X == 1.0) {.....} else {.../(X-1.0)...}\n");
00725 }
00726 if (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf(
00727 " *, /, and - appear to have guard digits, as they should.\n");
00728 /*=============================================*/
00729 Milestone = 40;
00730 /*=============================================*/
00731 Pause();
00732 printf("Checking rounding on multiply, divide and add/subtract.\n");
00733 RMult = Other;
00734 RDiv = Other;
00735 RAddSub = Other;
00736 RadixD2 = Radix / Two;
00737 A1 = Two;
00738 Done = False;
00739 do {
00740 AInvrse = Radix;
00741 do {
00742 X = AInvrse;
00743 AInvrse = AInvrse / A1;
00744 } while ( ! (FLOOR(AInvrse) != AInvrse));
00745 Done = (X == One) || (A1 > Three);
00746 if (! Done) A1 = Nine + One;
00747 } while ( ! (Done));
00748 if (X == One) A1 = Radix;
00749 AInvrse = One / A1;
00750 X = A1;
00751 Y = AInvrse;
00752 Done = False;
00753 do {
00754 Z = X * Y - Half;
00755 TstCond (Failure, Z == Half,
00756 "X * (1/X) differs from 1");
00757 Done = X == Radix;
00758 X = Radix;
00759 Y = One / X;
00760 } while ( ! (Done));
00761 Y2 = One + U2;
00762 Y1 = One - U2;
00763 X = OneAndHalf - U2;
00764 Y = OneAndHalf + U2;
00765 Z = (X - U2) * Y2;
00766 T = Y * Y1;
00767 Z = Z - X;
00768 T = T - X;
00769 X = X * Y2;
00770 Y = (Y + U2) * Y1;
00771 X = X - OneAndHalf;
00772 Y = Y - OneAndHalf;
00773 if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) {
00774 X = (OneAndHalf + U2) * Y2;
00775 Y = OneAndHalf - U2 - U2;
00776 Z = OneAndHalf + U2 + U2;
00777 T = (OneAndHalf - U2) * Y1;
00778 X = X - (Z + U2);
00779 StickyBit = Y * Y1;
00780 S = Z * Y2;
00781 T = T - Y;
00782 Y = (U2 - Y) + StickyBit;
00783 Z = S - (Z + U2 + U2);
00784 StickyBit = (Y2 + U2) * Y1;
00785 Y1 = Y2 * Y1;
00786 StickyBit = StickyBit - Y2;
00787 Y1 = Y1 - Half;
00788 if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)
00789 && ( StickyBit == Zero) && (Y1 == Half)) {
00790 RMult = Rounded;
00791 printf("Multiplication appears to round correctly.\n");
00792 }
00793 else if ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero)
00794 && (T < Zero) && (StickyBit + U2 == Zero)
00795 && (Y1 < Half)) {
00796 RMult = Chopped;
00797 printf("Multiplication appears to chop.\n");
00798 }
00799 else printf("* is neither chopped nor correctly rounded.\n");
00800 if ((RMult == Rounded) && (GMult == No)) notify("Multiplication");
00801 }
00802 else printf("* is neither chopped nor correctly rounded.\n");
00803 /*=============================================*/
00804 Milestone = 45;
00805 /*=============================================*/
00806 Y2 = One + U2;
00807 Y1 = One - U2;
00808 Z = OneAndHalf + U2 + U2;
00809 X = Z / Y2;
00810 T = OneAndHalf - U2 - U2;
00811 Y = (T - U2) / Y1;
00812 Z = (Z + U2) / Y2;
00813 X = X - OneAndHalf;
00814 Y = Y - T;
00815 T = T / Y1;
00816 Z = Z - (OneAndHalf + U2);
00817 T = (U2 - OneAndHalf) + T;
00818 if (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) {
00819 X = OneAndHalf / Y2;
00820 Y = OneAndHalf - U2;
00821 Z = OneAndHalf + U2;
00822 X = X - Y;
00823 T = OneAndHalf / Y1;
00824 Y = Y / Y1;
00825 T = T - (Z + U2);
00826 Y = Y - Z;
00827 Z = Z / Y2;
00828 Y1 = (Y2 + U2) / Y2;
00829 Z = Z - OneAndHalf;
00830 Y2 = Y1 - Y2;
00831 Y1 = (F9 - U1) / F9;
00832 if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)
00833 && (Y2 == Zero) && (Y2 == Zero)
00834 && (Y1 - Half == F9 - Half )) {
00835 RDiv = Rounded;
00836 printf("Division appears to round correctly.\n");
00837 if (GDiv == No) notify("Division");
00838 }
00839 else if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero)
00840 && (Y2 < Zero) && (Y1 - Half < F9 - Half)) {
00841 RDiv = Chopped;
00842 printf("Division appears to chop.\n");
00843 }
00844 }
00845 if (RDiv == Other) printf("/ is neither chopped nor correctly rounded.\n");
00846 BInvrse = One / Radix;
00847 TstCond (Failure, (BInvrse * Radix - Half == Half),
00848 "Radix * ( 1 / Radix ) differs from 1");
00849 /*=============================================*/
00850 /*SPLIT
00851 }
00852 #include "paranoia.h"
00853 part4(){
00854 */
00855 Milestone = 50;
00856 /*=============================================*/
00857 TstCond (Failure, ((F9 + U1) - Half == Half)
00858 && ((BMinusU2 + U2 ) - One == Radix - One),
00859 "Incomplete carry-propagation in Addition");
00860 X = One - U1 * U1;
00861 Y = One + U2 * (One - U2);
00862 Z = F9 - Half;
00863 X = (X - Half) - Z;
00864 Y = Y - One;
00865 if ((X == Zero) && (Y == Zero)) {
00866 RAddSub = Chopped;
00867 printf("Add/Subtract appears to be chopped.\n");
00868 }
00869 if (GAddSub == Yes) {
00870 X = (Half + U2) * U2;
00871 Y = (Half - U2) * U2;
00872 X = One + X;
00873 Y = One + Y;
00874 X = (One + U2) - X;
00875 Y = One - Y;
00876 if ((X == Zero) && (Y == Zero)) {
00877 X = (Half + U2) * U1;
00878 Y = (Half - U2) * U1;
00879 X = One - X;
00880 Y = One - Y;
00881 X = F9 - X;
00882 Y = One - Y;
00883 if ((X == Zero) && (Y == Zero)) {
00884 RAddSub = Rounded;
00885 printf("Addition/Subtraction appears to round correctly.\n");
00886 if (GAddSub == No) notify("Add/Subtract");
00887 }
00888 else printf("Addition/Subtraction neither rounds nor chops.\n");
00889 }
00890 else printf("Addition/Subtraction neither rounds nor chops.\n");
00891 }
00892 else printf("Addition/Subtraction neither rounds nor chops.\n");
00893 S = One;
00894 X = One + Half * (One + Half);
00895 Y = (One + U2) * Half;
00896 Z = X - Y;
00897 T = Y - X;
00898 StickyBit = Z + T;
00899 if (StickyBit != Zero) {
00900 S = Zero;
00901 BadCond(Flaw, "(X - Y) + (Y - X) is non zero!\n");
00902 }
00903 StickyBit = Zero;
00904 if ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes)
00905 && (RMult == Rounded) && (RDiv == Rounded)
00906 && (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) {
00907 printf("Checking for sticky bit.\n");
00908 X = (Half + U1) * U2;
00909 Y = Half * U2;
00910 Z = One + Y;
00911 T = One + X;
00912 if ((Z - One <= Zero) && (T - One >= U2)) {
00913 Z = T + Y;
00914 Y = Z - X;
00915 if ((Z - T >= U2) && (Y - T == Zero)) {
00916 X = (Half + U1) * U1;
00917 Y = Half * U1;
00918 Z = One - Y;
00919 T = One - X;
00920 if ((Z - One == Zero) && (T - F9 == Zero)) {
00921 Z = (Half - U1) * U1;
00922 T = F9 - Z;
00923 Q = F9 - Y;
00924 if ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) {
00925 Z = (One + U2) * OneAndHalf;
00926 T = (OneAndHalf + U2) - Z + U2;
00927 X = One + Half / Radix;
00928 Y = One + Radix * U2;
00929 Z = X * Y;
00930 if (T == Zero && X + Radix * U2 - Z == Zero) {
00931 if (Radix != Two) {
00932 X = Two + U2;
00933 Y = X / Two;
00934 if ((Y - One == Zero)) StickyBit = S;
00935 }
00936 else StickyBit = S;
00937 }
00938 }
00939 }
00940 }
00941 }
00942 }
00943 if (StickyBit == One) printf("Sticky bit apparently used correctly.\n");
00944 else printf("Sticky bit used incorrectly or not at all.\n");
00945 TstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No ||
00946 RMult == Other || RDiv == Other || RAddSub == Other),
00947 "lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below");
00948 /*=============================================*/
00949 Milestone = 60;
00950 /*=============================================*/
00951 printf("\n");
00952 printf("Does Multiplication commute? ");
00953 printf("Testing on %d random pairs.\n", NoTrials);
00954 Random9 = SQRT(3.0);
00955 Random1 = Third;
00956 I = 1;
00957 do {
00958 X = Random();
00959 Y = Random();
00960 Z9 = Y * X;
00961 Z = X * Y;
00962 Z9 = Z - Z9;
00963 I = I + 1;
00964 } while ( ! ((I > NoTrials) || (Z9 != Zero)));
00965 if (I == NoTrials) {
00966 Random1 = One + Half / Three;
00967 Random2 = (U2 + U1) + One;
00968 Z = Random1 * Random2;
00969 Y = Random2 * Random1;
00970 Z9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half /
00971 Three) * ((U2 + U1) + One);
00972 }
00973 if (! ((I == NoTrials) || (Z9 == Zero)))
00974 BadCond(Defect, "X * Y == Y * X trial fails.\n");
00975 else printf(" No failures found in %d integer pairs.\n", NoTrials);
00976 /*=============================================*/
00977 Milestone = 70;
00978 /*=============================================*/
00979 printf("\nRunning test of square root(x).\n");
00980 TstCond (Failure, (Zero == SQRT(Zero))
00981 && (- Zero == SQRT(- Zero))
00982 && (One == SQRT(One)), "Square root of 0.0, -0.0 or 1.0 wrong");
00983 MinSqEr = Zero;
00984 MaxSqEr = Zero;
00985 J = Zero;
00986 X = Radix;
00987 OneUlp = U2;
00988 SqXMinX (Serious);
00989 X = BInvrse;
00990 OneUlp = BInvrse * U1;
00991 SqXMinX (Serious);
00992 X = U1;
00993 OneUlp = U1 * U1;
00994 SqXMinX (Serious);
00995 if (J != Zero) Pause();
00996 printf("Testing if sqrt(X * X) == X for %d Integers X.\n", NoTrials);
00997 J = Zero;
00998 X = Two;
00999 Y = Radix;
01000 if ((Radix != One)) do {
01001 X = Y;
01002 Y = Radix * Y;
01003 } while ( ! ((Y - X >= NoTrials)));
01004 OneUlp = X * U2;
01005 I = 1;
01006 while (I <= NoTrials) {
01007 X = X + One;
01008 SqXMinX (Defect);
01009 if (J > Zero) break;
01010 I = I + 1;
01011 }
01012 printf("Test for sqrt monotonicity.\n");
01013 I = - 1;
01014 X = BMinusU2;
01015 Y = Radix;
01016 Z = Radix + Radix * U2;
01017 NotMonot = False;
01018 Monot = False;
01019 while ( ! (NotMonot || Monot)) {
01020 I = I + 1;
01021 X = SQRT(X);
01022 Q = SQRT(Y);
01023 Z = SQRT(Z);
01024 if ((X > Q) || (Q > Z)) NotMonot = True;
01025 else {
01026 Q = FLOOR(Q + Half);
01027 if ((I > 0) || (Radix == Q * Q)) Monot = True;
01028 else if (I > 0) {
01029 if (I > 1) Monot = True;
01030 else {
01031 Y = Y * BInvrse;
01032 X = Y - U1;
01033 Z = Y + U1;
01034 }
01035 }
01036 else {
01037 Y = Q;
01038 X = Y - U2;
01039 Z = Y + U2;
01040 }
01041 }
01042 }
01043 if (Monot) printf("sqrt has passed a test for Monotonicity.\n");
01044 else {
01045 BadCond(Defect, "");
01046 printf("sqrt(X) is non-monotonic for X near %.7e .\n", Y);
01047 }
01048 /*=============================================*/
01049 /*SPLIT
01050 }
01051 #include "paranoia.h"
01052 part5(){
01053 */
01054 Milestone = 80;
01055 /*=============================================*/
01056 MinSqEr = MinSqEr + Half;
01057 MaxSqEr = MaxSqEr - Half;
01058 Y = (SQRT(One + U2) - One) / U2;
01059 SqEr = (Y - One) + U2 / Eight;
01060 if (SqEr > MaxSqEr) MaxSqEr = SqEr;
01061 SqEr = Y + U2 / Eight;
01062 if (SqEr < MinSqEr) MinSqEr = SqEr;
01063 Y = ((SQRT(F9) - U2) - (One - U2)) / U1;
01064 SqEr = Y + U1 / Eight;
01065 if (SqEr > MaxSqEr) MaxSqEr = SqEr;
01066 SqEr = (Y + One) + U1 / Eight;
01067 if (SqEr < MinSqEr) MinSqEr = SqEr;
01068 OneUlp = U2;
01069 X = OneUlp;
01070 for( Indx = 1; Indx <= 3; ++Indx) {
01071 Y = SQRT((X + U1 + X) + F9);
01072 Y = ((Y - U2) - ((One - U2) + X)) / OneUlp;
01073 Z = ((U1 - X) + F9) * Half * X * X / OneUlp;
01074 SqEr = (Y + Half) + Z;
01075 if (SqEr < MinSqEr) MinSqEr = SqEr;
01076 SqEr = (Y - Half) + Z;
01077 if (SqEr > MaxSqEr) MaxSqEr = SqEr;
01078 if (((Indx == 1) || (Indx == 3)))
01079 X = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp)));
01080 else {
01081 OneUlp = U1;
01082 X = - OneUlp;
01083 }
01084 }
01085 /*=============================================*/
01086 Milestone = 85;
01087 /*=============================================*/
01088 SqRWrng = False;
01089 Anomaly = False;
01090 RSqrt = Other; /* ~dgh */
01091 if (Radix != One) {
01092 printf("Testing whether sqrt is rounded or chopped.\n");
01093 D = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision)));
01094 /* ... == Radix^(1 + fract) if (Precision == Integer + fract. */
01095 X = D / Radix;
01096 Y = D / A1;
01097 if ((X != FLOOR(X)) || (Y != FLOOR(Y))) {
01098 Anomaly = True;
01099 }
01100 else {
01101 X = Zero;
01102 Z2 = X;
01103 Y = One;
01104 Y2 = Y;
01105 Z1 = Radix - One;
01106 FourD = Four * D;
01107 do {
01108 if (Y2 > Z2) {
01109 Q = Radix;
01110 Y1 = Y;
01111 do {
01112 X1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1);
01113 Q = Y1;
01114 Y1 = X1;
01115 } while ( ! (X1 <= Zero));
01116 if (Q <= One) {
01117 Z2 = Y2;
01118 Z = Y;
01119 }
01120 }
01121 Y = Y + Two;
01122 X = X + Eight;
01123 Y2 = Y2 + X;
01124 if (Y2 >= FourD) Y2 = Y2 - FourD;
01125 } while ( ! (Y >= D));
01126 X8 = FourD - Z2;
01127 Q = (X8 + Z * Z) / FourD;
01128 X8 = X8 / Eight;
01129 if (Q != FLOOR(Q)) Anomaly = True;
01130 else {
01131 Break = False;
01132 do {
01133 X = Z1 * Z;
01134 X = X - FLOOR(X / Radix) * Radix;
01135 if (X == One)
01136 Break = True;
01137 else
01138 Z1 = Z1 - One;
01139 } while ( ! (Break || (Z1 <= Zero)));
01140 if ((Z1 <= Zero) && (! Break)) Anomaly = True;
01141 else {
01142 if (Z1 > RadixD2) Z1 = Z1 - Radix;
01143 do {
01144 NewD();
01145 } while ( ! (U2 * D >= F9));
01146 if (D * Radix - D != W - D) Anomaly = True;
01147 else {
01148 Z2 = D;
01149 I = 0;
01150 Y = D + (One + Z) * Half;
01151 X = D + Z + Q;
01152 SR3750();
01153 Y = D + (One - Z) * Half + D;
01154 X = D - Z + D;
01155 X = X + Q + X;
01156 SR3750();
01157 NewD();
01158 if (D - Z2 != W - Z2) Anomaly = True;
01159 else {
01160 Y = (D - Z2) + (Z2 + (One - Z) * Half);
01161 X = (D - Z2) + (Z2 - Z + Q);
01162 SR3750();
01163 Y = (One + Z) * Half;
01164 X = Q;
01165 SR3750();
01166 if (I == 0) Anomaly = True;
01167 }
01168 }
01169 }
01170 }
01171 }
01172 if ((I == 0) || Anomaly) {
01173 BadCond(Failure, "Anomalous arithmetic with Integer < ");
01174 printf("Radix^Precision = %.7e\n", W);
01175 printf(" fails test whether sqrt rounds or chops.\n");
01176 SqRWrng = True;
01177 }
01178 }
01179 if (! Anomaly) {
01180 if (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) {
01181 RSqrt = Rounded;
01182 printf("Square root appears to be correctly rounded.\n");
01183 }
01184 else {
01185 if ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half)
01186 || (MinSqEr + Radix < Half)) SqRWrng = True;
01187 else {
01188 RSqrt = Chopped;
01189 printf("Square root appears to be chopped.\n");
01190 }
01191 }
01192 }
01193 if (SqRWrng) {
01194 printf("Square root is neither chopped nor correctly rounded.\n");
01195 printf("Observed errors run from %.7e ", MinSqEr - Half);
01196 printf("to %.7e ulps.\n", Half + MaxSqEr);
01197 TstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix,
01198 "sqrt gets too many last digits wrong");
01199 }
01200 /*=============================================*/
01201 Milestone = 90;
01202 /*=============================================*/
01203 Pause();
01204 printf("Testing powers Z^i for small Integers Z and i.\n");
01205 N = 0;
01206 /* ... test powers of zero. */
01207 I = 0;
01208 Z = -Zero;
01209 M = 3.0;
01210 Break = False;
01211 do {
01212 X = One;
01213 SR3980();
01214 if (I <= 10) {
01215 I = 1023;
01216 SR3980();
01217 }
01218 if (Z == MinusOne) Break = True;
01219 else {
01220 Z = MinusOne;
01221 PrintIfNPositive();
01222 N = 0;
01223 /* .. if(-1)^N is invalid, replace MinusOne by One. */
01224 I = - 4;
01225 }
01226 } while ( ! Break);
01227 PrintIfNPositive();
01228 N1 = N;
01229 N = 0;
01230 Z = A1;
01231 M = FLOOR(Two * LOG(W) / LOG(A1));
01232 Break = False;
01233 do {
01234 X = Z;
01235 I = 1;
01236 SR3980();
01237 if (Z == AInvrse) Break = True;
01238 else Z = AInvrse;
01239 } while ( ! (Break));
01240 /*=============================================*/
01241 Milestone = 100;
01242 /*=============================================*/
01243 /* Powers of Radix have been tested, */
01244 /* next try a few primes */
01245 M = NoTrials;
01246 Z = Three;
01247 do {
01248 X = Z;
01249 I = 1;
01250 SR3980();
01251 do {
01252 Z = Z + Two;
01253 } while ( Three * FLOOR(Z / Three) == Z );
01254 } while ( Z < Eight * Three );
01255 if (N > 0) {
01256 printf("Errors like this may invalidate financial calculations\n");
01257 printf("\tinvolving interest rates.\n");
01258 }
01259 PrintIfNPositive();
01260 N += N1;
01261 if (N == 0) printf("... no discrepancis found.\n");
01262 if (N > 0) Pause();
01263 else printf("\n");
01264 /*=============================================*/
01265 /*SPLIT
01266 }
01267 #include "paranoia.h"
01268 part6(){
01269 */
01270 Milestone = 110;
01271 /*=============================================*/
01272 printf("Seeking Underflow thresholds UfThold and E0.\n");
01273 D = U1;
01274 if (Precision != FLOOR(Precision)) {
01275 D = BInvrse;
01276 X = Precision;
01277 do {
01278 D = D * BInvrse;
01279 X = X - One;
01280 } while ( X > Zero);
01281 }
01282 Y = One;
01283 Z = D;
01284 /* ... D is power of 1/Radix < 1. */
01285 do {
01286 C = Y;
01287 Y = Z;
01288 Z = Y * Y;
01289 } while ((Y > Z) && (Z + Z > Z));
01290 Y = C;
01291 Z = Y * D;
01292 do {
01293 C = Y;
01294 Y = Z;
01295 Z = Y * D;
01296 } while ((Y > Z) && (Z + Z > Z));
01297 if (Radix < Two) HInvrse = Two;
01298 else HInvrse = Radix;
01299 H = One / HInvrse;
01300 /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */
01301 CInvrse = One / C;
01302 E0 = C;
01303 Z = E0 * H;
01304 /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */
01305 do {
01306 Y = E0;
01307 E0 = Z;
01308 Z = E0 * H;
01309 } while ((E0 > Z) && (Z + Z > Z));
01310 UfThold = E0;
01311 E1 = Zero;
01312 Q = Zero;
01313 E9 = U2;
01314 S = One + E9;
01315 D = C * S;
01316 if (D <= C) {
01317 E9 = Radix * U2;
01318 S = One + E9;
01319 D = C * S;
01320 if (D <= C) {
01321 BadCond(Failure, "multiplication gets too many last digits wrong.\n");
01322 Underflow = E0;
01323 Y1 = Zero;
01324 PseudoZero = Z;
01325 Pause();
01326 }
01327 }
01328 else {
01329 Underflow = D;
01330 PseudoZero = Underflow * H;
01331 UfThold = Zero;
01332 do {
01333 Y1 = Underflow;
01334 Underflow = PseudoZero;
01335 if (E1 + E1 <= E1) {
01336 Y2 = Underflow * HInvrse;
01337 E1 = FABS(Y1 - Y2);
01338 Q = Y1;
01339 if ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1;
01340 }
01341 PseudoZero = PseudoZero * H;
01342 } while ((Underflow > PseudoZero)
01343 && (PseudoZero + PseudoZero > PseudoZero));
01344 }
01345 /* Comment line 4530 .. 4560 */
01346 if (PseudoZero != Zero) {
01347 printf("\n");
01348 Z = PseudoZero;
01349 /* ... Test PseudoZero for "phoney- zero" violates */
01350 /* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero
01351 ... */
01352 if (PseudoZero <= Zero) {
01353 BadCond(Failure, "Positive expressions can underflow to an\n");
01354 printf("allegedly negative value\n");
01355 printf("PseudoZero that prints out as: %g .\n", PseudoZero);
01356 X = - PseudoZero;
01357 if (X <= Zero) {
01358 printf("But -PseudoZero, which should be\n");
01359 printf("positive, isn't; it prints out as %g .\n", X);
01360 }
01361 }
01362 else {
01363 BadCond(Flaw, "Underflow can stick at an allegedly positive\n");
01364 printf("value PseudoZero that prints out as %g .\n", PseudoZero);
01365 }
01366 TstPtUf();
01367 }
01368 /*=============================================*/
01369 Milestone = 120;
01370 /*=============================================*/
01371 if (CInvrse * Y > CInvrse * Y1) {
01372 S = H * S;
01373 E0 = Underflow;
01374 }
01375 if (! ((E1 == Zero) || (E1 == E0))) {
01376 BadCond(Defect, "");
01377 if (E1 < E0) {
01378 printf("Products underflow at a higher");
01379 printf(" threshold than differences.\n");
01380 if (PseudoZero == Zero)
01381 E0 = E1;
01382 }
01383 else {
01384 printf("Difference underflows at a higher");
01385 printf(" threshold than products.\n");
01386 }
01387 }
01388 printf("Smallest strictly positive number found is E0 = %g .\n", E0);
01389 Z = E0;
01390 TstPtUf();
01391 Underflow = E0;
01392 if (N == 1) Underflow = Y;
01393 I = 4;
01394 if (E1 == Zero) I = 3;
01395 if (UfThold == Zero) I = I - 2;
01396 UfNGrad = True;
01397 switch (I) {
01398 case 1:
01399 UfThold = Underflow;
01400 if ((CInvrse * Q) != ((CInvrse * Y) * S)) {
01401 UfThold = Y;
01402 BadCond(Failure, "Either accuracy deteriorates as numbers\n");
01403 printf("approach a threshold = %.17e\n", UfThold);;
01404 printf(" coming down from %.17e\n", C);
01405 printf(" or else multiplication gets too many last digits wrong.\n");
01406 }
01407 Pause();
01408 break;
01409
01410 case 2:
01411 BadCond(Failure, "Underflow confuses Comparison, which alleges that\n");
01412 printf("Q == Y while denying that |Q - Y| == 0; these values\n");
01413 printf("print out as Q = %.17e, Y = %.17e .\n", Q, Y2);
01414 printf ("|Q - Y| = %.17e .\n" , FABS(Q - Y2));
01415 UfThold = Q;
01416 break;
01417
01418 case 3:
01419 X = X;
01420 break;
01421
01422 case 4:
01423 if ((Q == UfThold) && (E1 == E0)
01424 && (FABS( UfThold - E1 / E9) <= E1)) {
01425 UfNGrad = False;
01426 printf("Underflow is gradual; it incurs Absolute Error =\n");
01427 printf("(roundoff in UfThold) < E0.\n");
01428 Y = E0 * CInvrse;
01429 Y = Y * (OneAndHalf + U2);
01430 X = CInvrse * (One + U2);
01431 Y = Y / X;
01432 IEEE = (Y == E0);
01433 }
01434 }
01435 if (UfNGrad) {
01436 printf("\n");
01437 sigsave = sigfpe;
01438 if (setjmp(ovfl_buf)) {
01439 printf("Underflow / UfThold failed!\n");
01440 R = H + H;
01441 }
01442 else R = SQRT(Underflow / UfThold);
01443 sigsave = 0;
01444 if (R <= H) {
01445 Z = R * UfThold;
01446 X = Z * (One + R * H * (One + H));
01447 }
01448 else {
01449 Z = UfThold;
01450 X = Z * (One + H * H * (One + H));
01451 }
01452 if (! ((X == Z) || (X - Z != Zero))) {
01453 BadCond(Flaw, "");
01454 printf("X = %.17e\n\tis not equal to Z = %.17e .\n", X, Z);
01455 Z9 = X - Z;
01456 printf("yet X - Z yields %.17e .\n", Z9);
01457 printf(" Should this NOT signal Underflow, ");
01458 printf("this is a SERIOUS DEFECT\nthat causes ");
01459 printf("confusion when innocent statements like\n");;
01460 printf(" if (X == Z) ... else");
01461 printf(" ... (f(X) - f(Z)) / (X - Z) ...\n");
01462 printf("encounter Division by Zero although actually\n");
01463 sigsave = sigfpe;
01464 if (setjmp(ovfl_buf)) printf("X / Z fails!\n");
01465 else printf("X / Z = 1 + %g .\n", (X / Z - Half) - Half);
01466 sigsave = 0;
01467 }
01468 }
01469 printf("The Underflow threshold is %.17e, %s\n", UfThold,
01470 " below which");
01471 printf("calculation may suffer larger Relative error than ");
01472 printf("merely roundoff.\n");
01473 Y2 = U1 * U1;
01474 Y = Y2 * Y2;
01475 Y2 = Y * U1;
01476 if (Y2 <= UfThold) {
01477 if (Y > E0) {
01478 BadCond(Defect, "");
01479 I = 5;
01480 }
01481 else {
01482 BadCond(Serious, "");
01483 I = 4;
01484 }
01485 printf("Range is too narrow; U1^%d Underflows.\n", I);
01486 }
01487 /*=============================================*/
01488 /*SPLIT
01489 }
01490 #include "paranoia.h"
01491 part7(){
01492 */
01493 Milestone = 130;
01494 /*=============================================*/
01495 Y = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty;
01496 Y2 = Y + Y;
01497 printf("Since underflow occurs below the threshold\n");
01498 printf("UfThold = (%.17e) ^ (%.17e)\nonly underflow ", HInvrse, Y);
01499 printf("should afflict the expression\n\t(%.17e) ^ (%.17e);\n", HInvrse, Y);
01500 V9 = POW(HInvrse, Y2);
01501 printf("actually calculating yields: %.17e .\n", V9);
01502 if (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) {
01503 BadCond(Serious, "this is not between 0 and underflow\n");
01504 printf(" threshold = %.17e .\n", UfThold);
01505 }
01506 else if (! (V9 > UfThold * (One + E9)))
01507 printf("This computed value is O.K.\n");
01508 else {
01509 BadCond(Defect, "this is not between 0 and underflow\n");
01510 printf(" threshold = %.17e .\n", UfThold);
01511 }
01512 /*=============================================*/
01513 Milestone = 140;
01514 /*=============================================*/
01515 printf("\n");
01516 /* ...calculate Exp2 == exp(2) == 7.389056099... */
01517 X = Zero;
01518 I = 2;
01519 Y = Two * Three;
01520 Q = Zero;
01521 N = 0;
01522 do {
01523 Z = X;
01524 I = I + 1;
01525 Y = Y / (I + I);
01526 R = Y + Q;
01527 X = Z + R;
01528 Q = (Z - X) + R;
01529 } while(X > Z);
01530 Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo);
01531 X = Z * Z;
01532 Exp2 = X * X;
01533 X = F9;
01534 Y = X - U1;
01535 printf("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n",
01536 Exp2);
01537 for(I = 1;;) {
01538 Z = X - BInvrse;
01539 Z = (X + One) / (Z - (One - BInvrse));
01540 Q = POW(X, Z) - Exp2;
01541 if (FABS(Q) > TwoForty * U2) {
01542 N = 1;
01543 V9 = (X - BInvrse) - (One - BInvrse);
01544 BadCond(Defect, "Calculated");
01545 printf(" %.17e for\n", POW(X,Z));
01546 printf("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z);
01547 printf("\tdiffers from correct value by %.17e .\n", Q);
01548 printf("\tThis much error may spoil financial\n");
01549 printf("\tcalculations involving tiny interest rates.\n");
01550 break;
01551 }
01552 else {
01553 Z = (Y - X) * Two + Y;
01554 X = Y;
01555 Y = Z;
01556 Z = One + (X - F9)*(X - F9);
01557 if (Z > One && I < NoTrials) I++;
01558 else {
01559 if (X > One) {
01560 if (N == 0)
01561 printf("Accuracy seems adequate.\n");
01562 break;
01563 }
01564 else {
01565 X = One + U2;
01566 Y = U2 + U2;
01567 Y += X;
01568 I = 1;
01569 }
01570 }
01571 }
01572 }
01573 /*=============================================*/
01574 Milestone = 150;
01575 /*=============================================*/
01576 printf("Testing powers Z^Q at four nearly extreme values.\n");
01577 N = 0;
01578 Z = A1;
01579 Q = FLOOR(Half - LOG(C) / LOG(A1));
01580 Break = False;
01581 do {
01582 X = CInvrse;
01583 Y = POW(Z, Q);
01584 IsYeqX();
01585 Q = - Q;
01586 X = C;
01587 Y = POW(Z, Q);
01588 IsYeqX();
01589 if (Z < One) Break = True;
01590 else Z = AInvrse;
01591 } while ( ! (Break));
01592 PrintIfNPositive();
01593 if (N == 0) printf(" ... no discrepancies found.\n");
01594 printf("\n");
01595
01596 /*=============================================*/
01597 Milestone = 160;
01598 /*=============================================*/
01599 Pause();
01600 printf("Searching for Overflow threshold:\n");
01601 printf("This may generate an error.\n");
01602 Y = - CInvrse;
01603 V9 = HInvrse * Y;
01604 sigsave = sigfpe;
01605 if (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; }
01606 do {
01607 V = Y;
01608 Y = V9;
01609 V9 = HInvrse * Y;
01610 } while(V9 < Y);
01611 I = 1;
01612 overflow:
01613 sigsave = 0;
01614 Z = V9;
01615 printf("Can `Z = -Y' overflow?\n");
01616 printf("Trying it on Y = %.17e .\n", Y);
01617 V9 = - Y;
01618 V0 = V9;
01619 if (V - Y == V + V0) printf("Seems O.K.\n");
01620 else {
01621 printf("finds a ");
01622 BadCond(Flaw, "-(-Y) differs from Y.\n");
01623 }
01624 if (Z != Y) {
01625 BadCond(Serious, "");
01626 printf("overflow past %.17e\n\tshrinks to %.17e .\n", Y, Z);
01627 }
01628 if (I) {
01629 Y = V * (HInvrse * U2 - HInvrse);
01630 Z = Y + ((One - HInvrse) * U2) * V;
01631 if (Z < V0) Y = Z;
01632 if (Y < V0) V = Y;
01633 if (V0 - V < V0) V = V0;
01634 }
01635 else {
01636 V = Y * (HInvrse * U2 - HInvrse);
01637 V = V + ((One - HInvrse) * U2) * Y;
01638 }
01639 printf("Overflow threshold is V = %.17e .\n", V);
01640 if (I) printf("Overflow saturates at V0 = %.17e .\n", V0);
01641 else printf("There is no saturation value because the system traps on overflow.\n");
01642 V9 = V * One;
01643 printf("No Overflow should be signaled for V * 1 = %.17e\n", V9);
01644 V9 = V / One;
01645 printf(" nor for V / 1 = %.17e .\n", V9);
01646 printf("Any overflow signal separating this * from the one\n");
01647 printf("above is a DEFECT.\n");
01648 /*=============================================*/
01649 Milestone = 170;
01650 /*=============================================*/
01651 if (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) {
01652 BadCond(Failure, "Comparisons involving ");
01653 printf("+-%g, +-%g\nand +-%g are confused by Overflow.",
01654 V, V0, UfThold);
01655 }
01656 /*=============================================*/
01657 Milestone = 175;
01658 /*=============================================*/
01659 printf("\n");
01660 for(Indx = 1; Indx <= 3; ++Indx) {
01661 switch (Indx) {
01662 case 1: Z = UfThold; break;
01663 case 2: Z = E0; break;
01664 case 3: Z = PseudoZero; break;
01665 }
01666 if (Z != Zero) {
01667 V9 = SQRT(Z);
01668 Y = V9 * V9;
01669 if (Y / (One - Radix * E9) < Z
01670 || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */
01671 if (V9 > U1) BadCond(Serious, "");
01672 else BadCond(Defect, "");
01673 printf("Comparison alleges that what prints as Z = %.17e\n", Z);
01674 printf(" is too far from sqrt(Z) ^ 2 = %.17e .\n", Y);
01675 }
01676 }
01677 }
01678 /*=============================================*/
01679 Milestone = 180;
01680 /*=============================================*/
01681 for(Indx = 1; Indx <= 2; ++Indx) {
01682 if (Indx == 1) Z = V;
01683 else Z = V0;
01684 V9 = SQRT(Z);
01685 X = (One - Radix * E9) * V9;
01686 V9 = V9 * X;
01687 if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) {
01688 Y = V9;
01689 if (X < W) BadCond(Serious, "");
01690 else BadCond(Defect, "");
01691 printf("Comparison alleges that Z = %17e\n", Z);
01692 printf(" is too far from sqrt(Z) ^ 2 (%.17e) .\n", Y);
01693 }
01694 }
01695 /*=============================================*/
01696 /*SPLIT
01697 }
01698 #include "paranoia.h"
01699 part8(){
01700 */
01701 Milestone = 190;
01702 /*=============================================*/
01703 Pause();
01704 X = UfThold * V;
01705 Y = Radix * Radix;
01706 if (X*Y < One || X > Y) {
01707 if (X * Y < U1 || X > Y/U1) BadCond(Defect, "Badly");
01708 else BadCond(Flaw, "");
01709
01710 printf(" unbalanced range; UfThold * V = %.17e\n\t%s\n",
01711 X, "is too far from 1.\n");
01712 }
01713 /*=============================================*/
01714 Milestone = 200;
01715 /*=============================================*/
01716 for (Indx = 1; Indx <= 5; ++Indx) {
01717 X = F9;
01718 switch (Indx) {
01719 case 2: X = One + U2; break;
01720 case 3: X = V; break;
01721 case 4: X = UfThold; break;
01722 case 5: X = Radix;
01723 }
01724 Y = X;
01725 sigsave = sigfpe;
01726 if (setjmp(ovfl_buf))
01727 printf(" X / X traps when X = %g\n", X);
01728 else {
01729 V9 = (Y / X - Half) - Half;
01730 if (V9 == Zero) continue;
01731 if (V9 == - U1 && Indx < 5) BadCond(Flaw, "");
01732 else BadCond(Serious, "");
01733 printf(" X / X differs from 1 when X = %.17e\n", X);
01734 printf(" instead, X / X - 1/2 - 1/2 = %.17e .\n", V9);
01735 }
01736 sigsave = 0;
01737 }
01738 /*=============================================*/
01739 Milestone = 210;
01740 /*=============================================*/
01741 MyZero = Zero;
01742 printf("\n");
01743 printf("What message and/or values does Division by Zero produce?\n") ;
01744 #ifndef NOPAUSE
01745 printf("This can interupt your program. You can ");
01746 printf("skip this part if you wish.\n");
01747 printf("Do you wish to compute 1 / 0? ");
01748 fflush(stdout);
01749 read (KEYBOARD, ch, 8);
01750 if ((ch[0] == 'Y') || (ch[0] == 'y')) {
01751 #endif
01752 sigsave = sigfpe;
01753 printf(" Trying to compute 1 / 0 produces ...");
01754 if (!setjmp(ovfl_buf)) printf(" %.7e .\n", One / MyZero);
01755 sigsave = 0;
01756 #ifndef NOPAUSE
01757 }
01758 else printf("O.K.\n");
01759 printf("\nDo you wish to compute 0 / 0? ");
01760 fflush(stdout);
01761 read (KEYBOARD, ch, 80);
01762 if ((ch[0] == 'Y') || (ch[0] == 'y')) {
01763 #endif
01764 sigsave = sigfpe;
01765 printf("\n Trying to compute 0 / 0 produces ...");
01766 if (!setjmp(ovfl_buf)) printf(" %.7e .\n", Zero / MyZero);
01767 sigsave = 0;
01768 #ifndef NOPAUSE
01769 }
01770 else printf("O.K.\n");
01771 #endif
01772 /*=============================================*/
01773 Milestone = 220;
01774 /*=============================================*/
01775 Pause();
01776 printf("\n");
01777 {
01778 static char *msg[] = {
01779 "FAILUREs encountered =",
01780 "SERIOUS DEFECTs discovered =",
01781 "DEFECTs discovered =",
01782 "FLAWs discovered =" };
01783 int i;
01784 for(i = 0; i < 4; i++) if (ErrCnt[i])
01785 printf("The number of %-29s %d.\n",
01786 msg[i], ErrCnt[i]);
01787 }
01788 printf("\n");
01789 if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect]
01790 + ErrCnt[Flaw]) > 0) {
01791 if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[
01792 Defect] == 0) && (ErrCnt[Flaw] > 0)) {
01793 printf("The arithmetic diagnosed seems ");
01794 printf("Satisfactory though flawed.\n");
01795 }
01796 if ((ErrCnt[Failure] + ErrCnt[Serious] == 0)
01797 && ( ErrCnt[Defect] > 0)) {
01798 printf("The arithmetic diagnosed may be Acceptable\n");
01799 printf("despite inconvenient Defects.\n");
01800 }
01801 if ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) {
01802 printf("The arithmetic diagnosed has ");
01803 printf("unacceptable Serious Defects.\n");
01804 }
01805 if (ErrCnt[Failure] > 0) {
01806 printf("Potentially fatal FAILURE may have spoiled this");
01807 printf(" program's subsequent diagnoses.\n");
01808 }
01809 }
01810 else {
01811 printf("No failures, defects nor flaws have been discovered.\n");
01812 if (! ((RMult == Rounded) && (RDiv == Rounded)
01813 && (RAddSub == Rounded) && (RSqrt == Rounded)))
01814 printf("The arithmetic diagnosed seems Satisfactory.\n");
01815 else {
01816 if (StickyBit >= One &&
01817 (Radix - Two) * (Radix - Nine - One) == Zero) {
01818 printf("Rounding appears to conform to ");
01819 printf("the proposed IEEE standard P");
01820 if ((Radix == Two) &&
01821 ((Precision - Four * Three * Two) *
01822 ( Precision - TwentySeven -
01823 TwentySeven + One) == Zero))
01824 printf("754");
01825 else printf("854");
01826 if (IEEE) printf(".\n");
01827 else {
01828 printf(",\nexcept for possibly Double Rounding");
01829 printf(" during Gradual Underflow.\n");
01830 }
01831 }
01832 printf("The arithmetic diagnosed appears to be Excellent!\n");
01833 }
01834 }
01835 if (fpecount)
01836 printf("\nA total of %d floating point exceptions were registered.\n",
01837 fpecount);
01838 printf("END OF TEST.\n");
01839 return 0;
01840 }
|
Here is the call graph for this function:

|
|
Definition at line 2068 of file paranoia.c. Referenced by Characteristics(), Heading(), History(), and Instructions(). 02070 { while(*s) printf("%s\n", *s++); }
|
Here is the call graph for this function:

|
|
Definition at line 1928 of file paranoia.c. References D, FLOOR, Half, Q, Radix, Two, X, Z, and Z1. Referenced by main(). 01929 {
01930 X = Z1 * Q;
01931 X = FLOOR(Half - X / Radix) * Radix + X;
01932 Q = (Q - X * Z) / Radix + X * X * (D / Radix);
01933 Z = Z - Two * X * D;
01934 if (Z <= Zero) {
01935 Z = - Z;
01936 Z1 = - Z1;
01937 }
01938 D = Radix * D;
01939 }
|
|
|
Definition at line 2057 of file paranoia.c. Referenced by main(). 02059 {
02060 printf("%s test appears to be inconsistent...\n", s);
02061 printf(" PLEASE NOTIFY KARPINKSI!\n");
02062 }
|
Here is the call graph for this function:

|
|
Definition at line 1854 of file paranoia.c. References ch, fflush(), KEYBOARD, Milestone, PageNo, printf(), read(), and stdout. Referenced by main(), and TstPtUf(). 01855 {
01856 #ifndef NOPAUSE
01857 char ch[8];
01858
01859 printf("\nTo continue, press RETURN");
01860 fflush(stdout);
01861 read(KEYBOARD, ch, 8);
01862 #endif
01863 printf("\nDiagnosis resumes after milestone Number %d", Milestone);
01864 printf(" Page: %d\n\n", PageNo);
01865 ++Milestone;
01866 ++PageNo;
01867 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2176 of file paranoia.c. References exp(), frexp(), i, ldexp(), log(), modf(), x, and y. 02178 {
02179 extern double exp(), frexp(), ldexp(), log(), modf();
02180 double xy, ye;
02181 long i;
02182 int ex, ey = 0, flip = 0;
02183
02184 if (!y) return 1.0;
02185
02186 if ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x));
02187
02188 if (y < 0.) { y = -y; flip = 1; }
02189 y = modf(y, &ye);
02190 if (y) xy = exp(y * log(x));
02191 else xy = 1.0;
02192 /* next several lines assume >= 32 bit integers */
02193 x = frexp(x, &ex);
02194 if (i = ye) for(;;) {
02195 if (i & 1) { xy *= x; ey += ex; }
02196 if (!(i >>= 1)) break;
02197 x *= x;
02198 ex *= 2;
02199 if (x < .5) { x *= 2.; ex -= 1; }
02200 }
02201 if (flip) { xy = 1. / xy; ey = -ey; }
02202 return ldexp(xy, ey);
02203 }
|
Here is the call graph for this function:

|
|
Referenced by idSplineList::calcSpline(), R_InitFogTable(), R_SetColorMappings(), Texture_InitPalette(), and Texture_LoadTGATexture(). |
|
|
Definition at line 1992 of file paranoia.c. Referenced by main().
|
Here is the call graph for this function:

|
|
Definition at line 1893 of file paranoia.c. References FLOAT, FLOOR, Random1, X, and Y. Referenced by main(). 01894 {
01895 FLOAT X, Y;
01896
01897 X = Random1 + Random9;
01898 Y = X * X;
01899 Y = Y * Y;
01900 X = X * Y;
01901 Y = X - FLOOR(X);
01902 Random1 = Y + X * 0.000005;
01903 return(Random1);
01904 }
|
|
|
Definition at line 327 of file paranoia.c. References abort(), fflush(), fpecount, longjmp(), ovfl_buf, printf(), SIGFPE, signal, sigsave, and stdout. Referenced by main(). 00328 {
00329 fpecount++;
00330 printf("\n* * * FLOATING-POINT ERROR * * *\n");
00331 fflush(stdout);
00332 if (sigsave) {
00333 #ifndef NOSIGNAL
00334 signal(SIGFPE, sigsave);
00335 #endif
00336 sigsave = 0;
00337 longjmp(ovfl_buf, 1);
00338 }
00339 abort();
00340 }
|
Here is the call graph for this function:

|
|
Definition at line 1848 of file paranoia.c. 01850 { return X >= 0. ? 1.0 : -1.0; }
|
|
|
|
|
|
|
Definition at line 1908 of file paranoia.c. References BadCond(), FLOAT, J, MaxSqEr, MinSqEr, OneUlp, printf(), SqEr, SQRT, and X. Referenced by main(). 01910 {
01911 FLOAT XA, XB;
01912
01913 XB = X * BInvrse;
01914 XA = X - XB;
01915 SqEr = ((SQRT(X * X) - XB) - XA) / OneUlp;
01916 if (SqEr != Zero) {
01917 if (SqEr < MinSqEr) MinSqEr = SqEr;
01918 if (SqEr > MaxSqEr) MaxSqEr = SqEr;
01919 J = J + 1.0;
01920 BadCond(ErrKind, "\n");
01921 printf("sqrt( %.17e) - %.17e = %.17e\n", X * X, X, OneUlp * SqEr);
01922 printf("\tinstead of correct value 0 .\n");
01923 }
01924 }
|
Here is the call graph for this function:

|
|
Definition at line 1943 of file paranoia.c. References D, Half, I, MaxSqEr, MinSqEr, Radix, SqEr, SQRT, W, X, X2, X8, Y, Y2, and Z2. Referenced by main(). 01944 {
01945 if (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) {
01946 I = I + 1;
01947 X2 = SQRT(X * D);
01948 Y2 = (X2 - Z2) - (Y - Z2);
01949 X2 = X8 / (Y - Half);
01950 X2 = X2 - Half * X2 * X2;
01951 SqEr = (Y2 + Half) + (Half - X2);
01952 if (SqEr < MinSqEr) MinSqEr = SqEr;
01953 SqEr = Y2 - X2;
01954 if (SqEr > MaxSqEr) MaxSqEr = SqEr;
01955 }
01956 }
|
|
|
Definition at line 1979 of file paranoia.c. References I, IsYeqX(), POW, Q, X, Y, and Z. Referenced by main(). 01980 {
01981 do {
01982 Q = (FLOAT) I;
01983 Y = POW(Z, Q);
01984 IsYeqX();
01985 if (++I > M) break;
01986 X = Z * X;
01987 } while ( X < W );
01988 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1871 of file paranoia.c. References BadCond(), printf(), and T. Referenced by main().
|
Here is the call graph for this function:

|
|
Definition at line 1999 of file paranoia.c. References BadCond(), Defect, ErrCnt, FABS, N, One, ovfl_buf, Pause(), printf(), Q9, Radix, Random1, Random2, setjmp(), sigsave, Two, V9, and Z. Referenced by main(). 02000 {
02001 N = 0;
02002 if (Z != Zero) {
02003 printf("Since comparison denies Z = 0, evaluating ");
02004 printf("(Z + Z) / Z should be safe.\n");
02005 sigsave = sigfpe;
02006 if (setjmp(ovfl_buf)) goto very_serious;
02007 Q9 = (Z + Z) / Z;
02008 printf("What the machine gets for (Z + Z) / Z is %.17e .\n",
02009 Q9);
02010 if (FABS(Q9 - Two) < Radix * U2) {
02011 printf("This is O.K., provided Over/Underflow");
02012 printf(" has NOT just been signaled.\n");
02013 }
02014 else {
02015 if ((Q9 < One) || (Q9 > Two)) {
02016 very_serious:
02017 N = 1;
02018 ErrCnt [Serious] = ErrCnt [Serious] + 1;
02019 printf("This is a VERY SERIOUS DEFECT!\n");
02020 }
02021 else {
02022 N = 1;
02023 ErrCnt [Defect] = ErrCnt [Defect] + 1;
02024 printf("This is a DEFECT!\n");
02025 }
02026 }
02027 sigsave = 0;
02028 V9 = Z * One;
02029 Random1 = V9;
02030 V9 = One * Z;
02031 Random2 = V9;
02032 V9 = Z / One;
02033 if ((Z == Random1) && (Z == Random2) && (Z == V9)) {
02034 if (N > 0) Pause();
02035 }
02036 else {
02037 N = 1;
02038 BadCond(Defect, "What prints as Z = ");
02039 printf("%.17e\n\tcompares different from ", Z);
02040 if (Z != Random1) printf("Z * 1 = %.17e ", Random1);
02041 if (! ((Z == Random2)
02042 || (Random2 == Random1)))
02043 printf("1 * Z == %g\n", Random2);
02044 if (! (Z == V9)) printf("Z / 1 = %.17e\n", V9);
02045 if (Random2 != Random1) {
02046 ErrCnt [Defect] = ErrCnt [Defect] + 1;
02047 BadCond(Defect, "Multiplication does not commute!\n");
02048 printf("\tComparison alleges that 1 * Z = %.17e\n",
02049 Random2);
02050 printf("\tdiffers from Z * 1 = %.17e\n", Random1);
02051 }
02052 Pause();
02053 }
02054 }
02055 }
|
Here is the call graph for this function:

|
|
Definition at line 291 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 291 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 247 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 247 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 292 of file paranoia.c. |
|
|
|
Definition at line 292 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 293 of file paranoia.c. |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(), and ParseChunk(). |
|
|
Definition at line 294 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 294 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 294 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 295 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 258 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 312 of file paranoia.c. |
|
|
Definition at line 294 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 297 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 297 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 257 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 256 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 293 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 313 of file paranoia.c. |
|
|
Definition at line 317 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 317 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 317 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 298 of file paranoia.c. |
|
|
Definition at line 252 of file paranoia.c. |
|
|
Definition at line 298 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 299 of file paranoia.c. |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 289 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 300 of file paranoia.c. |
|
|
Definition at line 316 of file paranoia.c. Referenced by alloc_funny_pointers(), Face_MoveTexture_BrushPrimit(), main(), make_funny_pointers(), RotateFaceTexture_BrushPrimit(), and set_wraparound_pointers(). |
|
|
Definition at line 295 of file paranoia.c. |
|
|
Definition at line 314 of file paranoia.c. |
|
|
Definition at line 294 of file paranoia.c. |
|
|
Definition at line 263 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 301 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 316 of file paranoia.c. Referenced by IsYeqX(), main(), PrintIfNPositive(), and TstPtUf(). |
|
|
Definition at line 316 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 259 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 266 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 253 of file paranoia.c. |
|
|
Definition at line 264 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 306 of file paranoia.c. |
|
|
Definition at line 241 of file paranoia.c. |
|
|
Definition at line 315 of file paranoia.c. |
|
|
Definition at line 302 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 311 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 303 of file paranoia.c. |
|
|
Definition at line 303 of file paranoia.c. Referenced by TstPtUf(). |
|
|
Definition at line 304 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 318 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 247 of file paranoia.c. |
|
|
Definition at line 247 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 309 of file paranoia.c. |
|
|
Definition at line 310 of file paranoia.c. |
|
|
Definition at line 304 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 318 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 318 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 318 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 305 of file paranoia.c. |
|
|
Definition at line 243 of file paranoia.c. |
|
|
Definition at line 295 of file paranoia.c. |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 300 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 305 of file paranoia.c. |
|
|
Definition at line 296 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 261 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 255 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 260 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 254 of file paranoia.c. |
|
|
Definition at line 262 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 306 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 306 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 319 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 306 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 305 of file paranoia.c. Referenced by main(). |
|
|
Referenced by asdl_gen(), branch(), definelab(), dumptree(), jump(), labelnode(), listnodes(), main(), requate(), and visit(). |
|
|
Definition at line 307 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 307 of file paranoia.c. |
|
|
Definition at line 308 of file paranoia.c. |
|
|
Definition at line 309 of file paranoia.c. Referenced by ComputeBest2DVector(), IsYeqX(), main(), NewD(), Random(), Sign(), SqXMinX(), SR3750(), and SR3980(). |
|
|
Definition at line 309 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 309 of file paranoia.c. Referenced by SR3750(). |
|
|
Definition at line 309 of file paranoia.c. |
|
|
Definition at line 310 of file paranoia.c. Referenced by ComputeBest2DVector(), IsYeqX(), main(), Random(), SR3750(), and SR3980(). |
|
|
Definition at line 310 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 310 of file paranoia.c. |
|
|
Definition at line 311 of file paranoia.c. Referenced by IsYeqX(), main(), NewD(), SR3980(), and TstPtUf(). |
|
|
Definition at line 311 of file paranoia.c. |
|
|
Definition at line 311 of file paranoia.c. |
|
|
Definition at line 311 of file paranoia.c. Referenced by main(). |
|
|
Definition at line 251 of file paranoia.c. |
1.3.9.1