Skip to content

Commit

Permalink
mpfr 4.0 deprecated mpfr_root
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Feb 10, 2018
1 parent 504c808 commit a7d9c0b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions arb/test/t-can_round_mpfr.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ int main()

if (arb_can_round_mpfr(t, prec, rnd))
{
#if MPFR_VERSION_MAJOR >= 4
r1 = mpfr_rootn_ui(y1, x, 4, rnd);
#else
r1 = mpfr_root(y1, x, 4, rnd);
#endif
r2 = arf_get_mpfr(y2, arb_midref(t), rnd);

if (r1 != r2 || !mpfr_equal_p(y1, y2))
Expand Down
4 changes: 4 additions & 0 deletions arf/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ arf_root(arf_ptr z, arf_srcptr x, ulong k, slong prec, arf_rnd_t rnd)
xf->_mpfr_sign = 1;
xf->_mpfr_exp = fmpz_get_ui(r);

#if MPFR_VERSION_MAJOR >= 4
inexact = mpfr_rootn_ui(zf, xf, k, arf_rnd_to_mpfr(rnd));
#else
inexact = mpfr_root(zf, xf, k, arf_rnd_to_mpfr(rnd));
#endif
inexact = (inexact != 0);

val = 0;
Expand Down
4 changes: 4 additions & 0 deletions fmpr/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ fmpr_root(fmpr_t y, const fmpr_t x, ulong k, slong prec, fmpr_rnd_t rnd)
fmpz_set(fmpr_manref(t), fmpr_manref(x));
fmpz_set(fmpr_expref(t), b);

#if MPFR_VERSION_MAJOR >= 4
CALL_MPFR_FUNC_K(r, mpfr_rootn_ui, y, t, k, prec, rnd);
#else
CALL_MPFR_FUNC_K(r, mpfr_root, y, t, k, prec, rnd);
#endif

fmpr_mul_2exp_fmpz(y, y, a);

Expand Down
13 changes: 9 additions & 4 deletions fmpr/test/t-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

#include "fmpr.h"

#if MPFR_VERSION_MAJOR >= 4
#define func_mpfr_root mpfr_rootn_ui
#else
#define func_mpfr_root mpfr_root
#endif

int main()
{
Expand Down Expand Up @@ -52,19 +57,19 @@ int main()
switch (n_randint(state, 4))
{
case 0:
mpfr_root(Z, X, k, MPFR_RNDZ);
func_mpfr_root(Z, X, k, MPFR_RNDZ);
fmpr_root(z, x, k, bits, FMPR_RND_DOWN);
break;
case 1:
mpfr_root(Z, X, k, MPFR_RNDA);
func_mpfr_root(Z, X, k, MPFR_RNDA);
fmpr_root(z, x, k, bits, FMPR_RND_UP);
break;
case 2:
mpfr_root(Z, X, k, MPFR_RNDD);
func_mpfr_root(Z, X, k, MPFR_RNDD);
fmpr_root(z, x, k, bits, FMPR_RND_FLOOR);
break;
case 3:
mpfr_root(Z, X, k, MPFR_RNDU);
func_mpfr_root(Z, X, k, MPFR_RNDU);
fmpr_root(z, x, k, bits, FMPR_RND_CEIL);
break;
}
Expand Down

0 comments on commit a7d9c0b

Please sign in to comment.