1 | /*! |
---|
2 | * \file F5cData.cc |
---|
3 | * \author Christian Eder |
---|
4 | * \brief This file includes the inlined methods of the classes CPair and Rule. |
---|
5 | * \details This file include the inlined methods of the class CPair, |
---|
6 | * representing critical pairs in the F5C Algorithm, and the class Rule, |
---|
7 | * representing the labels in the F5C Algorithm. In this file the handling of |
---|
8 | * these data types is defined. |
---|
9 | */ |
---|
10 | |
---|
11 | #include "mod2.h" |
---|
12 | |
---|
13 | #ifdef HAVE_F5C |
---|
14 | #include "kutil.h" |
---|
15 | #include "structs.h" |
---|
16 | #include "omalloc.h" |
---|
17 | #include "polys.h" |
---|
18 | #include "p_polys.h" |
---|
19 | #include "ideals.h" |
---|
20 | #include "febase.h" |
---|
21 | #include "kstd1.h" |
---|
22 | #include "khstd.h" |
---|
23 | #include "kbuckets.h" |
---|
24 | #include "weight.h" |
---|
25 | #include "intvec.h" |
---|
26 | #include "pInline1.h" |
---|
27 | #include "f5c.h" |
---|
28 | #include "F5cData.h" |
---|
29 | #include "F5cLists.h" |
---|
30 | |
---|
31 | /* |
---|
32 | * CONSTRUCTOR / DESTRUCTOR of class Label |
---|
33 | */ |
---|
34 | |
---|
35 | Label::Label(int* expVec) |
---|
36 | { |
---|
37 | m_pExpVec = expVec; |
---|
38 | m_nShortExpVec = computeShortExpVec(m_pExpVec); |
---|
39 | } |
---|
40 | |
---|
41 | Label::~Label() |
---|
42 | { |
---|
43 | delete &m_nShortExpVec; |
---|
44 | delete [] m_pExpVec; |
---|
45 | } |
---|
46 | |
---|
47 | /* |
---|
48 | * GETTER of class Label |
---|
49 | */ |
---|
50 | inline int* Label::getExpVec() |
---|
51 | { |
---|
52 | return m_pExpVec; |
---|
53 | } |
---|
54 | |
---|
55 | inline unsigned long Label::getShortExpVec() |
---|
56 | { |
---|
57 | return m_nShortExpVec; |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * SETTER of class Label |
---|
62 | */ |
---|
63 | |
---|
64 | |
---|
65 | /* |
---|
66 | * MISC of class Label |
---|
67 | */ |
---|
68 | inline unsigned long Label::computeShortExpVec(int* expVec) |
---|
69 | { |
---|
70 | //if (p == NULL) return 0; |
---|
71 | unsigned long ev = 0; // short exponent vector |
---|
72 | unsigned int n = BIT_SIZEOF_LONG / currRing->N; // number of bits per exp |
---|
73 | unsigned int m1; // highest bit which is filled with (n+1) |
---|
74 | unsigned int i = 0, j=1; |
---|
75 | |
---|
76 | if (n == 0) |
---|
77 | { |
---|
78 | if (currRing->N <2*BIT_SIZEOF_LONG) |
---|
79 | { |
---|
80 | n=1; |
---|
81 | m1=0; |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | for (; j<=(unsigned long) currRing->N; j++) |
---|
86 | { |
---|
87 | if (expVec[j] > 0) i++; |
---|
88 | if (i == BIT_SIZEOF_LONG) break; |
---|
89 | } |
---|
90 | if (i>0) |
---|
91 | ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i)); |
---|
92 | return ev; |
---|
93 | } |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | m1 = (n+1)*(BIT_SIZEOF_LONG - n*currRing->N); |
---|
98 | } |
---|
99 | |
---|
100 | n++; |
---|
101 | while (i<m1) |
---|
102 | { |
---|
103 | ev |= getBitFields(expVec[j], i, n); |
---|
104 | i += n; |
---|
105 | j++; |
---|
106 | } |
---|
107 | |
---|
108 | n--; |
---|
109 | while (i<BIT_SIZEOF_LONG) |
---|
110 | { |
---|
111 | ev |= getBitFields(expVec[j], i, n); |
---|
112 | i += n; |
---|
113 | j++; |
---|
114 | } |
---|
115 | return ev; |
---|
116 | } |
---|
117 | |
---|
118 | inline unsigned long Label::getBitFields(int e, unsigned int s, unsigned int n) |
---|
119 | { |
---|
120 | #define Sy_bit_L(x) (((unsigned long)1L)<<(x)) |
---|
121 | unsigned int i = 0; |
---|
122 | unsigned long ev = 0L; |
---|
123 | assume(n > 0 && s < BIT_SIZEOF_LONG); |
---|
124 | do |
---|
125 | { |
---|
126 | assume(s+i < BIT_SIZEOF_LONG); |
---|
127 | if (e > (int) i) ev |= Sy_bit_L(s+i); |
---|
128 | else break; |
---|
129 | i++; |
---|
130 | } |
---|
131 | while (i < n); |
---|
132 | return ev; |
---|
133 | } |
---|
134 | |
---|
135 | |
---|
136 | |
---|
137 | #endif |
---|
138 | // HAVE_F5C |
---|