File: app_combinerays.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 (98 lines) | stat: -rw-r--r-- 2,670 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "parser.h"
#include "printer.h"
#include "polynomial.h"
#include "division.h"
#include "lp.h"
#include "gfanapplication.h"
#include "polyhedralcone.h"

#include "polymakefile.h"
#include "determinant.h"
#include "subspace.h"
#include "triangulation.h"

#include "symmetry.h"

class CombineRaysApplication : public GFanApplication
{
  StringOption inputOption;
  StringOption sectionOption;
  SimpleOption dumpOption;
  IntegerOption dumpHeightOption;
  IntegerOption dumpWidthOption;
public:
  const char *helpText()
  {
    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";
  }
  CombineRaysApplication():
    inputOption("-i","Specify the name of the input file.","examples/grassmann3_7.out"),
	sectionOption("--section","Specify a section of the polymake file to use as input, rather than standard input.",0),
	dumpOption("--dump","Dump specified section as a matrix rather than combining the rays"),
        dumpHeightOption("--dheight","Specify height of matrix to be dumped.",1),
        dumpWidthOption("--dwidth","Specify width of matrix to be dumped.",1)
  {
    dumpOption.hide();
    dumpHeightOption.hide();
    dumpWidthOption.hide();
    registerOptions();
  }

  const char *name()
  {
    return "_combinerays";
  }

  int main()
  {
    PolymakeFile inFile;
    inFile.open(inputOption.getValue());

    if(dumpOption.getValue())
      {
        pout<<inFile.readMatrixProperty(sectionOption.getValue(),dumpHeightOption.getValue(),dumpWidthOption.getValue()).getRows();
        return 0;
      }

    int N=inFile.readCardinalProperty("AMBIENT_DIM");

    int nRays=inFile.readCardinalProperty("N_RAYS");
    IntegerMatrix rays=inFile.readMatrixProperty("RAYS",nRays,N);


    FileParser P(Stdin);

    IntegerVectorList comb;
    if(sectionOption.getValue())
    {
		vector<list<int> > l=inFile.readMatrixIncidenceProperty(sectionOption.getValue());
		for(vector<list<int> >::const_iterator i=l.begin();i!=l.end();i++)
		{
			IntegerVector temp(i->size());
			int J=0;
			for(list<int>::const_iterator j=i->begin();j!=i->end();j++,J++)temp[J]=*j;
			comb.push_back(temp);
		}
    }
    else
    	comb=P.parseIntegerVectorList();

    IntegerVectorList result;
    for(IntegerVectorList::const_iterator j=comb.begin();j!=comb.end();j++)
      {
	IntegerVector interiorPoint(N);
	for(int i=0;i<j->size();i++)
	  {
	    interiorPoint+=rays[(*j)[i]];
	  }
	result.push_back(interiorPoint);
      }

    AsciiPrinter(Stdout).printVectorList(result);
    fprintf(Stdout,"\n");

    return 0;
  }
};

static CombineRaysApplication theApplication;