# TEST of Gussian Elimination Algorism
#
#   by Shin-ichiro Hara
#
# Version 1.0 (2001.04.13)

require "rational"
require "residue-class-ring"
require "polynomial"
require "gaussian-elimination"

class Rational < Numeric
  def inspect; to_s; end
end

M45 = Matrix(Rational, 4, 5)
m = M45[
  [1, 2, -1, 1, 0],
  [2, 4, -2, 2, 1],
  [-2, -4, 3, 0,1],
  [3, 6, -1, 7, 1]]

puts "m = "
m.display

m = m.left_sweep
m.display; puts
basis = m.kernel_basis
basis.each do |b|
  p b
end

M3 = SquareMatrix(Rational, 3)
m = M3[
  [2, 3, 1],
  [4, 1, -3],
  [-1, 2, 2]]

m.inverse.display
