Frobby  0.9.5
IrreducibleIdealSplitter.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program 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  This program 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 this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #include "stdinc.h"
19 
20 #include "VarNames.h"
21 #include "TermTranslator.h"
22 
24 (BigTermConsumer& consumer):
25  _consumer(consumer),
26  _inList(false) {
27 }
28 
30 (auto_ptr<BigTermConsumer> consumer):
31  _consumer(*consumer),
32  _consumerDeleter(consumer),
33  _inList(false) {
34 }
35 
37  _tmp.reset(names.getVarCount());
38  _bigTmp.resize(names.getVarCount());
39  _consumer.consumeRing(names);
40 
42  ASSERT(_bigTmp == vector<mpz_class>(_bigTmp.size()));
43 }
44 
46  ASSERT(!_inList);
47  _inList = true;
49 }
50 
52  if (!_inList)
54 }
55 
57  ASSERT(term.getVarCount() == _tmp.getVarCount());
59 
61  for (size_t var = 0; var < term.getVarCount(); ++var) {
62  if (term[var] != 0) {
63  _tmp[var] = term[var];
65  _tmp[var] = 0;
66  }
67  }
69 
71 }
72 
74 (const Term& term, const TermTranslator& translator) {
75  ASSERT(term.getVarCount() == _tmp.getVarCount());
77 
79  for (size_t var = 0; var < term.getVarCount(); ++var) {
80  if (translator.getExponent(var, term) != 0) {
81  _tmp[var] = term[var];
82  _consumer.consume(_tmp, translator);
83  _tmp[var] = 0;
84  }
85  }
87 
89 }
90 
91 void IrreducibleIdealSplitter::consume(const vector<mpz_class>& term) {
92  ASSERT(term.size() == _bigTmp.size());
93  ASSERT(_bigTmp == vector<mpz_class>(_bigTmp.size()));
94 
96  for (size_t var = 0; var < term.size(); ++var) {
97  if (term[var] != 0) {
98  _bigTmp[var] = term[var];
100  _bigTmp[var] = 0;
101  }
102  }
104 
105  ASSERT(_bigTmp == vector<mpz_class>(_bigTmp.size()));
106 }
107 
109  if (!_inList)
111 }
112 
114  ASSERT(_inList);
116 }
virtual void consume(const vector< mpz_class > &term)=0
virtual void consumeRing(const VarNames &names)=0
Tell the consumer which ring is being used.
virtual void doneConsuming()=0
Must be called once after each time beginConsuming has been called.
virtual void beginConsuming()=0
Tell the consumer to begin consuming an ideal.
IrreducibleIdealSplitter(BigTermConsumer &consumer)
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
virtual void consume(const Term &term)
Consume a term.
virtual void beginConsumingList()
Tell the consumer that the ideals that are consumed until the next call to doneConsumingList are to b...
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
virtual void doneConsumingList()
Must be called once after each time beginConsumingList has been called.
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
virtual void doneConsumingList()
Must be called once after each time beginConsumingList has been called.
virtual void beginConsumingList()
Tell the consumer that the ideals that are consumed until the next call to doneConsumingList are to b...
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
void reset(size_t newVarCount)
Definition: Term.h:551
size_t getVarCount() const
Definition: Term.h:85
static bool isIdentity(const Exponent *a, size_t varCount)
Returns whether a is 1, i.e. whether all entries of a are 0.
Definition: Term.h:316
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
size_t getVarCount() const
Returns the current number of variables.
Definition: VarNames.h:113
#define ASSERT(X)
Definition: stdinc.h:86