DimensionAction.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2009 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 "DimensionAction.h"
#include "DataType.h"
#include "IOFacade.h"
#include "IdealFacade.h"
#include "Scanner.h"
#include "BigIdeal.h"
#include "BigTermConsumer.h"
#include "SliceFacade.h"
#include "SliceParams.h"
#include "NullTermConsumer.h"
#include "SliceParameters.h"
#include "error.h"
#include <algorithm>
DimensionAction::DimensionAction():
Action
(staticGetName(),
"Compute the (co)dimension of the input ideal.",
"Compute the dimension or codimension of the input ideal. This is the\n"
"dimension of the zero set of the ideal. The ideal containing the identity\n"
"has an empty zero set, and we define the dimension of this to be -1.\n"
"All other ideals have non-negative dimension.",
false),
_codimension
("codim",
"Compute the codimension instead of the dimension. The codimension is the\n"
"number of variables in the polynomial ring minus the dimension.",
false),
_squareFreeAndMinimal
("squareFreeAndMinimal",
"State that the input ideal is square free and minimally generated. This\n"
"can speed up the the computation, but will result in unpredictable\n"
"behavior if it is not true.",
false),
_useSlice
("useSlice",
"Use the Slice Algorithm to compute the dimension instead of the usual\n"
"algorithm.",
false),
_io(DataType::getMonomialIdealType(), DataType::getNullType()) {
}
void DimensionAction::obtainParameters(vector<Parameter*>& parameters) {
parameters.push_back(&_codimension);
parameters.push_back(&_squareFreeAndMinimal);
parameters.push_back(&_useSlice);
_io.obtainParameters(parameters);
Action::obtainParameters(parameters);
}
void DimensionAction::perform() {
mpz_class result;
if (_useSlice) {
SliceParams params;
params.useIndependenceSplits(false); // not supported
validateSplit(params, true, false);
SliceFacade facade(params, DataType::getNullType());
result = facade.computeDimension(_codimension);
} else {
BigIdeal ideal;
Scanner in(_io.getInputFormat(), stdin);
_io.autoDetectInputFormat(in);
_io.validateFormats();
IOFacade ioFacade(_printActions);
ioFacade.readIdeal(in, ideal);
in.expectEOF();
IdealFacade facade(_printActions);
result = facade.computeDimension(ideal,
_codimension,
_squareFreeAndMinimal);
}
gmp_fprintf(stdout, "%Zd\n", result.get_mpz_t());
}
const char* DimensionAction::staticGetName() {
return "dimension";
}
BigIdeal.h
BigTermConsumer.h
DataType.h
DimensionAction.h
IOFacade.h
IdealFacade.h
NullTermConsumer.h
Scanner.h
SliceFacade.h
SliceParameters.h
validateSplit
void validateSplit(const SliceParams &params, bool allowLabel, bool allowDegree)
Definition SliceParams.cpp:61
SliceParams.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
DataType
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
Definition DataType.h:29
DataType::getNullType
static const DataType & getNullType()
Returns the one and only instance for null.
Definition DataType.cpp:40
DimensionAction::staticGetName
static const char * staticGetName()
Definition DimensionAction.cpp:101
DimensionAction::_useSlice
BoolParameter _useSlice
Definition DimensionAction.h:38
DimensionAction::DimensionAction
DimensionAction()
Definition DimensionAction.cpp:35
DimensionAction::_io
IOParameters _io
Definition DimensionAction.h:39
DimensionAction::_codimension
BoolParameter _codimension
Definition DimensionAction.h:36
DimensionAction::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition DimensionAction.cpp:67
DimensionAction::_squareFreeAndMinimal
BoolParameter _squareFreeAndMinimal
Definition DimensionAction.h:37
DimensionAction::perform
virtual void perform()
Definition DimensionAction.cpp:75
IOFacade
A facade for input and output of mathematical objects.
Definition IOFacade.h:39
IOFacade::readIdeal
void readIdeal(Scanner &in, BigTermConsumer &consumer)
Read an ideal from in and feed it to consumer.
Definition IOFacade.cpp:81
IdealFacade
A facade for performing operations on BigIdeal.
Definition IdealFacade.h:34
IdealFacade::computeDimension
mpz_class computeDimension(const BigIdeal &ideal, bool codimension=false, bool squareFreeAndMinimal=false)
Compute the Krull dimension of ideal.
Definition IdealFacade.cpp:82
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
SliceFacade
A facade for operations on monomial ideals using the Slice Algorithm.
Definition SliceFacade.h:44
SliceFacade::computeDimension
mpz_class computeDimension(bool codimension=false)
Compute the Krull dimension of ideal.
Definition SliceFacade.cpp:114
SliceParams
Definition SliceParams.h:25
SliceParams::useIndependenceSplits
void useIndependenceSplits(bool value)
Definition SliceParams.h:34
error.h
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...