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 }
BigIdeal
Definition: BigIdeal.h:27
BigTermRecorder::BigTermRecorder
BigTermRecorder()
Definition: BigTermRecorder.cpp:24
stdinc.h
BigTermRecorder::beginConsuming
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
Definition: BigTermRecorder.cpp:38
BigTermRecorder::releaseIdeal
auto_ptr< BigIdeal > releaseIdeal()
Definition: BigTermRecorder.cpp:74
BigTermRecorder::consumeRing
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
Definition: BigTermRecorder.cpp:29
BigTermRecorder.h
BigTermRecorder::_names
VarNames _names
Definition: BigTermRecorder.h:54
Term::getVarCount
size_t getVarCount() const
Definition: Term.h:85
BigIdeal::newLastTerm
void newLastTerm()
Definition: BigIdeal.cpp:104
Term.h
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition: TermTranslator.h:41
TermTranslator::getExponent
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
Definition: TermTranslator.cpp:392
TermTranslator::getVarCount
size_t getVarCount() const
Definition: TermTranslator.cpp:447
BigIdeal::getLastTermExponentRef
mpz_class & getLastTermExponentRef(size_t var)
Definition: BigIdeal.h:126
Term
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
BigTermRecorder::empty
bool empty() const
Definition: BigTermRecorder.cpp:70
BigTermRecorder::doneConsuming
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
Definition: BigTermRecorder.cpp:67
BigTermRecorder::consume
virtual void consume(const Term &term, const TermTranslator &translator)
Definition: BigTermRecorder.cpp:44
exceptionSafePushBack
void exceptionSafePushBack(Container &container, auto_ptr< Element > pointer)
Definition: ElementDeleter.h:129
TermTranslator.h
BigTermRecorder::getRing
const VarNames & getRing()
Definition: BigTermRecorder.cpp:81
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
ASSERT
#define ASSERT(X)
Definition: stdinc.h:85
BigTermRecorder::_ideals
list< BigIdeal * > _ideals
Definition: BigTermRecorder.h:56
BigIdeal.h
BigIdeal::getVarCount
size_t getVarCount() const
Definition: BigIdeal.h:148