Go to the documentation of this file.
37 const char* formatDescription):
38 _formatName(formatName),
39 _formatDescription(formatDescription) {
51 return std::find(_supportedInputs.begin(), _supportedInputs.end(),
52 &type) != _supportedInputs.end();
56 return std::find(_supportedOutputs.begin(), _supportedOutputs.end(),
57 &type) != _supportedOutputs.end();
62 ASSERT(!supportsInput(type));
64 _supportedInputs.push_back(&type);
69 ASSERT(!supportsOutput(type));
71 _supportedOutputs.push_back(&type);
105 return _formatDescription;
110 vector<mpz_class>& term) {
112 for (
size_t var = 0; var < term.size(); ++var)
120 }
while (in.
match(
'*'));
128 if (coef >= 0 && !hidePlus)
132 gmp_fprintf(out,
"%Zd", coef.get_mpz_t());
139 gmp_fprintf(out,
"%Zd*", coef.get_mpz_t());
145 const vector<mpz_class>& term,
149 if (coef >= 0 && !hidePlus)
153 for (
size_t var = 0; var < term.size(); ++var)
158 gmp_fprintf(out,
"%Zd", coef.get_mpz_t());
165 gmp_fprintf(out,
"%Zd*", coef.get_mpz_t());
173 bool seenNonZero =
false;
175 for (
size_t var = 0; var < varCount; ++var) {
195 bool seenNonZero =
false;
196 size_t varCount = term.size();
197 for (
size_t var = 0; var < varCount; ++var) {
206 fputs(names.
getName(var).c_str(), out);
207 if ((term[var]) != 1) {
209 mpz_out_str(out, 10, term[var].get_mpz_t());
225 }
while (in.
match(
'*'));
229 vector<mpz_class>& term,
234 for (
size_t var = 0; var < term.size(); ++var)
237 bool positive =
true;
238 if (!firstTerm && in.
match(
'+'))
239 positive = !in.
match(
'-');
240 else if (in.
match(
'-'))
242 else if (!firstTerm) {
255 while (in.
match(
'*'))
267 vector<mpz_class>& term = polynomial.
getLastTerm();
277 if (term[var] != 0) {
278 const string& name = names.
getName(var);
280 name +
" appears more than once in monomial.");
285 if (term[var] <= 0) {
287 errorMsg <<
"Expected positive integer as exponent but got "
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
void readCoefTerm(BigPolynomial &polynomial, bool firstTerm, Scanner &in)
static bool isIdentity(const Exponent *a, size_t varCount)
Returns whether a is 1, i.e. whether all entries of a are 0.
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)=0
const char * getVarExponentString(size_t variable, Exponent exponent) const
As getExponent, except the string "var^e" is returned or null if the exponent is zero,...
vector< mpz_class > & getLastTermRef()
void readInteger(mpz_class &integer)
Read an arbitrary-precision integer.
virtual const char * doGetDescription() const
IOHandlerImpl(const char *formatName, const char *formatDescription)
mpz_class & getLastCoef()
void readVarPower(vector< mpz_class > &term, const VarNames &names, Scanner &in)
This class offers an input interface which is more convenient and for some purposes more efficient th...
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)
void registerInput(const DataType &type)
Specify that input of the argument type is supported.
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
const VarNames & getNames() const
size_t readVariable(const VarNames &names)
Reads an identifier and returns the index of that identifier as the index of a variable in names.
size_t getVarCount() const
bool match(char c)
Return true if the next character is c, and in that case skip past it.
const string & getName(size_t index) const
The returned reference can become invalid next time addVar is called.
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
virtual bool doHasMoreInput(Scanner &in) const
size_t getVarCount() const
Returns the current number of variables.
bool matchEOF()
Return true if no more input.
Term represents a product of variables which does not include a coefficient.
void writeCoefTermProduct(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool hidePlus, FILE *out)
vector< mpz_class > & getLastTerm()
void expect(char expected)
Require the next character to be equal to expected.
void reportSyntaxError(const Scanner &scanner, const string &errorMsg)
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
const VarNames & getNames() const
virtual const char * doGetName() const
#define INTERNAL_ERROR_UNIMPLEMENTED()
A replacement for stringstream.
virtual void doReadTerm(Scanner &in, InputConsumer &term)
bool peekIdentifier()
Skips whitespace and returns true if the next token is an identifier.
Defines the variables of a polynomial ring and facilities IO involving them.
bool isNull() const
Returns true if this object was returned by getNullType().
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
void readTermProduct(Scanner &in, const VarNames &names, vector< mpz_class > &term)
virtual bool doSupportsInput(const DataType &type) const
virtual bool doSupportsOutput(const DataType &type) const
bool isIdentity(const Word *a, Word *aEnd)