]> www.ginac.de Git - cln.git/blob - src/complex/transcendental/cl_C_sin.cc
2d5935c3fafe7dbde9b157ec9acb61f411e85831
[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 "cl_complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cl_real.h"
14
15 const cl_N sin (const cl_N& x)
16 {
17 // Methode:
18 // x reell -> klar
19 // x = a+bi -> (complex (* (sin a) (cosh b)) (* (cos a) (sinh b)))
20         if (realp(x)) {
21                 DeclareType(cl_R,x);
22                 return sin(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_cosh_sinh_t hyp_b = cl_cosh_sinh(b); // cosh(b), sinh(b) errechnen
29                 var cl_cos_sin_t trig_a = cl_cos_sin(a); // cos(a), sin(a) errechnen
30                 // Da b nicht = Fixnum 0 ist, ist auch sinh(b) nicht = Fixnum 0.
31                 // cos(a) /= Fixnum 0.
32                 return complex_C(trig_a.sin * hyp_b.cosh, // sin(a)*cosh(b)
33                                  trig_a.cos * hyp_b.sinh // cos(a)*sinh(b), nicht Fixnum 0
34                                 );
35         }
36 }