arb/acb_poly/powsum_series_naive.c

116 lines
2.9 KiB
C
Raw Normal View History

2014-06-13 22:08:25 +02: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_poly.h"
void _acb_poly_acb_invpow_cpx(acb_ptr res, const acb_t N, const acb_t c, slong trunc, slong prec)
2014-06-13 22:08:25 +02:00
{
slong i;
2014-06-13 22:08:25 +02:00
acb_t logN;
acb_init(logN);
acb_log(logN, N, prec);
acb_mul(res + 0, logN, c, prec);
acb_neg(res + 0, res + 0);
acb_exp(res + 0, res + 0, prec);
for (i = 1; i < trunc; i++)
{
acb_mul(res + i, res + i - 1, logN, prec);
acb_div_si(res + i, res + i, -i, prec);
}
acb_clear(logN);
}
void
_acb_poly_powsum_series_naive(acb_ptr z,
const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec)
2014-06-13 22:08:25 +02:00
{
slong k, i;
2014-07-10 16:29:32 +02:00
int q_one, s_int;
acb_t ak, logak, t, qpow, negs;
2014-06-13 22:08:25 +02:00
acb_init(ak);
acb_init(logak);
acb_init(t);
acb_init(qpow);
2014-07-10 16:29:32 +02:00
acb_init(negs);
2014-06-13 22:08:25 +02:00
_acb_vec_zero(z, len);
acb_one(qpow);
2014-07-10 16:29:32 +02:00
acb_neg(negs, s);
q_one = acb_is_one(q);
2014-07-10 16:29:32 +02:00
s_int = arb_is_int(acb_realref(s)) && arb_is_zero(acb_imagref(s));
2014-06-13 22:08:25 +02:00
for (k = 0; k < n; k++)
{
acb_add_ui(ak, a, k, prec);
if (len == 1)
{
2014-07-10 16:29:32 +02:00
acb_pow(t, ak, negs, prec);
}
else
{
acb_log(logak, ak, prec);
2014-07-10 16:29:32 +02:00
if (s_int)
{
acb_pow(t, ak, negs, prec);
}
else
{
acb_mul(t, logak, negs, prec);
acb_exp(t, t, prec);
}
}
if (!q_one)
{
acb_mul(t, t, qpow, prec);
if (k < n - 1)
acb_mul(qpow, qpow, q, prec);
}
acb_add(z, z, t, prec);
for (i = 1; i < len; i++)
{
acb_mul(t, t, logak, prec);
acb_div_si(t, t, -i, prec);
acb_add(z + i, z + i, t, prec);
}
2014-06-13 22:08:25 +02:00
}
acb_clear(ak);
acb_clear(logak);
acb_clear(t);
acb_clear(qpow);
2014-07-10 16:29:32 +02:00
acb_clear(negs);
2014-06-13 22:08:25 +02:00
}