Esempio n. 1
0
#f = f1**2 * f2 * f3;
f = f1 * f2 * f3;
#f = f1 * f2;
#f = f1 * f3;
#f = f2 * f3;
#f = f3;

#f = f**3;

print "f = ", f;
print;

#startLog();

t = System.currentTimeMillis();
R = r.factors(f);
t = System.currentTimeMillis() - t;
#print "R = ", R;
#print "complex factor time =", t, "milliseconds";

g = one;
for h, i in R.iteritems():
    print "h**i = "+  str(h) + "**" + str(i);
    h = h**i;
    g = g*h;
#print "g = ", g;

if cmp(f,g) == 0:
    print "complex factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
    print "complex factor time =", t, "milliseconds,", "isFactors(f,g): ",  cmp(f,g);
Esempio n. 2
0
#f = x**3 - x**2 + x - 1;

#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;

#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
#f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
#f = x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8;

print "f = ", f;
print;

startLog();

t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";

g = one;
for h, i in G.iteritems():
    print "h**i = (", h, ")**" + str(i);
    h = h**i;
    g = g*h;
#print "g = ", g;

if cmp(f,g) == 0:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): ",  cmp(f,g);
# f = x**6 + x**5 + x**4 + x**3 + x**2 + x + 1;
# f = x**2 - i;
# f = x**3 - i;
# f = x**2 + 1;
# f = x**5 - 1;
# f = x**4 + x**3 + x**2 + x + (1,);
# f = ( x**2 - i - 1 ) * ( x**2 + i + 1 );
f = (x ** 2 - i) * (x ** 2 + i + 1)

print "f = ", f
print

# startLog();

t = System.currentTimeMillis()
G = r.factors(f)
t = System.currentTimeMillis() - t
# print "G = ", G;
# print "factor time =", t, "milliseconds";

f2 = one
for h, i in G.iteritems():
    print "h**i = (", h, ")**" + str(i)
    h = h ** i
    f2 = f2 * h
# print "f2 = ", f2;
print

if cmp(f, f2) == 0:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): true"
else:
Esempio n. 4
0
# jython examples for jas.
# $Id$
#

import operator
from jas import PolyRing, QQ
from jas import startLog, terminate

# simple factorization example

r = PolyRing( QQ(), "x,y,z", PolyRing.lex); # or PolyRing.grad
print "PolyRing: " + str(r);
print;

p = (x+y+z)**11*(x+1)**5*(y+z)**3;
#print "p: " + str(p);
#print;

#startLog();
f = r.factors( p );
print "factors: " + ", ".join( [ str(k) + "**" + str(v) for k,v in f.items() ] );
print;

mp = reduce(operator.mul, [ k**v for k,v in f.items() ] );
#print str(mp);
print "p == mp: " + str(p == mp);
print;

startLog();
terminate();
#f = ( y**2 - 2 );
#f = ( y**2 - x );
#f = ( w2 * y**2 - 1 );
#f = ( y**2 - 1/x );
#f = ( y**2 - (1,2) );
#f = ( y**2 - 1/x ) * ( y**2 - (1,2) );

print "f = ", f;
print;

#sys.exit();

startLog();

t = System.currentTimeMillis();
G = Yr.factors(f);
t = System.currentTimeMillis() - t;
#print "G = ", G;
#print "factor time =", t, "milliseconds";

#sys.exit();

print "f    = ", f;
g = one;
for h, i in G.iteritems():
    if i > 1:
        print "h**i = ", h, "**" + str(i);
    else:
        print "h    = ", h;
    h = h**i;
    g = g*h;
Esempio n. 6
0
# f = ( y**2 - 2 );
# f = ( y**2 - x );
# f = ( w2 * y**2 - 1 );
# f = ( y**2 - 1/x );
# f = ( y**2 - (1,2) );
# f = ( y**2 - 1/x ) * ( y**2 - (1,2) );

print "f = ", f
print

# sys.exit();

startLog()

t = System.currentTimeMillis()
G = Yr.factors(f)
t = System.currentTimeMillis() - t
# print "G = ", G;
# print "factor time =", t, "milliseconds";

# sys.exit();

print "f    = ", f
g = one
for h, i in G.iteritems():
    if i > 1:
        print "h**i = ", h, "**" + str(i)
    else:
        print "h    = ", h
    h = h ** i
    g = g * h
Esempio n. 7
0
print "i     = " + str(i);
print "w2    = " + str(w2);
print "x     = " + str(x);
print;

#sys.exit();

f = ( x**2 + 1 ) * ( x**2 - 2 );

print "f = ", f;
print;

startLog();

t = System.currentTimeMillis();
G = Qiw2.factors(f);
t = System.currentTimeMillis() - t;
#print "G = ", G;
#print "factor time =", t, "milliseconds";

g = one;
for h, i in G.iteritems():
    print "h**i = (", h, ")**" + str(i);
    h = h**i;
    g = g*h;
#print "g = ", g;

if cmp(f,g) == 0:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): ",  cmp(f,g);
Esempio n. 8
0
print "one   = " + str(one);
print "i     = " + str(i);
print "x     = " + str(x);


#f = x**7 - 1;

f = x**6 + x**5 + x**4 + x**3 + x**2 + x + 1;

print "f = ", f;
print;

startLog();

t = System.currentTimeMillis();
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", str(len(G));
#print "factor time =", t, "milliseconds";

## f2 = one;
## for h, i in G.iteritems():
##     print "h**i = (", h, ")**" + str(i);
##     h = h**i;
##     f2 = f2*h;
#print "f2 = ", f2;
print;

## if cmp(f,f2) == 0:
##     print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
## else:
[one, i, x] = r.gens()
print "one   = " + str(one)
print "i     = " + str(i)
print "x     = " + str(x)

#f = x**7 - 1;

f = x**6 + x**5 + x**4 + x**3 + x**2 + x + 1

print "f = ", f
print

startLog()

t = System.currentTimeMillis()
G = r.factors(f)
t = System.currentTimeMillis() - t
print "#G = ", str(len(G))
#print "factor time =", t, "milliseconds";

## f2 = one;
## for h, i in G.iteritems():
##     print "h**i = (", h, ")**" + str(i);
##     h = h**i;
##     f2 = f2*h;
#print "f2 = ", f2;
print

## if cmp(f,f2) == 0:
##     print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
## else:
Esempio n. 10
0
# $Id$
#

import operator
from jas import PolyRing, QQ
from jas import startLog, terminate

# simple factorization example

r = PolyRing(QQ(), "x,y,z", PolyRing.lex)
# or PolyRing.grad
print "PolyRing: " + str(r)
print

p = (x + y + z)**11 * (x + 1)**5 * (y + z)**3
#print "p: " + str(p);
#print;

#startLog();
f = r.factors(p)
print "factors: " + ", ".join([str(k) + "**" + str(v) for k, v in f.items()])
print

mp = reduce(operator.mul, [k**v for k, v in f.items()])
#print str(mp);
print "p == mp: " + str(p == mp)
print

startLog()
terminate()
Esempio n. 11
0
print "i     = " + str(i)
print "w2    = " + str(w2)
print "x     = " + str(x)
print

#sys.exit();

f = (x**2 + 1) * (x**2 - 2)

print "f = ", f
print

startLog()

t = System.currentTimeMillis()
G = Qiw2.factors(f)
t = System.currentTimeMillis() - t
#print "G = ", G;
#print "factor time =", t, "milliseconds";

g = one
for h, i in G.iteritems():
    print "h**i = (", h, ")**" + str(i)
    h = h**i
    g = g * h
#print "g = ", g;
print

if cmp(f, g) == 0:
    print "factor time =", t, "milliseconds,", "isFactors(f,g): true"
else:
Esempio n. 12
0
from jas import PolyRing, AN, QQ, ZZ, terminate


# multiple algebraic field extensions

print "------- multiple algebraic field extensions QQ(alpha)(beta)(gamma)(delta) ---------";
r = PolyRing(QQ(),"alpha",PolyRing.lex);
print "r     = " + str(r);
e,a = r.gens();
print "e     = " + str(e);
print "a     = " + str(a);

ap = a**5 - a + 1;
print "ap    = " + str(ap);
x = r.factors(ap); 
print "x     = " + str( [ str(p)+"**"+str(e)+"," for (p,e) in x.iteritems() ] );
qs2 = AN(ap,0,len(x)==1); # and e==1
print "qs2   = " + str(qs2.factory());
one,alpha = qs2.gens();
print "one   = " + str(one);
print "alpha = " + str(alpha);

b = alpha**2 - 1;
print "b     = " + str(b);
c = 1 / b;
print "c     = " + str(c);
print "b*c   = " + str(b*c);
print

ar = PolyRing(qs2,"beta",PolyRing.lex);