class JAS::SimIdeal

Represents a JAS polynomial ideal: PolynomialList and Ideal.

Methods for Groebner bases, ideal sum, intersection and others.

Attributes

list[R]

the Java polynomial list, polynomial ring, and ideal decompositions

primary[R]

the Java polynomial list, polynomial ring, and ideal decompositions

prime[R]

the Java polynomial list, polynomial ring, and ideal decompositions

pset[R]

the Java polynomial list, polynomial ring, and ideal decompositions

ring[R]

the Java polynomial list, polynomial ring, and ideal decompositions

roots[R]

the Java polynomial list, polynomial ring, and ideal decompositions

Public Class Methods

new(ring,polystr="",list=nil) click to toggle source

SimIdeal constructor.

     # File examples/jas.rb
2858 def initialize(ring,polystr="",list=nil)
2859     @ring = ring;
2860     if list == nil
2861        sr = StringReader.new( polystr );
2862        tok = GenPolynomialTokenizer.new(ring::ring,sr);
2863        @list = tok.nextPolynomialList();
2864     else
2865        @list = rbarray2arraylist(list,rec=1);
2866     end
2867     #@list = PolyUtil.monic(@list);
2868     @pset = OrderedPolynomialList.new(@ring.ring,@list);
2869     #@ideal = Ideal.new(@pset);
2870     @roots = nil;
2871     @croots = nil;
2872     @prime = nil;
2873     @primary = nil;
2874     #super(@ring::ring,@list) # non-sense, JRuby extends application.Ideal
2875 end

Public Instance Methods

<=>(other) click to toggle source

Compare two ideals.

     # File examples/jas.rb
2887 def <=>(other)
2888     s = Ideal.new(@pset);
2889     o = Ideal.new(other.pset);
2890     return s.compareTo(o);
2891 end
==(other) click to toggle source

Test if two ideals are equal.

     # File examples/jas.rb
2896 def ==(other)
2897     if not other.is_a? SimIdeal
2898        return false;
2899     end
2900     return (self <=> other) == 0; 
2901 end
CS() click to toggle source

Compute a Characteristic Set.

     # File examples/jas.rb
3429 def CS()
3430     s = @pset;
3431     cofac = s.ring.coFac;
3432     ff = s.list;
3433     t = System.currentTimeMillis();
3434     if cofac.isField()
3435         gg = CharacteristicSetWu.new().characteristicSet(ff);
3436     else
3437         puts "CS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
3438         gg = nil;
3439     end
3440     t = System.currentTimeMillis() - t;
3441     puts "sequential char set executed in #{t} ms\n"; 
3442     return SimIdeal.new(@ring,"",gg);
3443 end
GB() click to toggle source

Compute a Groebner base.

     # File examples/jas.rb
2929 def GB()
2930     #if @ideal != nil
2931     #   return SimIdeal.new(@ring,"",nil,@ideal.GB());
2932     #end
2933     cofac = @ring.ring.coFac;
2934     ff = @pset.list;
2935     kind = "";
2936     t = System.currentTimeMillis();
2937     if cofac.isField()
2938         #gg = GroebnerBaseSeq.new().GB(ff);
2939         #gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedPairlist.new()).GB(ff);
2940         gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff);
2941         #gg = GroebnerBaseSeqIter.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff);
2942         kind = "field"
2943     else
2944         if cofac.is_a? GenPolynomialRing and cofac.isCommutative()
2945             gg = GroebnerBasePseudoRecSeq.new(cofac).GB(ff);
2946             kind = "pseudoRec"
2947         else
2948             gg = GroebnerBasePseudoSeq.new(cofac).GB(ff);
2949             kind = "pseudo"
2950         end
2951     end
2952     t = System.currentTimeMillis() - t;
2953     puts "sequential(#{kind}) GB executed in #{t} ms\n"; 
2954     return SimIdeal.new(@ring,"",gg);
2955 end
NF(reducer) click to toggle source

Compute a normal form of this ideal with respect to reducer.

     # File examples/jas.rb
3170 def NF(reducer)
3171     s = @pset;
3172     ff = s.list;
3173     gg = reducer.list;
3174     t = System.currentTimeMillis();
3175     nn = ReductionSeq.new().normalform(gg,ff);
3176     t = System.currentTimeMillis() - t;
3177     puts "sequential NF executed in #{t} ms\n"; 
3178     return SimIdeal.new(@ring,"",nn);
3179 end
complexRoots() click to toggle source

Compute complex roots of 0-dim ideal.

     # File examples/jas.rb
3349 def complexRoots()
3350     ii = Ideal.new(@pset);
3351     @croots = PolyUtilApp.complexAlgebraicRoots(ii);
3352     for r in @croots
3353         r.doDecimalApproximation();
3354     end
3355     return @croots;
3356 end
complexRootsPrint() click to toggle source

Print decimal approximation of complex roots of 0-dim ideal.

     # File examples/jas.rb
3361 def complexRootsPrint()
3362     if @croots == nil
3363         ii = Ideal.new(@pset);
3364         @croots = PolyUtilApp.complexAlgebraicRoots(ii);
3365         for r in @croots
3366             r.doDecimalApproximation();
3367         end
3368     end
3369     for ic in @croots
3370         for dc in ic.decimalApproximation()
3371             puts dc.to_s;
3372         end
3373         puts;
3374     end
3375 end
csReduction(p) click to toggle source

Compute a normal form of polynomial p with respect this characteristic set.

     # File examples/jas.rb
3468 def csReduction(p)
3469     s = @pset;
3470     ff = s.list.clone();
3471     Collections.reverse(ff); # todo
3472     if p.is_a? RingElem
3473         p = p.elem;
3474     end
3475     t = System.currentTimeMillis();
3476     nn = CharacteristicSetWu.new().characteristicSetReduction(ff,p);
3477     t = System.currentTimeMillis() - t;
3478     #puts "sequential char set reduction executed in #{t} ms\n";
3479     return RingElem.new(nn);
3480 end
dGB() click to toggle source

Compute an d-Groebner base.

     # File examples/jas.rb
3018 def dGB()
3019     s = @pset;
3020     cofac = s.ring.coFac;
3021     ff = s.list;
3022     t = System.currentTimeMillis();
3023     if cofac.isField()
3024         gg = GroebnerBaseSeq.new().GB(ff);
3025     else
3026         gg = DGroebnerBaseSeq.new().GB(ff)
3027     end
3028     t = System.currentTimeMillis() - t;
3029     puts "sequential d-GB executed in #{t} ms\n"; 
3030     return SimIdeal.new(@ring,"",gg);
3031 end
decomposition() click to toggle source

Compute irreducible decomposition of this ideal.

     # File examples/jas.rb
3340 def decomposition()
3341     ii = Ideal.new(@pset);
3342     @irrdec = ii.decomposition();
3343     return @irrdec;
3344 end
distClient(port=4711) click to toggle source

Client for a distributed computation.

     # File examples/jas.rb
3108 def distClient(port=4711)
3109     s = @pset;
3110     e1 = ExecutableServer.new( port );
3111     e1.init();
3112     e2 = ExecutableServer.new( port+1 );
3113     e2.init();
3114     @exers = [e1,e2];
3115     return nil;
3116 end
distClientStop() click to toggle source

Client for a distributed computation.

     # File examples/jas.rb
3122 def distClientStop()
3123     for es in @exers;
3124         es.terminate();
3125     end
3126     return nil;
3127 end
distGB(th=2,machine="examples/machines.localhost",port=55711) click to toggle source

Compute on a distributed system a Groebner base.

     # File examples/jas.rb
3089 def distGB(th=2,machine="examples/machines.localhost",port=55711)
3090     s = @pset;
3091     ff = s.list;
3092     t = System.currentTimeMillis();
3093     # old: gbd = GBDist.new(th,machine,port);
3094     gbd = GroebnerBaseDistributedEC.new(machine,th,port);
3095     #gbd = GroebnerBaseDistributedHybridEC.new(machine,th,3,port);
3096     t1 = System.currentTimeMillis();
3097     gg = gbd.GB(ff);
3098     t1 = System.currentTimeMillis() - t1;
3099     gbd.terminate(false);
3100     t = System.currentTimeMillis() - t;
3101     puts "distributed #{th} executed in #{t1} ms (#{t-t1} ms start-up)\n"; 
3102     return SimIdeal.new(@ring,"",gg);
3103 end
eGB() click to toggle source

Compute an e-Groebner base.

     # File examples/jas.rb
2982 def eGB()
2983     s = @pset;
2984     cofac = s.ring.coFac;
2985     ff = s.list;
2986     t = System.currentTimeMillis();
2987     if cofac.isField()
2988         gg = GroebnerBaseSeq.new().GB(ff);
2989     else
2990         gg = EGroebnerBaseSeq.new().GB(ff)
2991     end
2992     t = System.currentTimeMillis() - t;
2993     puts "sequential e-GB executed in #{t} ms\n"; 
2994     return SimIdeal.new(@ring,"",gg);
2995 end
eReduction(p) click to toggle source

Compute a e-normal form of p with respect to this ideal.

     # File examples/jas.rb
3154 def eReduction(p)
3155     s = @pset;
3156     gg = s.list;
3157     if p.is_a? RingElem
3158         p = p.elem;
3159     end
3160     t = System.currentTimeMillis();
3161     n = EReductionSeq.new().normalform(gg,p);
3162     t = System.currentTimeMillis() - t;
3163     puts "sequential eReduction executed in " + str(t) + " ms"; 
3164     return RingElem.new(n);
3165 end
eliminateRing(ring) click to toggle source

Compute the elimination ideal of this and the given polynomial ring.

     # File examples/jas.rb
3236 def eliminateRing(ring)
3237     s = Ideal.new(@pset);
3238     nn = s.eliminate(ring.ring);
3239     r = Ring.new( "", nn.getRing() );
3240     return SimIdeal.new(r,"",nn.getList());
3241 end
interreduced_basis() click to toggle source

Compute a interreduced ideal basis of this.

     # File examples/jas.rb
3208 def interreduced_basis()
3209     ff = @pset.list;
3210     nn = ReductionSeq.new().irreducibleSet(ff);
3211     return nn.map{ |x| RingElem.new(x) };
3212 end
intersect(id2) click to toggle source

Compute the intersection of this and the given ideal.

     # File examples/jas.rb
3226 def intersect(id2)
3227     s1 = Ideal.new(@pset);
3228     s2 = Ideal.new(id2.pset);
3229     nn = s1.intersect(s2);
3230     return SimIdeal.new(@ring,"",nn.getList());
3231 end
intersectRing(ring) click to toggle source

Compute the intersection of this and the given polynomial ring.

     # File examples/jas.rb
3217 def intersectRing(ring)
3218     s = Ideal.new(@pset);
3219     nn = s.intersect(ring.ring);
3220     return SimIdeal.new(ring,"",nn.getList());
3221 end
inverse(p) click to toggle source

Compute the inverse polynomial modulo this ideal, if it exists.

     # File examples/jas.rb
3278 def inverse(p)
3279     if p.is_a? RingElem
3280         p = p.elem;
3281     end
3282     s = Ideal.new(@pset);
3283     i = s.inverse(p);
3284     return RingElem.new(i);
3285 end
isCS() click to toggle source

Test for Characteristic Set.

     # File examples/jas.rb
3448 def isCS()
3449     s = @pset;
3450     cofac = s.ring.coFac;
3451     ff = s.list.clone();
3452     Collections.reverse(ff); # todo
3453     t = System.currentTimeMillis();
3454     if cofac.isField()
3455         b = CharacteristicSetWu.new().isCharacteristicSet(ff);
3456     else
3457         puts "isCS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
3458         b = false;
3459     end
3460     t = System.currentTimeMillis() - t;
3461     #puts "sequential is char set executed in #{t} ms\n";
3462     return b;
3463 end
isGB() click to toggle source

Test if this is a Groebner base.

     # File examples/jas.rb
2960 def isGB()
2961     s = @pset;
2962     cofac = s.ring.coFac;
2963     ff = s.list;
2964     t = System.currentTimeMillis();
2965     if cofac.isField()
2966         b = GroebnerBaseSeq.new().isGB(ff);
2967     else
2968         if cofac.is_a? GenPolynomialRing and cofac.isCommutative()
2969             b = GroebnerBasePseudoRecSeq.new(cofac).isGB(ff);
2970         else
2971             b = GroebnerBasePseudoSeq.new(cofac).isGB(ff);
2972         end
2973     end
2974     t = System.currentTimeMillis() - t;
2975     puts "isGB = #{b} executed in #{t} ms\n"; 
2976     return b;
2977 end
isONE() click to toggle source

Test if ideal is one.

     # File examples/jas.rb
2906 def isONE()
2907     s = Ideal.new(@pset);
2908     return s.isONE(); 
2909 end
isSyzygy(m) click to toggle source

Test if this is a syzygy of the module in m.

     # File examples/jas.rb
3499 def isSyzygy(m)
3500     p = @pset;
3501     g = p.list;
3502     l = m.list;
3503     #puts "l = #{l}";
3504     #puts "g = #{g}";
3505     t = System.currentTimeMillis();
3506     z = SyzygySeq.new(p.ring.coFac).isZeroRelation( l, g );
3507     t = System.currentTimeMillis() - t;
3508     puts "executed isSyzygy in #{t} ms\n"; 
3509     return z;
3510 end
isZERO() click to toggle source

Test if ideal is zero.

     # File examples/jas.rb
2914 def isZERO()
2915     s = Ideal.new(@pset);
2916     return s.isZERO(); 
2917 end
isdGB() click to toggle source

Test if this is a d-Groebner base.

     # File examples/jas.rb
3036 def isdGB()
3037     s = @pset;
3038     cofac = s.ring.coFac;
3039     ff = s.list;
3040     t = System.currentTimeMillis();
3041     if cofac.isField()
3042         b = GroebnerBaseSeq.new().isGB(ff);
3043     else
3044         b = DGroebnerBaseSeq.new().isGB(ff)
3045     end
3046     t = System.currentTimeMillis() - t;
3047     puts "is d-GB = #{b} executed in #{t} ms\n"; 
3048     return b;
3049 end
iseGB() click to toggle source

Test if this is an e-Groebner base.

     # File examples/jas.rb
3000 def iseGB()
3001     s = @pset;
3002     cofac = s.ring.coFac;
3003     ff = s.list;
3004     t = System.currentTimeMillis();
3005     if cofac.isField()
3006         b = GroebnerBaseSeq.new().isGB(ff);
3007     else
3008         b = EGroebnerBaseSeq.new().isGB(ff)
3009     end
3010     t = System.currentTimeMillis() - t;
3011     puts "is e-GB = #{b} executed in #{t} ms\n"; 
3012     return b;
3013 end
lift(p) click to toggle source

Represent p as element of this ideal.

     # File examples/jas.rb
3184 def lift(p)
3185     gg = @pset.list;
3186     z = @ring.ring.getZERO();
3187     rr = gg.map { |x| z };
3188     if p.is_a? RingElem
3189         p = p.elem;
3190     end
3191     #t = System.currentTimeMillis();
3192     if @ring.ring.coFac.isField()
3193        n = ReductionSeq.new().normalform(rr,gg,p);
3194     else 
3195        n = PseudoReductionSeq.new().normalform(rr,gg,p);
3196     end
3197     if not n.isZERO()
3198        raise StandardError, "p ist not a member of the ideal"
3199     end
3200     #t = System.currentTimeMillis() - t;
3201     #puts "sequential reduction executed in " + str(t) + " ms";
3202     return rr.map { |x| RingElem.new(x) };
3203 end
optimize() click to toggle source

Optimize the term order on the variables.

     # File examples/jas.rb
3290 def optimize()
3291     p = @pset;
3292     o = TermOrderOptimization.optimizeTermOrder(p);
3293     r = Ring.new("",o.ring);
3294     return SimIdeal.new(r,"",o.list);
3295 end
parGB(th) click to toggle source

Compute in parallel a Groebner base.

     # File examples/jas.rb
3069 def parGB(th)
3070     s = @pset;
3071     ff = s.list;
3072     cofac = s.ring.coFac;
3073     if cofac.isField() 
3074        bbpar = GroebnerBaseParallel.new(th);
3075     else 
3076        bbpar = GroebnerBasePseudoParallel.new(th,cofac);
3077     end
3078     t = System.currentTimeMillis();
3079     gg = bbpar.GB(ff);
3080     t = System.currentTimeMillis() - t;
3081     bbpar.terminate();
3082     puts "parallel #{th} executed in #{t} ms\n"; 
3083     return SimIdeal.new(@ring,"",gg);
3084 end
parUnusedGB(th) click to toggle source

Compute in parallel a Groebner base.

     # File examples/jas.rb
3054 def parUnusedGB(th)
3055     s = @pset;
3056     ff = s.list;
3057     bbpar = GroebnerBaseSeqPairParallel.new(th);
3058     t = System.currentTimeMillis();
3059     gg = bbpar.GB(ff);
3060     t = System.currentTimeMillis() - t;
3061     bbpar.terminate();
3062     puts "parallel-old #{th} executed in #{t} ms\n"; 
3063     return SimIdeal.new(@ring,"",gg);
3064 end
paramideal() click to toggle source

Create an ideal in a polynomial ring with parameter coefficients.

     # File examples/jas.rb
2922 def paramideal()
2923     return ParamIdeal.new(@ring,"",@list);
2924 end
primaryDecomp() click to toggle source

Compute primary decomposition of this ideal.

     # File examples/jas.rb
3389     def primaryDecomp()
3390         ii = Ideal.new(@pset);
3391 ##         if @prime == nil:
3392 ##             @prime = I.primeDecomposition();
3393         @primary = ii.primaryDecomposition();
3394         return @primary;
3395     end
primeDecomp() click to toggle source

Compute prime decomposition of this ideal.

     # File examples/jas.rb
3380 def primeDecomp()
3381     ii = Ideal.new(@pset);
3382     @prime = ii.primeDecomposition();
3383     return @prime;
3384 end
radicalDecomp() click to toggle source

Compute radical decomposition of this ideal.

     # File examples/jas.rb
3331 def radicalDecomp()
3332     ii = Ideal.new(@pset);
3333     @radical = ii.radicalDecomposition();
3334     return @radical;
3335 end
realRoots() click to toggle source

Compute real roots of 0-dim ideal.

     # File examples/jas.rb
3300 def realRoots()
3301     ii = Ideal.new(@pset);
3302     @roots = PolyUtilApp.realAlgebraicRoots(ii);
3303     for r in @roots
3304         r.doDecimalApproximation();
3305     end
3306     return @roots;
3307 end
realRootsPrint() click to toggle source

Print decimal approximation of real roots of 0-dim ideal.

     # File examples/jas.rb
3312 def realRootsPrint()
3313     if @roots == nil
3314         ii = Ideal.new(@pset);
3315         @roots = PolyUtilApp.realAlgebraicRoots(ii);
3316         for r in @roots
3317             r.doDecimalApproximation();
3318         end
3319     end
3320     for ir in @roots
3321         for dr in ir.decimalApproximation()
3322             puts dr.to_s;
3323         end
3324         puts;
3325     end
3326 end
reduction(p) click to toggle source

Compute a normal form of p with respect to this ideal.

     # File examples/jas.rb
3132 def reduction(p)
3133     s = @pset;
3134     gg = s.list;
3135     if p.is_a? RingElem
3136         p = p.elem;
3137     end
3138     #t = System.currentTimeMillis();
3139     if @ring.ring.coFac.isField()
3140        n = ReductionSeq.new().normalform(gg,p);
3141     else 
3142        n = PseudoReductionSeq.new().normalform(gg,p);
3143        #ff = PseudoReductionSeq.New().normalformFactor(gg,p);
3144        #print "ff.multiplicator = " + str(ff.multiplicator)
3145     end
3146     #t = System.currentTimeMillis() - t;
3147     #puts "sequential reduction executed in " + str(t) + " ms";
3148     return RingElem.new(n);
3149 end
sat(id2) click to toggle source

Compute the saturation of this and the given ideal.

     # File examples/jas.rb
3246 def sat(id2)
3247     s1 = Ideal.new(@pset);
3248     s2 = Ideal.new(id2.pset);
3249     #nn = s1.infiniteQuotient(s2);
3250     nn = s1.infiniteQuotientRab(s2);
3251     mm = nn.getList(); #PolyUtil.monicRec(nn.getList());
3252     return SimIdeal.new(@ring,"",mm);
3253 end
sum(other) click to toggle source

Compute the sum of this and the ideal.

     # File examples/jas.rb
3258 def sum(other)
3259     s = Ideal.new(@pset);
3260     t = Ideal.new(other.pset);
3261     nn = s.sum( t );
3262     return SimIdeal.new(@ring,"",nn.getList());
3263 end
syzygy() click to toggle source

Syzygy of generating polynomials.

     # File examples/jas.rb
3485 def syzygy()
3486     p = @pset;
3487     l = p.list;
3488     t = System.currentTimeMillis();
3489     s = SyzygySeq.new(p.ring.coFac).zeroRelations( l );
3490     t = System.currentTimeMillis() - t;
3491     puts "executed Syzygy in #{t} ms\n"; 
3492     m = CommutativeModule.new("",p.ring);
3493     return SubModule.new(m,"",s);
3494 end
toInteger() click to toggle source

Convert rational coefficients to integer coefficients.

     # File examples/jas.rb
3400 def toInteger()
3401     p = @pset;
3402     l = p.list;
3403     r = p.ring;
3404     ri = GenPolynomialRing.new( BigInteger.new(), r.nvar, r.tord, r.vars );
3405     pi = PolyUtil.integerFromRationalCoefficients(ri,l);
3406     r = Ring.new("",ri);
3407     return SimIdeal.new(r,"",pi);
3408 end
toModular(mf) click to toggle source

Convert integer coefficients to modular coefficients.

     # File examples/jas.rb
3413 def toModular(mf)
3414     p = @pset;
3415     l = p.list;
3416     r = p.ring;
3417     if mf.is_a? RingElem
3418         mf = mf.ring;
3419     end
3420     rm = GenPolynomialRing.new( mf, r.nvar, r.tord, r.vars );
3421     pm = PolyUtil.fromIntegerCoefficients(rm,l);
3422     r = Ring.new("",rm);
3423     return SimIdeal.new(r,"",pm);
3424 end
to_s() click to toggle source

Create a string representation.

     # File examples/jas.rb
2880 def to_s()
2881     return @pset.toScript();
2882 end
univariates() click to toggle source

Compute the univariate polynomials in each variable of this ideal.

     # File examples/jas.rb
3268 def univariates()
3269     s = Ideal.new(@pset);
3270     ll = s.constructUnivariate();
3271     nn = ll.map {|e| RingElem.new(e) };
3272     return nn;
3273 end