module Algebra

Elementary Divisor

by Shin-ichiro HARA

Ver. 1.0 (2001.11.03)

Expression of Divisors

by Shin-ichiro Hara

Version 1.1 (2001.08.12)

Gussian Elimination Algorism

by Shin-ichiro Hara

Version 1.1 (2001.09.12)

Groebner basis module (with coeffitients)

by Shin-ichiro Hara

Version 1.2 (2001.04.03)

require “algebra/work/old-basis”

Multi-index class for MPolymial

by Shin-ichiro Hara

Version 2.00 (2002.02.04)

require “algebra/combinatorial”

require “algebra/annihilate”

require “algebra/polynomial-converter”

require “algebra/algebraic-extension-field.rb”

Constants

VERSION

Public Class Methods

AlgebraicExtensionField(field, var = 'x', &b) click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 12
def AlgebraicExtensionField(field, var = 'x', &b)
  AlgebraicExtensionField.create(field, var, &b)
end
Covector(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 41
def Covector(ground, size)
  Covector.create(ground, size)
end
LocalizedRing(ring) click to toggle source
# File lib/algebra/localized-ring.rb, line 11
def LocalizedRing(ring)
  LocalizedRing.create(ring)
end
MPolynomial(ground, *vars) click to toggle source
# File lib/algebra/m-polynomial.rb, line 12
def MPolynomial(ground, *vars)
  Algebra::MPolynomial.create(ground, *vars)
end
MRationalFunctionField(field, *objs) click to toggle source
# File lib/algebra/localized-ring.rb, line 28
def MRationalFunctionField(field, *objs)
  require 'algebra/m-polynomial'
  k = LocalizedRing(MPolynomial(field, *objs))
  def k.vars(*vs)
    ground.vars(*vs).map { |v| self[v] }
  end

  def k.to_ary
    [self, *vars]
  end
  k.reducible = false
  k
end
MatrixAlgebra(ground, rsize, csize) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 29
def MatrixAlgebra(ground, rsize, csize)
  MatrixAlgebra.create(ground, rsize, csize)
end
MinimalDecompositionField(f, *a) click to toggle source

for backward compatibility

# File lib/algebra/splitting-field.rb, line 99
def MinimalDecompositionField(f, *a)
  f.decompose(*a)
end
Polynomial(ground = Integer, *variables) click to toggle source
# File lib/algebra/polynomial.rb, line 11
def Polynomial(ground = Integer, *variables)
  Polynomial.create(ground, *variables)
end
QuadraticExtensionField(field, var_obj = nil) { |var| ... } click to toggle source

experimental ###################

# File lib/algebra/algebraic-extension-field.rb, line 66
def QuadraticExtensionField(field, var_obj = nil)
  poly_ring = Algebra.Polynomial(field, 'x')
  modulus = yield(poly_ring.var)
  unless modulus.deg == 2
    raise 'give deg 2 polynomial to QuadraticicExtensionField.'
  end

  fact = modulus.factorize
  if o = fact.find { |x| x[0].deg == 1 }
    b = o[0][0]
    a = o[0][1]
    c = b / a
    return [field, - c, c]
  end

  c = modulus[0]
  b = modulus[1]
  a = modulus[2]
  a2 = a * 2
  b0 = a2.zero? ? b : (b / a2)
  c1 = c / a - b0**2
  cs = (-c1).to_s
  r = 'r'
  var_obj ||= r + (/^\d+$/ !~ cs ? '(' + cs + ')' : cs)

  klass, v = AlgebraicExtensionField(field, var_obj) { |x| x**2 + c1 }

  r1 = v - b0
  r2 = - v - b0
  [klass, r1, r2]
end
RationalFunctionField(field, obj) click to toggle source
# File lib/algebra/localized-ring.rb, line 15
def RationalFunctionField(field, obj)
  require 'algebra/polynomial'
  k = LocalizedRing(Polynomial(field, obj))
  def k.var
    self[ground.var]
  end

  def k.to_ary
    [self, var]
  end
  k
end
ResidueClassRing(klass, mod) click to toggle source
# File lib/algebra/residue-class-ring.rb, line 12
def ResidueClassRing(klass, mod)
  ResidueClassRing.create(klass, mod)
end
Root(field, a = nil, deg = 2, cs = nil) { |x| ... } click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 105
def Root(field, a = nil, deg = 2, cs = nil, &b)
  r, x = Polynomial(field)
  if b
    f = yield(x)
    as = a ? a.to_s : f.to_s
  else
    f = x**deg - a
    as = a.to_s
  end

  r = deg == 2 ? 'r' : "r[#{deg}]"
  cs ||= r + (/^\d+$/ !~ as ? '(' + as + ')' : as)
  k = f.splitting_field(nil, cs)
  [k.field, *k.roots]
end
Sqrt(field, a, _name = nil) click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 99
def Sqrt(field, a, _name = nil)
  QuadraticExtensionField(field, nil) { |x| x**2 - a }
end
SquareMatrix(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 33
def SquareMatrix(ground, size)
  SquareMatrix.create(ground, size)
end
Vector(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 37
def Vector(ground, size)
  Vector.create(ground, size)
end

Private Instance Methods

AlgebraicExtensionField(field, var = 'x', &b) click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 12
def AlgebraicExtensionField(field, var = 'x', &b)
  AlgebraicExtensionField.create(field, var, &b)
end
Covector(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 41
def Covector(ground, size)
  Covector.create(ground, size)
end
LocalizedRing(ring) click to toggle source
# File lib/algebra/localized-ring.rb, line 11
def LocalizedRing(ring)
  LocalizedRing.create(ring)
end
MPolynomial(ground, *vars) click to toggle source
# File lib/algebra/m-polynomial.rb, line 12
def MPolynomial(ground, *vars)
  Algebra::MPolynomial.create(ground, *vars)
end
MRationalFunctionField(field, *objs) click to toggle source
# File lib/algebra/localized-ring.rb, line 28
def MRationalFunctionField(field, *objs)
  require 'algebra/m-polynomial'
  k = LocalizedRing(MPolynomial(field, *objs))
  def k.vars(*vs)
    ground.vars(*vs).map { |v| self[v] }
  end

  def k.to_ary
    [self, *vars]
  end
  k.reducible = false
  k
end
MatrixAlgebra(ground, rsize, csize) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 29
def MatrixAlgebra(ground, rsize, csize)
  MatrixAlgebra.create(ground, rsize, csize)
end
MinimalDecompositionField(f, *a) click to toggle source

for backward compatibility

# File lib/algebra/splitting-field.rb, line 99
def MinimalDecompositionField(f, *a)
  f.decompose(*a)
end
Polynomial(ground = Integer, *variables) click to toggle source
# File lib/algebra/polynomial.rb, line 11
def Polynomial(ground = Integer, *variables)
  Polynomial.create(ground, *variables)
end
QuadraticExtensionField(field, var_obj = nil) { |var| ... } click to toggle source

experimental ###################

# File lib/algebra/algebraic-extension-field.rb, line 66
def QuadraticExtensionField(field, var_obj = nil)
  poly_ring = Algebra.Polynomial(field, 'x')
  modulus = yield(poly_ring.var)
  unless modulus.deg == 2
    raise 'give deg 2 polynomial to QuadraticicExtensionField.'
  end

  fact = modulus.factorize
  if o = fact.find { |x| x[0].deg == 1 }
    b = o[0][0]
    a = o[0][1]
    c = b / a
    return [field, - c, c]
  end

  c = modulus[0]
  b = modulus[1]
  a = modulus[2]
  a2 = a * 2
  b0 = a2.zero? ? b : (b / a2)
  c1 = c / a - b0**2
  cs = (-c1).to_s
  r = 'r'
  var_obj ||= r + (/^\d+$/ !~ cs ? '(' + cs + ')' : cs)

  klass, v = AlgebraicExtensionField(field, var_obj) { |x| x**2 + c1 }

  r1 = v - b0
  r2 = - v - b0
  [klass, r1, r2]
end
RationalFunctionField(field, obj) click to toggle source
# File lib/algebra/localized-ring.rb, line 15
def RationalFunctionField(field, obj)
  require 'algebra/polynomial'
  k = LocalizedRing(Polynomial(field, obj))
  def k.var
    self[ground.var]
  end

  def k.to_ary
    [self, var]
  end
  k
end
ResidueClassRing(klass, mod) click to toggle source
# File lib/algebra/residue-class-ring.rb, line 12
def ResidueClassRing(klass, mod)
  ResidueClassRing.create(klass, mod)
end
Root(field, a = nil, deg = 2, cs = nil) { |x| ... } click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 105
def Root(field, a = nil, deg = 2, cs = nil, &b)
  r, x = Polynomial(field)
  if b
    f = yield(x)
    as = a ? a.to_s : f.to_s
  else
    f = x**deg - a
    as = a.to_s
  end

  r = deg == 2 ? 'r' : "r[#{deg}]"
  cs ||= r + (/^\d+$/ !~ as ? '(' + as + ')' : as)
  k = f.splitting_field(nil, cs)
  [k.field, *k.roots]
end
Sqrt(field, a, _name = nil) click to toggle source
# File lib/algebra/algebraic-extension-field.rb, line 99
def Sqrt(field, a, _name = nil)
  QuadraticExtensionField(field, nil) { |x| x**2 - a }
end
SquareMatrix(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 33
def SquareMatrix(ground, size)
  SquareMatrix.create(ground, size)
end
Vector(ground, size) click to toggle source
# File lib/algebra/matrix-algebra.rb, line 37
def Vector(ground, size)
  Vector.create(ground, size)
end