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