
[index-ja]

Algebra::EuclidianRing

(G.C.D.׻⥸塼)

divmod  G.C.D()׻⥸塼Ǥ Integer 
Algebra::Polynomial ˥󥯥롼ɤޤ

ե̾:

  euclidian-ring.rb

᥽å:

gcd(other)
    self  other Ȥκ֤ޤ
   
gcd_all(other0 [, other1[, ...]])
    self  other0, other1,... Ȥκ֤ޤ
   
gcd_coeff(other)
    self  other Ȥκȡɽ뷸֤ޤ
   
    :
    require "polynomial"
    require "rational"
    P = Algebra.Polynomial(Rational, "x")
    x = P.var
    f = (x + 2) * (x**2 - 1)**2
    g = (x + 2)**2 * (x - 1)**3
    gcd, a, b = f.gcd_coeff(g)
    p gcd #=> 4x^3 - 12x + 8
    p a   #=> -x + 2
    p b   #=> x - 1
    p gcd == a*f + b*g #=> true
   
gcd_ext(other)
    gcd_coeff ƱǤ
   
gcd_coeff_all(other0 [, other1[, ...]])
    self  other0, other1,... Ȥκȡɽ뷸֤
    ޤ
   
    :
    require "polynomial"
    require "rational"
    P = Algebra.Polynomial(Rational, "x")
    x = P.var
    f = (x + 2) * (x**2 - 1)**2
    g = (x + 2)**2 * (x - 1)**3
    h = (x + 2) * (x + 1) * (x - 1)
    gcd, a, b, c = f.gcd_coeff_all(g, h)
    p gcd #=> -8x^2 - 8x + 16
    p a   #=> -x + 2
    p b   #=> x - 1
    p c   #=> -4
    p gcd == a*f + b*g + c*h #=> true
   
gcd_ext_all(other)
    gcd_coeff_all ƱǤ
   
lcm(b)
    self  other ȤκǾ֤ܿޤ
   
lcm_all(other0 [, other1[, ...]])
    self  other0, other1,... ȤκǾ֤ܿޤ
   

