line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::MVPoly::Ideal;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (c) 1998 by Brian Guarraci. All rights reserved.
|
4
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
5
|
|
|
|
|
|
|
# under the same terms as Perl itself.
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
837
|
use Math::MVPoly::Polynomial;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
874
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub
|
11
|
|
|
|
|
|
|
new
|
12
|
|
|
|
|
|
|
{
|
13
|
0
|
|
|
0
|
1
|
|
my $self;
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
$self = {};
|
16
|
0
|
|
|
|
|
|
$self->{POLYNOMIALS} = [];
|
17
|
0
|
|
|
|
|
|
$self->{VERBOSE} = 0;
|
18
|
0
|
|
|
|
|
|
bless($self);
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
return $self;
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub
|
24
|
|
|
|
|
|
|
copy
|
25
|
|
|
|
|
|
|
{
|
26
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
27
|
0
|
|
|
|
|
|
my $p = shift;
|
28
|
0
|
|
|
|
|
|
my $polynomials;
|
29
|
|
|
|
|
|
|
my $copy_polynomials;
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$polynomials = $p->polynomials();
|
32
|
0
|
|
|
|
|
|
$copy_polynomials = [@$polynomials];
|
33
|
0
|
|
|
|
|
|
$self->polynomials($copy_polynomials);
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub
|
37
|
|
|
|
|
|
|
polynomials
|
38
|
|
|
|
|
|
|
{
|
39
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
40
|
0
|
0
|
|
|
|
|
if (@_)
|
41
|
|
|
|
|
|
|
{
|
42
|
0
|
|
|
|
|
|
$self->{POLYNOMIALS} = shift;
|
43
|
|
|
|
|
|
|
}
|
44
|
0
|
|
|
|
|
|
return($self->{POLYNOMIALS});
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub
|
48
|
|
|
|
|
|
|
verbose
|
49
|
|
|
|
|
|
|
{
|
50
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
51
|
0
|
0
|
|
|
|
|
if (@_)
|
52
|
|
|
|
|
|
|
{
|
53
|
0
|
|
|
|
|
|
$self->{VERBOSE} = shift;
|
54
|
|
|
|
|
|
|
}
|
55
|
0
|
|
|
|
|
|
return($self->{VERBOSE});
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub
|
59
|
|
|
|
|
|
|
varOrder
|
60
|
|
|
|
|
|
|
{
|
61
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
62
|
0
|
|
|
|
|
|
my $varOrder = shift;
|
63
|
0
|
|
|
|
|
|
my $p;
|
64
|
|
|
|
|
|
|
my $polynomials;
|
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
foreach $p (@$polynomials)
|
69
|
|
|
|
|
|
|
{
|
70
|
0
|
|
|
|
|
|
$p->varOrder($varOrder);
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub
|
75
|
|
|
|
|
|
|
monOrder
|
76
|
|
|
|
|
|
|
{
|
77
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
78
|
0
|
|
|
|
|
|
my $monOrder = shift;
|
79
|
0
|
|
|
|
|
|
my $p;
|
80
|
|
|
|
|
|
|
my $polynomials;
|
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
foreach $p (@$polynomials)
|
85
|
|
|
|
|
|
|
{
|
86
|
0
|
|
|
|
|
|
$p->monOrder($monOrder);
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub
|
91
|
|
|
|
|
|
|
applyOrder
|
92
|
|
|
|
|
|
|
{
|
93
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
94
|
0
|
|
|
|
|
|
my $p;
|
95
|
|
|
|
|
|
|
my $polynomials;
|
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
foreach $p (@$polynomials)
|
100
|
|
|
|
|
|
|
{
|
101
|
0
|
|
|
|
|
|
$p->applyOrder();
|
102
|
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub
|
106
|
|
|
|
|
|
|
appendPolynomial
|
107
|
|
|
|
|
|
|
{
|
108
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
109
|
0
|
|
|
|
|
|
my $p = shift;
|
110
|
0
|
|
|
|
|
|
my $polynomials;
|
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
push(@$polynomials, $p);
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub
|
118
|
|
|
|
|
|
|
toString
|
119
|
|
|
|
|
|
|
{
|
120
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
121
|
0
|
|
|
|
|
|
my $s;
|
122
|
|
|
|
|
|
|
my $p;
|
123
|
0
|
|
|
|
|
|
my $polynomials;
|
124
|
0
|
|
|
|
|
|
my $i;
|
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$s = "";
|
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
foreach $i (0..$#$polynomials)
|
131
|
|
|
|
|
|
|
{
|
132
|
0
|
|
|
|
|
|
$p = $$polynomials[$i];
|
133
|
0
|
|
|
|
|
|
$p->verbose($self->verbose());
|
134
|
0
|
|
|
|
|
|
$s .= $p->toString();
|
135
|
0
|
0
|
|
|
|
|
if ($i < $#$polynomials)
|
136
|
|
|
|
|
|
|
{
|
137
|
0
|
|
|
|
|
|
$s .= ", ";
|
138
|
|
|
|
|
|
|
}
|
139
|
|
|
|
|
|
|
}
|
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return $s;
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub
|
145
|
|
|
|
|
|
|
set
|
146
|
|
|
|
|
|
|
{
|
147
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
148
|
0
|
|
|
|
|
|
my $list = shift;
|
149
|
0
|
|
|
|
|
|
my $p;
|
150
|
|
|
|
|
|
|
my $q;
|
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
foreach $p (@$list)
|
153
|
|
|
|
|
|
|
{
|
154
|
0
|
|
|
|
|
|
$q = Math::MVPoly::Polynomial->new();
|
155
|
0
|
|
|
|
|
|
$q->copy($p);
|
156
|
0
|
|
|
|
|
|
$self->appendPolynomial($q);
|
157
|
|
|
|
|
|
|
}
|
158
|
|
|
|
|
|
|
}
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub
|
161
|
|
|
|
|
|
|
getSize
|
162
|
|
|
|
|
|
|
{
|
163
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
164
|
0
|
|
|
|
|
|
my $size;
|
165
|
|
|
|
|
|
|
my $polynomials;
|
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$size = $#$polynomials;
|
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
return $size;
|
172
|
|
|
|
|
|
|
}
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub
|
175
|
|
|
|
|
|
|
getPolynomial
|
176
|
|
|
|
|
|
|
{
|
177
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
178
|
0
|
|
|
|
|
|
my $i = shift;
|
179
|
0
|
|
|
|
|
|
my $polynomials;
|
180
|
|
|
|
|
|
|
my $p;
|
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
$polynomials = $self->polynomials();
|
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
$p = $$polynomials[$i];
|
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
return $p;
|
187
|
|
|
|
|
|
|
}
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub
|
190
|
|
|
|
|
|
|
getGBasis
|
191
|
|
|
|
|
|
|
{
|
192
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
193
|
0
|
|
|
|
|
|
my $G;
|
194
|
|
|
|
|
|
|
my $GP;
|
195
|
0
|
|
|
|
|
|
my $changed;
|
196
|
0
|
|
|
|
|
|
my $s;
|
197
|
0
|
|
|
|
|
|
my $q;
|
198
|
0
|
|
|
|
|
|
my $p;
|
199
|
0
|
|
|
|
|
|
my $r;
|
200
|
0
|
|
|
|
|
|
my $i;
|
201
|
0
|
|
|
|
|
|
my $j;
|
202
|
0
|
|
|
|
|
|
my $div_results;
|
203
|
0
|
|
|
|
|
|
my $rem;
|
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
$GP = Math::MVPoly::Ideal->new();
|
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$G = Math::MVPoly::Ideal->new();
|
208
|
0
|
|
|
|
|
|
$G->copy($self);
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
do
|
212
|
0
|
|
|
|
|
|
{
|
213
|
0
|
|
|
|
|
|
$changed = 0;
|
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
$GP->copy($G);
|
216
|
0
|
|
|
|
|
|
$s = $GP->getSize();
|
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
foreach $i (0..($s-1))
|
219
|
|
|
|
|
|
|
{
|
220
|
0
|
|
|
|
|
|
foreach $j (($i+1)..$s)
|
221
|
|
|
|
|
|
|
{
|
222
|
0
|
|
|
|
|
|
$p = $G->getPolynomial($i);
|
223
|
0
|
|
|
|
|
|
$q = $G->getPolynomial($j);
|
224
|
0
|
|
|
|
|
|
$r = $p->spoly($q);
|
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
$div_results = $r->divide($GP->polynomials());
|
227
|
0
|
|
|
|
|
|
$rem = $$div_results[$#$div_results];
|
228
|
|
|
|
|
|
|
|
229
|
0
|
0
|
|
|
|
|
if ($rem->isNotZero())
|
230
|
|
|
|
|
|
|
{
|
231
|
0
|
|
|
|
|
|
$G->appendPolynomial($rem);
|
232
|
0
|
|
|
|
|
|
$changed = 1;
|
233
|
|
|
|
|
|
|
}
|
234
|
|
|
|
|
|
|
}
|
235
|
|
|
|
|
|
|
}
|
236
|
|
|
|
|
|
|
}
|
237
|
|
|
|
|
|
|
while($changed);
|
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $G;
|
240
|
|
|
|
|
|
|
}
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
1;
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__END__
|