Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
confidence.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 /*
00037  *      Arithmetic library low-level and high-level confidence tests
00038  */
00039 
00040 #include <stdio.h>
00041 #include <string.h>
00042 #include <signal.h>
00043 #ifdef _CRAY
00044 #include <complex.h>
00045 extern float RANF ();
00046 #else
00047 #include <stdlib.h>
00048 #endif
00049 #include "arith.h"
00050 #include "arith.internal.h"
00051 
00052 #define RAND_ITERS      10000
00053 
00054 #define FLAGMASK        (AR_STAT_OVERFLOW | AR_STAT_UNDEFINED | \
00055                          AR_STAT_ZERO | AR_STAT_NEGATIVE)
00056 
00057 #define AR_ERR          (AR_STAT_OVERFLOW | AR_STAT_UNDEFINED)
00058 
00059 
00060 void fadd (float *z, float *a, float *b) { *z = *a + *b; }
00061 void fsub (float *z, float *a, float *b) { *z = *a - *b; }
00062 void fmul (float *z, float *a, float *b) { *z = *a * *b; }
00063 void fdiv (float *z, float *a, float *b) { *z = *a / *b; }
00064 
00065 #if _CRAY
00066 void dfadd (long double *z, long double *a, long double *b) { *z = *a + *b; }
00067 void dfsub (long double *z, long double *a, long double *b) { *z = *a - *b; }
00068 void dfmul (long double *z, long double *a, long double *b) { *z = *a * *b; }
00069 void dfdiv (long double *z, long double *a, long double *b) { *z = *a / *b; }
00070 void cadd (double complex *z, double complex *a, double complex *b) {
00071         *z = *a + *b;
00072 }
00073 void csub (double complex *z, double complex *a, double complex *b) {
00074         *z = *a - *b;
00075 }
00076 void cmul (double complex *z, double complex *a, double complex *b) {
00077         *z = *a * *b;
00078 }
00079 void cdiv (double complex *z, double complex *a, double complex *b) {
00080 #if _ADDR32
00081         if (!cimag (*b)) {
00082                 /* zero imaginary part - expect different answers (sigh) */
00083                 *z = (creal (*a) / creal (*b)) +
00084                         0.0i * (cimag (*a) / creal (*b));
00085         } else
00086 #endif
00087                 *z = *a / *b;
00088 }
00089 
00090 #else
00091 
00092 void xdfadd (long double *z, long double *a, long double *b) { *z = *a + *b; }
00093 void xdfsub (long double *z, long double *a, long double *b) { *z = *a - *b; }
00094 void xdfmul (long double *z, long double *a, long double *b) { *z = *a * *b; }
00095 void xdfdiv (long double *z, long double *a, long double *b) { *z = *a / *b; }
00096 
00097 void dfadd (double *z, double *a, double *b) { *z = *a + *b; }
00098 void dfsub (double *z, double *a, double *b) { *z = *a - *b; }
00099 void dfmul (double *z, double *a, double *b) { *z = *a * *b; }
00100 void dfdiv (double *z, double *a, double *b) { *z = *a / *b; }
00101 
00102 #endif
00103 
00104 
00105 /* Trap floating-point exceptions and set a flag */
00106 static volatile int fp_error = 0;
00107 void
00108 fperr (int sig) {
00109 
00110         fp_error = 1;
00111         signal (SIGFPE, fperr);
00112 
00113 }
00114 
00115 #if _CRAY
00116 extern void ARFMULT (float *, float *, float *);
00117 extern void ARRMULT (float *, float *, float *);
00118 extern void ARIMULT (float *, float *, float *);
00119 extern void ARQMULT (float *, float *, float *);
00120 extern void ARHRECIP (float *, float *);
00121 
00122 void
00123 trapmathlibabort (void) {
00124         fp_error = 1;
00125 }
00126 #else
00127 
00128 /* Prevent printing of math library error messages on Suns */
00129 int
00130 matherr () {
00131         return 1;
00132 }
00133 
00134 #endif
00135 
00136 #if _CRAY || _SPARC
00137 extern void ARSQRT (float *, float *);
00138 extern void ARDSQRT (long double *, long double *);
00139 extern void ARLOG (float *, float *);
00140 extern void ARDLOG (long double *, long double *);
00141 extern void AREXP (float *, float *);
00142 extern void ARDEXP (long double *, long double *);
00143 #endif
00144 
00145 
00146 /* Input routines */
00147 
00148 int
00149 getnewline (FILE *fp) {
00150         int ch;
00151         while ((ch = fgetc (fp)) == ' ' || ch == '\n' || ch == '\t') ;
00152         if (ch == '$' && fgetc (fp) == 't')
00153                 return 1;
00154         return 0;
00155 }
00156 
00157 int
00158 getcray64 (FILE *fp, AR_CRAY_64 *x) {
00159         int ct;
00160         unsigned long xsign, xexpo, xc [4];
00161         ct = fscanf (fp, " %1lo %5lo %1lo%5lo%5lo%5lo",
00162                      &xsign, &xexpo, xc + 0, xc + 1, xc + 2, xc + 3);
00163         x->sign = xsign;
00164         x->expo = xexpo;
00165         x->coeff0 = (xc [0] << 13) | (xc [1] >> 2);
00166         x->coeff1 = (xc [1] << 14) | (xc [2] >> 1);
00167         x->coeff2 = (xc [2] << 15) | xc [3];
00168         return ct == 6;
00169 }
00170 
00171 int
00172 getcray128 (FILE *fp, AR_CRAY_128 *x) {
00173         int ct;
00174         unsigned long xsign, xexpo, xzero, xc [8];
00175         ct = fscanf (fp, " %1lo%5lo%1lo%5lo%5lo%5lo %6lo%1lo%5lo%5lo%5lo",
00176                      &xsign, &xexpo, xc + 0, xc + 1, xc + 2, xc + 3,
00177                         &xzero, xc + 4, xc + 5, xc + 6, xc + 7);
00178         x->sign = xsign;
00179         x->expo = xexpo;
00180         x->coeff0 = (xc [0] << 13) | (xc [1] >> 2);
00181         x->coeff1 = (xc [1] << 14) | (xc [2] >> 1);
00182         x->coeff2 = (xc [2] << 15) | xc [3];
00183         x->zero = xzero;
00184         x->coeff3 = (xc [4] << 13) | (xc [5] >> 2);
00185         x->coeff4 = (xc [5] << 14) | (xc [6] >> 1);
00186         x->coeff5 = (xc [6] << 15) | xc [7];
00187         return ct == 11;
00188 }
00189 
00190 int
00191 getieee32 (FILE *fp, AR_IEEE_32 *x) {
00192         int ct;
00193         unsigned long xsign, xexpo, xc [2];
00194         ct = fscanf (fp, " %1lo%3lo%3lo%4lo",
00195                      &xsign, &xexpo, xc + 0, xc + 1);
00196         x->sign = xsign >> 1;
00197         x->expo = (xsign << 7) | (xexpo >> 2);
00198         x->coeff0 = (xexpo << 5) | (xc [0] >> 4);
00199         x->coeff1 = (xc [0] << 12) | xc [1];
00200         return ct == 4;
00201 }
00202 
00203 int
00204 getieee64 (FILE *fp, AR_IEEE_64 *x) {
00205         int ct;
00206         unsigned long xsign, xexpo, xc [4];
00207         ct = fscanf (fp, " %1lo%5lo%1lo%5lo%5lo%5lo",
00208                      &xsign, &xexpo, xc + 0, xc + 1, xc + 2, xc + 3);
00209         x->sign = xsign;
00210         x->expo = xexpo >> 4;
00211         x->coeff0 = xexpo;
00212         x->coeff1 = (xc [0] << 13) | (xc [1] >> 2);
00213         x->coeff2 = (xc [1] << 14) | (xc [2] >> 1);
00214         x->coeff3 = (xc [2] << 15) | xc [3];
00215         return ct == 6;
00216 }
00217 
00218 int
00219 getint64 (FILE *fp, AR_INT_64 *x) {
00220         int ct;
00221         unsigned long xc [5];
00222         ct = fscanf (fp, " %6lo%1lo%5lo%5lo%5lo",
00223                      xc + 0, xc + 1, xc + 2, xc + 3, xc + 4);
00224         x->part1 = xc [0];
00225         x->part2 = (xc [1] << 13) | (xc [2] >> 2);
00226         x->part3 = (xc [2] << 14) | (xc [3] >> 1);
00227         x->part4 = (xc [3] << 15) | xc [4];
00228         return ct == 5;
00229 }
00230 
00231 int
00232 getint (FILE *fp, int *x) {
00233         return fscanf (fp, " %o", x) == 1;
00234 }
00235 
00236 int
00237 getcray64_2 (FILE *fp,
00238              AR_CRAY_64 *x,
00239              AR_CRAY_64 *y,
00240              AR_CRAY_64 *res,
00241              int *ansflags) {
00242         return getnewline (fp) &&
00243                getcray64 (fp, x) &&
00244                getcray64 (fp, y) &&
00245                getcray64 (fp, res) &&
00246                getint (fp, ansflags);
00247 }
00248 
00249 int
00250 getcray64_1 (FILE *fp,
00251              AR_CRAY_64 *x,
00252              AR_CRAY_64 *res,
00253              int *ansflags) {
00254         return getnewline (fp) &&
00255                getcray64 (fp, x) &&
00256                getcray64 (fp, res) &&
00257                getint (fp, ansflags);
00258 }
00259 
00260 int
00261 getcray64_i (FILE *fp,
00262              AR_CRAY_64 *x,
00263              AR_INT_64 *y,
00264              AR_CRAY_64 *res,
00265              int *ansflags) {
00266         return getnewline (fp) &&
00267                getcray64 (fp, x) &&
00268                getint64 (fp, y) &&
00269                getcray64 (fp, res) &&
00270                getint (fp, ansflags);
00271 }
00272 
00273 int
00274 getcray64_i2 (FILE *fp,
00275               AR_INT_64 *x,
00276               AR_INT_64 *y,
00277               AR_INT_64 *res,
00278               int *ansflags) {
00279         return getnewline (fp) &&
00280                getint64 (fp, x) &&
00281                getint64 (fp, y) &&
00282                getint64 (fp, res) &&
00283                getint (fp, ansflags);
00284 }
00285 
00286 int
00287 getcray128_2 (FILE *fp,
00288               AR_CRAY_128 *x,
00289               AR_CRAY_128 *y,
00290               AR_CRAY_128 *res,
00291               int *ansflags) {
00292         return getnewline (fp) &&
00293                getcray128 (fp, x) &&
00294                getcray128 (fp, y) &&
00295                getcray128 (fp, res) &&
00296                getint (fp, ansflags);
00297 }
00298 
00299 int
00300 getcray128_1 (FILE *fp,
00301               AR_CRAY_128 *x,
00302               AR_CRAY_128 *res,
00303               int *ansflags) {
00304         return getnewline (fp) &&
00305                getcray128 (fp, x) &&
00306                getcray128 (fp, res) &&
00307                getint (fp, ansflags);
00308 }
00309 
00310 int
00311 getcray128_1a (FILE *fp,
00312                AR_INT_64 *x,
00313                AR_CRAY_128 *res,
00314                int *ansflags) {
00315         return getnewline (fp) &&
00316                getint64 (fp, x) &&
00317                getcray128 (fp, res) &&
00318                getint (fp, ansflags);
00319 }
00320 
00321 int
00322 getcray128_1b (FILE *fp,
00323                AR_CRAY_128 *x,
00324                AR_INT_64 *res,
00325                int *ansflags) {
00326         return getnewline (fp) &&
00327                getcray128 (fp, x) &&
00328                getint64 (fp, res) &&
00329                getint (fp, ansflags);
00330 }
00331 
00332 int
00333 getcray128_1c (FILE *fp,
00334                AR_CRAY_128 *x,
00335                AR_IEEE_64 *res,
00336                int *ansflags) {
00337         return getnewline (fp) &&
00338                getcray128 (fp, x) &&
00339                getieee64 (fp, res) &&
00340                getint (fp, ansflags);
00341 }
00342 
00343 int
00344 getcray128_i (FILE *fp,
00345               AR_CRAY_128 *x,
00346               AR_INT_64 *y,
00347               AR_CRAY_128 *res,
00348               int *ansflags) {
00349         return getnewline (fp) &&
00350                getcray128 (fp, x) &&
00351                getint64 (fp, y) &&
00352                getcray128 (fp, res) &&
00353                getint (fp, ansflags);
00354 }
00355 
00356 int
00357 getcray128_64 (FILE *fp,
00358                AR_CRAY_128 *x,
00359                AR_CRAY_64 *y,
00360                AR_CRAY_128 *res,
00361                int *ansflags) {
00362         return getnewline (fp) &&
00363                getcray128 (fp, x) &&
00364                getcray64 (fp, y) &&
00365                getcray128 (fp, res) &&
00366                getint (fp, ansflags);
00367 }
00368 
00369 int
00370 getieee64_2 (FILE *fp,
00371              AR_IEEE_64 *x,
00372              AR_IEEE_64 *y,
00373              AR_IEEE_64 *res,
00374              int *ansflags) {
00375         return getnewline (fp) &&
00376                getieee64 (fp, x) &&
00377                getieee64 (fp, y) &&
00378                getieee64 (fp, res) &&
00379                getint (fp, ansflags);
00380 }
00381 
00382 int
00383 getieee64_2c (FILE *fp,
00384              AR_CPLX_IEEE_64 *x,
00385              AR_CPLX_IEEE_64 *y,
00386              AR_CPLX_IEEE_64 *res,
00387              int *ansflags) {
00388         return getnewline (fp) &&
00389                getieee64 (fp, &x->real) &&
00390                getieee64 (fp, &x->imag) &&
00391                getieee64 (fp, &y->real) &&
00392                getieee64 (fp, &y->imag) &&
00393                getieee64 (fp, &res->real) &&
00394                getieee64 (fp, &res->imag) &&
00395                getint (fp, ansflags);
00396 }
00397 
00398 int
00399 getieee64_1 (FILE *fp,
00400              AR_IEEE_64 *x,
00401              AR_IEEE_64 *res,
00402              int *ansflags) {
00403         return getnewline (fp) &&
00404                getieee64 (fp, x) &&
00405                getieee64 (fp, res) &&
00406                getint (fp, ansflags);
00407 }
00408 
00409 int
00410 getieee32_2 (FILE *fp,
00411              AR_IEEE_32 *x,
00412              AR_IEEE_32 *y,
00413              AR_IEEE_32 *res,
00414              int *ansflags) {
00415         return getnewline (fp) &&
00416                getieee32 (fp, x) &&
00417                getieee32 (fp, y) &&
00418                getieee32 (fp, res) &&
00419                getint (fp, ansflags);
00420 }
00421 
00422 int
00423 getieee32_2c (FILE *fp,
00424              AR_CPLX_IEEE_32 *x,
00425              AR_CPLX_IEEE_32 *y,
00426              AR_CPLX_IEEE_32 *res,
00427              int *ansflags) {
00428              int status;
00429              AR_IEEE_32 f;
00430         status  = getnewline (fp);
00431         status |= getieee32 (fp, &f);
00432                   x->rsign = f.sign;
00433                   x->rexpo = f.expo;
00434                   x->rcoeff0 = f.coeff0;
00435                   x->rcoeff1 = f.coeff1;
00436         status |= getieee32 (fp, &f);
00437                   x->isign = f.sign;
00438                   x->iexpo = f.expo;
00439                   x->icoeff0 = f.coeff0;
00440                   x->icoeff1 = f.coeff1;
00441         status |= getieee32 (fp, &f);
00442                   y->rsign = f.sign;
00443                   y->rexpo = f.expo;
00444                   y->rcoeff0 = f.coeff0;
00445                   y->rcoeff1 = f.coeff1;
00446         status |= getieee32 (fp, &f);
00447                   y->isign = f.sign;
00448                   y->iexpo = f.expo;
00449                   y->icoeff0 = f.coeff0;
00450                   y->icoeff1 = f.coeff1;
00451         status |= getieee32 (fp, &f);
00452                   res->rsign = f.sign;
00453                   res->rexpo = f.expo;
00454                   res->rcoeff0 = f.coeff0;
00455                   res->rcoeff1 = f.coeff1;
00456         status |= getieee32 (fp, &f);
00457                   res->isign = f.sign;
00458                   res->iexpo = f.expo;
00459                   res->icoeff0 = f.coeff0;
00460                   res->icoeff1 = f.coeff1;
00461         return status && getint (fp, ansflags);
00462 }
00463 
00464 int
00465 getieee32_1 (FILE *fp,
00466              AR_IEEE_32 *x,
00467              AR_IEEE_32 *res,
00468              int *ansflags) {
00469         return getnewline (fp) &&
00470                getieee32 (fp, x) &&
00471                getieee32 (fp, res) &&
00472                getint (fp, ansflags);
00473 }
00474 
00475 int
00476 getint64_1 (FILE *fp,
00477             AR_INT_64 *x,
00478             AR_INT_64 *res,
00479             int *ansflags) {
00480         return getnewline (fp) &&
00481                getint64 (fp, x) &&
00482                getint64 (fp, res) &&
00483                getint (fp, ansflags);
00484 }
00485 
00486 
00487 /* Result checking */
00488 
00489 int
00490 crayok64 (AR_CRAY_64 *ans,
00491           AR_CRAY_64 *res,
00492           int ansflags,
00493           int resflags) {
00494 
00495         if (ansflags & AR_ERR)
00496                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00497         if ((resflags ^ ansflags) & FLAGMASK)
00498                 return 0;
00499         return res->sign == ans->sign &&
00500                res->expo == ans->expo &&
00501                res->coeff0 == ans->coeff0 &&
00502                res->coeff1 == ans->coeff1 &&
00503                res->coeff2 == ans->coeff2;
00504 }
00505 
00506 int
00507 crayok64i (AR_INT_64 *ans,
00508            AR_INT_64 *res,
00509            int ansflags,
00510            int resflags) {
00511 
00512         if (ansflags & AR_ERR)
00513                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00514         if ((resflags ^ ansflags) & FLAGMASK)
00515                 return 0;
00516         return res->part1 == ans->part1 &&
00517                res->part2 == ans->part2 &&
00518                res->part3 == ans->part3 &&
00519                res->part4 == ans->part4;
00520 }
00521 
00522 int
00523 crayok128 (AR_CRAY_128 *ans,
00524            AR_CRAY_128 *res,
00525            int ansflags,
00526            int resflags) {
00527 
00528         if (ansflags & AR_ERR)
00529                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00530         if ((resflags ^ ansflags) & FLAGMASK)
00531                 return 0;
00532         return res->sign == ans->sign &&
00533                res->expo == ans->expo &&
00534                res->coeff0 == ans->coeff0 &&
00535                res->coeff1 == ans->coeff1 &&
00536                res->coeff2 == ans->coeff2 &&
00537                res->coeff3 == ans->coeff3 &&
00538                res->coeff4 == ans->coeff4 &&
00539                res->coeff5 == ans->coeff5;
00540 }
00541 
00542 int
00543 ieeeok64 (AR_IEEE_64 *ans,
00544           AR_IEEE_64 *res,
00545           int ansflags,
00546           int resflags) {
00547 
00548         if (ansflags & AR_ERR)
00549                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00550         if ((resflags ^ ansflags) & FLAGMASK)
00551                 return 0;
00552         return res->sign == ans->sign &&
00553                res->expo == ans->expo &&
00554                res->coeff0 == ans->coeff0 &&
00555                res->coeff1 == ans->coeff1 &&
00556                res->coeff2 == ans->coeff2 &&
00557                res->coeff3 == ans->coeff3;
00558 }
00559 
00560 int
00561 ieeeok32 (AR_IEEE_32 *ans,
00562           AR_IEEE_32 *res,
00563           int ansflags,
00564           int resflags) {
00565 
00566         if (ansflags & AR_ERR)
00567                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00568         if ((resflags ^ ansflags) & FLAGMASK)
00569                 return 0;
00570         return res->sign == ans->sign &&
00571                res->expo == ans->expo &&
00572                res->coeff0 == ans->coeff0 &&
00573                res->coeff1 == ans->coeff1;
00574 }
00575 
00576 int
00577 intok64 (AR_INT_64 *ans,
00578          AR_INT_64 *res,
00579          int ansflags,
00580          int resflags) {
00581 
00582         if (ansflags & AR_ERR)
00583                 return ((resflags ^ ansflags) & AR_ERR) == 0;
00584         if ((resflags ^ ansflags) & FLAGMASK)
00585                 return 0;
00586         return res->part1 == ans->part1 &&
00587                res->part2 == ans->part2 &&
00588                res->part3 == ans->part3 &&
00589                res->part4 == ans->part4;
00590 }
00591 
00592 
00593 /* Error messages */
00594 
00595 prcray64 (AR_CRAY_64 *x) {
00596         printf ("%o%05o%o%05o%05o%05o",
00597                 x->sign, x->expo, x->coeff0 >> 13,
00598                 MASKR (15) & ((x->coeff0 << 2) | (x->coeff1 >> 14)),
00599                 MASKR (15) & ((x->coeff1 << 1) | (x->coeff2 >> 15)),
00600                 MASKR (15) & x->coeff2);
00601 }
00602 
00603 prcray128 (AR_CRAY_128 *x) {
00604         printf ("%o%05o%o%05o%05o%05o %o%05o%05o%05o",
00605                 x->sign, x->expo, x->coeff0 >> 13,
00606                 MASKR (15) & ((x->coeff0 << 2) | (x->coeff1 >> 14)),
00607                 MASKR (15) & ((x->coeff1 << 1) | (x->coeff2 >> 15)),
00608                 MASKR (15) & x->coeff2,
00609                 x->coeff3 >> 13,
00610                 MASKR (15) & ((x->coeff3 << 2) | (x->coeff4 >> 14)),
00611                 MASKR (15) & ((x->coeff4 << 1) | (x->coeff5 >> 15)),
00612                 MASKR (15) & x->coeff5);
00613 }
00614 
00615 print64 (AR_INT_64 *x) {
00616         printf ("%06o%o%05o%05o%05o",
00617                 x->part1,
00618                 x->part2 >> 13,
00619                 MASKR (15) & ((x->part2 << 2) | (x->part3 >> 14)),
00620                 MASKR (15) & ((x->part3 << 1) | (x->part4 >> 15)),
00621                 MASKR (15) & x->part4);
00622 }
00623 
00624 prieee64 (AR_IEEE_64 *x) {
00625         printf ("%o%05o%o%05o%05o%05o",
00626                 x->sign, (x->expo << 4) | x->coeff0, x->coeff1 >> 13,
00627                 MASKR (15) & ((x->coeff1 << 2) | (x->coeff2 >> 14)),
00628                 MASKR (15) & ((x->coeff2 << 1) | (x->coeff3 >> 15)),
00629                 MASKR (15) & x->coeff3);
00630 }
00631 
00632 prieee32 (AR_IEEE_32 *x) {
00633         printf ("%o%03o%02o%05o",
00634                 (x->sign << 1) | (x->expo >> 7),
00635                 MASKR (9) & ((x->expo << 2) | (x->coeff0 >> 5)),
00636                 MASKR (6) & ((x->coeff0 << 1) | (x->coeff1 >> 15)),
00637                 MASKR (15) & x->coeff1);
00638 }
00639 
00640 crayerr64_2 (char *lab,
00641              AR_CRAY_64 *x,
00642              AR_CRAY_64 *y,
00643              AR_CRAY_64 *ans,
00644              AR_CRAY_64 *res,
00645              int ansflags,
00646              int resflags) {
00647         printf ("%s (", lab);
00648         prcray64 (x);
00649         printf (", ");
00650         prcray64 (y);
00651         printf (")\n\t-> ");
00652         prcray64 (res);
00653         printf ("\n\t!= ");
00654         prcray64 (ans);
00655         printf (" (%o, %o)\n", ansflags, resflags);
00656 }
00657 
00658 crayerr64_1 (char *lab,
00659              AR_CRAY_64 *x,
00660              AR_CRAY_64 *ans,
00661              AR_CRAY_64 *res,
00662              int ansflags,
00663              int resflags) {
00664         printf ("%s (", lab);
00665         prcray64 (x);
00666         printf (")\n\t-> ");
00667         prcray64 (res);
00668         printf ("\n\t!= ");
00669         prcray64 (ans);
00670         printf (" (%o, %o)\n", ansflags, resflags);
00671 }
00672 
00673 crayerr64_i (char *lab,
00674              AR_CRAY_64 *x,
00675              AR_INT_64 *y,
00676              AR_CRAY_64 *ans,
00677              AR_CRAY_64 *res,
00678              int ansflags,
00679              int resflags) {
00680         printf ("%s (", lab);
00681         prcray64 (x);
00682         printf (", ");
00683         print64 (y);
00684         printf (")\n\t-> ");
00685         prcray64 (res);
00686         printf ("\n\t!= ");
00687         prcray64 (ans);
00688         printf (" (%o, %o)\n", ansflags, resflags);
00689 }
00690 
00691 crayerr64_i2 (char *lab,
00692               AR_INT_64 *x,
00693               AR_INT_64 *y,
00694               AR_INT_64 *ans,
00695               AR_INT_64 *res,
00696               int ansflags,
00697               int resflags) {
00698         printf ("%s (", lab);
00699         print64 (x);
00700         printf (", ");
00701         print64 (y);
00702         printf (")\n\t-> ");
00703         print64 (res);
00704         printf ("\n\t!= ");
00705         print64 (ans);
00706         printf (" (%o, %o)\n", ansflags, resflags);
00707 }
00708 
00709 crayerr128_2 (char *lab,
00710               AR_CRAY_128 *x,
00711               AR_CRAY_128 *y,
00712               AR_CRAY_128 *ans,
00713               AR_CRAY_128 *res,
00714               int ansflags,
00715               int resflags) {
00716         printf ("%s (", lab);
00717         prcray128 (x);
00718         printf (", ");
00719         prcray128 (y);
00720         printf (")\n\t-> ");
00721         prcray128 (res);
00722         printf ("\n\t!= ");
00723         prcray128 (ans);
00724         printf (" (%o, %o)\n", ansflags, resflags);
00725 }
00726 
00727 crayerr128_1 (char *lab,
00728               AR_CRAY_128 *x,
00729               AR_CRAY_128 *ans,
00730               AR_CRAY_128 *res,
00731               int ansflags,
00732               int resflags) {
00733         printf ("%s (", lab);
00734         prcray128 (x);
00735         printf (")\n\t-> ");
00736         prcray128 (res);
00737         printf ("\n\t!= ");
00738         prcray128 (ans);
00739         printf (" (%o, %o)\n", ansflags, resflags);
00740 }
00741 
00742 crayerr128_1a (char *lab,
00743                AR_INT_64 *x,
00744                AR_CRAY_128 *ans,
00745                AR_CRAY_128 *res,
00746                int ansflags,
00747                int resflags) {
00748         printf ("%s (", lab);
00749         print64 (x);
00750         printf (")\n\t-> ");
00751         prcray128 (res);
00752         printf ("\n\t!= ");
00753         prcray128 (ans);
00754         printf (" (%o, %o)\n", ansflags, resflags);
00755 }
00756 
00757 crayerr128_1b (char *lab,
00758                AR_CRAY_128 *x,
00759                AR_INT_64 *ans,
00760                AR_INT_64 *res,
00761                int ansflags,
00762                int resflags) {
00763         printf ("%s (", lab);
00764         prcray128 (x);
00765         printf (")\n\t-> ");
00766         print64 (res);
00767         printf ("\n\t!= ");
00768         print64 (ans);
00769         printf (" (%o, %o)\n", ansflags, resflags);
00770 }
00771 
00772 crayerr128_1c (char *lab,
00773                AR_CRAY_128 *x,
00774                AR_IEEE_64 *ans,
00775                AR_IEEE_64 *res,
00776                int ansflags,
00777                int resflags) {
00778         printf ("%s (", lab);
00779         prcray128 (x);
00780         printf (")\n\t-> ");
00781         prieee64 (res);
00782         printf ("\n\t!= ");
00783         prieee64 (ans);
00784         printf (" (%o, %o)\n", ansflags, resflags);
00785 }
00786 
00787 crayerr128_i (char *lab,
00788               AR_CRAY_128 *x,
00789               AR_INT_64 *y,
00790               AR_CRAY_128 *ans,
00791               AR_CRAY_128 *res,
00792               int ansflags,
00793               int resflags) {
00794         printf ("%s (", lab);
00795         prcray128 (x);
00796         printf (", ");
00797         print64 (y);
00798         printf (")\n\t-> ");
00799         prcray128 (res);
00800         printf ("\n\t!= ");
00801         prcray128 (ans);
00802         printf (" (%o, %o)\n", ansflags, resflags);
00803 }
00804 
00805 crayerr128_64 (char *lab,
00806                AR_CRAY_128 *x,
00807                AR_CRAY_64 *y,
00808                AR_CRAY_128 *ans,
00809                AR_CRAY_128 *res,
00810                int ansflags,
00811                int resflags) {
00812         printf ("%s (", lab);
00813         prcray128 (x);
00814         printf (", ");
00815         prcray64 (y);
00816         printf (")\n\t-> ");
00817         prcray128 (res);
00818         printf ("\n\t!= ");
00819         prcray128 (ans);
00820         printf (" (%o, %o)\n", ansflags, resflags);
00821 }
00822 
00823 ieeeerr64_2 (char *lab,
00824              AR_IEEE_64 *x,
00825              AR_IEEE_64 *y,
00826              AR_IEEE_64 *ans,
00827              AR_IEEE_64 *res,
00828              int ansflags,
00829              int resflags) {
00830         printf ("%s (", lab);
00831         prieee64 (x);
00832         printf (", ");
00833         prieee64 (y);
00834         printf (")\n\t-> ");
00835         prieee64 (res);
00836         printf ("\n\t!= ");
00837         prieee64 (ans);
00838         printf (" (%o, %o)\n", ansflags, resflags);
00839 }
00840 
00841 ieeeerr64_2c (char *lab,
00842              AR_CPLX_IEEE_64 *x,
00843              AR_CPLX_IEEE_64 *y,
00844              AR_CPLX_IEEE_64 *ans,
00845              AR_CPLX_IEEE_64 *res,
00846              int ansflags,
00847              int resflags) {
00848         printf ("%s (", lab);
00849         prieee64 (&x->real);
00850         prieee64 (&x->imag);
00851         printf (", ");
00852         prieee64 (&y->real);
00853         prieee64 (&y->imag);
00854         printf (")\n\t-> ");
00855         prieee64 (&res->real);
00856         prieee64 (&res->imag);
00857         printf ("\n\t!= ");
00858         prieee64 (&ans->real);
00859         prieee64 (&ans->imag);
00860         printf (" (%o, %o)\n", ansflags, resflags);
00861 }
00862 
00863 ieeeerr64_1 (char *lab,
00864              AR_IEEE_64 *x,
00865              AR_IEEE_64 *ans,
00866              AR_IEEE_64 *res,
00867              int ansflags,
00868              int resflags) {
00869         printf ("%s (", lab);
00870         prieee64 (x);
00871         printf (")\n\t-> ");
00872         prieee64 (res);
00873         printf ("\n\t!= ");
00874         prieee64 (ans);
00875         printf (" (%o, %o)\n", ansflags, resflags);
00876 }
00877 
00878 ieeeerr32_2 (char *lab,
00879              AR_IEEE_32 *x,
00880              AR_IEEE_32 *y,
00881              AR_IEEE_32 *ans,
00882              AR_IEEE_32 *res,
00883              int ansflags,
00884              int resflags) {
00885         printf ("%s (", lab);
00886         prieee32 (x);
00887         printf (", ");
00888         prieee32 (y);
00889         printf (")\n\t-> ");
00890         prieee32 (res);
00891         printf ("\n\t!= ");
00892         prieee32 (ans);
00893         printf (" (%o, %o)\n", ansflags, resflags);
00894 }
00895 
00896 ieeeerr32_2c (char *lab,
00897              AR_CPLX_IEEE_32 *x,
00898              AR_CPLX_IEEE_32 *y,
00899              AR_CPLX_IEEE_32 *ans,
00900              AR_CPLX_IEEE_32 *res,
00901              int ansflags,
00902              int resflags) {
00903         AR_IEEE_32 f;
00904         printf ("%s (", lab);
00905         f.sign = x->rsign;
00906         f.expo = x->rexpo;
00907         f.coeff0 = x->rcoeff0;
00908         f.coeff1 = x->rcoeff1;
00909         prieee32 (&f);
00910         printf (" ");
00911         f.sign = x->isign;
00912         f.expo = x->iexpo;
00913         f.coeff0 = x->icoeff0;
00914         f.coeff1 = x->icoeff1;
00915         prieee32 (&f);
00916         printf (", ");
00917         f.sign = y->rsign;
00918         f.expo = y->rexpo;
00919         f.coeff0 = y->rcoeff0;
00920         f.coeff1 = y->rcoeff1;
00921         prieee32 (&f);
00922         printf (" ");
00923         f.sign = y->isign;
00924         f.expo = y->iexpo;
00925         f.coeff0 = y->icoeff0;
00926         f.coeff1 = y->icoeff1;
00927         prieee32 (&f);
00928         printf (")\n\t-> ");
00929         f.sign = res->rsign;
00930         f.expo = res->rexpo;
00931         f.coeff0 = res->rcoeff0;
00932         f.coeff1 = res->rcoeff1;
00933         prieee32 (&f);
00934         printf (" ");
00935         f.sign = res->isign;
00936         f.expo = res->iexpo;
00937         f.coeff0 = res->icoeff0;
00938         f.coeff1 = res->icoeff1;
00939         prieee32 (&f);
00940         printf ("\n\t!= ");
00941         f.sign = ans->rsign;
00942         f.expo = ans->rexpo;
00943         f.coeff0 = ans->rcoeff0;
00944         f.coeff1 = ans->rcoeff1;
00945         prieee32 (&f);
00946         printf (" ");
00947         f.sign = ans->isign;
00948         f.expo = ans->iexpo;
00949         f.coeff0 = ans->icoeff0;
00950         f.coeff1 = ans->icoeff1;
00951         prieee32 (&f);
00952         printf (" (%o, %o)\n", ansflags, resflags);
00953 }
00954 
00955 ieeeerr32_1 (char *lab,
00956              AR_IEEE_32 *x,
00957              AR_IEEE_32 *ans,
00958              AR_IEEE_32 *res,
00959              int ansflags,
00960              int resflags) {
00961         printf ("%s (", lab);
00962         prieee32 (x);
00963         printf (")\n\t-> ");
00964         prieee32 (res);
00965         printf ("\n\t!= ");
00966         prieee32 (ans);
00967         printf (" (%o, %o)\n", ansflags, resflags);
00968 }
00969 
00970 interr64_1 (char *lab,
00971             AR_INT_64 *x,
00972             AR_INT_64 *ans,
00973             AR_INT_64 *res,
00974             int ansflags,
00975             int resflags) {
00976         printf ("%s (", lab);
00977         print64 (x);
00978         printf (")\n\t-> ");
00979         print64 (res);
00980         printf ("\n\t!= ");
00981         print64 (ans);
00982         printf (" (%o, %o)\n", ansflags, resflags);
00983 }
00984 
00985 
00986 /* Drivers */
00987 
00988 craytest64_2 (char *fn,
00989               char *lab,
00990               int (*op) (),
00991               int rounding,
00992               int *tests,
00993               int *failures) {
00994 
00995         int ansflags, resflags, i;
00996         AR_CRAY_64 res, x, y, ans;
00997         FILE *fp;
00998 
00999         if (fp = fopen (fn, "r")) {
01000                 for (i = 0; getcray64_2 (fp, &x, &y, &ans, &ansflags); i++) {
01001                         if(rounding < 0)
01002                                 resflags = op (&res, &x, &y);
01003                         else
01004                                 resflags = op (&res, &x, &y, rounding);
01005                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01006                                 ++*failures;
01007                                 crayerr64_2 (lab, &x, &y, &ans, &res,
01008                                                 ansflags, resflags);
01009                         }
01010                         ++*tests;
01011                 }
01012                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01013                 fclose (fp);
01014         } else {
01015                 printf ("can't open %s to test %s\n", fn, lab);
01016                 /* ++*failures; */
01017         }
01018 }
01019 
01020 craytest64_2t (char *fn,
01021                char *lab,
01022                int (*op) (),
01023                AR_TYPE type,
01024                int *tests,
01025                int *failures) {
01026 
01027         int ansflags, resflags, i;
01028         AR_CRAY_64 res, x, y, ans;
01029         FILE *fp;
01030 
01031         if (fp = fopen (fn, "r")) {
01032                 for (i = 0; getcray64_2 (fp, &x, &y, &ans, &ansflags); i++) {
01033                         resflags = op (&res, &type, &x, &type, &y, &type);
01034                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01035                                 ++*failures;
01036                                 crayerr64_2 (lab, &x, &y, &ans, &res,
01037                                                 ansflags, resflags);
01038                         }
01039                         ++*tests;
01040                 }
01041                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01042                 fclose (fp);
01043         } else {
01044                 printf ("can't open %s to test %s\n", fn, lab);
01045                 /* ++*failures; */
01046         }
01047 }
01048 
01049 craytest64_1 (char *fn,
01050               char *lab,
01051               int (*op) (),
01052               int rounding,
01053               int *tests,
01054               int *failures) {
01055 
01056         int ansflags, resflags, i;
01057         AR_CRAY_64 res, x, ans;
01058         FILE *fp;
01059 
01060         if (fp = fopen (fn, "r")) {
01061                 for (i = 0; getcray64_1 (fp, &x, &ans, &ansflags); i++) {
01062                         resflags = op (&res, &x, rounding);
01063                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01064                                 ++*failures;
01065                                 crayerr64_1 (lab, &x, &ans, &res,
01066                                              ansflags, resflags);
01067                         }
01068                         ++*tests;
01069                 }
01070                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01071                 fclose (fp);
01072         } else {
01073                 printf ("can't open %s to test %s\n", fn, lab);
01074                 /* ++*failures; */
01075         }
01076 }
01077 
01078 craytest64_1t (char *fn,
01079                char *lab,
01080                int (*op) (),
01081                AR_TYPE type,
01082                int *tests,
01083                int *failures) {
01084 
01085         int ansflags, resflags, i;
01086         AR_CRAY_64 res, x, ans;
01087         FILE *fp;
01088 
01089         if (fp = fopen (fn, "r")) {
01090                 for (i = 0; getcray64_1 (fp, &x, &ans, &ansflags); i++) {
01091                         resflags = op (&res, &type, &x, &type);
01092                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01093                                 ++*failures;
01094                                 crayerr64_1 (lab, &x, &ans, &res,
01095                                              ansflags, resflags);
01096                         }
01097                         ++*tests;
01098                 }
01099                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01100                 fclose (fp);
01101         } else {
01102                 printf ("can't open %s to test %s\n", fn, lab);
01103                 /* ++*failures; */
01104         }
01105 }
01106 
01107 craytest64_c (char *fn,
01108               char *lab,
01109               int (*op) (),
01110               AR_TYPE type1,
01111               AR_TYPE type2,
01112               int *tests,
01113               int *failures) {
01114 
01115         int ansflags, resflags, i;
01116         AR_CPLX_CRAY_64 x;
01117         AR_CRAY_64 res, ans;
01118         FILE *fp;
01119 
01120         if (fp = fopen (fn, "r")) {
01121                 for (i = 0; getcray64_2 (fp, &x.real, &x.imag, &ans, &ansflags); i++) {
01122                         resflags = op (&res, &type2, &x, &type1);
01123                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01124                                 ++*failures;
01125                                 crayerr64_2 (lab, &x.real, &x.imag, &ans, &res,
01126                                              ansflags, resflags);
01127                         }
01128                         ++*tests;
01129                 }
01130                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01131                 fclose (fp);
01132         } else {
01133                 printf ("can't open %s to test %s\n", fn, lab);
01134                 /* ++*failures; */
01135         }
01136 }
01137 
01138 craytest64_i (char *fn,
01139               char *lab,
01140               int (*op) (),
01141               AR_TYPE type,
01142               int *tests,
01143               int *failures) {
01144 
01145         int ansflags, resflags, i;
01146         AR_CRAY_64 res, x, ans;
01147         AR_INT_64 y;
01148         AR_TYPE inttype = AR_Int_64_S;
01149         FILE *fp;
01150 
01151         if (fp = fopen (fn, "r")) {
01152                 for (i = 0; getcray64_i (fp, &x, &y, &ans, &ansflags); i++) {
01153                         resflags = op (&res, &type, &x, &type, &y, &inttype);
01154                         if (!crayok64 (&ans, &res, ansflags, resflags)) {
01155                                 ++*failures;
01156                                 crayerr64_i (lab, &x, &y, &ans, &res,
01157                                                 ansflags, resflags);
01158                         }
01159                         ++*tests;
01160                 }
01161                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01162                 fclose (fp);
01163         } else {
01164                 printf ("can't open %s to test %s\n", fn, lab);
01165                 /* ++*failures; */
01166         }
01167 }
01168 
01169 craytest64_i2 (char *fn,
01170                char *lab,
01171                int (*op) (),
01172                AR_TYPE type,
01173                int *tests,
01174                int *failures) {
01175 
01176         int ansflags, resflags, i;
01177         AR_INT_64 res, x, y, ans;
01178         FILE *fp;
01179 
01180         if (fp = fopen (fn, "r")) {
01181                 for (i = 0; getcray64_i2 (fp, &x, &y, &ans, &ansflags); i++) {
01182                         resflags = op (&res, &type, &x, &type, &y, &type);
01183                         if (!crayok64i (&ans, &res, ansflags, resflags)) {
01184                                 ++*failures;
01185                                 crayerr64_i2 (lab, &x, &y, &ans, &res,
01186                                                 ansflags, resflags);
01187                         }
01188                         ++*tests;
01189                 }
01190                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01191                 fclose (fp);
01192         } else {
01193                 printf ("can't open %s to test %s\n", fn, lab);
01194                 /* ++*failures; */
01195         }
01196 }
01197 
01198 craytest128_64 (char *fn,
01199                 char *lab,
01200                 int (*op) (),
01201                 AR_TYPE type1,
01202                 AR_TYPE type2,
01203                 int *tests,
01204                 int *failures) {
01205 
01206         int ansflags, resflags, i;
01207         AR_CRAY_128 res, x, ans;
01208         AR_CRAY_64 y;
01209         FILE *fp;
01210 
01211         if (fp = fopen (fn, "r")) {
01212                 for (i = 0; getcray128_64 (fp, &x, &y, &ans, &ansflags); i++) {
01213                         resflags = op (&res, &type1, &x, &type1, &y, &type2);
01214                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01215                                 ++*failures;
01216                                 crayerr128_64 (lab, &x, &y, &ans, &res,
01217                                                 ansflags, resflags);
01218                         }
01219                         ++*tests;
01220                 }
01221                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01222                 fclose (fp);
01223         } else {
01224                 printf ("can't open %s to test %s\n", fn, lab);
01225                 /* ++*failures; */
01226         }
01227 }
01228 
01229 craytest128_2t (char *fn,
01230                 char *lab,
01231                 int (*op) (),
01232                 AR_TYPE type,
01233                 int *tests,
01234                 int *failures) {
01235 
01236         int ansflags, resflags, i;
01237         AR_CRAY_128 res, x, y, ans;
01238         FILE *fp;
01239 
01240         if (fp = fopen (fn, "r")) {
01241                 for (i = 0; getcray128_2 (fp, &x, &y, &ans, &ansflags); i++) {
01242                         resflags = op (&res, &type, &x, &type, &y, &type);
01243                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01244                                 ++*failures;
01245                                 crayerr128_2 (lab, &x, &y, &ans, &res,
01246                                                 ansflags, resflags);
01247                         }
01248                         ++*tests;
01249                 }
01250                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01251                 fclose (fp);
01252         } else {
01253                 printf ("can't open %s to test %s\n", fn, lab);
01254                 /* ++*failures; */
01255         }
01256 }
01257 
01258 craytest128_1 (char *fn,
01259                char *lab,
01260                int (*op) (),
01261                int rounding,
01262                int *tests,
01263                int *failures) {
01264 
01265         int ansflags, resflags, i;
01266         AR_CRAY_128 res, x, ans;
01267         FILE *fp;
01268 
01269         if (fp = fopen (fn, "r")) {
01270                 for (i = 0; getcray128_1 (fp, &x, &ans, &ansflags); i++) {
01271                         resflags = op (&res, &x, rounding);
01272                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01273                                 ++*failures;
01274                                 crayerr128_1 (lab, &x, &ans, &res,
01275                                                 ansflags, resflags);
01276                         }
01277                         ++*tests;
01278                 }
01279                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01280                 fclose (fp);
01281         } else {
01282                 printf ("can't open %s to test %s\n", fn, lab);
01283                 /* ++*failures; */
01284         }
01285 }
01286 
01287 craytest128_1t (char *fn,
01288                 char *lab,
01289                 int (*op) (),
01290                 AR_TYPE type,
01291                 int *tests,
01292                 int *failures) {
01293 
01294         int ansflags, resflags, i;
01295         AR_CRAY_128 res, x, ans;
01296         FILE *fp;
01297 
01298         if (fp = fopen (fn, "r")) {
01299                 for (i = 0; getcray128_1 (fp, &x, &ans, &ansflags); i++) {
01300                         resflags = op (&res, &type, &x, &type);
01301                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01302                                 ++*failures;
01303                                 crayerr128_1 (lab, &x, &ans, &res,
01304                                                 ansflags, resflags);
01305                         }
01306                         ++*tests;
01307                 }
01308                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01309                 fclose (fp);
01310         } else {
01311                 printf ("can't open %s to test %s\n", fn, lab);
01312                 /* ++*failures; */
01313         }
01314 }
01315 
01316 craytest128_i (char *fn,
01317                char *lab,
01318                int (*op) (),
01319                AR_TYPE type,
01320                int *tests,
01321                int *failures) {
01322 
01323         int ansflags, resflags, i;
01324         AR_CRAY_128 res, x, ans;
01325         AR_INT_64 y;
01326         AR_TYPE inttype = AR_Int_64_S;
01327         FILE *fp;
01328 
01329         if (fp = fopen (fn, "r")) {
01330                 for (i = 0; getcray128_i (fp, &x, &y, &ans, &ansflags); i++) {
01331                         resflags = op (&res, &type, &x, &type, &y, &inttype);
01332                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01333                                 ++*failures;
01334                                 crayerr128_i (lab, &x, &y, &ans, &res,
01335                                                 ansflags, resflags);
01336                         }
01337                         ++*tests;
01338                 }
01339                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01340                 fclose (fp);
01341         } else {
01342                 printf ("can't open %s to test %s\n", fn, lab);
01343                 /* ++*failures; */
01344         }
01345 }
01346 
01347 ieeetest64_2c (char *fn,
01348                char *lab,
01349                int (*op) (),
01350                AR_TYPE type,
01351                int *tests,
01352                int *failures) {
01353 
01354         int ansflags, resflags, i;
01355         AR_CPLX_IEEE_64 res, x, y, ans;
01356         FILE *fp;
01357 
01358         if (fp = fopen (fn, "r")) {
01359                 for (i = 0; getieee64_2c (fp, &x, &y, &ans, &ansflags); i++) {
01360                         resflags = op (&res, &type, &x, &type, &y, &type);
01361                         if (!ieeeok64(&ans.real, &res.real, ansflags,resflags) ||
01362                             !ieeeok64(&ans.imag, &res.imag, ansflags,resflags)) {
01363                                 ++*failures;
01364                                 ieeeerr64_2c (lab, &x, &y, &ans, &res,
01365                                                 ansflags, resflags);
01366                         }
01367                         ++*tests;
01368                 }
01369                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01370                 fclose (fp);
01371         } else {
01372                 printf ("can't open %s to test %s\n", fn, lab);
01373                 /* ++*failures; */
01374         }
01375 }
01376 
01377 ieeetest64_2cmp (char *fn,
01378                char *lab,
01379                AR_COMPARE_TYPE (*op) (),
01380                AR_TYPE type,
01381                int *tests,
01382                int *failures) {
01383 
01384         int ansflags, resflags, i;
01385         AR_IEEE_64 x, y, ans;
01386         FILE *fp;
01387 
01388         if (fp = fopen (fn, "r")) {
01389                 for (i = 0; getieee64_2 (fp, &x, &y, &ans, &ansflags); i++) {
01390                         resflags = op (&x, &type, &y, &type);
01391                         switch (resflags) {
01392                         case AR_Compare_LT:
01393                                 resflags = AR_STAT_NEGATIVE;
01394                                 break;
01395                         case AR_Compare_EQ:
01396                                 resflags = AR_STAT_ZERO;
01397                                 break;
01398                         case AR_Compare_GT:
01399                                 resflags = AR_STAT_OK;
01400                                 break;
01401                         case AR_Compare_Unord:
01402                                 resflags = AR_STAT_UNDEFINED;
01403                                 break;
01404                         }
01405                         if (!ieeeok64 (&ans, &ans, ansflags, resflags)) {
01406                                 ++*failures;
01407                                 ieeeerr64_2 (lab, &x, &y, &ans, &ans,
01408                                                 ansflags, resflags);
01409                         }
01410                         ++*tests;
01411                 }
01412                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01413                 fclose (fp);
01414         } else {
01415                 printf ("can't open %s to test %s\n", fn, lab);
01416                 /* ++*failures; */
01417         }
01418 }
01419 
01420 ieeetest64_2t (char *fn,
01421                char *lab,
01422                int (*op) (),
01423                AR_TYPE type,
01424                int *tests,
01425                int *failures) {
01426 
01427         int ansflags, resflags, i;
01428         AR_IEEE_64 res, x, y, ans;
01429         FILE *fp;
01430 
01431         if (fp = fopen (fn, "r")) {
01432                 for (i = 0; getieee64_2 (fp, &x, &y, &ans, &ansflags); i++) {
01433                         resflags = op (&res, &type, &x, &type, &y, &type);
01434                         if (!ieeeok64 (&ans, &res, ansflags, resflags)) {
01435                                 ++*failures;
01436                                 ieeeerr64_2 (lab, &x, &y, &ans, &res,
01437                                                 ansflags, resflags);
01438                         }
01439                         ++*tests;
01440                 }
01441                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01442                 fclose (fp);
01443         } else {
01444                 printf ("can't open %s to test %s\n", fn, lab);
01445                 /* ++*failures; */
01446         }
01447 }
01448 
01449 ieeetest64_1t (char *fn,
01450                char *lab,
01451                int (*op) (),
01452                AR_TYPE type,
01453                int *tests,
01454                int *failures) {
01455 
01456         int ansflags, resflags, i;
01457         AR_IEEE_64 res, x, ans;
01458         FILE *fp;
01459 
01460         if (fp = fopen (fn, "r")) {
01461                 for (i = 0; getieee64_1 (fp, &x, &ans, &ansflags); i++) {
01462                         resflags = op (&res, &type, &x, &type);
01463                         if (!ieeeok64 (&ans, &res, ansflags, resflags)) {
01464                                 ++*failures;
01465                                 ieeeerr64_1 (lab, &x, &ans, &res,
01466                                                 ansflags, resflags);
01467                         }
01468                         ++*tests;
01469                 }
01470                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01471                 fclose (fp);
01472         } else {
01473                 printf ("can't open %s to test %s\n", fn, lab);
01474                 /* ++*failures; */
01475         }
01476 }
01477 
01478 ieeetest32_2c (char *fn,
01479                char *lab,
01480                int (*op) (),
01481                AR_TYPE type,
01482                int *tests,
01483                int *failures) {
01484 
01485         int ansflags, resflags, i;
01486         AR_CPLX_IEEE_32 res, x, y, ans;
01487         FILE *fp;
01488 
01489         if (fp = fopen (fn, "r")) {
01490                 for (i = 0; getieee32_2c (fp, &x, &y, &ans, &ansflags); i++) {
01491                         resflags = op (&res, &type, &x, &type, &y, &type);
01492                         if (!ieeeok64((AR_IEEE_64*)&ans, (AR_IEEE_64*)&res, ansflags, resflags)) {
01493                                 ++*failures;
01494                                 ieeeerr32_2c (lab, &x, &y, &ans, &res,
01495                                                 ansflags, resflags);
01496                         }
01497                         ++*tests;
01498                 }
01499                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01500                 fclose (fp);
01501         } else {
01502                 printf ("can't open %s to test %s\n", fn, lab);
01503                 /* ++*failures; */
01504         }
01505 }
01506 
01507 ieeetest32_2cmp (char *fn,
01508                char *lab,
01509                AR_COMPARE_TYPE (*op) (),
01510                AR_TYPE type,
01511                int *tests,
01512                int *failures) {
01513 
01514         int ansflags, resflags, i;
01515         AR_IEEE_32 x, y, ans;
01516         FILE *fp;
01517 
01518         if (fp = fopen (fn, "r")) {
01519                 for (i = 0; getieee32_2 (fp, &x, &y, &ans, &ansflags); i++) {
01520                         resflags = op (&x, &type, &y, &type);
01521                         switch (resflags) {
01522                         case AR_Compare_LT:
01523                                 resflags = AR_STAT_NEGATIVE;
01524                                 break;
01525                         case AR_Compare_EQ:
01526                                 resflags = AR_STAT_ZERO;
01527                                 break;
01528                         case AR_Compare_GT:
01529                                 resflags = AR_STAT_OK;
01530                                 break;
01531                         case AR_Compare_Unord:
01532                                 resflags = AR_STAT_UNDEFINED;
01533                                 break;
01534                         }
01535                         if (!ieeeok32 (&ans, &ans, ansflags, resflags)) {
01536                                 ++*failures;
01537                                 ieeeerr32_2 (lab, &x, &y, &ans, &ans,
01538                                                 ansflags, resflags);
01539                         }
01540                         ++*tests;
01541                 }
01542                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01543                 fclose (fp);
01544         } else {
01545                 printf ("can't open %s to test %s\n", fn, lab);
01546                 /* ++*failures; */
01547         }
01548 }
01549 
01550 ieeetest32_2t (char *fn,
01551                char *lab,
01552                int (*op) (),
01553                AR_TYPE type,
01554                int *tests,
01555                int *failures) {
01556 
01557         int ansflags, resflags, i;
01558         AR_IEEE_32 res, x, y, ans;
01559         FILE *fp;
01560 
01561         if (fp = fopen (fn, "r")) {
01562                 for (i = 0; getieee32_2 (fp, &x, &y, &ans, &ansflags); i++) {
01563                         resflags = op (&res, &type, &x, &type, &y, &type);
01564                         if (!ieeeok32 (&ans, &res, ansflags, resflags)) {
01565                                 ++*failures;
01566                                 ieeeerr32_2 (lab, &x, &y, &ans, &res,
01567                                                 ansflags, resflags);
01568                         }
01569                         ++*tests;
01570                 }
01571                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01572                 fclose (fp);
01573         } else {
01574                 printf ("can't open %s to test %s\n", fn, lab);
01575                 /* ++*failures; */
01576         }
01577 }
01578 
01579 ieeetest32_1t (char *fn,
01580                char *lab,
01581                int (*op) (),
01582                AR_TYPE type,
01583                int *tests,
01584                int *failures) {
01585 
01586         int ansflags, resflags, i;
01587         AR_IEEE_32 res, x, ans;
01588         FILE *fp;
01589 
01590         if (fp = fopen (fn, "r")) {
01591                 for (i = 0; getieee32_1 (fp, &x, &ans, &ansflags); i++) {
01592                         resflags = op (&res, &type, &x, &type);
01593                         if (!ieeeok32 (&ans, &res, ansflags, resflags)) {
01594                                 ++*failures;
01595                                 ieeeerr32_1 (lab, &x, &ans, &res,
01596                                                 ansflags, resflags);
01597                         }
01598                         ++*tests;
01599                 }
01600                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01601                 fclose (fp);
01602         } else {
01603                 printf ("can't open %s to test %s\n", fn, lab);
01604                 /* ++*failures; */
01605         }
01606 }
01607 
01608 
01609 /* Random testing with native hardware */
01610 
01611 #ifdef _CRAY
01612 
01613 crayrand64_2 (char *lab,
01614               int (*simop) (),
01615               int rounding,
01616               void (*realop) (),
01617               int *tests,
01618               int *lowp,
01619               int *highp) {
01620 
01621         int i, simflags, realflags, low = 0, high = 0;
01622         float x, y, sim, real;
01623 
01624         for (i = 0; i < RAND_ITERS; i++) {
01625                 x = (RANF()-0.5)*i*100;
01626                 y = (RANF()-0.5)*i*100;
01627                 fp_error = 0;
01628                 realop (&real, &x, &y);
01629                 realflags = !!fp_error;
01630                 if(rounding < 0)
01631                         simflags = simop (&sim, &x, &y);
01632                 else
01633                         simflags = simop (&sim, &x, &y, rounding);
01634                 if (sim != real)
01635                         printf ("rand test of %s (%022o, %022o)\n\t->%022o\n\t!=%022o (%d, %d)\n",
01636                                 lab, x, y, sim, real, realflags, simflags);
01637                 if (sim < real)
01638                         low++;
01639                 else if (sim != real)
01640                         high++;
01641                 ++*tests;
01642         }
01643 
01644         printf ("end %d random tests of %s: %d results low, %d high\n",
01645                 i, lab, low, high);
01646         *lowp += low;
01647         *highp += high;
01648 }
01649 
01650 crayrand64_1 (char *lab,
01651               int (*simop) (),
01652               int rounding,
01653               void (*realop) (),
01654               int *tests,
01655               int *lowp,
01656               int *highp) {
01657 
01658         int i, simflags, realflags, low = 0, high = 0;
01659         float x, sim, real;
01660 
01661         for (i = 0; i < RAND_ITERS; i++) {
01662                 x = (RANF()-0.5)*i*100;
01663                 fp_error = 0;
01664                 realop (&real, &x);
01665                 realflags = !!fp_error;
01666                 simflags = simop (&sim, &x, rounding);
01667                 if (sim != real)
01668                         printf ("rand test of %s (%022o)\n\t->%022o\n\t!=%022o (%d, %d)\n",
01669                                 lab, x, sim, real, realflags, simflags);
01670                 if (sim < real)
01671                         low++;
01672                 else if (sim != real)
01673                         high++;
01674                 ++*tests;
01675         }
01676 
01677         printf ("end %d random tests of %s: %d results low, %d high\n",
01678                 i, lab, low, high);
01679         *lowp += low;
01680         *highp += high;
01681 }
01682 
01683 crayrand128_2 (char *lab,
01684                int (*simop) (),
01685                int rounding,
01686                void (*realop) (),
01687                int *tests,
01688                int *lowp,
01689                int *highp) {
01690 
01691         int i, simflags, realflags, low = 0, high = 0;
01692         long double x, y, sim, real;
01693 
01694         for (i = 0; i < RAND_ITERS; i++) {
01695                 x = (long double) (RANF()-0.5)*i*100 -
01696                         (long double) RANF () * 1.0e-19;
01697                 y = (long double) (RANF()-0.5)*i*100 +
01698                         (long double) RANF () * 1.0e-19;
01699                 fp_error = 0;
01700                 realop (&real, &x, &y);
01701                 realflags = !!fp_error;
01702                 if(rounding < 0)
01703                         simflags = simop (&sim, &x, &y);
01704                 else
01705                         simflags = simop (&sim, &x, &y, rounding);
01706                 if (sim < real)
01707                         low++;
01708                 else if (sim != real)
01709                         high++;
01710                 ++*tests;
01711         }
01712 
01713         printf ("end %d random tests of %s: %d results low, %d high\n",
01714                 i, lab, low, high);
01715         *lowp += low;
01716         *highp += high;
01717 }
01718 
01719 crayrandcplx (char *lab,
01720               int (*simop) (),
01721               AR_TYPE cplxtype,
01722               void (*realop) (),
01723               int *tests,
01724               int *badp) {
01725 
01726         int i, simflags, realflags, bad = 0;
01727         double complex x, y, sim, real;
01728 
01729         for (i = 0; i < RAND_ITERS; i++) {
01730                 x = (RANF()-0.5)*i*100;
01731                 y = (RANF()-0.5)*i*100;
01732                 if (i) {
01733                         x += 0.0i * RANF ();
01734                         y += 0.0i * RANF ();
01735                 }
01736                 fp_error = 0;
01737                 realop (&real, &x, &y);
01738                 realflags = !!fp_error;
01739                 simflags = simop (&sim, &cplxtype,
01740                                   &x, &cplxtype,
01741                                   &y, &cplxtype);
01742                 if (sim != real ||
01743                     realflags != !!(simflags & AR_ERR)) {
01744                         printf ("rand test of %s ((%022o,%022o),(%022o,%022o))\n\t->(%022o,%022o)\n\t!=(%022o,%022o) (%d, %d)\n",
01745                                 lab, x, y, sim, real, realflags, simflags);
01746                         bad++;
01747                 }
01748                 ++*tests;
01749         }
01750 
01751         printf ("end %d random tests of %s: %d results bad\n", i, lab, bad);
01752         *badp += bad;
01753 }
01754 
01755 
01756 #else
01757 
01758 
01759 ieeerand128_2 (char *lab,
01760               int (*simop) (),
01761               int rounding,
01762               void (*realop) (),
01763               int *tests,
01764               int *lowp,
01765               int *highp) {
01766 
01767         int i, simflags, realflags, low = 0, high = 0;
01768         long double x, y, sim, real;
01769 
01770         for (i = 0; i < RAND_ITERS; i++) {
01771                 x = (long double)((drand48()-0.5)*i*100 - 1.0e-19 * drand48());
01772                 y = (long double)((drand48()-0.5)*i*100 + 1.0e-19 * drand48());
01773                 fp_error = 0;
01774                 realop (&real, &x, &y);
01775                 realflags = !!fp_error;
01776                 simflags = simop (&sim, &x, &y, rounding);
01777                 if (sim != real) {
01778                         printf ("rand test of %s\n\t(%011lo %011lo %011lo %011lo,\n\t %011lo %011lo %011lo %011lo)\n\t->%011lo %011lo %011lo %011lo\n\t!=%011lo %011lo %011lo %011lo (%d, %d)\n",
01779                                 lab, x, y, sim, real, realflags, simflags);
01780                         if (sim < real)
01781                                 low++;
01782                         else
01783                                 high++;
01784                 }
01785                 ++*tests;
01786         }
01787 
01788         printf ("end %d random tests of %s: %d results low, %d high\n",
01789                 i, lab, low, high);
01790         *lowp += low;
01791         *highp += high;
01792 }
01793 
01794 ieeerand64_2 (char *lab,
01795               int (*simop) (),
01796               int rounding,
01797               void (*realop) (),
01798               int *tests,
01799               int *lowp,
01800               int *highp) {
01801 
01802         int i, simflags, realflags, low = 0, high = 0;
01803         double x, y, sim, real;
01804 
01805         for (i = 0; i < RAND_ITERS; i++) {
01806                 x = (drand48()-0.5)*i*100 - 1.0e-19 * drand48 ();
01807                 y = (drand48()-0.5)*i*100 + 1.0e-19 * drand48 ();
01808                 fp_error = 0;
01809                 realop (&real, &x, &y);
01810                 realflags = !!fp_error;
01811                 simflags = simop (&sim, &x, &y, rounding);
01812                 if (sim != real)
01813                         printf ("rand test of %s (%011lo %011lo, %011lo %011lo)\n\t->%011lo %011lo\n\t!=%011lo %011lo (%d, %d)\n",
01814                                 lab, x, y, sim, real, realflags, simflags);
01815                 if (sim < real)
01816                         low++;
01817                 else if (sim != real)
01818                         high++;
01819                 ++*tests;
01820         }
01821 
01822         printf ("end %d random tests of %s: %d results low, %d high\n",
01823                 i, lab, low, high);
01824         *lowp += low;
01825         *highp += high;
01826 }
01827 
01828 ieeerand32_2 (char *lab,
01829               int (*simop) (),
01830               int rounding,
01831               void (*realop) (),
01832               int *tests,
01833               int *lowp,
01834               int *highp) {
01835 
01836         int i, simflags, realflags, low = 0, high = 0;
01837         struct floatstruct { float UNUSED; float f; };
01838         struct floatstruct x, y, sim, real;
01839 
01840         for (i = 0; i < RAND_ITERS; i++) {
01841                 x.f = (drand48()-0.5)*i*100-1.0e-19;
01842                 y.f = (drand48()-0.5)*i*100+1.0e-19;
01843                 fp_error = 0;
01844                 realop (&real.f, &x.f, &y.f);
01845                 realflags = !!fp_error;
01846                 simflags = simop (&sim, &x, &y, rounding);
01847                 if (sim.f != real.f)
01848                         printf ("rand test of %s (%011lo, %011lo)\n\t->%011lo\n\t!=%011lo (%d, %d)\n",
01849                                 lab, *(unsigned long *)&x.f,
01850                                 *(unsigned long *)&y.f, *(unsigned long *)&sim.f,
01851                                 *(unsigned long *)&real.f, realflags, simflags);
01852                 if (sim.f < real.f)
01853                         low++;
01854                 else if (sim.f != real.f)
01855                         high++;
01856                 ++*tests;
01857         }
01858 
01859         printf ("end %d random tests of %s: %d results low, %d high\n",
01860                 i, lab, low, high);
01861         *lowp += low;
01862         *highp += high;
01863 }
01864 
01865 #endif
01866 
01867 
01868 /* Conversion tests */
01869 
01870 convtest64 (char *fn,
01871             char *lab,
01872             int (*op) (),
01873             int opt1, int opt2,
01874             int *tests,
01875             int *failures) {
01876 
01877         int ansflags, resflags, i;
01878         AR_INT_64 x, ans, res;
01879         FILE *fp;
01880 
01881         if (fp = fopen (fn, "r")) {
01882                 for (i = 0; getint64_1 (fp, &x, &ans, &ansflags); i++) {
01883                         resflags = op (&res, &x, opt1, opt2);
01884                         if (!intok64 (&ans, &res, ansflags, resflags)) {
01885                                 ++*failures;
01886                                 interr64_1 (lab, &x, &ans, &res,
01887                                                 ansflags, resflags);
01888                         }
01889                         ++*tests;
01890                 }
01891                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01892                 fclose (fp);
01893         } else {
01894                 printf ("can't open %s to test %s\n", fn, lab);
01895                 /* ++*failures; */
01896         }
01897 }
01898 
01899 convtest128a (char *fn,
01900               char *lab,
01901               int (*op) (),
01902               int opt,
01903               int *tests,
01904               int *failures) {
01905 
01906         int ansflags, resflags, i;
01907         AR_INT_64 x;
01908         AR_CRAY_128 ans, res;
01909         FILE *fp;
01910 
01911         if (fp = fopen (fn, "r")) {
01912                 for (i = 0; getcray128_1a (fp, &x, &ans, &ansflags); i++) {
01913                         resflags = op (&res, &x, opt);
01914                         if (!crayok128 (&ans, &res, ansflags, resflags)) {
01915                                 ++*failures;
01916                                 crayerr128_1a (lab, &x, &ans, &res,
01917                                                 ansflags, resflags);
01918                         }
01919                         ++*tests;
01920                 }
01921                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01922                 fclose (fp);
01923         } else {
01924                 printf ("can't open %s to test %s\n", fn, lab);
01925                 /* ++*failures; */
01926         }
01927 }
01928 
01929 convtest128b (char *fn,
01930               char *lab,
01931               int (*op) (),
01932               int opt,
01933               int *tests,
01934               int *failures) {
01935 
01936         int ansflags, resflags, i;
01937         AR_CRAY_128 x;
01938         AR_INT_64 ans, res;
01939         FILE *fp;
01940 
01941         if (fp = fopen (fn, "r")) {
01942                 for (i = 0; getcray128_1b (fp, &x, &ans, &ansflags); i++) {
01943                         resflags = op (&res, &x, opt);
01944                         if (!intok64 (&ans, &res, ansflags, resflags)) {
01945                                 ++*failures;
01946                                 crayerr128_1b (lab, &x, &ans, &res,
01947                                                 ansflags, resflags);
01948                         }
01949                         ++*tests;
01950                 }
01951                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01952                 fclose (fp);
01953         } else {
01954                 printf ("can't open %s to test %s\n", fn, lab);
01955                 /* ++*failures; */
01956         }
01957 }
01958 
01959 convtest128c (char *fn,
01960               char *lab,
01961               int (*op) (),
01962               int opt,
01963               int *tests,
01964               int *failures) {
01965 
01966         int ansflags, resflags, i;
01967         AR_CRAY_128 x;
01968         AR_IEEE_64 ans, res;
01969         FILE *fp;
01970 
01971         if (fp = fopen (fn, "r")) {
01972                 for (i = 0; getcray128_1c (fp, &x, &ans, &ansflags); i++) {
01973                         resflags = op (&res, &x, opt);
01974                         if (!ieeeok64 (&ans, &res, ansflags, resflags)) {
01975                                 ++*failures;
01976                                 crayerr128_1c (lab, &x, &ans, &res,
01977                                                 ansflags, resflags);
01978                         }
01979                         ++*tests;
01980                 }
01981                 printf ("end %d tests of %s from %s\n", i, lab, fn);
01982                 fclose (fp);
01983         } else {
01984                 printf ("can't open %s to test %s\n", fn, lab);
01985                 /* ++*failures; */
01986         }
01987 }
01988 
01989 AR_TYPE  inttype;
01990 static  misc_errors = 0;
01991 
01992 misc_tests(int *failures) {
01993         ar_data result;
01994         ar_data precision = {0,0,0,12};
01995         ar_data range = {0,0,0,2000};
01996 
01997         /* Determine target's native integer size */
01998         inttype = AR_Int_32_S;
01999         if(AR_selected_real_kind((AR_DATA*)&result, &inttype,
02000                                                          (AR_DATA*)&precision, &inttype,
02001                                                          (AR_DATA*)&range, &inttype)&AR_STAT_INVALID_TYPE) {
02002                 inttype = AR_Int_64_S;
02003                 if(AR_selected_real_kind((AR_DATA*)&result, &inttype,
02004                                                                  (AR_DATA*)&precision, &inttype,
02005                                                                  (AR_DATA*)&range, &inttype) & AR_STAT_INVALID_TYPE) {
02006                         fprintf(stderr, "Cannot determine target int type\n");
02007                         failures++;
02008                         return;
02009                 }
02010                 if(result.ar_i64.part4 == 0xfffe)
02011                         printf("Target is a 64-bit IEEE system\n");
02012                 else
02013                         printf("Target is a 64-bit PVP system\n");
02014         }
02015         else
02016                 printf("Target is a 32-bit sparc system\n");
02017 
02018         t_index();
02019         t_scan();
02020         t_verify();
02021 
02022         *failures += misc_errors;
02023 }
02024 
02025 t_index()
02026 {
02027         char str1[] = "abcdefghijklmnopqrstuvwxyz";
02028 
02029         int     status;
02030 
02031         ar_data result;
02032         AR_DATA backward;
02033 
02034         ar_data len1 = {0,0,0,26};
02035         ar_data len2 = {0,0,0,0};
02036 
02037         AR_TYPE backtype = AR_Logical;
02038 
02039         printf("Testing AR_index\n");
02040 
02041         len2.ar_i64.part4 = 3;
02042         status = AR_index((AR_DATA*)&result, &inttype,
02043                                 str1, (AR_DATA*)&len1, &inttype,
02044                            "fgh", (AR_DATA*)&len2, &inttype,
02045                                 NULL, NULL);
02046         validate(status, 0, result.ar_i64.part4, 6);
02047 
02048         len2.ar_i64.part4 = 4;
02049         status = AR_index((AR_DATA*)&result, &inttype,
02050                                 str1, (AR_DATA*)&len1, &inttype,
02051                           "fgh0", (AR_DATA*)&len2, &inttype,
02052                                 NULL, NULL);
02053         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02054 
02055         len2.ar_i64.part4 = 0;
02056         status = AR_index((AR_DATA*)&result, &inttype,
02057                                 str1, (AR_DATA*)&len1, &inttype,
02058                                   "", (AR_DATA*)&len2, &inttype,
02059                                 NULL, NULL);
02060         validate(status, 0, result.ar_i64.part4, 1);
02061 
02062         len1.ar_i64.part4 = 0;
02063         len2.ar_i64.part4 = 3;
02064         status = AR_index((AR_DATA*)&result, &inttype,
02065                                   "", (AR_DATA*)&len1, &inttype,
02066                            "fgh", (AR_DATA*)&len2, &inttype,
02067                                 NULL, NULL);
02068         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02069 
02070         len2.ar_i64.part4 = 0;
02071         status = AR_index((AR_DATA*)&result, &inttype,
02072                                   "", (AR_DATA*)&len1, &inttype,
02073                                   "", (AR_DATA*)&len2, &inttype,
02074                                 NULL, NULL);
02075         validate(status, 0, result.ar_i64.part4, 1);
02076 
02077         len1.ar_i64.part4 = 26;
02078         len2.ar_i64.part4 = 1;
02079         status = AR_index((AR_DATA*)&result, &inttype,
02080                                 str1, (AR_DATA*)&len1, &inttype,
02081                                  "z", (AR_DATA*)&len2, &inttype,
02082                                 NULL, NULL);
02083         validate(status, 0, result.ar_i64.part4, 26);
02084 
02085         len2.ar_i64.part4 = 1;
02086         status = AR_index((AR_DATA*)&result, &inttype,
02087                                 str1, (AR_DATA*)&len1, &inttype,
02088                                  "a", (AR_DATA*)&len2, &inttype,
02089                                 NULL, NULL);
02090         validate(status, 0, result.ar_i64.part4, 1);
02091 
02092         backward = AR_const_false;
02093         len2.ar_i64.part4 = 2;
02094         status = AR_index((AR_DATA*)&result, &inttype,
02095                                 str1, (AR_DATA*)&len1, &inttype,
02096                                 "jk", (AR_DATA*)&len2, &inttype,
02097                                 (AR_DATA*)&backward, &backtype);
02098         validate(status, 0, result.ar_i64.part4, 10);
02099 
02100         backward = AR_const_true;
02101         len2.ar_i64.part4 = 2;
02102         status = AR_index((AR_DATA*)&result, &inttype,
02103                                 str1, (AR_DATA*)&len1, &inttype,
02104                                 "jk", (AR_DATA*)&len2, &inttype,
02105                                 (AR_DATA*)&backward, &backtype);
02106         validate(status, 0, result.ar_i64.part4, 10);
02107 
02108         backward = AR_const_true;
02109         len2.ar_i64.part4 = 1;
02110         status = AR_index((AR_DATA*)&result, &inttype,
02111                                 str1, (AR_DATA*)&len1, &inttype,
02112                                  "x", (AR_DATA*)&len2, &inttype,
02113                                 (AR_DATA*)&backward, &backtype);
02114         validate(status, 0, result.ar_i64.part4, 24);
02115 
02116         backward = AR_const_true;
02117         len2.ar_i64.part4 = 3;
02118         status = AR_index((AR_DATA*)&result, &inttype,
02119                                 str1, (AR_DATA*)&len1, &inttype,
02120                            "jrk", (AR_DATA*)&len2, &inttype,
02121                                 (AR_DATA*)&backward, &backtype);
02122         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02123 
02124         backward = AR_const_true;
02125         len2.ar_i64.part4 = 0;
02126         status = AR_index((AR_DATA*)&result, &inttype,
02127                                 str1, (AR_DATA*)&len1, &inttype,
02128                                   "", (AR_DATA*)&len2, &inttype,
02129                                 (AR_DATA*)&backward, &backtype);
02130         validate(status, 0, result.ar_i64.part4, 27);
02131 
02132         backward = AR_const_true;
02133         len1.ar_i64.part4 = 0;
02134         len2.ar_i64.part4 = 0;
02135         status = AR_index((AR_DATA*)&result, &inttype,
02136                                   "", (AR_DATA*)&len1, &inttype,
02137                                   "", (AR_DATA*)&len2, &inttype,
02138                                 (AR_DATA*)&backward, &backtype);
02139         validate(status, 0, result.ar_i64.part4, 1);
02140 }
02141 
02142 t_scan()
02143 {
02144         char str1[] = "abcdefghijklmnopqrstuvwxyz";
02145 
02146         int     status;
02147 
02148         ar_data result;
02149         AR_DATA backward;
02150 
02151         ar_data len1 = {0,0,0,26};
02152         ar_data len2 = {0,0,0,0};
02153 
02154         AR_TYPE backtype = AR_Logical;
02155 
02156         printf("Testing AR_scan\n");
02157 
02158         len2.ar_i64.part4 = 3;
02159         status = AR_scan((AR_DATA*)&result, &inttype,
02160                            str1, (AR_DATA*)&len1, &inttype,
02161                           "fgh", (AR_DATA*)&len2, &inttype,
02162                                 NULL, NULL);
02163         validate(status, 0, result.ar_i64.part4, 6);
02164 
02165         len2.ar_i64.part4 = 3;
02166         status = AR_scan((AR_DATA*)&result, &inttype,
02167                            str1, (AR_DATA*)&len1, &inttype,
02168                           "0.2", (AR_DATA*)&len2, &inttype,
02169                                 NULL, NULL);
02170         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02171 
02172         len2.ar_i64.part4 = 0;
02173         status = AR_scan((AR_DATA*)&result, &inttype,
02174                            str1, (AR_DATA*)&len1, &inttype,
02175                                 "", (AR_DATA*)&len2, &inttype,
02176                                 NULL, NULL);
02177         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02178 
02179         len1.ar_i64.part4 = 0;
02180         len2.ar_i64.part4 = 3;
02181         status = AR_scan((AR_DATA*)&result, &inttype,
02182                                  "", (AR_DATA*)&len1, &inttype,
02183                           "fgh", (AR_DATA*)&len2, &inttype,
02184                                 NULL, NULL);
02185         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02186 
02187         len2.ar_i64.part4 = 0;
02188         status = AR_scan((AR_DATA*)&result, &inttype,
02189                                  "", (AR_DATA*)&len1, &inttype,
02190                                  "", (AR_DATA*)&len2, &inttype,
02191                                 NULL, NULL);
02192         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02193 
02194         len1.ar_i64.part4 = 26;
02195         len2.ar_i64.part4 = 1;
02196         status = AR_scan((AR_DATA*)&result, &inttype,
02197                            str1, (AR_DATA*)&len1, &inttype,
02198                                 "z", (AR_DATA*)&len2, &inttype,
02199                                 NULL, NULL);
02200         validate(status, 0, result.ar_i64.part4, 26);
02201 
02202         len2.ar_i64.part4 = 1;
02203         status = AR_scan((AR_DATA*)&result, &inttype,
02204                            str1, (AR_DATA*)&len1, &inttype,
02205                                 "a", (AR_DATA*)&len2, &inttype,
02206                                 NULL, NULL);
02207         validate(status, 0, result.ar_i64.part4, 1);
02208 
02209         backward = AR_const_false;
02210         len2.ar_i64.part4 = 2;
02211         status = AR_scan((AR_DATA*)&result, &inttype,
02212                            str1, (AR_DATA*)&len1, &inttype,
02213                            "kj", (AR_DATA*)&len2, &inttype,
02214                           (AR_DATA*)&backward, &backtype);
02215         validate(status, 0, result.ar_i64.part4, 10);
02216 
02217         backward = AR_const_true;
02218         len2.ar_i64.part4 = 2;
02219         status = AR_scan((AR_DATA*)&result, &inttype,
02220                            str1, (AR_DATA*)&len1, &inttype,
02221                            "jk", (AR_DATA*)&len2, &inttype,
02222                           (AR_DATA*)&backward, &backtype);
02223         validate(status, 0, result.ar_i64.part4, 11);
02224 
02225         backward = AR_const_true;
02226         len2.ar_i64.part4 = 1;
02227         status = AR_scan((AR_DATA*)&result, &inttype,
02228                            str1, (AR_DATA*)&len1, &inttype,
02229                                 "x", (AR_DATA*)&len2, &inttype,
02230                           (AR_DATA*)&backward, &backtype);
02231         validate(status, 0, result.ar_i64.part4, 24);
02232 
02233         backward = AR_const_true;
02234         len2.ar_i64.part4 = 3;
02235         status = AR_scan((AR_DATA*)&result, &inttype,
02236                            str1, (AR_DATA*)&len1, &inttype,
02237                           "jrk", (AR_DATA*)&len2, &inttype,
02238                           (AR_DATA*)&backward, &backtype);
02239         validate(status, 0, result.ar_i64.part4, 18);
02240 
02241         backward = AR_const_true;
02242         len2.ar_i64.part4 = 0;
02243         status = AR_scan((AR_DATA*)&result, &inttype,
02244                            str1, (AR_DATA*)&len1, &inttype,
02245                                  "", (AR_DATA*)&len2, &inttype,
02246                           (AR_DATA*)&backward, &backtype);
02247         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02248 
02249         backward = AR_const_true;
02250         len1.ar_i64.part4 = 0;
02251         len2.ar_i64.part4 = 0;
02252         status = AR_scan((AR_DATA*)&result, &inttype,
02253                                  "", (AR_DATA*)&len1, &inttype,
02254                                  "", (AR_DATA*)&len2, &inttype,
02255                           (AR_DATA*)&backward, &backtype);
02256         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02257 }
02258 
02259 t_verify()
02260 {
02261         char str1[] = "abcdefghijklmnopqrstuvwxyz";
02262 
02263         int     status;
02264 
02265         ar_data result;
02266         AR_DATA backward;
02267 
02268         ar_data len1 = {0,0,0,26};
02269         ar_data len2 = {0,0,0,0};
02270 
02271         AR_TYPE backtype = AR_Logical;
02272 
02273         printf("Testing AR_verify\n");
02274 
02275         len2.ar_i64.part4 = 3;
02276         status = AR_verify((AR_DATA*)&result, &inttype,
02277                                  str1, (AR_DATA*)&len1, &inttype,
02278                                 "fgh", (AR_DATA*)&len2, &inttype,
02279                                 NULL, NULL);
02280         validate(status, 0, result.ar_i64.part4, 1);
02281 
02282         len2.ar_i64.part4 = 6;
02283         status = AR_verify((AR_DATA*)&result, &inttype,
02284                                  str1, (AR_DATA*)&len1, &inttype,
02285                          "axbycz", (AR_DATA*)&len2, &inttype,
02286                                 NULL, NULL);
02287         validate(status, 0, result.ar_i64.part4, 4);
02288 
02289         len2.ar_i64.part4 = 0;
02290         status = AR_verify((AR_DATA*)&result, &inttype,
02291                                  str1, (AR_DATA*)&len1, &inttype,
02292                                    "", (AR_DATA*)&len2, &inttype,
02293                                 NULL, NULL);
02294         validate(status, 0, result.ar_i64.part4, 1);
02295 
02296         len1.ar_i64.part4 = 0;
02297         len2.ar_i64.part4 = 3;
02298         status = AR_verify((AR_DATA*)&result, &inttype,
02299                                    "", (AR_DATA*)&len1, &inttype,
02300                                 "fgh", (AR_DATA*)&len2, &inttype,
02301                                 NULL, NULL);
02302         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02303 
02304         len2.ar_i64.part4 = 0;
02305         status = AR_verify((AR_DATA*)&result, &inttype,
02306                                    "", (AR_DATA*)&len1, &inttype,
02307                                    "", (AR_DATA*)&len2, &inttype,
02308                                 NULL, NULL);
02309         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02310 
02311         len1.ar_i64.part4 = 26;
02312         len2.ar_i64.part4 = 2;
02313         status = AR_verify((AR_DATA*)&result, &inttype,
02314                                  str1, (AR_DATA*)&len1, &inttype,
02315                                  "az", (AR_DATA*)&len2, &inttype,
02316                                 NULL, NULL);
02317         validate(status, 0, result.ar_i64.part4, 2);
02318 
02319         len2.ar_i64.part4 = 26;
02320         status = AR_verify((AR_DATA*)&result, &inttype,
02321                                  str1, (AR_DATA*)&len1, &inttype,
02322                                  str1, (AR_DATA*)&len1, &inttype,
02323                                 NULL, NULL);
02324         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02325 
02326         backward = AR_const_false;
02327         len2.ar_i64.part4 = 2;
02328         status = AR_verify((AR_DATA*)&result, &inttype,
02329                                  str1, (AR_DATA*)&len1, &inttype,
02330                                  "jk", (AR_DATA*)&len2, &inttype,
02331                           (AR_DATA*)&backward, &backtype);
02332         validate(status, 0, result.ar_i64.part4, 1);
02333 
02334         backward = AR_const_true;
02335         len2.ar_i64.part4 = 2;
02336         status = AR_verify((AR_DATA*)&result, &inttype,
02337                                  str1, (AR_DATA*)&len1, &inttype,
02338                                  "jk", (AR_DATA*)&len2, &inttype,
02339                           (AR_DATA*)&backward, &backtype);
02340         validate(status, 0, result.ar_i64.part4, 26);
02341 
02342         backward = AR_const_true;
02343         len2.ar_i64.part4 = 3;
02344         status = AR_verify((AR_DATA*)&result, &inttype,
02345                                  str1, (AR_DATA*)&len1, &inttype,
02346                                 "xyz", (AR_DATA*)&len2, &inttype,
02347                           (AR_DATA*)&backward, &backtype);
02348         validate(status, 0, result.ar_i64.part4, 23);
02349 
02350         backward = AR_const_true;
02351         len2.ar_i64.part4 = 4;
02352         status = AR_verify((AR_DATA*)&result, &inttype,
02353                                  str1, (AR_DATA*)&len1, &inttype,
02354                            "jrkz", (AR_DATA*)&len2, &inttype,
02355                           (AR_DATA*)&backward, &backtype);
02356         validate(status, 0, result.ar_i64.part4, 25);
02357 
02358         backward = AR_const_true;
02359         len2.ar_i64.part4 = 0;
02360         status = AR_verify((AR_DATA*)&result, &inttype,
02361                                  str1, (AR_DATA*)&len1, &inttype,
02362                                    "", (AR_DATA*)&len2, &inttype,
02363                           (AR_DATA*)&backward, &backtype);
02364         validate(status, 0, result.ar_i64.part4, 26);
02365 
02366         backward = AR_const_true;
02367         len1.ar_i64.part4 = 0;
02368         len2.ar_i64.part4 = 0;
02369         status = AR_verify((AR_DATA*)&result, &inttype,
02370                                    "", (AR_DATA*)&len1, &inttype,
02371                                    "", (AR_DATA*)&len2, &inttype,
02372                           (AR_DATA*)&backward, &backtype);
02373         validate(status, AR_STAT_ZERO, result.ar_i64.part4, 0);
02374 }
02375 
02376 validate(int status, int xstatus, int result, int xresult)
02377 {
02378         if(status != xstatus || result != xresult) {
02379             fprintf(stderr,
02380                 "status = 0%o, result = %d, expected status, result = 0%o, %d\n",
02381                 status, result, xstatus, xresult);
02382             misc_errors++;
02383         }
02384 }
02385 
02386 
02387 /* Main driver */
02388 
02389 main (int argc, char **argv) {
02390 
02391         int tests = 0, failures = 0, rtests = 0, low = 0, high = 0;
02392 
02393         signal (SIGFPE, fperr);
02394 
02395         convtest64 ("results/cfix64_46", "Cray fix 46", ar_cfix64,
02396                         46, 0, &tests, &failures);
02397         convtest64 ("results/cfix64_64", "Cray fix 64", ar_cfix64,
02398                         64, 0, &tests, &failures);
02399         convtest64 ("results/cflts64", "Cray flt signed", ar_cflt64,
02400                         0, 0, &tests, &failures);
02401         convtest64 ("results/cfltu64", "Cray flt unsigned", ar_cflt64,
02402                         1, 0, &tests, &failures);
02403         convtest64 ("results/ifix64", "IEEE fix 64", ar_ifix64,
02404                         64, 0, &tests, &failures);
02405         convtest64 ("results/iflts", "IEEE flt signed", ar_iflt64,
02406                         0, 0, &tests, &failures);
02407         convtest64 ("results/ifltu", "IEEE flt unsigned", ar_iflt64,
02408                         1, 0, &tests, &failures);
02409         convtest64 ("results/itoc64", "IEEE->Cray convert", ar_itoc64,
02410                         AR_ROUND_NEAREST, 0, &tests, &failures);
02411         convtest64 ("results/ctoi64", "Cray->IEEE convert", ar_ctoi64,
02412                         0, 0, &tests, &failures);
02413         convtest128a ("results/itoc128", "IEEE->Cray double convert", ar_i64toc128,
02414                         0, &tests, &failures);
02415         convtest128a ("results/cflts128", "Cray double flt signed", ar_cflt128,
02416                         0, &tests, &failures);
02417         convtest128a ("results/cfltu128", "Cray double flt unsigned", ar_cflt128,
02418                         1, &tests, &failures);
02419         convtest128b ("results/cfix128_46", "Cray double fix 46", ar_cfix128,
02420                         46, &tests, &failures);
02421         convtest128b ("results/cfix128_64", "Cray double fix 64", ar_cfix128,
02422                         64, &tests, &failures);
02423         convtest128b ("results/c128to64", "Cray double round", ar_c128to64,
02424                         0, &tests, &failures);
02425         convtest128c ("results/c128toi64", "Cray double -> IEEE", ar_c128toi64,
02426                         0, &tests, &failures);
02427 
02428         craytest64_2 ("results/cray1_add64", "C1 fadd",
02429                       ar_cfadd64, -1,
02430                       &tests, &failures);
02431         craytest64_2 ("results/cray1_sub64", "C1 fsub",
02432                       ar_cfsub64, -1,
02433                       &tests, &failures);
02434         craytest64_2 ("results/cray1_mul64", "C1 fmul",
02435                       ar_cfmul64, AR_ROUNDED,
02436                       &tests, &failures);
02437         craytest64_2 ("results/cray1_recipiter", "C1 recipiter",
02438                       ar_cfmul64, AR_RECIPROCAL_ITERATION,
02439                       &tests, &failures);
02440         craytest64_1 ("results/cray1_recip", "C1 recip",
02441                       ar_c1frecip, AR_RECIPROCAL_ITERATION, /* unused arg */
02442                       &tests, &failures);
02443         craytest64_2 ("results/cray1_div64", "C1 fdiv",
02444                       ar_cfdiv64, AR_ROUNDED,
02445                       &tests, &failures);
02446 
02447         ieeetest64_2t ("results/ieee_add64", "IEEE 64 fadd",
02448                        AR_add, AR_Float_IEEE_NR_64,
02449                        &tests, &failures);
02450         ieeetest64_2t ("results/ieee_sub64", "IEEE 64 fsub",
02451                        AR_subtract, AR_Float_IEEE_NR_64,
02452                        &tests, &failures);
02453         ieeetest64_2t ("results/ieee_mul64", "IEEE 64 fmul",
02454                        AR_multiply, AR_Float_IEEE_NR_64,
02455                        &tests, &failures);
02456         ieeetest64_2t ("results/ieee_div64", "IEEE 64 fdiv",
02457                        AR_divide, AR_Float_IEEE_NR_64,
02458                        &tests, &failures);
02459         ieeetest64_2cmp ("results/ieee_cmp64", "IEEE 64 fcmp",
02460                        AR_compare, AR_Float_IEEE_NR_64,
02461                        &tests, &failures);
02462         ieeetest32_2t ("results/ieee_add32", "IEEE 32 fadd",
02463                        AR_add, AR_Float_IEEE_NR_32,
02464                        &tests, &failures);
02465         ieeetest32_2t ("results/ieee_sub32", "IEEE 32 fsub",
02466                        AR_subtract, AR_Float_IEEE_NR_32,
02467                        &tests, &failures);
02468         ieeetest32_2t ("results/ieee_mul32", "IEEE 32 fmul",
02469                        AR_multiply, AR_Float_IEEE_NR_32,
02470                        &tests, &failures);
02471         ieeetest32_2t ("results/ieee_div32", "IEEE 32 fdiv",
02472                        AR_divide, AR_Float_IEEE_NR_32,
02473                        &tests, &failures);
02474         ieeetest32_2cmp ("results/ieee_cmp32", "IEEE 32 fcmp",
02475                        AR_compare, AR_Float_IEEE_NR_32,
02476                        &tests, &failures);
02477         /* !! run the generated 32-64 conversion tests? !! */
02478 
02479         craytest128_2t ("results/cray1_add128", "C dpadd",
02480                         AR_add, AR_Float_Cray1_128,
02481                         &tests, &failures);
02482         craytest128_2t ("results/cray1_sub128", "C dpsub",
02483                         AR_subtract, AR_Float_Cray1_128,
02484                         &tests, &failures);
02485         craytest128_2t ("results/cray1_mul128", "C1 dpmul",
02486                         AR_multiply, AR_Float_Cray1_128,
02487                         &tests, &failures);
02488         craytest128_2t ("results/cray1_div128", "C1 dpdiv",
02489                         AR_divide, AR_Float_Cray1_128,
02490                         &tests, &failures);
02491 
02492 #ifdef _CRAY1
02493         craytest64_1t ("results/cray1_sqrt", "C1 sqrt",
02494                        AR_sqrt, AR_Float_Cray1_64,
02495                        &tests, &failures);
02496         craytest64_c ("results/cray1_cabs", "C1 cabs",
02497                       AR_cabs, AR_Complex_Cray1_64, AR_Float_Cray1_64,
02498                       &tests, &failures);
02499         craytest64_1t ("results/cray1_log", "C1 log",
02500                        AR_log, AR_Float_Cray1_64,
02501                        &tests, &failures);
02502         craytest64_1t ("results/cray1_exp", "C1 exp",
02503                        AR_exp, AR_Float_Cray1_64,
02504                        &tests, &failures);
02505         craytest64_i2 ("results/cray1_powii", "C powii 46",
02506                        AR_power, AR_Int_46_S,
02507                        &tests, &failures);
02508         craytest64_i2 ("results/cray1_powii", "C powii 64",
02509                        AR_power, AR_Int_64_S,
02510                        &tests, &failures);
02511         craytest64_i ("results/cray1_powri", "C1 powri",
02512                       AR_power, AR_Float_Cray1_64,
02513                       &tests, &failures);
02514         craytest64_2t ("results/cray1_powrr", "C1 powrr",
02515                        AR_power, AR_Float_Cray1_64,
02516                        &tests, &failures);
02517         craytest128_1t ("results/cray1_dsqrt", "C1 dsqrt",
02518                        AR_sqrt, AR_Float_Cray1_128,
02519                        &tests, &failures);
02520         craytest128_1t ("results/cray1_dlog", "C1 dlog",
02521                        AR_log, AR_Float_Cray1_128,
02522                        &tests, &failures);
02523         craytest128_1t ("results/cray1_dexp", "C1 dexp",
02524                        AR_exp, AR_Float_Cray1_128,
02525                        &tests, &failures);
02526         craytest128_i ("results/cray1_powdi", "C1 powdi",
02527                        AR_power, AR_Float_Cray1_128,
02528                        &tests, &failures);
02529         craytest128_2t ("results/cray1_powdd", "C1 powdd",
02530                        AR_power, AR_Float_Cray1_128,
02531                        &tests, &failures);
02532         craytest128_64 ("results/cray1_powdr", "C1 powdr",
02533                        AR_power, AR_Float_Cray1_128, AR_Float_Cray1_64,
02534                        &tests, &failures);
02535 #else
02536 #ifdef __svr4__
02537         ieeetest32_2c ("results/ieee_cdiv32", "IEEE cdiv",
02538                        AR_divide, AR_Complex_IEEE_NR_32,
02539                        &tests, &failures);
02540         ieeetest64_2c ("results/ieee_cdiv64", "IEEE cddiv",
02541                        AR_divide, AR_Complex_IEEE_NR_64,
02542                        &tests, &failures);
02543    #define U "_solaris"
02544 #else
02545    #define U "_sunOS"
02546 #endif
02547         ieeetest64_1t ("results/ieee_sqrt64" U, "IEEE sqrt",
02548                        AR_sqrt, AR_Float_IEEE_NR_64,
02549                        &tests, &failures);
02550         ieeetest64_1t ("results/ieee_log64" U, "IEEE log",
02551                        AR_log, AR_Float_IEEE_NR_64,
02552                        &tests, &failures);
02553         ieeetest64_1t ("results/ieee_exp64" U, "IEEE exp",
02554                        AR_exp, AR_Float_IEEE_NR_64,
02555                        &tests, &failures);
02556         ieeetest64_2t ("results/ieee_powrr64" U, "IEEE powrr",
02557                        AR_power, AR_Float_IEEE_NR_64,
02558                        &tests, &failures);
02559 #endif
02560 
02561 #undef U
02562 
02563         printf ("end %d confidence tests (%d failures)\n", tests, failures);
02564 
02565 #ifdef _CRAY1
02566         crayrand64_2 ("C1 fadd", ar_cfadd64, -1, fadd,
02567                         &rtests, &low, &high);
02568         crayrand64_2 ("C1 fsub", ar_cfsub64, -1, fsub,
02569                         &rtests, &low, &high);
02570         crayrand64_2 ("C1 *R mul", ar_cfmul64, AR_ROUNDED, ARRMULT,
02571                         &rtests, &low, &high);
02572         crayrand64_2 ("C1 *F mul", ar_cfmul64, AR_UNROUNDED, ARFMULT,
02573                         &rtests, &low, &high);
02574         crayrand64_2 ("C1 *I mul", ar_cfmul64, AR_RECIPROCAL_ITERATION, ARIMULT,
02575                         &rtests, &low, &high);
02576         crayrand64_1 ("C1 recip", ar_c1frecip, AR_ROUNDED, ARHRECIP,
02577                         &rtests, &low, &high);
02578         crayrand64_2 ("C1 fdiv", ar_cfdiv64, AR_ROUNDED, fdiv,
02579                         &rtests, &low, &high);
02580         crayrand128_2 ("C1 dp fadd", ar_cfadd128, -1, dfadd,
02581                         &rtests, &low, &high);
02582         crayrand128_2 ("C1 dp fsub", ar_cfsub128, -1, dfsub,
02583                         &rtests, &low, &high);
02584         crayrand128_2 ("C1 dp fmul", ar_cfmul128, AR_ROUNDED, dfmul,
02585                         &rtests, &low, &high);
02586         crayrand128_2 ("C1 dp fdiv", ar_cfdiv128, AR_ROUNDED, dfdiv,
02587                         &rtests, &low, &high);
02588         crayrandcplx ("C1 complex add", AR_add, AR_Complex_Cray1_64, cadd,
02589                         &rtests, &low);
02590         crayrandcplx ("C1 complex sub", AR_subtract, AR_Complex_Cray1_64, csub,
02591                         &rtests, &low);
02592         crayrandcplx ("C1 complex mul", AR_multiply, AR_Complex_Cray1_64, cmul,
02593                         &rtests, &low);
02594         crayrandcplx ("C1 complex div", AR_divide, AR_Complex_Cray1_64, cdiv,
02595                         &rtests, &low);
02596 #else
02597 #if _Solaris || defined(__mips)
02598         ieeerand128_2 ("IEEE128 fadd", ar_ifadd128, AR_ROUND_NEAREST, xdfadd,
02599                         &rtests, &low, &high);
02600         ieeerand128_2 ("IEEE128 fsub", ar_ifsub128, AR_ROUND_NEAREST, xdfsub,
02601                         &rtests, &low, &high);
02602         ieeerand128_2 ("IEEE128 fmul", ar_ifmul128, AR_ROUND_NEAREST, xdfmul,
02603                         &rtests, &low, &high);
02604         ieeerand128_2 ("IEEE128 fdiv", ar_ifdiv128, AR_ROUND_NEAREST, xdfdiv,
02605                         &rtests, &low, &high);
02606 #endif
02607         ieeerand64_2 ("IEEE64 fadd", ar_ifadd64, AR_ROUND_NEAREST, dfadd,
02608                         &rtests, &low, &high);
02609         ieeerand64_2 ("IEEE64 fsub", ar_ifsub64, AR_ROUND_NEAREST, dfsub,
02610                         &rtests, &low, &high);
02611         ieeerand64_2 ("IEEE64 fmul", ar_ifmul64, AR_ROUND_NEAREST, dfmul,
02612                         &rtests, &low, &high);
02613         ieeerand64_2 ("IEEE64 fdiv", ar_ifdiv64, AR_ROUND_NEAREST, dfdiv,
02614                         &rtests, &low, &high);
02615         ieeerand32_2 ("IEEE32 fadd", ar_ifadd32, AR_ROUND_NEAREST, fadd,
02616                         &rtests, &low, &high);
02617         ieeerand32_2 ("IEEE32 fsub", ar_ifsub32, AR_ROUND_NEAREST, fsub,
02618                         &rtests, &low, &high);
02619         ieeerand32_2 ("IEEE32 fmul", ar_ifmul32, AR_ROUND_NEAREST, fmul,
02620                         &rtests, &low, &high);
02621         ieeerand32_2 ("IEEE32 fdiv", ar_ifdiv32, AR_ROUND_NEAREST, fdiv,
02622                         &rtests, &low, &high);
02623         /* !! random 32-64 conversion tests? !! */
02624 #endif
02625 
02626         printf ("end %d random tests; %d low, %d high\n", rtests, low, high);
02627 
02628         misc_tests(&failures);
02629 
02630         exit (!!failures | !!low | !!high);
02631 }
02632 
02633 
02634 static char USMID [] = "\n%Z%%M%        %I%     %G% %U%\n";
02635 static char rcsid [] = "$Id: confidence.c,v 1.1.1.1 2002-05-22 20:06:18 dsystem Exp $";
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines