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

  check_inexact ();
  check_cmp (argc, argv);

  test_generic (2, 1000, 10);

  tests_end_mpfr ();
  return 0;
}
Example #2
0
int
main (void)
{
  tests_start_mpfr ();
  /* We test iff long = mp_limb_t */
  if (sizeof (long) == sizeof (mp_limb_t))
    {
      test1 ();
      test2 ();
      test_nan_inf_zero ();
    }
  tests_end_mpfr ();
  return 0;
}
Example #3
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();

  test_generic (2, 100, 30);

  data_check ("data/log2", mpfr_log2, "mpfr_log2");

  tests_end_mpfr ();
  return 0;
}
Example #4
0
int
main (void)
{
  tests_start_mpfr ();
  mpfr_test_init ();

  bug20090520 ();

  check_round ();
  check_inf_nan ();

  tests_end_mpfr ();
  return 0;
}
Example #5
0
int
main (int argc, char *argv[])
{
  mpfr_t x, z;
  int y;
  int i;

  tests_start_mpfr ();
  mpfr_inits2 (53, x, z, (mpfr_ptr) 0);
  for(i = 0 ; i < numberof (tab) ; i++)
    {
      mpfr_set_str (x, tab[i].op1, 16, MPFR_RNDN);
      y = tab[i].op2;
      mpfr_add_si (z, x, y, MPFR_RNDZ);
      if (mpfr_cmp_str (z, tab[i].res_add, 16, MPFR_RNDN))
        ERROR1("add_si", i, z, tab[i].res_add);
      mpfr_sub_si (z, x, y, MPFR_RNDZ);
      if (mpfr_cmp_str (z, tab[i].res_sub, 16, MPFR_RNDN))
        ERROR1("sub_si", i, z, tab[i].res_sub);
      mpfr_si_sub (z, y, x, MPFR_RNDZ);
      mpfr_neg (z, z, MPFR_RNDZ);
      if (mpfr_cmp_str (z, tab[i].res_sub, 16, MPFR_RNDN))
        ERROR1("si_sub", i, z, tab[i].res_sub);
      mpfr_mul_si (z, x, y, MPFR_RNDZ);
      if (mpfr_cmp_str (z, tab[i].res_mul, 16, MPFR_RNDN))
        ERROR1("mul_si", i, z, tab[i].res_mul);
      mpfr_div_si (z, x, y, MPFR_RNDZ);
      if (mpfr_cmp_str (z, tab[i].res_div, 16, MPFR_RNDN))
        ERROR1("div_si", i, z, tab[i].res_div);
    }
  mpfr_set_str1 (x, "1");
  mpfr_si_div (z, 1024, x, MPFR_RNDN);
  if (mpfr_cmp_str1 (z, "1024"))
    ERROR1("si_div", i, z, "1024");
  mpfr_si_div (z, -1024, x, MPFR_RNDN);
  if (mpfr_cmp_str1 (z, "-1024"))
    ERROR1("si_div", i, z, "-1024");

  mpfr_clears (x, z, (mpfr_ptr) 0);

  check_invert ();

  test_generic_add_si (2, 200, 17);
  test_generic_sub_si (2, 200, 17);
  test_generic_mul_si (2, 200, 17);
  test_generic_div_si (2, 200, 17);

  tests_end_mpfr ();
  return 0;
}
Example #6
0
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");

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

  special_overflow ();
  special ();

  test_generic (2, 100, 100);

  data_check ("data/tanh", mpfr_tanh, "mpfr_tanh");

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

  tests_start_mpfr ();

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

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

  bug20090519 ();

  test_generic (2, 100, 100);

  special ();
  regular ();

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

  special ();

  test_large ();
  alltst ();

  test_generic (2, 100, 10);

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

  tcc_bug20160606 ();

  special ();
  test_generic (MPFR_PREC_MIN, 100, 2);

  data_check ("data/lgamma", mpfr_lgamma1, "mpfr_lgamma");

  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 #13
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 #14
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 #15
0
int
main (int argc, char **argv)
{
  void *ptr;

  tests_start_mpfr ();
  tests_expect_abort ();

  printf ("[tabort_defalloc2] Check for good handling of abort"
          " in memory function.\n");
  ptr = (*__gmp_allocate_func) (128);
  ptr = (*__gmp_reallocate_func) (ptr, 128, (size_t) -1);

  tests_end_mpfr ();
  return -1; /* Should not be executed */
}
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  check_special();
  check_reftable ();
  check_parse ();
  check_overflow ();
  check_retval ();
  bug20081028 ();
  test20100310 ();

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

  special ();
  special_overflow ();
  test_generic (2, 100, 2);
  gamma_integer ();

  data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");

  tests_end_mpfr ();
  return 0;
}
Example #18
0
int
main (int argc, char *argv[])
{
  long j;

  tests_start_mpfr ();

  check (0, MPFR_RNDN);
  for (j = 0; j < 200000; j++)
    check (randlimb () & LONG_MAX, RND_RAND ());
  check0 ();

  tests_end_mpfr ();

  return 0;
}
Example #19
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;
}
Example #20
0
int
main (int argc, char *argv[])
{
  mpfr_t x;
  FILE *f;
  int i;
  tests_start_mpfr ();

  mpfr_init (x);

  mpfr_set_prec (x, 15);
  f = src_fopen ("inp_str.data", "r");
  if (f == NULL)
    {
      printf ("Error, can't open inp_str.data\n");
      exit (1);
    }
  i = mpfr_inp_str (x, f, 10, GMP_RNDN);
  if (i == 0 || mpfr_cmp_ui (x, 31415))
    {
      printf ("Error in reading 1st line from file inp_str.data (%d)\n", i);
      mpfr_dump (x);
      exit (1);
    }
  getc (f);
  i = mpfr_inp_str (x, f, 10, GMP_RNDN);
  if ((i == 0) || mpfr_cmp_ui (x, 31416))
    {
      printf ("Error in reading 2nd line from file inp_str.data (%d)\n", i);
      mpfr_dump (x);
      exit (1);
    }
  getc (f);
  i = mpfr_inp_str (x, f, 10, GMP_RNDN);
  if (i != 0)
    {
      printf ("Error in reading 3rd line from file inp_str.data (%d)\n", i);
      mpfr_dump (x);
      exit (1);
    }
  fclose (f);

  mpfr_clear (x);

  tests_end_mpfr ();
  return 0;
}
Example #21
0
int
main (void)
{
  mpfr_prec_t p;
  unsigned long n;

  tests_start_mpfr ();

  check_special ();
  test_sort (1764, 1026);
  for (p = 2 ; p < 444 ; p += 17)
    for (n = 2 ; n < 1026 ; n += 42 + p)
      test_sum (p, n);

  tests_end_mpfr ();
  return 0;
}
Example #22
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 #23
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 #24
0
File: tadd.c Project: qsnake/mpfr
int
main (int argc, char *argv[])
{
    tests_start_mpfr ();

    usesp = 0;
    tests ();

#ifndef CHECK_EXTERNAL /* no need to check twice */
    usesp = 1;
    tests ();
#endif
    test_generic (2, 1000, 100);

    tests_end_mpfr ();
    return 0;
}
Example #25
0
File: tl2b.c Project: Canar/mpfr
int
main (int argc, char *argv[])
{
  if (argc != 1)
    {
      /* Generate code that initializes the l2b constants. */
      compute_l2b (1);
    }
  else
    {
      /* Check the l2b constants. */
      tests_start_mpfr ();
      compute_l2b (0);
      tests_end_mpfr ();
    }
  return 0;
}
Example #26
0
int
main (int argc, char **argv)
{
  tests_start_mpfr ();

  /* The tested function and macro exist in MPFR 2.2.0, but with a
     different (incorrect, but with no effect in 2.2.0) behavior. */
#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
  test_int_ceil_log2 ();
#endif

  test_round_near_x ();
  test_set_prec_raw ();

  tests_end_mpfr ();
  return 0;
}
Example #27
0
int
main (void)
{
  mpfr_t x, y, z;

  tests_start_mpfr ();

  mpfr_init (x);
  mpfr_init (y);
  mpfr_init (z);

  /* case y=NaN */
  mpfr_set_nan (y);
  mpfr_set_ui (x, 1250, GMP_RNDN);
  mpfr_copysign (z, x, y, GMP_RNDN);
  if (!mpfr_nan_p (z))
    {
      printf ("Error in mpfr_copysign (NaN)\n");
      exit (1);
    }
  /* case y!=NaN */
  mpfr_set_ui (y, 123, GMP_RNDN);
  mpfr_set_ui (x, 1250, GMP_RNDN);
  mpfr_copysign (z, x, y, GMP_RNDN);
  if (mpfr_cmp_ui (z, 1250))
    {
      printf ("Error in mpfr_copysign (1250)\n");
      exit (1);
    }
  mpfr_set_si (y, -17, GMP_RNDN);
  mpfr_set_ui (x, 42, GMP_RNDN);
  mpfr_copysign (z, x, y, GMP_RNDN);
  if (mpfr_cmp_si (z, -42))
    {
      printf ("Error in mpfr_copysign (-42)\n");
      exit (1);
    }

  mpfr_clear (x);
  mpfr_clear (y);
  mpfr_clear (z);

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

  bug20091013 ();

  special ();

  normal ();

  test_generic (2, 100, 2);

  data_check ("data/li2", mpfr_li2, "mpfr_li2");

  tests_end_mpfr ();
  return 0;
}
Example #29
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 #30
0
int
main (void)
{
  mpfr_t x, y, z;
  double d;
  int inexact;

  tests_start_mpfr ();

  /* check with enough precision */
  mpfr_init2 (x, IEEE_DBL_MANT_DIG);
  mpfr_init2 (y, IEEE_DBL_MANT_DIG);
  mpfr_init2 (z, IEEE_DBL_MANT_DIG);

  mpfr_set_str (y, "4096", 10, MPFR_RNDN);
  d = 0.125;
  mpfr_clear_flags ();
  inexact = mpfr_d_sub (x, d, y, MPFR_RNDN);
  if (inexact != 0)
    {
      printf ("Inexact flag error in mpfr_d_sub\n");
      exit (1);
    }
  mpfr_set_str (z, "-4095.875", 10, MPFR_RNDN);
  if (mpfr_cmp (z, x))
    {
      printf ("Error in mpfr_d_sub (");
      mpfr_out_str (stdout, 10, 7, y, MPFR_RNDN);
      printf (" + %.20g)\nexpected ", d);
      mpfr_out_str (stdout, 10, 0, z, MPFR_RNDN);
      printf ("\ngot     ");
      mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
      printf ("\n");
      exit (1);
    }
  mpfr_clears (x, y, z, (mpfr_ptr) 0);

  check_nans ();

  test_generic (2, 1000, 100);

  tests_end_mpfr ();
  return 0;
}