/* C---------------------------------------------------------------------- CProgramtotestCLOG C CAccuracytestsarebasedontheidentity C Clog(z)=log(z*z)/2 Cand Clog(z)=log(17z/16)-log(17/16) 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 CCMPLX(orDCMPLX),LOG,REAL(orDBLE),SQRT C CTheprogramasgivenheremustbemodifiedbeforecompiling. CIfasingle(double)precisionversionisdesired,changeall CoccurrencesofCS(CD)incolumns1and2toblanks.Fora Ccalibrationversion,changealloccurrencesofCSandofCC Cincolumns1and2toblanks. C CLatestrevision-November20,1990 C CAuthor-W.J.Cody CArgonneNationalLaboratory C C---------------------------------------------------------------------- CDeclarenamedcommon C----------------------------------------------------------------------
*/
AX = ONE + ONE;
BX = TEN;
AY = ZERO;
BY = BX;
N = 2000;
XN = CONV (N);
I1 = 0;
RFLAG = TRUE;
IFLAG = TRUE;
PFLAG = FALSE; /* C--------------------------------------------------------------------- CRandomargumentaccuracytests C---------------------------------------------------------------------
*/ /* DO 300 J = 1, 3 */ for (J = 1; J <= 3; J++)
{
RESET ();
DELX = (BX - AX) / XN;
DELY = (BY - AY);
XL = AX; /* DO 200 I = 1, N */ for (I = 1; I <= N; I++)
{
X = DELX * REN (I1) + XL;
Y = DELY * REN (I1) + AY; /* C----------------------------------------------------------------- CPurifyargumentandevaluateidentities C-----------------------------------------------------------------
*/
Z = X * SCALE;
W = Z + X;
X = W - Z;
Z = Y * SCALE;
W = Z + Y;
Y = W - Z;
CX = CONVC (X, Y);
Z = X * X - Y * Y;
W = X * Y;
CY = CONVC (Z, W + W);
CZ = FLOG (CX);
CZZ = FLOG (CY);
CZZ = CZZ * HALF; /* C----------------------------------------------------------------- CAccumulateresults C-----------------------------------------------------------------
*/
TABLAT ();
XL = XL + DELX; /* 200 CONTINUE */
} /* C----------------------------------------------------------------- CProcessandoutputstatistics C-----------------------------------------------------------------
*/
printf (" Test of LOG(Z) vs LOG(Z*Z)/2\n");
REPORT (IOUT); if (J == 1)
{
AX = THOUS;
BX = AX + AX;
AY = -AX;
BY = -BX - BX;
} else
{
AX = EPS;
BX = HALF * HALF;
AY = -AX;
BY = -BX;
} /* 300 CONTINUE*/
} /* C----------------------------------------------------------------- CSpecialtests C-----------------------------------------------------------------
*/
printf (" Special tests\n");
printf (" The identity LOG(Z) = -LOG(1/Z) will be tested\n");
printf (" Z LOG(Z) + LOG(1/Z)\n"); /* DO 320 I = 1, 5*/ for (I = 1; I <= 5; I++)
{
X = REN (I1) * TEN;
Y = REN (I1) * TEN;
CX = CONVC (X, Y);
CY = ONE / CX;
CZ = FLOG (CX) + FLOG (CY);
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 (ONE, ZERO);
CZ = FLOG (CX);
printf (" LOG(1.0,0.0) = (%15.7E,%15.7E)\n", creal (CZ), cimag (CZ));
printf (" Tests near extreme arguments. These should not\n");
printf (" but may\n trigger error messages\n");
CX = CONVC (XMIN, XMIN);
printf (" LOG will be called with the argument ");
printf (" (%15.4E,%15.4E)\n", creal (CX), cimag (CX));
CZ = FLOG (CX);
printf (" LOG(XMIN,XMIN) = LOG(%15.7E,%15.7E) =\n", creal (CX), cimag (CX));
printf (" (%15.7E,%15.7E)\n", creal (CZ), cimag (CZ));
CX = CONVC (XMAX, XMAX);
printf (" LOG will be called with the argument ");
printf (" (%15.4E,%15.4E)\n", creal (CX), cimag (CX));
CZ = FLOG (CX);
printf (" LOG(XMAX,XMAX) = LOG(%15.7E,%15.7E) =\n", creal (CX), cimag (CX));
printf (" (%15.7E,%15.7E)\n", creal (CZ), cimag (CZ));
/* C----------------------------------------------------------------- CTestoferrorreturns C-----------------------------------------------------------------
*/
printf (" Test of error returns\n");
CX = CONVC (ZERO, ZERO);
printf (" LOG will be called with the argument (%15.4E,%15.4E)\n",
creal (CX), cimag (CX));
printf (" This should trigger an error message\n");
CZ = FLOG (CX);
printf (" LOG 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.