47 vector<mpz_class>& term,
119 const vector<mpz_class>& term,
125 bool isIdentity =
true;
126 for (
size_t var = 0; var < term.size(); ++var)
152 "Format understandable by the program CoCoA 4.") {
206 for (
size_t var = 0; var <
varCount; ++var) {
211 names.addVarSyntaxCheckUnique(
in,
in.readIdentifier());
226 return in.peek(
'U') ||
in.peek(
'u');
238 if (!
in.match(
')')) {
241 }
while (
in.match(
','));
253 vector<mpz_class> term(
names.getVarCount());
265 }
while (!
in.match(
';'));
270 if (
names.getVarCount() == 0) {
271 fputs(
"Use R ::= Q[x];\nNames := [];\n",
out);
276 (
unsigned long)
names.getVarCount());
280 const char*
pre =
"\"";
281 for (
size_t i = 0;
i <
names.getVarCount(); ++
i) {
294 for (
size_t var = 0; var <
varCount; ++var) {
295 const char*
exp =
translator.getExponentString(var, term[var]);
300 fprintf(
out,
"x[%lu]", (
unsigned long)(var + 1));
301 if (
exp[0] !=
'1' ||
exp[1] !=
'\0') {
316 for (
size_t var = 0; var <
varCount; ++var) {
321 fprintf(
out,
"x[%lu]", (
unsigned long)(var + 1));
322 if (term[var] != 1) {
333 for (
size_t var = 0; var < term.size(); ++var)
342 }
while (
in.peek() ==
'x');
347 if (!
in.match(
'1')) {
351 }
while (
in.peek() ==
'x');
362 if (var == 0 || var > term.size()) {
364 errorMsg <<
"There is no variable x[" << var <<
"].";
371 if (term[var] != 0) {
375 <<
"] appears twice in the same monomial.";
380 in.readInteger(term[var]);
381 if (term[var] <= 0) {
383 errorMsg <<
"Expected positive integer as exponent but got "
403 vector<mpz_class>& term,
406 for (
size_t var = 0; var < term.size(); ++var)
412 else if (
in.match(
'-'))
418 if (
in.match(
'+') ||
in.match(
'-'))
421 if (
in.peekIdentifier()) {
425 in.readInteger(coef);
428 while (
in.peek() ==
'x') {
void nameFactoryRegister(NameFactory< AbstractProduct > &factory)
Registers the string returned by ConcreteProduct::getStaticName() to a function that default-construc...
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.
A replacement for stringstream.
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)
virtual void doReadBarePolynomial(Scanner &in, const VarNames &names, CoefBigTermConsumer &consumer)
virtual void doReadBareIdeal(Scanner &in, InputConsumer &consumer)
virtual void doReadRing(Scanner &in, VarNames &names)
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)
static const char * staticGetName()
virtual bool doPeekRing(Scanner &in)
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
CoCoA4IdealWriter(FILE *out)
virtual void doWriteEmptyList()
virtual void doWriteTerm(const Term &term, const TermTranslator &translator, bool first)
virtual void doWriteFooter(bool wasZeroIdeal)
virtual void doWriteHeader(bool first)
virtual void doWriteTerm(const vector< mpz_class > &term, bool first)
virtual void doWriteTerm(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool firstGenerator)
virtual void doWriteHeader()
virtual void doWriteFooter(bool wasZero)
CoCoA4PolyWriter(FILE *out)
virtual void doWriteTerm(const mpz_class &coef, const vector< mpz_class > &term, bool firstGenerator)
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()
const VarNames & getNames() const
This class offers an input interface which is more convenient and for some purposes more efficient th...
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Term represents a product of variables which does not include a coefficient.
size_t getVarCount() const
static bool isIdentity(const Exponent *a, size_t varCount)
Returns whether a is 1, i.e. whether all entries of a are 0.
Defines the variables of a polynomial ring and facilities IO involving them.
void reportSyntaxError(const Scanner &scanner, const string &errorMsg)
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)
void readCoefTerm(mpz_class &coef, vector< mpz_class > &term, bool firstTerm, Scanner &in)
void readTerm(Scanner &in, vector< mpz_class > &term)
void readVarPower(vector< mpz_class > &term, Scanner &in)
void writeRing(const VarNames &names, FILE *out)