# File examples/jas.rb 3336 def primaryDecomp() 3337 ii = Ideal.new(@pset); 3338 ## if @prime == nil: 3339 ## @prime = I.primeDecomposition(); 3340 @primary = ii.primaryDecomposition(); 3341 return @primary; 3342 end
class JAS::SimIdeal
Represents a JAS polynomial ideal: PolynomialList and Ideal.
Methods for Groebner bases, ideal sum, intersection and others.
Attributes
the Java polynomial list, polynomial ring, and ideal decompositions
the Java polynomial list, polynomial ring, and ideal decompositions
the Java polynomial list, polynomial ring, and ideal decompositions
the Java polynomial list, polynomial ring, and ideal decompositions
the Java polynomial list, polynomial ring, and ideal decompositions
the Java polynomial list, polynomial ring, and ideal decompositions
Public Class Methods
SimIdeal constructor.
# File examples/jas.rb 2805 def initialize(ring,polystr="",list=nil) 2806 @ring = ring; 2807 if list == nil 2808 sr = StringReader.new( polystr ); 2809 tok = GenPolynomialTokenizer.new(ring::ring,sr); 2810 @list = tok.nextPolynomialList(); 2811 else 2812 @list = rbarray2arraylist(list,rec=1); 2813 end 2814 #@list = PolyUtil.monic(@list); 2815 @pset = OrderedPolynomialList.new(@ring.ring,@list); 2816 #@ideal = Ideal.new(@pset); 2817 @roots = nil; 2818 @croots = nil; 2819 @prime = nil; 2820 @primary = nil; 2821 #super(@ring::ring,@list) # non-sense, JRuby extends application.Ideal 2822 end
Public Instance Methods
Compare two ideals.
# File examples/jas.rb 2834 def <=>(other) 2835 s = Ideal.new(@pset); 2836 o = Ideal.new(other.pset); 2837 return s.compareTo(o); 2838 end
Test if two ideals are equal.
# File examples/jas.rb 2843 def ==(other) 2844 if not other.is_a? SimIdeal 2845 return false; 2846 end 2847 return (self <=> other) == 0; 2848 end
Compute a Characteristic Set.
# File examples/jas.rb 3376 def CS() 3377 s = @pset; 3378 cofac = s.ring.coFac; 3379 ff = s.list; 3380 t = System.currentTimeMillis(); 3381 if cofac.isField() 3382 gg = CharacteristicSetWu.new().characteristicSet(ff); 3383 else 3384 puts "CS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 3385 gg = nil; 3386 end 3387 t = System.currentTimeMillis() - t; 3388 puts "sequential char set executed in #{t} ms\n"; 3389 return SimIdeal.new(@ring,"",gg); 3390 end
Compute a Groebner base.
# File examples/jas.rb 2876 def GB() 2877 #if @ideal != nil 2878 # return SimIdeal.new(@ring,"",nil,@ideal.GB()); 2879 #end 2880 cofac = @ring.ring.coFac; 2881 ff = @pset.list; 2882 kind = ""; 2883 t = System.currentTimeMillis(); 2884 if cofac.isField() 2885 #gg = GroebnerBaseSeq.new().GB(ff); 2886 #gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedPairlist.new()).GB(ff); 2887 gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff); 2888 #gg = GroebnerBaseSeqIter.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff); 2889 kind = "field" 2890 else 2891 if cofac.is_a? GenPolynomialRing and cofac.isCommutative() 2892 gg = GroebnerBasePseudoRecSeq.new(cofac).GB(ff); 2893 kind = "pseudoRec" 2894 else 2895 gg = GroebnerBasePseudoSeq.new(cofac).GB(ff); 2896 kind = "pseudo" 2897 end 2898 end 2899 t = System.currentTimeMillis() - t; 2900 puts "sequential(#{kind}) GB executed in #{t} ms\n"; 2901 return SimIdeal.new(@ring,"",gg); 2902 end
Compute a normal form of this ideal with respect to reducer.
# File examples/jas.rb 3117 def NF(reducer) 3118 s = @pset; 3119 ff = s.list; 3120 gg = reducer.list; 3121 t = System.currentTimeMillis(); 3122 nn = ReductionSeq.new().normalform(gg,ff); 3123 t = System.currentTimeMillis() - t; 3124 puts "sequential NF executed in #{t} ms\n"; 3125 return SimIdeal.new(@ring,"",nn); 3126 end
Compute complex roots of 0-dim ideal.
# File examples/jas.rb 3296 def complexRoots() 3297 ii = Ideal.new(@pset); 3298 @croots = PolyUtilApp.complexAlgebraicRoots(ii); 3299 for r in @croots 3300 r.doDecimalApproximation(); 3301 end 3302 return @croots; 3303 end
Print decimal approximation of complex roots of 0-dim ideal.
# File examples/jas.rb 3308 def complexRootsPrint() 3309 if @croots == nil 3310 ii = Ideal.new(@pset); 3311 @croots = PolyUtilApp.complexAlgebraicRoots(ii); 3312 for r in @croots 3313 r.doDecimalApproximation(); 3314 end 3315 end 3316 for ic in @croots 3317 for dc in ic.decimalApproximation() 3318 puts dc.to_s; 3319 end 3320 puts; 3321 end 3322 end
Compute a normal form of polynomial p with respect this characteristic set.
# File examples/jas.rb 3415 def csReduction(p) 3416 s = @pset; 3417 ff = s.list.clone(); 3418 Collections.reverse(ff); # todo 3419 if p.is_a? RingElem 3420 p = p.elem; 3421 end 3422 t = System.currentTimeMillis(); 3423 nn = CharacteristicSetWu.new().characteristicSetReduction(ff,p); 3424 t = System.currentTimeMillis() - t; 3425 #puts "sequential char set reduction executed in #{t} ms\n"; 3426 return RingElem.new(nn); 3427 end
Compute an d-Groebner base.
# File examples/jas.rb 2965 def dGB() 2966 s = @pset; 2967 cofac = s.ring.coFac; 2968 ff = s.list; 2969 t = System.currentTimeMillis(); 2970 if cofac.isField() 2971 gg = GroebnerBaseSeq.new().GB(ff); 2972 else 2973 gg = DGroebnerBaseSeq.new().GB(ff) 2974 end 2975 t = System.currentTimeMillis() - t; 2976 puts "sequential d-GB executed in #{t} ms\n"; 2977 return SimIdeal.new(@ring,"",gg); 2978 end
Compute irreducible decomposition of this ideal.
# File examples/jas.rb 3287 def decomposition() 3288 ii = Ideal.new(@pset); 3289 @irrdec = ii.decomposition(); 3290 return @irrdec; 3291 end
Client for a distributed computation.
# File examples/jas.rb 3055 def distClient(port=4711) 3056 s = @pset; 3057 e1 = ExecutableServer.new( port ); 3058 e1.init(); 3059 e2 = ExecutableServer.new( port+1 ); 3060 e2.init(); 3061 @exers = [e1,e2]; 3062 return nil; 3063 end
Client for a distributed computation.
# File examples/jas.rb 3069 def distClientStop() 3070 for es in @exers; 3071 es.terminate(); 3072 end 3073 return nil; 3074 end
Compute on a distributed system a Groebner base.
# File examples/jas.rb 3036 def distGB(th=2,machine="examples/machines.localhost",port=55711) 3037 s = @pset; 3038 ff = s.list; 3039 t = System.currentTimeMillis(); 3040 # old: gbd = GBDist.new(th,machine,port); 3041 gbd = GroebnerBaseDistributedEC.new(machine,th,port); 3042 #gbd = GroebnerBaseDistributedHybridEC.new(machine,th,3,port); 3043 t1 = System.currentTimeMillis(); 3044 gg = gbd.GB(ff); 3045 t1 = System.currentTimeMillis() - t1; 3046 gbd.terminate(false); 3047 t = System.currentTimeMillis() - t; 3048 puts "distributed #{th} executed in #{t1} ms (#{t-t1} ms start-up)\n"; 3049 return SimIdeal.new(@ring,"",gg); 3050 end
Compute an e-Groebner base.
# File examples/jas.rb 2929 def eGB() 2930 s = @pset; 2931 cofac = s.ring.coFac; 2932 ff = s.list; 2933 t = System.currentTimeMillis(); 2934 if cofac.isField() 2935 gg = GroebnerBaseSeq.new().GB(ff); 2936 else 2937 gg = EGroebnerBaseSeq.new().GB(ff) 2938 end 2939 t = System.currentTimeMillis() - t; 2940 puts "sequential e-GB executed in #{t} ms\n"; 2941 return SimIdeal.new(@ring,"",gg); 2942 end
Compute a e-normal form of p with respect to this ideal.
# File examples/jas.rb 3101 def eReduction(p) 3102 s = @pset; 3103 gg = s.list; 3104 if p.is_a? RingElem 3105 p = p.elem; 3106 end 3107 t = System.currentTimeMillis(); 3108 n = EReductionSeq.new().normalform(gg,p); 3109 t = System.currentTimeMillis() - t; 3110 puts "sequential eReduction executed in " + str(t) + " ms"; 3111 return RingElem.new(n); 3112 end
Compute the elimination ideal of this and the given polynomial ring.
# File examples/jas.rb 3183 def eliminateRing(ring) 3184 s = Ideal.new(@pset); 3185 nn = s.eliminate(ring.ring); 3186 r = Ring.new( "", nn.getRing() ); 3187 return SimIdeal.new(r,"",nn.getList()); 3188 end
Compute a interreduced ideal basis of this.
# File examples/jas.rb 3155 def interreduced_basis() 3156 ff = @pset.list; 3157 nn = ReductionSeq.new().irreducibleSet(ff); 3158 return nn.map{ |x| RingElem.new(x) }; 3159 end
Compute the intersection of this and the given ideal.
# File examples/jas.rb 3173 def intersect(id2) 3174 s1 = Ideal.new(@pset); 3175 s2 = Ideal.new(id2.pset); 3176 nn = s1.intersect(s2); 3177 return SimIdeal.new(@ring,"",nn.getList()); 3178 end
Compute the intersection of this and the given polynomial ring.
# File examples/jas.rb 3164 def intersectRing(ring) 3165 s = Ideal.new(@pset); 3166 nn = s.intersect(ring.ring); 3167 return SimIdeal.new(ring,"",nn.getList()); 3168 end
Compute the inverse polynomial modulo this ideal, if it exists.
# File examples/jas.rb 3225 def inverse(p) 3226 if p.is_a? RingElem 3227 p = p.elem; 3228 end 3229 s = Ideal.new(@pset); 3230 i = s.inverse(p); 3231 return RingElem.new(i); 3232 end
Test for Characteristic Set.
# File examples/jas.rb 3395 def isCS() 3396 s = @pset; 3397 cofac = s.ring.coFac; 3398 ff = s.list.clone(); 3399 Collections.reverse(ff); # todo 3400 t = System.currentTimeMillis(); 3401 if cofac.isField() 3402 b = CharacteristicSetWu.new().isCharacteristicSet(ff); 3403 else 3404 puts "isCS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 3405 b = false; 3406 end 3407 t = System.currentTimeMillis() - t; 3408 #puts "sequential is char set executed in #{t} ms\n"; 3409 return b; 3410 end
Test if this is a Groebner base.
# File examples/jas.rb 2907 def isGB() 2908 s = @pset; 2909 cofac = s.ring.coFac; 2910 ff = s.list; 2911 t = System.currentTimeMillis(); 2912 if cofac.isField() 2913 b = GroebnerBaseSeq.new().isGB(ff); 2914 else 2915 if cofac.is_a? GenPolynomialRing and cofac.isCommutative() 2916 b = GroebnerBasePseudoRecSeq.new(cofac).isGB(ff); 2917 else 2918 b = GroebnerBasePseudoSeq.new(cofac).isGB(ff); 2919 end 2920 end 2921 t = System.currentTimeMillis() - t; 2922 puts "isGB = #{b} executed in #{t} ms\n"; 2923 return b; 2924 end
Test if ideal is one.
# File examples/jas.rb 2853 def isONE() 2854 s = Ideal.new(@pset); 2855 return s.isONE(); 2856 end
Test if this is a syzygy of the module in m.
# File examples/jas.rb 3446 def isSyzygy(m) 3447 p = @pset; 3448 g = p.list; 3449 l = m.list; 3450 #puts "l = #{l}"; 3451 #puts "g = #{g}"; 3452 t = System.currentTimeMillis(); 3453 z = SyzygySeq.new(p.ring.coFac).isZeroRelation( l, g ); 3454 t = System.currentTimeMillis() - t; 3455 puts "executed isSyzygy in #{t} ms\n"; 3456 return z; 3457 end
Test if ideal is zero.
# File examples/jas.rb 2861 def isZERO() 2862 s = Ideal.new(@pset); 2863 return s.isZERO(); 2864 end
Test if this is a d-Groebner base.
# File examples/jas.rb 2983 def isdGB() 2984 s = @pset; 2985 cofac = s.ring.coFac; 2986 ff = s.list; 2987 t = System.currentTimeMillis(); 2988 if cofac.isField() 2989 b = GroebnerBaseSeq.new().isGB(ff); 2990 else 2991 b = DGroebnerBaseSeq.new().isGB(ff) 2992 end 2993 t = System.currentTimeMillis() - t; 2994 puts "is d-GB = #{b} executed in #{t} ms\n"; 2995 return b; 2996 end
Test if this is an e-Groebner base.
# File examples/jas.rb 2947 def iseGB() 2948 s = @pset; 2949 cofac = s.ring.coFac; 2950 ff = s.list; 2951 t = System.currentTimeMillis(); 2952 if cofac.isField() 2953 b = GroebnerBaseSeq.new().isGB(ff); 2954 else 2955 b = EGroebnerBaseSeq.new().isGB(ff) 2956 end 2957 t = System.currentTimeMillis() - t; 2958 puts "is e-GB = #{b} executed in #{t} ms\n"; 2959 return b; 2960 end
Represent p as element of this ideal.
# File examples/jas.rb 3131 def lift(p) 3132 gg = @pset.list; 3133 z = @ring.ring.getZERO(); 3134 rr = gg.map { |x| z }; 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(rr,gg,p); 3141 else 3142 n = PseudoReductionSeq.new().normalform(rr,gg,p); 3143 end 3144 if not n.isZERO() 3145 raise StandardError, "p ist not a member of the ideal" 3146 end 3147 #t = System.currentTimeMillis() - t; 3148 #puts "sequential reduction executed in " + str(t) + " ms"; 3149 return rr.map { |x| RingElem.new(x) }; 3150 end
Optimize the term order on the variables.
# File examples/jas.rb 3237 def optimize() 3238 p = @pset; 3239 o = TermOrderOptimization.optimizeTermOrder(p); 3240 r = Ring.new("",o.ring); 3241 return SimIdeal.new(r,"",o.list); 3242 end
Compute in parallel a Groebner base.
# File examples/jas.rb 3016 def parGB(th) 3017 s = @pset; 3018 ff = s.list; 3019 cofac = s.ring.coFac; 3020 if cofac.isField() 3021 bbpar = GroebnerBaseParallel.new(th); 3022 else 3023 bbpar = GroebnerBasePseudoParallel.new(th,cofac); 3024 end 3025 t = System.currentTimeMillis(); 3026 gg = bbpar.GB(ff); 3027 t = System.currentTimeMillis() - t; 3028 bbpar.terminate(); 3029 puts "parallel #{th} executed in #{t} ms\n"; 3030 return SimIdeal.new(@ring,"",gg); 3031 end
Compute in parallel a Groebner base.
# File examples/jas.rb 3001 def parUnusedGB(th) 3002 s = @pset; 3003 ff = s.list; 3004 bbpar = GroebnerBaseSeqPairParallel.new(th); 3005 t = System.currentTimeMillis(); 3006 gg = bbpar.GB(ff); 3007 t = System.currentTimeMillis() - t; 3008 bbpar.terminate(); 3009 puts "parallel-old #{th} executed in #{t} ms\n"; 3010 return SimIdeal.new(@ring,"",gg); 3011 end
Create an ideal in a polynomial ring with parameter coefficients.
# File examples/jas.rb 2869 def paramideal() 2870 return ParamIdeal.new(@ring,"",@list); 2871 end
Compute primary decomposition of this ideal.
Compute prime decomposition of this ideal.
# File examples/jas.rb 3327 def primeDecomp() 3328 ii = Ideal.new(@pset); 3329 @prime = ii.primeDecomposition(); 3330 return @prime; 3331 end
Compute radical decomposition of this ideal.
# File examples/jas.rb 3278 def radicalDecomp() 3279 ii = Ideal.new(@pset); 3280 @radical = ii.radicalDecomposition(); 3281 return @radical; 3282 end
Compute real roots of 0-dim ideal.
# File examples/jas.rb 3247 def realRoots() 3248 ii = Ideal.new(@pset); 3249 @roots = PolyUtilApp.realAlgebraicRoots(ii); 3250 for r in @roots 3251 r.doDecimalApproximation(); 3252 end 3253 return @roots; 3254 end
Print decimal approximation of real roots of 0-dim ideal.
# File examples/jas.rb 3259 def realRootsPrint() 3260 if @roots == nil 3261 ii = Ideal.new(@pset); 3262 @roots = PolyUtilApp.realAlgebraicRoots(ii); 3263 for r in @roots 3264 r.doDecimalApproximation(); 3265 end 3266 end 3267 for ir in @roots 3268 for dr in ir.decimalApproximation() 3269 puts dr.to_s; 3270 end 3271 puts; 3272 end 3273 end
Compute a normal form of p with respect to this ideal.
# File examples/jas.rb 3079 def reduction(p) 3080 s = @pset; 3081 gg = s.list; 3082 if p.is_a? RingElem 3083 p = p.elem; 3084 end 3085 #t = System.currentTimeMillis(); 3086 if @ring.ring.coFac.isField() 3087 n = ReductionSeq.new().normalform(gg,p); 3088 else 3089 n = PseudoReductionSeq.new().normalform(gg,p); 3090 #ff = PseudoReductionSeq.New().normalformFactor(gg,p); 3091 #print "ff.multiplicator = " + str(ff.multiplicator) 3092 end 3093 #t = System.currentTimeMillis() - t; 3094 #puts "sequential reduction executed in " + str(t) + " ms"; 3095 return RingElem.new(n); 3096 end
Compute the saturation of this and the given ideal.
# File examples/jas.rb 3193 def sat(id2) 3194 s1 = Ideal.new(@pset); 3195 s2 = Ideal.new(id2.pset); 3196 #nn = s1.infiniteQuotient(s2); 3197 nn = s1.infiniteQuotientRab(s2); 3198 mm = nn.getList(); #PolyUtil.monicRec(nn.getList()); 3199 return SimIdeal.new(@ring,"",mm); 3200 end
Compute the sum of this and the ideal.
# File examples/jas.rb 3205 def sum(other) 3206 s = Ideal.new(@pset); 3207 t = Ideal.new(other.pset); 3208 nn = s.sum( t ); 3209 return SimIdeal.new(@ring,"",nn.getList()); 3210 end
Syzygy of generating polynomials.
# File examples/jas.rb 3432 def syzygy() 3433 p = @pset; 3434 l = p.list; 3435 t = System.currentTimeMillis(); 3436 s = SyzygySeq.new(p.ring.coFac).zeroRelations( l ); 3437 t = System.currentTimeMillis() - t; 3438 puts "executed Syzygy in #{t} ms\n"; 3439 m = CommutativeModule.new("",p.ring); 3440 return SubModule.new(m,"",s); 3441 end
Convert rational coefficients to integer coefficients.
# File examples/jas.rb 3347 def toInteger() 3348 p = @pset; 3349 l = p.list; 3350 r = p.ring; 3351 ri = GenPolynomialRing.new( BigInteger.new(), r.nvar, r.tord, r.vars ); 3352 pi = PolyUtil.integerFromRationalCoefficients(ri,l); 3353 r = Ring.new("",ri); 3354 return SimIdeal.new(r,"",pi); 3355 end
Convert integer coefficients to modular coefficients.
# File examples/jas.rb 3360 def toModular(mf) 3361 p = @pset; 3362 l = p.list; 3363 r = p.ring; 3364 if mf.is_a? RingElem 3365 mf = mf.ring; 3366 end 3367 rm = GenPolynomialRing.new( mf, r.nvar, r.tord, r.vars ); 3368 pm = PolyUtil.fromIntegerCoefficients(rm,l); 3369 r = Ring.new("",rm); 3370 return SimIdeal.new(r,"",pm); 3371 end
Create a string representation.
# File examples/jas.rb 2827 def to_s() 2828 return @pset.toScript(); 2829 end
Compute the univariate polynomials in each variable of this ideal.
# File examples/jas.rb 3215 def univariates() 3216 s = Ideal.new(@pset); 3217 ll = s.constructUnivariate(); 3218 nn = ll.map {|e| RingElem.new(e) }; 3219 return nn; 3220 end