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 = GenSolvablePolynomialRing.new(cf,nv,to,names); 4149 #ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names); 4150 #ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 4151 ring = ResidueSolvableWordPolynomialRing.new(cf,nv,to,names); 4152 puts "ring = #{ring.toScript()}"; 4153 table = ring.table; 4154 coeffTable = ring.polCoeff.coeffTable; 4155 elsif resSolv 4156 puts "ResidueSolvablePolynomialRing: " + cfs; 4157 #ring = ResidueSolvablePolynomialRing.new(cf,nv,to,names); 4158 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 4159 table = ring.table; 4160 coeffTable = ring.polCoeff.coeffTable; 4161 elsif quotSolv 4162 puts "QuotSolvablePolynomialRing: " + cfs; 4163 #ring = QuotSolvablePolynomialRing.new(cf,nv,to,names); 4164 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 4165 table = ring.table; 4166 coeffTable = ring.polCoeff.coeffTable; 4167 elsif locSolv 4168 puts "LocalSolvablePolynomialRing: " + cfs; 4169 #ring = LocalSolvablePolynomialRing.new(cf,nv,to,names); 4170 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 4171 table = ring.table; 4172 coeffTable = ring.polCoeff.coeffTable; 4173 elsif locresSolv 4174 puts "QLRSolvablePolynomialRing: " + cfs; 4175 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 4176 table = ring.table; 4177 coeffTable = ring.polCoeff.coeffTable; 4178 else 4179 puts "GenSolvablePolynomialRing: " + cfs; 4180 ring = GenSolvablePolynomialRing.new(cf,nv,to,names); 4181 table = ring.table; 4182 coeffTable = table; 4183 end 4184 #puts "ll = " + str(ll); 4185 (0..ll.size-1).step(3) { |i| 4186 puts "adding relation: " + str(ll[i]) + " * " + str(ll[i+1]) + " = " + str(ll[i+2]); 4187 if ll[i+1].isConstant() 4188 if recSolv 4189 #puts "r coeff type " + str(ll[i].class); 4190 #coeffTable.update( ll[i], ll[i+1].leadingBaseCoefficient(), ll[i+2] ); 4191 coeffTable.update( ll[i], ll[i+1], ll[i+2] ); 4192 elsif recSolvWord 4193 #puts "rw coeff type " + str(ll[i].class); 4194 coeffTable.update( ll[i], ll[i+1], ll[i+2] ); 4195 elsif resWord 4196 #puts "rw coeff type " + str(ll[i].class); 4197 coeffTable.update( ring.toPolyCoefficients(ll[i]), 4198 ring.toPolyCoefficients(ll[i+1]), 4199 ring.toPolyCoefficients(ll[i+2]) ); 4200 elsif resSolv 4201 #puts "ri coeff type " + str(ll[i].class); 4202 coeffTable.update( ring.toPolyCoefficients(ll[i]), 4203 ring.toPolyCoefficients(ll[i+1]), 4204 ring.toPolyCoefficients(ll[i+2]) ); 4205 elsif quotSolv 4206 #puts "q coeff type " + str(ll[i].class); 4207 coeffTable.update( ring.toPolyCoefficients(ll[i]), 4208 ring.toPolyCoefficients(ll[i+1]), 4209 ring.toPolyCoefficients(ll[i+2]) ); 4210 elsif locSolv 4211 #puts "l coeff type " + str(ll[i].class); 4212 coeffTable.update( ring.toPolyCoefficients(ll[i]), 4213 ring.toPolyCoefficients(ll[i+1]), 4214 ring.toPolyCoefficients(ll[i+2]) ); 4215 elsif locresSolv 4216 #puts "lr coeff type " + str(ll[i].class); 4217 coeffTable.update( ring.toPolyCoefficients(ll[i]), 4218 ring.toPolyCoefficients(ll[i+1]), 4219 ring.toPolyCoefficients(ll[i+2]) ); 4220 end 4221 else # no coeff relation 4222 #puts "ll[i], ll[i+1], ll[i+2]: " + str(ll[i]) + ", " + str(ll[i+1]) + ", " + str(ll[i+2]); 4223 #puts "poly type " + str(ll[i].class); 4224 table.update( ll[i], ll[i+1], ll[i+2] ); 4225 if locresSolv or locSolv or quotSolv or resSolv or resWord 4226 #puts "ring.polCoeff.table " + str(ring.polCoeff.table.toScript()); 4227 ring.polCoeff.table.update( ring.toPolyCoefficients(ll[i]), 4228 ring.toPolyCoefficients(ll[i+1]), 4229 ring.toPolyCoefficients(ll[i+2]) ); 4230 end 4231 end 4232 } 4233 #puts "ring " + ring.toScript(); 4234 #puts "isAssoc " + str(ring.isAssociative()); 4235 @ring = ring; 4236 #puts "SolvPolyRing to super()"; 4237 super("",@ring) 4238 # puts "ai = " + self.class.auto_inject.to_s 4239 # done in super(): 4240 #if self.class.auto_inject or self.class.superclass.auto_inject 4241 # inject_variables(); 4242 #end 4243 end
Public Instance Methods
to_s()
click to toggle source
Create a string representation.
# File examples/jas.rb 4248 def to_s() 4249 return @ring.toScript(); 4250 end