int main (int argc, char *argv[]) { tests_start_mpfr (); check_nans (); check_exact (); check_float (); check53("6.9314718055994530941514e-1", "0.0", MPFR_RNDZ, "0.0"); check53("0.0", "6.9314718055994530941514e-1", MPFR_RNDZ, "0.0"); check_sign(); check53("-4.165000000e4", "-0.00004801920768307322868063274915", MPFR_RNDN, "2.0"); check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165", MPFR_RNDZ, "-1.8251348697787782844e-172"); check53("2.71331408349172961467e-08", "-6.72658901114033715233e-165", MPFR_RNDA, "-1.8251348697787786e-172"); check53("0.31869277231188065", "0.88642843322303122", MPFR_RNDZ, "2.8249833483992453642e-1"); check("8.47622108205396074254e-01", "3.24039313247872939883e-01", MPFR_RNDU, 28, 45, 2, "0.375"); check("8.47622108205396074254e-01", "3.24039313247872939883e-01", MPFR_RNDA, 28, 45, 2, "0.375"); check("2.63978122803639081440e-01", "6.8378615379333496093e-1", MPFR_RNDN, 34, 23, 31, "0.180504585267044603"); check("1.0", "0.11835170935876249132", MPFR_RNDU, 6, 41, 36, "0.1183517093595583"); check53("67108865.0", "134217729.0", MPFR_RNDN, "9.007199456067584e15"); check("1.37399642157394197284e-01", "2.28877275604219221350e-01", MPFR_RNDN, 49, 15, 32, "0.0314472340833162888"); check("4.03160720978664954828e-01", "5.854828e-1" /*"5.85483042917246621073e-01"*/, MPFR_RNDZ, 51, 22, 32, "0.2360436821472831"); check("3.90798504668055102229e-14", "9.85394674650308388664e-04", MPFR_RNDN, 46, 22, 12, "0.385027296503914762e-16"); check("4.58687081072827851358e-01", "2.20543551472118792844e-01", MPFR_RNDN, 49, 3, 2, "0.09375"); check_max(); check_min(); check_regression (); test_generic (2, 500, 100); data_check ("data/mulpi", mpfr_mulpi, "mpfr_mulpi"); valgrind20110503 (); tests_end_mpfr (); return 0; }
int main (int argc, char *argv[]) { mpfr_t x, c, s, c2, s2; tests_start_mpfr (); check_regression (); check_nans (); /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */ check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", MPFR_RNDN); check53 ("4.984987858808754279e-1", "4.781075595393329824e-1", MPFR_RNDD); check53 ("4.984987858808754279e-1", "4.781075595393329824e-1", MPFR_RNDZ); check53 ("4.984987858808754279e-1", "4.781075595393330379e-1", MPFR_RNDU); check53 ("1.00031274099908640274", "8.416399183372403892e-1", MPFR_RNDN); check53 ("1.00229256850978698523", "8.427074524447979442e-1", MPFR_RNDZ); check53 ("1.00288304857059840103", "8.430252033025980029e-1", MPFR_RNDZ); check53 ("1.00591265847407274059", "8.446508805292128885e-1", MPFR_RNDN); /* Other worst cases showing a bug introduced on 2005-01-29 in rev 3248 */ check53b ("1.0111001111010111010111111000010011010001110001111011e-21", "1.0111001111010111010111111000010011010001101001110001e-21", MPFR_RNDU); check53b ("1.1011101111111010000001010111000010000111100100101101", "1.1111100100101100001111100000110011110011010001010101e-1", MPFR_RNDU); mpfr_init2 (x, 2); mpfr_set_str (x, "0.5", 10, MPFR_RNDN); test_sin (x, x, MPFR_RNDD); if (mpfr_cmp_ui_2exp (x, 3, -3)) /* x != 0.375 = 3/8 */ { printf ("mpfr_sin(0.5, MPFR_RNDD) failed with precision=2\n"); exit (1); } /* bug found by Kevin Ryde */ mpfr_const_pi (x, MPFR_RNDN); mpfr_mul_ui (x, x, 3L, MPFR_RNDN); mpfr_div_ui (x, x, 2L, MPFR_RNDN); test_sin (x, x, MPFR_RNDN); if (mpfr_cmp_ui (x, 0) >= 0) { printf ("Error: wrong sign for sin(3*Pi/2)\n"); exit (1); } /* Can fail on an assert */ mpfr_set_prec (x, 53); mpfr_set_str (x, "77291789194529019661184401408", 10, MPFR_RNDN); mpfr_init2 (c, 4); mpfr_init2 (s, 42); mpfr_init2 (c2, 4); mpfr_init2 (s2, 42); test_sin (s, x, MPFR_RNDN); mpfr_cos (c, x, MPFR_RNDN); mpfr_sin_cos (s2, c2, x, MPFR_RNDN); if (mpfr_cmp (c2, c)) { printf("cos differs for x=77291789194529019661184401408"); exit (1); } if (mpfr_cmp (s2, s)) { printf("sin differs for x=77291789194529019661184401408"); exit (1); } mpfr_set_str_binary (x, "1.1001001000011111101101010100010001000010110100010011"); test_sin (x, x, MPFR_RNDZ); if (mpfr_cmp_str (x, "1.1111111111111111111111111111111111111111111111111111e-1", 2, MPFR_RNDN)) { printf ("Error for x= 1.1001001000011111101101010100010001000010110100010011\nGot "); mpfr_dump (x); exit (1); } mpfr_set_prec (s, 9); mpfr_set_prec (x, 190); mpfr_const_pi (x, MPFR_RNDN); mpfr_sin (s, x, MPFR_RNDZ); if (mpfr_cmp_str (s, "0.100000101e-196", 2, MPFR_RNDN)) { printf ("Error for x ~= pi\n"); mpfr_dump (s); exit (1); } mpfr_clear (s2); mpfr_clear (c2); mpfr_clear (s); mpfr_clear (c); mpfr_clear (x); test_generic (2, 100, 15); test_generic (MPFR_SINCOS_THRESHOLD-1, MPFR_SINCOS_THRESHOLD+1, 2); test_sign (); check_tiny (); data_check ("data/sin", mpfr_sin, "mpfr_sin"); bad_cases (mpfr_sin, mpfr_asin, "mpfr_sin", 256, -40, 0, 4, 128, 800, 50); tests_end_mpfr (); return 0; }