Frobby  0.9.0
BigTermRecorder.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"
18 #include "BigTermRecorder.h"
19 
20 #include "BigIdeal.h"
21 #include "Term.h"
22 #include "TermTranslator.h"
23 
25  _ideals(),
26  _idealsDeleter(_ideals) {
27 }
28 
30  _names = names;
31 }
32 
33 void BigTermRecorder::consume(auto_ptr<BigIdeal> ideal) {
34  consumeRing(ideal->getNames());
36 }
37 
39  auto_ptr<BigIdeal> ideal(new BigIdeal(_names));
41 }
42 
44 (const Term& term, const TermTranslator& translator) {
45  ASSERT(!_ideals.empty());
46  BigIdeal& ideal = *(_ideals.back());
47 
48  ASSERT(term.getVarCount() == ideal.getVarCount());
49  ASSERT(translator.getVarCount() == ideal.getVarCount());
50 
51  ideal.newLastTerm();
52  size_t varCount = ideal.getVarCount();
53  for (size_t var = 0; var < varCount; ++var)
54  ideal.getLastTermExponentRef(var) = translator.getExponent(var, term);
55 }
56 
57 void BigTermRecorder::consume(const vector<mpz_class>& term) {
58  ASSERT(!_ideals.empty());
59  BigIdeal& ideal = *(_ideals.back());
60 
61  ideal.newLastTerm();
62  size_t varCount = ideal.getVarCount();
63  for (size_t var = 0; var < varCount; ++var)
64  ideal.getLastTermExponentRef(var) = term[var];
65 }
66 
68 }
69 
70 bool BigTermRecorder::empty() const {
71  return _ideals.empty();
72 }
73 
74 auto_ptr<BigIdeal> BigTermRecorder::releaseIdeal() {
75  ASSERT(!empty());
76  auto_ptr<BigIdeal> ideal(_ideals.front());
77  _ideals.pop_front();
78  return ideal;
79 }
80 
82  return _names;
83 }
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
auto_ptr< BigIdeal > releaseIdeal()
#define ASSERT(X)
Definition: stdinc.h:85
void exceptionSafePushBack(Container &container, auto_ptr< Element > pointer)
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
size_t getVarCount() const
size_t getVarCount() const
Definition: Term.h:85
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
bool empty() const
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
const VarNames & getRing()
list< BigIdeal * > _ideals
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
virtual void consume(const Term &term, const TermTranslator &translator)
void newLastTerm()
Definition: BigIdeal.cpp:104