~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to app_combinerays.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "parser.h"
 
2
#include "printer.h"
 
3
#include "polynomial.h"
 
4
#include "division.h"
 
5
#include "lp.h"
 
6
#include "gfanapplication.h"
 
7
#include "polyhedralcone.h"
 
8
 
 
9
#include "polymakefile.h"
 
10
#include "determinant.h"
 
11
#include "subspace.h"
 
12
#include "triangulation.h"
 
13
 
 
14
#include "symmetry.h"
 
15
 
 
16
class CombineRaysApplication : public GFanApplication
 
17
{
 
18
  StringOption inputOption;
 
19
  StringOption sectionOption;
 
20
  SimpleOption dumpOption;
 
21
  IntegerOption dumpHeightOption;
 
22
  IntegerOption dumpWidthOption;
 
23
public:
 
24
  const char *helpText()
 
25
  {
 
26
    return "This program combines rays from the specified polymake file by adding according to a list of vectors of indices given on the standard input.\n";
 
27
  }
 
28
  CombineRaysApplication():
 
29
    inputOption("-i","Specify the name of the input file.","examples/grassmann3_7.out"),
 
30
        sectionOption("--section","Specify a section of the polymake file to use as input, rather than standard input.",0),
 
31
        dumpOption("--dump","Dump specified section as a matrix rather than combining the rays"),
 
32
        dumpHeightOption("--dheight","Specify height of matrix to be dumped.",1),
 
33
        dumpWidthOption("--dwidth","Specify width of matrix to be dumped.",1)
 
34
  {
 
35
    dumpOption.hide();
 
36
    dumpHeightOption.hide();
 
37
    dumpWidthOption.hide();
 
38
    registerOptions();
 
39
  }
 
40
 
 
41
  const char *name()
 
42
  {
 
43
    return "_combinerays";
 
44
  }
 
45
 
 
46
  int main()
 
47
  {
 
48
    PolymakeFile inFile;
 
49
    inFile.open(inputOption.getValue());
 
50
 
 
51
    if(dumpOption.getValue())
 
52
      {
 
53
        pout<<inFile.readMatrixProperty(sectionOption.getValue(),dumpHeightOption.getValue(),dumpWidthOption.getValue()).getRows();
 
54
        return 0;
 
55
      }
 
56
 
 
57
    int N=inFile.readCardinalProperty("AMBIENT_DIM");
 
58
 
 
59
    int nRays=inFile.readCardinalProperty("N_RAYS");
 
60
    IntegerMatrix rays=inFile.readMatrixProperty("RAYS",nRays,N);
 
61
 
 
62
 
 
63
    FileParser P(Stdin);
 
64
 
 
65
    IntegerVectorList comb;
 
66
    if(sectionOption.getValue())
 
67
    {
 
68
                vector<list<int> > l=inFile.readMatrixIncidenceProperty(sectionOption.getValue());
 
69
                for(vector<list<int> >::const_iterator i=l.begin();i!=l.end();i++)
 
70
                {
 
71
                        IntegerVector temp(i->size());
 
72
                        int J=0;
 
73
                        for(list<int>::const_iterator j=i->begin();j!=i->end();j++,J++)temp[J]=*j;
 
74
                        comb.push_back(temp);
 
75
                }
 
76
    }
 
77
    else
 
78
        comb=P.parseIntegerVectorList();
 
79
 
 
80
    IntegerVectorList result;
 
81
    for(IntegerVectorList::const_iterator j=comb.begin();j!=comb.end();j++)
 
82
      {
 
83
        IntegerVector interiorPoint(N);
 
84
        for(int i=0;i<j->size();i++)
 
85
          {
 
86
            interiorPoint+=rays[(*j)[i]];
 
87
          }
 
88
        result.push_back(interiorPoint);
 
89
      }
 
90
 
 
91
    AsciiPrinter(Stdout).printVectorList(result);
 
92
    fprintf(Stdout,"\n");
 
93
 
 
94
    return 0;
 
95
  }
 
96
};
 
97
 
 
98
static CombineRaysApplication theApplication;