diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 1999-06-24 07:47:59 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 1999-06-24 07:47:59 +0000 |
commit | 88581e54763c9d1d3115751dfbfcbe857be68943 (patch) | |
tree | 796b601c785a905d5f69c905095ea9690bcbfb4c /tests | |
parent | 34c50d4302367d2852e9a140c7c9b08904b47930 (diff) | |
download | mpfr-88581e54763c9d1d3115751dfbfcbe857be68943.tar.gz |
added tests from JM Muller and V Lefevre
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@150 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tlog.c | 111 |
1 files changed, 106 insertions, 5 deletions
diff --git a/tests/tlog.c b/tests/tlog.c index d5421ad8e..c9152b469 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -26,14 +26,16 @@ int ulp(a,b) double a,b; return (int) floor(b/eps); } +#define check(a,r) check2(a,r,0.0) -void check(double a, unsigned char rnd_mode) + +void check2(double a, unsigned char rnd_mode, double res1) { mpfr_t ta, tres; - double res1,res2 ; + double res2 ; mpfr_set_machine_rnd_mode(rnd_mode); - res1=log(a); + if (res1==0.0) res1=log(a); mpfr_init2(ta, 53); mpfr_init2(tres, 53); @@ -42,7 +44,6 @@ void check(double a, unsigned char rnd_mode) mpfr_log(tres, ta, rnd_mode); res2=mpfr_get_d(tres); - if (res1!=res2 && (!isnan(res1) || !isnan(res2))) { printf("mpfr_log failed for a=%1.20e, rnd_mode=%d\n",a,rnd_mode); printf(" double calculus gives %1.20e\n mpfr_log gives %1.20e (%d ulp)\n pari gives \n \n",res1,res2,ulp(res1,res2)); @@ -65,6 +66,106 @@ check3(double d, unsigned long prec, unsigned char rnd) mpfr_clear(x); mpfr_clear(y); } +/* examples from Jean-Michel Muller and Vincent Lefevre + Cf http://www.ens-lyon.fr/~jmmuller/Intro-to-TMD.htm +*/ +check_worst_cases() +{ + check2(1.00089971802309629645, GMP_RNDD, 8.99313519443722736088e-04); /*-2*/ + check2(1.00089971802309629645, GMP_RNDN, 8.99313519443722844508e-04); + check2(1.00089971802309629645, GMP_RNDU, 8.99313519443722844508e-04); + + check2(1.01979300812244555452, GMP_RNDD, 1.95996734891603630047e-02); /*+1*/ + check2(1.01979300812244555452, GMP_RNDN, 1.95996734891603664741e-02); + check2(1.01979300812244555452, GMP_RNDD, 1.95996734891603664741e-02); + + check2(1.02900871924604464525, GMP_RNDD, 2.85959303301472726744e-02); + check2(1.02900871924604464525, GMP_RNDN, 2.85959303301472761438e-02); + check2(1.02900871924604464525, GMP_RNDU, 2.85959303301472761438e-02); + + check2(1.27832870030418943585, GMP_RNDD, 2.45553521871417795852e-01); + check2(1.27832870030418943585, GMP_RNDN, 2.45553521871417823608e-01); + check2(1.27832870030418943585, GMP_RNDU, 2.45553521871417823608e-01); + + check2(1.31706530746788241792, GMP_RNDD, 2.75406009586277422674e-01); + check2(1.31706530746788241792, GMP_RNDN, 2.75406009586277478185e-01); + check2(1.31706530746788241792, GMP_RNDU, 2.75406009586277478185e-01); + + check2(1.47116981099449883885, GMP_RNDD, 3.86057874110010412760e-01); + check2(1.47116981099449883885, GMP_RNDN, 3.86057874110010412760e-01); + check2(1.47116981099449883885, GMP_RNDU, 3.86057874110010468272e-01); + + check2(1.58405446812987782401, GMP_RNDD, 4.59987679246663727639e-01); + check2(1.58405446812987782401, GMP_RNDN, 4.59987679246663783150e-01); + check2(1.58405446812987782401, GMP_RNDU, 4.59987679246663783150e-01); + + check2(1.67192331263391547047, GMP_RNDD, 5.13974647961076613889e-01); + check2(1.67192331263391547047, GMP_RNDN, 5.13974647961076724911e-01); + check2(1.67192331263391547047, GMP_RNDU, 5.13974647961076724911e-01); + + check2(1.71101198068990645318, GMP_RNDD, 5.37084997042120315669e-01); + check2(1.71101198068990645318, GMP_RNDN, 5.37084997042120315669e-01); + check2(1.71101198068990645318, GMP_RNDU, 5.37084997042120426691e-01); + + check2(1.72634853551388700588, GMP_RNDD, 5.46008504786553605648e-01); + check2(1.72634853551388700588, GMP_RNDN, 5.46008504786553716670e-01); + check2(1.72634853551388700588, GMP_RNDU, 5.46008504786553716670e-01); + +#ifdef DEBUG + check2(2.00028876593004323325, GMP_RNDD, 6.93291553102749702475e-01);/*segv*/ +#endif + check2(2.00028876593004323325, GMP_RNDN, 6.93291553102749813497e-01); +#ifdef DEBUG + check2(2.00028876593004323325, GMP_RNDU, 6.93291553102749813497e-01);/*segv*/ +#endif + + check2(6.27593230200363105808, GMP_RNDD, 1.83672204800630312072); + check2(6.27593230200363105808, GMP_RNDN, 1.83672204800630334276); + check2(6.27593230200363105808, GMP_RNDU, 1.83672204800630334276); + + check2(7.47216682321367997588, GMP_RNDD, 2.01118502712453661729); + check2(7.47216682321367997588, GMP_RNDN, 2.01118502712453706138); + check2(7.47216682321367997588, GMP_RNDU, 2.01118502712453706138); + + check2(9.34589857718275318632, GMP_RNDD, 2.23493759221664944903); + check2(9.34589857718275318632, GMP_RNDN, 2.23493759221664989312); + check2(9.34589857718275318632, GMP_RNDU, 2.23493759221664989312); + +#ifdef DEBUG + check2(10.6856587560831854944, GMP_RNDD, 2.36890253928838445674); /* segv */ +#endif + check2(10.6856587560831854944, GMP_RNDN, 2.36890253928838445674); +#ifdef DEBUG + check2(10.6856587560831854944, GMP_RNDU, 2.36890253928838490083); /* segv */ +#endif + +#ifdef DEBUG + check2(12.4646345033981766903, GMP_RNDD, 2.52289539471636015122); /* segv */ +#endif + check2(12.4646345033981766903, GMP_RNDN, 2.52289539471636015122); +#ifdef DEBUG + check2(12.4646345033981766903, GMP_RNDU, 2.52289539471636059531); +#endif + + check2(17.0953275851761752335, GMP_RNDD, 2.83880518553861849185); +#ifdef DEBUG + check2(17.0953275851761752335, GMP_RNDN, 2.83880518553861893594); /* segv */ +#endif + check2(17.0953275851761752335, GMP_RNDU, 2.83880518553861893594); + + check2(19.8509496207496916043, GMP_RNDD, 2.98825184582516722998); + check2(19.8509496207496916043, GMP_RNDN, 2.98825184582516722998); + check2(19.8509496207496916043, GMP_RNDU, 2.98825184582516767406); + + check2(23.9512076062771335216, GMP_RNDD, 3.17601874455977206679); + check2(23.9512076062771335216, GMP_RNDN, 3.17601874455977206679); + check2(23.9512076062771335216, GMP_RNDU, 3.17601874455977251088); + + check2(428.315247165198229595, GMP_RNDD, 6.05985948325268264369); + check2(428.315247165198229595, GMP_RNDN, 6.05985948325268353187); + check2(428.315247165198229595, GMP_RNDU, 6.05985948325268353187); +} + void main(int argc, char *argv[]) { int i; double d; @@ -73,10 +174,10 @@ void main(int argc, char *argv[]) { check3(atof(argv[1]), atoi(argv[2]), atoi(argv[3])); return; } + check_worst_cases(); printf("SUN Solaris: craffe\n 20000 essais\n"); printf("GMP_RNDN : %i, GMP_RNDZ : %i,GMP_RNDU : %i,GMP_RNDD : %i\n",GMP_RNDN, GMP_RNDZ,GMP_RNDU, GMP_RNDD); - check(10,GMP_RNDU); check(6,GMP_RNDU); check(1,GMP_RNDZ); |