44 void writeTerm(
const vector<mpz_class>& term, FILE* out);
50 size_t generatorCount,
54 size_t generatorCount,
58 namespace F = Fourti2;
72 (
unsigned long)generatorCount,
73 (
unsigned long)
getNames().getVarCount());
82 virtual void doWriteTerm(
const vector<mpz_class>& term,
bool first) {
107 fprintf(
getFile(),
"%lu %lu\n",
108 (
unsigned long)termCount,
109 (
unsigned long)
getNames().getVarCount() + 1);
115 bool firstGenerator) {
118 mpz_out_str(
getFile(), 10, coef.get_mpz_t());
128 const vector<mpz_class>& term,
129 bool firstGenerator) {
132 mpz_out_str(
getFile(), 10, coef.get_mpz_t());
142 fputs(
"(coefficient)",
getFile());
152 "Format used by the software package 4ti2.") {
186 fputs(
"_fourtitwo_identity", out);
196 size_t generatorCount;
213 size_t generatorCount;
236 size_t generatorCount;
244 (
"A polynomial has at least one column in the matrix,"
245 "but this matrix has no columns.");
253 for (
size_t t = 0; t < generatorCount; ++t) {
258 vector<mpz_class>& term = polynomial.
getLastTerm();
259 for (
size_t var = 0; var < varCount; ++var) {
260 ASSERT(var < term.size());
265 if (!in.
match(
'(')) {
268 in.
expect(
"(coefficient)");
275 for (
size_t var = 0; var < varCount; ++var)
285 size_t generatorCount;
295 fputs(
"42 ring\n", out);
304 for (
size_t var = 0; var < names.
getVarCount(); ++var) {
307 fputs(names.
getName(var).c_str(), out);
316 in.
expect(
"_fourtitwo_identity");
318 for (
size_t var = 0; var < varCount; ++var) {
336 for (
size_t var = 0; var < varCount; ++var)
340 void F::writeTerm(
const vector<mpz_class>& term, FILE* out) {
341 size_t varCount = term.size();
342 for (
size_t var = 0; var < varCount; ++var) {
344 mpz_out_str(out, 10, term[var].get_mpz_t());
357 for (
size_t var = 0; var < varCount; ++var) {
377 size_t generatorCount,
383 for (
size_t t = 0; t < generatorCount; ++t) {
388 for (
size_t t = 0; t < generatorCount; ++t)
402 size_t generatorCount,
409 ideal.reserve(generatorCount);
410 for (
size_t t = 0; t < generatorCount; ++t) {
413 vector<mpz_class>& binom = ideal.getLastBinomRef();
414 for (
size_t var = 0; var < varCount; ++var)
421 ideal.renameVars(names);
428 string msg =
"Using the format ";
430 msg +=
" makes it necessary to store all of the output in "
431 "memory before writing it out. This increases "
432 "memory consumption and decreases performance.";
mpz_class & getLastCoef()
void renameVars(const VarNames &names)
vector< mpz_class > & getLastTerm()
virtual void consume(const mpz_class &coef, const Term &term)
static const DataType & getSatBinomIdealType()
Returns the one and only instance for saturated binomial ideals.
static const DataType & getMonomialIdealListType()
Returns the one and only instance for monomial ideal lists.
static const DataType & getMonomialIdealType()
Returns the one and only instance for monomial ideals.
static const DataType & getPolynomialType()
Returns the one and only instance for polynomials.
bool hasMoreInput(Scanner &in) const
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
static const char * staticGetName()
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)
virtual void doWriteTerm(const vector< mpz_class > &term, bool first)
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool first)
Fourti2IdealWriter(FILE *out)
virtual void doWriteEmptyList()
virtual void doWriteHeader(bool first, size_t generatorCount)
virtual void doWriteFooter(bool wasZeroIdeal)
virtual void doWriteHeader(bool first)
virtual void doWriteFooter(bool wasZero)
virtual void doWriteTerm(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool firstGenerator)
virtual void doWriteHeader(size_t termCount)
Fourti2PolyWriter(FILE *out)
virtual void doWriteTerm(const mpz_class &coef, const vector< mpz_class > &term, bool firstGenerator)
virtual void doWriteHeader()
This class contains a minimum level of functionality that makes it more convenient to derive from tha...
void registerInput(const DataType &type)
Specify that input of the argument type is supported.
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
const VarNames & getNames()
const VarNames & getNames() const
virtual void consume(const vector< mpz_class > &term)=0
Represents a saturated binomial ideal.
This class offers an input interface which is more convenient and for some purposes more efficient th...
void expectEOF()
Require that there is no more input.
void readIntegerAndNegativeAsZero(mpz_class &integer)
Read an integer and set it to zero if it is negative.
void expectIntegerNoSign()
Read an arbitrary-precision integer.
void expect(char expected)
Require the next character to be equal to expected.
const char * readIdentifier()
The returned string is only valid until the next method on this object gets called.
bool peekIdentifier()
Skips whitespace and returns true if the next token is an identifier.
void readSizeT(size_t &size)
Reads a size_t, where the representable range of that type determines when the number is too big.
void readInteger(mpz_class &integer)
Read an arbitrary-precision integer.
bool match(char c)
Return true if the next character is c, and in that case skip past it.
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
size_t getVarCount() const
const char * getExponentString(size_t variable, Exponent exponent) const
as getExponent, except the string "e" is returned, where e is the exponent.
Term represents a product of variables which does not include a coefficient.
size_t getVarCount() const
Defines the variables of a polynomial ring and facilities IO involving them.
bool addVar(const string &name)
Adds the variable and returns true if name is not already a variable.
size_t getVarCount() const
Returns the current number of variables.
const string & getName(size_t index) const
The returned reference can become invalid next time addVar is called.
void clear()
Resets the number of variables to zero.
void addVarSyntaxCheckUnique(const Scanner &in, const string &name)
As addvar, except it reports a syntax error if name is already a variable.
void displayNote(const string &msg)
Display msg to standard error in a way that indicates that this is something that the user should tak...
This file contains functions for printing strings to standard error.
void reportError(const string &errorMsg)
#define INTERNAL_ERROR_UNIMPLEMENTED()
void writeTerm(const vector< mpz_class > &term, FILE *out)
void writeTerm(const Term &term, const TermTranslator &translator, FILE *out)
void writeRing(const VarNames &names, FILE *out)
void writeRingWithoutHeader(const VarNames &names, FILE *out)
void readRing(Scanner &in, VarNames &names)
void readIdeal(Scanner &in, InputConsumer &consumer, size_t generatorCount, size_t varCount)
void readSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer, size_t generatorCount, size_t varCount)
void display4ti2Warning()
void readRing(Scanner &in, VarNames &names, size_t varCount)
void readTerm(Scanner &in, InputConsumer &consumer)