module Algebra::MPolynomialFactorization::Q

Public Instance Methods

contQ() click to toggle source
# File lib/algebra/m-polynomial-factor-int.rb, line 102
def contQ
  ns = collect { |_ind, q| q.numerator }
  ds = collect { |_ind, q| q.denominator }
  n = ns.first.gcd_all(* ns[1..-1])
  d = ds.first.lcm_all(* ds[1..-1])
  # if ground == Rational #in 1.8.0, Rational.new is private.
  # ground.new!(n, d)
  # else
  # raise "unknown gound type #{ground}" #20030606
  # ground.new(n, d)
  # end
  if ground == Rational
    Rational(n, d)
  else
    ground.new(n, d)
  end
end
factorize_rational() click to toggle source
# File lib/algebra/m-polynomial-factor-int.rb, line 124
def factorize_rational
  pz = Algebra.MPolynomial(Integer)
  pz.vars(*self.class.variables)
  fz = ppQ(pz)
  a = fz.factorize_int

  # ground == Rational, ground.ground == Integer
  u = ground.ground.unity
  b = a.collect do |f, i|
    [f.project(self.class) do |c, _j|
       if ground == Rational
         Rational(c, u)
       else
         ground.new(c, u)
       end
     end, i]
  end
  contQ == ground.unity ? b : b.unshift([self.class.const(contQ), 1])
end
ppQ(ring) click to toggle source
# File lib/algebra/m-polynomial-factor-int.rb, line 120
def ppQ(ring)
  (self / contQ).project(ring) { |c, _j| c.to_i }
end