LatticeFormatAction.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 "LatticeFormatAction.h"
#include "BigIdeal.h"
#include "IOFacade.h"
#include "fplllIO.h"
#include "LatticeFacade.h"
#include "Scanner.h"
#include "error.h"
#include "IOHandler.h"
LatticeFormatAction::LatticeFormatAction():
Action
(staticGetName(),
"Change the representation of the input lattice.",
"By default, latformat simply writes the input lattice to output.\n"
"The main functionality is to change the format.",
false),
_inputFormat
("iformat",
"The input format. The available formats are 4ti2 and fplll.",
"4ti2"),
_outputFormat
("oformat",
"The output format. The additional format \"" +
getFormatNameIndicatingToUseInputFormatAsOutputFormat() +
"\" means use input format.",
getFormatNameIndicatingToUseInputFormatAsOutputFormat()),
_zero
("zero",
"Adjust lattice basis to increase the number of zero entries.",
false) {
}
void LatticeFormatAction::obtainParameters(vector<Parameter*>& parameters) {
Action::obtainParameters(parameters);
parameters.push_back(&_inputFormat);
parameters.push_back(&_outputFormat);
parameters.push_back(&_zero);
}
void LatticeFormatAction::perform() {
string iformat = _inputFormat.getValue();
string oformat = _outputFormat.getValue();
if (oformat == getFormatNameIndicatingToUseInputFormatAsOutputFormat())
oformat = iformat;
IOFacade facade(_printActions);
if (!facade.isValidLatticeFormat(iformat))
reportError("Unknown lattice input format \"" + iformat + "\".");
if (!facade.isValidLatticeFormat(oformat))
reportError("Unknown lattice output format \"" + oformat + "\".");
BigIdeal basis;
Scanner in(iformat, stdin);
facade.readLattice(in, basis);
in.expectEOF();
if (_zero) {
LatticeFacade latticeFacade(_printActions);
latticeFacade.makeZeroesInLatticeBasis(basis);
}
facade.writeLattice(stdout, basis, oformat);
}
const char* LatticeFormatAction::staticGetName() {
return "latformat";
}
BigIdeal.h
IOFacade.h
getFormatNameIndicatingToUseInputFormatAsOutputFormat
string getFormatNameIndicatingToUseInputFormatAsOutputFormat()
Using the returned string in place of an (output) format name indicates to use the input format as th...
Definition IOHandler.cpp:230
IOHandler.h
LatticeFacade.h
LatticeFormatAction.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
BigIdeal
Definition BigIdeal.h:27
IOFacade
A facade for input and output of mathematical objects.
Definition IOFacade.h:39
IOFacade::isValidLatticeFormat
bool isValidLatticeFormat(const string &format)
Definition IOFacade.cpp:318
IOFacade::readLattice
void readLattice(Scanner &in, BigIdeal &ideal)
Definition IOFacade.cpp:329
IOFacade::writeLattice
void writeLattice(FILE *out, const BigIdeal &ideal, const string &format)
Definition IOFacade.cpp:344
LatticeFacade
A facade for operations on lattices.
Definition LatticeFacade.h:27
LatticeFacade::makeZeroesInLatticeBasis
void makeZeroesInLatticeBasis(BigIdeal &basis)
Definition LatticeFacade.cpp:26
LatticeFormatAction::staticGetName
static const char * staticGetName()
Definition LatticeFormatAction.cpp:88
LatticeFormatAction::_zero
BoolParameter _zero
Definition LatticeFormatAction.h:37
LatticeFormatAction::perform
virtual void perform()
Definition LatticeFormatAction.cpp:61
LatticeFormatAction::LatticeFormatAction
LatticeFormatAction()
Definition LatticeFormatAction.cpp:28
LatticeFormatAction::_outputFormat
StringParameter _outputFormat
Definition LatticeFormatAction.h:36
LatticeFormatAction::_inputFormat
StringParameter _inputFormat
Definition LatticeFormatAction.h:35
LatticeFormatAction::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition LatticeFormatAction.cpp:54
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
reportError
void reportError(const string &errorMsg)
Definition error.cpp:23
error.h
fplllIO.h
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...