Example #1
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();

  test_generic (2, 100, 100);

  data_check ("data/sinh", mpfr_sinh, "mpfr_sinh");
  bad_cases (mpfr_sinh, mpfr_asinh, "mpfr_sinh", 256, -256, 255,
             4, 128, 800, 100);

  tests_end_mpfr ();
  return 0;
}
Example #2
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special_overflow ();
  special ();

  test_generic (2, 100, 100);

  data_check ("data/cosh", mpfr_cosh, "mpfr_cosh");
  bad_cases (mpfr_cosh, mpfr_acosh, "mpfr_cosh", 0, 1, 255, 4, 128, 800, 100);

  tests_end_mpfr ();
  return 0;
}
Example #3
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();

  test_generic (2, 100, 100);

  data_check ("data/expm1", mpfr_expm1, "mpfr_expm1");
  bad_cases (mpfr_expm1, mpfr_log1p, "mpfr_expm1", 256, -256, 255,
             4, 128, 800, 40);

  tests_end_mpfr ();
  return 0;
}
int
main (void)
{
  tests_start_mpfr ();

  special ();
  bad_case1 ();
  test_generic (2, 300, 15);

  data_check ("data/rec_sqrt", mpfr_rec_sqrt, "mpfr_rec_sqrt");
  bad_cases (mpfr_rec_sqrt, pm2, "mpfr_rec_sqrt", 8, -256, 255, 4, 128,
             800, 50);

  tests_end_mpfr ();
  return 0;
}
Example #5
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special_overflow ();
  special ();

  test_generic (MPFR_PREC_MIN, 100, 100);

  data_check ("data/tanh", mpfr_tanh, "mpfr_tanh");
  bad_cases (mpfr_tanh, mpfr_atanh, "mpfr_tanh", 256, -128, 0,
             4, 128, 800, 100);

  tests_end_mpfr ();
  return 0;
}
Example #6
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();
  other ();

  test_generic (MPFR_PREC_MIN, 100, 50);

  data_check ("data/log1p", mpfr_log1p, "mpfr_log1p");
  bad_cases (mpfr_log1p, mpfr_expm1, "mpfr_log1p", 256, -64, 40,
             4, 128, 800, 40);

  tests_end_mpfr ();
  return 0;
}
Example #7
0
int
main (void)
{
  mpfr_prec_t p;

  tests_start_mpfr ();

  check_special ();
  for (p = 2; p < 200; p++)
    check_random (p);

  test_generic (2, 200, 15);
  data_check ("data/sqr", mpfr_sqr, "mpfr_sqr");
  bad_cases (mpfr_sqr, mpfr_sqrt, "mpfr_sqr", 8, -256, 255, 4, 128, 800, 50);

  tests_end_mpfr ();
  return 0;
}
Example #8
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();
  bug20070831 ();
  huge ();

  test_generic (2, 100, 25);
  test_generic_huge (2, 100, 5);

  data_check ("data/acosh", mpfr_acosh, "mpfr_acosh");
  bad_cases (mpfr_acosh, mpfr_cosh, "mpfr_acosh", 0, -128, 29,
             4, 128, 800, 40);

  tests_end_mpfr ();
  return 0;
}
Example #9
0
File: tasin.c Project: Canar/mpfr
int
main (void)
{
  tests_start_mpfr ();

  special ();
  special_overflow ();
  reduced_expo_range ();

  test_generic (2, 100, 15);

  tests_end_mpfr ();

  data_check ("data/asin", mpfr_asin, "mpfr_asin");
  bad_cases (mpfr_asin, mpfr_sin, "mpfr_asin", 256, -40, 1, 4, 128, 800, 30);

  test20071215 ();

  tests_end_mpfr ();
  return 0;
}
Example #10
0
File: tatan.c Project: Canar/mpfr
int
main (int argc, char *argv[])
{
    tests_start_mpfr ();

    special_overflow ();
    special ();
    special_atan2 ();
    smallvals_atan2 ();
    atan2_bug_20071003 ();
    atan2_different_prec ();
    reduced_expo_range ();

    test_generic_atan  (2, 200, 17);
    test_generic_atan2 (2, 200, 17);
    test_generic_atan2_neg (2, 200, 17);

    data_check ("data/atan", mpfr_atan, "mpfr_atan");
    bad_cases (mpfr_atan, mpfr_tan, "mpfr_atan", 256, -40, 1, 4, 128, 800, 40);
    atan2_pow_of_2 ();

    tests_end_mpfr ();
    return 0;
}
int
main (int argc, char *argv[])
{
  mpfr_t x, y;
  int inex;

  tests_start_mpfr ();

  special_overflow ();
  check_nans ();

  mpfr_init (x);
  mpfr_init (y);

  mpfr_set_prec (x, 53);
  mpfr_set_prec (y, 2);
  mpfr_set_str (x, "9.81333845856942e-1", 10, MPFR_RNDN);
  test_cos (y, x, MPFR_RNDN);

  mpfr_set_prec (x, 30);
  mpfr_set_prec (y, 30);
  mpfr_set_str_binary (x, "1.00001010001101110010100010101e-1");
  test_cos (y, x, MPFR_RNDU);
  mpfr_set_str_binary (x, "1.10111100010101011110101010100e-1");
  if (mpfr_cmp (y, x))
    {
      printf ("Error for prec=30, rnd=MPFR_RNDU\n");
      printf ("expected "); mpfr_print_binary (x); puts ("");
      printf ("     got "); mpfr_print_binary (y); puts ("");
      exit (1);
    }

  mpfr_set_prec (x, 59);
  mpfr_set_prec (y, 59);
  mpfr_set_str_binary (x, "1.01101011101111010011111110111111111011011101100111100011e-3");
  test_cos (y, x, MPFR_RNDU);
  mpfr_set_str_binary (x, "1.1111011111110010001001001011100111101110100010000010010011e-1");
  if (mpfr_cmp (y, x))
    {
      printf ("Error for prec=59, rnd=MPFR_RNDU\n");
      printf ("expected "); mpfr_print_binary (x); puts ("");
      printf ("     got "); mpfr_print_binary (y); puts ("");
      exit (1);
    }

  mpfr_set_prec (x, 5);
  mpfr_set_prec (y, 5);
  mpfr_set_str_binary (x, "1.1100e-2");
  test_cos (y, x, MPFR_RNDD);
  mpfr_set_str_binary (x, "1.1100e-1");
  if (mpfr_cmp (y, x))
    {
      printf ("Error for x=1.1100e-2, rnd=MPFR_RNDD\n");
      printf ("expected 1.1100e-1, got "); mpfr_print_binary (y); puts ("");
      exit (1);
    }

  mpfr_set_prec (x, 32);
  mpfr_set_prec (y, 32);

  mpfr_set_str_binary (x, "0.10001000001001011000100001E-6");
  mpfr_set_str_binary (y, "0.1111111111111101101111001100001");
  test_cos (x, x, MPFR_RNDN);
  if (mpfr_cmp (x, y))
    {
      printf ("Error for prec=32 (1)\n");
      exit (1);
    }

  mpfr_set_str_binary (x, "-0.1101011110111100111010011001011E-1");
  mpfr_set_str_binary (y, "0.11101001100110111011011010100011");
  test_cos (x, x, MPFR_RNDN);
  if (mpfr_cmp (x, y))
    {
      printf ("Error for prec=32 (2)\n");
      exit (1);
    }

  /* huge argument reduction */
  mpfr_set_str_binary (x, "0.10000010000001101011101111001011E40");
  mpfr_set_str_binary (y, "0.10011000001111010000101011001011E-1");
  test_cos (x, x, MPFR_RNDN);
  if (mpfr_cmp (x, y))
    {
      printf ("Error for prec=32 (3)\n");
      exit (1);
    }

  mpfr_set_prec (x, 3);
  mpfr_set_prec (y, 3);
  mpfr_set_str_binary (x, "0.110E60");
  inex = mpfr_cos (y, x, MPFR_RNDD);
  MPFR_ASSERTN(inex < 0);

  /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
  check53 ("4.984987858808754279e-1", "8.783012931285841817e-1", MPFR_RNDN);
  check53 ("4.984987858808754279e-1", "8.783012931285840707e-1", MPFR_RNDD);
  check53 ("4.984987858808754279e-1", "8.783012931285840707e-1", MPFR_RNDZ);
  check53 ("4.984987858808754279e-1", "8.783012931285841817e-1", MPFR_RNDU);
  check53 ("1.00031274099908640274",  "0.540039116973283217504", MPFR_RNDN);
  check53 ("1.00229256850978698523",  "0.538371757797526551137", MPFR_RNDZ);
  check53 ("1.00288304857059840103",  "0.537874062022526966409", MPFR_RNDZ);
  check53 ("1.00591265847407274059",  "0.53531755997839769456",  MPFR_RNDN);

  check53 ("1.00591265847407274059", "0.53531755997839769456",  MPFR_RNDN);

  overflowed_cos0 ();
  test_generic (2, 100, 15);

  /* check inexact flag */
  mpfr_set_prec (x, 3);
  mpfr_set_prec (y, 13);
  mpfr_set_str_binary (x, "-0.100E196");
  inex = mpfr_cos (y, x, MPFR_RNDU);
  mpfr_set_prec (x, 13);
  mpfr_set_str_binary (x, "0.1111111100101");
  MPFR_ASSERTN (inex > 0 && mpfr_equal_p (x, y));

  mpfr_clear (x);
  mpfr_clear (y);

  bug20091030 ();

  data_check ("data/cos", mpfr_cos, "mpfr_cos");
  bad_cases (mpfr_cos, mpfr_acos, "mpfr_cos", 256, -40, 0, 4, 128, 800, 50);

  tests_end_mpfr ();
  return 0;
}
Example #12
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;
}
int
main (void)
{
  mpfr_prec_t p;
  int k;

  tests_start_mpfr ();

  for (p = MPFR_PREC_MIN; p <= 128; p++)
    {
      test_property1 (p, MPFR_RNDN, 0);
      test_property1 (p, MPFR_RNDU, 0);
      test_property1 (p, MPFR_RNDA, 0);
      test_property1 (p, MPFR_RNDN, 1);
      test_property1 (p, MPFR_RNDU, 1);
      test_property1 (p, MPFR_RNDA, 1);
      test_property2 (p, MPFR_RNDN);
    }

  check_diverse ("635030154261163106768013773815762607450069292760790610550915652722277604820131530404842415587328", 160, "796887792767063979679855997149887366668464780637");
  special ();
  check_nan ();

  for (p=2; p<200; p++)
    for (k=0; k<200; k++)
      check_inexact (p);
  check_float();

  check3 ("-0.0", MPFR_RNDN, "0.0");
  check4 ("6.37983013646045901440e+32", MPFR_RNDN, "5.9bc5036d09e0c@13");
  check4 ("1.0", MPFR_RNDN, "1");
  check4 ("1.0", MPFR_RNDZ, "1");
  check4 ("3.725290298461914062500000e-9", MPFR_RNDN, "4@-4");
  check4 ("3.725290298461914062500000e-9", MPFR_RNDZ, "4@-4");
  check4 ("1190456976439861.0", MPFR_RNDZ, "2.0e7957873529a@6");
  check4 ("1219027943874417664.0", MPFR_RNDZ, "4.1cf2af0e6a534@7");
  /* the following examples are bugs in Cygnus compiler/system, found by
     Fabrice Rouillier while porting mpfr to Windows */
  check4 ("9.89438396044940256501e-134", MPFR_RNDU, "8.7af7bf0ebbee@-56");
  check4 ("7.86528588050363751914e+31", MPFR_RNDZ, "1.f81fc40f32062@13");
  check4 ("0.99999999999999988897", MPFR_RNDN, "f.ffffffffffff8@-1");
  check4 ("1.00000000000000022204", MPFR_RNDN, "1");
  /* the following examples come from the paper "Number-theoretic Test
   Generation for Directed Rounding" from Michael Parks, Table 4 */

  check4 ("78652858805036375191418371571712.0", MPFR_RNDN,
          "1.f81fc40f32063@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDN,
          "1.60c012a92fc65@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDN,
          "1.51d17526c7161@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDN,
          "1.25e19302f7e51@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDN,
          "1.0ecea7dd2ec3d@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDN,
          "1.0ecf250e8e921@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDN,
          "1.5552f3eedcf33@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDN,
          "1.3853ee10c9c99@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDN,
          "1.556abe212b56f@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDN,
          "1.e2d9a51977e6e@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDZ,
          "1.f81fc40f32062@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDZ,
          "1.60c012a92fc64@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDZ, "1.51d17526c716@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDZ, "1.25e19302f7e5@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDZ,
          "1.0ecea7dd2ec3c@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDZ, "1.0ecf250e8e92@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDZ,
          "1.5552f3eedcf32@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDZ,
          "1.3853ee10c9c98@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDZ,
          "1.556abe212b56e@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDZ,
          "1.e2d9a51977e6d@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDU,
          "1.f81fc40f32063@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDU,
          "1.60c012a92fc65@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDU,
          "1.51d17526c7161@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDU,
          "1.25e19302f7e51@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDU,
          "1.0ecea7dd2ec3d@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDU,
          "1.0ecf250e8e921@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDU,
          "1.5552f3eedcf33@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDU,
          "1.3853ee10c9c99@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDU,
          "1.556abe212b56f@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDU,
          "1.e2d9a51977e6e@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDD,
          "1.f81fc40f32062@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDD,
          "1.60c012a92fc64@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDD, "1.51d17526c716@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDD, "1.25e19302f7e5@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDD,
          "1.0ecea7dd2ec3c@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDD, "1.0ecf250e8e92@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDD,
          "1.5552f3eedcf32@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDD,
          "1.3853ee10c9c98@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDD,
          "1.556abe212b56e@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDD,
          "1.e2d9a51977e6d@13");

  /* check that rounding away is just rounding toward plus infinity */
  check4 ("72154663483843080704304789585920.0", MPFR_RNDA,
          "1.e2d9a51977e6e@13");

  test_generic (2, 300, 15);
  data_check ("data/sqrt", mpfr_sqrt, "mpfr_sqrt");
  bad_cases (mpfr_sqrt, mpfr_sqr, "mpfr_sqrt", 8, -256, 255, 4, 128, 800, 50);

  tests_end_mpfr ();
  return 0;
}
Example #14
0
File: texp.c Project: jozip/xcl
int
main (int argc, char *argv[])
{
    tests_start_mpfr ();

    if (argc > 1)
        check_large ();

    check_inexact ();
    check_special ();

    test_generic (2, 100, 100);

    compare_exp2_exp3 (20, 1000);
    check_worst_cases();
    check3("0.0", MPFR_RNDU, "1.0");
    check3("-1e-170", MPFR_RNDU, "1.0");
    check3("-1e-170", MPFR_RNDN, "1.0");
    check3("-8.88024741073346941839e-17", MPFR_RNDU, "1.0");
    check3("8.70772839244701057915e-01", MPFR_RNDN, "2.38875626491680437269");
    check3("1.0", MPFR_RNDN, "2.71828182845904509080");
    check3("-3.42135637628104173534e-07", MPFR_RNDZ, "0.999999657864420798958");
    /* worst case for argument reduction, very near from 5*log(2),
       thanks to Jean-Michel Muller  */
    check3("3.4657359027997265421", MPFR_RNDN, "32.0");
    check3("3.4657359027997265421", MPFR_RNDU, "32.0");
    check3("3.4657359027997265421", MPFR_RNDD, "31.999999999999996447");
    check3("2.26523754332090625496e+01", MPFR_RNDD, "6.8833785261699581146e9");
    check3("1.31478962104089092122e+01", MPFR_RNDZ, "5.12930793917860137299e+05");
    check3("4.25637507920002378103e-01", MPFR_RNDU, "1.53056585656161181497e+00");
    check3("6.26551618962329307459e-16", MPFR_RNDU, "1.00000000000000066613e+00");
    check3("-3.35589513871216568383e-03",MPFR_RNDD, "9.96649729583626853291e-01");
    check3("1.95151388850007272424e+01", MPFR_RNDU, "2.98756340674767792225e+08");
    check3("2.45045953503350730784e+01", MPFR_RNDN, "4.38743344916128387451e+10");
    check3("2.58165606081678085104e+01", MPFR_RNDD, "1.62925781879432281494e+11");
    check3("-2.36539020084338638128e+01",MPFR_RNDZ, "5.33630792749924762447e-11");
    check3("2.39211946135858077866e+01", MPFR_RNDU, "2.44817704330214385986e+10");
    check3("-2.78190533055889162029e+01",MPFR_RNDZ, "8.2858803483596879512e-13");
    check3("2.64028186174889789584e+01", MPFR_RNDD, "2.9281844652878973388e11");
    check3("2.92086338843268329413e+01", MPFR_RNDZ, "4.8433797301907177734e12");
    check3("-2.46355324071459982349e+01",MPFR_RNDZ, "1.9995129297760994791e-11");
    check3("-2.23509444608605427618e+01",MPFR_RNDZ, "1.9638492867489702307e-10");
    check3("-2.41175390197331687148e+01",MPFR_RNDD, "3.3564940885530624592e-11");
    check3("2.46363885231578088053e+01", MPFR_RNDU, "5.0055014282693267822e10");
    check3("111.1263531080090984914932050742208957672119140625", MPFR_RNDN, "1.8262572323517295459e48");
    check3("-3.56196340354684821250e+02",MPFR_RNDN, "2.0225297096141478156e-155");
    check3("6.59678273772710895173e+02", MPFR_RNDU, "3.1234469273830195529e286");
    check3("5.13772529701934331570e+02", MPFR_RNDD, "1.3445427121297197752e223");
    check3("3.57430211008718345056e+02", MPFR_RNDD, "1.6981197246857298443e155");
    check3("3.82001814471465536371e+02", MPFR_RNDU, "7.9667300591087367805e165");
    check3("5.92396038219384422518e+02", MPFR_RNDD, "1.880747529554661989e257");
    check3("-5.02678550462488090034e+02",MPFR_RNDU, "4.8919201895446217839e-219");
    check3("5.30015757134837031117e+02", MPFR_RNDD, "1.5237672861171573939e230");
    check3("5.16239362447650933063e+02", MPFR_RNDZ, "1.5845518406744492105e224");
    check3("6.00812634798592370977e-01", MPFR_RNDN, "1.823600119339019443");
    check_exp10 ();

    bug20080731 ();

    overflowed_exp0 ();
    underflow ();

    data_check ("data/exp", mpfr_exp, "mpfr_exp");
    bad_cases (mpfr_exp, mpfr_log, "mpfr_exp", 0, -256, 255, 4, 128, 800, 50);

    tests_end_mpfr ();
    return 0;
}
Example #15
0
File: tlog.c Project: epowers/mpfr
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  if (argc==4)
    {   /* tlog x prec rnd */
      check3 (atof(argv[1]), atoi(argv[2]), (mpfr_rnd_t) atoi(argv[3]));
      goto done;
    }

  special ();
  check_worst_cases();

  check2("1.01979300812244555452", MPFR_RNDN, "1.95996734891603664741e-02");
  check2("10.0",MPFR_RNDU,"2.30258509299404590110e+00");
  check2("6.0",MPFR_RNDU,"1.79175946922805517936");
  check2("1.0",MPFR_RNDZ,"0.0");
  check2("62.0",MPFR_RNDU,"4.12713438504509166905");
  check2("0.5",MPFR_RNDZ,"-6.93147180559945286226e-01");
  check2("3.0",MPFR_RNDZ,"1.09861228866810956006e+00");
  check2("234375765.0",MPFR_RNDU,"1.92724362186836231104e+01");
  check2("8.0",MPFR_RNDZ,"2.07944154167983574765e+00");
  check2("44.0",MPFR_RNDU,"3.78418963391826146392e+00");
  check2("1.01979300812244555452", MPFR_RNDN, "1.95996734891603664741e-02");

  /* bugs found by Vincent Lefe`vre */
  check2("0.99999599881598921769", MPFR_RNDN, "-0.0000040011920155404072924737977900999652547398000024259090423583984375");
  check2("9.99995576063808955247e-01",MPFR_RNDZ,"-4.42394597667932383816e-06");
  check2("9.99993687357856209097e-01",MPFR_RNDN,"-6.31266206860017342601e-06");
  check2("9.99995223520736886691e-01",MPFR_RNDN,"-4.77649067052670982220e-06");
  check2("9.99993025794720935551e-01",MPFR_RNDN,"-6.97422959894716163837e-06");
  check2("9.99987549017837484833e-01",MPFR_RNDN,"-1.24510596766369924330e-05");
  check2("9.99985901426543311032e-01",MPFR_RNDN,"-1.40986728425098585229e-05");
  check2("9.99986053947420794330e-01",MPFR_RNDN, "-0.000013946149826301084938555592540598837558718514628708362579345703125");
  check2("9.99971938247442126979e-01",MPFR_RNDN,"-2.80621462962173414790e-05");

  /* other bugs found by Vincent Lefe`vre */
  check2("1.18615436389927785905e+77",MPFR_RNDN,"1.77469768607706015473e+02");
  check2("9.48868723578399476187e+77",MPFR_RNDZ,"1.79549152432275803903e+02");
  check2("2.31822210096938820854e+89",MPFR_RNDN,"2.05770873832573869322e+02");

  /* further bugs found by Vincent Lefe`vre */
  check2("9.99999989485669482647e-01",MPFR_RNDZ,"-1.05143305726283042331e-08");
  check2("9.99999989237970177136e-01",MPFR_RNDZ,"-1.07620298807745377934e-08");
  check2("9.99999989239339082125e-01",MPFR_RNDN,"-1.07606609757704445430e-08");

  check2("7.3890560989306504",MPFR_RNDU,"2.0000000000000004"); /* exp(2.0) */
  check2("7.3890560989306495",MPFR_RNDU,"2.0"); /* exp(2.0) */
  check2("7.53428236571286402512e+34",MPFR_RNDZ,"8.03073567492226345621e+01");
  check2("6.18784121531737948160e+19",MPFR_RNDZ,"4.55717030391710693493e+01");
  check2("1.02560267603047283735e+00",MPFR_RNDD,"2.52804164149448735987e-02");
  check2("7.53428236571286402512e+34",MPFR_RNDZ,"8.03073567492226345621e+01");
  check2("1.42470900831881198052e+49",MPFR_RNDZ,"113.180637144887668910087086260318756103515625");

  check2("1.08013816255293777466e+11",MPFR_RNDN,"2.54055249841782604392e+01");
  check2("6.72783635300509015581e-37",MPFR_RNDU,"-8.32893948416799503320e+01");
  check2("2.25904918906057891180e-52",MPFR_RNDU,"-1.18919480823735682406e+02");
  check2("1.48901209246462951085e+00",MPFR_RNDD,"3.98112874867437460668e-01");
  check2("1.70322470467612341327e-01",MPFR_RNDN,"-1.77006175364294615626");
  check2("1.94572026316065240791e+01",MPFR_RNDD,"2.96821731676437838842");
  check2("4.01419512207026418764e+04",MPFR_RNDD,"1.06001772315501128218e+01");
  check2("9.47077365236487591672e-04",MPFR_RNDZ,"-6.96212977303956748187e+00");
  check2("3.95906157687589643802e-109",MPFR_RNDD,"-2.49605768114704119399e+02");
  check2("2.73874914516503004113e-02",MPFR_RNDD,"-3.59766888618655977794e+00");
  check2("9.18989072589566467669e-17",MPFR_RNDZ,"-3.69258425351464083519e+01");
  check2("7706036453608191045959753324430048151991964994788917248.0",MPFR_RNDZ,"126.3815989984199177342816255986690521240234375");
  check2("1.74827399630587801934e-23",MPFR_RNDZ,"-5.24008281254547156891e+01");
  check2("4.35302958401482307665e+22",MPFR_RNDD,"5.21277441046519527390e+01");
  check2("9.70791868689332915209e+00",MPFR_RNDD,"2.27294191194272210410e+00");
  check2("2.22183639799464011100e-01",MPFR_RNDN,"-1.50425103275253957413e+00");
  check2("2.27313466156682375540e+00",MPFR_RNDD,"8.21159787095675608448e-01");
  check2("6.58057413965851156767e-01",MPFR_RNDZ,"-4.18463096196088235600e-01");
  check2 ("7.34302197248998461006e+43",MPFR_RNDZ,"101.0049094695131799426235374994575977325439453125");
  check2("6.09969788341579732815e+00",MPFR_RNDD,"1.80823924264386204363e+00");

  x_near_one ();

  test_generic (2, 100, 40);

  data_check ("data/log", mpfr_log, "mpfr_log");
  bad_cases (mpfr_log, mpfr_exp, "mpfr_log", 256, -30, 30, 4, 128, 800, 50);

 done:
  tests_end_mpfr ();
  return 0;
}
Example #16
0
int
main (void)
{
  mpfr_t x, y;
  int r;

  tests_start_mpfr ();

  special_overflow ();
  special ();

  mpfr_init (x);
  mpfr_init (y);

  MPFR_SET_NAN(x);
  mpfr_acos (y, x, MPFR_RNDN);
  if (mpfr_nan_p(y) == 0)
    {
      printf ("Error: acos(NaN) != NaN\n");
      exit (1);
    }

  mpfr_set_ui (x, 2, MPFR_RNDN);
  mpfr_acos (y, x, MPFR_RNDN);
  if (mpfr_nan_p(y) == 0)
    {
      printf ("Error: acos(2) != NaN\n");
      exit (1);
    }

  mpfr_set_si (x, -2, MPFR_RNDN);
  mpfr_acos (y, x, MPFR_RNDN);
  if (mpfr_nan_p(y) == 0)
    {
      printf ("Error: acos(-2) != NaN\n");
      exit (1);
    }

  /* acos (1) = 0 */
  mpfr_set_ui (x, 1, MPFR_RNDN);
  mpfr_acos (y, x, MPFR_RNDN);
  if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
    {
      printf ("Error: acos(1) != +0.0\n");
      exit (1);
    }

  /* acos (0) = Pi/2 */
  for (r = 0; r < MPFR_RND_MAX; r++)
    {
      mpfr_set_ui (x, 0, MPFR_RNDN); /* exact */
      mpfr_acos (y, x, (mpfr_rnd_t) r);
      mpfr_const_pi (x, (mpfr_rnd_t) r);
      mpfr_div_2exp (x, x, 1, MPFR_RNDN); /* exact */
      if (mpfr_cmp (x, y))
        {
          printf ("Error: acos(0) != Pi/2 for rnd=%s\n",
                  mpfr_print_rnd_mode ((mpfr_rnd_t) r));
          exit (1);
        }
    }

  /* acos (-1) = Pi */
  for (r = 0; r < MPFR_RND_MAX; r++)
    {
      mpfr_set_si (x, -1, MPFR_RNDN); /* exact */
      mpfr_acos (y, x, (mpfr_rnd_t) r);
      mpfr_const_pi (x, (mpfr_rnd_t) r);
      if (mpfr_cmp (x, y))
        {
          printf ("Error: acos(1) != Pi for rnd=%s\n",
                  mpfr_print_rnd_mode ((mpfr_rnd_t) r));
          exit (1);
        }
    }

  test_generic (2, 100, 7);

  mpfr_clear (x);
  mpfr_clear (y);

  data_check ("data/acos", mpfr_acos, "mpfr_acos");
  bad_cases (mpfr_acos, mpfr_cos, "mpfr_acos", 0, -40, 2, 4, 128, 800, 30);

  tests_end_mpfr ();
  return 0;
}
Example #17
0
int
main (int argc, char *argv[])
{
  mpfr_t x;
  unsigned int i;
  unsigned int prec[10] = {14, 15, 19, 22, 23, 24, 25, 40, 41, 52};
  unsigned int prec2[10] = {4, 5, 6, 19, 70, 95, 100, 106, 107, 108};

  tests_start_mpfr ();

  check_nans ();

  mpfr_init (x);

  mpfr_set_prec (x, 2);
  mpfr_set_str (x, "0.5", 10, MPFR_RNDN);
  mpfr_tan (x, x, MPFR_RNDD);
  if (mpfr_cmp_ui_2exp(x, 1, -1))
    {
      printf ("mpfr_tan(0.5, MPFR_RNDD) failed\n"
              "expected 0.5, got");
      mpfr_print_binary(x);
      putchar('\n');
      exit (1);
    }

  /* check that tan(3*Pi/4) ~ -1 */
  for (i=0; i<10; i++)
    {
      mpfr_set_prec (x, prec[i]);
      mpfr_const_pi (x, MPFR_RNDN);
      mpfr_mul_ui (x, x, 3, MPFR_RNDN);
      mpfr_div_ui (x, x, 4, MPFR_RNDN);
      mpfr_tan (x, x, MPFR_RNDN);
      if (mpfr_cmp_si (x, -1))
        {
          printf ("tan(3*Pi/4) fails for prec=%u\n", prec[i]);
          exit (1);
        }
    }

  /* check that tan(7*Pi/4) ~ -1 */
  for (i=0; i<10; i++)
    {
      mpfr_set_prec (x, prec2[i]);
      mpfr_const_pi (x, MPFR_RNDN);
      mpfr_mul_ui (x, x, 7, MPFR_RNDN);
      mpfr_div_ui (x, x, 4, MPFR_RNDN);
      mpfr_tan (x, x, MPFR_RNDN);
      if (mpfr_cmp_si (x, -1))
        {
          printf ("tan(3*Pi/4) fails for prec=%u\n", prec2[i]);
          exit (1);
        }
    }

  mpfr_clear (x);

  test_generic (2, 100, 10);

  data_check ("data/tan", mpfr_tan, "mpfr_tan");
  bad_cases (mpfr_tan, mpfr_atan, "mpfr_tan", 256, -256, 255, 4, 128, 800, 40);

  tests_end_mpfr ();
  return 0;
}