class JAS::SolvPolyRing

Represents a JAS solvable polynomial ring: GenSolvablePolynomialRing.

Provides more convenient constructor. Then returns a Ring.

Attributes

auto_inject[RW]

inject variables into environment

auto_lowervar[RW]

avoid capital letter variables

Public Class Methods

new(coeff,vars,order,rel=[]) click to toggle source

Ring constructor.

coeff = factory for coefficients, vars = string with variable names, order = term order, rel = triple list of relations. (e,f,p,…) with e * f = p as relation.

Calls superclass method JAS::SolvableRing::new
     # File examples/jas.rb
4230 def initialize(coeff,vars,order,rel=[])
4231     if coeff == nil
4232         raise ArgumentError, "No coefficient given."
4233     end
4234     cf = coeff;
4235     if coeff.is_a? RingElem
4236         cf = coeff.elem.factory();
4237     end
4238     if coeff.is_a? Ring
4239         cf = coeff.ring;
4240     end
4241     if vars == nil
4242         raise ArgumentError, "No variable names given."
4243     end
4244     names = vars;
4245     if vars.is_a? String
4246         names = GenPolynomialTokenizer.variableList(vars);
4247     end
4248     nv = names.size;
4249     #to = PolyRing.lex;
4250     to = PolyRing.grad;
4251     if order.is_a? TermOrder
4252         to = order;
4253     end
4254     if order.is_a? Array # ruby has no keyword params
4255         rel = order;
4256     end
4257     ll = [];
4258     for x in rel
4259         if x.is_a? RingElem
4260            x = x.elem;
4261         end
4262         ll << x;
4263     end
4264     constSolv = false;
4265     (0..ll.size-1).step(3) { |i|
4266         #puts "ll[i+1] = #{ll[i+1]}"
4267         if ll[i+1].isConstant()
4268            constSolv = true;
4269         end
4270     }
4271     #puts "constSolv = #{constSolv}"
4272     cfs = cf.toScript();
4273     if cfs[0] == "0"
4274        cfs = cf.toScriptFactory();
4275     end
4276     #puts "cf = #{cfs}"
4277     recSolv = cf.is_a? GenPolynomialRing
4278     recSolvWord = cf.is_a? GenWordPolynomialRing
4279     resWord = cf.is_a? WordResidueRing
4280     quotSolv = cf.is_a? SolvableQuotientRing
4281     resSolv = cf.is_a? SolvableResidueRing
4282     locSolv = cf.is_a? SolvableLocalRing
4283     locresSolv = cf.is_a? SolvableLocalResidueRing
4284     if recSolv and not constSolv
4285        recSolv = false;
4286     end
4287     #puts "cf = " + cf.getClass().to_s + ", quotSolv = " + quotSolv.to_s + ", recSolv = " + recSolv.to_s;
4288     if recSolv
4289        puts "RecSolvablePolynomialRing: " + cfs;
4290        ring = RecSolvablePolynomialRing.new(cf,nv,to,names);
4291        table = ring.table;
4292        coeffTable = ring.coeffTable;
4293     elsif recSolvWord
4294        puts "RecSolvableWordPolynomialRing: " + cfs;
4295        ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names);
4296        table = ring.table;
4297        coeffTable = ring.coeffTable;
4298     elsif resWord
4299        puts "ResWordSolvablePolynomialRing: " + cfs;
4300        #ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names);
4301        ring = ResidueSolvableWordPolynomialRing.new(cf,nv,to,names);
4302        #puts "ring = #{ring.toScript()}";
4303        table = ring.table;
4304        coeffTable = ring.polCoeff.coeffTable;
4305     elsif resSolv
4306        puts "ResidueSolvablePolynomialRing: " + cfs;
4307        #ring = ResidueSolvablePolynomialRing.new(cf,nv,to,names);
4308        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4309        table = ring.table;
4310        coeffTable = ring.polCoeff.coeffTable;
4311     elsif quotSolv
4312        puts "QuotSolvablePolynomialRing: " + cfs;
4313        #ring = QuotSolvablePolynomialRing.new(cf,nv,to,names);
4314        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4315        table = ring.table;
4316        coeffTable = ring.polCoeff.coeffTable;
4317     elsif locSolv
4318        puts "LocalSolvablePolynomialRing: " + cfs;
4319        #ring = LocalSolvablePolynomialRing.new(cf,nv,to,names);
4320        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4321        table = ring.table;
4322        coeffTable = ring.polCoeff.coeffTable;
4323     elsif locresSolv
4324        puts "LocalResidueSolvablePolynomialRing: " + cfs;
4325        #puts "QLRSolvablePolynomialRing: " + cfs;
4326        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4327        table = ring.table;
4328        coeffTable = ring.polCoeff.coeffTable;
4329     else
4330        puts "GenSolvablePolynomialRing: " + cfs;
4331        ring = GenSolvablePolynomialRing.new(cf,nv,to,names);
4332        table = ring.table;
4333        coeffTable = table;
4334     end
4335     #puts "ll = " + str(ll);
4336     (0..ll.size-1).step(3) { |i|
4337         puts "adding relation: " + str(ll[i]) + " * " + str(ll[i+1]) + " = " + str(ll[i+2]);
4338         if ll[i+1].isConstant() 
4339            if recSolv or recSolvWord
4340               #puts "r coeff type " + str(ll[i].class);
4341               #coeffTable.update( ll[i], ll[i+1].leadingBaseCoefficient(), ll[i+2] );
4342               coeffTable.update( ll[i], ll[i+1], ll[i+2] );
4343            elsif resWord or resSolv or quotSolv or locSolv or locresSolv
4344               #puts "rw coeff type " + str(ll[i].class);
4345               coeffTable.update( ring.toPolyCoefficients(ll[i]),
4346                                  ring.toPolyCoefficients(ll[i+1]), 
4347                                  ring.toPolyCoefficients(ll[i+2]) );
4348             end
4349         else # no coeff relation
4350             #puts "ll[i], ll[i+1], ll[i+2]: " + str(ll[i]) + ", " + str(ll[i+1]) + ", " + str(ll[i+2]);
4351             #puts "poly type " + str(ll[i].class);
4352             table.update( ll[i], ll[i+1], ll[i+2] );
4353             if locresSolv or locSolv or quotSolv or resSolv or resWord
4354                #puts "ring.polCoeff.table " + str(ring.polCoeff.table.toScript());
4355                ring.polCoeff.table.update( ring.toPolyCoefficients(ll[i]),
4356                                            ring.toPolyCoefficients(ll[i+1]), 
4357                                            ring.toPolyCoefficients(ll[i+2]) );
4358             end
4359         end
4360     }
4361     #puts "ring " + ring.toScript();
4362     #puts "isAssoc " + str(ring.isAssociative());
4363     @ring = ring;
4364     #puts "SolvPolyRing to super()";
4365     super("",@ring)
4366     # puts "ai = " +  self.class.auto_inject.to_s
4367     # done in super():
4368     #if self.class.auto_inject or self.class.superclass.auto_inject
4369     #   inject_variables();
4370     #end
4371 end

Public Instance Methods

to_s() click to toggle source

Create a string representation.

     # File examples/jas.rb
4376 def to_s()
4377     return @ring.toScript();
4378 end