IntersectFacade.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 "IntersectFacade.h"
#include "Term.h"
#include "BigIdeal.h"
#include "Ideal.h"
#include "intersect.h"
#include "Ideal.h"
#include "TermTranslator.h"
#include "ElementDeleter.h"
IntersectFacade::IntersectFacade(bool printActions):
Facade(printActions) {
}
unique_ptr<BigIdeal> IntersectFacade::intersect(const vector<BigIdeal*>& ideals,
const VarNames& emptyNames) {
beginAction("Intersecting ideals.");
if (ideals.empty()) {
unique_ptr<BigIdeal> entireRing(new BigIdeal(emptyNames));
entireRing->newLastTerm();
return entireRing;
}
vector<Ideal*> ideals2;
ElementDeleter<vector<Ideal*> > ideals2Deleter(ideals2);
TermTranslator translator(ideals, ideals2);
const VarNames& names = translator.getNames();
size_t variableCount = names.getVarCount();
unique_ptr<Ideal> intersection(new Ideal(variableCount));
Term identity(variableCount);
intersection->insert(identity);
for (size_t i = 0; i < ideals2.size(); ++i) {
ideals2[i]->minimize();
// Compute intersection
unique_ptr<Ideal> tmp(new Ideal(variableCount));
::intersect(tmp.get(), intersection.get(), ideals2[i]);
// Handle bookkeeping
intersection = std::move(tmp);
}
unique_ptr<BigIdeal> bigIdeal(new BigIdeal(names));
bigIdeal->insert(*intersection, translator);
endAction();
return bigIdeal;
}
BigIdeal.h
ElementDeleter.h
Ideal.h
IntersectFacade.h
TermTranslator.h
Term.h
BigIdeal
Definition BigIdeal.h:27
ElementDeleter
Definition ElementDeleter.h:50
Facade::beginAction
void beginAction(const char *message)
Prints message to standard error if printing is turned on, and records the time when the action start...
Definition Facade.cpp:38
Facade::endAction
void endAction()
Prints to standard error the time since the last call to beginAction.
Definition Facade.cpp:51
Facade::Facade
Facade(bool printActions)
Constructs a facade that prints out what it is doing if printActions is true.
Definition Facade.cpp:20
Ideal
Represents a monomial ideal with int exponents.
Definition Ideal.h:27
IntersectFacade::intersect
unique_ptr< BigIdeal > intersect(const vector< BigIdeal * > &ideals, const VarNames &names)
Returns the intersection of ideals.
Definition IntersectFacade.cpp:32
IntersectFacade::IntersectFacade
IntersectFacade(bool printActions)
Definition IntersectFacade.cpp:28
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition TermTranslator.h:41
TermTranslator::getNames
const VarNames & getNames() const
Definition TermTranslator.cpp:443
Term
Term represents a product of variables which does not include a coefficient.
Definition Term.h:49
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
VarNames::getVarCount
size_t getVarCount() const
Returns the current number of variables.
Definition VarNames.h:113
intersect.h
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...