23 using std::cout;
using std::endl;
25 #include "system_constants.hpp" 28 #include "cyclic_n.hpp" 29 #include "polynomial.hpp" 30 #include "strategies.hpp" 31 #include "monomial_ordering.hpp" 32 #include "particular_orderings.hpp" 33 #include "polynomial_linked_list.hpp" 34 #include "f4_reduction.cpp" 43 bool meaningful_arguments(
int,
char **,
bool &,
int &,
int &);
47 int main(
int argc,
char *argv[]) {
50 if (not meaningful_arguments(argc, argv, homog, modulus, numvars)) {
53 int true_numvars = (homog) ? numvars + 1 : numvars;
56 list<Abstract_Polynomial *> F =
cyclic_n(numvars, FF, homog);
58 cout <<
"Computing a Groebner basis for:\n";
60 cout <<
'\t' << *f << endl;
64 cout << G.size() <<
" polynomials in basis:\n";
69 G.front()->monomial_ordering()
71 cout << G.size() <<
" leading monomials:\n";
73 cout << g->leading_monomial() <<
", ";
80 if (mord != generic_grevlex_ptr)
delete mord;
82 if (goda !=
nullptr)
delete goda;
83 if (moda !=
nullptr)
delete moda;
84 if (monoda !=
nullptr)
delete monoda;
85 if (monododa !=
nullptr)
delete monododa;
89 enum order_flags { GENERIC_GREVLEX = 0, GREVLEX, LEX, WGREVLEX };
91 bool meaningful_arguments(
92 int argc,
char *argv[],
93 bool & homogeneous,
int & modulus,
int & numvars
97 WT_TYPE * weights =
nullptr;
98 unsigned int order_flag = 0;
99 bool good_args = (argc > 1);
101 for (
int i = 1; good_args and i < argc; ++i) {
102 if (!strcmp(argv[i],
"hom") or !strcmp(argv[i],
"homog")
103 or !strcmp(argv[i],"homogeneous"))
107 for (; argv[i][j] !=
'=' and argv[i][j] !=
'\0'; ++j) { }
108 if (argv[i][j] !=
'=') {
110 cout <<
"Options must have form <option>=<value>.\n";
114 if (!strcmp(argv[i],
"n") or !strcmp(argv[i],
"num")
115 or !strcmp(argv[i],
"numvars")) {
116 numvars = atoi(&(argv[i][j+1]));
119 cout <<
"Invalid number of variables: must be at least 3.\n";
122 else if (!strcmp(argv[i],
"m") or !strcmp(argv[i],
"mod")
123 or !strcmp(argv[i],
"modulus"))
125 modulus = atoi(&(argv[i][j+1]));
128 cout <<
"Invalid modulus; must be at least 2.\n";
132 cout <<
"Unrecognized argument.\n"; good_args =
false;
142 cout <<
"Call with options n=<num> m=<mod> [hom]\n";
143 cout <<
"You *must* specify <num> vars, an integer greater than 2.\n";
144 cout <<
"You can add optional <mod>ulus (please make it prime).\n";
145 cout <<
"The option <hom>ogenize will give you a homogenized ideal.\n";
146 cout <<
"So 'test_f4 n=6 m=43' would compute the Groebner basis\n";
147 cout <<
"of the Cyclic-n ideal in 6 variables, modulo 43.";
The general class of a polynomial.
special memory pool allocator for Grevlex_Order_Data and WGrevlex_Order_Data
Grading_Order_Data_Allocator< Monomial > * monoda
memory manager for monomials (not their exponents; see moda for that).
A Constant_Polynomial is a polynomial that should not change.
Grading_Order_Data_Allocator< EXP_TYPE > * moda
memory manager for monomial exponents
Information necessary for a field modulo a prime.
interface to a monomial ordering
Grading_Order_Data_Allocator< WT_TYPE > * goda
Memory manager for graded ordering data.
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
list< Constant_Polynomial * > f4_control(const list< Abstract_Polynomial *> &F)
equivalent to buchberger(), but for Faugère’s F4 algorithm
the weighted grevlex ordering for a specified number of variables, with cached weights for each monom...
Grading_Order_Data_Allocator< Monomial_Node > * monododa
memory manager for Monomial_Node
list< Abstract_Polynomial * > cyclic_n(NVAR_TYPE n, Prime_Field &F, bool homog, Monomial_Ordering *mord=generic_grevlex_ptr)
generates the Cyclic- system