My Project
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Private Member Functions | Private Attributes
DegreePattern Class Reference

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

#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() ){}
struct DegreePattern::Pattern * m_data

◆ 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" );
125 };
#define ASSERT(expression, message)
Definition: cf_assert.h:99
#define NULL
Definition: omList.c:12
int m_refCounter
reference counter
Definition: DegreePattern.h:36

◆ 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 }
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}
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int degree(const CanonicalForm &f)
int getGFDegree()
Definition: cf_char.cc:75
void FACTORY_PUBLIC setCharacteristic(int c)
Definition: cf_char.cc:28
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
Variable x
Definition: cfModGcd.cc:4082
int p
Definition: cfModGcd.cc:4078
#define GaloisFieldDomain
Definition: cf_defs.h:18
static int gettype()
Definition: cf_factory.h:28
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
factory's main class
Definition: canonicalform.h:86
int getLength() const
getter
Definition: DegreePattern.h:86
factory's class for variables
Definition: variable.h:33
int j
Definition: facHensel.cc:110
VAR char gf_name
Definition: gfops.cc:52
int status int void * buf
Definition: si_signals.h:59

◆ ~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 }
void release()
clear m_data
Definition: DegreePattern.h:48

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 }
int m_length
length of m_pattern
Definition: DegreePattern.h:37

◆ 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 }
int * m_pattern
some array containing the degree pattern
Definition: DegreePattern.h:38

◆ 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}
DegreePattern provides a functionality to create, intersect and refine degree patterns.
Definition: DegreePattern.h:32
int find(const int x) const
find an element x
void intersect(const DegreePattern &degPat)
intersect two degree patterns
void init(int n)
initialise a DegreePattern
Definition: DegreePattern.h:60
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
int status int void size_t count
Definition: si_signals.h:59

◆ 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;
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 }
int * getPattern() const
getter
Definition: DegreePattern.h:74
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592

◆ 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: