]> www.ginac.de Git - cln.git/blob - src/complex/elem/division/cl_C_div.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / complex / elem / division / cl_C_div.cc
1 // binary operator /
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 operator/ (const cl_N& x, const cl_N& y)
18 {
19 // Methode:
20 // x,y beide reell -> klar.
21 // x=a+bi, y=c reell -> (a/c)+(b/c)i
22 // y komplex -> (* x (/ y))
23         if (realp(y)) {
24                 DeclareType(cl_R,y);
25                 if (realp(x)) {
26                         DeclareType(cl_R,x);
27                         // x,y beide reell
28                         return x/y;
29                 } else {
30                         DeclareType(cl_C,x);
31                         // x komplex: x=a+bi, y=c
32                         var const cl_R& a = realpart(x);
33                         var const cl_R& b = imagpart(x);
34                         var const cl_R& c = y;
35                         return complex(a/c,b/c);
36                 }
37         } else {
38                 DeclareType(cl_C,y);
39                 // y komplex
40                 return x * recip(y);
41         }
42 }
43
44 }  // namespace cln