line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::MVPoly::Parser;
|
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
|
|
880
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
545
|
use Math::MVPoly::Ideal;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
11
|
use Math::MVPoly::Polynomial;
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
3725
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub
|
12
|
|
|
|
|
|
|
new
|
13
|
|
|
|
|
|
|
{
|
14
|
1
|
|
|
1
|
1
|
73
|
my $self;
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
$self = {};
|
17
|
1
|
|
|
|
|
3
|
$self->{VARIABLES} = {};
|
18
|
1
|
|
|
|
|
3
|
$self->{STATUS} = {};
|
19
|
1
|
|
|
|
|
2
|
$self->{VERBOSE} = 0;
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
bless($self);
|
22
|
1
|
|
|
|
|
4
|
return $self;
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub
|
26
|
|
|
|
|
|
|
variables
|
27
|
|
|
|
|
|
|
{
|
28
|
153
|
|
|
153
|
1
|
173
|
my $self = shift;
|
29
|
153
|
50
|
|
|
|
313
|
if (@_) { $self->{VARIABLES} = shift }
|
|
0
|
|
|
|
|
0
|
|
30
|
153
|
|
|
|
|
269
|
return $self->{VARIABLES};
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub
|
34
|
|
|
|
|
|
|
status
|
35
|
|
|
|
|
|
|
{
|
36
|
188
|
|
|
188
|
1
|
210
|
my $self = shift;
|
37
|
188
|
100
|
|
|
|
382
|
if (@_) { $self->{STATUS} = shift }
|
|
50
|
|
|
|
|
88
|
|
38
|
188
|
|
|
|
|
551
|
return $self->{STATUS};
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub
|
42
|
|
|
|
|
|
|
verbose
|
43
|
|
|
|
|
|
|
{
|
44
|
17
|
|
|
17
|
0
|
21
|
my $self = shift;
|
45
|
17
|
50
|
|
|
|
34
|
if (@_) { $self->{VERBOSE} = shift }
|
|
0
|
|
|
|
|
0
|
|
46
|
17
|
|
|
|
|
60
|
return $self->{VERBOSE};
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub
|
50
|
|
|
|
|
|
|
statusIsValid
|
51
|
|
|
|
|
|
|
{
|
52
|
138
|
|
|
138
|
1
|
167
|
my $self = shift;
|
53
|
|
|
|
|
|
|
|
54
|
138
|
|
|
|
|
222
|
return ($self->status() == 0)
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub
|
58
|
|
|
|
|
|
|
statusToString
|
59
|
|
|
|
|
|
|
{
|
60
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
61
|
0
|
|
|
|
|
0
|
my $s;
|
62
|
|
|
|
|
|
|
my $status;
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
$status = $self->status();
|
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
0
|
if ($status eq 0)
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
67
|
|
|
|
|
|
|
{
|
68
|
0
|
|
|
|
|
0
|
$s = "Valid";
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
elsif ($status eq 1)
|
71
|
|
|
|
|
|
|
{
|
72
|
0
|
|
|
|
|
0
|
$s = "Syntax Error";
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
elsif ($status eq 2)
|
75
|
|
|
|
|
|
|
{
|
76
|
0
|
|
|
|
|
0
|
$s = "Variable Not Found";
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
elsif ($status eq 3)
|
79
|
|
|
|
|
|
|
{
|
80
|
0
|
|
|
|
|
0
|
$s = "Monomial Ordering Not Defined.";
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
elsif ($status eq 4)
|
83
|
|
|
|
|
|
|
{
|
84
|
0
|
|
|
|
|
0
|
$s = "Variable Ordering Not Defined.";
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
elsif ($status eq 5)
|
87
|
|
|
|
|
|
|
{
|
88
|
0
|
|
|
|
|
0
|
$s = "Attempt to use multi-variables under lex monomial ordering.";
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
elsif ($status eq 6)
|
91
|
|
|
|
|
|
|
{
|
92
|
0
|
|
|
|
|
0
|
$s = "Attempt to use lex monomial ordering with multi-variate polynomials.";
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
else
|
95
|
|
|
|
|
|
|
{
|
96
|
0
|
|
|
|
|
0
|
$s = $status;
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
return $s;
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub
|
103
|
|
|
|
|
|
|
toString
|
104
|
|
|
|
|
|
|
{
|
105
|
0
|
|
|
0
|
1
|
0
|
my $self = shift();
|
106
|
0
|
|
|
|
|
0
|
my $s;
|
107
|
|
|
|
|
|
|
my $myVars;
|
108
|
0
|
|
|
|
|
0
|
my $name;
|
109
|
0
|
|
|
|
|
0
|
my $r;
|
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
0
|
$myVars = $self->variables();
|
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
$s = "";
|
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
foreach $name (keys %$myVars)
|
116
|
|
|
|
|
|
|
{
|
117
|
0
|
|
|
|
|
0
|
$r = $self->varToString($name);
|
118
|
0
|
|
|
|
|
0
|
$s .= "$name = $r\n";
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
return $s;
|
122
|
|
|
|
|
|
|
}
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub
|
125
|
|
|
|
|
|
|
setVariable
|
126
|
|
|
|
|
|
|
{
|
127
|
30
|
|
|
30
|
1
|
41
|
my $self = shift;
|
128
|
30
|
|
|
|
|
41
|
my $var = shift;
|
129
|
30
|
|
|
|
|
36
|
my $val = shift;
|
130
|
30
|
|
|
|
|
1206
|
my $myVars;
|
131
|
|
|
|
|
|
|
|
132
|
30
|
|
|
|
|
57
|
$myVars = $self->variables();
|
133
|
30
|
|
|
|
|
108
|
$myVars->{$var} = $val;
|
134
|
|
|
|
|
|
|
}
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub
|
137
|
|
|
|
|
|
|
getVariable
|
138
|
|
|
|
|
|
|
{
|
139
|
64
|
|
|
64
|
1
|
76
|
my $self = shift;
|
140
|
64
|
|
|
|
|
72
|
my $var = shift;
|
141
|
64
|
|
|
|
|
80
|
my $val;
|
142
|
|
|
|
|
|
|
my $myVars;
|
143
|
|
|
|
|
|
|
|
144
|
64
|
|
|
|
|
113
|
$myVars = $self->variables();
|
145
|
|
|
|
|
|
|
|
146
|
64
|
|
|
|
|
105
|
$val = $myVars->{$var};
|
147
|
|
|
|
|
|
|
|
148
|
64
|
|
|
|
|
128
|
return $val;
|
149
|
|
|
|
|
|
|
}
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub
|
152
|
|
|
|
|
|
|
haveVariable
|
153
|
|
|
|
|
|
|
{
|
154
|
47
|
|
|
47
|
1
|
58
|
my $self = shift;
|
155
|
47
|
|
|
|
|
62
|
my $var = shift;
|
156
|
47
|
|
|
|
|
48
|
my $myVars;
|
157
|
|
|
|
|
|
|
my $flag;
|
158
|
|
|
|
|
|
|
|
159
|
47
|
|
|
|
|
91
|
$myVars = $self->variables();
|
160
|
|
|
|
|
|
|
|
161
|
47
|
|
|
|
|
62
|
$flag = 0;
|
162
|
|
|
|
|
|
|
|
163
|
47
|
100
|
|
|
|
120
|
if (exists($myVars->{$var}))
|
164
|
|
|
|
|
|
|
{
|
165
|
46
|
|
|
|
|
60
|
$flag = 1;
|
166
|
|
|
|
|
|
|
}
|
167
|
|
|
|
|
|
|
|
168
|
47
|
|
|
|
|
111
|
return $flag;
|
169
|
|
|
|
|
|
|
}
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub
|
172
|
|
|
|
|
|
|
printConstant
|
173
|
|
|
|
|
|
|
{
|
174
|
3
|
|
|
3
|
1
|
4
|
my $self = shift;
|
175
|
3
|
|
|
|
|
5
|
my $info = shift;
|
176
|
3
|
|
|
|
|
3
|
my $s;
|
177
|
|
|
|
|
|
|
|
178
|
3
|
|
|
|
|
6
|
$s = $$info[1];
|
179
|
|
|
|
|
|
|
|
180
|
3
|
50
|
|
|
|
12
|
if ($s =~ /^\"/)
|
181
|
|
|
|
|
|
|
{
|
182
|
3
|
|
|
|
|
12
|
$s =~ s/\"//g;
|
183
|
|
|
|
|
|
|
}
|
184
|
|
|
|
|
|
|
|
185
|
3
|
|
|
|
|
11
|
return $s;
|
186
|
|
|
|
|
|
|
}
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub
|
189
|
|
|
|
|
|
|
varToString
|
190
|
|
|
|
|
|
|
{
|
191
|
17
|
|
|
17
|
1
|
18
|
my $self = shift;
|
192
|
17
|
|
|
|
|
29
|
my $name = shift;
|
193
|
17
|
|
|
|
|
19
|
my $v;
|
194
|
|
|
|
|
|
|
my $i;
|
195
|
0
|
|
|
|
|
0
|
my $s;
|
196
|
|
|
|
|
|
|
|
197
|
17
|
|
|
|
|
21
|
$s = "";
|
198
|
|
|
|
|
|
|
|
199
|
17
|
50
|
|
|
|
40
|
if ($self->haveVariable($name))
|
200
|
|
|
|
|
|
|
{
|
201
|
17
|
|
|
|
|
36
|
$v = $self->getVariable($name);
|
202
|
|
|
|
|
|
|
|
203
|
17
|
50
|
|
|
|
45
|
if (ref($v))
|
|
|
0
|
|
|
|
|
|
204
|
|
|
|
|
|
|
{
|
205
|
17
|
|
|
|
|
41
|
$v->verbose($self->verbose());
|
206
|
17
|
|
|
|
|
60
|
$s .= $v->toString();
|
207
|
|
|
|
|
|
|
}
|
208
|
|
|
|
|
|
|
elsif (ref($v) eq "ARRAY")
|
209
|
|
|
|
|
|
|
{
|
210
|
0
|
|
|
|
|
0
|
for $i (0..$#$v)
|
211
|
|
|
|
|
|
|
{
|
212
|
0
|
0
|
|
|
|
0
|
if (ref($$v[$i]))
|
213
|
|
|
|
|
|
|
{
|
214
|
0
|
|
|
|
|
0
|
$$v[$i]->verbose($self->verbose());
|
215
|
0
|
|
|
|
|
0
|
$s .= $$v[$i]->toString();
|
216
|
|
|
|
|
|
|
}
|
217
|
|
|
|
|
|
|
else
|
218
|
|
|
|
|
|
|
{
|
219
|
0
|
|
|
|
|
0
|
$s .= $$v[$i];
|
220
|
|
|
|
|
|
|
}
|
221
|
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
0
|
if ($i < $#$v)
|
223
|
|
|
|
|
|
|
{
|
224
|
0
|
|
|
|
|
0
|
$s .= ", ";
|
225
|
|
|
|
|
|
|
}
|
226
|
|
|
|
|
|
|
}
|
227
|
|
|
|
|
|
|
}
|
228
|
|
|
|
|
|
|
else
|
229
|
|
|
|
|
|
|
{
|
230
|
0
|
|
|
|
|
0
|
$s .= $v;
|
231
|
|
|
|
|
|
|
}
|
232
|
|
|
|
|
|
|
}
|
233
|
|
|
|
|
|
|
else
|
234
|
|
|
|
|
|
|
{
|
235
|
0
|
|
|
|
|
0
|
$self->status(2);
|
236
|
|
|
|
|
|
|
}
|
237
|
|
|
|
|
|
|
|
238
|
17
|
|
|
|
|
146
|
return $s;
|
239
|
|
|
|
|
|
|
}
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub
|
242
|
|
|
|
|
|
|
printVariable
|
243
|
|
|
|
|
|
|
{
|
244
|
17
|
|
|
17
|
1
|
19
|
my $self = shift;
|
245
|
17
|
|
|
|
|
23
|
my $info = shift;
|
246
|
17
|
|
|
|
|
18
|
my $name;
|
247
|
|
|
|
|
|
|
my $s;
|
248
|
0
|
|
|
|
|
0
|
my $r;
|
249
|
|
|
|
|
|
|
|
250
|
17
|
|
|
|
|
21
|
$name = $$info[1];
|
251
|
|
|
|
|
|
|
|
252
|
17
|
|
|
|
|
41
|
$r = $self->varToString($name);
|
253
|
17
|
|
|
|
|
29
|
$s = "$name = $r";
|
254
|
|
|
|
|
|
|
|
255
|
17
|
|
|
|
|
35
|
return $s;
|
256
|
|
|
|
|
|
|
}
|
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub
|
259
|
|
|
|
|
|
|
printCommand
|
260
|
|
|
|
|
|
|
{
|
261
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
262
|
0
|
|
|
|
|
0
|
my $info = shift;
|
263
|
0
|
|
|
|
|
0
|
my $s;
|
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
0
|
$s = $self->doFunction($info);
|
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
0
|
return $s;
|
268
|
|
|
|
|
|
|
}
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub
|
271
|
|
|
|
|
|
|
doPrint
|
272
|
|
|
|
|
|
|
{
|
273
|
20
|
|
|
20
|
1
|
26
|
my $self = shift;
|
274
|
20
|
|
|
|
|
27
|
my $info = shift;
|
275
|
20
|
|
|
|
|
23
|
my $cmd_info;
|
276
|
|
|
|
|
|
|
my $type;
|
277
|
0
|
|
|
|
|
0
|
my $result;
|
278
|
|
|
|
|
|
|
|
279
|
20
|
|
|
|
|
37
|
$cmd_info = $self->getBlockInfo($$info[2]);
|
280
|
|
|
|
|
|
|
|
281
|
20
|
|
|
|
|
30
|
$type = $$cmd_info[0];
|
282
|
|
|
|
|
|
|
|
283
|
20
|
100
|
|
|
|
65
|
if ($type eq "const")
|
|
|
50
|
|
|
|
|
|
284
|
|
|
|
|
|
|
{
|
285
|
3
|
|
|
|
|
10
|
$result = $self->printConstant($cmd_info);
|
286
|
|
|
|
|
|
|
}
|
287
|
|
|
|
|
|
|
elsif ($type eq "variable")
|
288
|
|
|
|
|
|
|
{
|
289
|
17
|
|
|
|
|
41
|
$result = $self->printVariable($cmd_info);
|
290
|
|
|
|
|
|
|
}
|
291
|
|
|
|
|
|
|
else
|
292
|
|
|
|
|
|
|
{
|
293
|
0
|
|
|
|
|
0
|
$self->status(1);
|
294
|
|
|
|
|
|
|
}
|
295
|
|
|
|
|
|
|
|
296
|
20
|
50
|
|
|
|
42
|
if ($self->statusIsValid())
|
297
|
|
|
|
|
|
|
{
|
298
|
20
|
|
|
|
|
24
|
$result .= "\n";
|
299
|
|
|
|
|
|
|
}
|
300
|
|
|
|
|
|
|
|
301
|
20
|
|
|
|
|
58
|
return $result;
|
302
|
|
|
|
|
|
|
}
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub
|
305
|
|
|
|
|
|
|
doGBasis
|
306
|
|
|
|
|
|
|
{
|
307
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
308
|
0
|
|
|
|
|
0
|
my $info = shift;
|
309
|
0
|
|
|
|
|
0
|
my $r;
|
310
|
|
|
|
|
|
|
my @parts;
|
311
|
0
|
|
|
|
|
0
|
my $F;
|
312
|
0
|
|
|
|
|
0
|
my $list;
|
313
|
0
|
|
|
|
|
0
|
my $p;
|
314
|
0
|
|
|
|
|
0
|
my $v;
|
315
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
0
|
$F = Math::MVPoly::Ideal->new();
|
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
0
|
$list = [];
|
319
|
0
|
|
|
|
|
0
|
foreach $p (@$info[2..$#$info])
|
320
|
|
|
|
|
|
|
{
|
321
|
|
|
|
|
|
|
# TODO: get info about p to see if it is a variable or a polynomial expr.
|
322
|
0
|
|
|
|
|
0
|
$v = $self->getVariable($p);
|
323
|
0
|
|
|
|
|
0
|
push(@$list, $v);
|
324
|
|
|
|
|
|
|
}
|
325
|
0
|
|
|
|
|
0
|
$F->set($list);
|
326
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
0
|
$r = $F->getGBasis();
|
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
0
|
return $r;
|
330
|
|
|
|
|
|
|
}
|
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub
|
333
|
|
|
|
|
|
|
doSPoly
|
334
|
|
|
|
|
|
|
{
|
335
|
2
|
|
|
2
|
1
|
4
|
my $self = shift;
|
336
|
2
|
|
|
|
|
3
|
my $info = shift;
|
337
|
2
|
|
|
|
|
2
|
my $v1;
|
338
|
|
|
|
|
|
|
my $v2;
|
339
|
0
|
|
|
|
|
0
|
my $n1;
|
340
|
0
|
|
|
|
|
0
|
my $n2;
|
341
|
0
|
|
|
|
|
0
|
my $r;
|
342
|
|
|
|
|
|
|
|
343
|
2
|
|
|
|
|
4
|
$n1 = $$info[2];
|
344
|
2
|
|
|
|
|
3
|
$n2 = $$info[3];
|
345
|
|
|
|
|
|
|
|
346
|
2
|
|
|
|
|
10
|
$v1 = $self->getVariable($n1);
|
347
|
2
|
|
|
|
|
4
|
$v2 = $self->getVariable($n2);
|
348
|
|
|
|
|
|
|
|
349
|
2
|
|
|
|
|
9
|
$r = $v1->spoly($v2);
|
350
|
|
|
|
|
|
|
|
351
|
2
|
|
|
|
|
6
|
return $r;
|
352
|
|
|
|
|
|
|
}
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
sub
|
355
|
|
|
|
|
|
|
doMonLCM
|
356
|
|
|
|
|
|
|
{
|
357
|
2
|
|
|
2
|
1
|
19
|
my $self = shift;
|
358
|
2
|
|
|
|
|
4
|
my $info = shift;
|
359
|
2
|
|
|
|
|
2
|
my $v1;
|
360
|
|
|
|
|
|
|
my $v2;
|
361
|
0
|
|
|
|
|
0
|
my $n1;
|
362
|
0
|
|
|
|
|
0
|
my $n2;
|
363
|
0
|
|
|
|
|
0
|
my $r;
|
364
|
|
|
|
|
|
|
|
365
|
2
|
|
|
|
|
3
|
$n1 = $$info[2];
|
366
|
2
|
|
|
|
|
4
|
$n2 = $$info[3];
|
367
|
|
|
|
|
|
|
|
368
|
2
|
|
|
|
|
5
|
$v1 = $self->getVariable($n1);
|
369
|
2
|
|
|
|
|
6
|
$v2 = $self->getVariable($n2);
|
370
|
|
|
|
|
|
|
|
371
|
2
|
|
|
|
|
8
|
$v1 = $v1->getLT();
|
372
|
2
|
|
|
|
|
5
|
$v2 = $v2->getLT();
|
373
|
|
|
|
|
|
|
|
374
|
2
|
|
|
|
|
8
|
$r = $v1->getLCM($v2);
|
375
|
|
|
|
|
|
|
|
376
|
2
|
|
|
|
|
7
|
$v1 = Math::MVPoly::Polynomial->new();
|
377
|
2
|
|
|
|
|
23
|
$r = $v1->add($r);
|
378
|
|
|
|
|
|
|
|
379
|
2
|
|
|
|
|
8
|
return $r;
|
380
|
|
|
|
|
|
|
}
|
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub
|
383
|
|
|
|
|
|
|
doReduce
|
384
|
|
|
|
|
|
|
{
|
385
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
386
|
0
|
|
|
|
|
0
|
my $info = shift;
|
387
|
0
|
|
|
|
|
0
|
my $v1;
|
388
|
|
|
|
|
|
|
my $v2;
|
389
|
0
|
|
|
|
|
0
|
my $n1;
|
390
|
0
|
|
|
|
|
0
|
my $n2;
|
391
|
0
|
|
|
|
|
0
|
my $r;
|
392
|
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
0
|
$n1 = $$info[2];
|
394
|
0
|
|
|
|
|
0
|
$v1 = $self->getVariable($n1);
|
395
|
|
|
|
|
|
|
|
396
|
0
|
|
|
|
|
0
|
$v1->reduce();
|
397
|
|
|
|
|
|
|
}
|
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub
|
400
|
|
|
|
|
|
|
doGCD
|
401
|
|
|
|
|
|
|
{
|
402
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
403
|
1
|
|
|
|
|
2
|
my $info = shift;
|
404
|
1
|
|
|
|
|
1
|
my $v1;
|
405
|
|
|
|
|
|
|
my $v2;
|
406
|
0
|
|
|
|
|
0
|
my $n;
|
407
|
0
|
|
|
|
|
0
|
my $g;
|
408
|
|
|
|
|
|
|
|
409
|
1
|
|
|
|
|
2
|
$n = $$info[2];
|
410
|
1
|
|
|
|
|
3
|
$v1 = $self->getVariable($n);
|
411
|
|
|
|
|
|
|
|
412
|
1
|
|
|
|
|
4
|
foreach $n (@$info[3..$#$info])
|
413
|
|
|
|
|
|
|
{
|
414
|
1
|
|
|
|
|
3
|
$v2 = $self->getVariable($n);
|
415
|
1
|
|
|
|
|
4
|
$g = $v1->gcd($v2);
|
416
|
1
|
|
|
|
|
3
|
$v1 = $g;
|
417
|
|
|
|
|
|
|
}
|
418
|
|
|
|
|
|
|
|
419
|
1
|
|
|
|
|
3
|
return $g;
|
420
|
|
|
|
|
|
|
}
|
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub
|
423
|
|
|
|
|
|
|
doMult
|
424
|
|
|
|
|
|
|
{
|
425
|
1
|
|
|
1
|
1
|
4
|
my $self = shift;
|
426
|
1
|
|
|
|
|
1
|
my $info = shift;
|
427
|
1
|
|
|
|
|
2
|
my $v1;
|
428
|
|
|
|
|
|
|
my $v2;
|
429
|
0
|
|
|
|
|
0
|
my $n1;
|
430
|
0
|
|
|
|
|
0
|
my $n2;
|
431
|
0
|
|
|
|
|
0
|
my $r;
|
432
|
|
|
|
|
|
|
|
433
|
1
|
|
|
|
|
2
|
$n1 = $$info[2];
|
434
|
1
|
|
|
|
|
2
|
$n2 = $$info[3];
|
435
|
|
|
|
|
|
|
|
436
|
1
|
|
|
|
|
4
|
$v1 = $self->getVariable($n1);
|
437
|
1
|
|
|
|
|
3
|
$v2 = $self->getVariable($n2);
|
438
|
|
|
|
|
|
|
|
439
|
1
|
|
|
|
|
6
|
$r = $v1->mult($v2);
|
440
|
|
|
|
|
|
|
|
441
|
1
|
|
|
|
|
3
|
return $r;
|
442
|
|
|
|
|
|
|
}
|
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
sub
|
445
|
|
|
|
|
|
|
doQuo
|
446
|
|
|
|
|
|
|
{
|
447
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
448
|
1
|
|
|
|
|
1
|
my $info = shift;
|
449
|
1
|
|
|
|
|
3
|
my $v1;
|
450
|
|
|
|
|
|
|
my $v2;
|
451
|
0
|
|
|
|
|
0
|
my $n1;
|
452
|
0
|
|
|
|
|
0
|
my $n2;
|
453
|
0
|
|
|
|
|
0
|
my $r;
|
454
|
|
|
|
|
|
|
|
455
|
1
|
|
|
|
|
2
|
$n1 = $$info[2];
|
456
|
1
|
|
|
|
|
2
|
$n2 = $$info[3];
|
457
|
|
|
|
|
|
|
|
458
|
1
|
|
|
|
|
4
|
$v1 = $self->getVariable($n1);
|
459
|
1
|
|
|
|
|
3
|
$v2 = $self->getVariable($n2);
|
460
|
|
|
|
|
|
|
|
461
|
1
|
|
|
|
|
6
|
$r = $v1->divide($v2);
|
462
|
|
|
|
|
|
|
|
463
|
1
|
|
|
|
|
9
|
return $$r[0];
|
464
|
|
|
|
|
|
|
}
|
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
sub
|
467
|
|
|
|
|
|
|
doRem
|
468
|
|
|
|
|
|
|
{
|
469
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
470
|
1
|
|
|
|
|
2
|
my $info = shift;
|
471
|
1
|
|
|
|
|
2
|
my $v1;
|
472
|
|
|
|
|
|
|
my $v2;
|
473
|
0
|
|
|
|
|
0
|
my $n1;
|
474
|
0
|
|
|
|
|
0
|
my $n2;
|
475
|
0
|
|
|
|
|
0
|
my $r;
|
476
|
|
|
|
|
|
|
|
477
|
1
|
|
|
|
|
3
|
$n1 = $$info[2];
|
478
|
1
|
|
|
|
|
3
|
$n2 = $$info[3];
|
479
|
|
|
|
|
|
|
|
480
|
1
|
|
|
|
|
4
|
$v1 = $self->getVariable($n1);
|
481
|
1
|
|
|
|
|
42
|
$v2 = $self->getVariable($n2);
|
482
|
|
|
|
|
|
|
|
483
|
1
|
|
|
|
|
5
|
$r = $v1->divide($v2);
|
484
|
|
|
|
|
|
|
|
485
|
1
|
|
|
|
|
10
|
return $$r[1];
|
486
|
|
|
|
|
|
|
}
|
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
sub
|
489
|
|
|
|
|
|
|
doNormalf
|
490
|
|
|
|
|
|
|
{
|
491
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
492
|
0
|
|
|
|
|
0
|
my $info = shift;
|
493
|
0
|
|
|
|
|
0
|
my $v1;
|
494
|
|
|
|
|
|
|
my $v2;
|
495
|
0
|
|
|
|
|
0
|
my $n1;
|
496
|
0
|
|
|
|
|
0
|
my $n2;
|
497
|
0
|
|
|
|
|
0
|
my $r;
|
498
|
|
|
|
|
|
|
|
499
|
0
|
|
|
|
|
0
|
$n1 = $$info[2];
|
500
|
0
|
|
|
|
|
0
|
$n2 = $$info[3];
|
501
|
|
|
|
|
|
|
|
502
|
0
|
|
|
|
|
0
|
$v1 = $self->getVariable($n1);
|
503
|
0
|
|
|
|
|
0
|
$v2 = $self->getVariable($n2);
|
504
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
0
|
$r = $self->doDivide($info);
|
506
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
0
|
return $$r[$#$r];
|
508
|
|
|
|
|
|
|
}
|
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub
|
511
|
|
|
|
|
|
|
doDivide
|
512
|
|
|
|
|
|
|
{
|
513
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
514
|
0
|
|
|
|
|
0
|
my $info = shift;
|
515
|
0
|
|
|
|
|
0
|
my $v1;
|
516
|
|
|
|
|
|
|
my $v2;
|
517
|
0
|
|
|
|
|
0
|
my $v;
|
518
|
0
|
|
|
|
|
0
|
my $n;
|
519
|
0
|
|
|
|
|
0
|
my $n1;
|
520
|
0
|
|
|
|
|
0
|
my $n2;
|
521
|
0
|
|
|
|
|
0
|
my $r;
|
522
|
0
|
|
|
|
|
0
|
my $s;
|
523
|
0
|
|
|
|
|
0
|
my $arr;
|
524
|
0
|
|
|
|
|
0
|
my @parts;
|
525
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
0
|
$n1 = $$info[2];
|
527
|
0
|
|
|
|
|
0
|
$n2 = $$info[3];
|
528
|
|
|
|
|
|
|
|
529
|
0
|
|
|
|
|
0
|
$v1 = $self->getVariable($n1);
|
530
|
|
|
|
|
|
|
|
531
|
0
|
0
|
|
|
|
0
|
if ($#$info > 3)
|
532
|
|
|
|
|
|
|
{
|
533
|
0
|
|
|
|
|
0
|
$arr = [];
|
534
|
0
|
|
|
|
|
0
|
foreach $n (@$info[3..$#$info])
|
535
|
|
|
|
|
|
|
{
|
536
|
0
|
|
|
|
|
0
|
$v = $self->getVariable($n);
|
537
|
0
|
|
|
|
|
0
|
push(@$arr, $v);
|
538
|
|
|
|
|
|
|
}
|
539
|
|
|
|
|
|
|
|
540
|
0
|
|
|
|
|
0
|
$r = $v1->divide($arr);
|
541
|
|
|
|
|
|
|
}
|
542
|
|
|
|
|
|
|
else
|
543
|
|
|
|
|
|
|
{
|
544
|
0
|
|
|
|
|
0
|
$v2 = $self->getVariable($n2);
|
545
|
0
|
|
|
|
|
0
|
$r = $v1->divide($v2);
|
546
|
|
|
|
|
|
|
}
|
547
|
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
0
|
return $r;
|
549
|
|
|
|
|
|
|
}
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
sub
|
552
|
|
|
|
|
|
|
doSubtract
|
553
|
|
|
|
|
|
|
{
|
554
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
555
|
0
|
|
|
|
|
0
|
my $info = shift;
|
556
|
0
|
|
|
|
|
0
|
my $v1;
|
557
|
|
|
|
|
|
|
my $v2;
|
558
|
0
|
|
|
|
|
0
|
my $n1;
|
559
|
0
|
|
|
|
|
0
|
my $n2;
|
560
|
0
|
|
|
|
|
0
|
my $r;
|
561
|
|
|
|
|
|
|
|
562
|
0
|
|
|
|
|
0
|
$n1 = $$info[2];
|
563
|
0
|
|
|
|
|
0
|
$n2 = $$info[3];
|
564
|
|
|
|
|
|
|
|
565
|
0
|
|
|
|
|
0
|
$v1 = $self->getVariable($n1);
|
566
|
0
|
|
|
|
|
0
|
$v2 = $self->getVariable($n2);
|
567
|
|
|
|
|
|
|
|
568
|
0
|
|
|
|
|
0
|
$r = $v1->subtract($v2);
|
569
|
|
|
|
|
|
|
|
570
|
0
|
|
|
|
|
0
|
return $r;
|
571
|
|
|
|
|
|
|
}
|
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
sub
|
574
|
|
|
|
|
|
|
doAdd
|
575
|
|
|
|
|
|
|
{
|
576
|
1
|
|
|
1
|
1
|
3
|
my $self = shift;
|
577
|
1
|
|
|
|
|
2
|
my $info = shift;
|
578
|
1
|
|
|
|
|
2
|
my $v1;
|
579
|
|
|
|
|
|
|
my $v2;
|
580
|
0
|
|
|
|
|
0
|
my $n1;
|
581
|
0
|
|
|
|
|
0
|
my $n2;
|
582
|
0
|
|
|
|
|
0
|
my $r;
|
583
|
|
|
|
|
|
|
|
584
|
1
|
|
|
|
|
2
|
$n1 = $$info[2];
|
585
|
1
|
|
|
|
|
2
|
$n2 = $$info[3];
|
586
|
|
|
|
|
|
|
|
587
|
1
|
|
|
|
|
2
|
$v1 = $self->getVariable($n1);
|
588
|
1
|
|
|
|
|
3
|
$v2 = $self->getVariable($n2);
|
589
|
|
|
|
|
|
|
|
590
|
1
|
|
|
|
|
4
|
$r = $v1->add($v2);
|
591
|
|
|
|
|
|
|
|
592
|
1
|
|
|
|
|
3
|
return $r;
|
593
|
|
|
|
|
|
|
}
|
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
sub
|
596
|
|
|
|
|
|
|
doFunction
|
597
|
|
|
|
|
|
|
{
|
598
|
41
|
|
|
41
|
1
|
48
|
my $self = shift;
|
599
|
41
|
|
|
|
|
46
|
my $info = shift;
|
600
|
41
|
|
|
|
|
44
|
my $cmd;
|
601
|
|
|
|
|
|
|
my $result;
|
602
|
|
|
|
|
|
|
|
603
|
41
|
|
|
|
|
56
|
$cmd = $$info[1];
|
604
|
|
|
|
|
|
|
|
605
|
41
|
100
|
|
|
|
250
|
if ($cmd eq "print")
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
606
|
|
|
|
|
|
|
{
|
607
|
20
|
|
|
|
|
49
|
$result = $self->doPrint($info);
|
608
|
|
|
|
|
|
|
}
|
609
|
|
|
|
|
|
|
elsif ($cmd eq "monOrder")
|
610
|
|
|
|
|
|
|
{
|
611
|
7
|
|
|
|
|
19
|
$self->doMonomialOrdering($info);
|
612
|
|
|
|
|
|
|
}
|
613
|
|
|
|
|
|
|
elsif ($cmd eq "varOrder")
|
614
|
|
|
|
|
|
|
{
|
615
|
5
|
|
|
|
|
12
|
$self->doVariableOrdering($info);
|
616
|
|
|
|
|
|
|
}
|
617
|
|
|
|
|
|
|
elsif ($cmd eq "gbasis")
|
618
|
|
|
|
|
|
|
{
|
619
|
0
|
|
|
|
|
0
|
$result = $self->doGBasis($info);
|
620
|
|
|
|
|
|
|
}
|
621
|
|
|
|
|
|
|
elsif ($cmd eq "monLCM")
|
622
|
|
|
|
|
|
|
{
|
623
|
2
|
|
|
|
|
8
|
$result = $self->doMonLCM($info);
|
624
|
|
|
|
|
|
|
}
|
625
|
|
|
|
|
|
|
elsif ($cmd eq "spoly")
|
626
|
|
|
|
|
|
|
{
|
627
|
2
|
|
|
|
|
7
|
$result = $self->doSPoly($info);
|
628
|
|
|
|
|
|
|
}
|
629
|
|
|
|
|
|
|
elsif ($cmd eq "reduce")
|
630
|
|
|
|
|
|
|
{
|
631
|
0
|
|
|
|
|
0
|
$self->doReduce($info);
|
632
|
|
|
|
|
|
|
}
|
633
|
|
|
|
|
|
|
elsif ($cmd eq "gcd")
|
634
|
|
|
|
|
|
|
{
|
635
|
1
|
|
|
|
|
5
|
$result = $self->doGCD($info);
|
636
|
|
|
|
|
|
|
}
|
637
|
|
|
|
|
|
|
elsif ($cmd eq "mult")
|
638
|
|
|
|
|
|
|
{
|
639
|
1
|
|
|
|
|
5
|
$result = $self->doMult($info);
|
640
|
|
|
|
|
|
|
}
|
641
|
|
|
|
|
|
|
elsif ($cmd eq "add")
|
642
|
|
|
|
|
|
|
{
|
643
|
1
|
|
|
|
|
3
|
$result = $self->doAdd($info);
|
644
|
|
|
|
|
|
|
}
|
645
|
|
|
|
|
|
|
elsif ($cmd eq "subtract")
|
646
|
|
|
|
|
|
|
{
|
647
|
0
|
|
|
|
|
0
|
$result = $self->doSubtract($info);
|
648
|
|
|
|
|
|
|
}
|
649
|
|
|
|
|
|
|
elsif ($cmd eq "divide")
|
650
|
|
|
|
|
|
|
{
|
651
|
0
|
|
|
|
|
0
|
$result = $self->doDivide($info);
|
652
|
|
|
|
|
|
|
}
|
653
|
|
|
|
|
|
|
elsif ($cmd eq "normalf")
|
654
|
|
|
|
|
|
|
{
|
655
|
0
|
|
|
|
|
0
|
$result = $self->doNormalf($info);
|
656
|
|
|
|
|
|
|
}
|
657
|
|
|
|
|
|
|
elsif ($cmd eq "quo")
|
658
|
|
|
|
|
|
|
{
|
659
|
1
|
|
|
|
|
5
|
$result = $self->doQuo($info);
|
660
|
|
|
|
|
|
|
}
|
661
|
|
|
|
|
|
|
elsif ($cmd eq "rem")
|
662
|
|
|
|
|
|
|
{
|
663
|
1
|
|
|
|
|
5
|
$result = $self->doRem($info);
|
664
|
|
|
|
|
|
|
}
|
665
|
|
|
|
|
|
|
elsif ($cmd eq "value")
|
666
|
|
|
|
|
|
|
{
|
667
|
0
|
|
|
|
|
0
|
$result = $self->doValue($info);
|
668
|
|
|
|
|
|
|
}
|
669
|
|
|
|
|
|
|
elsif ($cmd eq "verbose")
|
670
|
|
|
|
|
|
|
{
|
671
|
0
|
|
|
|
|
0
|
$self->doVerbose($info);
|
672
|
|
|
|
|
|
|
}
|
673
|
|
|
|
|
|
|
elsif ($cmd eq "state")
|
674
|
|
|
|
|
|
|
{
|
675
|
0
|
|
|
|
|
0
|
$result = $self->doState($info);
|
676
|
|
|
|
|
|
|
}
|
677
|
|
|
|
|
|
|
else
|
678
|
|
|
|
|
|
|
{
|
679
|
0
|
|
|
|
|
0
|
$self->status(1);
|
680
|
|
|
|
|
|
|
}
|
681
|
|
|
|
|
|
|
|
682
|
41
|
|
|
|
|
88
|
return $result;
|
683
|
|
|
|
|
|
|
}
|
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
sub
|
686
|
|
|
|
|
|
|
doMonomialOrdering
|
687
|
|
|
|
|
|
|
{
|
688
|
7
|
|
|
7
|
1
|
7
|
my $self = shift;
|
689
|
7
|
|
|
|
|
10
|
my $info = shift;
|
690
|
7
|
|
|
|
|
12
|
my $monOrder;
|
691
|
|
|
|
|
|
|
my $vars;
|
692
|
0
|
|
|
|
|
0
|
my $v;
|
693
|
0
|
|
|
|
|
0
|
my $varOrder;
|
694
|
|
|
|
|
|
|
|
695
|
7
|
|
|
|
|
12
|
$monOrder = $$info[2];
|
696
|
7
|
|
|
|
|
15
|
$monOrder =~ s/\W//g;
|
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
# do some sanity checking
|
700
|
|
|
|
|
|
|
|
701
|
7
|
100
|
|
|
|
15
|
if ($self->haveVariableOrdering())
|
702
|
|
|
|
|
|
|
{
|
703
|
6
|
|
|
|
|
16
|
$varOrder = $self->getVariable("varOrder");
|
704
|
|
|
|
|
|
|
|
705
|
6
|
50
|
33
|
|
|
23
|
if ($monOrder eq "tdeg" && $#$varOrder > 1)
|
706
|
|
|
|
|
|
|
{
|
707
|
0
|
|
|
|
|
0
|
$self->status(6);
|
708
|
0
|
|
|
|
|
0
|
return;
|
709
|
|
|
|
|
|
|
}
|
710
|
|
|
|
|
|
|
}
|
711
|
|
|
|
|
|
|
|
712
|
7
|
50
|
66
|
|
|
62
|
if ($monOrder eq "tdeg" ||
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
713
|
|
|
|
|
|
|
$monOrder eq "grlex" ||
|
714
|
|
|
|
|
|
|
$monOrder eq "grevlex" ||
|
715
|
|
|
|
|
|
|
$monOrder eq "lex")
|
716
|
|
|
|
|
|
|
{
|
717
|
7
|
|
|
|
|
19
|
$self->setVariable("monOrder", $monOrder);
|
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
# iterate through the variables and see if there are any
|
720
|
|
|
|
|
|
|
# polynomials. Once found, change the monomial ordering
|
721
|
|
|
|
|
|
|
# and apply the change
|
722
|
|
|
|
|
|
|
|
723
|
7
|
|
|
|
|
13
|
$vars = $self->variables();
|
724
|
7
|
|
|
|
|
20
|
foreach $v (values %$vars)
|
725
|
|
|
|
|
|
|
{
|
726
|
42
|
100
|
100
|
|
|
261
|
if (ref($v) ne "" and
|
|
|
|
66
|
|
|
|
|
727
|
|
|
|
|
|
|
ref($v) ne "ARRAY" and
|
728
|
|
|
|
|
|
|
ref($v) ne "HASH")
|
729
|
|
|
|
|
|
|
{
|
730
|
29
|
|
|
|
|
91
|
$v->monOrder($monOrder);
|
731
|
29
|
|
|
|
|
69
|
$v->applyOrder();
|
732
|
|
|
|
|
|
|
}
|
733
|
|
|
|
|
|
|
}
|
734
|
|
|
|
|
|
|
}
|
735
|
|
|
|
|
|
|
else
|
736
|
|
|
|
|
|
|
{
|
737
|
0
|
|
|
|
|
0
|
$self->status(1);
|
738
|
|
|
|
|
|
|
}
|
739
|
|
|
|
|
|
|
}
|
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
sub
|
742
|
|
|
|
|
|
|
haveMonomialOrdering
|
743
|
|
|
|
|
|
|
{
|
744
|
14
|
|
|
14
|
1
|
17
|
my $self = shift;
|
745
|
14
|
|
|
|
|
19
|
my $flag;
|
746
|
|
|
|
|
|
|
|
747
|
14
|
|
|
|
|
15
|
$flag = 0;
|
748
|
|
|
|
|
|
|
|
749
|
14
|
50
|
|
|
|
29
|
if ($self->haveVariable("monOrder"))
|
750
|
|
|
|
|
|
|
{
|
751
|
14
|
|
|
|
|
20
|
$flag = 1;
|
752
|
|
|
|
|
|
|
}
|
753
|
|
|
|
|
|
|
|
754
|
14
|
|
|
|
|
39
|
return $flag;
|
755
|
|
|
|
|
|
|
}
|
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
sub
|
758
|
|
|
|
|
|
|
doVariableOrdering
|
759
|
|
|
|
|
|
|
{
|
760
|
5
|
|
|
5
|
1
|
8
|
my $self = shift;
|
761
|
5
|
|
|
|
|
7
|
my $info = shift;
|
762
|
5
|
|
|
|
|
5
|
my @vars;
|
763
|
|
|
|
|
|
|
my $varOrder;
|
764
|
0
|
|
|
|
|
0
|
my $vars;
|
765
|
0
|
|
|
|
|
0
|
my $v;
|
766
|
|
|
|
|
|
|
|
767
|
5
|
|
|
|
|
25
|
@vars = (@$info[2..$#$info]);
|
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
# do some sanity checking
|
770
|
|
|
|
|
|
|
|
771
|
5
|
50
|
33
|
|
|
12
|
if (! $self->haveMonomialOrdering())
|
|
|
50
|
|
|
|
|
|
772
|
|
|
|
|
|
|
{
|
773
|
0
|
|
|
|
|
0
|
$self->status(3);
|
774
|
0
|
|
|
|
|
0
|
return;
|
775
|
|
|
|
|
|
|
}
|
776
|
|
|
|
|
|
|
elsif ($self->getVariable("monOrder") eq "tdeg" && $#vars > 1)
|
777
|
|
|
|
|
|
|
{
|
778
|
0
|
|
|
|
|
0
|
$self->status(5);
|
779
|
0
|
|
|
|
|
0
|
return;
|
780
|
|
|
|
|
|
|
}
|
781
|
|
|
|
|
|
|
|
782
|
5
|
50
|
|
|
|
15
|
if ($#vars >= 0)
|
783
|
|
|
|
|
|
|
{
|
784
|
5
|
|
|
|
|
12
|
$varOrder = [@vars];
|
785
|
5
|
|
|
|
|
11
|
$self->setVariable("varOrder", $varOrder);
|
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
# iterate through the variables and see if there are any
|
788
|
|
|
|
|
|
|
# polynomials. Once found, change the variable ordering
|
789
|
|
|
|
|
|
|
|
790
|
5
|
|
|
|
|
12
|
$vars = $self->variables();
|
791
|
5
|
|
|
|
|
13
|
foreach $v (values %$vars)
|
792
|
|
|
|
|
|
|
{
|
793
|
29
|
100
|
100
|
|
|
176
|
if (ref($v) ne "" and
|
|
|
|
66
|
|
|
|
|
794
|
|
|
|
|
|
|
ref($v) ne "ARRAY" and
|
795
|
|
|
|
|
|
|
ref($v) ne "HASH")
|
796
|
|
|
|
|
|
|
{
|
797
|
19
|
|
|
|
|
70
|
$v->varOrder([@vars]);
|
798
|
19
|
|
|
|
|
302
|
$varOrder = $v->varOrder();
|
799
|
|
|
|
|
|
|
}
|
800
|
|
|
|
|
|
|
}
|
801
|
|
|
|
|
|
|
}
|
802
|
|
|
|
|
|
|
else
|
803
|
|
|
|
|
|
|
{
|
804
|
0
|
|
|
|
|
0
|
$self->status(1);
|
805
|
|
|
|
|
|
|
}
|
806
|
|
|
|
|
|
|
}
|
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
sub
|
809
|
|
|
|
|
|
|
haveVariableOrdering
|
810
|
|
|
|
|
|
|
{
|
811
|
16
|
|
|
16
|
1
|
20
|
my $self = shift;
|
812
|
16
|
|
|
|
|
17
|
my $flag;
|
813
|
|
|
|
|
|
|
|
814
|
16
|
|
|
|
|
23
|
$flag = 0;
|
815
|
|
|
|
|
|
|
|
816
|
16
|
100
|
|
|
|
30
|
if ($self->haveVariable("varOrder"))
|
817
|
|
|
|
|
|
|
{
|
818
|
15
|
|
|
|
|
95
|
$flag = 1;
|
819
|
|
|
|
|
|
|
}
|
820
|
|
|
|
|
|
|
|
821
|
16
|
|
|
|
|
40
|
return $flag;
|
822
|
|
|
|
|
|
|
}
|
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
sub
|
825
|
|
|
|
|
|
|
doVerbose
|
826
|
|
|
|
|
|
|
{
|
827
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
828
|
0
|
|
|
|
|
0
|
my $info = shift;
|
829
|
0
|
|
|
|
|
0
|
my $v;
|
830
|
|
|
|
|
|
|
my $p;
|
831
|
0
|
|
|
|
|
0
|
my $vars;
|
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
# toggle the verbose status
|
834
|
0
|
|
|
|
|
0
|
$v = ! $self->verbose();
|
835
|
0
|
|
|
|
|
0
|
$self->verbose($v);
|
836
|
|
|
|
|
|
|
|
837
|
0
|
|
|
|
|
0
|
$vars = $self->variables();
|
838
|
0
|
|
|
|
|
0
|
foreach $p (values %$vars)
|
839
|
|
|
|
|
|
|
{
|
840
|
0
|
0
|
|
|
|
0
|
if (ref($p))
|
841
|
|
|
|
|
|
|
{
|
842
|
0
|
|
|
|
|
0
|
$p->verbose($v);
|
843
|
|
|
|
|
|
|
}
|
844
|
|
|
|
|
|
|
}
|
845
|
|
|
|
|
|
|
}
|
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
sub
|
848
|
|
|
|
|
|
|
doState
|
849
|
|
|
|
|
|
|
{
|
850
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
851
|
0
|
|
|
|
|
0
|
my $s;
|
852
|
|
|
|
|
|
|
|
853
|
0
|
|
|
|
|
0
|
$s = "\nState:\n\n";
|
854
|
0
|
|
|
|
|
0
|
$s .= $self->toString();
|
855
|
|
|
|
|
|
|
|
856
|
0
|
|
|
|
|
0
|
return $s;
|
857
|
|
|
|
|
|
|
}
|
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
sub
|
860
|
|
|
|
|
|
|
doValue
|
861
|
|
|
|
|
|
|
{
|
862
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
863
|
0
|
|
|
|
|
0
|
my $info = shift;
|
864
|
0
|
|
|
|
|
0
|
my $v1;
|
865
|
|
|
|
|
|
|
my $n1;
|
866
|
0
|
|
|
|
|
0
|
my $r;
|
867
|
|
|
|
|
|
|
|
868
|
0
|
|
|
|
|
0
|
$n1 = $$info[2];
|
869
|
|
|
|
|
|
|
|
870
|
0
|
0
|
|
|
|
0
|
if ($self->haveVariable($n1))
|
871
|
|
|
|
|
|
|
{
|
872
|
0
|
|
|
|
|
0
|
$v1 = $self->getVariable($n1);
|
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
# tell the object to copy itself - go go magic polymorphism!
|
875
|
0
|
|
|
|
|
0
|
$r = $v1->new();
|
876
|
0
|
|
|
|
|
0
|
$r->copy($v1);
|
877
|
|
|
|
|
|
|
}
|
878
|
|
|
|
|
|
|
else
|
879
|
|
|
|
|
|
|
{
|
880
|
0
|
|
|
|
|
0
|
$self->status(2);
|
881
|
0
|
|
|
|
|
0
|
$r = "";
|
882
|
|
|
|
|
|
|
}
|
883
|
|
|
|
|
|
|
|
884
|
0
|
|
|
|
|
0
|
return $r;
|
885
|
|
|
|
|
|
|
}
|
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
sub
|
889
|
|
|
|
|
|
|
doAssignment
|
890
|
|
|
|
|
|
|
{
|
891
|
18
|
|
|
18
|
1
|
20
|
my $self = shift;
|
892
|
18
|
|
|
|
|
21
|
my $info = shift;
|
893
|
18
|
|
|
|
|
21
|
my $cmd;
|
894
|
|
|
|
|
|
|
my $var;
|
895
|
0
|
|
|
|
|
0
|
my $set_info;
|
896
|
0
|
|
|
|
|
0
|
my $type;
|
897
|
0
|
|
|
|
|
0
|
my $v;
|
898
|
0
|
|
|
|
|
0
|
my $p;
|
899
|
0
|
|
|
|
|
0
|
my $monOrder;
|
900
|
0
|
|
|
|
|
0
|
my $varOrder;
|
901
|
|
|
|
|
|
|
|
902
|
18
|
|
|
|
|
26
|
$var = $$info[1];
|
903
|
18
|
|
|
|
|
23
|
$cmd = $$info[2];
|
904
|
|
|
|
|
|
|
|
905
|
18
|
|
|
|
|
32
|
$set_info = $self->getBlockInfo($cmd);
|
906
|
|
|
|
|
|
|
|
907
|
18
|
|
|
|
|
30
|
$type = $$set_info[0];
|
908
|
|
|
|
|
|
|
|
909
|
18
|
100
|
|
|
|
38
|
if ($type eq "function")
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
910
|
|
|
|
|
|
|
{
|
911
|
9
|
|
|
|
|
24
|
$v = $self->doFunction($set_info);
|
912
|
|
|
|
|
|
|
}
|
913
|
|
|
|
|
|
|
elsif ($type eq "variable")
|
914
|
|
|
|
|
|
|
{
|
915
|
9
|
50
|
|
|
|
17
|
if (! $self->haveMonomialOrdering())
|
916
|
|
|
|
|
|
|
{
|
917
|
0
|
|
|
|
|
0
|
$self->status(3);
|
918
|
|
|
|
|
|
|
}
|
919
|
9
|
50
|
|
|
|
20
|
if (! $self->haveVariableOrdering())
|
920
|
|
|
|
|
|
|
{
|
921
|
0
|
|
|
|
|
0
|
$self->status(4);
|
922
|
|
|
|
|
|
|
}
|
923
|
|
|
|
|
|
|
else
|
924
|
|
|
|
|
|
|
{
|
925
|
9
|
|
|
|
|
18
|
$monOrder = $self->getVariable("monOrder");
|
926
|
9
|
|
|
|
|
21
|
$varOrder = $self->getVariable("varOrder");
|
927
|
9
|
|
|
|
|
38
|
$v = Math::MVPoly::Polynomial->new();
|
928
|
9
|
|
|
|
|
27
|
$v->monOrder($monOrder);
|
929
|
9
|
|
|
|
|
47
|
$v->varOrder([@$varOrder]);
|
930
|
9
|
|
|
|
|
30
|
$v->fromString($$set_info[1]);
|
931
|
|
|
|
|
|
|
}
|
932
|
|
|
|
|
|
|
}
|
933
|
|
|
|
|
|
|
elsif ($type eq "const")
|
934
|
|
|
|
|
|
|
{
|
935
|
0
|
|
|
|
|
0
|
$v = $$set_info[1];
|
936
|
|
|
|
|
|
|
}
|
937
|
|
|
|
|
|
|
else
|
938
|
|
|
|
|
|
|
{
|
939
|
0
|
|
|
|
|
0
|
$self->status(1);
|
940
|
|
|
|
|
|
|
}
|
941
|
|
|
|
|
|
|
|
942
|
18
|
50
|
|
|
|
54
|
if ($self->statusIsValid())
|
943
|
|
|
|
|
|
|
{
|
944
|
18
|
|
|
|
|
45
|
$self->setVariable($var, $v);
|
945
|
|
|
|
|
|
|
}
|
946
|
|
|
|
|
|
|
}
|
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
sub
|
949
|
|
|
|
|
|
|
getBlockInfo
|
950
|
|
|
|
|
|
|
{
|
951
|
88
|
|
|
88
|
1
|
109
|
my $self = shift;
|
952
|
88
|
|
|
|
|
119
|
my $s = shift;
|
953
|
88
|
|
|
|
|
89
|
my $type;
|
954
|
|
|
|
|
|
|
my $info;
|
955
|
0
|
|
|
|
|
0
|
my $op;
|
956
|
0
|
|
|
|
|
0
|
my @parts;
|
957
|
0
|
|
|
|
|
0
|
my @args;
|
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
# remove the white space
|
960
|
88
|
|
|
|
|
132
|
$s =~ s/\s//g;
|
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
# 'deduce' the nature of $s
|
963
|
88
|
100
|
|
|
|
2162
|
if ($s =~ /\=/g)
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
964
|
|
|
|
|
|
|
{
|
965
|
18
|
|
|
|
|
62
|
@parts = split(/[\=]/, $s);
|
966
|
18
|
|
|
|
|
45
|
$info = ["assignment", @parts];
|
967
|
|
|
|
|
|
|
}
|
968
|
|
|
|
|
|
|
elsif ($s =~ /[\(\)]/g)
|
969
|
|
|
|
|
|
|
{
|
970
|
41
|
|
|
|
|
158
|
@parts = split(/[\(\)]/, $s);
|
971
|
41
|
|
|
|
|
95
|
@args = split(/[\,]/, $parts[1]);
|
972
|
41
|
|
|
|
|
342
|
$info = ["function", $parts[0], @args];
|
973
|
|
|
|
|
|
|
}
|
974
|
|
|
|
|
|
|
elsif ($s =~ /[\"\'\,]/g)
|
975
|
|
|
|
|
|
|
{
|
976
|
3
|
|
|
|
|
8
|
$info = ["const", $s];
|
977
|
|
|
|
|
|
|
}
|
978
|
|
|
|
|
|
|
else
|
979
|
|
|
|
|
|
|
{
|
980
|
26
|
|
|
|
|
57
|
$info = ["variable", $s];
|
981
|
|
|
|
|
|
|
}
|
982
|
|
|
|
|
|
|
|
983
|
88
|
|
|
|
|
233
|
return $info;
|
984
|
|
|
|
|
|
|
}
|
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
sub
|
987
|
|
|
|
|
|
|
parseLine
|
988
|
|
|
|
|
|
|
{
|
989
|
50
|
|
|
50
|
1
|
63
|
my $self = shift;
|
990
|
50
|
|
|
|
|
72
|
my $s = shift;
|
991
|
50
|
|
|
|
|
75
|
my $lnum = shift;
|
992
|
50
|
|
|
|
|
58
|
my $info;
|
993
|
|
|
|
|
|
|
my $type;
|
994
|
0
|
|
|
|
|
0
|
my $result;
|
995
|
|
|
|
|
|
|
|
996
|
50
|
|
|
|
|
92
|
$self->status(0);
|
997
|
|
|
|
|
|
|
|
998
|
50
|
|
|
|
|
93
|
$info = $self->getBlockInfo($s);
|
999
|
50
|
|
|
|
|
78
|
$type = $$info[0];
|
1000
|
|
|
|
|
|
|
|
1001
|
50
|
100
|
|
|
|
112
|
if ($type eq "function")
|
|
|
50
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
{
|
1003
|
32
|
|
|
|
|
65
|
$result = $self->doFunction($info);
|
1004
|
|
|
|
|
|
|
}
|
1005
|
|
|
|
|
|
|
elsif ($type eq "assignment")
|
1006
|
|
|
|
|
|
|
{
|
1007
|
18
|
|
|
|
|
38
|
$self->doAssignment($info);
|
1008
|
|
|
|
|
|
|
}
|
1009
|
|
|
|
|
|
|
else
|
1010
|
|
|
|
|
|
|
{
|
1011
|
0
|
|
|
|
|
0
|
$self->status(1);
|
1012
|
|
|
|
|
|
|
}
|
1013
|
|
|
|
|
|
|
|
1014
|
50
|
50
|
|
|
|
160
|
if (! $self->statusIsValid())
|
1015
|
|
|
|
|
|
|
{
|
1016
|
0
|
|
|
|
|
0
|
$result = $self->statusToString()." @ $lnum\n";
|
1017
|
|
|
|
|
|
|
}
|
1018
|
|
|
|
|
|
|
|
1019
|
50
|
|
|
|
|
160
|
return $result;
|
1020
|
|
|
|
|
|
|
}
|
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
sub
|
1023
|
|
|
|
|
|
|
parseCGICmdString
|
1024
|
|
|
|
|
|
|
{
|
1025
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
1026
|
0
|
|
|
|
|
0
|
my $s = shift;
|
1027
|
0
|
|
|
|
|
0
|
my $r;
|
1028
|
|
|
|
|
|
|
|
1029
|
0
|
|
|
|
|
0
|
$r = $self->parseCmdString($s);
|
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
# replace the EOL with the HTML EOL
|
1032
|
0
|
|
|
|
|
0
|
$r =~ s/\n/ \n/g;
|
1033
|
|
|
|
|
|
|
|
1034
|
0
|
|
|
|
|
0
|
return $r;
|
1035
|
|
|
|
|
|
|
}
|
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
sub
|
1038
|
|
|
|
|
|
|
parseCmdString
|
1039
|
|
|
|
|
|
|
{
|
1040
|
5
|
|
|
5
|
1
|
10
|
my $self = shift;
|
1041
|
5
|
|
|
|
|
10
|
my $s = shift;
|
1042
|
5
|
|
|
|
|
7
|
my $i;
|
1043
|
|
|
|
|
|
|
my @line;
|
1044
|
0
|
|
|
|
|
0
|
my $l;
|
1045
|
0
|
|
|
|
|
0
|
my $r;
|
1046
|
0
|
|
|
|
|
0
|
my $outs;
|
1047
|
|
|
|
|
|
|
|
1048
|
5
|
|
|
|
|
38
|
@line = split(";",$s);
|
1049
|
|
|
|
|
|
|
|
1050
|
5
|
|
|
|
|
10
|
$outs = "";
|
1051
|
|
|
|
|
|
|
|
1052
|
5
|
|
|
|
|
16
|
foreach $i (0..$#line)
|
1053
|
|
|
|
|
|
|
{
|
1054
|
57
|
|
|
|
|
94
|
$_ = $line[$i];
|
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
# remove white space
|
1057
|
57
|
|
|
|
|
295
|
s/\s//g;
|
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
# skip comment lines
|
1060
|
57
|
100
|
100
|
|
|
295
|
if (/^ *\#/ || length($_) == 0)
|
1061
|
|
|
|
|
|
|
{
|
1062
|
7
|
|
|
|
|
17
|
next;
|
1063
|
|
|
|
|
|
|
}
|
1064
|
|
|
|
|
|
|
|
1065
|
50
|
|
|
|
|
122
|
$outs .= $self->parseLine($_,$i);
|
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
# leave if there was an error
|
1068
|
50
|
50
|
|
|
|
97
|
last if (! $self->statusIsValid());
|
1069
|
|
|
|
|
|
|
}
|
1070
|
|
|
|
|
|
|
|
1071
|
5
|
|
|
|
|
25
|
return $outs;
|
1072
|
|
|
|
|
|
|
}
|
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
sub
|
1075
|
|
|
|
|
|
|
parseFile
|
1076
|
|
|
|
|
|
|
{
|
1077
|
5
|
|
|
5
|
1
|
569
|
my $self = shift;
|
1078
|
5
|
|
|
|
|
64
|
my $fname = shift;
|
1079
|
5
|
|
|
|
|
7
|
my $s;
|
1080
|
|
|
|
|
|
|
my $r;
|
1081
|
|
|
|
|
|
|
|
1082
|
5
|
|
|
|
|
307
|
open(INFILE, $fname);
|
1083
|
|
|
|
|
|
|
|
1084
|
5
|
|
|
|
|
11
|
$s = "";
|
1085
|
|
|
|
|
|
|
|
1086
|
5
|
|
|
|
|
140
|
while()
|
1087
|
|
|
|
|
|
|
{
|
1088
|
57
|
|
|
|
|
156
|
$s .= $_;
|
1089
|
|
|
|
|
|
|
}
|
1090
|
|
|
|
|
|
|
|
1091
|
5
|
|
|
|
|
126
|
close(INFILE);
|
1092
|
|
|
|
|
|
|
|
1093
|
5
|
|
|
|
|
20
|
$r = $self->parseCmdString($s);
|
1094
|
|
|
|
|
|
|
|
1095
|
5
|
|
|
|
|
21
|
return $r;
|
1096
|
|
|
|
|
|
|
}
|
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
1;
|
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
__END__
|