the Java polynomial list, polynomial ring, and ideal decompositions
Represents a JAS polynomial ideal: PolynomialList and Ideal.
Methods for Groebner bases, ideal sum, intersection and others.
SimIdeal constructor.
# File examples/jas.rb, line 2496 def initialize(ring,polystr="",list=nil) @ring = ring; if list == nil sr = StringReader.new( polystr ); tok = GenPolynomialTokenizer.new(ring::ring,sr); @list = tok.nextPolynomialList(); else @list = rbarray2arraylist(list,rec=1); end #@list = PolyUtil.monic(@list); @pset = OrderedPolynomialList.new(@ring.ring,@list); #@ideal = Ideal.new(@pset); @roots = nil; @croots = nil; @prime = nil; @primary = nil; #super(@ring::ring,@list) # non-sense, JRuby extends application.Ideal end
Compare two ideals.
# File examples/jas.rb, line 2525 def <=>(other) s = Ideal.new(@pset); o = Ideal.new(other.pset); return s.compareTo(o); end
Test if two ideals are equal.
# File examples/jas.rb, line 2534 def ===(other) if not other.is_a? SimIdeal return false; end return (self <=> other) == 0; end
Compute a Characteristic Set.
# File examples/jas.rb, line 3067 def CS() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() gg = CharacteristicSetWu.new().characteristicSet(ff); else puts "CS not implemented for coefficients #{cofac.toScriptFactory()}\n"; gg = nil; end t = System.currentTimeMillis() - t; puts "sequential char set executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Compute a Groebner base.
# File examples/jas.rb, line 2567 def GB() #if @ideal != nil # return SimIdeal.new(@ring,"",nil,@ideal.GB()); #end cofac = @ring.ring.coFac; ff = @pset.list; kind = ""; t = System.currentTimeMillis(); if cofac.isField() #gg = GroebnerBaseSeq.new().GB(ff); #gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedPairlist.new()).GB(ff); gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff); #gg = GroebnerBaseSeqIter.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff); kind = "field" else if cofac.is_a? GenPolynomialRing and cofac.isCommutative() gg = GroebnerBasePseudoRecSeq.new(cofac).GB(ff); kind = "pseudoRec" else gg = GroebnerBasePseudoSeq.new(cofac).GB(ff); kind = "pseudo" end end t = System.currentTimeMillis() - t; puts "sequential(#{kind}) GB executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Compute a normal form of this ideal with respect to reducer.
# File examples/jas.rb, line 2808 def NF(reducer) s = @pset; ff = s.list; gg = reducer.list; t = System.currentTimeMillis(); nn = ReductionSeq.new().normalform(gg,ff); t = System.currentTimeMillis() - t; puts "sequential NF executed in #{t} ms\n"; return SimIdeal.new(@ring,"",nn); end
Compute complex roots of 0-dim ideal.
# File examples/jas.rb, line 2987 def complexRoots() ii = Ideal.new(@pset); @croots = PolyUtilApp.complexAlgebraicRoots(ii); for r in @croots r.doDecimalApproximation(); end return @croots; end
Print decimal approximation of complex roots of 0-dim ideal.
# File examples/jas.rb, line 2999 def complexRootsPrint() if @croots == nil ii = Ideal.new(@pset); @croots = PolyUtilApp.complexAlgebraicRoots(ii); for r in @croots r.doDecimalApproximation(); end end for ic in @croots for dc in ic.decimalApproximation() puts dc.to_s; end puts; end end
Compute a normal form of polynomial p with respect this characteristic set.
# File examples/jas.rb, line 3106 def csReduction(p) s = @pset; ff = s.list.clone(); Collections.reverse(ff); # todo if p.is_a? RingElem p = p.elem; end t = System.currentTimeMillis(); nn = CharacteristicSetWu.new().characteristicSetReduction(ff,p); t = System.currentTimeMillis() - t; #puts "sequential char set reduction executed in #{t} ms\n"; return RingElem.new(nn); end
Compute an d-Groebner base.
# File examples/jas.rb, line 2656 def dGB() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() gg = GroebnerBaseSeq.new().GB(ff); else gg = DGroebnerBaseSeq.new().GB(ff) end t = System.currentTimeMillis() - t; puts "sequential d-GB executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Compute irreducible decomposition of this ideal.
# File examples/jas.rb, line 2978 def decomposition() ii = Ideal.new(@pset); @irrdec = ii.decomposition(); return @irrdec; end
Client for a distributed computation.
# File examples/jas.rb, line 2746 def distClient(port=4711) s = @pset; e1 = ExecutableServer.new( port ); e1.init(); e2 = ExecutableServer.new( port+1 ); e2.init(); @exers = [e1,e2]; return nil; end
Client for a distributed computation.
# File examples/jas.rb, line 2760 def distClientStop() for es in @exers; es.terminate(); end return nil; end
Compute on a distributed system a Groebner base.
# File examples/jas.rb, line 2727 def distGB(th=2,machine="examples/machines.localhost",port=55711) s = @pset; ff = s.list; t = System.currentTimeMillis(); # old: gbd = GBDist.new(th,machine,port); gbd = GroebnerBaseDistributedEC.new(machine,th,port); #gbd = GroebnerBaseDistributedHybridEC.new(machine,th,3,port); t1 = System.currentTimeMillis(); gg = gbd.GB(ff); t1 = System.currentTimeMillis() - t1; gbd.terminate(false); t = System.currentTimeMillis() - t; puts "distributed #{th} executed in #{t1} ms (#{t-t1} ms start-up)\n"; return SimIdeal.new(@ring,"",gg); end
Compute an e-Groebner base.
# File examples/jas.rb, line 2620 def eGB() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() gg = GroebnerBaseSeq.new().GB(ff); else gg = EGroebnerBaseSeq.new().GB(ff) end t = System.currentTimeMillis() - t; puts "sequential e-GB executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Compute a e-normal form of p with respect to this ideal.
# File examples/jas.rb, line 2792 def eReduction(p) s = @pset; gg = s.list; if p.is_a? RingElem p = p.elem; end t = System.currentTimeMillis(); n = EReductionSeq.new().normalform(gg,p); t = System.currentTimeMillis() - t; puts "sequential eReduction executed in " + str(t) + " ms"; return RingElem.new(n); end
Compute the elimination ideal of this and the given polynomial ring.
# File examples/jas.rb, line 2874 def eliminateRing(ring) s = Ideal.new(@pset); nn = s.eliminate(ring.ring); r = Ring.new( "", nn.getRing() ); return SimIdeal.new(r,"",nn.getList()); end
Compute a interreduced ideal basis of this.
# File examples/jas.rb, line 2846 def interreduced_basis() ff = @pset.list; nn = ReductionSeq.new().irreducibleSet(ff); return nn.map{ |x| RingElem.new(x) }; end
Compute the intersection of this and the given ideal.
# File examples/jas.rb, line 2864 def intersect(id2) s1 = Ideal.new(@pset); s2 = Ideal.new(id2.pset); nn = s1.intersect(s2); return SimIdeal.new(@ring,"",nn.getList()); end
Compute the intersection of this and the given polynomial ring.
# File examples/jas.rb, line 2855 def intersectRing(ring) s = Ideal.new(@pset); nn = s.intersect(ring.ring); return SimIdeal.new(ring,"",nn.getList()); end
Compute the inverse polynomial modulo this ideal, if it exists.
# File examples/jas.rb, line 2916 def inverse(p) if p.is_a? RingElem p = p.elem; end s = Ideal.new(@pset); i = s.inverse(p); return RingElem.new(i); end
Test for Characteristic Set.
# File examples/jas.rb, line 3086 def isCS() s = @pset; cofac = s.ring.coFac; ff = s.list.clone(); Collections.reverse(ff); # todo t = System.currentTimeMillis(); if cofac.isField() b = CharacteristicSetWu.new().isCharacteristicSet(ff); else puts "isCS not implemented for coefficients #{cofac.toScriptFactory()}\n"; b = false; end t = System.currentTimeMillis() - t; #puts "sequential is char set executed in #{t} ms\n"; return b; end
Test if this is a Groebner base.
# File examples/jas.rb, line 2598 def isGB() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() b = GroebnerBaseSeq.new().isGB(ff); else if cofac.is_a? GenPolynomialRing and cofac.isCommutative() b = GroebnerBasePseudoRecSeq.new(cofac).isGB(ff); else b = GroebnerBasePseudoSeq.new(cofac).isGB(ff); end end t = System.currentTimeMillis() - t; puts "isGB = #{b} executed in #{t} ms\n"; return b; end
Test if ideal is one.
# File examples/jas.rb, line 2544 def isONE() s = Ideal.new(@pset); return s.isONE(); end
Test if this is a syzygy of the module in m.
# File examples/jas.rb, line 3137 def isSyzygy(m) p = @pset; g = p.list; l = m.list; #puts "l = #{l}"; #puts "g = #{g}"; t = System.currentTimeMillis(); z = SyzygySeq.new(p.ring.coFac).isZeroRelation( l, g ); t = System.currentTimeMillis() - t; puts "executed isSyzygy in #{t} ms\n"; return z; end
Test if ideal is zero.
# File examples/jas.rb, line 2552 def isZERO() s = Ideal.new(@pset); return s.isZERO(); end
Test if this is a d-Groebner base.
# File examples/jas.rb, line 2674 def isdGB() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() b = GroebnerBaseSeq.new().isGB(ff); else b = DGroebnerBaseSeq.new().isGB(ff) end t = System.currentTimeMillis() - t; puts "is d-GB = #{b} executed in #{t} ms\n"; return b; end
Test if this is an e-Groebner base.
# File examples/jas.rb, line 2638 def iseGB() s = @pset; cofac = s.ring.coFac; ff = s.list; t = System.currentTimeMillis(); if cofac.isField() b = GroebnerBaseSeq.new().isGB(ff); else b = EGroebnerBaseSeq.new().isGB(ff) end t = System.currentTimeMillis() - t; puts "is e-GB = #{b} executed in #{t} ms\n"; return b; end
Represent p as element of this ideal.
# File examples/jas.rb, line 2822 def lift(p) gg = @pset.list; z = @ring.ring.getZERO(); rr = gg.map { |x| z }; if p.is_a? RingElem p = p.elem; end #t = System.currentTimeMillis(); if @ring.ring.coFac.isField() n = ReductionSeq.new().normalform(rr,gg,p); else n = PseudoReductionSeq.new().normalform(rr,gg,p); end if not n.isZERO() raise StandardError, "p ist not a member of the ideal" end #t = System.currentTimeMillis() - t; #puts "sequential reduction executed in " + str(t) + " ms"; return rr.map { |x| RingElem.new(x) }; end
Optimize the term order on the variables.
# File examples/jas.rb, line 2928 def optimize() p = @pset; o = TermOrderOptimization.optimizeTermOrder(p); r = Ring.new("",o.ring); return SimIdeal.new(r,"",o.list); end
Compute in parallel a Groebner base.
# File examples/jas.rb, line 2707 def parGB(th) s = @pset; ff = s.list; cofac = s.ring.coFac; if cofac.isField() bbpar = GroebnerBaseParallel.new(th); else bbpar = GroebnerBasePseudoParallel.new(th,cofac); end t = System.currentTimeMillis(); gg = bbpar.GB(ff); t = System.currentTimeMillis() - t; bbpar.terminate(); puts "parallel #{th} executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Compute in parallel a Groebner base.
# File examples/jas.rb, line 2692 def parUnusedGB(th) s = @pset; ff = s.list; bbpar = GroebnerBaseSeqPairParallel.new(th); t = System.currentTimeMillis(); gg = bbpar.GB(ff); t = System.currentTimeMillis() - t; bbpar.terminate(); puts "parallel-old #{th} executed in #{t} ms\n"; return SimIdeal.new(@ring,"",gg); end
Create an ideal in a polynomial ring with parameter coefficients.
# File examples/jas.rb, line 2560 def paramideal() return ParamIdeal.new(@ring,"",@list); end
Compute primary decomposition of this ideal.
# File examples/jas.rb, line 3027 def primaryDecomp() ii = Ideal.new(@pset); ## if @prime == nil: ## @prime = I.primeDecomposition(); @primary = ii.primaryDecomposition(); return @primary; end
Compute prime decomposition of this ideal.
# File examples/jas.rb, line 3018 def primeDecomp() ii = Ideal.new(@pset); @prime = ii.primeDecomposition(); return @prime; end
Compute radical decomposition of this ideal.
# File examples/jas.rb, line 2969 def radicalDecomp() ii = Ideal.new(@pset); @radical = ii.radicalDecomposition(); return @radical; end
Compute real roots of 0-dim ideal.
# File examples/jas.rb, line 2938 def realRoots() ii = Ideal.new(@pset); @roots = PolyUtilApp.realAlgebraicRoots(ii); for r in @roots r.doDecimalApproximation(); end return @roots; end
Print decimal approximation of real roots of 0-dim ideal.
# File examples/jas.rb, line 2950 def realRootsPrint() if @roots == nil ii = Ideal.new(@pset); @roots = PolyUtilApp.realAlgebraicRoots(ii); for r in @roots r.doDecimalApproximation(); end end for ir in @roots for dr in ir.decimalApproximation() puts dr.to_s; end puts; end end
Compute a normal form of p with respect to this ideal.
# File examples/jas.rb, line 2770 def reduction(p) s = @pset; gg = s.list; if p.is_a? RingElem p = p.elem; end #t = System.currentTimeMillis(); if @ring.ring.coFac.isField() n = ReductionSeq.new().normalform(gg,p); else n = PseudoReductionSeq.new().normalform(gg,p); #ff = PseudoReductionSeq.New().normalformFactor(gg,p); #print "ff.multiplicator = " + str(ff.multiplicator) end #t = System.currentTimeMillis() - t; #puts "sequential reduction executed in " + str(t) + " ms"; return RingElem.new(n); end
Compute the saturation of this and the given ideal.
# File examples/jas.rb, line 2884 def sat(id2) s1 = Ideal.new(@pset); s2 = Ideal.new(id2.pset); #nn = s1.infiniteQuotient(s2); nn = s1.infiniteQuotientRab(s2); mm = nn.getList(); #PolyUtil.monicRec(nn.getList()); return SimIdeal.new(@ring,"",mm); end
Compute the sum of this and the ideal.
# File examples/jas.rb, line 2896 def sum(other) s = Ideal.new(@pset); t = Ideal.new(other.pset); nn = s.sum( t ); return SimIdeal.new(@ring,"",nn.getList()); end
Syzygy of generating polynomials.
# File examples/jas.rb, line 3123 def syzygy() p = @pset; l = p.list; t = System.currentTimeMillis(); s = SyzygySeq.new(p.ring.coFac).zeroRelations( l ); t = System.currentTimeMillis() - t; puts "executed Syzygy in #{t} ms\n"; m = CommutativeModule.new("",p.ring); return SubModule.new(m,"",s); end
Convert rational coefficients to integer coefficients.
# File examples/jas.rb, line 3038 def toInteger() p = @pset; l = p.list; r = p.ring; ri = GenPolynomialRing.new( BigInteger.new(), r.nvar, r.tord, r.vars ); pi = PolyUtil.integerFromRationalCoefficients(ri,l); r = Ring.new("",ri); return SimIdeal.new(r,"",pi); end
Convert integer coefficients to modular coefficients.
# File examples/jas.rb, line 3051 def toModular(mf) p = @pset; l = p.list; r = p.ring; if mf.is_a? RingElem mf = mf.ring; end rm = GenPolynomialRing.new( mf, r.nvar, r.tord, r.vars ); pm = PolyUtil.fromIntegerCoefficients(rm,l); r = Ring.new("",rm); return SimIdeal.new(r,"",pm); end
Generated with the Darkfish Rdoc Generator 2.