Ejemplo n.º 1
0
int
main (int argc, char *argv[])
{
  long nbtests;
  mpfr_prec_t prec;
  int verbose = 0;
  int rnd;
  long bit_index;

  tests_start_mpfr ();

  if (argc > 1)
    verbose = 1;

  nbtests = 10000;
  if (argc > 1)
    {
      long a = atol(argv[1]);
      if (a != 0)
        nbtests = a;
    }

  if (argc <= 2)
    prec = 1000;
  else
    prec = atol(argv[2]);

  if (argc <= 3)
    bit_index = -1;
  else
    {
      bit_index = atol(argv[3]);
      if (bit_index >= prec)
        {
          printf ("Warning. Cannot compute the bit frequency: the given bit "
                  "index (= %ld) is not less than the precision (= %ld).\n",
                  bit_index, (long) prec);
          bit_index = -1;
        }
    }

  RND_LOOP(rnd)
    {
      test_urandom (nbtests, prec, (mpfr_rnd_t) rnd, bit_index, verbose);

      if (argc == 1)  /* check also small precision */
        {
          test_urandom (nbtests, 2, (mpfr_rnd_t) rnd, -1, 0);
        }
    }

#ifndef MPFR_USE_MINI_GMP
  /* since this test assumes a deterministic random generator, and this is not
     implemented in mini-gmp, we omit it with mini-gmp */
  bug20100914 ();
#endif

  tests_end_mpfr ();
  return 0;
}
Ejemplo n.º 2
0
int
main (int argc, char *argv[])
{
  long nbtests;
  mpfr_prec_t prec;
  int verbose = 0;

  tests_start_mpfr ();

  if (argc > 1)
    verbose = 1;

  nbtests = 10000;
  if (argc > 1)
    {
      long a = atol(argv[1]);
      if (a != 0)
        nbtests = a;
    }

  if (argc <= 2)
    prec = 1000;
  else
    prec = atol(argv[2]);

  test_urandomb (nbtests, prec, verbose);

  if (argc == 1)  /* check also small precision */
    {
      test_urandomb (nbtests, 2, 0);
    }

  bug20100914 ();

  tests_end_mpfr ();
  return 0;
}
Ejemplo n.º 3
0
int
main (int argc, char *argv[])
{
    long nbtests;
    mpfr_prec_t prec;
    int verbose = 0;

    tests_start_mpfr ();

    if (argc > 1)
        verbose = 1;

    nbtests = 10000;
    if (argc > 1)
    {
        long a = atol(argv[1]);
        if (a != 0)
            nbtests = a;
    }

    if (argc <= 2)
        prec = 1000;
    else
        prec = atol(argv[2]);

    test_urandomb (nbtests, prec, verbose);

    if (argc == 1)  /* check also small precision */
    {
        test_urandomb (nbtests, 2, 0);
    }

#ifndef MPFR_USE_MINI_GMP

    /* Since these tests assume a deterministic random generator, and this
       is not implemented in mini-gmp, we omit them with mini-gmp. */

    bug20100914 ();

#if __MPFR_GMP(4,2,0)
    /* Get a non-zero fixed-point number whose first 32 bits are 0 with the
       default GMP PRNG. This corresponds to the case cnt == 0 && k != 0 in
       src/urandomb.c (fixed in r8762) with the 32-bit ABI. */
    {
        gmp_randstate_t s;
        mpfr_t x;
        char *str = "0.1010111100000000000000000000000000000000E-32";
        int k;

        gmp_randinit_default (s);
        gmp_randseed_ui (s, 4518);
        mpfr_init2 (x, 40);

        for (k = 0; k < 575123; k++)
        {
            mpfr_urandomb (x, s);
            MPFR_ASSERTN (MPFR_IS_FP (x));
        }

        if (mpfr_cmp_str (x, str, 2, MPFR_RNDN) != 0)
        {
            printf ("Error in test_urandomb:\n");
            printf ("Expected %s\n", str);
            printf ("Got      ");
            mpfr_dump (x);
            exit (1);
        }

        mpfr_clear (x);
        gmp_randclear (s);
    }
#endif

#endif

    tests_end_mpfr ();
    return 0;
}