Frobby  0.9.5
Slice.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #ifndef SLICE_GUARD
18 #define SLICE_GUARD
19 
20 #include "Ideal.h"
21 #include "Term.h"
22 #include "Task.h"
23 
24 class Projection;
25 class SliceStrategy;
26 
77 class Slice : public Task {
78  public:
82  Slice(SliceStrategy& strategy);
83 
87  Slice(SliceStrategy& strategy,
88  const Ideal& ideal, const Ideal& subtract, const Term& multiply);
89 
90  virtual ~Slice();
91 
94 
96  size_t getVarCount() const {return _varCount;}
97 
104  const Ideal& getIdeal() const {return _ideal;}
105 
108 
110  const Ideal& getSubtract() const {return _subtract;}
111 
114 
116  const Term& getMultiply() const {return _multiply;}
117 
124  const Term& getLcm() const;
125 
128  void print(FILE* file) const;
129 
131 
134 
140  virtual bool baseCase(bool simplified) = 0;
141 
143  virtual Slice& operator=(const Slice& slice) = 0;
144 
148  void resetAndSetVarCount(size_t varCount);
149 
157  void clearIdealAndSubtract();
158 
160  void singleDegreeSortIdeal(size_t var);
161 
171  virtual bool innerSlice(const Term& pivot);
172 
182  virtual void outerSlice(const Term& pivot);
183 
190  bool normalize();
191 
196  bool adjustMultiply();
197 
202  virtual bool simplify();
203 
213  virtual bool simplifyStep() = 0;
214 
216 
217  virtual void run(TaskEngine& tasks);
218  virtual void dispose();
219 
220  protected:
225  void setToProjOf(const Slice& slice, const Projection& projection);
226 
231  void swap(Slice& slice);
232 
238  bool pruneSubtract();
239 
249  bool applyLowerBound();
250 
263  virtual bool getLowerBound(Term& bound, size_t var) const = 0;
264 
267 
270 
273 
275  size_t _varCount;
276 
285  mutable Term _lcm;
286 
293  mutable bool _lcmUpdated;
294 
302 
304 };
305 
306 #endif
Represents a monomial ideal with int exponents.
Definition: Ideal.h:27
This class describes the interface of a strategy object for the Slice Algorithm.
Definition: SliceStrategy.h:33
This class represents a slice, which is the central data structure of the Slice Algorithm.
Definition: Slice.h:77
size_t _varCount
The number of variables in the ambient polynomial ring.
Definition: Slice.h:275
Ideal _ideal
The of a slice .
Definition: Slice.h:266
void resetAndSetVarCount(size_t varCount)
Resets this slice to in an ambient polynomial ring of varCount variables.
Definition: Slice.cpp:89
SliceStrategy & _strategy
Definition: Slice.h:303
bool normalize()
Removes those generators of getIdeal() that are strictly divisible by some generator of getSubtract()...
Definition: Slice.cpp:189
void singleDegreeSortIdeal(size_t var)
Calls Ideal::singleDegreeSort on getIdeal().
Definition: Slice.cpp:106
void print(FILE *file) const
Write a text representation of this object to file in a format appropriate for debugging.
Definition: Slice.cpp:68
virtual bool innerSlice(const Term &pivot)
Sets this object to the inner slice according to pivot.
Definition: Slice.cpp:110
virtual void outerSlice(const Term &pivot)
Sets this object to the outer slice according to pivot.
Definition: Slice.cpp:132
size_t _lowerBoundHint
A hint that starting simplification through a lower bound at the variable indicated by _lowerBoundHin...
Definition: Slice.h:301
virtual Slice & operator=(const Slice &slice)=0
Performs a deep copy of slice into this object.
Definition: Slice.cpp:77
const Ideal & getIdeal() const
Returns for a slice .
Definition: Slice.h:104
bool adjustMultiply()
Ensure that for each var, var appears to the first power in some generator of getIdeal().
Definition: Slice.cpp:162
void setToProjOf(const Slice &slice, const Projection &projection)
Set this object to be the projection of slice according to projection.
Definition: Slice.cpp:218
Term _multiply
The of a slice .
Definition: Slice.h:272
void swap(Slice &slice)
Simultaneously set the value of this object to that of slice and vice versa.
Definition: Slice.cpp:252
Ideal & getSubtract()
Returns for a slice .
Definition: Slice.h:107
Slice(SliceStrategy &strategy)
Construct the slice in a ring of zero variables.
Definition: Slice.cpp:26
bool pruneSubtract()
Removes those generators of subtract that do not strictly divide the lcm of getIdeal(),...
Definition: Slice.cpp:281
virtual void run(TaskEngine &tasks)
Does whatever work this task represents.
Definition: Slice.cpp:321
Term _lcm
The lcm of getIdeal() if _lcmUpdated is true, and otherwise the value is undefind.
Definition: Slice.h:285
void clearIdealAndSubtract()
Clears getIdeal() and getSubtract() and does not change getMultiply().
Definition: Slice.cpp:99
bool applyLowerBound()
Calculates a lower bound on the content of the slice using getLowerBound() and calls innerSlice with ...
Definition: Slice.cpp:289
virtual bool getLowerBound(Term &bound, size_t var) const =0
Calculates a lower bound that depends on var.
Term & getMultiply()
Returns for a slice .
Definition: Slice.h:113
const Term & getLcm() const
Returns the least common multiple of the generators of getIdeal().
Definition: Slice.cpp:52
bool _lcmUpdated
Indicates whether _lcm is correct.
Definition: Slice.h:293
const Ideal & getSubtract() const
Returns for a slice .
Definition: Slice.h:110
Ideal _subtract
The of a slice .
Definition: Slice.h:269
size_t getVarCount() const
Returns the number of variables in the ambient ring.
Definition: Slice.h:96
virtual bool baseCase(bool simplified)=0
Returns true if this slice is a base case slice, and in that case produces output in a derivative-spe...
const Term & getMultiply() const
Returns for a slice .
Definition: Slice.h:116
virtual bool simplifyStep()=0
Like simplify(), except that only one simplification step is performed.
virtual ~Slice()
Definition: Slice.cpp:47
virtual void dispose()
Called when the task is no longer used but run has not and will not be called.
Definition: Slice.cpp:325
virtual bool simplify()
Simplifies this object such that it may become simpler without changing the content.
Definition: Slice.cpp:204
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
A Task object represents a unit of work that is performed when the method run() is called.
Definition: Task.h:27
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49