]> www.ginac.de Git - cln.git/blob - src/complex/transcendental/cl_C_sin.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / complex / transcendental / cl_C_sin.cc
1 // sin().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cln/real.h"
14
15 namespace cln {
16
17 const cl_N sin (const cl_N& x)
18 {
19 // Methode:
20 // x reell -> klar
21 // x = a+bi -> (complex (* (sin a) (cosh b)) (* (cos a) (sinh b)))
22         if (realp(x)) {
23                 DeclareType(cl_R,x);
24                 return sin(x);
25         } else {
26                 DeclareType(cl_C,x);
27                 // x=a+bi
28                 var const cl_R& a = realpart(x);
29                 var const cl_R& b = imagpart(x);
30                 var cosh_sinh_t hyp_b = cosh_sinh(b); // cosh(b), sinh(b) errechnen
31                 var cos_sin_t trig_a = cos_sin(a); // cos(a), sin(a) errechnen
32                 // Da b nicht = Fixnum 0 ist, ist auch sinh(b) nicht = Fixnum 0.
33                 // cos(a) /= Fixnum 0.
34                 return complex_C(trig_a.sin * hyp_b.cosh, // sin(a)*cosh(b)
35                                  trig_a.cos * hyp_b.sinh // cos(a)*sinh(b), nicht Fixnum 0
36                                 );
37         }
38 }
39
40 }  // namespace cln