arb/acb/unit_root.c

43 lines
963 B
C
Raw Normal View History

2016-09-06 15:32:23 +02:00
/*
Copyright (C) 2016 Pascal Molin
2016-09-06 15:32:23 +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 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.h"
2016-04-12 15:07:04 +02:00
static void
_acb_unit_root(acb_t res, ulong order, slong prec)
{
fmpq_t t;
fmpq_init(t);
fmpq_set_si(t, 2, order);
arb_sin_cos_pi_fmpq(acb_imagref(res), acb_realref(res), t, prec);
fmpq_clear(t);
}
2016-04-12 15:07:04 +02:00
void
acb_unit_root(acb_t res, ulong order, slong prec)
2016-04-12 15:07:04 +02:00
{
switch (order)
{
case 1:
acb_one(res);
break;
case 2:
acb_set_si(res, -1);
break;
case 4:
acb_onei(res);
break;
default:
_acb_unit_root(res, order, prec);
2016-04-12 15:07:04 +02:00
break;
}
}