Frobby 0.9.7
HilbertIndependenceConsumer.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
21#include "HilbertStrategy.h"
22
25 _rightConsumer(this),
26 _strategy(strategy) {
27 ASSERT(strategy != 0);
28 clear();
29}
30
32 IndependenceSplitter& splitter,
33 size_t varCount) {
34 ASSERT(parent != 0);
35
36 _tmpTerm.reset(varCount);
37 _parent = parent;
38
41
42 _rightTerms.clearAndSetVarCount(_rightProjection.getRangeVarCount());
43}
44
46 _parent = 0;
47 _rightTerms.clear();
48 _rightCoefs.clear();
49}
50
52 ASSERT(_strategy != 0);
53 _strategy->freeConsumer(unique_ptr<HilbertIndependenceConsumer>(this));
54}
55
59
64
67
70
73
74void HilbertIndependenceConsumer::consume(const mpz_class& coef,
75 const Term& term) {
76 ASSERT(_parent != 0);
77 ASSERT(coef != 0);
78 consumeLeft(coef, term);
79}
80
85
90
95
100
104
107
109consume(const mpz_class& coef, const Term& term) {
110 _parent->consumeRight(coef, term);
111}
112
115
116void HilbertIndependenceConsumer::consumeLeft(const mpz_class& leftCoef,
117 const Term& leftTerm) {
118 ASSERT(_tmpTerm.getVarCount() ==
119 _leftProjection.getRangeVarCount() +
120 _rightProjection.getRangeVarCount());
121
122 _leftProjection.inverseProject(_tmpTerm, leftTerm);
123
124 size_t rightSize = _rightTerms.getGeneratorCount();
125 ASSERT(rightSize == _rightCoefs.size());
126 for (size_t right = 0; right < rightSize; ++right) {
127 _rightProjection.inverseProject(_tmpTerm,
128 *(_rightTerms.begin() + right));
129 ASSERT(leftCoef != 0);
130 ASSERT(_rightCoefs[right] != 0);
131 _tmpCoef = leftCoef * _rightCoefs[right];
132
133 ASSERT(_tmpCoef != 0);
134 _parent->consume(_tmpCoef, _tmpTerm);
135 }
136}
137
139 const Term& term) {
140 ASSERT(term.getVarCount() == _rightProjection.getRangeVarCount());
141 ASSERT(_rightTerms.getVarCount() == term.getVarCount());
142 ASSERT(coef != 0);
143
144 _rightTerms.insert(term);
145 _rightCoefs.push_back(coef);
146}
RightConsumer(HilbertIndependenceConsumer *parent)
virtual void consume(const mpz_class &coef, const Term &term)
virtual void consumeRing(const VarNames &names)
const Projection & getRightProjection() const
virtual void consumeRight(const mpz_class &coef, const Term &term)
virtual void run(TaskEngine &engine)
Does whatever work this task represents.
void reset(CoefTermConsumer *parent, IndependenceSplitter &splitter, size_t varCount)
const Projection & getLeftProjection() const
virtual void consumeLeft(const mpz_class &leftCoef, const Term &leftTerm)
virtual void dispose()
Called when the task is no longer used but run has not and will not be called.
HilbertIndependenceConsumer(HilbertStrategy *strategy)
virtual void consume(const mpz_class &coef, const Term &term)
void getRestProjection(Projection &projection) const
void getBigProjection(Projection &projection) const
TaskEngine handles a list of tasks that are to be carried out.
Definition TaskEngine.h:40
Term represents a product of variables which does not include a coefficient.
Definition Term.h:49
size_t getVarCount() const
Definition Term.h:85
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
This header file includes common definitions and is included as the first line of code in every imple...
#define ASSERT(X)
Definition stdinc.h:86