2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2015-11-01 01:56:29 +01:00
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +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 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/>.
|
|
|
|
*/
|
2015-11-01 01:56:29 +01:00
|
|
|
|
|
|
|
#include "acb.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:43:36 +00:00
|
|
|
slong iter;
|
2015-11-01 01:56:29 +01:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("acos....");
|
2015-11-01 01:56:29 +01:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++)
|
2015-11-01 01:56:29 +01:00
|
|
|
{
|
|
|
|
acb_t x, a, b;
|
2015-11-05 17:43:36 +00:00
|
|
|
slong prec1, prec2;
|
2015-11-01 01:56:29 +01:00
|
|
|
|
|
|
|
prec1 = 2 + n_randint(state, 1000);
|
|
|
|
prec2 = prec1 + 30;
|
|
|
|
|
|
|
|
acb_init(x);
|
|
|
|
acb_init(a);
|
|
|
|
acb_init(b);
|
|
|
|
|
|
|
|
acb_randtest_special(x, state, 1 + n_randint(state, 1000), 2 + n_randint(state, 100));
|
|
|
|
acb_randtest_special(a, state, 1 + n_randint(state, 1000), 2 + n_randint(state, 100));
|
|
|
|
acb_randtest_special(b, state, 1 + n_randint(state, 1000), 2 + n_randint(state, 100));
|
|
|
|
|
|
|
|
acb_acos(a, x, prec1);
|
|
|
|
acb_acos(b, x, prec2);
|
|
|
|
|
|
|
|
/* check consistency */
|
|
|
|
if (!acb_overlaps(a, b))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL: overlap\n\n");
|
|
|
|
flint_printf("x = "); acb_printd(x, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("a = "); acb_printd(a, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("b = "); acb_printd(b, 15); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2015-11-01 01:56:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check cos(acos(x)) = x */
|
|
|
|
acb_cos(b, b, prec1);
|
|
|
|
|
|
|
|
if (!acb_contains(b, x))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL: functional equation\n\n");
|
|
|
|
flint_printf("x = "); acb_printd(x, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("b = "); acb_printd(b, 15); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2015-11-01 01:56:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
acb_acos(x, x, prec1);
|
|
|
|
|
|
|
|
if (!acb_overlaps(a, x))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL: aliasing\n\n");
|
|
|
|
flint_printf("a = "); acb_printd(a, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("x = "); acb_printd(x, 15); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2015-11-01 01:56:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
acb_clear(x);
|
|
|
|
acb_clear(a);
|
|
|
|
acb_clear(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2015-11-01 01:56:29 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|