def intersect(i, j, **gb_opts): """ This functions intersects two ideals. The first ring variable is used as helper variable for this intersection. It is assumed, that it doesn't occur in the ideals, and that we have an elimination ordering for this variables. Both assumptions are checked. >>> from polybori.frontend import declare_ring >>> from polybori import Block >>> r=declare_ring(Block("x", 1000), globals()) >>> x = r.variable >>> intersect([x(1),x(2)+1],[x(1),x(2)]) [x(1)] """ if not i or not j: return [] uv = used_vars_set(i) * used_vars_set(j) t = iter(i).next().ring().variable(0) if uv.reducible_by(t): raise ValueError, \ "First ring variable has to be reserved as helper variable t" if not t > uv: raise ValueError, "need elimination ordering for first ring variable" gb = groebner_basis(list(chain((t * p for p in i), ((1 + t) * p for p in j ))), **gb_opts) return [p for p in gb if p.navigation().value() > t.index()]
def _calculate_gb_with_keywords(args): (I, kwds_as_single_arg) = args import traceback try: return groebner_basis(I, **kwds_as_single_arg) except: raise ValueError, traceback.format_exc()
def _calculate_gb_with_keywords(args): (I, kwds_as_single_arg) = args import traceback try: return groebner_basis(I, **kwds_as_single_arg) except: raise ValueError, traceback.format_exc()
def intersect(i, j, **gb_opts): """ This functions intersects two ideals. The first ring variable is used as helper variable for this intersection. It is assumed, that it doesn't occur in the ideals, and that we have an elimination ordering for this variables. Both assumptions are checked. >>> from polybori.frontend import declare_ring >>> from polybori import Block >>> r=declare_ring(Block("x", 1000), globals()) >>> x = r.variable >>> intersect([x(1),x(2)+1],[x(1),x(2)]) [x(1)] """ if not i or not j: return [] uv = used_vars_set(i) * used_vars_set(j) t = iter(i).next().ring().variable(0) if uv.reducible_by(t): raise ValueError, \ "First ring variable has to be reserved as helper variable t" if not t > uv: raise ValueError, "need elimination ordering for first ring variable" gb = groebner_basis( list(chain((t * p for p in i), ((1 + t) * p for p in j))), **gb_opts) return [p for p in gb if p.navigation().value() > t.index()]
prot = True try: from custom_profile import filename as datafilename except: print "No filename in custom_profile.py file! Using " + datafilename + "." try: from custom_profile import ordering as ordername except: print "No ordering in custom_profile.py file! Using " + ordername + "." try: from custom_profile import protocol as prot except: print "No protocol in custom_profile.py file! Using " + prot + "." data = load_data(datafilename, base_dir="../../polybori-testsuite/") ring = data.ideal[0].ring().clone(ordering=getattr(OrderCode, ordername)) I = groebner_basis([ring(poly) for poly in data.ideal], prot=prot) ## from_ring=global_ring() ## change_ordering(lp) ## to_ring=global_ring() ## vec=BoolePolynomialVector() ## for p in I: ## vec.append(p) ## from time import sleep ## sleep(30) ## res=FGLMStrategy(from_ring,to_ring, vec).main()
ordername = "lp" prot = True try: from custom_profile import filename as datafilename except: print 'No filename in custom_profile.py file! Using ' + datafilename + '.' try: from custom_profile import ordering as ordername except: print 'No ordering in custom_profile.py file! Using ' + ordername + '.' try: from custom_profile import protocol as prot except: print 'No protocol in custom_profile.py file! Using ' + prot + '.' data = load_data(datafilename, base_dir="../../polybori-testsuite/") ring = data.ideal[0].ring().clone(ordering=getattr(OrderCode, ordername)) I = groebner_basis([ring(poly) for poly in data.ideal], prot=prot) ## from_ring=global_ring() ## change_ordering(lp) ## to_ring=global_ring() ## vec=BoolePolynomialVector() ## for p in I: ## vec.append(p) ## from time import sleep ## sleep(30) ## res=FGLMStrategy(from_ring,to_ring, vec).main()
# Main code # ################################################### PK, maxNV = readPK(fpIn) # Convert file to PolyBoRi format maxNV += 1 # Not an index but a quantity writePolyForPolyBoRi(PK, maxNV, "forPB") # Generate file for Groebner Basis data = load_file("forPB") # Import file to use in GB acumm = 0.0 ####### Computes Groebner Basis for a set of polynomials equal to a random "y" for i in range( k-1 ): polys = copy.copy(data.ideal) # Copy original data ( = 0 ) y = randVect( len(data.ideal) ) # Generates random "y" polys = equalZero(polys, y) # Set of "polys" - "y" = 0 startTime = time.time() gb = groebner_basis( polys ) # Computes Groebner Basis endTime = time.time() acumm += (endTime - startTime) print ".", sys.stdout.flush() ####### Computes Groebner Basis for a set of polynomials equal to an ####### algebraic variety startTime = time.time() gb = groebner_basis( data.ideal ) # Computes last Groebner Basis endTime = time.time() # when "polys" = 0 acumm += (endTime - startTime) print ".", sys.stdout.flush() if ( len(gb) < 5 ):