File: enumeration.cpp

package info (click to toggle)
gfan 0.5%2Bdfsg-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,296 kB
  • ctags: 5,612
  • sloc: cpp: 39,675; makefile: 453; sh: 1
file content (120 lines) | stat: -rw-r--r-- 2,032 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "enumeration.h"
#include <cassert>
#include "printer.h"
#include "log.h"


EnumerationFilePrinter::EnumerationFilePrinter():
  initialisedFile(0),
  file(0),
  filename("")
{
}


EnumerationFilePrinter::~EnumerationFilePrinter()
{
  assert(file==0);
}


void EnumerationFilePrinter::open(string filename)
{
  this->filename=filename;
  string name=filename+extension();
  initialisedFile=fopen(name.c_str(),"w");
  file=initialisedFile;

  assert(file);

  fprintf(Stderr,"Output file opened: \"%s\"\n",name.c_str());

  onOpened();
}


void EnumerationFilePrinter::open(FILE *file)
{
  initialisedFile=0;
  this->file=file;

  assert(file);

  onOpened();
}


void EnumerationFilePrinter::close()
{
  onClose();

  if(initialisedFile)
    {
      fclose(initialisedFile);
      onClosed();
      initialisedFile=0;
    }
  file=0;
}


string EnumerationFilePrinter::extension()
{
  return "";
}


void EnumerationAlgorithm::printProgress(int step)
{
  while(step>0)
    {
      progressCounter++;
      //      if(!(progressCounter&4095))
	//      if(!(progressCounter&255))
      if(!(progressCounter&15))
	log2 fprintf(Stderr,"Number of Gr\"obner Bases found %i\n",progressCounter);
      fflush(Stderr);
      step--;
    }
}


//--------------------------------------
// EnumerationTargetCollector
//--------------------------------------

void EnumerationTargetCollector::beginEnumeration(PolynomialSet const &g)
{
  theList=PolynomialSetList();
}


void EnumerationTargetCollector::endEnumeration()
{
}


bool EnumerationTargetCollector::basis(const PolynomialSet &groebnerBasis)
{
  theList.push_back(groebnerBasis);
  return true;
}


PolynomialSetList EnumerationTargetCollector::getList()
{
  return theList;
}

#include "traverser_groebnerfan.h"

TargetGlue::TargetGlue(EnumerationTarget &target_):
	target(target_)
	{
	}

bool TargetGlue::process(ConeTraverser &traverser)
{
	GroebnerFanTraverser &r=dynamic_cast<GroebnerFanTraverser&>(traverser);
	return target.basis(r.refToGroebnerBasisRepresentation());
}