From bcf76d07acba2fce6959c42154a8857c0bd5e4ba Mon Sep 17 00:00:00 2001 From: fredrik Date: Mon, 14 Oct 2019 15:53:44 -0400 Subject: [PATCH] theta_series --- acb_modular.h | 8 +++ acb_modular/test/t-theta_series.c | 102 ++++++++++++++++++++++++++++ acb_modular/theta_series.c | 107 ++++++++++++++++++++++++++++++ doc/source/acb_modular.rst | 8 +++ 4 files changed, 225 insertions(+) create mode 100644 acb_modular/test/t-theta_series.c create mode 100644 acb_modular/theta_series.c diff --git a/acb_modular.h b/acb_modular.h index 2040fd18..1eef61c5 100644 --- a/acb_modular.h +++ b/acb_modular.h @@ -15,6 +15,7 @@ #include #include "flint/fmpz_poly.h" #include "acb.h" +#include "acb_poly.h" #ifdef __cplusplus extern "C" { @@ -162,6 +163,13 @@ void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec); +void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, + acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec); + +void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, + acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, + slong len, slong prec); + void acb_modular_j(acb_t z, const acb_t tau, slong prec); int acb_modular_epsilon_arg(const psl2z_t g); diff --git a/acb_modular/test/t-theta_series.c b/acb_modular/test/t-theta_series.c new file mode 100644 index 00000000..409771b7 --- /dev/null +++ b/acb_modular/test/t-theta_series.c @@ -0,0 +1,102 @@ +/* + Copyright (C) 2019 Fredrik Johansson + + 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_modular.h" + +int main() +{ + slong iter; + flint_rand_t state; + + flint_printf("theta_series...."); + fflush(stdout); + + flint_randinit(state); + + for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++) + { + acb_poly_t t1, t2, t3, t4, t1b, t2b, t3b, t4b, z; + acb_t tau; + slong len1, len2, prec1, prec2; + unsigned int mask; + + acb_poly_init(t1); acb_poly_init(t1b); + acb_poly_init(t2); acb_poly_init(t2b); + acb_poly_init(t3); acb_poly_init(t3b); + acb_poly_init(t4); acb_poly_init(t4b); + acb_poly_init(z); + acb_init(tau); + + prec1 = 2 + n_randint(state, 300); + prec2 = 2 + n_randint(state, 300); + + len1 = n_randint(state, 6); + len2 = n_randint(state, 6); + + acb_poly_randtest(t1, state, 10, prec1, 10); + acb_poly_randtest(t2, state, 10, prec1, 10); + acb_poly_randtest(t3, state, 10, prec1, 10); + acb_poly_randtest(t4, state, 10, prec1, 10); + acb_poly_randtest(z, state, 1 + n_randint(state, 10), prec1, 10); + acb_randtest(tau, state, prec1, 10); + + acb_modular_theta_series(t1, t2, t3, t4, z, tau, len1, prec1); + + mask = n_randlimb(state); + + acb_modular_theta_series((mask & 1) ? t1b : NULL, + (mask & 2) ? t2b : NULL, + (mask & 4) ? t3b : NULL, + (mask & 8) ? t4b : NULL, z, tau, len2, prec2); + + acb_poly_truncate(t1, FLINT_MIN(len1, len2)); + acb_poly_truncate(t1b, FLINT_MIN(len1, len2)); + acb_poly_truncate(t2, FLINT_MIN(len1, len2)); + acb_poly_truncate(t2b, FLINT_MIN(len1, len2)); + acb_poly_truncate(t3, FLINT_MIN(len1, len2)); + acb_poly_truncate(t3b, FLINT_MIN(len1, len2)); + acb_poly_truncate(t4, FLINT_MIN(len1, len2)); + acb_poly_truncate(t4b, FLINT_MIN(len1, len2)); + + if (((mask & 1) && (!acb_poly_overlaps(t1, t1b))) || + ((mask & 2) && (!acb_poly_overlaps(t2, t2b))) || + ((mask & 4) && (!acb_poly_overlaps(t3, t3b))) || + ((mask & 8) && (!acb_poly_overlaps(t4, t4b)))) + { + flint_printf("FAIL: consistency (mask)\n\n"); + flint_printf("mask = %u\n\n", mask); + flint_printf("len1 = %wd, len2 = %wd\n\n", len1, len2); + flint_printf("z = "); acb_poly_printd(z, 30); flint_printf("\n\n"); + flint_printf("tau = "); acb_printd(tau, 30); flint_printf("\n\n"); + flint_printf("t1 = "); acb_poly_printd(t1, 30); flint_printf("\n\n"); + flint_printf("t1b = "); acb_poly_printd(t1b, 30); flint_printf("\n\n"); + flint_printf("t2 = "); acb_poly_printd(t2, 30); flint_printf("\n\n"); + flint_printf("t2b = "); acb_poly_printd(t2b, 30); flint_printf("\n\n"); + flint_printf("t3 = "); acb_poly_printd(t3, 30); flint_printf("\n\n"); + flint_printf("t3b = "); acb_poly_printd(t3b, 30); flint_printf("\n\n"); + flint_printf("t4 = "); acb_poly_printd(t4, 30); flint_printf("\n\n"); + flint_printf("t4b = "); acb_poly_printd(t4b, 30); flint_printf("\n\n"); + flint_abort(); + } + + acb_poly_clear(t1); acb_poly_clear(t1b); + acb_poly_clear(t2); acb_poly_clear(t2b); + acb_poly_clear(t3); acb_poly_clear(t3b); + acb_poly_clear(t4); acb_poly_clear(t4b); + acb_poly_clear(z); acb_clear(tau); + } + + flint_randclear(state); + flint_cleanup(); + flint_printf("PASS\n"); + return EXIT_SUCCESS; +} + diff --git a/acb_modular/theta_series.c b/acb_modular/theta_series.c new file mode 100644 index 00000000..f1e58400 --- /dev/null +++ b/acb_modular/theta_series.c @@ -0,0 +1,107 @@ +/* + Copyright (C) 2019 Fredrik Johansson + + 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_modular.h" + +void +_acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, + acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) +{ + acb_ptr t1, t2, t3, t4, t, v; + + zlen = FLINT_MIN(zlen, len); + + if (zlen <= 0) + return; + + t = _acb_vec_init(4 * len); + t1 = t; + t2 = t1 + len; + t3 = t2 + len; + t4 = t3 + len; + + acb_modular_theta_jet(t1, t2, t3, t4, z, tau, len, prec); + + if (len == 1) + { + if (theta1 != NULL) acb_set(theta1, t1); + if (theta2 != NULL) acb_set(theta2, t2); + if (theta3 != NULL) acb_set(theta3, t3); + if (theta4 != NULL) acb_set(theta4, t4); + } + else + { + v = _acb_vec_init(zlen); + + /* compose with nonconstant part */ + acb_zero(v); + _acb_vec_set(v + 1, z + 1, zlen - 1); + + if (theta1 != NULL) _acb_poly_compose_series(theta1, t1, len, v, zlen, len, prec); + if (theta2 != NULL) _acb_poly_compose_series(theta2, t2, len, v, zlen, len, prec); + if (theta3 != NULL) _acb_poly_compose_series(theta3, t3, len, v, zlen, len, prec); + if (theta4 != NULL) _acb_poly_compose_series(theta4, t4, len, v, zlen, len, prec); + + _acb_vec_clear(v, zlen); + } + + _acb_vec_clear(t, 4 * len); +} + +void +acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, + acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, + slong len, slong prec) +{ + if (len == 0) + { + if (theta1 != NULL) acb_poly_zero(theta1); + if (theta2 != NULL) acb_poly_zero(theta2); + if (theta3 != NULL) acb_poly_zero(theta3); + if (theta4 != NULL) acb_poly_zero(theta4); + return; + } + + if (z->length <= 1) + len = 1; + + if (theta1 != NULL) acb_poly_fit_length(theta1, len); + if (theta2 != NULL) acb_poly_fit_length(theta2, len); + if (theta3 != NULL) acb_poly_fit_length(theta3, len); + if (theta4 != NULL) acb_poly_fit_length(theta4, len); + + if (z->length == 0) + { + acb_t t; + acb_init(t); + _acb_modular_theta_series(theta1 ? theta1->coeffs : NULL, + theta2 ? theta2->coeffs : NULL, theta3 ? theta3->coeffs : NULL, + theta4 ? theta4->coeffs : NULL, t, 1, tau, len, prec); + acb_clear(t); + } + else + { + _acb_modular_theta_series(theta1 ? theta1->coeffs : NULL, + theta2 ? theta2->coeffs : NULL, theta3 ? theta3->coeffs : NULL, + theta4 ? theta4->coeffs : NULL, z->coeffs, z->length, tau, len, prec); + } + + if (theta1 != NULL) _acb_poly_set_length(theta1, len); + if (theta2 != NULL) _acb_poly_set_length(theta2, len); + if (theta3 != NULL) _acb_poly_set_length(theta3, len); + if (theta4 != NULL) _acb_poly_set_length(theta4, len); + + if (theta1 != NULL) _acb_poly_normalise(theta1); + if (theta2 != NULL) _acb_poly_normalise(theta2); + if (theta3 != NULL) _acb_poly_normalise(theta3); + if (theta4 != NULL) _acb_poly_normalise(theta4); +} + diff --git a/doc/source/acb_modular.rst b/doc/source/acb_modular.rst index 61b73148..b6f3cdbf 100644 --- a/doc/source/acb_modular.rst +++ b/doc/source/acb_modular.rst @@ -440,6 +440,14 @@ To avoid confusion, we only write `q^k` when `k` is an integer. each respective output variable. The *notransform* version does not move `\tau` to the fundamental domain or reduce `z` during the computation. +.. function:: void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) + +.. function:: void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) + + Evaluates the respective Jacobi theta functions of the power series *z*, + truncated to length *len*. Either of the output variables can be *NULL*. + + Dedekind eta function -------------------------------------------------------------------------------