My Project  debian-1:4.1.1-p2+ds-4
Data Structures | Public Member Functions | Private Member Functions | Private Attributes
DegreePattern Class Reference

#include "factory/DegreePattern.h"

Data Structures

struct  Pattern
 

Public Member Functions

int getLength () const
 getter More...
 
int operator[] (const int index) const
 operator [] More...
 
int & operator[] (const int index)
 operator [] More...
 
 DegreePattern ()
 default constructor More...
 
 DegreePattern (const DegreePattern &degPat)
 copy constructor More...
 
 DegreePattern (const CFList &l)
 construct a degree pattern from a list of (univariate) polys More...
 
DegreePatternoperator= (const DegreePattern &degPat)
 assignment More...
 
 ~DegreePattern ()
 destructor More...
 
int find (const int x) const
 find an element x More...
 
void intersect (const DegreePattern &degPat)
 intersect two degree patterns More...
 
void refine ()
 Refine a degree pattern. Assumes that (*this)[0]:= d is the degree of the poly to be factored. Now for every other entry a there should be some entry b such that a+b= d. Elements which do not satisfy this relation are removed. More...
 

Private Member Functions

void release ()
 clear m_data More...
 
void init (int n)
 initialise a DegreePattern More...
 
int * getPattern () const
 getter More...
 

Private Attributes

struct DegreePattern::Patternm_data
 

Detailed Description

DegreePattern provides a functionality to create, intersect and refine degree patterns.

Definition at line 31 of file DegreePattern.h.

Constructor & Destructor Documentation

◆ DegreePattern() [1/3]

DegreePattern::DegreePattern ( )
inline

default constructor

Definition at line 117 of file DegreePattern.h.

117 : m_data( new Pattern() ){}

◆ DegreePattern() [2/3]

DegreePattern::DegreePattern ( const DegreePattern degPat)
inline

copy constructor

Parameters
[in]degPatsome degree pattern

Definition at line 120 of file DegreePattern.h.

121  : m_data( degPat.m_data )
122  {
123  ASSERT( degPat.m_data != NULL, "non-null pointer expected" );
124  m_data->m_refCounter++;
125  };

◆ DegreePattern() [3/3]

DegreePattern::DegreePattern ( const CFList l)

construct a degree pattern from a list of (univariate) polys

Parameters
[in]lsome list of (univariate) polys

Definition at line 24 of file DegreePattern.cc.

25 {
26  m_data = NULL;
27 
28  if (l.length() == 0)
29  m_data = new Pattern();
30  else
31  {
32 
33  Variable x= Variable (1);
34  int p= getCharacteristic();
35  int d= 0;
36  char cGFName= 'Z';
38  {
39  d= getGFDegree();
40  cGFName= gf_name;
41  }
43  CanonicalForm buf= 1;
45  for (int i= 0; i < l.length(); i++, k++)
46  buf *= (power (x, degree (k.getItem(), x)) + 1);
47 
48  int j= 0;
49  for (CFIterator i= buf; i.hasTerms(); i++, j++)
50  ;
51 
52  ASSERT ( j > 1, "j > 1 expected" );
53 
54  m_data = new Pattern( j - 1 );
55 
56  int i= 0;
57  for (CFIterator m = buf; i < getLength(); i++, m++)
58  (*this) [i]= m.exp();
59 
60  if (d > 1)
61  setCharacteristic (p, d, cGFName);
62  else
64  }
65 }

◆ ~DegreePattern()

DegreePattern::~DegreePattern ( )
inline

destructor

Definition at line 148 of file DegreePattern.h.

149  {
150  ASSERT( m_data != NULL, "non-null pointer expected" );
151  if( (--m_data->m_refCounter) < 1 )
152  release();
153  }

Member Function Documentation

◆ find()

int DegreePattern::find ( const int  x) const
inline

find an element x

Returns
find returns the index + 1 of x, if x is an element of the degree pattern, 0 otherwise
Parameters
[in]xsome int

Definition at line 159 of file DegreePattern.h.

161  {
162  if (getLength() == 0) return 0;
163  for (int i= 0; i < getLength(); i++)
164  if ((*this)[i] == x) return i + 1;
165  return 0;
166  };

◆ getLength()

int DegreePattern::getLength ( ) const
inline

getter

Returns
getLength returns the length of the degree pattern

Definition at line 86 of file DegreePattern.h.

87  {
88  ASSERT( m_data != NULL, "non-null pointer expected" );
89  return m_data->m_length;
90  }

◆ getPattern()

int* DegreePattern::getPattern ( ) const
inlineprivate

getter

Returns
getPattern returns a degree pattern

Definition at line 74 of file DegreePattern.h.

75  {
76  ASSERT( m_data != NULL, "non-null pointer expected" );
77  ASSERT( m_data->m_pattern != NULL, "non-null pointer expected" );
78  return m_data->m_pattern;
79  }

◆ init()

void DegreePattern::init ( int  n)
inlineprivate

initialise a DegreePattern

Definition at line 60 of file DegreePattern.h.

61  {
62  ASSERT ( m_data != NULL, "non-null pointer expected" );
63  ASSERT( m_data->m_refCounter > 0, "ref count > 0 expected" );
64 
65  if( (--m_data->m_refCounter) < 1 )
66  release();
67 
68  m_data = new Pattern(n);
69  }

◆ intersect()

void DegreePattern::intersect ( const DegreePattern degPat)

intersect two degree patterns

Parameters
[in]degPatsome degree pattern

Definition at line 68 of file DegreePattern.cc.

69 {
70  if (degPat.getLength() < getLength())
71  {
72  DegreePattern bufDeg= *this;
73  *this= degPat;
74  return (*this).intersect (bufDeg);
75  }
76 
77  int count= 0;
78  int length= tmin (getLength(), degPat.getLength());
79  int* buf= new int [length];
80  for (int i= 0; i < length; i++)
81  {
82  if (degPat.find ((*this)[i]))
83  {
84  buf[i]= (*this)[i];
85  count++;
86  }
87  else
88  buf[i]= -1;
89  }
90  ASSERT ( count > 0, "count > 0 expected" );
91 
92  init (count);
93  count= 0;
94  for (int i= 0; i < length; i++)
95  {
96  if (buf[i] != -1)
97  {
98  (*this) [count]= buf[i];
99  count++;
100  }
101  }
102  delete[] buf;
103 }

◆ operator=()

DegreePattern& DegreePattern::operator= ( const DegreePattern degPat)
inline

assignment

Parameters
[in]degPatsome degree pattern

Definition at line 132 of file DegreePattern.h.

135  {
136  ASSERT( m_data != NULL, "non-null pointer expected" );
137  ASSERT( degPat.m_data != NULL, "non-null pointer expected" );
138  if( m_data != degPat.m_data )
139  {
140  m_data = degPat.m_data;
141  m_data->m_refCounter++;
142  }
143 
144  return *this;
145  }

◆ operator[]() [1/2]

int& DegreePattern::operator[] ( const int  index)
inline

operator []

Returns
operator[] sets the element at index
Parameters
[in]indexsome int >= 0, < getLength()

Definition at line 107 of file DegreePattern.h.

109  {
110  ASSERT( m_data != NULL, "non-null pointer expected" );
111  ASSERT( index >= 0 && index < getLength(), "bad index" );
112  ASSERT( getPattern() != NULL, "non-null pointer expected" );
113  return getPattern()[index];
114  }

◆ operator[]() [2/2]

int DegreePattern::operator[] ( const int  index) const
inline

operator []

Returns
operator[] returns the element at index
Parameters
[in]indexsome int >= 0, < getLength()

Definition at line 95 of file DegreePattern.h.

97  {
98  ASSERT( m_data != NULL, "non-null pointer expected" );
99  ASSERT( index >= 0 && index < getLength(), "bad index" );
100  ASSERT( getPattern() != NULL, "non-null pointer expected" );
101  return getPattern()[index];
102  }

◆ refine()

void DegreePattern::refine ( )

Refine a degree pattern. Assumes that (*this)[0]:= d is the degree of the poly to be factored. Now for every other entry a there should be some entry b such that a+b= d. Elements which do not satisfy this relation are removed.

Definition at line 105 of file DegreePattern.cc.

106 {
107  if (getLength() <= 1)
108  return;
109  int count= 0;
110  int* buf= new int [getLength()];
111  int d= (*this) [0];
112  int pos;
113  for (int i= 0; i < getLength(); i++)
114  buf[i]= -1;
115  for (int i= 1; i < getLength(); i++)
116  {
117  pos= (*this).find (d - (*this)[i]);
118  if (pos)
119  {
120  buf[i]= (*this)[i];
121  count++;
122  }
123  }
124  buf[0]= d;
125  count++;
126  if (count == getLength())
127  {
128  delete [] buf;
129  return;
130  }
131  int length= getLength();
132 
133  ASSERT ( count > 0, "count > 0 expected" );
134  init (count);
135  count= 0;
136  for (int i= 0; i < length; i++)
137  {
138  if (buf[i] != -1)
139  {
140  (*this)[count]= buf[i];
141  count++;
142  }
143  }
144 
145  delete[] buf;
146  return;
147 }

◆ release()

void DegreePattern::release ( )
inlineprivate

clear m_data

Definition at line 48 of file DegreePattern.h.

49  {
50  ASSERT ( m_data != NULL, "non-null pointer expected");
51  ASSERT ( m_data->m_refCounter == 0, "ref count of 0 expected");
52  if( m_data->m_pattern != NULL )
53  delete[] m_data->m_pattern;
55 
56  delete m_data;
57  m_data = NULL;
58  }

Field Documentation

◆ m_data

struct DegreePattern::Pattern* DegreePattern::m_data
private

The documentation for this class was generated from the following files:
j
int j
Definition: facHensel.cc:105
k
int k
Definition: cfEzgcd.cc:92
CFIterator
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
x
Variable x
Definition: cfModGcd.cc:4023
DegreePattern::Pattern::m_pattern
int * m_pattern
some array containing the degree pattern
Definition: DegreePattern.h:38
DegreePattern
Definition: DegreePattern.h:31
CFFactory::gettype
static int gettype()
Definition: cf_factory.h:28
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: canonicalform.cc:1837
length
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
DegreePattern::init
void init(int n)
initialise a DegreePattern
Definition: DegreePattern.h:60
DegreePattern::Pattern::m_refCounter
int m_refCounter
reference counter
Definition: DegreePattern.h:36
gf_name
char gf_name
Definition: gfops.cc:52
getCharacteristic
int getCharacteristic()
Definition: cf_char.cc:51
CanonicalForm
factory's main class
Definition: canonicalform.h:77
GaloisFieldDomain
#define GaloisFieldDomain
Definition: cf_defs.h:22
i
int i
Definition: cfEzgcd.cc:125
ASSERT
#define ASSERT(expression, message)
Definition: cf_assert.h:99
buf
int status int void * buf
Definition: si_signals.h:58
DegreePattern::intersect
void intersect(const DegreePattern &degPat)
intersect two degree patterns
Definition: DegreePattern.cc:68
DegreePattern::release
void release()
clear m_data
Definition: DegreePattern.h:48
setCharacteristic
void setCharacteristic(int c)
Definition: cf_char.cc:23
DegreePattern::getPattern
int * getPattern() const
getter
Definition: DegreePattern.h:74
tmin
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
getGFDegree
int getGFDegree()
Definition: cf_char.cc:56
DegreePattern::getLength
int getLength() const
getter
Definition: DegreePattern.h:86
Variable
factory's class for variables
Definition: factory.h:117
m
int m
Definition: cfEzgcd.cc:121
NULL
#define NULL
Definition: omList.c:9
l
int l
Definition: cfEzgcd.cc:93
DegreePattern::Pattern::m_length
int m_length
length of m_pattern
Definition: DegreePattern.h:37
p
int p
Definition: cfModGcd.cc:4019
count
int status int void size_t count
Definition: si_signals.h:58
DegreePattern::find
int find(const int x) const
find an element x
Definition: DegreePattern.h:159
index
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:585
degree
int degree(const CanonicalForm &f)
Definition: canonicalform.h:309
DegreePattern::m_data
struct DegreePattern::Pattern * m_data
ListIterator
Definition: ftmpl_list.h:17