PolyTransformAction.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#include "stdinc.h"
#include "PolyTransformAction.h"
#include "Scanner.h"
#include "IOFacade.h"
#include "BigPolynomial.h"
#include "PolynomialFacade.h"
#include "DataType.h"
PolyTransformAction::PolyTransformAction():
Action
(staticGetName(),
"Change the representation of the input polynomial.",
"By default, transform simply writes the input polynomial to output. A\n"
"number of parameters allow one to transform the input polynomial in various\n"
"ways.",
false),
_io(DataType::getPolynomialType(), DataType::getPolynomialType()),
_canonicalize
("canon",
"Sort variables and generators to get a canonical representation.",
false),
_sortTerms
("sort",
"Sort the terms.",
false) {
}
void PolyTransformAction::obtainParameters(vector<Parameter*>& parameters) {
Action::obtainParameters(parameters);
_io.obtainParameters(parameters);
parameters.push_back(&_canonicalize);
parameters.push_back(&_sortTerms);
}
void PolyTransformAction::perform() {
Scanner in(_io.getInputFormat(), stdin);
_io.autoDetectInputFormat(in);
_io.validateFormats();
IOFacade facade(_printActions);
BigPolynomial polynomial;
facade.readPolynomial(in, polynomial);
in.expectEOF();
PolynomialFacade polyFacade(_printActions);
if (_canonicalize)
polyFacade.sortVariables(polynomial);
if (_sortTerms || _canonicalize)
polyFacade.sortTerms(polynomial);
unique_ptr<IOHandler> output = _io.createOutputHandler();
facade.writePolynomial(polynomial, output.get(), stdout);
}
const char* PolyTransformAction::staticGetName() {
return "ptransform";
}
BigPolynomial.h
DataType.h
IOFacade.h
PolyTransformAction.h
PolynomialFacade.h
Scanner.h
Action::_printActions
BoolParameter _printActions
Definition Action.h:68
Action::Action
Action(const char *name, const char *shortDescription, const char *description, bool acceptsNonParameter)
Definition Action.cpp:46
Action::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition Action.cpp:133
BigPolynomial
Definition BigPolynomial.h:27
DataType
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
Definition DataType.h:29
IOFacade
A facade for input and output of mathematical objects.
Definition IOFacade.h:39
IOFacade::writePolynomial
void writePolynomial(const BigPolynomial &polynomial, IOHandler *handler, FILE *out)
Definition IOFacade.cpp:205
IOFacade::readPolynomial
void readPolynomial(Scanner &in, BigPolynomial &polynomial)
Definition IOFacade.cpp:192
PolyTransformAction::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition PolyTransformAction.cpp:48
PolyTransformAction::_sortTerms
BoolParameter _sortTerms
Definition PolyTransformAction.h:39
PolyTransformAction::staticGetName
static const char * staticGetName()
Definition PolyTransformAction.cpp:76
PolyTransformAction::_io
IOParameters _io
Definition PolyTransformAction.h:37
PolyTransformAction::PolyTransformAction
PolyTransformAction()
Definition PolyTransformAction.cpp:26
PolyTransformAction::perform
virtual void perform()
Definition PolyTransformAction.cpp:55
PolyTransformAction::_canonicalize
BoolParameter _canonicalize
Definition PolyTransformAction.h:38
PolynomialFacade
A facade for operations on polynomials.
Definition PolynomialFacade.h:28
PolynomialFacade::sortVariables
void sortVariables(BigPolynomial &poly)
Sort the variables of poly.
Definition PolynomialFacade.cpp:34
PolynomialFacade::sortTerms
void sortTerms(BigPolynomial &poly)
Sort the terms of poly.
Definition PolynomialFacade.cpp:26
Scanner
This class offers an input interface which is more convenient and for some purposes more efficient th...
Definition Scanner.h:50
Scanner::expectEOF
void expectEOF()
Require that there is no more input.
Definition Scanner.cpp:77
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...