def CGB(self): '''Compute a comprehensive Groebner base. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); if self.gbsys == None: self.gbsys = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).GBsys(F); G = self.gbsys.getCGB(); t = System.currentTimeMillis() - t; print "sequential comprehensive executed in %s ms" % t; return ParamIdeal(self.ring,"",G,self.gbsys);
def isCGBsystem(self): '''Test if this is a comprehensive Groebner system. ''' s = self.pset; S = self.gbsys; t = System.currentTimeMillis(); b = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).isGBsys(S); t = System.currentTimeMillis() - t; print "isCGBsystem executed in %s ms" % t; return b;
def isCGB(self): '''Test if this is a comprehensive Groebner base. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); b = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).isGB(F); t = System.currentTimeMillis() - t; print "isCGB executed in %s ms" % t; return b;
def CGBsystem(self): '''Compute a comprehensive Groebner system. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); S = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).GBsys(F); t = System.currentTimeMillis() - t; print "sequential comprehensive system executed in %s ms" % t; return ParamIdeal(self.ring,None,F,S);
class ParamIdeal: '''Represents a JAS polynomial ideal with polynomial coefficients. Methods to compute comprehensive Groebner bases. ''' def __init__(self,ring,polystr="",list=None,gbsys=None): '''Parametric ideal constructor. ''' self.ring = ring; if list == None and polystr != None: sr = StringReader( polystr ); tok = GenPolynomialTokenizer(ring.pset.ring,sr); self.list = tok.nextPolynomialList(); else: self.list = pylist2arraylist(list); self.gbsys = gbsys; self.pset = OrderedPolynomialList(ring.ring,self.list); def __str__(self): '''Create a string representation. ''' if self.gbsys == None: return str(self.pset); else: return str(self.gbsys); # return str(self.pset) + "\n" + str(self.gbsys); def optimizeCoeff(self): '''Optimize the term order on the variables of the coefficients. ''' p = self.pset; o = TermOrderOptimization.optimizeTermOrderOnCoefficients(p); r = Ring("",o.ring); return ParamIdeal(r,"",o.list); def optimizeCoeffQuot(self): '''Optimize the term order on the variables of the quotient coefficients. ''' p = self.pset; l = p.list; r = p.ring; q = r.coFac; c = q.ring; rc = GenPolynomialRing( c, r.nvar, r.tord, r.vars ); #print "rc = ", rc; lp = PolyUfdUtil.integralFromQuotientCoefficients(rc,l); #print "lp = ", lp; pp = PolynomialList(rc,lp); #print "pp = ", pp; oq = TermOrderOptimization.optimizeTermOrderOnCoefficients(pp); oor = oq.ring; qo = oor.coFac; cq = QuotientRing( qo ); rq = GenPolynomialRing( cq, r.nvar, r.tord, r.vars ); #print "rq = ", rq; o = PolyUfdUtil.quotientFromIntegralCoefficients(rq,oq.list); r = Ring("",rq); return ParamIdeal(r,"",o); def toIntegralCoeff(self): '''Convert rational function coefficients to integral function coefficients. ''' p = self.pset; l = p.list; r = p.ring; q = r.coFac; c = q.ring; rc = GenPolynomialRing( c, r.nvar, r.tord, r.vars ); #print "rc = ", rc; lp = PolyUfdUtil.integralFromQuotientCoefficients(rc,l); #print "lp = ", lp; r = Ring("",rc); return ParamIdeal(r,"",lp); def toModularCoeff(self,mf): '''Convert integral function coefficients to modular function coefficients. ''' p = self.pset; l = p.list; r = p.ring; c = r.coFac; #print "c = ", c; cm = GenPolynomialRing( mf, c.nvar, c.tord, c.vars ); #print "cm = ", cm; rm = GenPolynomialRing( cm, r.nvar, r.tord, r.vars ); #print "rm = ", rm; pm = PolyUfdUtil.fromIntegerCoefficients(rm,l); r = Ring("",rm); return ParamIdeal(r,"",pm); def toQuotientCoeff(self): '''Convert integral function coefficients to rational function coefficients. ''' p = self.pset; l = p.list; r = p.ring; c = r.coFac; #print "c = ", c; q = QuotientRing(c); #print "q = ", q; qm = GenPolynomialRing( q, r.nvar, r.tord, r.vars ); #print "qm = ", qm; pm = PolyUfdUtil.quotientFromIntegralCoefficients(qm,l); r = Ring("",qm); return ParamIdeal(r,"",pm); 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 isGB(self): '''Test if this is a Groebner base. ''' I = Ideal(self.ring,"",self.pset.list); return I.isGB(); def CGB(self): '''Compute a comprehensive Groebner base. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); if self.gbsys == None: self.gbsys = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).GBsys(F); G = self.gbsys.getCGB(); t = System.currentTimeMillis() - t; print "sequential comprehensive executed in %s ms" % t; return ParamIdeal(self.ring,"",G,self.gbsys); def CGBsystem(self): '''Compute a comprehensive Groebner system. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); S = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).GBsys(F); t = System.currentTimeMillis() - t; print "sequential comprehensive system executed in %s ms" % t; return ParamIdeal(self.ring,None,F,S); def isCGB(self): '''Test if this is a comprehensive Groebner base. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); b = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).isGB(F); t = System.currentTimeMillis() - t; print "isCGB executed in %s ms" % t; return b; def isCGBsystem(self): '''Test if this is a comprehensive Groebner system. ''' s = self.pset; S = self.gbsys; t = System.currentTimeMillis(); b = ComprehensiveGroebnerBaseSeq(self.ring.ring.coFac).isGBsys(S); t = System.currentTimeMillis() - t; print "isCGBsystem executed in %s ms" % t; return b; def regularRepresentation(self): '''Convert Groebner system to a representation with regular ring coefficents. ''' if self.gbsys == None: return None; G = PolyUtilApp.toProductRes(self.gbsys.list); ring = Ring(None,G[0].ring); return ParamIdeal(ring,None,G); def regularGB(self): '''Compute a Groebner base over a regular ring. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); G = RGroebnerBasePseudoSeq(self.ring.ring.coFac).GB(F); t = System.currentTimeMillis() - t; print "sequential regular GB executed in %s ms" % t; return ParamIdeal(self.ring,None,G); def isRegularGB(self): '''Test if this is Groebner base over a regular ring. ''' s = self.pset; F = s.list; t = System.currentTimeMillis(); b = RGroebnerBasePseudoSeq(self.ring.ring.coFac).isGB(F); t = System.currentTimeMillis() - t; print "isRegularGB executed in %s ms" % t; return b; def stringSlice(self): '''Get each component (slice) of regular ring coefficients separate. ''' s = self.pset; b = PolyUtilApp.productToString(s); return b;