2015-01-21 16:14:46 +01: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) 2014 Fredrik Johansson
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "acb_hypgeom.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:46:43 +00:00
|
|
|
slong iter;
|
2015-01-21 16:14:46 +01:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("gamma_upper....");
|
2015-01-21 16:14:46 +01:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-02-22 16:26:26 +01:00
|
|
|
/* special accuracy test -- see nemo #38 */
|
|
|
|
for (iter = 0; iter < 1000; iter++)
|
|
|
|
{
|
|
|
|
acb_t a, z, res;
|
|
|
|
slong prec, goal;
|
2016-03-10 01:35:18 +01:00
|
|
|
int regularized;
|
2016-02-22 16:26:26 +01:00
|
|
|
|
|
|
|
acb_init(a);
|
|
|
|
acb_init(z);
|
|
|
|
acb_init(res);
|
|
|
|
|
|
|
|
acb_set_si(a, n_randint(state, 100) - 50);
|
|
|
|
|
|
|
|
do {
|
|
|
|
acb_set_si(z, n_randint(state, 100) - 50);
|
|
|
|
} while (acb_is_zero(z));
|
|
|
|
|
2016-03-10 01:35:18 +01:00
|
|
|
regularized = n_randint(state, 3);
|
2016-02-22 16:26:26 +01:00
|
|
|
|
|
|
|
goal = 2 + n_randint(state, 4000);
|
|
|
|
|
|
|
|
for (prec = 2 + n_randint(state, 1000); ; prec *= 2)
|
|
|
|
{
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper(res, a, z, regularized, prec);
|
2016-02-22 16:26:26 +01:00
|
|
|
|
|
|
|
if (acb_rel_accuracy_bits(res) > goal)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (prec > 10000)
|
|
|
|
{
|
|
|
|
printf("FAIL (convergence)\n");
|
2016-03-10 01:35:18 +01:00
|
|
|
flint_printf("regularized = %d\n\n", regularized);
|
2016-02-22 16:26:26 +01:00
|
|
|
flint_printf("a = "); acb_printd(a, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("z = "); acb_printd(z, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("res = "); acb_printd(res, 30); flint_printf("\n\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_clear(a);
|
|
|
|
acb_clear(z);
|
|
|
|
acb_clear(res);
|
|
|
|
}
|
|
|
|
|
2015-01-21 16:14:46 +01:00
|
|
|
for (iter = 0; iter < 2000; iter++)
|
|
|
|
{
|
|
|
|
acb_t a0, a1, b, z, w0, w1, t, u;
|
2015-11-05 17:46:43 +00:00
|
|
|
slong prec0, prec1;
|
2016-03-10 01:35:18 +01:00
|
|
|
int regularized;
|
2015-01-21 16:14:46 +01:00
|
|
|
|
|
|
|
acb_init(a0);
|
|
|
|
acb_init(a1);
|
|
|
|
acb_init(b);
|
|
|
|
acb_init(z);
|
|
|
|
acb_init(w0);
|
|
|
|
acb_init(w1);
|
|
|
|
acb_init(t);
|
|
|
|
acb_init(u);
|
|
|
|
|
2016-03-10 01:35:18 +01:00
|
|
|
regularized = n_randint(state, 3);
|
2015-01-21 16:14:46 +01:00
|
|
|
|
|
|
|
prec0 = 2 + n_randint(state, 1000);
|
|
|
|
prec1 = 2 + n_randint(state, 1000);
|
|
|
|
|
2015-06-05 23:39:02 -04:00
|
|
|
acb_randtest_param(a0, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
|
2015-01-21 16:14:46 +01:00
|
|
|
acb_randtest(z, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
|
|
|
|
acb_randtest(w0, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
|
|
|
|
acb_randtest(w1, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
|
|
|
|
|
|
|
|
acb_add_ui(a1, a0, 1, prec0);
|
|
|
|
|
|
|
|
switch (n_randint(state, 4))
|
|
|
|
{
|
|
|
|
case 0:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_asymp(w0, a0, z, regularized, prec0);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1a(w0, a0, z, regularized, prec0);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1b(w0, a0, z, regularized, prec0);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper(w0, a0, z, regularized, prec0);
|
2015-01-21 16:14:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (n_randint(state, 4))
|
|
|
|
{
|
|
|
|
case 0:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_asymp(w1, a0, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1a(w1, a0, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1b(w1, a0, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper(w1, a0, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!acb_overlaps(w0, w1))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL: consistency\n\n");
|
2016-03-10 01:35:18 +01:00
|
|
|
flint_printf("a0 = "); acb_printd(a0, 30); flint_printf("\n\n");
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("z = "); acb_printd(z, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("w0 = "); acb_printd(w0, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("w1 = "); acb_printd(w1, 30); flint_printf("\n\n");
|
2015-01-21 16:14:46 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (n_randint(state, 4))
|
|
|
|
{
|
|
|
|
case 0:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_asymp(w1, a1, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1a(w1, a1, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper_1f1b(w1, a1, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_hypgeom_gamma_upper(w1, a1, z, regularized, prec1);
|
2015-01-21 16:14:46 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 01:35:18 +01:00
|
|
|
if (regularized == 2)
|
|
|
|
{
|
2015-01-21 16:14:46 +01:00
|
|
|
acb_one(t);
|
|
|
|
|
2016-03-10 01:35:18 +01:00
|
|
|
acb_neg(u, z);
|
|
|
|
acb_exp(u, u, prec0);
|
|
|
|
acb_mul(t, t, u, prec0);
|
2015-01-21 16:14:46 +01:00
|
|
|
|
|
|
|
acb_mul(b, w1, z, prec0);
|
|
|
|
acb_addmul(t, a0, w0, prec0);
|
|
|
|
acb_sub(t, t, b, prec0);
|
|
|
|
}
|
2016-03-10 01:35:18 +01:00
|
|
|
else if (regularized == 1)
|
|
|
|
{
|
|
|
|
/* Q(a,z) + exp(-z) z^a / Gamma(a+1) - Q(a+1,z) = 0 */
|
|
|
|
acb_pow(t, z, a0, prec0);
|
|
|
|
acb_rgamma(u, a1, prec0);
|
|
|
|
acb_mul(t, t, u, prec0);
|
|
|
|
|
|
|
|
acb_neg(u, z);
|
|
|
|
acb_exp(u, u, prec0);
|
|
|
|
acb_mul(t, t, u, prec0);
|
|
|
|
|
|
|
|
acb_add(t, t, w0, prec0);
|
|
|
|
acb_sub(t, t, w1, prec0);
|
|
|
|
}
|
2015-01-21 16:14:46 +01:00
|
|
|
else
|
|
|
|
{
|
2016-03-10 01:35:18 +01:00
|
|
|
/* a Gamma(a,z) + exp(-z) z^a - Gamma(a+1,z) = 0 */
|
|
|
|
acb_pow(t, z, a0, prec0);
|
|
|
|
|
|
|
|
acb_neg(u, z);
|
|
|
|
acb_exp(u, u, prec0);
|
|
|
|
acb_mul(t, t, u, prec0);
|
|
|
|
|
2015-01-21 16:14:46 +01:00
|
|
|
acb_addmul(t, a0, w0, prec0);
|
|
|
|
acb_sub(t, t, w1, prec0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!acb_contains_zero(t))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL: contiguous relation\n\n");
|
2016-03-10 01:35:18 +01:00
|
|
|
flint_printf("regularized = %d\n\n", regularized);
|
|
|
|
flint_printf("a0 = "); acb_printd(a0, 30); flint_printf("\n\n");
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("z = "); acb_printd(z, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("w0 = "); acb_printd(w0, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("w1 = "); acb_printd(w1, 30); flint_printf("\n\n");
|
|
|
|
flint_printf("t = "); acb_printd(t, 30); flint_printf("\n\n");
|
2015-01-21 16:14:46 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_clear(a0);
|
|
|
|
acb_clear(a1);
|
|
|
|
acb_clear(b);
|
|
|
|
acb_clear(z);
|
|
|
|
acb_clear(w0);
|
|
|
|
acb_clear(w1);
|
|
|
|
acb_clear(t);
|
|
|
|
acb_clear(u);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2015-01-21 16:14:46 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|