1- module TestExponentsIterator
1+ module TestComparison
22
33using Test
44using MultivariatePolynomials
55
66function _test (object, M; kws... )
77 it = ExponentsIterator {M} (object; kws... )
88 v = collect (Iterators. take (it, 20 ))
9- @test issorted (v, lt = (a, b) -> compare (a, b, M))
9+ @test issorted (v, lt = (a, b) -> compare (a, b, M) < 0 )
1010end
1111
1212function _test (nvars:: Int , M; kws... )
13- _test (zeros (Int, nvars); inline = false , kws... )
14- _test (zeros (Int, nvars); inline = true , kws... )
15- _test (ntuple (zero, nvars); inline = false , kws... )
13+ _test (zeros (Int, nvars), M ; inline = false , kws... )
14+ _test (zeros (Int, nvars), M ; inline = true , kws... )
15+ _test (ntuple (zero, nvars), M ; inline = false , kws... )
1616 return
1717end
1818
19- function test_all ()
19+ function test_exponents_iterator ()
2020 @testset " nvariables = $nvars " for nvars in 0 : 3
2121 @testset " mindegree = $mindegree " for mindegree in 0 : 3
22- @testset " maxdegree = $maxdegree " for maxdegree in
23- vcat (nothing ; 0 : 3 )
22+ @testset " maxdegree = $maxdegree " for maxdegree in vcat (nothing , 0 : 3 )
2423 for L in [LexOrder, InverseLexOrder]
2524 @testset " M = $M " for M in [L, Graded{L}]
2625 _test (nvars, M; mindegree, maxdegree)
@@ -31,6 +30,33 @@ function test_all()
3130 end
3231end
3332
33+ function test_compare ()
34+ lex = LexOrder
35+ grlex = Graded{lex}
36+ rinvlex = Reverse{InverseLexOrder}
37+ grevlex = Graded{rinvlex}
38+ @test compare ([1 , 0 , 1 ], [1 , 1 , 0 ], grlex) == - 1
39+ @test compare ([1 , 1 , 0 ], [1 , 0 , 1 ], grlex) == 1
40+ # [CLO13, p. 58]
41+ @test compare (1 : 3 , [3 , 2 , 0 ], lex) < 0
42+ @test compare (1 : 3 , [3 , 2 , 0 ], grlex) > 0
43+ @test compare (1 : 3 , [3 , 2 , 0 ], rinvlex) < 0
44+ @test compare (1 : 3 , [3 , 2 , 0 ], grevlex) > 0
45+ @test compare ([1 , 2 , 4 ], [1 , 1 , 5 ], lex) > 0
46+ @test compare ([1 , 2 , 4 ], [1 , 1 , 5 ], grlex) > 0
47+ @test compare ([1 , 2 , 4 ], [1 , 1 , 5 ], rinvlex) > 0
48+ @test compare ([1 , 2 , 4 ], [1 , 1 , 5 ], grevlex) > 0
49+ # [CLO13, p. 59]
50+ @test compare ((5 , 1 , 1 ), (4 , 1 , 2 ), lex) > 0
51+ @test compare ((5 , 1 , 1 ), (4 , 1 , 2 ), grlex) > 0
52+ @test compare ((5 , 1 , 1 ), (4 , 1 , 2 ), rinvlex) > 0
53+ @test compare ((5 , 1 , 1 ), (4 , 1 , 2 ), grevlex) > 0
54+ # [CLO13] Cox, D., Little, J., & OShea, D.
55+ # *Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra*.
56+ # Springer Science & Business Media, **2013**.
57+
58+ end
59+
3460function runtests ()
3561 for name in names (@__MODULE__ ; all = true )
3662 if startswith (" $(name) " , " test_" )
4470
4571end # module
4672
47- TestExponentsIterator . runtests ()
73+ TestComparison . runtests ()
0 commit comments