Gröbner basis project
Codebase for research into Gröbner basis computation
test_hilbert_functions.cpp
1 /*****************************************************************************\
2 * This file is part of DynGB. *
3 * *
4 * DynGB is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * Foobar is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
16 \*****************************************************************************/
17 
18 #include <iostream>
19 
20 using std::cout; using std::endl;
21 
22 #include "hilbert_functions.hpp"
23 
24 int main() {
25  Monomial x0 = { 1, 0, 0, 0, 0, 0 };
26  WT_TYPE wt6 [6] = { 3, 2, 1, 1, 1, 1 };
27  list <Monomial> T0 = { x0 };
28  cout << "Hilbert numerator of { " << x0 << "}\n";
30  cout << *hn << endl;
31  cout << "Hilbert reduced numerator of { " << x0 << "}\n";
33  cout << *hnr << endl;
34  cout << "Graded Hilbert numerator of { " << x0 << "}\n";
35  cout << "\t(with grading (";
36  for (unsigned i = 0; i < 6; ++i) cout << wt6[i] << ',';
37  cout << ") )\n";
39  cout << *hng << endl;
40  cout << "Graded Hilbert reduced numerator of { " << x0 << "}\n";
41  cout << "\t(with grading (";
42  for (unsigned i = 0; i < 6; ++i) cout << wt6[i] << ',';
43  cout << ") )\n";
45  cout << *hngr << endl;
46  cout << "Hilbert polynomial of { " << x0 << "}\n";
48  cout << *hp << endl;
49  delete hn; delete hng; delete hngr;
50  delete hp;
51  cout << endl; cout << endl;
52  //
53  Monomial t = { 5, 0 };
54  Monomial u = { 3, 1 };
55  Monomial v = { 1, 4 };
56  WT_TYPE wt2 [2] = { 5, 3 };
57  list<Monomial> T = { t, u, v };
58  cout << "Hilbert numerator of { " << t << ", " << u << ", " << v << "}\n";
60  cout << *hn << endl;
61  cout << "Hilbert reduced numerator of { " << t << ", " << u << ", " << v << "}\n";
62  hnr = hilbert_second_numerator(2, hn);
63  cout << *hnr << endl;
64  cout << "Graded Hilbert numerator of { " << t << ", " << u << ", " << v << "}\n";
65  cout << "\t(with grading (" << wt2[0] << ',' << wt2[1] << ") )\n";
66  hng = hilbert_numerator_bigatti(T, wt2);
67  cout << *hng << endl;
68  cout << "Graded Hilbert reduced numerator of { " << t << ", " << u << ", " << v << "}\n";
69  cout << "\t(with grading (" << wt2[0] << ',' << wt2[1] << ") )\n";
70  hngr = hilbert_second_numerator(2, hng, wt2);
71  cout << *hngr << endl;
72  cout << "Hilbert polynomial of { " << t << ", " << u << ", " << v << "}\n";
73  hp = hilbert_polynomial(2, 0, T, hn);
74  cout << *hp << endl;
75  delete hn; delete hng; delete hngr;
76  delete hp;
77  cout << endl; cout << endl;
78  //
79  Monomial t1 = { 0, 2, 0, 0, 0 };
80  Monomial t2 = { 0, 1, 1, 0, 0 };
81  Monomial t3 = { 0, 0, 2, 0, 0 };
82  Monomial t4 = { 0, 1, 0, 1, 0 };
83  Monomial t5 = { 0, 0, 1, 1, 0 };
84  Monomial t6 = { 0, 0, 0, 2, 0 };
85  WT_TYPE wt5 [5] = { 1, 2, 3, 4, 5 };
86  list<Monomial> T1 = { t1, t2, t3, t4, t5, t6 };
87  cout << "Hilbert numerator of { " << t1 << ',' << t2 << ',' << t3 << ','
88  << t4 << ',' << t5 << ',' << t6 << "}\n";
90  cout << *hn << endl;
91  cout << "Hilbert reduced numerator of { " << t1 << ',' << t2 << ',' << t3 << ','
92  << t4 << ',' << t5 << ',' << t6 << "}\n";
93  hnr = hilbert_second_numerator(5, hn);
94  cout << *hnr << endl;
95  cout << "Graded Hilbert numerator of { " << t1 << ',' << t2 << ',' << t3 << ','
96  << t4 << ',' << t5 << ',' << t6 << "}\n";
97  cout << "\t(with grading (";
98  for (unsigned i = 0; i < 5; ++i) cout << wt5[i] << ',';
99  cout << ") )\n";
100  hng = hilbert_numerator_bigatti(T1, wt5);
101  cout << *hng << endl;
102  cout << "Graded Hilbert reduced numerator of { " << t1 << ',' << t2 << ',' << t3 << ','
103  << t4 << ',' << t5 << ',' << t6 << "}\n";
104  cout << "\t(with grading (";
105  for (unsigned i = 0; i < 5; ++i) cout << wt5[i] << ',';
106  cout << ") )\n";
107  hngr = hilbert_second_numerator(5, hng, wt5);
108  cout << *hngr << endl;
109  cout << "Hilbert polynomial:\n";
110  hp = hilbert_polynomial(5, 0, T, hn);
111  cout << *hp << endl;
112  delete hn; delete hng; delete hngr;
113  delete hp;
114  cout << endl;
115 }
Dense_Univariate_Rational_Polynomial * hilbert_polynomial(NVAR_TYPE n, unsigned int pole_order, const list< Monomial > T, Dense_Univariate_Integer_Polynomial *hn, Dense_Univariate_Integer_Polynomial *hn2)
computes the Hilbert polynomial for an ideal
Dense_Univariate_Integer_Polynomial * hilbert_second_numerator(NVAR_TYPE n, Dense_Univariate_Integer_Polynomial *first, const WT_TYPE *grading)
computes the second Hilbert numerator (after reduction by )
Dense_Univariate_Integer_Polynomial * hilbert_numerator_bigatti(const list< Monomial > &T, const WT_TYPE *grading)
the Bigatti algorithm to compute the Hilbert numerator
quick-’n-dirty Dense_Univariate integer polynomial class
Implementation of monomials.
Definition: monomial.hpp:69
quick-’n-dirty Dense_Univariate rational polynomial class