/* Provide inverses for square root and cube root: */ int
qsquare (x, y)
QELT x[], y[];
{
qmul (x, x, y); return0;
}
int
qcube (x, y)
QELT x[], y[];
{
qmul (x, x, y);
qmul (x, y, y); return0;
}
/* lookup table for each function */ struct fundef
{ char *nam1; /* the function */ int (*name) (); char *nam2; /* its inverse */ int (*inv) (); int nargs; /* number of function arguments */ int tstyp; /* type code of the function */ long ctrl; /* relative error flag */ double arg1w; /* width of domain for 1st arg */ double arg1l; /* lower bound domain 1st arg */ long arg1f; /* flags, e.g. integer arg */ double arg2w; /* same info for args 2, 3, 4 */ double arg2l; long arg2f;
};
int main ()
{ int (*fun) (); int (*ifun) (); struct fundef *d; int i, k, itst; int ntr; long ll, m;
ntr = NTRIALS;
printf ("Consistency test of math functions.\n");
printf ("Max and rms errors for %d random arguments.\n",
ntr);
printf ("A = absolute error criterion (but relative if >1):\n");
printf ("Otherwise, estimate is of relative error\n");
/* Initialize machine dependent parameters to test near the *largestansmallestpossiblearguments.Tocomparedifferent *machines,usethesametestintervalsforallsystems.
*/
defs[1].arg1w = 3.14159;
defs[1].arg1l = -3.14159 / 2.0;
qadd (qone, qtwo, qthree);
dx.d = 1.0e-15;
etoq (dx.i, fuzz);
/* Smaller number of trials for Wronksians
(put them at end of list) */ if (d->tstyp == WRONK1 || d->tstyp == WRONK2 || d->tstyp == NDTR)
{
ntr = WTRIALS;
printf ("Absolute error and only %d trials:\n", ntr);
}
printf (headrs[d->tstyp], d->nam2, d->nam1);
for (i = 0; i < ntr; i++)
{
m++;
/* make random number(s) in desired range(s) */
k = 0; switch (d->nargs)
{
switch (d->tstyp)
{ case WRONK1: /* e = (y2*y3 - y1*y4) - 2.0L/(PIL*x); *//* Jn, Yn */
qmul (y1, y4, temp);
qmul (y2, y3, e);
qsub (temp, e, e);
qmov (qpi, temp);
qmul (temp, x, temp);
qdiv (temp, qtwo, temp);
qsub (temp, e, e); break;
case WRONK2: /* e = (y2*y3 + y1*y4) - 1.0L/x; *//* In, Kn */
qmul (y1, y4, temp);
qmul (y2, y3, e);
qadd (temp, e, e);
qdiv (x, qone, temp);
qsub (temp, e, e); break;
case ELLIP: /* e = (y1-y3)*y4 + y3*y2 - PIO2L; */
qsub (y3, y1, temp);
qmul (y4, temp, e);
qmul (y3, y2, temp);
qadd (temp, e, e);
qmov (qpi, temp);
temp[1] -= 1;
qsub (temp, e, e); break;
default: /* e = y - x; */
qsub (x, y, e); break;
}
if (d->ctrl & RELERR)
{ if (qcmp (x, qzero) != 0)
qdiv (x, e, e); else
printf ("warning, x == 0\n");
} else
{
qmov (x, temp);
temp[0] = 0; if (qcmp (temp, qone) > 0)
qdiv (x, e, e);
}
qadd (e, ave, ave); /* absolute value of error */
e[0] = 0; /* peak detect the error */ if (qcmp (e, max) > 0)
{
qmov (e, max); #if0 if (e > 1.0e-10L)
{
da = x;
db = z;
dc = y;
dd = max;
printf ("x %.6E z %.6E y %.6E max %.4E\n",
da, db, dc, dd);
} #endif
} /* accumulate rms error */ if( e[1] )
{
qmul (e, e, temp);
qadd (temp, rmsa, rmsa);
}
}
/* report after NTRIALS trials */
ltoq (&m, temp);
qdiv (temp, rmsa, temp);
qsqrt (temp, rms);
qtoasc (max, str1, 3);
qtoasc (rms, str2, 3); if (d->ctrl & RELERR)
printf (" max = %s rms = %s\n", str1, str2); else
printf (" max = %s A rms = %s A\n", str1, str2);
} /* loop on itst */
exit(0);
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet am 2026-06-23)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.