1 /*
2     Copyright (C) 2012 Fredrik Johansson
3 
4     This file is part of Arb.
5 
6     Arb is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
10 */
11 
12 #include "acb.h"
13 
14 void
acb_sin_cos_pi(acb_t s,acb_t c,const acb_t z,slong prec)15 acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec)
16 {
17 #define a acb_realref(z)
18 #define b acb_imagref(z)
19     if (arb_is_zero(b))
20     {
21         arb_sin_cos_pi(acb_realref(s), acb_realref(c), a, prec);
22         arb_zero(acb_imagref(s));
23         arb_zero(acb_imagref(c));
24     }
25     else if (arb_is_zero(a))
26     {
27         arb_t t;
28         arb_init(t);
29         arb_const_pi(t, prec);
30         arb_mul(t, t, b, prec);
31         arb_sinh_cosh(acb_imagref(s), acb_realref(c), t, prec);
32         arb_zero(acb_realref(s));
33         arb_zero(acb_imagref(c));
34         arb_clear(t);
35     }
36     else
37     {
38         arb_t sa, ca, sb, cb;
39 
40         arb_init(sa);
41         arb_init(ca);
42         arb_init(sb);
43         arb_init(cb);
44 
45         arb_const_pi(sb, prec);
46         arb_mul(sb, sb, b, prec);
47 
48         arb_sin_cos_pi(sa, ca, a, prec);
49         arb_sinh_cosh(sb, cb, sb, prec);
50 
51         arb_mul(acb_realref(s), sa, cb, prec);
52         arb_mul(acb_imagref(s), sb, ca, prec);
53 
54         arb_mul(acb_realref(c), ca, cb, prec);
55         arb_mul(acb_imagref(c), sa, sb, prec);
56         arb_neg(acb_imagref(c), acb_imagref(c));
57 
58         arb_clear(sa);
59         arb_clear(ca);
60         arb_clear(sb);
61         arb_clear(cb);
62     }
63 #undef a
64 #undef b
65 }
66 
67