source: git/kernel/F5cData.cc @ 642e65

spielwiese
Last change on this file since 642e65 was 642e65, checked in by Christian Eder, 14 years ago
implementation of classes Label and CPair in F5cData.* git-svn-id: file:///usr/local/Singular/svn/trunk@11957 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.5 KB
Line 
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
35Label::Label(int* expVec) 
36{
37  m_pExpVec       = expVec;
38  m_nShortExpVec  = computeShortExpVec(m_pExpVec);
39}
40
41Label::~Label() 
42{
43  delete &m_nShortExpVec;
44  delete [] m_pExpVec;
45}
46
47/*
48 * GETTER of class Label
49 */
50inline int* Label::getExpVec() 
51{
52  return m_pExpVec;
53}
54
55inline 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 */
68inline 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
118inline 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
Note: See TracBrowser for help on using the repository browser.