/* C---------------------------------------------------------------------- CProgramtotestCEXP C CAccuracytestsarebasedontheidentity C Cexp(z)=exp(z-w)*exp(w) C CDatarequired: C CNone C CSubprogramsrequiredfromthispackage: C CMACHAR-Anenvironmentalinquiryprogramproviding Cinformationonthefloatingpointarithmetic Csystem.NotethatthecalltoMACHARcan Cbedeletedprovidedthefollowingfour Cparametersareassignedthevaluesindicated: C CIBETA-theradixofthefloatingpointsystem; CIT-thenumberofbase-IBETAdigitsinthe Csignificandofafloating-pointnumber; CXMIN-thesmallestnon-vanishingfloating-point Cpoweroftheradix; CXMAX-thelargestfinitefloating-pointno. C CREN(K)-afunctionsubprogramreturningrandomreal Cnumbersuniformlydistributedover(0,1) C CRESET,TABLAT,REPORT-programstoreportresults. C C CGenericFortransubprogramsrequired: C CAIMAG(orDIMAG),AINT,CMPLX(orDCMPLX),EXP, C CLOG,REAL(orDBLE),SQRT C C CLatestrevision-October31,1990 C CAuthor-W.J.Cody CArgonneNationalLaboratory C C---------------------------------------------------------------------- CDeclarenamedcommon C----------------------------------------------------------------------
*/
#include"celefunt.h"
int IFLAG, RFLAG, PFLAG; int KX1, KX2, KX3, KY1, KY2, KY3;
REPORT (IOUT); if (J == 1)
{
AX = ONEP6;
BX = THREE;
} else
{
AX = SIXTEN;
BX = AX + ONE;
}
AY = AX;
BY = BX; /* 300 CONTINUE */
} /* C--------------------------------------------------------------------- CSpecialtests C---------------------------------------------------------------------
*/
printf (" Special tests\n");
printf (" The identity EXP(Z)*EXP(-Z) = 1.0 will be tested.\n");
printf (" Z F(Z)*F(-Z) - 1\n");
/* DO 320 I = 1, 5 */ for (I = 1; I <= 5; I++)
{
X = REN (I1) * BETA;
Y = REN (I1) * BETA;
CX = CONVC (X, Y);
CY = -CX;
CZ = FEXP (CX) * FEXP (CY) - ONE;
printf ("(%15.7E,%15.7E) (%15.7E,%15.7E)\n",
creal (CX), cimag (CX), creal (CZ), cimag (CZ)); /* 320 CONTINUE*/
}
printf (" Test of special arguments\n");
CX = CONVC (ZERO, ZERO);
CZ = FEXP (CX) - ONE;
printf (" EXP(0.0,0.0) - 1.0E0 = (%15.7E,%15.7E)\n",
creal (CZ), cimag (CZ));
printf (" Test cos(y), sin(y), and exp(x)\n");
CX = CONVC (ZERO, TEN);
CZ = FEXP (CX);
X = COS (TEN);
Y = SIN (TEN);
W = (CONVR (CZ) - X) / X;
printf (" [REAL(EXP(0,10)) - COS(10)]/COS(10) = %15.7E\n", W);
W = (CONVI (CZ) - Y) / Y;
printf (" [IMAG(EXP(0,10)) - SIN(10)]/SIN(10) = %15.7E\n", W);
CX = CONVC (TEN, ZERO);
CZ = FEXP (CX);
X = EXP (TEN);
W = (CONVR (CZ) - X) / X;
printf (" [REAL(EXP(10,0)) - EXP(10)]/EXP(10) = %15.7E\n", W);
printf (" Tests near extreme arguments\n");
printf (" The real part of the first result below may underflow.\n");
X = AINT (LOG (XMIN));
CX = CONVC (X, ONE);
CZ = FEXP (CX);
printf (" EXP(%13.6E,%13.6E) = (%13.6E,%13.6E)\n",
creal (CX), cimag (CX), creal (CZ), cimag (CZ));
Y = SQRT (XMAX);
X = AINT (LOG (XMAX));
CX = CONVC (X, ONE);
CZ = FEXP (CX);
printf (" EXP(%13.6E,%13.6E) = (%13.6E,%13.6E)\n",
creal (CX), cimag (CX), creal (CZ), cimag (CZ));
CX = CONVC (X * HALF, TEN);
CY = CX * HALF;
CZ = FEXP (CX);
CZZ = FEXP (CY);
CZZ = CZZ * CZZ;
printf (" If EXP(%13.6E,%13.6E) = (%13.6E,%13.6E)\n",
creal (CX), cimag (CX), creal (CZ), cimag (CZ));
printf (" is not about\n EXP(%13.6E,%13.6E)**2 = \n",
creal (CY), cimag (CY));
printf (" (%13.6E,%13.6E) there is an\n argument reduction error\n",
creal (CZZ), cimag (CZZ));
/* C--------------------------------------------------------------------- CTestoferrorreturns C---------------------------------------------------------------------
*/
printf (" Test of error returns\n");
X = -ONE / SQRT (XMIN);
CX = CONVC (X, ONE);
printf (" EXP will be called with the argument (%15.4E,%15.4E)\n",
creal (CX), cimag (CX));
printf (" The real component of the argument is so negative\n");
printf (" that the real exponential should underflow to zero.\n");
printf (" Thus, the result should be (0,0).\n");
CZ = FEXP (CX);
printf (" EXP returned the value (%15.4E,%15.4E)\n",
creal (CZ), cimag (CZ));
Y = SQRT (XMAX);
CX = CONVC (TEN, Y);
printf (" EXP will be called with the argument (%15.4E,%15.4E)\n",
creal (CX), cimag (CX));
printf (" The imaginary component of the argument is too large\n");
printf (" for the sin and cos computations to make sense.\n");
CZ = FEXP (CX);
printf (" EXP returned the value (%15.4E,%15.4E)\n",
creal (CZ), cimag (CZ));
CX = CONVC (-X, -ONE);
printf (" EXP will be called with the argument (%15.4E,%15.4E)\n",
creal (CX), cimag (CX));
printf (" The real component of the argument is so large\n");
printf (" that the real exponential should overflow. The\n");
printf (" result should be (inf,inf) with an error return.\n");
CZ = FEXP (CX);
printf (" EXP returned the value (%15.4E,%15.4E)\n",
creal (CZ), cimag (CZ));
printf (" This concludes the tests\n"); exit (0);
}
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.