Frobby 0.9.5
IdealWriter.cpp
Go to the documentation of this file.
1/* Frobby: Software for monomial ideal computations.
2 Copyright (C) 2009 University of Aarhus
3 Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see http://www.gnu.org/licenses/.
17*/
18#include "stdinc.h"
19#include "IdealWriter.h"
20
21#include "BigIdeal.h"
22#include "Term.h"
23
24namespace IO {
26 _out(out),
27 _firstIdeal(true),
28 _firstGenerator(true) {
29 }
30
32 if (_names != names) {
33 _names = names;
34 _firstIdeal = true;
35 }
36 }
37
41
46
47 void IdealWriter::consume(const Term& term, const TermTranslator& translator) {
49 bool firstGenerator = _firstGenerator; // To get tail recursion.
50 _firstGenerator = false;
51 doWriteTerm(term, translator, firstGenerator);
52 }
53
54 void IdealWriter::consume(const vector<mpz_class>& term) {
55 ASSERT(term.size() == _names.getVarCount());
56 bool firstGenerator = _firstGenerator; // To get tail recursion.
57 _firstGenerator = false;
58 doWriteTerm(term, firstGenerator);
59 }
60
65
70
71 void IdealWriter::consume(const BigIdeal& ideal) {
72 consumeRing(ideal.getNames());
73 _firstGenerator = true;
75
76 for (size_t term = 0; term < ideal.getGeneratorCount(); ++term)
77 consume(ideal.getTerm(term));
79 }
80
81 void IdealWriter::doWriteHeader(bool firstIdeal, size_t generatorCount) {
82 doWriteHeader(firstIdeal);
83 }
84}
const vector< mpz_class > & getTerm(size_t term) const
Definition BigIdeal.h:139
const VarNames & getNames() const
Definition BigIdeal.cpp:253
size_t getGeneratorCount() const
Definition BigIdeal.h:144
virtual void consume(const Term &term, const TermTranslator &translator)
virtual void doneConsumingList()
Must be called once after each time beginConsumingList has been called.
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
IdealWriter(FILE *out)
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool firstGenerator)=0
virtual void doWriteEmptyList()=0
virtual void doWriteHeader(bool firstIdeal, size_t generatorCount)
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
VarNames _names
Definition IdealWriter.h:60
virtual void doWriteFooter(bool wasZeroIdeal)=0
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 ...
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
size_t getVarCount() const
Returns the current number of variables.
Definition VarNames.h:113
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