module Algebra::PolynomialFactorization::Q
Public Instance Methods
contQ()
click to toggle source
# File lib/algebra/polynomial-factor-int.rb, line 171 def contQ ns = collect{|q| q.numerator} ds = collect{|q| q.denominator} n = ns.first.gcd_all(* ns[1..-1]) d = ds.first.lcm_all(* ds[1..-1]) # ground.new(n, d) if ground == Rational #in 1.8.0, Rational.new is private. Rational(n, d) else raise "unknown gound type #{ground}" #20030606 ground.new(n, d) end end
factorize_rational()
click to toggle source
# File lib/algebra/polynomial-factor-int.rb, line 189 def factorize_rational pz = Algebra.Polynomial(Integer, "x") fz = ppQ(pz) a = fz.factorize u = ground.ground.unity # ground == Rational, ground.ground == Integer b = a.collect{|f, i| [f.project(self.class){|c, j| # ground.new ##in 1.8.0, Rational.new is private. ground == Rational ? Rational(c, u) : Rational(c, u) }, i] } contQ == ground.unity ? b : b.unshift([self.class.const(contQ), 1]) end
ppQ(ring)
click to toggle source
# File lib/algebra/polynomial-factor-int.rb, line 185 def ppQ(ring) (self / contQ).project(ring){|c, j| c.to_i} end