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
3046 def initialize(ring,polystr="",list=nil)
3047     @ring = ring;
3048     if list == nil
3049        sr = StringReader.new( polystr );
3050        tok = GenPolynomialTokenizer.new(ring::ring,sr);
3051        @list = tok.nextPolynomialList();
3052     else
3053        @list = rbarray2arraylist(list,rec=1);
3054     end
3055     #@list = PolyUtil.monic(@list);
3056     @pset = OrderedPolynomialList.new(@ring.ring,@list);
3057     #@ideal = Ideal.new(@pset);
3058     @roots = nil;
3059     @croots = nil;
3060     @prime = nil;
3061     @primary = nil;
3062     #super(@ring::ring,@list) # non-sense, JRuby extends application.Ideal
3063 end

Public Instance Methods

<=>(other) click to toggle source

Compare two ideals.

     # File examples/jas.rb
3075 def <=>(other)
3076     s = Ideal.new(@pset);
3077     o = Ideal.new(other.pset);
3078     return s.compareTo(o);
3079 end
==(other) click to toggle source

Test if two ideals are equal.

     # File examples/jas.rb
3084 def ==(other)
3085     if not other.is_a? SimIdeal
3086        return false;
3087     end
3088     return (self <=> other) == 0; 
3089 end
CS() click to toggle source

Compute a Characteristic Set.

     # File examples/jas.rb
3617 def CS()
3618     s = @pset;
3619     cofac = s.ring.coFac;
3620     ff = s.list;
3621     t = System.currentTimeMillis();
3622     if cofac.isField()
3623         gg = CharacteristicSetWu.new().characteristicSet(ff);
3624     else
3625         puts "CS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
3626         gg = nil;
3627     end
3628     t = System.currentTimeMillis() - t;
3629     puts "sequential char set executed in #{t} ms\n"; 
3630     return SimIdeal.new(@ring,"",gg);
3631 end
GB() click to toggle source

Compute a Groebner base.

     # File examples/jas.rb
3117 def GB()
3118     #if @ideal != nil
3119     #   return SimIdeal.new(@ring,"",nil,@ideal.GB());
3120     #end
3121     cofac = @ring.ring.coFac;
3122     ff = @pset.list;
3123     kind = "";
3124     t = System.currentTimeMillis();
3125     if cofac.isField()
3126         #gg = GroebnerBaseSeq.new().GB(ff);
3127         #gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedPairlist.new()).GB(ff);
3128         gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff);
3129         #gg = GroebnerBaseSeqIter.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff);
3130         kind = "field"
3131     else
3132         if cofac.is_a? GenPolynomialRing and cofac.isCommutative()
3133             gg = GroebnerBasePseudoRecSeq.new(cofac).GB(ff);
3134             kind = "pseudoRec"
3135         else
3136             gg = GroebnerBasePseudoSeq.new(cofac).GB(ff);
3137             kind = "pseudo"
3138         end
3139     end
3140     t = System.currentTimeMillis() - t;
3141     puts "sequential(#{kind}) GB executed in #{t} ms\n"; 
3142     return SimIdeal.new(@ring,"",gg);
3143 end
NF(reducer) click to toggle source

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

     # File examples/jas.rb
3358 def NF(reducer)
3359     s = @pset;
3360     ff = s.list;
3361     gg = reducer.list;
3362     t = System.currentTimeMillis();
3363     nn = ReductionSeq.new().normalform(gg,ff);
3364     t = System.currentTimeMillis() - t;
3365     puts "sequential NF executed in #{t} ms\n"; 
3366     return SimIdeal.new(@ring,"",nn);
3367 end
complexRoots() click to toggle source

Compute complex roots of 0-dim ideal.

     # File examples/jas.rb
3537 def complexRoots()
3538     ii = Ideal.new(@pset);
3539     @croots = PolyUtilApp.complexAlgebraicRoots(ii);
3540     for r in @croots
3541         r.doDecimalApproximation();
3542     end
3543     return @croots;
3544 end
complexRootsPrint() click to toggle source

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

     # File examples/jas.rb
3549 def complexRootsPrint()
3550     if @croots == nil
3551         ii = Ideal.new(@pset);
3552         @croots = PolyUtilApp.complexAlgebraicRoots(ii);
3553         for r in @croots
3554             r.doDecimalApproximation();
3555         end
3556     end
3557     for ic in @croots
3558         for dc in ic.decimalApproximation()
3559             puts dc.to_s;
3560         end
3561         puts;
3562     end
3563 end
csReduction(p) click to toggle source

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

     # File examples/jas.rb
3656 def csReduction(p)
3657     s = @pset;
3658     ff = s.list.clone();
3659     Collections.reverse(ff); # todo
3660     if p.is_a? RingElem
3661         p = p.elem;
3662     end
3663     t = System.currentTimeMillis();
3664     nn = CharacteristicSetWu.new().characteristicSetReduction(ff,p);
3665     t = System.currentTimeMillis() - t;
3666     #puts "sequential char set reduction executed in #{t} ms\n";
3667     return RingElem.new(nn);
3668 end
dGB() click to toggle source

Compute an d-Groebner base.

     # File examples/jas.rb
3206 def dGB()
3207     s = @pset;
3208     cofac = s.ring.coFac;
3209     ff = s.list;
3210     t = System.currentTimeMillis();
3211     if cofac.isField()
3212         gg = GroebnerBaseSeq.new().GB(ff);
3213     else
3214         gg = DGroebnerBaseSeq.new().GB(ff)
3215     end
3216     t = System.currentTimeMillis() - t;
3217     puts "sequential d-GB executed in #{t} ms\n"; 
3218     return SimIdeal.new(@ring,"",gg);
3219 end
decomposition() click to toggle source

Compute irreducible decomposition of this ideal.

     # File examples/jas.rb
3528 def decomposition()
3529     ii = Ideal.new(@pset);
3530     @irrdec = ii.decomposition();
3531     return @irrdec;
3532 end
distClient(port=4711) click to toggle source

Client for a distributed computation.

     # File examples/jas.rb
3296 def distClient(port=4711)
3297     s = @pset;
3298     e1 = ExecutableServer.new( port );
3299     e1.init();
3300     e2 = ExecutableServer.new( port+1 );
3301     e2.init();
3302     @exers = [e1,e2];
3303     return nil;
3304 end
distClientStop() click to toggle source

Client for a distributed computation.

     # File examples/jas.rb
3310 def distClientStop()
3311     for es in @exers;
3312         es.terminate();
3313     end
3314     return nil;
3315 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
3277 def distGB(th=2,machine="examples/machines.localhost",port=55711)
3278     s = @pset;
3279     ff = s.list;
3280     t = System.currentTimeMillis();
3281     # old: gbd = GBDist.new(th,machine,port);
3282     gbd = GroebnerBaseDistributedEC.new(machine,th,port);
3283     #gbd = GroebnerBaseDistributedHybridEC.new(machine,th,3,port);
3284     t1 = System.currentTimeMillis();
3285     gg = gbd.GB(ff);
3286     t1 = System.currentTimeMillis() - t1;
3287     gbd.terminate(false);
3288     t = System.currentTimeMillis() - t;
3289     puts "distributed #{th} executed in #{t1} ms (#{t-t1} ms start-up)\n"; 
3290     return SimIdeal.new(@ring,"",gg);
3291 end
eGB() click to toggle source

Compute an e-Groebner base.

     # File examples/jas.rb
3170 def eGB()
3171     s = @pset;
3172     cofac = s.ring.coFac;
3173     ff = s.list;
3174     t = System.currentTimeMillis();
3175     if cofac.isField()
3176         gg = GroebnerBaseSeq.new().GB(ff);
3177     else
3178         gg = EGroebnerBaseSeq.new().GB(ff)
3179     end
3180     t = System.currentTimeMillis() - t;
3181     puts "sequential e-GB executed in #{t} ms\n"; 
3182     return SimIdeal.new(@ring,"",gg);
3183 end
eReduction(p) click to toggle source

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

     # File examples/jas.rb
3342 def eReduction(p)
3343     s = @pset;
3344     gg = s.list;
3345     if p.is_a? RingElem
3346         p = p.elem;
3347     end
3348     t = System.currentTimeMillis();
3349     n = EReductionSeq.new().normalform(gg,p);
3350     t = System.currentTimeMillis() - t;
3351     puts "sequential eReduction executed in " + str(t) + " ms"; 
3352     return RingElem.new(n);
3353 end
eliminateRing(ring) click to toggle source

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

     # File examples/jas.rb
3424 def eliminateRing(ring)
3425     s = Ideal.new(@pset);
3426     nn = s.eliminate(ring.ring);
3427     r = Ring.new( "", nn.getRing() );
3428     return SimIdeal.new(r,"",nn.getList());
3429 end
interreduced_basis() click to toggle source

Compute a interreduced ideal basis of this.

     # File examples/jas.rb
3396 def interreduced_basis()
3397     ff = @pset.list;
3398     nn = ReductionSeq.new().irreducibleSet(ff);
3399     return nn.map{ |x| RingElem.new(x) };
3400 end
intersect(id2) click to toggle source

Compute the intersection of this and the given ideal.

     # File examples/jas.rb
3414 def intersect(id2)
3415     s1 = Ideal.new(@pset);
3416     s2 = Ideal.new(id2.pset);
3417     nn = s1.intersect(s2);
3418     return SimIdeal.new(@ring,"",nn.getList());
3419 end
intersectRing(ring) click to toggle source

Compute the intersection of this and the given polynomial ring.

     # File examples/jas.rb
3405 def intersectRing(ring)
3406     s = Ideal.new(@pset);
3407     nn = s.intersect(ring.ring);
3408     return SimIdeal.new(ring,"",nn.getList());
3409 end
inverse(p) click to toggle source

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

     # File examples/jas.rb
3466 def inverse(p)
3467     if p.is_a? RingElem
3468         p = p.elem;
3469     end
3470     s = Ideal.new(@pset);
3471     i = s.inverse(p);
3472     return RingElem.new(i);
3473 end
isCS() click to toggle source

Test for Characteristic Set.

     # File examples/jas.rb
3636 def isCS()
3637     s = @pset;
3638     cofac = s.ring.coFac;
3639     ff = s.list.clone();
3640     Collections.reverse(ff); # todo
3641     t = System.currentTimeMillis();
3642     if cofac.isField()
3643         b = CharacteristicSetWu.new().isCharacteristicSet(ff);
3644     else
3645         puts "isCS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
3646         b = false;
3647     end
3648     t = System.currentTimeMillis() - t;
3649     #puts "sequential is char set executed in #{t} ms\n";
3650     return b;
3651 end
isGB() click to toggle source

Test if this is a Groebner base.

     # File examples/jas.rb
3148 def isGB()
3149     s = @pset;
3150     cofac = s.ring.coFac;
3151     ff = s.list;
3152     t = System.currentTimeMillis();
3153     if cofac.isField()
3154         b = GroebnerBaseSeq.new().isGB(ff);
3155     else
3156         if cofac.is_a? GenPolynomialRing and cofac.isCommutative()
3157             b = GroebnerBasePseudoRecSeq.new(cofac).isGB(ff);
3158         else
3159             b = GroebnerBasePseudoSeq.new(cofac).isGB(ff);
3160         end
3161     end
3162     t = System.currentTimeMillis() - t;
3163     puts "isGB = #{b} executed in #{t} ms\n"; 
3164     return b;
3165 end
isONE() click to toggle source

Test if ideal is one.

     # File examples/jas.rb
3094 def isONE()
3095     s = Ideal.new(@pset);
3096     return s.isONE(); 
3097 end
isSyzygy(m) click to toggle source

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

     # File examples/jas.rb
3687 def isSyzygy(m)
3688     p = @pset;
3689     g = p.list;
3690     l = m.list;
3691     #puts "l = #{l}";
3692     #puts "g = #{g}";
3693     t = System.currentTimeMillis();
3694     z = SyzygySeq.new(p.ring.coFac).isZeroRelation( l, g );
3695     t = System.currentTimeMillis() - t;
3696     puts "executed isSyzygy in #{t} ms\n"; 
3697     return z;
3698 end
isZERO() click to toggle source

Test if ideal is zero.

     # File examples/jas.rb
3102 def isZERO()
3103     s = Ideal.new(@pset);
3104     return s.isZERO(); 
3105 end
isdGB() click to toggle source

Test if this is a d-Groebner base.

     # File examples/jas.rb
3224 def isdGB()
3225     s = @pset;
3226     cofac = s.ring.coFac;
3227     ff = s.list;
3228     t = System.currentTimeMillis();
3229     if cofac.isField()
3230         b = GroebnerBaseSeq.new().isGB(ff);
3231     else
3232         b = DGroebnerBaseSeq.new().isGB(ff)
3233     end
3234     t = System.currentTimeMillis() - t;
3235     puts "is d-GB = #{b} executed in #{t} ms\n"; 
3236     return b;
3237 end
iseGB() click to toggle source

Test if this is an e-Groebner base.

     # File examples/jas.rb
3188 def iseGB()
3189     s = @pset;
3190     cofac = s.ring.coFac;
3191     ff = s.list;
3192     t = System.currentTimeMillis();
3193     if cofac.isField()
3194         b = GroebnerBaseSeq.new().isGB(ff);
3195     else
3196         b = EGroebnerBaseSeq.new().isGB(ff)
3197     end
3198     t = System.currentTimeMillis() - t;
3199     puts "is e-GB = #{b} executed in #{t} ms\n"; 
3200     return b;
3201 end
lift(p) click to toggle source

Represent p as element of this ideal.

     # File examples/jas.rb
3372 def lift(p)
3373     gg = @pset.list;
3374     z = @ring.ring.getZERO();
3375     rr = gg.map { |x| z };
3376     if p.is_a? RingElem
3377         p = p.elem;
3378     end
3379     #t = System.currentTimeMillis();
3380     if @ring.ring.coFac.isField()
3381        n = ReductionSeq.new().normalform(rr,gg,p);
3382     else 
3383        n = PseudoReductionSeq.new().normalform(rr,gg,p);
3384     end
3385     if not n.isZERO()
3386        raise StandardError, "p ist not a member of the ideal"
3387     end
3388     #t = System.currentTimeMillis() - t;
3389     #puts "sequential reduction executed in " + str(t) + " ms";
3390     return rr.map { |x| RingElem.new(x) };
3391 end
optimize() click to toggle source

Optimize the term order on the variables.

     # File examples/jas.rb
3478 def optimize()
3479     p = @pset;
3480     o = TermOrderOptimization.optimizeTermOrder(p);
3481     r = Ring.new("",o.ring);
3482     return SimIdeal.new(r,"",o.list);
3483 end
parGB(th) click to toggle source

Compute in parallel a Groebner base.

     # File examples/jas.rb
3257 def parGB(th)
3258     s = @pset;
3259     ff = s.list;
3260     cofac = s.ring.coFac;
3261     if cofac.isField() 
3262        bbpar = GroebnerBaseParallel.new(th);
3263     else 
3264        bbpar = GroebnerBasePseudoParallel.new(th,cofac);
3265     end
3266     t = System.currentTimeMillis();
3267     gg = bbpar.GB(ff);
3268     t = System.currentTimeMillis() - t;
3269     bbpar.terminate();
3270     puts "parallel #{th} executed in #{t} ms\n"; 
3271     return SimIdeal.new(@ring,"",gg);
3272 end
parUnusedGB(th) click to toggle source

Compute in parallel a Groebner base.

     # File examples/jas.rb
3242 def parUnusedGB(th)
3243     s = @pset;
3244     ff = s.list;
3245     bbpar = GroebnerBaseSeqPairParallel.new(th);
3246     t = System.currentTimeMillis();
3247     gg = bbpar.GB(ff);
3248     t = System.currentTimeMillis() - t;
3249     bbpar.terminate();
3250     puts "parallel-old #{th} executed in #{t} ms\n"; 
3251     return SimIdeal.new(@ring,"",gg);
3252 end
paramideal() click to toggle source

Create an ideal in a polynomial ring with parameter coefficients.

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

Compute primary decomposition of this ideal.

     # File examples/jas.rb
3577     def primaryDecomp()
3578         ii = Ideal.new(@pset);
3579 ##         if @prime == nil:
3580 ##             @prime = I.primeDecomposition();
3581         @primary = ii.primaryDecomposition();
3582         return @primary;
3583     end
primeDecomp() click to toggle source

Compute prime decomposition of this ideal.

     # File examples/jas.rb
3568 def primeDecomp()
3569     ii = Ideal.new(@pset);
3570     @prime = ii.primeDecomposition();
3571     return @prime;
3572 end
radicalDecomp() click to toggle source

Compute radical decomposition of this ideal.

     # File examples/jas.rb
3519 def radicalDecomp()
3520     ii = Ideal.new(@pset);
3521     @radical = ii.radicalDecomposition();
3522     return @radical;
3523 end
realRoots() click to toggle source

Compute real roots of 0-dim ideal.

     # File examples/jas.rb
3488 def realRoots()
3489     ii = Ideal.new(@pset);
3490     @roots = PolyUtilApp.realAlgebraicRoots(ii);
3491     for r in @roots
3492         r.doDecimalApproximation();
3493     end
3494     return @roots;
3495 end
realRootsPrint() click to toggle source

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

     # File examples/jas.rb
3500 def realRootsPrint()
3501     if @roots == nil
3502         ii = Ideal.new(@pset);
3503         @roots = PolyUtilApp.realAlgebraicRoots(ii);
3504         for r in @roots
3505             r.doDecimalApproximation();
3506         end
3507     end
3508     for ir in @roots
3509         for dr in ir.decimalApproximation()
3510             puts dr.to_s;
3511         end
3512         puts;
3513     end
3514 end
reduction(p) click to toggle source

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

     # File examples/jas.rb
3320 def reduction(p)
3321     s = @pset;
3322     gg = s.list;
3323     if p.is_a? RingElem
3324         p = p.elem;
3325     end
3326     #t = System.currentTimeMillis();
3327     if @ring.ring.coFac.isField()
3328        n = ReductionSeq.new().normalform(gg,p);
3329     else 
3330        n = PseudoReductionSeq.new().normalform(gg,p);
3331        #ff = PseudoReductionSeq.New().normalformFactor(gg,p);
3332        #print "ff.multiplicator = " + str(ff.multiplicator)
3333     end
3334     #t = System.currentTimeMillis() - t;
3335     #puts "sequential reduction executed in " + str(t) + " ms";
3336     return RingElem.new(n);
3337 end
sat(id2) click to toggle source

Compute the saturation of this and the given ideal.

     # File examples/jas.rb
3434 def sat(id2)
3435     s1 = Ideal.new(@pset);
3436     s2 = Ideal.new(id2.pset);
3437     #nn = s1.infiniteQuotient(s2);
3438     nn = s1.infiniteQuotientRab(s2);
3439     mm = nn.getList(); #PolyUtil.monicRec(nn.getList());
3440     return SimIdeal.new(@ring,"",mm);
3441 end
sum(other) click to toggle source

Compute the sum of this and the ideal.

     # File examples/jas.rb
3446 def sum(other)
3447     s = Ideal.new(@pset);
3448     t = Ideal.new(other.pset);
3449     nn = s.sum( t );
3450     return SimIdeal.new(@ring,"",nn.getList());
3451 end
syzygy() click to toggle source

Syzygy of generating polynomials.

     # File examples/jas.rb
3673 def syzygy()
3674     p = @pset;
3675     l = p.list;
3676     t = System.currentTimeMillis();
3677     s = SyzygySeq.new(p.ring.coFac).zeroRelations( l );
3678     t = System.currentTimeMillis() - t;
3679     puts "executed Syzygy in #{t} ms\n"; 
3680     m = CommutativeModule.new("",p.ring);
3681     return SubModule.new(m,"",s);
3682 end
toInteger() click to toggle source

Convert rational coefficients to integer coefficients.

     # File examples/jas.rb
3588 def toInteger()
3589     p = @pset;
3590     l = p.list;
3591     r = p.ring;
3592     ri = GenPolynomialRing.new( BigInteger.new(), r.nvar, r.tord, r.vars );
3593     pi = PolyUtil.integerFromRationalCoefficients(ri,l);
3594     r = Ring.new("",ri);
3595     return SimIdeal.new(r,"",pi);
3596 end
toModular(mf) click to toggle source

Convert integer coefficients to modular coefficients.

     # File examples/jas.rb
3601 def toModular(mf)
3602     p = @pset;
3603     l = p.list;
3604     r = p.ring;
3605     if mf.is_a? RingElem
3606         mf = mf.ring;
3607     end
3608     rm = GenPolynomialRing.new( mf, r.nvar, r.tord, r.vars );
3609     pm = PolyUtil.fromIntegerCoefficients(rm,l);
3610     r = Ring.new("",rm);
3611     return SimIdeal.new(r,"",pm);
3612 end
to_s() click to toggle source

Create a string representation.

     # File examples/jas.rb
3068 def to_s()
3069     return @pset.toScript();
3070 end
univariates() click to toggle source

Compute the univariate polynomials in each variable of this ideal.

     # File examples/jas.rb
3456 def univariates()
3457     s = Ideal.new(@pset);
3458     ll = s.constructUnivariate();
3459     nn = ll.map {|e| RingElem.new(e) };
3460     return nn;
3461 end