]> www.ginac.de Git - cln.git/blob - src/complex/elem/cl_C_equal.cc
2004-01-01 Richard B. Kreckel <kreckel@ginac.de>
[cln.git] / src / complex / elem / cl_C_equal.cc
1 // equal().
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 cl_boolean equal (const cl_N& x, const cl_N& y)
18 {
19 // Methode:
20 // Falls beide reell, klar.
21 // Falls x reell, y komplex: (= x (realpart y)) und (zerop (imagpart y)).
22 // Falls x komplex, y reell: analog
23 // Falls beide komplex: Realteile und Imaginärteile jeweils gleich?
24         if (realp(x)) {
25                 DeclareType(cl_R,x);
26                 if (realp(y)) {
27                         DeclareType(cl_R,y);
28                         // x,y beide reell
29                         return equal(x,y);
30                 } else {
31                         DeclareType(cl_C,y);
32                         // x reell, y komplex
33                         if (!zerop(imagpart(y)))
34                                 return cl_false;
35                         return equal(x,realpart(y));
36                 }
37         } else {
38                 DeclareType(cl_C,x);
39                 if (realp(y)) {
40                         DeclareType(cl_R,y);
41                         // x komplex, y reell
42                         if (!zerop(imagpart(x)))
43                                 return cl_false;
44                         return equal(realpart(x),y);
45                 } else {
46                         DeclareType(cl_C,y);
47                         // x,y beide komplex
48                         if (!equal(realpart(x),realpart(y)))
49                                 return cl_false;
50                         if (!equal(imagpart(x),imagpart(y)))
51                                 return cl_false;
52                         return cl_true;
53                 }
54         }
55 }
56
57 }  // namespace cln