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);
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 readCoefTerm(BigPolynomial &polynomial, bool firstTerm, Scanner &in)
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
virtual void consumeRing(const VarNames &names)=0
void eatWhite()
Reads past any whitespace, where whitespace is defined by the standard function isspace().
static const DataType & getMonomialIdealListType()
Returns the one and only instance for monomial ideal lists.
size_t getVarCount() const
Returns the current number of variables.
const VarNames & getNames()
void clear()
Resets the number of variables to zero.
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
virtual void consume(const mpz_class &coef, const Term &term)
virtual void doWriteEmptyList()
Defines the variables of a polynomial ring and facilities IO involving them.
virtual void doReadBareIdeal(Scanner &in, InputConsumer &consumer)
size_t getVarCount() const
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
This file contains functions for printing strings to standard error.
virtual void doReadRing(Scanner &in, VarNames &names)
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...
bool contains(const string &name) const
Returns true if name is the name of a variable.
This class offers an input interface which is more convenient and for some purposes more efficient th...
void writeCoefTermProduct(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool hidePlus, FILE *out)
virtual void doWriteHeader()
const string & getName(size_t index) const
The returned reference can become invalid next time addVar is called.
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
const VarNames & getNames() const
virtual void doWriteTerm(const vector< mpz_class > &term, bool first)
bool peek(char character)
Skips whitespace and returns true if the next character is equal to the parameter(s).
const char * readIdentifier()
The returned string is only valid until the next method on this object gets called.
virtual void doWriteFooter(bool wasZeroIdeal)
virtual void doWriteHeader(bool first)
virtual void doWriteTerm(const mpz_class &coef, const vector< mpz_class > &term, bool firstGenerator)
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
static const char * staticGetName()
void expect(char expected)
Require the next character to be equal to expected.
void reportSyntaxError(const Scanner &scanner, const string &errorMsg)
static const DataType & getMonomialIdealType()
Returns the one and only instance for monomial ideals.
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool first)
virtual bool doPeekRing(Scanner &in)
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)
virtual void doWriteFooter(bool wasZero)
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)
virtual void doReadBarePolynomial(Scanner &in, const VarNames &names, CoefBigTermConsumer &consumer)
Term represents a product of variables which does not include a coefficient.
virtual void beginConsuming()=0
bool match(char c)
Return true if the next character is c, and in that case skip past it.
virtual void doWriteTerm(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool firstGenerator)
virtual void doneConsuming()=0