###############################################
#                                             #
#  This is test script for 'm-polynomial.rb'  #
#                                             #
###############################################
require "m-polynomial.rb"
include Algebra

Foo = MPolynomial(Integer)
f = Foo[MIndex[1,1]=>1, MIndex[1,3]=>4, MIndex[]=>9]
g = Foo[MIndex[1,1]=>1, MIndex[1,3]=>4, MIndex[]=>9,
  MIndex[0,2,3]=>6, MIndex[2,3]=>-1, MIndex[2]=>-5,MIndex[0,1]=>7]
$DEBUG = true
puts f, g, f*g
$DEBUG = false
puts

require "polynomial-converter"
require "mathn"
P = MPolynomial(Rational)
x, y, z = P.vars("xyz")
f = x**2*y + x*y**2 + y*2 + z**3
g = x*y-z**3
h = y*2-6*z

P.set_ord(:lex)
puts "LEX:"
puts "(#{f}).divmod([#{g}, #{h}]) =>"
fgh = f.divmod(g, h)
puts fgh
puts

P.method_cash_clear(f, g, h)
P.set_ord(:grlex)
puts "GRLEX:"
puts "(#{f}).divmod([#{g}, #{h}]) =>"
fgh = f.divmod(g, h)
puts fgh
puts

P.method_cash_clear(f, g, h)
P.set_ord(:grevlex)
puts "GREVLEX:"
puts "(#{f}).divmod([#{g}, #{h}]) =>"
fgh = f.divmod(g, h)
puts fgh
puts

P.variables.clear
z, y, x = P.vars("zyx")
f = x**2*y + x*y**2 + y*2 + z**3
g = x*y-z**3
h = y*2-6*z
puts "GREVLEX: order z, y, x"
puts "(#{f}).divmod([#{g}, #{h}]) =>"
fgh = f.divmod(g, h)
puts fgh
puts
