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.";
static const DataType & getPolynomialType()
Returns the one and only instance for polynomials.
static const DataType & getSatBinomIdealType()
Returns the one and only instance for saturated binomial ideals.
vector< mpz_class > & getLastTerm()
virtual void doWriteTerm(const vector< mpz_class > &term, bool first)
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
void readTerm(Scanner &in, InputConsumer &consumer)
void readIntegerAndNegativeAsZero(mpz_class &integer)
Read an integer and set it to zero if it is negative.
Represents a saturated binomial ideal.
Fourti2IdealWriter(FILE *out)
void readSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer, size_t generatorCount, size_t varCount)
static const DataType & getMonomialIdealListType()
Returns the one and only instance for monomial ideal lists.
virtual void doWriteFooter(bool wasZeroIdeal)
size_t getVarCount() const
Returns the current number of variables.
const VarNames & getNames()
void clear()
Resets the number of variables to zero.
static const char * staticGetName()
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
virtual void doWriteTerm(const mpz_class &coef, const vector< mpz_class > &term, bool firstGenerator)
virtual void consume(const mpz_class &coef, const Term &term)
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)
virtual void consume(const vector< mpz_class > &term)=0
Defines the variables of a polynomial ring and facilities IO involving them.
size_t getVarCount() const
void display4ti2Warning()
virtual void doWriteHeader(bool first, size_t generatorCount)
bool addVar(const string &name)
Adds the variable and returns true if name is not already a variable.
size_t getVarCount() const
void writeRing(const VarNames &names, FILE *out)
void readInteger(mpz_class &integer)
Read an arbitrary-precision integer.
virtual void doWriteFooter(bool wasZero)
This file contains functions for printing strings to standard error.
void writeTerm(const vector< mpz_class > &term, FILE *out)
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 class offers an input interface which is more convenient and for some purposes more efficient th...
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)
const char * getExponentString(size_t variable, Exponent exponent) const
as getExponent, except the string "e" is returned, where e is the exponent.
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool first)
const string & getName(size_t index) const
The returned reference can become invalid next time addVar is called.
virtual void doWriteHeader(size_t termCount)
bool peekIdentifier()
Skips whitespace and returns true if the next token is an identifier.
void registerInput(const DataType &type)
Specify that input of the argument type is supported.
const VarNames & getNames() const
This class contains a minimum level of functionality that makes it more convenient to derive from tha...
void readSizeT(size_t &size)
Reads a size_t, where the representable range of that type determines when the number is too big...
virtual void doWriteEmptyList()
virtual void doWriteTerm(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool firstGenerator)
virtual void doWriteHeader(bool first)
Fourti2PolyWriter(FILE *out)
void readRing(Scanner &in, VarNames &names)
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
const char * readIdentifier()
The returned string is only valid until the next method on this object gets called.
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
void expect(char expected)
Require the next character to be equal to expected.
#define INTERNAL_ERROR_UNIMPLEMENTED()
virtual void doWriteHeader()
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)
static const DataType & getMonomialIdealType()
Returns the one and only instance for monomial ideals.
void readIdeal(Scanner &in, InputConsumer &consumer, size_t generatorCount, size_t varCount)
bool hasMoreInput(Scanner &in) const
void writeTerm(const Term &term, const TermTranslator &translator, FILE *out)
void expectEOF()
Require that there is no more input.
void renameVars(const VarNames &names)
void writeRingWithoutHeader(const VarNames &names, FILE *out)
void readRing(Scanner &in, VarNames &names, size_t varCount)
void reportError(const string &errorMsg)
void expectIntegerNoSign()
Read an arbitrary-precision integer.
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
Term represents a product of variables which does not include a coefficient.
bool match(char c)
Return true if the next character is c, and in that case skip past it.
mpz_class & getLastCoef()