mirror of
https://github.com/vale981/arb
synced 2025-03-05 09:21:38 -05:00
98 lines
2.6 KiB
C
98 lines
2.6 KiB
C
/*=============================================================================
|
|
|
|
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 "arb_poly.h"
|
|
#include "acb_poly.h"
|
|
|
|
void
|
|
_arb_poly_riemann_siegel_theta_series(arb_ptr res,
|
|
arb_srcptr h, long hlen, long len, long prec)
|
|
{
|
|
acb_ptr s;
|
|
arb_t u;
|
|
long i;
|
|
|
|
hlen = FLINT_MIN(hlen, len);
|
|
|
|
s = _acb_vec_init(len);
|
|
|
|
arb_init(u);
|
|
|
|
/* s = 1/4 + (1/2) i h */
|
|
for (i = 0; i < hlen; i++)
|
|
arb_mul_2exp_si(acb_imagref(s + i), h + i, -1);
|
|
|
|
arb_one(u);
|
|
arb_mul_2exp_si(u, u, -2);
|
|
arb_add(acb_realref(s), acb_realref(s), u, prec);
|
|
|
|
/* log gamma */
|
|
_acb_poly_lgamma_series(s, s, hlen, len, prec);
|
|
|
|
/* imaginary part */
|
|
for (i = 0; i < len; i++)
|
|
arb_set(res + i, acb_imagref(s + i));
|
|
|
|
/* subtract log(pi)/2 * h */
|
|
arb_const_pi(u, prec);
|
|
arb_log(u, u, prec);
|
|
arb_mul_2exp_si(u, u, -1);
|
|
arb_neg(u, u);
|
|
_arb_vec_scalar_addmul(res, h, hlen, u, prec);
|
|
|
|
_acb_vec_clear(s, len);
|
|
arb_clear(u);
|
|
}
|
|
|
|
void
|
|
arb_poly_riemann_siegel_theta_series(arb_poly_t res,
|
|
const arb_poly_t f, long n, long prec)
|
|
{
|
|
if (n == 0 || f->length == 0)
|
|
{
|
|
arb_poly_zero(res);
|
|
return;
|
|
}
|
|
|
|
if (res == f)
|
|
{
|
|
arb_poly_t tmp;
|
|
arb_poly_init2(tmp, n);
|
|
_arb_poly_riemann_siegel_theta_series(tmp->coeffs,
|
|
f->coeffs, f->length, n, prec);
|
|
arb_poly_swap(res, tmp);
|
|
arb_poly_clear(tmp);
|
|
}
|
|
else
|
|
{
|
|
arb_poly_fit_length(res, n);
|
|
_arb_poly_riemann_siegel_theta_series(res->coeffs,
|
|
f->coeffs, f->length, n, prec);
|
|
}
|
|
|
|
_arb_poly_set_length(res, n);
|
|
_arb_poly_normalise(res);
|
|
}
|
|
|