]> www.ginac.de Git - cln.git/blob - src/complex/transcendental/cl_C_cosh.cc
f8a1ec2278b867fcaec4ae6382eaf0fa8c73b8af
[cln.git] / src / complex / transcendental / cl_C_cosh.cc
1 // cosh().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cl_real.h"
14
15 const cl_N cosh (const cl_N& x)
16 {
17 // Methode:
18 // x reell -> klar
19 // x = a+bi -> (complex (* (cosh a) (cos b)) (* (sinh a) (sin b)))
20         if (realp(x)) {
21                 DeclareType(cl_R,x);
22                 return cosh(x);
23         } else {
24                 DeclareType(cl_C,x);
25                 // x=a+bi
26                 var const cl_R& a = realpart(x);
27                 var const cl_R& b = imagpart(x);
28                 var cl_cos_sin_t trig_b = cl_cos_sin(b); // cos(b), sin(b) errechnen
29                 var cl_cosh_sinh_t hyp_a = cl_cosh_sinh(a); // cosh(a), sinh(a) errechnen
30                 return complex(hyp_a.cosh * trig_b.cos, // cosh(a)*cos(b)
31                                hyp_a.sinh * trig_b.sin // sinh(a)*sin(b)
32                               );
33         }
34 }