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