remove some unused fmpr functions and drop test iterations

This commit is contained in:
fredrik 2018-12-13 16:49:21 +01:00
parent 64c1c20384
commit 2488af9b1d
41 changed files with 34 additions and 790 deletions

View file

@ -368,23 +368,6 @@ Comparisons
Returns nonzero iff *x* equals `n 2^e` for some integer *n*. Returns nonzero iff *x* equals `n 2^e` for some integer *n*.
.. function:: void fmpr_abs_bound_le_2exp_fmpz(fmpz_t b, const fmpr_t x)
Sets *b* to the smallest integer such that `|x| \le 2^b`.
If *x* is zero, infinity or NaN, the result is undefined.
.. function:: void fmpr_abs_bound_lt_2exp_fmpz(fmpz_t b, const fmpr_t x)
Sets *b* to the smallest integer such that `|x| < 2^b`.
If *x* is zero, infinity or NaN, the result is undefined.
.. function:: slong fmpr_abs_bound_lt_2exp_si(const fmpr_t x)
Returns the smallest integer *b* such that `|x| < 2^b`, clamping
the result to lie between -*FMPR_PREC_EXACT* and *FMPR_PREC_EXACT*
inclusive. If *x* is zero, -*FMPR_PREC_EXACT* is returned,
and if *x* is infinity or NaN, *FMPR_PREC_EXACT* is returned.
Random number generation Random number generation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -468,15 +451,6 @@ Arithmetic
can be *FMPR_PREC_EXACT* to perform an exact addition, provided that the can be *FMPR_PREC_EXACT* to perform an exact addition, provided that the
result fits in memory. result fits in memory.
.. function:: slong fmpr_sum(fmpr_t s, const fmpr_struct * terms, slong len, slong prec, fmpr_rnd_t rnd)
Sets *s* to the sum of the array *terms* of length *len*, rounded to *prec* bits
in the direction *rnd*. The sum is computed as if done without any intermediate
rounding error, with only a single rounding applied to the final result.
Unlike repeated calls to *fmpr_add*, this function does not overflow if the
magnitudes of the terms are far apart. Warning: this function is implemented
naively, and the running time is quadratic with respect to *len* in the worst case.
.. function:: slong fmpr_mul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_mul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd)
.. function:: slong fmpr_mul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_mul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd)
@ -514,11 +488,6 @@ Arithmetic
Sets `z = x / y`, rounded according to *prec* and *rnd*. If *y* is zero, Sets `z = x / y`, rounded according to *prec* and *rnd*. If *y* is zero,
*z* is set to NaN. *z* is set to NaN.
.. function:: void fmpr_divappr_abs_ubound(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec)
Sets `z` to an upper bound for `|x| / |y|`, computed to a precision
of approximately *prec* bits. The error can be a few ulp.
.. function:: slong fmpr_addmul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_addmul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd)
.. function:: slong fmpr_addmul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_addmul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd)
@ -547,10 +516,6 @@ Arithmetic
.. function:: slong fmpr_sqrt(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_sqrt(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
.. function:: slong fmpr_sqrt_ui(fmpr_t z, ulong x, slong prec, fmpr_rnd_t rnd)
.. function:: slong fmpr_sqrt_fmpz(fmpr_t z, const fmpz_t x, slong prec, fmpr_rnd_t rnd)
Sets *z* to the square root of *x*, rounded according to *prec* and *rnd*. Sets *z* to the square root of *x*, rounded according to *prec* and *rnd*.
The result is NaN if *x* is negative. The result is NaN if *x* is negative.
@ -580,6 +545,7 @@ Arithmetic
Special functions Special functions
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
.. function:: slong fmpr_log(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd) .. function:: slong fmpr_log(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
Sets *y* to `\log(x)`, rounded according to *prec* and *rnd*. Sets *y* to `\log(x)`, rounded according to *prec* and *rnd*.
@ -609,4 +575,3 @@ Special functions
This function is currently implemented using MPFR and does not This function is currently implemented using MPFR and does not
support large exponents. support large exponents.

21
fmpr.h
View file

@ -474,8 +474,6 @@ slong fmpr_sub_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd)
slong fmpr_sub_si(fmpr_t z, const fmpr_t x, slong y, slong prec, fmpr_rnd_t rnd); slong fmpr_sub_si(fmpr_t z, const fmpr_t x, slong y, slong prec, fmpr_rnd_t rnd);
slong fmpr_sub_fmpz(fmpr_t z, const fmpr_t x, const fmpz_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_sub_fmpz(fmpr_t z, const fmpr_t x, const fmpz_t y, slong prec, fmpr_rnd_t rnd);
slong fmpr_sum(fmpr_t s, const fmpr_struct * terms, slong len, slong prec, fmpr_rnd_t rnd);
slong fmpr_div(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_div(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd);
slong fmpr_div_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd); slong fmpr_div_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd);
slong fmpr_ui_div(fmpr_t z, ulong x, const fmpr_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_ui_div(fmpr_t z, ulong x, const fmpr_t y, slong prec, fmpr_rnd_t rnd);
@ -485,8 +483,6 @@ slong fmpr_div_fmpz(fmpr_t z, const fmpr_t x, const fmpz_t y, slong prec, fmpr_r
slong fmpr_fmpz_div(fmpr_t z, const fmpz_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_fmpz_div(fmpr_t z, const fmpz_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd);
slong fmpr_fmpz_div_fmpz(fmpr_t z, const fmpz_t x, const fmpz_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_fmpz_div_fmpz(fmpr_t z, const fmpz_t x, const fmpz_t y, slong prec, fmpr_rnd_t rnd);
void fmpr_divappr_abs_ubound(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec);
slong fmpr_addmul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd); slong fmpr_addmul(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec, fmpr_rnd_t rnd);
slong fmpr_addmul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd); slong fmpr_addmul_ui(fmpr_t z, const fmpr_t x, ulong y, slong prec, fmpr_rnd_t rnd);
slong fmpr_addmul_si(fmpr_t z, const fmpr_t x, slong y, slong prec, fmpr_rnd_t rnd); slong fmpr_addmul_si(fmpr_t z, const fmpr_t x, slong y, slong prec, fmpr_rnd_t rnd);
@ -657,23 +653,6 @@ int fmpr_cmp_2exp_si(const fmpr_t x, slong e);
int fmpr_cmpabs_2exp_si(const fmpr_t x, slong e); int fmpr_cmpabs_2exp_si(const fmpr_t x, slong e);
static __inline__ void
fmpr_abs_bound_le_2exp_fmpz(fmpz_t b, const fmpr_t x)
{
if (fmpz_is_pm1(fmpr_manref(x)))
fmpz_set(b, fmpr_expref(x));
else
fmpz_add_ui(b, fmpr_expref(x), fmpz_bits(fmpr_manref(x)));
}
static __inline__ void
fmpr_abs_bound_lt_2exp_fmpz(fmpz_t b, const fmpr_t x)
{
fmpz_add_ui(b, fmpr_expref(x), fmpz_bits(fmpr_manref(x)));
}
slong fmpr_abs_bound_lt_2exp_si(const fmpr_t x);
static __inline__ void static __inline__ void
fmpr_min(fmpr_t z, const fmpr_t a, const fmpr_t b) fmpr_min(fmpr_t z, const fmpr_t a, const fmpr_t b)
{ {

View file

@ -1,46 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
slong
fmpr_abs_bound_lt_2exp_si(const fmpr_t x)
{
if (fmpr_is_special(x))
{
if (fmpr_is_zero(x))
return -FMPR_PREC_EXACT;
else
return FMPR_PREC_EXACT;
}
else
{
slong res;
fmpz_t t;
fmpz_init(t);
fmpr_abs_bound_lt_2exp_fmpz(t, x);
if (fmpz_fits_si(t))
res = fmpz_get_si(t);
else
res = fmpz_sgn(t) < 0 ? -FMPR_PREC_EXACT : FMPR_PREC_EXACT;
fmpz_clear(t);
if (res < -FMPR_PREC_EXACT)
res = -FMPR_PREC_EXACT;
if (res > FMPR_PREC_EXACT)
res = FMPR_PREC_EXACT;
return res;
}
}

View file

@ -1,74 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
void
fmpr_divappr_abs_ubound(fmpr_t z, const fmpr_t x, const fmpr_t y, slong prec)
{
if (fmpr_is_special(x) || fmpr_is_special(y) || fmpz_is_pm1(fmpr_manref(y)))
{
fmpr_div(z, x, y, prec, FMPR_RND_UP);
fmpr_abs(z, z);
}
else
{
fmpz_t t, u;
slong xbits, ybits, tbits, ubits, shift;
xbits = fmpz_bits(fmpr_manref(x));
ybits = fmpz_bits(fmpr_manref(y));
fmpz_init(t);
fmpz_init(u);
ubits = FLINT_MIN(ybits, prec);
tbits = prec + ubits + 1;
/* upper bound for |x|, shifted */
if (xbits <= tbits)
{
fmpz_mul_2exp(t, fmpr_manref(x), tbits - xbits);
fmpz_abs(t, t);
}
else if (fmpz_sgn(fmpr_manref(x)) > 0)
{
fmpz_cdiv_q_2exp(t, fmpr_manref(x), xbits - tbits);
}
else
{
fmpz_fdiv_q_2exp(t, fmpr_manref(x), xbits - tbits);
fmpz_neg(t, t);
}
/* lower bound for |y|, shifted */
if (ybits <= ubits)
fmpz_mul_2exp(u, fmpr_manref(y), ubits - ybits);
else
fmpz_tdiv_q_2exp(u, fmpr_manref(y), ybits - ubits);
fmpz_abs(u, u);
fmpz_cdiv_q(fmpr_manref(z), t, u);
shift = (ubits - ybits) - (tbits - xbits);
fmpz_sub(fmpr_expref(z), fmpr_expref(x), fmpr_expref(y));
if (shift >= 0)
fmpz_add_ui(fmpr_expref(z), fmpr_expref(z), shift);
else
fmpz_sub_ui(fmpr_expref(z), fmpr_expref(z), -shift);
_fmpr_normalise(fmpr_manref(z), fmpr_expref(z), prec, FMPR_RND_UP);
fmpz_clear(t);
fmpz_clear(u);
}
}

View file

@ -68,24 +68,3 @@ fmpr_sqrt(fmpr_t y, const fmpr_t x, slong prec, fmpr_rnd_t rnd)
} }
} }
slong
fmpr_sqrt_ui(fmpr_t z, ulong x, slong prec, fmpr_rnd_t rnd)
{
fmpr_t t; slong r;
fmpr_init(t);
fmpr_set_ui(t, x);
r = fmpr_sqrt(z, t, prec, rnd);
fmpr_clear(t);
return r;
}
slong
fmpr_sqrt_fmpz(fmpr_t z, const fmpz_t x, slong prec, fmpr_rnd_t rnd)
{
fmpr_t t; slong r;
fmpr_init(t);
fmpr_set_fmpz(t, x);
r = fmpr_sqrt(z, t, prec, rnd);
fmpr_clear(t);
return r;
}

View file

@ -1,169 +0,0 @@
/*
Copyright (C) 2012 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int are_close(const fmpr_t x, const fmpr_t y, slong prec)
{
fmpz_t xb, yb;
fmpz_t delta;
int result;
fmpz_init(xb);
fmpz_init(yb);
fmpz_init(delta);
fmpz_add_ui(xb, fmpr_expref(x), fmpz_bits(fmpr_manref(x)));
fmpz_add_ui(yb, fmpr_expref(y), fmpz_bits(fmpr_manref(y)));
if (fmpz_cmp(xb, yb) >= 0)
fmpz_sub(delta, fmpr_expref(x), yb);
else
fmpz_sub(delta, fmpr_expref(y), xb);
fmpz_sub_ui(delta, delta, 64);
result = (fmpz_cmp_ui(delta, prec) < 0);
fmpz_clear(xb);
fmpz_clear(yb);
fmpz_clear(delta);
return result;
}
slong
fmpr_sum(fmpr_t s, const fmpr_struct * terms, slong len, slong prec, fmpr_rnd_t rnd)
{
fmpr_struct * blocks;
slong i, j, used, res;
int have_merged;
/* first check if the result is inf or nan */
{
int have_pos_inf = 0;
int have_neg_inf = 0;
for (i = 0; i < len; i++)
{
if (fmpr_is_pos_inf(terms + i))
{
if (have_neg_inf)
{
fmpr_nan(s);
return FMPR_RESULT_EXACT;
}
have_pos_inf = 1;
}
else if (fmpr_is_neg_inf(terms + i))
{
if (have_pos_inf)
{
fmpr_nan(s);
return FMPR_RESULT_EXACT;
}
have_neg_inf = 1;
}
else if (fmpr_is_nan(terms + i))
{
fmpr_nan(s);
return FMPR_RESULT_EXACT;
}
}
if (have_pos_inf)
{
fmpr_pos_inf(s);
return FMPR_RESULT_EXACT;
}
if (have_neg_inf)
{
fmpr_neg_inf(s);
return FMPR_RESULT_EXACT;
}
}
blocks = flint_malloc(sizeof(fmpr_struct) * len);
for (i = 0; i < len; i++)
fmpr_init(blocks + i);
/* put all terms into blocks */
used = 0;
for (i = 0; i < len; i++)
{
if (!fmpr_is_zero(terms + i))
{
fmpr_set(blocks + used, terms + i);
used++;
}
}
/* merge blocks until all are well separated */
have_merged = 1;
while (used >= 2 && have_merged)
{
have_merged = 0;
for (i = 0; i < used && !have_merged; i++)
{
for (j = i + 1; j < used && !have_merged; j++)
{
if (are_close(blocks + i, blocks + j, prec))
{
fmpr_add(blocks + i, blocks + i, blocks + j, FMPR_PREC_EXACT, FMPR_RND_DOWN);
/* remove the merged block */
fmpr_swap(blocks + j, blocks + used - 1);
used--;
/* remove the updated block if the sum is zero */
if (fmpr_is_zero(blocks + i))
{
fmpr_swap(blocks + i, blocks + used - 1);
used--;
}
have_merged = 1;
}
}
}
}
if (used == 0)
{
fmpr_zero(s);
res = FMPR_RESULT_EXACT;
}
else if (used == 1)
{
res = fmpr_set_round(s, blocks + 0, prec, rnd);
}
else
{
/* find the two largest blocks */
for (i = 1; i < used; i++)
if (fmpr_cmpabs(blocks + 0, blocks + i) < 0)
fmpr_swap(blocks + 0, blocks + i);
for (i = 2; i < used; i++)
if (fmpr_cmpabs(blocks + 1, blocks + i) < 0)
fmpr_swap(blocks + 1, blocks + i);
res = _fmpr_add_eps(s, blocks + 0, fmpr_sgn(blocks + 1), prec, rnd);
}
for (i = 0; i < len; i++)
fmpr_clear(blocks + i);
flint_free(blocks);
return res;
}

View file

@ -1,68 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("abs_bound_le_2exp_fmpz....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{
fmpr_t x, y;
fmpz_t b;
int cmp1, cmp2;
fmpr_init(x);
fmpr_init(y);
fmpz_init(b);
fmpr_randtest_not_zero(x, state, 2 + n_randint(state, 1000), 100);
fmpr_abs_bound_le_2exp_fmpz(b, x);
fmpr_one(y);
fmpr_mul_2exp_fmpz(y, y, b);
cmp1 = (fmpr_cmpabs(x, y) <= 0);
fmpr_mul_2exp_si(y, y, -1);
cmp2 = (fmpr_cmpabs(y, x) < 0);
fmpr_mul_2exp_si(y, y, 1);
if (!cmp1 || !cmp2)
{
flint_printf("FAIL\n\n");
flint_printf("x = "); fmpr_print(x); flint_printf("\n\n");
flint_printf("y = "); fmpr_print(y); flint_printf("\n\n");
flint_printf("b = "); fmpz_print(b); flint_printf("\n\n");
flint_printf("cmp1 = %d, cmp2 = %d\n\n", cmp1, cmp2);
flint_abort();
}
fmpr_clear(x);
fmpr_clear(y);
fmpz_clear(b);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}

View file

@ -1,68 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("abs_bound_lt_2exp_fmpz....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{
fmpr_t x, y;
fmpz_t b;
int cmp1, cmp2;
fmpr_init(x);
fmpr_init(y);
fmpz_init(b);
fmpr_randtest_not_zero(x, state, 2 + n_randint(state, 1000), 100);
fmpr_abs_bound_lt_2exp_fmpz(b, x);
fmpr_one(y);
fmpr_mul_2exp_fmpz(y, y, b);
cmp1 = (fmpr_cmpabs(x, y) < 0);
fmpr_mul_2exp_si(y, y, -1);
cmp2 = (fmpr_cmpabs(y, x) <= 0);
fmpr_mul_2exp_si(y, y, 1);
if (!cmp1 || !cmp2)
{
flint_printf("FAIL\n\n");
flint_printf("x = "); fmpr_print(x); flint_printf("\n\n");
flint_printf("y = "); fmpr_print(y); flint_printf("\n\n");
flint_printf("b = "); fmpz_print(b); flint_printf("\n\n");
flint_printf("cmp1 = %d, cmp2 = %d\n\n", cmp1, cmp2);
flint_abort();
}
fmpr_clear(x);
fmpr_clear(y);
fmpz_clear(b);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}

View file

@ -1,75 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("abs_bound_lt_2exp_si....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{
fmpr_t x;
fmpz_t b;
slong c;
fmpr_init(x);
fmpz_init(b);
fmpr_randtest_special(x, state, 2 + n_randint(state, 1000), 100);
fmpr_abs_bound_lt_2exp_fmpz(b, x);
c = fmpr_abs_bound_lt_2exp_si(x);
if (c == -FMPR_PREC_EXACT)
{
if (!(fmpr_is_zero(x) || fmpz_cmp_si(b, -FMPR_PREC_EXACT) <= 0))
{
flint_printf("FAIL (small/zero)\n\n");
flint_abort();
}
}
else if (c == FMPR_PREC_EXACT)
{
if (!(fmpr_is_inf(x) || fmpr_is_nan(x) ||
fmpz_cmp_si(b, FMPR_PREC_EXACT) >= 0))
{
flint_printf("FAIL (large/inf/nan)\n\n");
flint_abort();
}
}
else
{
if (fmpz_cmp_si(b, c) != 0)
{
flint_printf("FAIL (normal)\n\n");
flint_printf("x = "); fmpr_print(x); flint_printf("\n\n");
flint_printf("b = "); fmpz_print(b); flint_printf("\n\n");
flint_printf("c = %wd\n\n", c);
flint_abort();
}
}
fmpr_clear(x);
fmpz_clear(b);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}

View file

@ -23,7 +23,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact addition: (x + y) + z == x + (y + z) */ /* test exact addition: (x + y) + z == x + (y + z) */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res1, res2, res3, res4; slong bits, res1, res2, res3, res4;
fmpr_t x, y, z, t, u; fmpr_t x, y, z, t, u;
@ -69,7 +69,7 @@ int main()
} }
/* compare with add_naive */ /* compare with add_naive */
for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++)
{ {
slong prec, ret1, ret2; slong prec, ret1, ret2;
fmpr_t x, y, z, w; fmpr_t x, y, z, w;
@ -122,7 +122,7 @@ int main()
} }
/* compare rounding with mpfr */ /* compare rounding with mpfr */
for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++)
{ {
slong bits, res; slong bits, res;
int mpfr_res; int mpfr_res;

View file

@ -23,7 +23,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact addition: (x + y) + z == x + (y + z) */ /* test exact addition: (x + y) + z == x + (y + z) */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res1, res2, res3, res4; slong bits, res1, res2, res3, res4;
fmpr_t x, y, z, t, u; fmpr_t x, y, z, t, u;
@ -69,7 +69,7 @@ int main()
} }
/* compare rounding with mpfr */ /* compare rounding with mpfr */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res; slong bits, res;
int mpfr_res; int mpfr_res;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, y; fmpr_t x, y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, e; slong bits, e;
fmpr_t x, y; fmpr_t x, y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, y; fmpr_t x, y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, e; slong bits, e;
fmpr_t x, y; fmpr_t x, y;

View file

@ -21,7 +21,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, r1, r2; slong bits, r1, r2;
fmpr_t x, y, z, w; fmpr_t x, y, z, w;

View file

@ -1,66 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("divappr_abs_ubound....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{
fmpr_t a, b, c, d;
slong prec;
fmpr_init(a);
fmpr_init(b);
fmpr_init(c);
fmpr_init(d);
fmpr_randtest_special(a, state, 2 + n_randint(state, 200), 100);
fmpr_randtest_special(b, state, 2 + n_randint(state, 200), 100);
fmpr_randtest_special(c, state, 2 + n_randint(state, 200), 100);
fmpr_randtest_special(d, state, 2 + n_randint(state, 200), 100);
prec = 2 + n_randint(state, 200);
fmpr_div(c, a, b, prec, FMPR_RND_UP);
fmpr_abs(c, c);
fmpr_divappr_abs_ubound(d, a, b, prec);
if (fmpr_cmp(c, d) > 0)
{
flint_printf("FAIL:\n");
fmpr_printd(a, prec / 3.32); flint_printf("\n");
fmpr_printd(b, prec / 3.32); flint_printf("\n");
fmpr_printd(c, prec / 3.32); flint_printf("\n");
fmpr_printd(d, prec / 3.32); flint_printf("\n");
flint_abort();
}
fmpr_clear(a);
fmpr_clear(b);
fmpr_clear(c);
fmpr_clear(d);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact roundtrip */ /* test exact roundtrip */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, z; fmpr_t x, z;
double y; double y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x; fmpr_t x;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z; fmpr_t x, z;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -21,7 +21,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, y, z, v; fmpr_t x, y, z, v;
slong prec, r1, r2; slong prec, r1, r2;

View file

@ -33,7 +33,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 300 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, z, v; fmpr_t x, z, v;
fmpz_t y; fmpz_t y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, y, z, w; fmpr_t x, y, z, w;

View file

@ -33,7 +33,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 300 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, z, v; fmpr_t x, z, v;
slong y; slong y;

View file

@ -33,7 +33,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 300 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, z, v; fmpr_t x, z, v;
ulong y; ulong y;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, xcopy, y, err_bound, err; fmpr_t x, xcopy, y, err_bound, err;
slong prec, ret1, ret2, bits, ebits; slong prec, ret1, ret2, bits, ebits;

View file

@ -27,7 +27,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
ulong k; ulong k;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res; slong bits, res;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -23,7 +23,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact roundtrip R -> Q -> R */ /* test exact roundtrip R -> Q -> R */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res; slong bits, res;
fmpr_t x, z; fmpr_t x, z;

View file

@ -23,7 +23,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact roundtrip R -> Q -> R */ /* test exact roundtrip R -> Q -> R */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits; slong bits;
fmpr_t x, z; fmpr_t x, z;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++)
{ {
slong prec, bits, shift, ret1, ret2; slong prec, bits, shift, ret1, ret2;
fmpz_t man, exp; fmpz_t man, exp;

View file

@ -21,7 +21,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong prec, ret1, ret2; slong prec, ret1, ret2;
fmpz_t man, exp; fmpz_t man, exp;

View file

@ -21,7 +21,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong prec, ret1, ret2; slong prec, ret1, ret2;
fmpz_t man, exp; fmpz_t man, exp;

View file

@ -22,7 +22,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res; slong bits, res;
fmpr_t x, z, w; fmpr_t x, z, w;

View file

@ -23,7 +23,7 @@ int main()
flint_randinit(state); flint_randinit(state);
/* test exact subtraction: (x - y) - z == (x - z) - y */ /* test exact subtraction: (x - y) - z == (x - z) - y */
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
slong bits, res1, res2, res3, res4; slong bits, res1, res2, res3, res4;
fmpr_t x, y, z, t, u; fmpr_t x, y, z, t, u;

View file

@ -1,113 +0,0 @@
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "fmpr.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("sum....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 1000000 * arb_test_multiplier(); iter++)
{
slong i, len, prec, bits, expbits, res1, res2;
fmpr_t s1, s2, s3, err, err_bound;
fmpr_struct terms[20];
fmpr_rnd_t rnd;
len = n_randint(state, 20);
bits = 2 + n_randint(state, 1000);
prec = 2 + n_randint(state, 1000);
expbits = n_randint(state, 14);
fmpr_init(s1);
fmpr_init(s2);
fmpr_init(s3);
fmpr_init(err);
fmpr_init(err_bound);
for (i = 0; i < len; i++)
{
fmpr_init(terms + i);
fmpr_randtest_special(terms + i, state, bits, expbits);
}
switch (n_randint(state, 4))
{
case 0: rnd = FMPR_RND_DOWN; break;
case 1: rnd = FMPR_RND_UP; break;
case 2: rnd = FMPR_RND_FLOOR; break;
default: rnd = FMPR_RND_CEIL; break;
}
res1 = fmpr_sum(s1, terms, len, prec, rnd);
fmpr_zero(s2);
for (i = 0; i < len; i++)
fmpr_add(s2, s2, terms + i, FMPR_PREC_EXACT, FMPR_RND_DOWN);
res2 = fmpr_set_round(s3, s2, prec, rnd);
if (!fmpr_equal(s1, s3) || res1 != res2 ||
!fmpr_check_ulp(s1, res1, prec) || !fmpr_check_ulp(s3, res2, prec))
{
flint_printf("FAIL (%wd)\n\n", iter);
flint_printf("prec = %wd\n\n", prec);
for (i = 0; i < len; i++)
{
flint_printf("terms[%wd] = ", i); fmpr_print(terms + i); flint_printf("\n\n");
}
flint_printf("s1 = "); fmpr_print(s1); flint_printf("\n\n");
flint_printf("s2 = "); fmpr_print(s2); flint_printf("\n\n");
flint_printf("s3 = "); fmpr_print(s3); flint_printf("\n\n");
flint_printf("res1 = %wd, res2 = %wd\n\n", res1, res2);
flint_abort();
}
fmpr_sub(err, s1, s2, FMPR_PREC_EXACT, FMPR_RND_DOWN);
fmpr_abs(err, err);
fmpr_set_error_result(err_bound, s1, res1);
if (fmpr_cmp(err, err_bound) > 0)
{
flint_printf("FAIL (error bound)!\n");
flint_printf("prec = %wd\n\n", prec);
for (i = 0; i < len; i++)
{
flint_printf("terms[%wd] = ", i); fmpr_print(terms + i); flint_printf("\n\n");
}
flint_printf("s1 = "); fmpr_print(s1); flint_printf("\n\n");
flint_printf("s2 = "); fmpr_print(s2); flint_printf("\n\n");
flint_printf("s3 = "); fmpr_print(s3); flint_printf("\n\n");
flint_printf("error: "); fmpr_print(err); flint_printf("\n\n");
flint_printf("error bound: "); fmpr_print(err_bound); flint_printf("\n\n");
flint_printf("res1 = %wd, res2 = %wd\n\n", res1, res2);
flint_abort();
}
fmpr_clear(s1);
fmpr_clear(s2);
fmpr_clear(s3);
fmpr_clear(err);
fmpr_clear(err_bound);
for (i = 0; i < len; i++)
fmpr_clear(terms + i);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}

View file

@ -21,7 +21,7 @@ int main()
flint_randinit(state); flint_randinit(state);
for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
{ {
fmpr_t x, ulp, a, b; fmpr_t x, ulp, a, b;
slong prec; slong prec;