Frobby  0.9.5
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 
20 #include "IndependenceSplitter.h"
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 
43 }
44 
46  _parent = 0;
48  _rightCoefs.clear();
49 }
50 
52  ASSERT(_strategy != 0);
53  _strategy->freeConsumer(auto_ptr<HilbertIndependenceConsumer>(this));
54 }
55 
57  dispose();
58 }
59 
61  ASSERT(_parent != 0);
62  return this;
63 }
64 
66 }
67 
69 }
70 
72 }
73 
74 void HilbertIndependenceConsumer::consume(const mpz_class& coef,
75  const Term& term) {
76  ASSERT(_parent != 0);
77  ASSERT(coef != 0);
78  consumeLeft(coef, term);
79 }
80 
82  ASSERT(_parent != 0);
83  return &_rightConsumer;
84 }
85 
87  ASSERT(_parent != 0);
88  return _leftProjection;
89 }
90 
92  ASSERT(_parent != 0);
93  return _rightProjection;
94 }
95 
98  _parent(parent) {
99 }
100 
102 (const VarNames& names) {
103 }
104 
106 }
107 
109 consume(const mpz_class& coef, const Term& term) {
110  _parent->consumeRight(coef, term);
111 }
112 
114 }
115 
116 void HilbertIndependenceConsumer::consumeLeft(const mpz_class& leftCoef,
117  const Term& leftTerm) {
121 
123 
124  size_t rightSize = _rightTerms.getGeneratorCount();
125  ASSERT(rightSize == _rightCoefs.size());
126  for (size_t right = 0; right < rightSize; ++right) {
128  *(_rightTerms.begin() + right));
129  ASSERT(leftCoef != 0);
130  ASSERT(_rightCoefs[right] != 0);
131  _tmpCoef = leftCoef * _rightCoefs[right];
132 
133  ASSERT(_tmpCoef != 0);
135  }
136 }
137 
138 void HilbertIndependenceConsumer::consumeRight(const mpz_class& coef,
139  const Term& term) {
142  ASSERT(coef != 0);
143 
144  _rightTerms.insert(term);
145  _rightCoefs.push_back(coef);
146 }
virtual void consume(const Polynomial &poly)
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 freeConsumer(auto_ptr< HilbertIndependenceConsumer > consumer)
size_t getGeneratorCount() const
Definition: Ideal.h:57
void clearAndSetVarCount(size_t varCount)
Definition: Ideal.cpp:646
void clear()
Definition: Ideal.cpp:641
void insert(const Exponent *term)
Definition: Ideal.cpp:455
const_iterator begin() const
Definition: Ideal.h:48
size_t getVarCount() const
Definition: Ideal.h:56
void getRestProjection(Projection &projection) const
void getBigProjection(Projection &projection) const
void inverseProject(Term &to, const Exponent *from) const
Definition: Projection.cpp:78
size_t getRangeVarCount() const
Definition: Projection.cpp:24
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
void reset(size_t newVarCount)
Definition: Term.h:551
size_t getVarCount() const
Definition: Term.h:85
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
#define ASSERT(X)
Definition: stdinc.h:86