/*
Copyright (C) 2019 D.H.J Polymath
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 .
*/
#include "acb_dirichlet.h"
#include "arb_hypgeom.h"
#include "acb_calc.h"
#include "acb_dft.h"
static void
_arb_add_d(arb_t z, const arb_t x, double d, slong prec)
{
arb_t u;
arb_init(u);
arb_set_d(u, d);
arb_add(z, x, u, prec);
arb_clear(u);
}
static void
_arb_inv_si(arb_t z, slong n, slong prec)
{
arb_set_si(z, n);
arb_inv(z, z, prec);
}
static void
platt_g_gamma_term(acb_t out, const arb_t t0, const acb_t t, slong prec)
{
acb_t z;
acb_init(z);
acb_add_arb(z, t, t0, prec);
acb_mul_onei(z, z);
acb_mul_2exp_si(z, z, 1);
acb_add_ui(z, z, 1, prec);
acb_mul_2exp_si(z, z, -2);
acb_gamma(out, z, prec);
acb_clear(z);
}
static void
platt_g_exp_term(acb_t out,
const arb_t t0, const arb_t h, const acb_t t, slong prec)
{
arb_t pi;
acb_t z1, z2;
arb_init(pi);
acb_init(z1);
acb_init(z2);
arb_const_pi(pi, prec);
acb_add_arb(z1, t, t0, prec);
acb_mul_arb(z1, z1, pi, prec);
acb_mul_2exp_si(z1, z1, -2);
acb_div_arb(z2, t, h, prec);
acb_sqr(z2, z2, prec);
acb_mul_2exp_si(z2, z2, -1);
acb_sub(out, z1, z2, prec);
acb_exp(out, out, prec);
arb_clear(pi);
acb_clear(z1);
acb_clear(z2);
}
static void
platt_g_base(acb_t out, const acb_t t, slong prec)
{
arb_t pi;
arb_init(pi);
arb_const_pi(pi, prec);
acb_mul_arb(out, t, pi, prec);
acb_mul_onei(out, out);
acb_mul_2exp_si(out, out, 1);
acb_neg(out, out);
arb_clear(pi);
}
static void
platt_g_table(acb_ptr table, slong A, slong B,
const arb_t t0, const arb_t h, slong K, slong prec)
{
slong N = A*B;
slong i, n, k;
acb_t t, base;
acb_t gamma_term, exp_term, coeff;
acb_ptr precomputed_powers;
acb_init(t);
acb_init(base);
acb_init(gamma_term);
acb_init(exp_term);
acb_init(coeff);
precomputed_powers = _acb_vec_init(K);
for (i=0; i