Gröbner basis project
Codebase for research into Gröbner basis computation
monomial_ideal.cpp
1 #ifndef __MONOMIAL_IDEAL_CPP_
2 #define __MONOMIAL_IDEAL_CPP_
3 
4 /*****************************************************************************\
5 * This file is part of DynGB. *
6 * *
7 * DynGB is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * Foobar is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
19 \*****************************************************************************/
20 
21 #include "monomial_ideal.hpp"
22 
23 ostream & operator << (ostream & os, const Monomial_Ideal & I) {
24  os << "[ ";
25  for (
26  list<Monomial>::const_iterator ti = I.gens.begin();
27  ti != I.gens.end();
28  ++ti
29  ) {
30  os << *ti << ',';
31  }
32  os << " ] (";
33  if (I.hNum == nullptr) os << I.hNum << ", ";
34  else os << *(I.hNum) << ", ";
35  if (I.hRedNum == nullptr) os << I.hRedNum << ", ";
36  else os << *(I.hRedNum) << ", ";
37  if (I.hPol == nullptr) os << I.hPol << ")";
38  else os << *(I.hPol) << ")";
39  return os;
40 }
41 
43  const list<Monomial> & U, const Monomial & t
44 ) {
45  list<Monomial> V;
46  for (const Monomial & u : U) {
47  Monomial tnew = u.colon(t);
48  // first prune from V monomials that tnew divides
49  bool redundant = false;
50  for (
51  list<Monomial>::const_iterator vi = V.begin();
52  vi != V.end();
53  ++vi
54  ) {
55  if ((not redundant) and tnew.divisible_by(*vi))
56  redundant = true;
57  while (
58  vi != V.end() and (not tnew.is_like(*vi))
59  and vi->divisible_by(tnew)
60  ) {
61  list<Monomial>::const_iterator wi = vi; ++wi;
62  V.erase(vi);
63  vi = wi;
64  }
65  }
66  // check that tnew not divisible by anything in V
67  if (not redundant)
68  V.push_back(tnew);
69  }
70  return V;
71 }
72 
73 #endif
A class for monomial ideals.
Dense_Univariate_Rational_Polynomial * hPol
the ideal&#39;s Hilbert polynomial – standard grading only
Dense_Univariate_Integer_Polynomial * hRedNum
the ideal&#39;s reduced Hilbert numerator, standard grading
bool divisible_by(const Monomial &other) const
Divisible by other?
Definition: monomial.cpp:286
Dense_Univariate_Integer_Polynomial * hNum
the ideal&#39;s Hilbert numerator, standard grading
Monomial colon(const Monomial &u) const
colon operator: exponents needed to make divisible by this
Definition: monomial.cpp:408
list< Monomial > gens
the ideal&#39;s generators
Implementation of monomials.
Definition: monomial.hpp:69
list< Monomial > colon_ideal_without_ideals(const list< Monomial > &U, const Monomial &t)
Computes the generators of an ideal and a new generator, given the ideal&#39;s generators. No monomial ideal machinery required.
bool is_like(const Monomial &other) const
Have same variables, same powers? Synonymous with operator==().
Definition: monomial.cpp:247