Skip to content

Commit

Permalink
fix missing _fmpz_demote_val in fmpz_or
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Aug 8, 2023
1 parent f455752 commit 9809014
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/fmpz/or.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ void fmpz_or(fmpz_t f, const fmpz_t g, const fmpz_t h)
__mpz_struct *mpz3 = _fmpz_promote(f);
flint_mpz_init_set_si(tmp,c2);
mpz_ior(mpz3, COEFF_TO_PTR(c1), tmp);
_fmpz_demote_val(f);
mpz_clear(tmp);
} else /* g and h are large */
{
__mpz_struct * mpz3 = _fmpz_promote(f);
__mpz_struct * mpz1 = COEFF_TO_PTR(c1);
__mpz_struct * mpz2 = COEFF_TO_PTR(c2);
mpz_ior(mpz3, mpz1, mpz2);
_fmpz_demote_val(f);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/fmpz/test/t-or.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ main(void)

for (i = 0; i < 10000 * flint_test_multiplier(); i++)
{
fmpz_t a, b, c;
mpz_t d, e, f, g;
fmpz_t a, b, c, g;
mpz_t d, e, f;

fmpz_init(a);
fmpz_init(b);
fmpz_init(c);
fmpz_init(g);

mpz_init(d);
mpz_init(e);
mpz_init(f);
mpz_init(g);

fmpz_randtest(a, state, 200);
fmpz_randtest(b, state, 200);
Expand All @@ -47,26 +47,26 @@ main(void)
fmpz_or(c, a, b);
mpz_ior(f, d, e);

fmpz_get_mpz(g, c);
fmpz_set_mpz(g, f);

result = (mpz_cmp(f, g) == 0);
result = (fmpz_equal(c, g));

if (!result)
{
flint_printf("FAIL:\n");
gmp_printf("d = %Zd, e = %Zd, f = %Zd, g = %Zd\n", d, e, f, g);
gmp_printf("d = %Zd, e = %Zd, f = %Zd, g = ", d, e, f); fmpz_print(g); flint_printf("\n");
fflush(stdout);
flint_abort();
}

fmpz_clear(a);
fmpz_clear(b);
fmpz_clear(c);
fmpz_clear(g);

mpz_clear(d);
mpz_clear(e);
mpz_clear(f);
mpz_clear(g);
}

/* Check aliasing of a and b */
Expand Down

0 comments on commit 9809014

Please sign in to comment.