]> www.ginac.de Git - cln.git/blob - src/complex/misc/cl_C_eqhashcode.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / complex / misc / cl_C_eqhashcode.cc
1 // cl_N equal_hashcode().
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_N.h"
13 #include "cl_C.h"
14 #include "cln/real.h"
15
16 namespace cln {
17
18 uint32 equal_hashcode (const cl_N& x)
19 {
20         if (realp(x)) {
21                 DeclareType(cl_R,x);
22                 return equal_hashcode(x);
23         } else {
24                 DeclareType(cl_C,x);
25                 var const cl_R& a = realpart(x);
26                 var const cl_R& b = imagpart(x);
27                 var uint32 code1 = equal_hashcode(a);
28                 var uint32 code2 = equal_hashcode(b);
29                 // Wichtig beim Kombinieren, wegen "complex canonicalization":
30                 // Ist imagpart=0.0, so ist der Hashcode = equal_hashcode(a).
31                 return code1 ^ ((code2 << 5) | (code2 >> 27));
32         }
33 }
34
35 }  // namespace cln