My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
factory
DegreePattern.cc
Go to the documentation of this file.
1
/*****************************************************************************\
2
* Computer Algebra System SINGULAR
3
\*****************************************************************************/
4
/** @file DegreePattern.cc
5
*
6
* This file provides functions for manipulating DegreePatterns
7
*
8
* @author Martin Lee
9
*
10
**/
11
/*****************************************************************************/
12
13
14
#include "config.h"
15
16
17
#include "
DegreePattern.h
"
18
#include "
cf_iter.h
"
19
#include "
templates/ftmpl_functions.h
"
20
#include "
gfops.h
"
21
#include "
cf_factory.h
"
22
23
24
DegreePattern::DegreePattern
(
const
CFList
&
l
)
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'
;
37
if
(
CFFactory::gettype
() ==
GaloisFieldDomain
)
38
{
39
d=
getGFDegree
();
40
cGFName=
gf_name
;
41
}
42
setCharacteristic
(0);
43
CanonicalForm
buf
= 1;
44
CFListIterator
k
=
l
;
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
63
setCharacteristic
(
p
);
64
}
65
}
66
67
68
void
DegreePattern::intersect
(
const
DegreePattern
& degPat)
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
}
104
105
void
DegreePattern::refine
()
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
}
148
DegreePattern.h
This file provides a class to handle degree patterns.
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition
canonicalform.cc:1896
degree
int degree(const CanonicalForm &f)
Definition
canonicalform.h:316
getGFDegree
int getGFDegree()
Definition
cf_char.cc:75
setCharacteristic
void FACTORY_PUBLIC setCharacteristic(int c)
Definition
cf_char.cc:28
CFListIterator
ListIterator< CanonicalForm > CFListIterator
Definition
canonicalform.h:396
CFList
List< CanonicalForm > CFList
Definition
canonicalform.h:395
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition
cf_char.cc:70
l
int l
Definition
cfEzgcd.cc:100
m
int m
Definition
cfEzgcd.cc:128
i
int i
Definition
cfEzgcd.cc:132
k
int k
Definition
cfEzgcd.cc:99
x
Variable x
Definition
cfModGcd.cc:4090
p
int p
Definition
cfModGcd.cc:4086
ASSERT
#define ASSERT(expression, message)
Definition
cf_assert.h:99
GaloisFieldDomain
#define GaloisFieldDomain
Definition
cf_defs.h:18
cf_factory.h
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
cf_iter.h
Iterators for CanonicalForm's.
CFFactory::gettype
static int gettype()
Definition
cf_factory.h:28
CFIterator
class to iterate through CanonicalForm's
Definition
cf_iter.h:44
CanonicalForm
factory's main class
Definition
canonicalform.h:86
DegreePattern::m_data
struct DegreePattern::Pattern * m_data
DegreePattern::find
int find(const int x) const
find an element x
Definition
DegreePattern.h:159
DegreePattern::intersect
void intersect(const DegreePattern °Pat)
intersect two degree patterns
Definition
DegreePattern.cc:68
DegreePattern::getLength
int getLength() const
getter
Definition
DegreePattern.h:86
DegreePattern::refine
void refine()
Refine a degree pattern. Assumes that (*this)[0]:= d is the degree of the poly to be factored....
Definition
DegreePattern.cc:105
DegreePattern::init
void init(int n)
initialise a DegreePattern
Definition
DegreePattern.h:60
DegreePattern::DegreePattern
DegreePattern()
default constructor
Definition
DegreePattern.h:117
Variable
factory's class for variables
Definition
factory.h:127
j
int j
Definition
facHensel.cc:110
ftmpl_functions.h
some useful template functions.
tmin
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
gf_name
VAR char gf_name
Definition
gfops.cc:52
gfops.h
Operations in GF, where GF is a finite field of size less than 2^16 represented by a root of Conway p...
length
static BOOLEAN length(leftv result, leftv arg)
Definition
interval.cc:257
NULL
#define NULL
Definition
omList.c:12
count
int status int void size_t count
Definition
si_signals.h:69
buf
int status int void * buf
Definition
si_signals.h:69
DegreePattern::Pattern
Definition
DegreePattern.h:35
Generated on
for My Project by
doxygen 1.17.0
for
Singular