1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
*/
#include "acb_elliptic.h"
void
_acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z,
int flags, slong prec)
{
acb_t a, b, c, t;
slong wp;
wp = prec + 10;
acb_init(a);
acb_init(b);
acb_init(c);
acb_init(t);
acb_elliptic_rf(a, x, y, z, 0, wp);
acb_mul(a, a, z, wp);
acb_elliptic_rj(b, x, y, z, z, 0, wp);
acb_sub(c, x, z, wp);
acb_mul(b, b, c, wp);
acb_sub(c, z, y, wp);
acb_mul(b, b, c, wp);
acb_div_ui(b, b, 3, wp);
acb_sqrt(c, x, wp);
acb_sqrt(t, y, wp);
acb_mul(c, c, t, wp);
acb_rsqrt(t, z, wp);
acb_mul(c, c, t, wp);
acb_add(res, a, b, wp);
acb_add(res, res, c, prec);
acb_mul_2exp_si(res, res, -1);
acb_clear(a);
acb_clear(b);
acb_clear(c);
acb_clear(t);
}
void
acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z,
int flags, slong prec)
{
if (acb_is_zero(x) && acb_is_zero(y))
{
acb_sqrt(res, z, prec);
acb_mul_2exp_si(res, res, -1);
}
else if (acb_is_zero(x) && acb_is_zero(z))
{
acb_sqrt(res, y, prec);
acb_mul_2exp_si(res, res, -1);
}
else if (acb_is_zero(y) && acb_is_zero(z))
{
acb_sqrt(res, x, prec);
acb_mul_2exp_si(res, res, -1);
}
else if (acb_contains_zero(z))
{
if (acb_contains_zero(y))
_acb_elliptic_rg(res, y, z, x, flags, prec);
else
_acb_elliptic_rg(res, x, z, y, flags, prec);
}
else
{
_acb_elliptic_rg(res, x, y, z, flags, prec);
}
}
|