Changeset 70e9af9 in rtems
- Timestamp:
- 11/09/99 22:45:35 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 3d67661
- Parents:
- e18ba7f
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/tests/samples/paranoia/paranoia.c
re18ba7f r70e9af9 274 274 FLOAT Third; 275 275 FLOAT F6, F9; 276 FLOAT H , HInvrse;276 FLOAT HVar, HInvrse; 277 277 int I; 278 278 FLOAT StickyBit, J; … … 284 284 FLOAT OneUlp, UfThold, U1, U2; 285 285 FLOAT V, V0, V9; 286 FLOAT W ;286 FLOAT WVar; 287 287 FLOAT X, X1, X2, X8, Random1; 288 288 FLOAT Y, Y1, Y2, Random2; … … 446 446 } 447 447 printf ("Searching for Radix and Precision.\n"); 448 W = One;448 WVar = One; 449 449 do { 450 W = W + W;451 Y = W + One;452 Z = Y - W ;450 WVar = WVar + WVar; 451 Y = WVar + One; 452 Z = Y - WVar; 453 453 Y = Z - One; 454 454 } 455 455 while (MinusOne + FABS (Y) < Zero); 456 /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/456 /*.. now WVar is just big enough that |((WVar+1)-WVar)-1| >= 1 ...*/ 457 457 Precision = Zero; 458 458 Y = One; 459 459 do { 460 Radix = W + Y;460 Radix = WVar + Y; 461 461 Y = Y + Y; 462 Radix = Radix - W ;462 Radix = Radix - WVar; 463 463 } 464 464 while (Radix == Zero); … … 467 467 printf ("Radix = %f .\n", Radix); 468 468 if (Radix != 1) { 469 W = One;469 WVar = One; 470 470 do { 471 471 Precision = Precision + One; 472 W = W* Radix;473 Y = W + One;474 } 475 while ((Y - W ) == One);476 } 477 /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W== 1472 WVar = WVar * Radix; 473 Y = WVar + One; 474 } 475 while ((Y - WVar) == One); 476 } 477 /*... now WVar == Radix^Precision is barely too big to satisfy (WVar+1)-WVar == 1 478 478 ...*/ 479 U1 = One / W ;479 U1 = One / WVar; 480 480 U2 = Radix * U1; 481 481 printf ("Closest relative separation found is U1 = %.7e .\n\n", U1); … … 529 529 else 530 530 printf ("gets better closest relative separation U1 = %.7e .\n", U1); 531 W = One / U1;531 WVar = One / U1; 532 532 F9 = (Half - U1) + Half; 533 533 Radix = FLOOR (0.01 + U2 / U1); … … 653 653 /*=============================================*/ 654 654 if (Radix >= Two) { 655 X = W / (Radix * Radix);655 X = WVar / (Radix * Radix); 656 656 Y = X + One; 657 657 Z = Y - X; … … 1195 1195 } 1196 1196 while (!(U2 * D >= F9)); 1197 if (D * Radix - D != W - D)1197 if (D * Radix - D != WVar - D) 1198 1198 Anomaly = True; 1199 1199 else { … … 1208 1208 SR3750 (); 1209 1209 NewD (); 1210 if (D - Z2 != W - Z2)1210 if (D - Z2 != WVar - Z2) 1211 1211 Anomaly = True; 1212 1212 else { … … 1226 1226 if ((I == 0) || Anomaly) { 1227 1227 BadCond (Failure, "Anomalous arithmetic with Integer < "); 1228 printf ("Radix^Precision = %.7e\n", W );1228 printf ("Radix^Precision = %.7e\n", WVar); 1229 1229 printf (" fails test whether sqrt rounds or chops.\n"); 1230 1230 SqRWrng = True; … … 1283 1283 N = 0; 1284 1284 Z = A1; 1285 M = (int) FLOOR (Two * LOG (W ) / LOG (A1));1285 M = (int) FLOOR (Two * LOG (WVar) / LOG (A1)); 1286 1286 Break = False; 1287 1287 do { … … 1359 1359 else 1360 1360 HInvrse = Radix; 1361 H = One / HInvrse;1362 /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */1361 HVar = One / HInvrse; 1362 /* ... 1/HInvrse == HVar == Min(1/Radix, 1/2) */ 1363 1363 CInvrse = One / C; 1364 1364 E0 = C; 1365 Z = E0 * H ;1365 Z = E0 * HVar; 1366 1366 /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ 1367 1367 do { 1368 1368 Y = E0; 1369 1369 E0 = Z; 1370 Z = E0 * H ;1370 Z = E0 * HVar; 1371 1371 } 1372 1372 while ((E0 > Z) && (Z + Z > Z)); … … 1390 1390 } else { 1391 1391 Underflow = D; 1392 PseudoZero = Underflow * H ;1392 PseudoZero = Underflow * HVar; 1393 1393 UfThold = Zero; 1394 1394 do { … … 1402 1402 UfThold = Y1; 1403 1403 } 1404 PseudoZero = PseudoZero * H ;1404 PseudoZero = PseudoZero * HVar; 1405 1405 } 1406 1406 while ((Underflow > PseudoZero) … … 1433 1433 /*=============================================*/ 1434 1434 if (CInvrse * Y > CInvrse * Y1) { 1435 S = H * S;1435 S = HVar * S; 1436 1436 E0 = Underflow; 1437 1437 } … … 1503 1503 if (setjmp (ovfl_buf)) { 1504 1504 printf ("Underflow / UfThold failed!\n"); 1505 R = H + H;1505 R = HVar + HVar; 1506 1506 } else 1507 1507 R = SQRT (Underflow / UfThold); 1508 1508 sigsave = 0; 1509 if (R <= H ) {1509 if (R <= HVar) { 1510 1510 Z = R * UfThold; 1511 X = Z * (One + R * H * (One + H));1511 X = Z * (One + R * HVar * (One + HVar)); 1512 1512 } else { 1513 1513 Z = UfThold; 1514 X = Z * (One + H * H * (One + H));1514 X = Z * (One + HVar * HVar * (One + HVar)); 1515 1515 } 1516 1516 if (!((X == Z) || (X - Z != Zero))) { … … 1780 1780 if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { 1781 1781 Y = V9; 1782 if (X < W )1782 if (X < WVar) 1783 1783 BadCond (Serious, ""); 1784 1784 else … … 2067 2067 SR3750 () 2068 2068 { 2069 if (!((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) {2069 if (!((X - Radix < Z2 - Radix) || (X - Z2 > WVar - Z2))) { 2070 2070 I = I + 1; 2071 2071 X2 = SQRT (X * D); … … 2112 2112 X = Z * X; 2113 2113 } 2114 while (X < W );2114 while (X < WVar); 2115 2115 } 2116 2116 -
testsuites/samples/paranoia/paranoia.c
re18ba7f r70e9af9 274 274 FLOAT Third; 275 275 FLOAT F6, F9; 276 FLOAT H , HInvrse;276 FLOAT HVar, HInvrse; 277 277 int I; 278 278 FLOAT StickyBit, J; … … 284 284 FLOAT OneUlp, UfThold, U1, U2; 285 285 FLOAT V, V0, V9; 286 FLOAT W ;286 FLOAT WVar; 287 287 FLOAT X, X1, X2, X8, Random1; 288 288 FLOAT Y, Y1, Y2, Random2; … … 446 446 } 447 447 printf ("Searching for Radix and Precision.\n"); 448 W = One;448 WVar = One; 449 449 do { 450 W = W + W;451 Y = W + One;452 Z = Y - W ;450 WVar = WVar + WVar; 451 Y = WVar + One; 452 Z = Y - WVar; 453 453 Y = Z - One; 454 454 } 455 455 while (MinusOne + FABS (Y) < Zero); 456 /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/456 /*.. now WVar is just big enough that |((WVar+1)-WVar)-1| >= 1 ...*/ 457 457 Precision = Zero; 458 458 Y = One; 459 459 do { 460 Radix = W + Y;460 Radix = WVar + Y; 461 461 Y = Y + Y; 462 Radix = Radix - W ;462 Radix = Radix - WVar; 463 463 } 464 464 while (Radix == Zero); … … 467 467 printf ("Radix = %f .\n", Radix); 468 468 if (Radix != 1) { 469 W = One;469 WVar = One; 470 470 do { 471 471 Precision = Precision + One; 472 W = W* Radix;473 Y = W + One;474 } 475 while ((Y - W ) == One);476 } 477 /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W== 1472 WVar = WVar * Radix; 473 Y = WVar + One; 474 } 475 while ((Y - WVar) == One); 476 } 477 /*... now WVar == Radix^Precision is barely too big to satisfy (WVar+1)-WVar == 1 478 478 ...*/ 479 U1 = One / W ;479 U1 = One / WVar; 480 480 U2 = Radix * U1; 481 481 printf ("Closest relative separation found is U1 = %.7e .\n\n", U1); … … 529 529 else 530 530 printf ("gets better closest relative separation U1 = %.7e .\n", U1); 531 W = One / U1;531 WVar = One / U1; 532 532 F9 = (Half - U1) + Half; 533 533 Radix = FLOOR (0.01 + U2 / U1); … … 653 653 /*=============================================*/ 654 654 if (Radix >= Two) { 655 X = W / (Radix * Radix);655 X = WVar / (Radix * Radix); 656 656 Y = X + One; 657 657 Z = Y - X; … … 1195 1195 } 1196 1196 while (!(U2 * D >= F9)); 1197 if (D * Radix - D != W - D)1197 if (D * Radix - D != WVar - D) 1198 1198 Anomaly = True; 1199 1199 else { … … 1208 1208 SR3750 (); 1209 1209 NewD (); 1210 if (D - Z2 != W - Z2)1210 if (D - Z2 != WVar - Z2) 1211 1211 Anomaly = True; 1212 1212 else { … … 1226 1226 if ((I == 0) || Anomaly) { 1227 1227 BadCond (Failure, "Anomalous arithmetic with Integer < "); 1228 printf ("Radix^Precision = %.7e\n", W );1228 printf ("Radix^Precision = %.7e\n", WVar); 1229 1229 printf (" fails test whether sqrt rounds or chops.\n"); 1230 1230 SqRWrng = True; … … 1283 1283 N = 0; 1284 1284 Z = A1; 1285 M = (int) FLOOR (Two * LOG (W ) / LOG (A1));1285 M = (int) FLOOR (Two * LOG (WVar) / LOG (A1)); 1286 1286 Break = False; 1287 1287 do { … … 1359 1359 else 1360 1360 HInvrse = Radix; 1361 H = One / HInvrse;1362 /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */1361 HVar = One / HInvrse; 1362 /* ... 1/HInvrse == HVar == Min(1/Radix, 1/2) */ 1363 1363 CInvrse = One / C; 1364 1364 E0 = C; 1365 Z = E0 * H ;1365 Z = E0 * HVar; 1366 1366 /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ 1367 1367 do { 1368 1368 Y = E0; 1369 1369 E0 = Z; 1370 Z = E0 * H ;1370 Z = E0 * HVar; 1371 1371 } 1372 1372 while ((E0 > Z) && (Z + Z > Z)); … … 1390 1390 } else { 1391 1391 Underflow = D; 1392 PseudoZero = Underflow * H ;1392 PseudoZero = Underflow * HVar; 1393 1393 UfThold = Zero; 1394 1394 do { … … 1402 1402 UfThold = Y1; 1403 1403 } 1404 PseudoZero = PseudoZero * H ;1404 PseudoZero = PseudoZero * HVar; 1405 1405 } 1406 1406 while ((Underflow > PseudoZero) … … 1433 1433 /*=============================================*/ 1434 1434 if (CInvrse * Y > CInvrse * Y1) { 1435 S = H * S;1435 S = HVar * S; 1436 1436 E0 = Underflow; 1437 1437 } … … 1503 1503 if (setjmp (ovfl_buf)) { 1504 1504 printf ("Underflow / UfThold failed!\n"); 1505 R = H + H;1505 R = HVar + HVar; 1506 1506 } else 1507 1507 R = SQRT (Underflow / UfThold); 1508 1508 sigsave = 0; 1509 if (R <= H ) {1509 if (R <= HVar) { 1510 1510 Z = R * UfThold; 1511 X = Z * (One + R * H * (One + H));1511 X = Z * (One + R * HVar * (One + HVar)); 1512 1512 } else { 1513 1513 Z = UfThold; 1514 X = Z * (One + H * H * (One + H));1514 X = Z * (One + HVar * HVar * (One + HVar)); 1515 1515 } 1516 1516 if (!((X == Z) || (X - Z != Zero))) { … … 1780 1780 if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { 1781 1781 Y = V9; 1782 if (X < W )1782 if (X < WVar) 1783 1783 BadCond (Serious, ""); 1784 1784 else … … 2067 2067 SR3750 () 2068 2068 { 2069 if (!((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) {2069 if (!((X - Radix < Z2 - Radix) || (X - Z2 > WVar - Z2))) { 2070 2070 I = I + 1; 2071 2071 X2 = SQRT (X * D); … … 2112 2112 X = Z * X; 2113 2113 } 2114 while (X < W );2114 while (X < WVar); 2115 2115 } 2116 2116
Note: See TracChangeset
for help on using the changeset viewer.