34 string m2GetRingName(
const VarNames& names);
35 void m2WriteRing(
const VarNames& names, FILE* out);
47 fputs(
"I = monomialIdeal(",
getFile());
53 fputs(first ?
"\n " :
",\n ",
getFile());
57 for (
size_t var = 0; var < varCount; ++var)
67 fputs(first ?
"\n " :
",\n ",
getFile());
70 const size_t varCount = term.size();
71 for (
size_t var = 0; var < varCount; ++var)
107 bool firstGenerator) {
117 const vector<mpz_class>& term,
118 bool firstGenerator) {
136 "Format understandable by the program Macaulay 2.") {
172 ASSERT(ringName != 0 &&
string(ringName) !=
"");
173 if (ringName[0] !=
'R') {
175 (in,
"Expected name of ring to start with an upper case R.");
182 if (in.
peek() ==
'Z') {
183 displayNote(
"In the Macaulay 2 format, writing ZZ as the ground field "
184 "instead of QQ is deprecated and may not work in future "
185 "releases of Frobby.");
193 bool readBrace = in.
match(
'{');
195 displayNote(
"In the Macaulay 2 format, putting braces { } around the "
196 "variables is deprecated and may not work in future "
197 "releases of Frobby.");
203 }
while (in.
match(
','));
213 return in.
peek(
'R') || in.
peek(
'r');
222 in.
expect(
"monomialIdeal");
233 }
while (in.
match(
','));
256 }
while (!in.
match(
';'));
261 string m2GetRingName(
const VarNames& names) {
266 for (mpz_class i = 1;
true; ++i) {
267 name =
"R" + i.get_str();
273 void m2WriteRing(
const VarNames& names, FILE* out) {
274 fputs(m2GetRingName(names).c_str(), out);
275 fputs(
" = QQ[", out);
277 const char* pre =
"";
278 for (
unsigned int i = 0; i < names.
getVarCount(); ++i) {
282 "The name of the ring in Macaulay 2 format is usually named R,\n"
283 "but in this case there is already a variable named R. Thus,\n"
284 "the ring has been renamed to " + m2GetRingName(names) +
'.';
287 fputs(names.
getName(i).c_str(), out);
virtual void beginConsuming()=0
virtual void consume(const mpz_class &coef, const Term &term)
virtual void doneConsuming()=0
virtual void consumeRing(const VarNames &names)=0
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.
This class contains further functionality that makes it more convenient to derive from than IOHandler...
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()
virtual void doWriteTerm(const vector< mpz_class > &term, bool first)
virtual void doWriteFooter(bool wasZeroIdeal)
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool first)
virtual void doWriteHeader(bool first)
virtual void doWriteEmptyList()
virtual void doWriteFooter(bool wasZero)
virtual void doWriteTerm(const mpz_class &coef, const vector< mpz_class > &term, bool firstGenerator)
virtual void doWriteHeader()
virtual void doWriteTerm(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool firstGenerator)
virtual bool doPeekRing(Scanner &in)
virtual void doReadBareIdeal(Scanner &in, InputConsumer &consumer)
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
static const char * staticGetName()
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
virtual void doReadRing(Scanner &in, VarNames &names)
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)
virtual void doReadBarePolynomial(Scanner &in, const VarNames &names, CoefBigTermConsumer &consumer)
const VarNames & getNames() const
This class offers an input interface which is more convenient and for some purposes more efficient th...
bool peek(char character)
Skips whitespace and returns true if the next character is equal to the parameter(s).
void eatWhite()
Reads past any whitespace, where whitespace is defined by the standard function isspace().
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.
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 ...
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
size_t getVarCount() const
const VarNames & getNames() const
Term represents a product of variables which does not include a coefficient.
Defines the variables of a polynomial ring and facilities IO involving them.
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.
bool contains(const string &name) const
Returns true if name is the name of 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 reportSyntaxError(const Scanner &scanner, const string &errorMsg)
void writeCoefTermProduct(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool hidePlus, FILE *out)
void readCoefTerm(BigPolynomial &polynomial, bool firstTerm, Scanner &in)
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)