]> www.ginac.de Git - cln.git/blob - src/complex/elem/division/cl_C_div.cc
* Removed internal gmp/ directory and other traces of it like $GMP_INCLUDES.
[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 "cl_complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cl_real.h"
14
15 const cl_N operator/ (const cl_N& x, const cl_N& y)
16 {
17 // Methode:
18 // x,y beide reell -> klar.
19 // x=a+bi, y=c reell -> (a/c)+(b/c)i
20 // y komplex -> (* x (/ y))
21         if (realp(y)) {
22                 DeclareType(cl_R,y);
23                 if (realp(x)) {
24                         DeclareType(cl_R,x);
25                         // x,y beide reell
26                         return x/y;
27                 } else {
28                         DeclareType(cl_C,x);
29                         // x komplex: x=a+bi, y=c
30                         var const cl_R& a = realpart(x);
31                         var const cl_R& b = imagpart(x);
32                         var const cl_R& c = y;
33                         return complex(a/c,b/c);
34                 }
35         } else {
36                 DeclareType(cl_C,y);
37                 // y komplex
38                 return x * recip(y);
39         }
40 }