File: polypower.py

package info (click to toggle)
jas 2.7.200-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,732 kB
  • sloc: java: 164,370; python: 14,882; ruby: 14,509; xml: 583; makefile: 545; sh: 349
file content (70 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# jython examples for jas.
# $Id$
#

from java.lang import System
from java.lang import Integer

from jas import PolyRing, SolvPolyRing, ZZ, QQ, GF, ZM

# sparse polynomial powers

#r = Ring( "Mod 1152921504606846883 (x,y,z) G" );
#r = Ring( "Rat(x,y,z) G" );
#r = Ring( "C(x,y,z) G" );
#r = Ring( "Z(x,y,z) L" );
r = PolyRing( ZZ(), "(x,y,z)", PolyRing.lex );
#r = SolvPolyRing( ZZ(), "(x,y,z)", PolyRing.lex );

print "Ring: " + str(r);
print;

ps = """
( 
 ( 1 + x^2147483647 + y^2147483647 + z^2147483647 )
 ( 1 + x + y + z )
 ( 10000000001 + 10000000001 x + 10000000001 y + 10000000001 z )
) 
""";

f = r.ideal( ps );
print "Ideal: " + str(f);
print;

pset = f.pset;
print "pset:", pset;
print;

plist = pset.list;
print "plist:", plist;
print;

#p = plist[1];
p = plist[0];
#p = plist[2];
print "p:", p;
print;

q = p;
for i in range(1,20): 
    q = q.multiply(p);

print "q:", q.length();
print;

q1 = q.sum( r.ring.getONE() );
#print "q1:", q1;
print "q1:", q1.length();
print;

t = System.currentTimeMillis();
q2 = q.multiply(q1);
t = System.currentTimeMillis() - t;

print "q2:", q2.length();
print "t:",t;
print;


print "Integer.MAX_VALUE = ", Integer.MAX_VALUE;