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
4078 def initialize(coeff,vars,order,rel=[])
4079     if coeff == nil
4080         raise ArgumentError, "No coefficient given."
4081     end
4082     cf = coeff;
4083     if coeff.is_a? RingElem
4084         cf = coeff.elem.factory();
4085     end
4086     if coeff.is_a? Ring
4087         cf = coeff.ring;
4088     end
4089     if vars == nil
4090         raise ArgumentError, "No variable names given."
4091     end
4092     names = vars;
4093     if vars.is_a? String
4094         names = GenPolynomialTokenizer.variableList(vars);
4095     end
4096     nv = names.size;
4097     #to = PolyRing.lex;
4098     to = PolyRing.grad;
4099     if order.is_a? TermOrder
4100         to = order;
4101     end
4102     if order.is_a? Array # ruby has no keyword params
4103         rel = order;
4104     end
4105     ll = [];
4106     for x in rel
4107         if x.is_a? RingElem
4108            x = x.elem;
4109         end
4110         ll << x;
4111     end
4112     constSolv = false;
4113     (0..ll.size-1).step(3) { |i|
4114         #puts "ll[i+1] = #{ll[i+1]}"
4115         if ll[i+1].isConstant()
4116            constSolv = true;
4117         end
4118     }
4119     #puts "constSolv = #{constSolv}"
4120     cfs = cf.toScript();
4121     if cfs[0] == "0"
4122        cfs = cf.toScriptFactory();
4123     end
4124     #puts "cf = #{cfs}"
4125     recSolv = cf.is_a? GenPolynomialRing
4126     recSolvWord = cf.is_a? GenWordPolynomialRing
4127     resWord = cf.is_a? WordResidueRing
4128     quotSolv = cf.is_a? SolvableQuotientRing
4129     resSolv = cf.is_a? SolvableResidueRing
4130     locSolv = cf.is_a? SolvableLocalRing
4131     locresSolv = cf.is_a? SolvableLocalResidueRing
4132     if recSolv and not constSolv
4133        recSolv = false;
4134     end
4135     #puts "cf = " + cf.getClass().to_s + ", quotSolv = " + quotSolv.to_s + ", recSolv = " + recSolv.to_s;
4136     if recSolv
4137        puts "RecSolvablePolynomialRing: " + cfs;
4138        ring = RecSolvablePolynomialRing.new(cf,nv,to,names);
4139        table = ring.table;
4140        coeffTable = ring.coeffTable;
4141     elsif recSolvWord
4142        puts "RecSolvableWordPolynomialRing: " + cfs;
4143        ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names);
4144        table = ring.table;
4145        coeffTable = ring.coeffTable;
4146     elsif resWord
4147        puts "ResWordSolvablePolynomialRing: " + cfs;
4148        #ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names);
4149        ring = ResidueSolvableWordPolynomialRing.new(cf,nv,to,names);
4150        #puts "ring = #{ring.toScript()}";
4151        table = ring.table;
4152        coeffTable = ring.polCoeff.coeffTable;
4153     elsif resSolv
4154        puts "ResidueSolvablePolynomialRing: " + cfs;
4155        #ring = ResidueSolvablePolynomialRing.new(cf,nv,to,names);
4156        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4157        table = ring.table;
4158        coeffTable = ring.polCoeff.coeffTable;
4159     elsif quotSolv
4160        puts "QuotSolvablePolynomialRing: " + cfs;
4161        #ring = QuotSolvablePolynomialRing.new(cf,nv,to,names);
4162        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4163        table = ring.table;
4164        coeffTable = ring.polCoeff.coeffTable;
4165     elsif locSolv
4166        puts "LocalSolvablePolynomialRing: " + cfs;
4167        #ring = LocalSolvablePolynomialRing.new(cf,nv,to,names);
4168        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4169        table = ring.table;
4170        coeffTable = ring.polCoeff.coeffTable;
4171     elsif locresSolv
4172        puts "LocalResidueSolvablePolynomialRing: " + cfs;
4173        #puts "QLRSolvablePolynomialRing: " + cfs;
4174        ring = QLRSolvablePolynomialRing.new(cf,nv,to,names);
4175        table = ring.table;
4176        coeffTable = ring.polCoeff.coeffTable;
4177     else
4178        puts "GenSolvablePolynomialRing: " + cfs;
4179        ring = GenSolvablePolynomialRing.new(cf,nv,to,names);
4180        table = ring.table;
4181        coeffTable = table;
4182     end
4183     #puts "ll = " + str(ll);
4184     (0..ll.size-1).step(3) { |i|
4185         puts "adding relation: " + str(ll[i]) + " * " + str(ll[i+1]) + " = " + str(ll[i+2]);
4186         if ll[i+1].isConstant() 
4187            if recSolv or recSolvWord
4188               #puts "r coeff type " + str(ll[i].class);
4189               #coeffTable.update( ll[i], ll[i+1].leadingBaseCoefficient(), ll[i+2] );
4190               coeffTable.update( ll[i], ll[i+1], ll[i+2] );
4191            elsif resWord or resSolv or quotSolv or locSolv or locresSolv
4192               #puts "rw coeff type " + str(ll[i].class);
4193               coeffTable.update( ring.toPolyCoefficients(ll[i]),
4194                                  ring.toPolyCoefficients(ll[i+1]), 
4195                                  ring.toPolyCoefficients(ll[i+2]) );
4196             end
4197         else # no coeff relation
4198             #puts "ll[i], ll[i+1], ll[i+2]: " + str(ll[i]) + ", " + str(ll[i+1]) + ", " + str(ll[i+2]);
4199             #puts "poly type " + str(ll[i].class);
4200             table.update( ll[i], ll[i+1], ll[i+2] );
4201             if locresSolv or locSolv or quotSolv or resSolv or resWord
4202                #puts "ring.polCoeff.table " + str(ring.polCoeff.table.toScript());
4203                ring.polCoeff.table.update( ring.toPolyCoefficients(ll[i]),
4204                                            ring.toPolyCoefficients(ll[i+1]), 
4205                                            ring.toPolyCoefficients(ll[i+2]) );
4206             end
4207         end
4208     }
4209     #puts "ring " + ring.toScript();
4210     #puts "isAssoc " + str(ring.isAssociative());
4211     @ring = ring;
4212     #puts "SolvPolyRing to super()";
4213     super("",@ring) 
4214     # puts "ai = " +  self.class.auto_inject.to_s
4215     # done in super():
4216     #if self.class.auto_inject or self.class.superclass.auto_inject
4217     #   inject_variables();
4218     #end
4219 end

Public Instance Methods

to_s() click to toggle source

Create a string representation.

     # File examples/jas.rb
4224 def to_s()
4225     return @ring.toScript();
4226 end