Back to index

glibc  2.9
testit.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <math.h>
00004 
00005 #include "soft-fp.h"
00006 #include "single.h"
00007 #include "double.h"
00008 
00009 #include <fpu_control.h>
00010 
00011 /*======================================================================*/
00012 /* declarations for the functions we are testing */
00013 
00014 double __adddf3(double, double);
00015 double __subdf3(double, double);
00016 double __muldf3(double, double);
00017 double __divdf3(double, double);
00018 double __negdf2(double);
00019 double __sqrtdf2(double);
00020 double __negdf3(double a, double dummy) { return __negdf2(a); }
00021 double __sqrtdf3(double a, double dummy) { return __sqrtdf2(a); }
00022 
00023 float __addsf3(float, float);
00024 float __subsf3(float, float);
00025 float __mulsf3(float, float);
00026 float __divsf3(float, float);
00027 float __negsf2(float);
00028 float __sqrtsf2(float);
00029 float __negsf3(float a, float dummy) { return __negsf2(a); }
00030 float __sqrtsf3(float a, float dummy) { return __sqrtsf2(a); }
00031 
00032 int __fixdfsi(double);
00033 int __fixsfsi(float);
00034 double __floatsidf(int);
00035 float __floatsisf(int);
00036 double __extendsfdf2(float);
00037 float __truncdfsf2(double);
00038 
00039 int __eqdf2(double, double);
00040 int __nedf2(double, double);
00041 int __gtdf2(double, double);
00042 int __gedf2(double, double);
00043 int __ltdf2(double, double);
00044 int __ledf2(double, double);
00045 
00046 int __eqsf2(float, float);
00047 int __nesf2(float, float);
00048 int __gtsf2(float, float);
00049 int __gesf2(float, float);
00050 int __ltsf2(float, float);
00051 int __lesf2(float, float);
00052 
00053 /*======================================================================*/
00054 /* definitions for functions we are checking against */
00055 
00056 double r_adddf3(double a, double b) { return a + b; }
00057 double r_subdf3(double a, double b) { return a - b; }
00058 double r_muldf3(double a, double b) { return a * b; }
00059 double r_divdf3(double a, double b) { return a / b; }
00060 double r_negdf3(double a, double b) { return -a; }
00061 double sqrt(double x);
00062 double r_sqrtdf3(double a, double b) { return sqrt(a); }
00063 
00064 float r_addsf3(float a, float b) { return a + b; }
00065 float r_subsf3(float a, float b) { return a - b; }
00066 float r_mulsf3(float a, float b) { return a * b; }
00067 float r_divsf3(float a, float b) { return a / b; }
00068 float r_negsf3(float a, float b) { return -a; }
00069 float sqrtf(float x);
00070 float r_sqrtsf3(float a, float b) { return sqrtf(a); }
00071 
00072 int r_fixdfsi(double a) { return (int)a; }
00073 int r_fixsfsi(float a) { return (int)a; }
00074 double r_floatsidf(int a) { return (double)a; }
00075 float r_floatsisf(int a) { return (float)a; }
00076 double r_extendsfdf2(float a) { return (double)a; }
00077 float r_truncdfsf2(double a) { return (float)a; }
00078 
00079 int r_eqdf2(double a, double b) { return !(a == b); }
00080 int r_nedf2(double a, double b) { return a != b; }
00081 int r_gtdf2(double a, double b) { return a > b; }
00082 int r_gedf2(double a, double b) { return (a >= b) - 1; }
00083 int r_ltdf2(double a, double b) { return -(a < b); }
00084 int r_ledf2(double a, double b) { return 1 - (a <= b); }
00085 
00086 int r_eqsf2(float a, float b) { return !(a == b); }
00087 int r_nesf2(float a, float b) { return a != b; }
00088 int r_gtsf2(float a, float b) { return a > b; }
00089 int r_gesf2(float a, float b) { return (a >= b) - 1; }
00090 int r_ltsf2(float a, float b) { return -(a < b); }
00091 int r_lesf2(float a, float b) { return 1 - (a <= b); }
00092 
00093 /*======================================================================*/
00094 
00095 void print_float(float x)
00096 {
00097     union _FP_UNION_S ux;
00098     ux.flt = x;
00099     printf("%-20.8e %X %02X %06lX",
00100           x, ux.bits.sign, ux.bits.exp, (unsigned long)ux.bits.frac);
00101 }
00102 
00103 void print_double(double x)
00104 {
00105     union _FP_UNION_D ux;
00106     ux.flt = x;
00107 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00108     printf("%-30.18e %X %04X %06lX%08lX",
00109           x, ux.bits.sign, ux.bits.exp,
00110           (unsigned long)ux.bits.frac1, (unsigned long)ux.bits.frac0);
00111 #else
00112     printf("%-30.18e %X %04X %014lX",
00113           x, ux.bits.sign, ux.bits.exp,
00114           (unsigned long)ux.bits.frac);
00115 #endif
00116 }
00117 
00118 float rand_float(void)
00119 {
00120     union {
00121        union _FP_UNION_S u;
00122        int i;
00123     } u;
00124 
00125     u.i = lrand48() << 1;
00126 
00127     if (u.u.bits.exp == _FP_EXPMAX_S)
00128        u.u.bits.exp--;
00129     else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
00130        u.u.bits.exp++;
00131 
00132     return u.u.flt;
00133 }
00134 
00135 
00136 double rand_double(void)
00137 {
00138     union {
00139        union _FP_UNION_D u;
00140        int i[2];
00141     } u;
00142 
00143     u.i[0] = lrand48() << 1;
00144     u.i[1] = lrand48() << 1;
00145 
00146     if (u.u.bits.exp == _FP_EXPMAX_D)
00147        u.u.bits.exp--;
00148 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00149     else if (u.u.bits.exp == 0 && !(u.u.bits.frac0 == 0 && u.u.bits.frac1 == 0))
00150        u.u.bits.exp++;
00151 #else
00152     else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
00153        u.u.bits.exp++;
00154 #endif
00155 
00156     return u.u.flt;
00157 }
00158 
00159 #define NSPECIALS  10
00160 
00161 float gen_special_float(int i)
00162 {
00163     FP_DECL_EX;
00164     FP_DECL_S(X);
00165     float x;
00166 
00167     switch (i & ~1)
00168     {
00169       case 0:
00170        X_c = FP_CLS_NAN; X_f = 0x1234;
00171        break;
00172       case 2:
00173        X_c = FP_CLS_NAN; X_f = 0x1;
00174        break;
00175       case 4:
00176        X_c = FP_CLS_INF;
00177        break;
00178       case 6:
00179        X_c = FP_CLS_ZERO;
00180        break;
00181       case 8:
00182        X_c = FP_CLS_NORMAL; X_e = 0;
00183        X_f = 0x4321;
00184        break;
00185     }
00186     X_s = (i & 1);
00187 
00188     FP_PACK_S(x, X);
00189     return x;
00190 }
00191 
00192 double gen_special_double(int i)
00193 {
00194     FP_DECL_EX;
00195     FP_DECL_D(X);
00196     double x;
00197 
00198     switch (i & ~1)
00199     {
00200       case 0:
00201        X_c = FP_CLS_NAN;
00202 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00203        __FP_FRAC_SET_2(X, _FP_QNANBIT_D, 0x1234);
00204 #else
00205        _FP_FRAC_SET_1(X, _FP_QNANBIT_D | 0x1234);
00206 #endif
00207        break;
00208       case 2:
00209        X_c = FP_CLS_NAN;
00210 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00211        __FP_FRAC_SET_2(X, _FP_QNANBIT_D, 0x1);
00212 #else
00213        _FP_FRAC_SET_1(X, _FP_QNANBIT_D | 0x1);
00214 #endif
00215        break;
00216       case 4:
00217        X_c = FP_CLS_INF;
00218        break;
00219       case 6:
00220        X_c = FP_CLS_ZERO;
00221        break;
00222       case 8:
00223        X_c = FP_CLS_NORMAL; X_e = 0;
00224 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00225        __FP_FRAC_SET_2(X, 0, 0x87654321);
00226 #else
00227        _FP_FRAC_SET_1(X, 0x87654321);
00228 #endif
00229        break;
00230     }
00231     X_s = (i & 1);
00232 
00233     FP_PACK_D(x, X);
00234     return x;
00235 }
00236 
00237 float build_float(const char *s, const char *e, const char *f)
00238 {
00239     union _FP_UNION_S u;
00240 
00241     u.bits.sign = strtoul(s, 0, 16);
00242     u.bits.exp = strtoul(e, 0, 16);
00243     u.bits.frac = strtoul(f, 0, 16);
00244 
00245     return u.flt;
00246 }
00247       
00248 double build_double(const char *s, const char *e, const char *f)
00249 {
00250     union _FP_UNION_D u;
00251 
00252     u.bits.sign = strtoul(s, 0, 16);
00253     u.bits.exp = strtoul(e, 0, 16);
00254 #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
00255     {
00256        size_t len = strlen(f)+1;
00257        char *dup = memcpy(alloca(len), f, len);
00258        char *low = dup + len - _FP_W_TYPE_SIZE/4 - 1;
00259 
00260        u.bits.frac0 = strtoul(low, 0, 16);
00261        *low = 0;
00262        u.bits.frac1 = strtoul(dup, 0, 16);
00263     }
00264 #else
00265     u.bits.frac = strtoul(f, 0, 16);
00266 #endif
00267        
00268     return u.flt;
00269 }
00270       
00271 /*======================================================================*/
00272 
00273 fpu_control_t fcw0, fcw1;
00274 
00275 void test_float_arith(float (*tf)(float, float),
00276                     float (*rf)(float, float),
00277                     float x, float y)
00278 {
00279     float tr, rr;
00280     rr = (*rf)(x, y);
00281     tr = (*tf)(x, y);
00282     if (memcmp(&tr, &rr, sizeof(float)) != 0)
00283     {
00284        fputs("error:\n\tx     = ", stdout); print_float(x);
00285        fputs("\n\ty     = ", stdout); print_float(y);
00286        fputs("\n\ttrue  = ", stdout); print_float(rr);
00287        fputs("\n\tfalse = ", stdout); print_float(tr);
00288        putchar('\n');
00289     }
00290 }
00291 
00292 void test_double_arith(double (*tf)(double, double),
00293                      double (*rf)(double, double),
00294                      double x, double y)
00295 {
00296     double tr, rr;
00297 #ifdef __i386__
00298     /* Don't worry.  Even this does not make it error free
00299        on ia32.  If the result is denormal,  it will not
00300        honour the double precision and generate bad results
00301        anyway.  On the other side,  who wants to use ia32
00302        for IEEE math?  I don't.  */
00303     _FPU_GETCW(fcw0);
00304     fcw1 = ((fcw0 & ~_FPU_EXTENDED) | _FPU_DOUBLE);
00305     _FPU_SETCW(fcw1);
00306 #endif    
00307     rr = (*rf)(x, y);
00308 #ifdef __i386__
00309     _FPU_SETCW(fcw0);
00310 #endif
00311     tr = (*tf)(x, y);
00312     if (memcmp(&tr, &rr, sizeof(double)) != 0)
00313     {
00314        fputs("error:\n\tx     = ", stdout); print_double(x);
00315        fputs("\n\ty     = ", stdout); print_double(y);
00316        fputs("\n\ttrue  = ", stdout); print_double(rr);
00317        fputs("\n\tfalse = ", stdout); print_double(tr);
00318        putchar('\n');
00319     }
00320 }
00321 
00322 void test_float_double_conv(float x)
00323 {
00324     double tr, rr;
00325     rr = r_extendsfdf2(x);
00326     tr = __extendsfdf2(x);
00327     if (memcmp(&tr, &rr, sizeof(double)) != 0)
00328     {
00329        fputs("error:\n\tx     = ", stdout); print_float(x);
00330        fputs("\n\ttrue  = ", stdout); print_double(rr);
00331        fputs("\n\tfalse = ", stdout); print_double(tr);
00332        putchar('\n');
00333     }
00334 }
00335 
00336 void test_double_float_conv(double x)
00337 {
00338     float tr, rr;
00339     rr = r_truncdfsf2(x);
00340     tr = __truncdfsf2(x);
00341     if (memcmp(&tr, &rr, sizeof(float)) != 0)
00342     {
00343        fputs("error:\n\tx     = ", stdout); print_double(x);
00344        fputs("\n\ttrue  = ", stdout); print_float(rr);
00345        fputs("\n\tfalse = ", stdout); print_float(tr);
00346        putchar('\n');
00347     }
00348 }
00349 
00350 void test_int_float_conv(int x)
00351 {
00352     float tr, rr;
00353     rr = r_floatsisf(x);
00354     tr = __floatsisf(x);
00355     if (memcmp(&tr, &rr, sizeof(float)) != 0)
00356     {
00357        printf("error\n\tx     = %d", x);
00358        fputs("\n\ttrue  = ", stdout); print_float(rr);
00359        fputs("\n\tfalse = ", stdout); print_float(tr);
00360        putchar('\n');
00361     }
00362 }
00363 
00364 void test_int_double_conv(int x)
00365 {
00366     double tr, rr;
00367     rr = r_floatsidf(x);
00368     tr = __floatsidf(x);
00369     if (memcmp(&tr, &rr, sizeof(double)) != 0)
00370     {
00371        printf("error\n\tx     = %d", x);
00372        fputs("\n\ttrue  = ", stdout); print_double(rr);
00373        fputs("\n\tfalse = ", stdout); print_double(tr);
00374        putchar('\n');
00375     }
00376 }
00377 
00378 void test_float_int_conv(float x)
00379 {
00380     int tr, rr;
00381     rr = r_fixsfsi(x);
00382     tr = __fixsfsi(x);
00383     if (rr != tr)
00384     {
00385        fputs("error:\n\tx     = ", stdout); print_float(x);
00386        printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
00387     }
00388 }
00389        
00390 void test_double_int_conv(double x)
00391 {
00392     int tr, rr;
00393     rr = r_fixsfsi(x);
00394     tr = __fixsfsi(x);
00395     if (rr != tr)
00396     {
00397        fputs("error:\n\tx     = ", stdout); print_double(x);
00398        printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
00399     }
00400 }
00401 
00402 int eq0(int x) { return x == 0; }
00403 int ne0(int x) { return x != 0; }
00404 int le0(int x) { return x <= 0; }
00405 int lt0(int x) { return x < 0; }
00406 int ge0(int x) { return x >= 0; }
00407 int gt0(int x) { return x > 0; }
00408 
00409 void test_float_cmp(int (*tf)(float, float),
00410                   int (*rf)(float, float),
00411                   int (*cmp0)(int),
00412                   float x, float y)
00413 {
00414     int tr, rr;
00415     rr = (*rf)(x, y);
00416     tr = (*tf)(x, y);
00417     if (cmp0(rr) != cmp0(tr))
00418     {
00419        fputs("error:\n\tx     = ", stdout); print_float(x);
00420        fputs("\n\ty     = ", stdout); print_float(y);
00421        printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
00422     }
00423 }
00424 
00425 void test_double_cmp(int (*tf)(double, double),
00426                    int (*rf)(double, double),
00427                    int (*cmp0)(int),
00428                    double x, double y)
00429 {
00430     int tr, rr;
00431     rr = (*rf)(x, y);
00432     tr = (*tf)(x, y);
00433     if (cmp0(rr) != cmp0(tr))
00434     {
00435        fputs("error:\n\tx     = ", stdout); print_double(x);
00436        fputs("\n\ty     = ", stdout); print_double(y);
00437        printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
00438     }
00439 }
00440 
00441 
00442 /*======================================================================*/
00443 
00444 
00445 int main(int ac, char **av)
00446 {
00447 #ifdef __alpha__
00448     __ieee_set_fp_control(0);
00449 #endif
00450     av++, ac--;
00451     switch (*(*av)++)
00452     {
00453        {
00454            float (*r)(float, float);
00455            float (*t)(float, float);
00456 
00457            do {
00458              case 'a': r = r_addsf3; t = __addsf3; break;
00459              case 's': r = r_subsf3; t = __subsf3; break;
00460              case 'm': r = r_mulsf3; t = __mulsf3; break;
00461              case 'd': r = r_divsf3; t = __divsf3; break;
00462              case 'r': r = r_sqrtsf3; t = __sqrtsf3; break;
00463              case 'j': r = r_negsf3; t = __negsf3; break;
00464            } while (0);
00465 
00466            switch (*(*av)++)
00467            {
00468              case 'n':
00469               {
00470                   int count = (ac > 1 ? atoi(av[1]) : 100);
00471                   while (count--)
00472                      test_float_arith(t, r, rand_float(), rand_float());
00473               }
00474               break;
00475 
00476              case 's':
00477               {
00478                   int i, j;
00479                   for (i = 0; i < NSPECIALS; i++)
00480                      for (j = 0; j < NSPECIALS; j++)
00481                          test_float_arith(t, r, gen_special_float(i),
00482                                          gen_special_float(j));
00483               }
00484               break;
00485 
00486              case 0:
00487               if (ac < 7) abort();
00488               test_float_arith(t, r, build_float(av[1], av[2], av[3]),
00489                              build_float(av[4], av[5], av[6]));
00490               break;
00491            }
00492        }
00493        break;
00494 
00495        {
00496            double (*r)(double, double);
00497            double (*t)(double, double);
00498 
00499            do {
00500              case 'A': r = r_adddf3; t = __adddf3; break;
00501              case 'S': r = r_subdf3; t = __subdf3; break;
00502              case 'M': r = r_muldf3; t = __muldf3; break;
00503              case 'D': r = r_divdf3; t = __divdf3; break;
00504              case 'R': r = r_sqrtdf3; t = __sqrtdf3; break;
00505              case 'J': r = r_negdf3; t = __negdf3; break;
00506            } while (0);
00507 
00508            switch (*(*av)++)
00509            {
00510              case 'n':
00511               {
00512                   int count = (ac > 1 ? atoi(av[1]) : 100);
00513                   while (count--)
00514                      test_double_arith(t, r, rand_double(), rand_double());
00515               }
00516               break;
00517 
00518              case 's':
00519               {
00520                   int i, j;
00521                   for (i = 0; i < NSPECIALS; i++)
00522                      for (j = 0; j < NSPECIALS; j++)
00523                          test_double_arith(t, r, gen_special_double(i),
00524                                          gen_special_double(j));
00525               }
00526               break;
00527 
00528              case 0:
00529               if (ac < 7) abort();
00530               test_double_arith(t, r, build_double(av[1], av[2], av[3]),
00531                               build_double(av[4], av[5], av[6]));
00532               break;
00533            }
00534        }
00535        break;
00536 
00537       case 'c':
00538        switch (*(*av)++)
00539        {
00540          case 'n':
00541            {
00542               int count = (ac > 1 ? atoi(av[1]) : 100);
00543               while (count--)
00544                   test_float_double_conv(rand_float());
00545            }
00546            break;
00547 
00548          case 's':
00549            {
00550               int i;
00551               for (i = 0; i < NSPECIALS; i++)
00552                   test_float_double_conv(gen_special_float(i));
00553            }
00554            break;
00555 
00556          case 0:
00557            if (ac < 4) abort();
00558            test_float_double_conv(build_float(av[1], av[2], av[3]));
00559            break;
00560        }
00561        break;
00562 
00563       case 'C':
00564        switch (*(*av)++)
00565        {
00566          case 'n':
00567            {
00568               int count = (ac > 1 ? atoi(av[1]) : 100);
00569               while (count--)
00570                   test_double_float_conv(rand_double());
00571            }
00572            break;
00573 
00574          case 's':
00575            {
00576               int i;
00577               for (i = 0; i < NSPECIALS; i++)
00578                   test_double_float_conv(gen_special_double(i));
00579            }
00580            break;
00581 
00582          case 0:
00583            if (ac < 4) abort();
00584            test_double_float_conv(build_double(av[1], av[2], av[3]));
00585            break;
00586        }
00587        break;
00588 
00589       case 'i':
00590        switch (*(*av)++)
00591        {
00592          case 'n':
00593            {
00594               int count = (ac > 1 ? atoi(av[1]) : 100);
00595               while (count--)
00596                   test_int_float_conv(lrand48() << 1);
00597            }
00598            break;
00599 
00600          case 0:
00601            if (ac < 2) abort();
00602            test_int_float_conv(strtol(av[1], 0, 0));
00603            break;
00604        }
00605        break;
00606 
00607       case 'I':
00608        switch (*(*av)++)
00609        {
00610          case 'n':
00611            {
00612               int count = (ac > 1 ? atoi(av[1]) : 100);
00613               while (count--)
00614                   test_int_double_conv(lrand48() << 1);
00615            }
00616            break;
00617 
00618          case 0:
00619            if (ac < 2) abort();
00620            test_int_double_conv(strtol(av[1], 0, 0));
00621            break;
00622        }
00623        break;
00624 
00625       case 'f':
00626        switch (*(*av)++)
00627        {
00628          case 'n':
00629            {
00630               int count = (ac > 1 ? atoi(av[1]) : 100);
00631               while (count--)
00632                   test_float_int_conv(rand_float());
00633            }
00634            break;
00635 
00636          case 's':
00637            {
00638               int i;
00639               for (i = 0; i < NSPECIALS; i++)
00640                   test_float_int_conv(gen_special_float(i));
00641            }
00642            break;
00643 
00644          case 0:
00645            if (ac < 4) abort();
00646            test_float_int_conv(build_float(av[1], av[2], av[3]));
00647            break;
00648        }
00649        break;
00650 
00651       case 'F':
00652        switch (*(*av)++)
00653        {
00654          case 'n':
00655            {
00656               int count = (ac > 1 ? atoi(av[1]) : 100);
00657               while (count--)
00658                   test_double_int_conv(rand_double());
00659            }
00660            break;
00661 
00662          case 's':
00663            {
00664               int i;
00665               for (i = 0; i < NSPECIALS; i++)
00666                   test_double_int_conv(gen_special_double(i));
00667            }
00668            break;
00669 
00670          case 0:
00671            if (ac < 4) abort();
00672            test_double_int_conv(build_double(av[1], av[2], av[3]));
00673            break;
00674        }
00675        break;
00676 
00677        {
00678            int (*r)(float, float);
00679            int (*t)(float, float);
00680            int (*c)(int);
00681 
00682            do {
00683              case 'e': r = r_eqsf2; t = __eqsf2; c = eq0; break;
00684              case 'n': r = r_nesf2; t = __nesf2; c = ne0; break;
00685              case 'l':
00686               switch (*(*av)++)
00687               {
00688                 case 'e': r = r_lesf2; t = __lesf2; c = le0; break;
00689                 case 't': r = r_ltsf2; t = __ltsf2; c = lt0; break;
00690               }
00691               break;
00692              case 'g':
00693               switch (*(*av)++)
00694               {
00695                 case 'e': r = r_gesf2; t = __gesf2; c = ge0; break;
00696                 case 't': r = r_gtsf2; t = __gtsf2; c = gt0; break;
00697               }
00698               break;
00699            } while (0);
00700 
00701            switch (*(*av)++)
00702            {
00703              case 'n':
00704               {
00705                   int count = (ac > 1 ? atoi(av[1]) : 100);
00706                   while (count--)
00707                      test_float_cmp(t, r, c, rand_float(), rand_float());
00708               }
00709               break;
00710 
00711              case 's':
00712               {
00713                   int i, j;
00714                   for (i = 0; i < NSPECIALS; i++)
00715                      for (j = 0; j < NSPECIALS; j++)
00716                          test_float_cmp(t, r, c, gen_special_float(i),
00717                                       gen_special_float(j));
00718               }
00719               break;
00720 
00721              case 0:
00722               if (ac < 7) abort();
00723               test_float_cmp(t, r, c, build_float(av[1], av[2], av[3]),
00724                             build_float(av[4], av[5], av[6]));
00725               break;
00726            }
00727        }
00728        break;
00729 
00730        {
00731            int (*r)(double, double);
00732            int (*t)(double, double);
00733            int (*c)(int);
00734 
00735            do {
00736              case 'E': r = r_eqdf2; t = __eqdf2; c = eq0; break;
00737              case 'N': r = r_nedf2; t = __nedf2; c = ne0; break;
00738              case 'L':
00739               switch (*(*av)++)
00740               {
00741                 case 'E': r = r_ledf2; t = __ledf2; c = le0; break;
00742                 case 'T': r = r_ltdf2; t = __ltdf2; c = lt0; break;
00743               }
00744               break;
00745              case 'G':
00746               switch (*(*av)++)
00747               {
00748                 case 'E': r = r_gedf2; t = __gedf2; c = ge0; break;
00749                 case 'T': r = r_gtdf2; t = __gtdf2; c = gt0; break;
00750               }
00751               break;
00752            } while (0);
00753 
00754            switch (*(*av)++)
00755            {
00756              case 'n':
00757               {
00758                   int count = (ac > 1 ? atoi(av[1]) : 100);
00759                   while (count--)
00760                      test_double_cmp(t, r, c, rand_double(), rand_double());
00761               }
00762               break;
00763 
00764              case 's':
00765               {
00766                   int i, j;
00767                   for (i = 0; i < NSPECIALS; i++)
00768                      for (j = 0; j < NSPECIALS; j++)
00769                          test_double_cmp(t, r, c, gen_special_double(i),
00770                                        gen_special_double(j));
00771               }
00772               break;
00773 
00774              case 0:
00775               if (ac < 7) abort();
00776               test_double_cmp(t, r, c, build_double(av[1], av[2], av[3]),
00777                             build_double(av[4], av[5], av[6]));
00778               break;
00779            }
00780        }
00781        break;
00782 
00783       default:
00784        abort();
00785     }
00786 
00787     return 0;
00788 }