class Algebra::JordanForm

Public Class Methods

construct(elem_divs, facts, field, pfield) click to toggle source
# File lib/algebra/jordan-form.rb, line 59
def self.construct(elem_divs, facts, field, pfield)
  a = []
  elem_divs.each do |e|
    facts.each do |f, n|
      next if f.deg.zero? || n.zero?
      f = f.convert_to(pfield)
      g = e.convert_to(pfield)

      raise 'insufficient decomposition' unless f.deg <= 1
      k = 0
      loop do
        q, r = g.divmod f
        break unless r.zero?
        g = q
        k += 1
      end
      a.push [-f[0], k] if k > 0
    end
  end
  Algebra::JordanForm.new(a).to_matrix(field)
end
decompose(m) click to toggle source
# File lib/algebra/jordan-form.rb, line 81
def self.decompose(m)
  base_ring = m.ground
  base_pring = Algebra.Polynomial(base_ring, 'x')
  base_alg = Algebra.SquareMatrix(base_pring, m.size)

  me = m._char_matrix(base_alg).to_quint.e_diagonalize
  elem_divs = me.body.diag

  facts = Algebra::ElementaryDivisor.factorize(elem_divs)
  dl = facts.last
  field, modulus, facts, roots, elms = dl.pi.decompose(dl)

  pfield = Algebra.Polynomial(field, 'x')
  pfm_alg = Algebra.SquareMatrix(pfield, m.size)

  jm = Algebra::JordanForm.construct(elem_divs, facts, field, pfield)
  jme = jm._char_matrix(pfm_alg).to_quint.e_diagonalize

  mebody = pfm_alg.convert_from(me.body)
  meright = pfm_alg.convert_from(me.right)
  meleft = pfm_alg.convert_from(me.left)

  sR = (meright * jme.righti).i2o.evaluateR(jm)
  tL = (jme.lefti * meleft).i2o.evaluateL(jm)

  [jm, tL, sR, field, modulus]
end
new(body) click to toggle source
# File lib/algebra/jordan-form.rb, line 20
def initialize(body)
  @body = body
end

Public Instance Methods

jordan_block_l(ring, x, n) click to toggle source
# File lib/algebra/jordan-form.rb, line 55
def jordan_block_l(ring, x, n)
  jordan_block_u(ring, x, n).transpose
end
jordan_block_u(ring, x, n) click to toggle source
# File lib/algebra/jordan-form.rb, line 42
def jordan_block_u(ring, x, n)
  a = Algebra.SquareMatrix(ring, n)
  a.matrix do |i, j|
    if i == j
      x
    elsif i == j - 1
      ring.unity
    else
      ring.zero
    end
  end
end
to_matrix(ring = Integer) click to toggle source
# File lib/algebra/jordan-form.rb, line 24
def to_matrix(ring = Integer)
  mat = nil
  @body.each do |x, n|
    mat = if mat
            mat.dsum(jordan_block_u(ring, x, n))
          else
            jordan_block_u(ring, x, n)
          end
  end
  mat
end
Also aliased as: to_matrix_u
to_matrix_l() click to toggle source
# File lib/algebra/jordan-form.rb, line 38
def to_matrix_l
  to_matrix_u.transpose
end
to_matrix_u(ring = Integer)
Alias for: to_matrix