def sum(self,other): '''Compute the sum of this and the ideal. ''' s = jas.application.Ideal(self.pset); t = jas.application.Ideal(other.pset); N = s.sum( t ); return Ideal(self.ring,"",N.getList());
def optimize(self): '''Optimize the term order on the variables. ''' p = self.pset; o = TermOrderOptimization.optimizeTermOrder(p); r = Ring("",o.ring); return Ideal(r,"",o.list);
def element(self,polystr): '''Create an element from a string. ''' I = Ideal(self, "( " + polystr + " )"); list = I.pset.list; if len(list) > 0: return RingElem( list[0] );
def toModular(self,mf): '''Convert integer coefficients to modular coefficients. ''' p = self.pset; l = p.list; r = p.ring; rm = GenPolynomialRing( mf, r.nvar, r.tord, r.vars ); pm = PolyUtil.fromIntegerCoefficients(rm,l); r = Ring("",rm); return Ideal(r,"",pm);
def toInteger(self): '''Convert rational coefficients to integer coefficients. ''' p = self.pset; l = p.list; r = p.ring; ri = GenPolynomialRing( BigInteger(), r.nvar, r.tord, r.vars ); pi = PolyUtil.integerFromRationalCoefficients(ri,l); r = Ring("",ri); return Ideal(r,"",pi);
def NF(self,reducer): '''Compute a normal form of this ideal with respect to reducer. ''' s = self.pset; F = s.list; G = reducer.list; t = System.currentTimeMillis(); N = ReductionSeq().normalform(G,F); t = System.currentTimeMillis() - t; print "sequential NF executed in %s ms" % t; return Ideal(self.ring,"",N);
def parTwosidedGB(self,th): '''Compute a two-sided Groebner base in parallel. ''' s = self.pset; F = s.list; bbpar = SolvableGroebnerBaseParallel(th); t = System.currentTimeMillis(); G = bbpar.twosidedGB(F); t = System.currentTimeMillis() - t; bbpar.terminate(); print "parallel %s twosidedGB executed in %s ms" % (th, t); return Ideal(self.ring,"",G);
def parOldGB(self,th): '''Compute in parallel a Groebner base. ''' s = self.pset; F = s.list; bbpar = GroebnerBaseParallel(th); t = System.currentTimeMillis(); G = bbpar.GB(F); t = System.currentTimeMillis() - t; bbpar.terminate(); print "parallel-old %s executed in %s ms" % (th, t); return Ideal(self.ring,"",G);
def distGB(self,th=2,machine="examples/machines.localhost",port=7114): '''Compute on a distributed system a Groebner base. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); # G = GroebnerBaseDistributed.Server(F,th); #G = GBDist(th,machine,port).execute(F); gbd = GBDist(th,machine,port); t1 = System.currentTimeMillis(); G = gbd.execute(F); t1 = System.currentTimeMillis() - t1; gbd.terminate(0); t = System.currentTimeMillis() - t; print "distributed %s executed in %s ms (%s ms start-up)" % (th,t1,t-t1); return Ideal(self.ring,"",G);
def GB(self): '''Compute a Groebner base. ''' s = self.pset; cofac = s.ring.coFac; F = s.list; t = System.currentTimeMillis(); if cofac.isField(): G = GroebnerBaseSeq().GB(F); else: v = None; try: v = cofac.vars; except: pass if v == None: G = GroebnerBasePseudoSeq(cofac).GB(F); else: G = GroebnerBasePseudoRecSeq(cofac).GB(F); t = System.currentTimeMillis() - t; print "sequential GB executed in %s ms" % t; return Ideal(self.ring,"",G);
def ideal(self,ringstr="",list=None): '''Create an ideal. ''' return Ideal(self,ringstr,list);
def isGB(self): '''Test if this is a Groebner base. ''' I = Ideal(self.ring,"",self.pset.list); return I.isGB();
def GB(self): '''Compute a Groebner base. ''' I = Ideal(self.ring,"",self.pset.list); g = I.GB(); return ParamIdeal(g.ring,"",g.pset.list);
def intersect(self,ring): '''Compute the intersection of this and the given polynomial ring. ''' s = jas.application.Ideal(self.pset); N = s.intersect(ring.ring); return Ideal(self.ring,"",N.getList());
""" for t in (2, 3, 5, 7, 11, 13, 17, 19, 23, 27, 31, 37, 43): #for t in (5,7): r1 = SolvableRing(rs1 % t) r1c = SolvableRing(rs1c) #print "SolvableRing: " + str(r1); #print "SolvableRing: " + str(r1c); #print; it = r1.ideal(ps % (t, t)) #print "SolvableIdeal: " + str(it); #print; # compute I_{\phi_t} \cap WA_1^opp x = it.leftGB() print "seq left x:", x y = Ideal(x.pset).intersect(r1c.ring) len = y.list.size() print "seq left y: ", y print "seq left y len: ", len #print; #------------------------------------- r2 = SolvableRing(rs2 % t) r2c = SolvableRing(rs2c % t) #print "SolvableRing: " + str(r2); #print "SolvableRing: " + str(r2c); #print; ikt = r2.ideal(ps % (t, t)) #print "SolvableIdeal: " + str(ikt); print # compute ker(\phi_t) x = ikt.leftGB()