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_cos(acb_t r,const acb_t z,slong prec)15 acb_cos(acb_t r, 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_cos(acb_realref(r), a, prec);
22 arb_zero(acb_imagref(r));
23 }
24 else if (arb_is_zero(a))
25 {
26 arb_cosh(acb_realref(r), b, prec);
27 arb_zero(acb_imagref(r));
28 }
29 else
30 {
31 arb_t sa, ca, sb, cb;
32
33 arb_init(sa);
34 arb_init(ca);
35 arb_init(sb);
36 arb_init(cb);
37
38 arb_sin_cos(sa, ca, a, prec);
39 arb_sinh_cosh(sb, cb, b, prec);
40
41 arb_mul(acb_realref(r), ca, cb, prec);
42 arb_mul(acb_imagref(r), sa, sb, prec);
43 arb_neg(acb_imagref(r), acb_imagref(r));
44
45 arb_clear(sa);
46 arb_clear(ca);
47 arb_clear(sb);
48 arb_clear(cb);
49 }
50 #undef a
51 #undef b
52 }
53
54