コード例 #1
0
ファイル: read.c プロジェクト: clear731/lattice
int 
fmpz_read(fmpz_t f)
{
    mpz_t t;
    size_t r;

    mpz_init(t);
    r = mpz_inp_str(t, stdin, 10);
    fmpz_set_mpz(f, t);
    mpz_clear(t);

    return (r > 0) ? 1 : 0;
}
コード例 #2
0
ファイル: evaluate_mpz.c プロジェクト: clear731/lattice
void fmpq_poly_evaluate_mpz(mpq_t res, const fmpq_poly_t poly, const mpz_t a)
{
    fmpq_t r;
    fmpz_t b;

    fmpq_init(r);
    fmpz_init(b);
    fmpz_set_mpz(b, a);
    fmpq_poly_evaluate_fmpz(r, poly, b);
    fmpq_get_mpq(res, r);
    fmpq_clear(r);
    fmpz_clear(b);
}
コード例 #3
0
ファイル: t-setbit.c プロジェクト: goens/flint2
int
main(void)
{
    int i, result;
    flint_rand_t state;

    printf("setbit....");
    fflush(stdout);

    flint_randinit(state);

    for (i = 0; i < 100000; i++)
    {
        ulong j;
        fmpz_t a, c;
        mpz_t b;

        fmpz_init(a);
        fmpz_init(c);
        mpz_init(b);

        fmpz_randtest(a, state, 2 * FLINT_BITS);
        fmpz_get_mpz(b, a);
        j = n_randint(state, 3 * FLINT_BITS);

        fmpz_setbit(a, j);
        mpz_setbit(b, j);
        fmpz_set_mpz(c, b);

        result = (fmpz_equal(a, c));

        if (!result)
        {
            printf("FAIL:\n");
            printf("a = "), fmpz_print(a), printf("\n");
            gmp_printf("b = %Zd\n", b);
            printf("c = "), fmpz_print(c), printf("\n");
            printf("j = %ld\n", j);
            abort();
        }

        fmpz_clear(a);
        fmpz_clear(c);
        mpz_clear(b);
    }

    flint_randclear(state);
    _fmpz_cleanup();
    printf("PASS\n");
    return 0;
}
コード例 #4
0
vec_integer_class UIntPolyFlint::multieval(const vec_integer_class &v) const
{
    const unsigned int n = v.size();
    fmpz *fvp = _fmpz_vec_init(n);
    for (unsigned int i = 0; i < n; ++i)
        fmpz_set_mpz(fvp + i, get_mpz_t(v[i]));

    poly_.eval_vec(fvp, fvp, n);
    vec_integer_class res(n);
    for (unsigned int i = 0; i < n; ++i)
        res[i] = to_integer_class(fvp + i);
    _fmpz_vec_clear(fvp, n);
    return res;
}
コード例 #5
0
ファイル: harmonic_number.c プロジェクト: goens/flint2
static void
_mpq_harmonic_odd_balanced(fmpz_t num, fmpz_t den, long n)
{
    mpz_t p, q;

    mp_ptr t, v;
    mp_size_t ts, vs;
    long size;

    if (n <= 0)
    {
        fmpz_zero(num);
        fmpz_one(den);
        return;
    }

    /* TODO: we could avoid the copying/allocation overhead when there
       is guaranteed to be sufficient space in res already */

    size = FLINT_BIT_COUNT(n) * (n+2) + 2*FLINT_BITS;
    mpz_init2(p, size);
    mpz_init2(q, size);
    t = p->_mp_d;
    v = q->_mp_d;

    mpn_harmonic_odd_balanced(t, &ts, v, &vs, 1, n+1, n, 1);
    p->_mp_size = ts;
    q->_mp_size = vs;

    fmpz_set_mpz(num, p);
    fmpz_set_mpz(den, q);

    mpz_clear(p);
    mpz_clear(q);

    _fmpq_canonicalise(num, den);
}
コード例 #6
0
ファイル: set_array_mpq.c プロジェクト: hemmecke/flint2
void
_fmpq_poly_set_array_mpq(fmpz * poly, fmpz_t den, const mpq_t * a, long n)
{
    long i;
    mpz_t d, t;
    
    mpz_init_set_ui(d, 1);
    mpz_init(t);
    for (i = 0; i < n; i++)
        mpz_lcm(d, d, mpq_denref(a[i]));
    
    for (i = 0; i < n; i++)
    {
        mpz_divexact(t, d, mpq_denref(a[i]));
        mpz_mul((mpz_ptr) mpq_numref(a[i]), (mpz_ptr) mpq_numref(a[i]), t);
    }
    
    for (i = 0; i < n; i++)
        fmpz_set_mpz(poly + i, (mpz_ptr) mpq_numref(a[i]));
    
    fmpz_set_mpz(den, d);
    mpz_clear(d);
    mpz_clear(t);
}
コード例 #7
0
ファイル: dgsl.c プロジェクト: malb/gghlite-flint
int dgsl_mp_call_identity(fmpz *rop,  const dgsl_mp_t *self, gmp_randstate_t state) {
  assert(rop); assert(self);

  const long n = fmpz_mat_ncols(self->B);
  mpz_t  tmp_g;  mpz_init(tmp_g);

  _fmpz_vec_zero(rop, n);

  for(long i=0; i<n; i++) {
    self->D[0]->call(tmp_g, self->D[0], state);
    fmpz_set_mpz(rop+i, tmp_g);
  }

  mpz_clear(tmp_g);

  return 0;
}
コード例 #8
0
ファイル: dgsl.c プロジェクト: malb/gghlite-flint
int dgsl_mp_call_inlattice(fmpz *rop,  const dgsl_mp_t *self, gmp_randstate_t state) {
  assert(rop); assert(self);

  const long m = fmpz_mat_nrows(self->B);
  const long n = fmpz_mat_ncols(self->B);
  mpz_t  tmp_g; mpz_init(tmp_g);
  fmpz_t tmp_f; fmpz_init(tmp_f);

  _fmpz_vec_zero(rop, n);

  for(long i=0; i<m; i++) {
    self->D[i]->call(tmp_g, self->D[i], state);
    fmpz_set_mpz(tmp_f, tmp_g);
    _fmpz_vec_scalar_addmul_fmpz(rop, self->B->rows[i], n, tmp_f);
  }
  _fmpz_vec_add(rop, rop, self->c_z, n);

  mpz_clear(tmp_g);
  fmpz_clear(tmp_f);

  return 0;
}
コード例 #9
0
ファイル: dgsl.c プロジェクト: malb/gghlite-flint
int dgsl_mp_call_coset(fmpz *rop, const dgsl_mp_t *self, gmp_randstate_t state) {
  assert(rop); assert(self);

  const long n = fmpz_mat_ncols(self->B);
  _fmpz_vec_zero(rop, n);

  mpfr_t *c = _mpfr_vec_init(n, mpfr_get_prec(self->sigma));
  _mpfr_vec_set(c, self->c, n, MPFR_RNDN);

  mpfr_t c_prime;
  mpfr_init2(c_prime, mpfr_get_prec(self->sigma));

  mpfr_t tmp;
  mpfr_init2(tmp, mpfr_get_prec(self->sigma));

  mpfr_t sigma_prime;
  mpfr_init2(sigma_prime, mpfr_get_prec(self->sigma));

  mpz_t z;
  mpz_init(z);

  mpfr_t z_mpfr;
  mpfr_init2(z_mpfr, mpfr_get_prec(self->sigma));

  fmpz_t z_fmpz;
  fmpz_init(z_fmpz);

  size_t tau = 3;
  if (ceil(sqrt(log2((double)n))) > tau)
    tau = ceil(sqrt(log2((double)n)));

  mpfr_t *b = _mpfr_vec_init(n, mpfr_get_prec(self->sigma));

  const long m = fmpz_mat_nrows(self->B);
  for(long j=0; j<m; j++) {
    long i = m-j-1;
    _mpfr_vec_dot_product(c_prime, c,                self->G->rows[i], n, MPFR_RNDN);
    _mpfr_vec_dot_product(tmp,     self->G->rows[i], self->G->rows[i], n, MPFR_RNDN);
    mpfr_div(c_prime, c_prime, tmp, MPFR_RNDN);

    mpfr_sqrt(tmp, tmp, MPFR_RNDN);
    mpfr_div(sigma_prime, self->sigma, tmp, MPFR_RNDN);

    assert(mpfr_cmp_d(sigma_prime, 0.0) > 0);
    dgs_disc_gauss_mp_t *D = dgs_disc_gauss_mp_init(sigma_prime, c_prime, tau, DGS_DISC_GAUSS_UNIFORM_ONLINE);
    D->call(z, D, state);
    dgs_disc_gauss_mp_clear(D);

    mpfr_set_z(z_mpfr, z, MPFR_RNDN);
    mpfr_neg(z_mpfr, z_mpfr, MPFR_RNDN);
    _mpfr_vec_set_fmpz_vec(b, self->B->rows[i], n, MPFR_RNDN);
    _mpfr_vec_scalar_addmul_mpfr(c, b, n, z_mpfr, MPFR_RNDN);

    fmpz_set_mpz(z_fmpz, z);
    _fmpz_vec_scalar_addmul_fmpz(rop, self->B->rows[i], n, z_fmpz);
  }

  fmpz_clear(z_fmpz);
  mpfr_clear(z_mpfr);
  mpfr_clear(sigma_prime);
  mpfr_clear(tmp);
  mpfr_clear(c_prime);
  _mpfr_vec_clear(c, n);
  _mpfr_vec_clear(b, n);
  return 0;
}
コード例 #10
0
ファイル: t-get_fmpz.c プロジェクト: bluescarni/arb
int main()
{
    long iter;
    flint_rand_t state;

    printf("get_fmpz....");
    fflush(stdout);

    flint_randinit(state);

    for (iter = 0; iter < 100000; iter++)
    {
        long bits;
        fmpr_t x;
        mpfr_t y;
        fmpz_t z, z2;
        mpz_t w;

        bits = 2 + n_randint(state, 1000);

        fmpr_init(x);
        mpfr_init2(y, bits);
        fmpz_init(z);
        fmpz_init(z2);
        mpz_init(w);

        fmpr_randtest(x, state, bits, 10);

        fmpr_get_mpfr(y, x, MPFR_RNDN);

        switch (n_randint(state, 5))
        {
            case 0:
                fmpr_get_fmpz(z, x, FMPR_RND_FLOOR);
                mpfr_get_z(w, y, MPFR_RNDD);
                break;
            case 1:
                fmpr_get_fmpz(z, x, FMPR_RND_CEIL);
                mpfr_get_z(w, y, MPFR_RNDU);
                break;
            case 2:
                fmpr_get_fmpz(z, x, FMPR_RND_DOWN);
                mpfr_get_z(w, y, MPFR_RNDZ);
                break;
            case 3:
                fmpr_get_fmpz(z, x, FMPR_RND_UP);
                mpfr_get_z(w, y, MPFR_RNDA);
                break;
            default:
                fmpr_get_fmpz(z, x, FMPR_RND_NEAR);
                mpfr_get_z(w, y, MPFR_RNDN);
                break;
        }

        fmpz_set_mpz(z2, w);

        if (!fmpz_equal(z, z2))
        {
            printf("FAIL\n\n");
            printf("x = "); fmpr_print(x); printf("\n\n");
            printf("z = "); fmpz_print(z); printf("\n\n");
            printf("z2 = "); fmpz_print(z2); printf("\n\n");
            abort();
        }

        fmpr_clear(x);
        mpfr_clear(y);
        fmpz_clear(z);
        fmpz_clear(z2);
        mpz_clear(w);
    }

    flint_randclear(state);
    flint_cleanup();
    printf("PASS\n");
    return EXIT_SUCCESS;
}
コード例 #11
0
ファイル: t-factor_pp1.c プロジェクト: clear731/lattice
int main(void)
{
   int i, j, result;
   ulong count = UWORD(0);
   gmp_randstate_t st;
   FLINT_TEST_INIT(state);
   gmp_randinit_default(st);
   

   flint_printf("factor_pp1....");
   fflush(stdout);

   for (i = 0; i < 50 * flint_test_multiplier(); i++) /* Test random numbers */
   {
      mp_bitcnt_t bits;
      mpz_t m, n;
      fmpz_t n1, n2, r;

      mpz_init(n);
      mpz_init(m);
      fmpz_init(n1);
      fmpz_init(n2);
      fmpz_init(r);

      do {
         mpz_urandomb(n, st, n_randint(state, 128) + 2); 
      } while (flint_mpz_cmp_ui(n, 2) < 0);
      do {
         mpz_urandomb(m, st, n_randint(state, 50) + 2); 
      } while (!mpz_probab_prime_p(m, 20));
      mpz_mul(n, n, m);

      fmpz_set_mpz(n1, n);
      bits = FLINT_MIN(fmpz_bits(n1), FLINT_BITS);

      for (j = 0; j < 20; j++)
      {
         fmpz_factor_pp1(n2, n1, 10000, 10000, n_randbits(state, bits - 2) + 3);
         if (fmpz_cmp_ui(n2, 1) > 0) break;
      }
      
      if (fmpz_cmp_ui(n2, 1) > 0)
      {
         count++;
         fmpz_mod(r, n1, n2);
         result = (fmpz_is_zero(r));
         if (!result)
         {
            flint_printf("FAIL:\n");
            flint_printf("n1 = ");
            fmpz_print(n1);
            flint_printf(", n2 = ");
            fmpz_print(n2);
            flint_printf("\n"); 
            fmpz_print(r); flint_printf("\n");
            abort();
         }
      }

      fmpz_clear(n1);
      fmpz_clear(n2);
      fmpz_clear(r);
      mpz_clear(m);
      mpz_clear(n);
   }
   
   if (count < 49 * flint_test_multiplier())
   {
      flint_printf("FAIL:\n");
      flint_printf("Only %wu numbers factored\n", count); 
      abort();
   }

   
   gmp_randclear(st);
   FLINT_TEST_CLEANUP(state);
   flint_printf("PASS\n");
   return 0;
}
コード例 #12
0
flint::fmpzxx URatPSeriesFlint::convert(const Integer &x) {
    flint::fmpzxx r;
    fmpz_set_mpz(r._data().inner, get_mpz_t(x.as_mpz()));
    return r;
}
コード例 #13
0
ファイル: t-init_set_readonly.c プロジェクト: goens/flint2
int main(void)
{
    int i;
    flint_rand_t state;
    
    printf("init_set_readonly....");
    fflush(stdout);
    
    flint_randinit(state);

    /* Create some small fmpz integers, clear the mpz_t */
    for (i = 0; i < 100000; i++)
    {
        fmpz_t f;
        mpz_t z;

        *f = z_randint(state, COEFF_MAX + 1);

        mpz_init(z);
        fmpz_get_mpz(z, f);

        {
            fmpz_t g;

            fmpz_init_set_readonly(g, z);
            fmpz_clear_readonly(g);
        }

        mpz_clear(z);
    }

    /* Create some small fmpz integers, do *not* clear the mpz_t */
    for (i = 0; i < 100000; i++)
    {
        fmpz_t f;
        mpz_t z;

        *f = z_randint(state, COEFF_MAX + 1);

        mpz_init(z);
        fmpz_get_mpz(z, f);

        {
            fmpz_t g;

            fmpz_init_set_readonly(g, z);
        }

        mpz_clear(z);
    }

    /* Create some more fmpz integers */
    for (i = 0; i < 100000; i++)
    {
        fmpz_t f;
        mpz_t z;

        fmpz_init(f);
        fmpz_randtest(f, state, 2 * FLINT_BITS);
        mpz_init(z);
        fmpz_get_mpz(z, f);

        {
            fmpz_t g, h;

            fmpz_init_set_readonly(g, z);
            fmpz_init(h);
            fmpz_set_mpz(h, z);

            if (!fmpz_equal(g, h))
            {
                printf("FAIL:\n\n");
                printf("g = "), fmpz_print(g), printf("\n");
                printf("h = "), fmpz_print(h), printf("\n");
                gmp_printf("z = %Zd\n", z);
            }

            fmpz_clear_readonly(g);
            fmpz_clear(h);
        }

        fmpz_clear(f);
        mpz_clear(z);
    }

    flint_randclear(state);
    _fmpz_cleanup();
    printf("PASS\n");
    return 0;
}
コード例 #14
0
ファイル: aring-qq-flint.hpp プロジェクト: ajagekarakshay/M2
 void set_from_mpz(ElementType& result,const mpz_ptr a) const {
   // printf("ARingQQFlint::calling set_from_mpz\n");
   fmpz_set_mpz(fmpq_numref(&result), a);
   fmpz_one(fmpq_denref(&result));
 }
コード例 #15
0
ファイル: t-get_fmpz.c プロジェクト: fredrik-johansson/arb
int main()
{
    slong iter;
    flint_rand_t state;

    flint_printf("get_fmpz....");
    fflush(stdout);

    flint_randinit(state);

    for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
    {
        arf_t x, x2;
        fmpz_t z, z2, e;
        int ret1, ret2;

        arf_init(x);
        arf_init(x2);
        fmpz_init(z);
        fmpz_init(z2);
        fmpz_init(e);

        arf_randtest(x, state, 2 + n_randint(state, 1000), 10);
        fmpz_randtest(z, state, 1 + n_randint(state, 1000));
        fmpz_randtest(z2, state, 1 + n_randint(state, 1000));
        fmpz_randtest(e, state, 1 + n_randint(state, 200));
        arf_mul_2exp_fmpz(x2, x, e);

        ret1 = arf_get_fmpz(z, x, ARF_RND_DOWN);
        ret2 = arf_get_fmpz_fixed_fmpz(z2, x2, e);

        if (!fmpz_equal(z, z2) || (ret1 != ret2))
        {
            flint_printf("FAIL (fixed_fmpz)\n\n");
            flint_printf("x = "); arf_print(x); flint_printf("\n\n");
            flint_printf("x2 = "); arf_print(x2); flint_printf("\n\n");
            flint_printf("z = "); fmpz_print(z); flint_printf("\n\n");
            flint_printf("z2 = "); fmpz_print(z2); flint_printf("\n\n");
            flint_printf("ret1 = %d, ret2 = %d\n\n", ret1, ret2);
            flint_abort();
        }

        arf_clear(x);
        arf_clear(x2);
        fmpz_clear(z);
        fmpz_clear(z2);
        fmpz_clear(e);
    }

    for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
    {
        arf_t x, x2;
        fmpz_t z, z2;
        slong e;
        int ret1, ret2;

        arf_init(x);
        arf_init(x2);
        fmpz_init(z);
        fmpz_init(z2);

        arf_randtest(x, state, 2 + n_randint(state, 1000), 10);
        fmpz_randtest(z, state, 1 + n_randint(state, 1000));
        fmpz_randtest(z2, state, 1 + n_randint(state, 1000));
        e = n_randtest(state);
        arf_mul_2exp_si(x2, x, e);

        ret1 = arf_get_fmpz(z, x, ARF_RND_DOWN);
        ret2 = arf_get_fmpz_fixed_si(z2, x2, e);

        if (!fmpz_equal(z, z2) || (ret1 != ret2))
        {
            flint_printf("FAIL (fixed_si)\n\n");
            flint_printf("x = "); arf_print(x); flint_printf("\n\n");
            flint_printf("x2 = "); arf_print(x2); flint_printf("\n\n");
            flint_printf("z = "); fmpz_print(z); flint_printf("\n\n");
            flint_printf("z2 = "); fmpz_print(z2); flint_printf("\n\n");
            flint_printf("ret1 = %d, ret2 = %d\n\n", ret1, ret2);
            flint_abort();
        }

        arf_clear(x);
        arf_clear(x2);
        fmpz_clear(z);
        fmpz_clear(z2);
    }

    for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++)
    {
        slong bits;
        arf_t x;
        mpfr_t y;
        fmpz_t z, z2;
        mpz_t w;
        int ret1, ret2;

        bits = 2 + n_randint(state, 1000);

        arf_init(x);
        mpfr_init2(y, bits);
        fmpz_init(z);
        fmpz_init(z2);
        mpz_init(w);

        arf_randtest(x, state, bits, 10);
        fmpz_randtest(z, state, 1 + n_randint(state, 1000));

        arf_get_mpfr(y, x, MPFR_RNDN);

        switch (n_randint(state, 5))
        {
            case 0:
                ret1 = arf_get_fmpz(z, x, ARF_RND_FLOOR);
                ret2 = mpfr_get_z(w, y, MPFR_RNDD);
                break;
            case 1:
                ret1 = arf_get_fmpz(z, x, ARF_RND_CEIL);
                ret2 = mpfr_get_z(w, y, MPFR_RNDU);
                break;
            case 2:
                ret1 = arf_get_fmpz(z, x, ARF_RND_DOWN);
                ret2 = mpfr_get_z(w, y, MPFR_RNDZ);
                break;
            case 3:
                ret1 = arf_get_fmpz(z, x, ARF_RND_UP);
                ret2 = mpfr_get_z(w, y, MPFR_RNDA);
                break;
            default:
                ret1 = arf_get_fmpz(z, x, ARF_RND_NEAR);
                ret2 = mpfr_get_z(w, y, MPFR_RNDN);
                break;
        }

        fmpz_set_mpz(z2, w);

        if (!fmpz_equal(z, z2) || (ret1 != (ret2 != 0)))
        {
            flint_printf("FAIL\n\n");
            flint_printf("x = "); arf_print(x); flint_printf("\n\n");
            flint_printf("z = "); fmpz_print(z); flint_printf("\n\n");
            flint_printf("z2 = "); fmpz_print(z2); flint_printf("\n\n");
            flint_printf("ret1 = %d, ret2 = %d\n\n", ret1, ret2);
            flint_abort();
        }

        arf_clear(x);
        mpfr_clear(y);
        fmpz_clear(z);
        fmpz_clear(z2);
        mpz_clear(w);
    }

    flint_randclear(state);
    flint_cleanup();
    flint_printf("PASS\n");
    return EXIT_SUCCESS;
}
コード例 #16
0
int
main(void)
{
    int i;
    FLINT_TEST_INIT(state);
    

    flint_printf("reconstruct_fmpz_2....");
    fflush(stdout);

    for (i = 0; i < 10000; i++)
    {
        int result;
        int modresult;
        int special_case;
        fmpq_t x, y;
        fmpz_t mod, res, N, D, t;
        mpz_t tmp;

        fmpq_init(x);
        fmpq_init(y);
        fmpz_init(mod);
        fmpz_init(res);
        fmpz_init(N);
        fmpz_init(D);
        fmpz_init(t);
        mpz_init(tmp);

        fmpq_randtest(x, state, 100);

        fmpz_abs(N, fmpq_numref(x));
        fmpz_set(D, fmpq_denref(x));

        /* Randomly generate larger bounds */
        if (n_randint(state, 2))
        {
            fmpz_randtest_not_zero(t, state, 100);
            fmpz_abs(t, t);
            fmpz_mul(N, N, t);
        }
        if (n_randint(state, 2))
        {
            fmpz_randtest_not_zero(t, state, 100);
            fmpz_abs(t, t);
            fmpz_mul(D, D, t);
        }

        fmpz_mul(mod, N, D);
        fmpz_mul_ui(mod, mod, UWORD(2));
        /* Next prime greater than or equal */
        fmpz_get_mpz(tmp, mod);
        flint_mpz_sub_ui(tmp, tmp, UWORD(1));
        mpz_nextprime(tmp, tmp);
        fmpz_set_mpz(mod, tmp);

        modresult = fmpq_mod_fmpz(res, x, mod);
        result = fmpq_reconstruct_fmpz_2(y, res, mod, N, D);

        /* Special case: both 1 and -1 have residue 1 mod 2.
           There's probably no particular reason to disallow this. */
        special_case = (fmpz_cmp_ui(mod, UWORD(2)) == 0 &&
                        fmpz_get_si(&x->num) == WORD(-1) &&
                        fmpz_cmp_ui(&x->den, UWORD(1)) == 0);

        if (special_case)
        {
            if (!modresult || !result ||
                !fmpz_is_one(&y->num) || !fmpz_is_one(&y->den))
            {
                flint_printf("FAIL: special case: -1 mod 2\n");
                abort();
            }
        }
        else if (!modresult || !result || !fmpq_equal(x, y))
        {
            flint_printf("FAIL: reconstruction failed\n");
            flint_printf("input = ");
            fmpq_print(x);
            flint_printf("\nmodulus = ");
            fmpz_print(mod);
            flint_printf("\nresidue = ");
            fmpz_print(res);
            flint_printf("\nreconstructed = ");
            fmpq_print(y);
            flint_printf("\nfmpq_mod_fmpz return value = %d", modresult);
            flint_printf("\nfmpq_reconstruct_fmpz return value = %d", result);
            flint_printf("\n");
            abort();
        }

        fmpq_clear(x);
        fmpq_clear(y);
        fmpz_clear(mod);
        fmpz_clear(res);
        fmpz_clear(N);
        fmpz_clear(D);
        fmpz_clear(t);
        mpz_clear(tmp);
    }

    

    FLINT_TEST_CLEANUP(state);
    flint_printf("PASS\n");
    return 0;
}