Frobby  0.9.5
BigattiState.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 University of Aarhus
3  Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see http://www.gnu.org/licenses/.
17 */
18 #include "stdinc.h"
19 #include "BigattiState.h"
20 
22 #include <sstream>
23 
25  const Ideal& ideal, const Term& multiply):
26  _algorithm(algorithm),
27  _ideal(ideal),
28  _multiply(multiply) {
29  ASSERT(_algorithm != 0);
31 }
32 
33 const Ideal& BigattiState::getIdeal() const {
34  return _ideal;
35 }
36 
38  return _multiply;
39 }
40 
42  return _ideal;
43 }
44 
46  return _multiply;
47 }
48 
49 size_t BigattiState::getVarCount() const {
51  return _ideal.getVarCount();
52 }
53 
55  ASSERT(var < getVarCount());
56 
60  while ((*begin)[var] == 0) {
61  ++begin;
62  ASSERT(begin != end);
63  }
64 
65  // This picks the lower median in case of a tie.
66  Exponent median = (*(begin + (distance(begin, end) - 1) / 2))[var];
67  ASSERT(median > 0);
68  return median;
69 }
70 
71 size_t BigattiState::getTypicalExponent(size_t& var, Exponent& exp) {
72  return _ideal.getTypicalExponent(var, exp);
73 }
74 
77 }
78 
79 void BigattiState::colonStep(const Term& pivot) {
80  ASSERT(pivot.getVarCount() == getVarCount());
81  _ideal.colonReminimize(pivot);
82  _multiply.product(_multiply, pivot);
83 }
84 
85 void BigattiState::addStep(const Term& pivot) {
86  ASSERT(pivot.getVarCount() == getVarCount());
87  _ideal.insertReminimize(pivot);
88 }
89 
91  _algorithm->processState(auto_ptr<BigattiState>(this));
92 }
93 
95  _algorithm->freeState(auto_ptr<BigattiState>(this));
96 }
97 
98 void BigattiState::print(FILE* out) {
99  ostringstream str;
100  print(str);
101  fputs(str.str().c_str(), out);
102 }
103 
104 void BigattiState::print(ostream& out) {
105  out << "BigattiState(multiply: " << _multiply << "\n"
106  << _ideal << ")\n";
107 }
Exponent median(const Exponent *a, size_t varCount)
Returns the lower median exponent of a.
Definition: TermExtra.cpp:25
void freeState(auto_ptr< BigattiState > state)
void processState(auto_ptr< BigattiState > state)
void colonStep(const Term &term)
size_t getTypicalExponent(size_t &var, Exponent &exp)
virtual void run(TaskEngine &tasks)
Does whatever work this task represents.
const Term & getMultiply() const
BigattiHilbertAlgorithm * _algorithm
Definition: BigattiState.h:53
size_t getVarCount() const
void addStep(const Term &term)
BigattiState(BigattiHilbertAlgorithm *algorithm, const Ideal &ideal, const Term &_multiply)
const Ideal & getIdeal() const
virtual void dispose()
Called when the task is no longer used but run has not and will not be called.
Exponent getMedianPositiveExponentOf(size_t var)
void singleDegreeSort(size_t var)
void print(FILE *out)
Represents a monomial ideal with int exponents.
Definition: Ideal.h:27
void singleDegreeSort(size_t var)
Definition: Ideal.cpp:518
Cont::const_iterator const_iterator
Definition: Ideal.h:43
size_t getTypicalExponent(size_t &var, Exponent &exp)
Sets var and exp such that var^exp is the typical non-zero exponent.
Definition: Ideal.cpp:237
void insertReminimize(const Exponent *term)
Definition: Ideal.cpp:484
const_iterator end() const
Definition: Ideal.h:49
const_iterator begin() const
Definition: Ideal.h:48
bool colonReminimize(const Exponent *colon)
Definition: Ideal.cpp:550
size_t getVarCount() const
Definition: Ideal.h:56
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
static void product(Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
Sets res equal to the product of a and b.
Definition: Term.h:280
size_t getVarCount() const
Definition: Term.h:85
unsigned int Exponent
Definition: stdinc.h:89
#define ASSERT(X)
Definition: stdinc.h:86