Represents a JAS polynomial ring: GenPolynomialRing.
Methods to create ideals and ideals with parametric coefficients.
Get the polynomial factorization engine implementation.
r is the given polynomial ring.
# File examples/jas.rb, line 1550 def Ring.getEngineFactor(r) if r.is_a? RingElem r = r.elem; end if r.getClass().getSimpleName() != "GenPolynomialRing" return nil; end begin i = FactorFactory.getImplementation(r.coFac); rescue Exception => e i = nil end return i; end
Get the polynomial gcd engine implementation.
r is the given polynomial ring.
# File examples/jas.rb, line 1510 def Ring.getEngineGcd(r) if r.is_a? RingElem r = r.elem; end if r.getClass().getSimpleName() != "GenPolynomialRing" return nil; end begin i = GCDFactory.getProxy(r.coFac); rescue Exception => e i = nil end return i; end
Get the polynomial squarefree engine implementation.
r is the given polynomial ring.
# File examples/jas.rb, line 1530 def Ring.getEngineSqf(r) if r.is_a? RingElem r = r.elem; end if r.getClass().getSimpleName() != "GenPolynomialRing" return nil; end begin i = SquarefreeFactory.getImplementation(r.coFac); rescue Exception => e i = nil end return i; end
Ring constructor.
ringstr string representation to be parsed. ring JAS ring object.
# File examples/jas.rb, line 1477 def initialize(ringstr="",ring=nil) if ring == nil sr = StringReader.new( ringstr ); tok = RingFactoryTokenizer.new(sr); pfac = tok.nextPolynomialRing(); #tok = GenPolynomialTokenizer.new(sr); #@pset = tok.nextPolynomialSet(); @ring = pfac; else if ring.is_a? Ring @ring = ring.ring else @ring = ring; end end # parameter ",fast=false" not possible w/o keyword params #if fast == true # return #end @engine = Ring.getEngineGcd(@ring); @sqf = Ring.getEngineSqf(@ring); @factor = Ring.getEngineFactor(@ring); variable_generators() if self.class.auto_inject or self.class.superclass.auto_inject # sic! inject_variables(); end end
Test if two rings are equal.
# File examples/jas.rb, line 1615 def ===(other) if not other.is_a? Ring return false; end return @ring.equals(other.ring); end
Compute complex roots of univariate polynomial.
# File examples/jas.rb, line 1809 def complexRoots(a,eps=nil) if not a.is_a? RingElem a = RingElem.new(a); end return a.complexRoots(eps); end
Create an element from a string or an object.
# File examples/jas.rb, line 1681 def element(poly) if not poly.is_a? String begin if @ring == poly.ring return RingElem.new(poly); end rescue Exception => e # pass end poly = str(poly); end i = SimIdeal.new( self, "( " + poly + " )" ); list = i.pset.list; if list.size > 0 return RingElem.new( list[0] ); end end
Compute irreducible factorization for modular, integer, rational number and algebriac number coefficients.
# File examples/jas.rb, line 1746 def factors(a) if a.is_a? RingElem a = a.elem; else a = element( a ); a = a.elem; end begin cf = @ring.coFac; if cf.getClass().getSimpleName() == "GenPolynomialRing" e = @factor.recursiveFactors( a ); else e = @factor.factors( a ); end ll = {}; for a in e.keySet() i = e.get(a); ll[ RingElem.new( a ) ] = i; end return ll; rescue Exception => e puts "error " + str(e) return nil end end
Compute absolute irreducible factorization for (modular,) rational number coefficients.
# File examples/jas.rb, line 1776 def factorsAbsolute(a) if a.is_a? RingElem a = a.elem; else a = element( a ); a = a.elem; end begin ll = @factor.factorsAbsolute( a ); ## ll = {}; ## for a in e.keySet() ## i = e.get(a); ## ll[ RingElem.new( a ) ] = i; return ll; rescue Exception => e puts "error in factorsAbsolute " + str(e) return nil end end
Compute the greatest common divisor of a and b.
# File examples/jas.rb, line 1702 def gcd(a,b) if a.is_a? RingElem a = a.elem; else a = element( a ); a = a.elem; end if b.is_a? RingElem b = b.elem; else b = element( b ); b = b.elem; end return RingElem.new( @engine.gcd(a,b) ); end
Get list of generators of the polynomial ring.
# File examples/jas.rb, line 1647 def gens() ll = @ring.generators(); n = ll.map{ |e| RingElem.new(e) }; return n; end
Create an ideal.
# File examples/jas.rb, line 1625 def ideal(ringstr="",list=nil) return JAS::SimIdeal.new(self,ringstr,list); end
Inject variables for generators in top level environment.
# File examples/jas.rb, line 1593 def inject_variables() begin require "irb/frame" # must be placed here bin = IRB::Frame.bottom(0); env = eval "self", bin; #puts "env = " + str(env) inject_gens(env) rescue Exception => e puts "error: 'irb/frame' not found, e = " + str(e); end end
Integrate rational function or power series.
# File examples/jas.rb, line 1819 def integrate(a) if not a.is_a? RingElem a = RingElem.new(a); end return a.integrate(); end
Get the one of the polynomial ring.
# File examples/jas.rb, line 1656 def one() return RingElem.new( @ring.getONE() ); end
Create an ideal in a polynomial ring with parameter coefficients.
# File examples/jas.rb, line 1632 def paramideal(ringstr="",list=nil,gbsys=nil) return ParamIdeal.new(self,ringstr,list,gbsys); end
Get a power series ring from this ring.
# File examples/jas.rb, line 1639 def powerseriesRing() pr = MultiVarPowerSeriesRing.new(@ring); return MultiSeriesRing.new("",nil,pr); end
Get a random polynomial.
# File examples/jas.rb, line 1670 def random(k=5,l=7,d=3,q=0.3) r = @ring.random(k,l,d,q); if @ring.coFac.isField() r = r.monic(); end return RingElem.new( r ); end
Compute real roots of univariate polynomial.
# File examples/jas.rb, line 1799 def realRoots(a,eps=nil) if not a.is_a? RingElem a = RingElem.new(a); end return a.realRoots(eps); end
Compute squarefree factors of polynomial.
# File examples/jas.rb, line 1721 def squarefreeFactors(a) if a.is_a? RingElem a = a.elem; else a = element( a ); a = a.elem; end cf = @ring.coFac; if cf.getClass().getSimpleName() == "GenPolynomialRing" e = @sqf.recursiveSquarefreeFactors( a ); else e = @sqf.squarefreeFactors( a ); end ll = {}; for a in e.keySet() i = e.get(a); ll[ RingElem.new( a ) ] = i; end return ll; end
Create a string representation.
# File examples/jas.rb, line 1608 def to_s() return @ring.toScript(); end
Define instance variables for generators.
# File examples/jas.rb, line 1568 def variable_generators() Ring.instance_eval( "attr_accessor :generators;" ) @generators = {}; for i in self.gens() begin ivs = nameFromValue(i); if ivs != nil #puts "string: #{ivs} = " + ivs.class.to_s; if @generators[ ivs ] != nil puts "redefining local variable #{ivs}"; end @generators[ ivs ] = i; self.instance_eval( "def #{ivs}; @generators[ '#{ivs}' ]; end" ) end rescue Exception => e puts "ring error: #{ivs} = " + i.to_s + ", e = " + str(e); #pass end end puts "locally defined generators: " + @generators.keys().join(", "); end
Generated with the Darkfish Rdoc Generator 2.