]> www.ginac.de Git - cln.git/blob - src/complex/misc/cl_C_eqhashcode.cc
Initial revision
[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 "cl_complex.h"
8
9
10 // Implementation.
11
12 #include "cl_N.h"
13 #include "cl_C.h"
14 #include "cl_real.h"
15
16 uint32 cl_equal_hashcode (const cl_N& x)
17 {
18         if (realp(x)) {
19                 DeclareType(cl_R,x);
20                 return cl_equal_hashcode(x);
21         } else {
22                 DeclareType(cl_C,x);
23                 var const cl_R& a = realpart(x);
24                 var const cl_R& b = imagpart(x);
25                 var uint32 code1 = cl_equal_hashcode(a);
26                 var uint32 code2 = cl_equal_hashcode(b);
27                 // Wichtig beim Kombinieren, wegen "complex canonicalization":
28                 // Ist imagpart=0.0, so ist der Hashcode = cl_equal_hashcode(a).
29                 return code1 ^ ((code2 << 5) | (code2 >> 27));
30         }
31 }