GenerateFrobeniusAction.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 "GenerateFrobeniusAction.h"
#include "BigIdeal.h"
#include "GenerateDataFacade.h"
#include "IOFacade.h"
#include "error.h"
GenerateFrobeniusAction::GenerateFrobeniusAction():
Action
(staticGetName(),
"Generate a random Frobenius problem instance.",
"Generate a random Frobenius problem instance.",
false),
_entryCount
("entryCount",
"The number of entries in the random instance.",
4),
_maxEntryDigits
("maxEntryDigits",
"The largest allowed number of decimal digits for entries in the\n"
"random instance.",
2) {
}
void GenerateFrobeniusAction::
obtainParameters(vector<Parameter*>& parameters) {
Action::obtainParameters(parameters);
parameters.push_back(&_entryCount);
parameters.push_back(&_maxEntryDigits);
}
void GenerateFrobeniusAction::perform() {
vector<mpz_class> instance;
if (_entryCount < 1)
reportError("There must be at least one entry.");
if (_maxEntryDigits < 1)
reportError("The largest allowed number of digits must be at least 1.");
mpz_class maxEntry;
mpz_ui_pow_ui(maxEntry.get_mpz_t(), 10, _maxEntryDigits.getValue());
GenerateDataFacade generator(_printActions);
generator.generateFrobeniusInstance
(instance, _entryCount.getValue(), maxEntry);
IOFacade ioFacade(_printActions);
ioFacade.writeFrobeniusInstance(stdout, instance);
}
const char* GenerateFrobeniusAction::staticGetName() {
return "genfrob";
}
BigIdeal.h
GenerateDataFacade.h
GenerateFrobeniusAction.h
IOFacade.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
GenerateDataFacade
A facade for random and other kinds of data.
Definition GenerateDataFacade.h:29
GenerateDataFacade::generateFrobeniusInstance
void generateFrobeniusInstance(vector< mpz_class > &instance, size_t entryCount, const mpz_class &maxEntry)
Definition GenerateDataFacade.cpp:113
GenerateFrobeniusAction::_entryCount
IntegerParameter _entryCount
Definition GenerateFrobeniusAction.h:34
GenerateFrobeniusAction::GenerateFrobeniusAction
GenerateFrobeniusAction()
Definition GenerateFrobeniusAction.cpp:25
GenerateFrobeniusAction::_maxEntryDigits
IntegerParameter _maxEntryDigits
Definition GenerateFrobeniusAction.h:35
GenerateFrobeniusAction::perform
virtual void perform()
Definition GenerateFrobeniusAction.cpp:51
GenerateFrobeniusAction::staticGetName
static const char * staticGetName()
Definition GenerateFrobeniusAction.cpp:70
GenerateFrobeniusAction::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition GenerateFrobeniusAction.cpp:45
IOFacade
A facade for input and output of mathematical objects.
Definition IOFacade.h:39
IOFacade::writeFrobeniusInstance
void writeFrobeniusInstance(FILE *out, vector< mpz_class > &instance)
Definition IOFacade.cpp:305
reportError
void reportError(const string &errorMsg)
Definition error.cpp:23
error.h
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...