File: app_representatives.cpp

package info (click to toggle)
gfan 0.3dfsg-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,016 kB
  • sloc: cpp: 17,728; makefile: 251
file content (84 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download | duplicates (2)
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
#include "vektor.h"
#include "printer.h"
#include "parser.h"
#include "gfanapplication.h"
#include "minkowskisum.h"
#include "newtonpolytope.h"
#include "buchberger.h"
#include "wallideal.h"
#include "lp.h"
#include "tropical.h"
#include "division.h"
#include "bergman.h"
#include "tropical2.h"
#include "dimension.h"
#include "timer.h"

class RepresentativesApplication : public GFanApplication
{
  FieldOption theFieldOption;
public:
  bool includeInDefaultInstallation()
  {
    return false;
  }
  const char *helpText()
  {
    return "This program computes takes generaters for a subgroup of S_n and a list of n-dimensional integer vectors. The output is a list of vectors, one from each orbit of elements of the list. \n";
  }
  RepresentativesApplication()
  {
    registerOptions();
  }
  char *name()
  {
    return "_representatives";
  }
  int main()
  {
    PolynomialSetList tropical;

    lpSetSolver("cddgmp");
    FileParser P(Stdin);

    AsciiPrinter p(Stdout);
    

    IntegerVectorList generators=P.parseIntegerVectorList();
    assert(generators.size()!=0);
    int n=generators.begin()->size();
    SymmetryGroup s(n);
    s.computeClosure(generators);
    s.print(Stderr);
    fprintf(Stderr,"\n");
    
    IntegerVectorList vList=P.parseIntegerVectorList();

    IntegerVectorList rep;

    for(IntegerVectorList::const_iterator i=vList.begin();i!=vList.end();i++)
      {
	bool found=false;
	for(IntegerVectorList::const_iterator j=rep.begin();j!=rep.end();j++)
	  {
	    if(i->sum()==j->sum())
	      {
		for(SymmetryGroup::ElementContainer::const_iterator k=s.elements.begin();k!=s.elements.end();k++)
		  if(SymmetryGroup::compose(*k,*j)==*i)
		    {
		      found=true;
		      break;
		    }
	      }
	    if(found)break;
	  }
	if(!found)rep.push_back(*i);
      }

    p.printVectorList(rep);

    return 0;
  }
};

static RepresentativesApplication theApplication;