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 3837 def initialize(coeff,vars,order,rel=[]) 3838 if coeff == nil 3839 raise ArgumentError, "No coefficient given." 3840 end 3841 cf = coeff; 3842 if coeff.is_a? RingElem 3843 cf = coeff.elem.factory(); 3844 end 3845 if coeff.is_a? Ring 3846 cf = coeff.ring; 3847 end 3848 if vars == nil 3849 raise ArgumentError, "No variable names given." 3850 end 3851 names = vars; 3852 if vars.is_a? String 3853 names = GenPolynomialTokenizer.variableList(vars); 3854 end 3855 nv = names.size; 3856 #to = PolyRing.lex; 3857 to = PolyRing.grad; 3858 if order.is_a? TermOrder 3859 to = order; 3860 end 3861 if order.is_a? Array # ruby has no keyword params 3862 rel = order; 3863 end 3864 ll = []; 3865 for x in rel 3866 if x.is_a? RingElem 3867 x = x.elem; 3868 end 3869 ll << x; 3870 end 3871 constSolv = false; 3872 (0..ll.size-1).step(3) { |i| 3873 #puts "ll[i+1] = #{ll[i+1]}" 3874 if ll[i+1].isConstant() 3875 constSolv = true; 3876 end 3877 } 3878 #puts "constSolv = #{constSolv}" 3879 cfs = cf.toScript(); 3880 if cfs[0] == "0" 3881 cfs = cf.toScriptFactory(); 3882 end 3883 #puts "cf = #{cfs}" 3884 recSolv = cf.is_a? GenPolynomialRing 3885 recSolvWord = cf.is_a? GenWordPolynomialRing 3886 resWord = cf.is_a? WordResidueRing 3887 quotSolv = cf.is_a? SolvableQuotientRing 3888 resSolv = cf.is_a? SolvableResidueRing 3889 locSolv = cf.is_a? SolvableLocalRing 3890 locresSolv = cf.is_a? SolvableLocalResidueRing 3891 if recSolv and not constSolv 3892 recSolv = false; 3893 end 3894 #puts "cf = " + cf.getClass().to_s + ", quotSolv = " + quotSolv.to_s + ", recSolv = " + recSolv.to_s; 3895 if recSolv 3896 puts "RecSolvablePolynomialRing: " + cfs; 3897 ring = RecSolvablePolynomialRing.new(cf,nv,to,names); 3898 table = ring.table; 3899 coeffTable = ring.coeffTable; 3900 elsif recSolvWord 3901 puts "RecSolvableWordPolynomialRing: " + cfs; 3902 ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names); 3903 table = ring.table; 3904 coeffTable = ring.coeffTable; 3905 elsif resWord 3906 puts "ResWordSolvablePolynomialRing: " + cfs; 3907 #ring = GenSolvablePolynomialRing.new(cf,nv,to,names); 3908 #ring = RecSolvableWordPolynomialRing.new(cf,nv,to,names); 3909 #ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 3910 ring = ResidueSolvableWordPolynomialRing.new(cf,nv,to,names); 3911 puts "ring = #{ring.toScript()}"; 3912 table = ring.table; 3913 coeffTable = ring.polCoeff.coeffTable; 3914 elsif resSolv 3915 puts "ResidueSolvablePolynomialRing: " + cfs; 3916 #ring = ResidueSolvablePolynomialRing.new(cf,nv,to,names); 3917 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 3918 table = ring.table; 3919 coeffTable = ring.polCoeff.coeffTable; 3920 elsif quotSolv 3921 puts "QuotSolvablePolynomialRing: " + cfs; 3922 #ring = QuotSolvablePolynomialRing.new(cf,nv,to,names); 3923 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 3924 table = ring.table; 3925 coeffTable = ring.polCoeff.coeffTable; 3926 elsif locSolv 3927 puts "LocalSolvablePolynomialRing: " + cfs; 3928 #ring = LocalSolvablePolynomialRing.new(cf,nv,to,names); 3929 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 3930 table = ring.table; 3931 coeffTable = ring.polCoeff.coeffTable; 3932 elsif locresSolv 3933 puts "QLRSolvablePolynomialRing: " + cfs; 3934 ring = QLRSolvablePolynomialRing.new(cf,nv,to,names); 3935 table = ring.table; 3936 coeffTable = ring.polCoeff.coeffTable; 3937 else 3938 puts "GenSolvablePolynomialRing: " + cfs; 3939 ring = GenSolvablePolynomialRing.new(cf,nv,to,names); 3940 table = ring.table; 3941 coeffTable = table; 3942 end 3943 #puts "ll = " + str(ll); 3944 (0..ll.size-1).step(3) { |i| 3945 puts "adding relation: " + str(ll[i]) + " * " + str(ll[i+1]) + " = " + str(ll[i+2]); 3946 if ll[i+1].isConstant() 3947 if recSolv 3948 #puts "r coeff type " + str(ll[i].class); 3949 #coeffTable.update( ll[i], ll[i+1].leadingBaseCoefficient(), ll[i+2] ); 3950 coeffTable.update( ll[i], ll[i+1], ll[i+2] ); 3951 elsif recSolvWord 3952 #puts "rw coeff type " + str(ll[i].class); 3953 coeffTable.update( ll[i], ll[i+1], ll[i+2] ); 3954 elsif resWord 3955 #puts "rw coeff type " + str(ll[i].class); 3956 coeffTable.update( ring.toPolyCoefficients(ll[i]), 3957 ring.toPolyCoefficients(ll[i+1]), 3958 ring.toPolyCoefficients(ll[i+2]) ); 3959 elsif resSolv 3960 #puts "ri coeff type " + str(ll[i].class); 3961 coeffTable.update( ring.toPolyCoefficients(ll[i]), 3962 ring.toPolyCoefficients(ll[i+1]), 3963 ring.toPolyCoefficients(ll[i+2]) ); 3964 elsif quotSolv 3965 #puts "q coeff type " + str(ll[i].class); 3966 coeffTable.update( ring.toPolyCoefficients(ll[i]), 3967 ring.toPolyCoefficients(ll[i+1]), 3968 ring.toPolyCoefficients(ll[i+2]) ); 3969 elsif locSolv 3970 #puts "l coeff type " + str(ll[i].class); 3971 coeffTable.update( ring.toPolyCoefficients(ll[i]), 3972 ring.toPolyCoefficients(ll[i+1]), 3973 ring.toPolyCoefficients(ll[i+2]) ); 3974 elsif locresSolv 3975 #puts "lr coeff type " + str(ll[i].class); 3976 coeffTable.update( ring.toPolyCoefficients(ll[i]), 3977 ring.toPolyCoefficients(ll[i+1]), 3978 ring.toPolyCoefficients(ll[i+2]) ); 3979 end 3980 else # no coeff relation 3981 #puts "ll[i], ll[i+1], ll[i+2]: " + str(ll[i]) + ", " + str(ll[i+1]) + ", " + str(ll[i+2]); 3982 #puts "poly type " + str(ll[i].class); 3983 table.update( ll[i], ll[i+1], ll[i+2] ); 3984 if locresSolv or locSolv or quotSolv or resSolv or resWord 3985 #puts "ring.polCoeff.table " + str(ring.polCoeff.table.toScript()); 3986 ring.polCoeff.table.update( ring.toPolyCoefficients(ll[i]), 3987 ring.toPolyCoefficients(ll[i+1]), 3988 ring.toPolyCoefficients(ll[i+2]) ); 3989 end 3990 end 3991 } 3992 #puts "ring " + ring.toScript(); 3993 #puts "isAssoc " + str(ring.isAssociative()); 3994 @ring = ring; 3995 #puts "SolvPolyRing to super()"; 3996 super("",@ring) 3997 # puts "ai = " + self.class.auto_inject.to_s 3998 # done in super(): 3999 #if self.class.auto_inject or self.class.superclass.auto_inject 4000 # inject_variables(); 4001 #end 4002 end
Public Instance Methods
to_s()
click to toggle source
Create a string representation.
# File examples/jas.rb 4007 def to_s() 4008 return @ring.toScript(); 4009 end