38 const Ideal& initialSubtract):
41 _initialSubtract(new
Ideal(initialSubtract)) {
54 Term sliceMultiply(varCount);
55 for (
size_t var = 0; var < varCount; ++var)
56 sliceMultiply[var] = 1;
90 ASSERT(dynamic_cast<MsmSlice*>(slice.get()) != 0);
91 return auto_ptr<MsmSlice>(
static_cast<MsmSlice*
>(slice.release()));
95 return auto_ptr<Slice>(
new MsmSlice(*
this));
100 ASSERT(dynamic_cast<MsmSlice*>(slice) != 0);
105 ASSERT(sliceParam.get() != 0);
107 auto_ptr<MsmSlice> slice
108 (static_cast<MsmSlice*>(sliceParam.release()));
110 ASSERT(!slice->adjustMultiply());
111 ASSERT(!slice->normalize());
115 Term term(slice->getVarCount());
117 const Term&
lcm = slice->getLcm();
121 bool hasTwoLabels =
false;
124 if ((*it)[var] == 1) {
128 bool couldBeLabel = !slice->getSubtract().contains(term);
130 for (
size_t v = 0; v < slice->getVarCount(); ++v) {
131 if (term[v] == lcm[v]) {
132 couldBeLabel =
false;
149 auto_ptr<Slice> hasLabelSlice;
156 *hasLabelSlice = *slice;
157 hasLabelSlice->innerSlice(term);
160 slice->outerSlice(term);
164 term.setToIdentity();
166 slice->innerSlice(term);
169 if (hasLabelSlice.get() != 0) {
260 ASSERT(sliceParam.get() != 0);
262 auto_ptr<MsmSlice> slice
263 (static_cast<MsmSlice*>(sliceParam.release()));
267 autoSplit->reset(slice->getConsumer(),
_indep);
272 auto_ptr<MsmSlice> leftSlice(
new MsmSlice(*
this));
277 auto_ptr<MsmSlice> rightSlice(
new MsmSlice(*
this));
MsmIndependenceSplit::RightConsumer _rightConsumer
Cont::const_iterator const_iterator
virtual void doneConsuming()=0
Must be called once after each time beginConsuming has been called.
void getBigProjection(Projection &projection) const
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
size_t getVarCount() const
auto_ptr< Slice > newSlice()
Returns a slice from the cache that freeSlice adds to, or allocate a new one using allocateSlice...
virtual void consume(const Term &term)
Consume a term.
virtual bool isPivotSplit() const =0
If returns true, only call getPivot.
virtual bool processSlice(TaskEngine &tasks, auto_ptr< Slice > slice)
Process the parameter slice.
A SplitStrategy is an implementation of a split selection strategy for the Slice Algorithm.
This class represents a slice, which is the central data structure of the Slice Algorithm.
virtual bool debugIsValidSlice(Slice *slice)
Check that this slice is valid for use with this strategy.
void reset(TermConsumer *consumer, IndependenceSplitter &splitter)
virtual void run(TaskEngine &engine)
Does whatever work this task represents.
void reset(size_t newVarCount)
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
Represents a monomial ideal with int exponents.
Projection _rightProjection
void lcm(Word *res, const Word *resEnd, const Word *a, const Word *b)
virtual bool isLabelSplit() const =0
If returns true, only call getLabelSplitVariable.
bool analyze(const Slice &slice)
auto_ptr< Ideal > _initialSubtract
const SplitStrategy * _split
TaskEngine _tasks
This keeps track of pending tasks to process.
A TermGrader assigns a value, the degree, to each monomial.
This class is used to transfer terms one at a time from one part of the program to another...
IndependenceSplitter _indep
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
virtual size_t getLabelSplitVariable(const Slice &slice) const =0
Returns the variable to perform a label split on.
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
TermConsumer * getLeftConsumer()
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
size_t getVarCount() const
TermConsumer * getRightConsumer()
bool getUseIndependence() const
Returns true if independence splits should be performed when possible.
const Projection & getRightProjection()
void runTasks()
Runs all pending tasks.
Projection _leftProjection
virtual void pivotSplit(auto_ptr< Slice > slice)
Takes over ownership of slice.
const_iterator end() const
virtual void beginConsuming()=0
Tell the consumer to begin consuming an ideal.
TaskEngine handles a list of tasks that are to be carried out.
virtual void consume(const Term &term)
Consume a term.
void labelSplit(auto_ptr< Slice > slice)
virtual void consume(const Term &term)=0
Consume a term.
void getRestProjection(Projection &projection) const
MsmStrategy(TermConsumer *consumer, const SplitStrategy *splitStrategy)
This class adds code to the SliceStrategy base class that is useful for derived classes.
void addTask(Task *task)
Add a task at the head of the list of pending tasks.
const Projection & getLeftProjection()
const_iterator begin() const
auto_ptr< MsmSlice > newMsmSlice()
virtual void getPivot(Term &pivot, Slice &slice) const =0
Sets pivot to the pivot of a pivot split on slice.
virtual bool simplify(Slice &slice)
Simplifies slice and returns true if it changed.
virtual auto_ptr< Slice > allocateSlice()
Directly allocate a slice of the correct type using new.
void insert(const Exponent *term)
void inverseProject(Term &to, const Exponent *from) const
virtual void getPivot(Term &pivot, Slice &slice)
Used by pivotSplit to obtain a pivot.
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
bool getUseSimplification() const
Returns true if slices should be simplified.
void independenceSplit(auto_ptr< Slice > slice)
A Task object represents a unit of work that is performed when the method run() is called...
Invariant: either the slice is a trivial base case, or removeDoubleLcm returns false.
Term represents a product of variables which does not include a coefficient.
virtual void dispose()
Called when the task is no longer used but run has not and will not be called.
size_t getRangeVarCount() const
void clearAndSetVarCount(size_t varCount)