OSDN Git Service

Merge tree-ssa-20020619-branch into mainline.
[pf3gnuchains/gcc-fork.git] / libgfortran / generated / trig_c8.c
1 /* Complex trig functions
2    Copyright 2002 Free Software Foundation, Inc.
3    Contributed by Paul Brook <paul@nowt.org>
4
5 This file is part of the GNU Fortran 95 runtime library (libgfor).
6
7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 Libgfortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with libgfor; see the file COPYING.LIB.  If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21 #include <math.h>
22 #include "libgfortran.h"
23
24
25 /* Complex number z = a + ib.  */
26
27 /* sin(z) = sin(a)cosh(b) + icos(a)sinh(b)  */
28 GFC_COMPLEX_8
29 csin (GFC_COMPLEX_8 a)
30 {
31   GFC_REAL_8 r;
32   GFC_REAL_8 i;
33   GFC_COMPLEX_8 v;
34
35   r = REALPART (a);
36   i = IMAGPART (a);
37   COMPLEX_ASSIGN (v, sin (r) * cosh (i), cos (r) * sinh (i));
38   return v;
39 }
40
41 /* cos(z) = cos(a)cosh(b) - isin(a)sinh(b)  */
42 GFC_COMPLEX_8
43 ccos (GFC_COMPLEX_8 a)
44 {
45   GFC_REAL_8 r;
46   GFC_REAL_8 i;
47   GFC_COMPLEX_8 v;
48
49   r = REALPART (a);
50   i = IMAGPART (a);
51   COMPLEX_ASSIGN (v, cos (r) * cosh (i), - (sin (r) * sinh (i)));
52   return v;
53 }
54
55 /* tan(z) = (tan(a) + itanh(b)) / (1 - itan(a)tanh(b))  */
56 GFC_COMPLEX_8
57 ctan (GFC_COMPLEX_8 a)
58 {
59   GFC_REAL_8 rt;
60   GFC_REAL_8 it;
61   GFC_COMPLEX_8 n;
62   GFC_COMPLEX_8 d;
63
64   rt = tan (REALPART (a));
65   it = tanh (IMAGPART (a));
66   COMPLEX_ASSIGN (n, rt, it);
67   COMPLEX_ASSIGN (d , 1, - (rt * it));
68
69   return n / d;
70 }
71