2014-06-19 16:17:32 +02:00
|
|
|
/*=============================================================================
|
|
|
|
|
|
|
|
This file is part of ARB.
|
|
|
|
|
|
|
|
ARB is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ARB is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with ARB; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
=============================================================================*/
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "acb_calc.h"
|
|
|
|
|
|
|
|
/* sin(x) */
|
|
|
|
int
|
2015-11-05 17:45:18 +00:00
|
|
|
sin_x(acb_ptr out, const acb_t inp, void * params, slong order, slong prec)
|
2014-06-19 16:17:32 +02:00
|
|
|
{
|
|
|
|
int xlen = FLINT_MIN(2, order);
|
|
|
|
|
|
|
|
acb_set(out, inp);
|
|
|
|
if (xlen > 1)
|
|
|
|
acb_one(out + 1);
|
|
|
|
|
|
|
|
_acb_poly_sin_series(out, out, xlen, order, prec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const double answers[10] = {
|
|
|
|
1.04570093561423094, 2.0358667496686487, 4.82706400405656566,
|
|
|
|
11.2347033850581819, 27.1331828778516522, 67.210305990439042,
|
|
|
|
168.564351176369878, 427.496180295369909, 1093.56959348921777,
|
|
|
|
2815.70144392142227
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:45:18 +00:00
|
|
|
slong iter;
|
2014-06-19 16:17:32 +02:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("cauchy_bound....");
|
2014-06-19 16:17:32 +02:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
|
|
|
for (iter = 0; iter < 100; iter++)
|
|
|
|
{
|
|
|
|
arb_t b, radius, ans;
|
|
|
|
acb_t x;
|
2015-11-05 17:45:18 +00:00
|
|
|
slong r, prec, maxdepth;
|
2014-06-19 16:17:32 +02:00
|
|
|
|
|
|
|
arb_init(b);
|
|
|
|
arb_init(radius);
|
|
|
|
arb_init(ans);
|
|
|
|
acb_init(x);
|
|
|
|
|
|
|
|
acb_set_ui(x, 5);
|
|
|
|
|
|
|
|
r = 1 + n_randint(state, 10);
|
|
|
|
arb_set_ui(radius, r);
|
|
|
|
|
|
|
|
prec = 2 + n_randint(state, 100);
|
|
|
|
maxdepth = n_randint(state, 10);
|
|
|
|
|
|
|
|
acb_calc_cauchy_bound(b, sin_x, NULL, x, radius, maxdepth, prec);
|
|
|
|
|
|
|
|
arf_set_d(arb_midref(ans), answers[r-1]);
|
|
|
|
mag_set_d(arb_radref(ans), 1e-8);
|
|
|
|
|
|
|
|
if (!arb_overlaps(b, ans))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL\n");
|
|
|
|
flint_printf("r = %wd, prec = %wd, maxdepth = %wd\n\n", r, prec, maxdepth);
|
|
|
|
arb_printd(b, 15); flint_printf("\n\n");
|
|
|
|
arb_printd(ans, 15); flint_printf("\n\n");
|
2014-06-19 16:17:32 +02:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
arb_clear(b);
|
|
|
|
arb_clear(radius);
|
|
|
|
arb_clear(ans);
|
|
|
|
acb_clear(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2014-06-19 16:17:32 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|