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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing
from jas import ZZ
from jas import QQ
from jas import CC
from jas import ZM
from jas import RF
from jas import startLog
from jas import terminate
# example for rational and complex numbers
#
#
zn = ZZ(7);
print "zn:", zn;
print "zn^2:", zn*zn;
print;
x = 10000000000000000000000000000000000000000000000000;
rn = QQ(2*x,4*x);
print "rn:", rn;
print "rn^2:", rn*rn;
print;
rn = QQ((6,4));
print "rn:", rn;
print "rn^2:", rn*rn;
print "1/rn: " + str(1/rn);
print;
c = CC();
print "c:", c;
c = c.one();
print "c:", c;
c = CC((2,),(3,));
print "c:", c;
print "c^5:", c**5 + c.one();
print;
c = CC( (2,),rn );
print "c: ", c;
print "1/c: " + str(1/c);
print;
zm = ZM(19,11);
print "zm: " + str(zm);
print "zm^2: " + str(zm*zm);
print "1/zm: " + str(1/zm);
#print "zm.ring: " + str(zm.ring.toScript());
print;
r = PolyRing(QQ(), "x,y", PolyRing.lex );
print "Ring: " + str(r);
print;
# sage like: with generators for the polynomial ring
#is automatic: [one,x,y] = r.gens();
zero = r.zero();
try:
f = RF(r);
except:
f = None;
print "f: " + str(f);
d = x**2 + 5 * x - 6;
f = RF(r,d);
print "f: " + str(f);
n = d*d + y + 1;
f = RF(r,d,n);
print "f: " + str(f);
print;
# beware not to mix expressions
f = f**2 - f;
print "f^2-f: " + str(f);
print;
f = f/f;
print "f/f: " + str(f);
f = RF(r,d,one);
print "f: " + str(f);
f = RF(r,zero);
print "f: " + str(f);
f = RF(r,d,y);
print "f: " + str(f);
print "one: " + str(f.one());
print "zero: " + str(f.zero());
print;
terminate();
#sys.exit();
|