source: git/kernel/F5cData.cc @ e44367

spielwiese
Last change on this file since e44367 was e44367, checked in by Christian Eder, 15 years ago
first implementation of classes Label, CPair and RuleAndShort git-svn-id: file:///usr/local/Singular/svn/trunk@11964 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*!
2 * \file F5cData.cc
3 * \author Christian Eder
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,
8 * representing the labels in the F5C Algorithm. In this file the handling of
9 * these data types is defined.
10 */
11
12#include "mod2.h"
13
14#ifdef HAVE_F5C
15#include "kutil.h"
16#include "structs.h"
17#include "omalloc.h"
18#include "polys.h"
19#include "p_polys.h"
20#include "ideals.h"
21#include "febase.h"
22#include "kstd1.h"
23#include "khstd.h"
24#include "kbuckets.h"
25#include "weight.h"
26#include "intvec.h"
27#include "pInline1.h"
28#include "f5c.h"
29#include "F5cData.h"
30#include "F5cLists.h"
31
32
33// IMPLEMENTATIONS OF METHODS OF CLASS LABEL
34
35
36// constructor / destructor of class Label
37Label::Label(unsigned int* expVec) {
38  m_pExpVec       = expVec;
39  m_nShortExpVec  = computeShortExpVec(m_pExpVec);
40}
41
42Label::~Label() {
43  delete &m_nShortExpVec;
44  delete [] m_pExpVec;
45}
46
47
48// GETTER of class Label
49unsigned int* Label::getExpVec() {
50  return m_pExpVec;
51}
52
53unsigned long Label::getShortExpVec() {
54  return m_nShortExpVec;
55}
56
57
58// SETTER of class Label
59
60
61// MISC of class Label
62unsigned long Label::computeShortExpVec(unsigned int* expVec) {
63  //if (p == NULL) return 0;
64  unsigned long ev = 0; // short exponent vector
65  unsigned int n = BIT_SIZEOF_LONG / currRing->N; // number of bits per exp
66  unsigned int m1; // highest bit which is filled with (n+1)
67  unsigned int i = 0, j=1;
68
69  if (n == 0) {
70    if (currRing->N <2*BIT_SIZEOF_LONG) {
71      n=1;
72      m1=0;
73    }
74    else {
75      for (; j<=(unsigned long) currRing->N; j++) {
76        if (expVec[j] > 0) i++;
77        if (i == BIT_SIZEOF_LONG) break;
78      }
79      if (i>0)
80      ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));
81      return ev;
82    }
83  }
84  else {
85    m1 = (n+1)*(BIT_SIZEOF_LONG - n*currRing->N);
86  }
87
88  n++;
89  while (i<m1) {
90    ev |= getBitFields(expVec[j], i, n);
91    i += n;
92    j++;
93  }
94
95  n--;
96  while (i<BIT_SIZEOF_LONG) {
97    ev |= getBitFields(expVec[j], i, n);
98    i += n;
99    j++;
100  }
101  return ev;
102}
103
104unsigned long Label::getBitFields(unsigned int e, unsigned int s, unsigned int n) {
105#define Sy_bit_L(x)     (((unsigned long)1L)<<(x))
106  unsigned int i = 0;
107  unsigned long  ev = 0L;
108  assume(n > 0 && s < BIT_SIZEOF_LONG);
109  do {
110    assume(s+i < BIT_SIZEOF_LONG);
111    if (e > (int) i) ev |= Sy_bit_L(s+i);
112    else break;
113    i++;
114  }
115  while (i < n);
116  return ev;
117}
118
119// END IMPLEMENTATIONS OF METHODS OF CLASS LABEL
120
121#endif
122// HAVE_F5C
Note: See TracBrowser for help on using the repository browser.