File: app_weightvector.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 (87 lines) | stat: -rw-r--r-- 2,129 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
#include "parser.h"
#include "printer.h"
#include "polynomial.h"
#include "division.h"
#include "buchberger.h"
#include "wallideal.h"
#include "lp.h"
#include "reversesearch.h"
#include "termorder.h"
#include "gfanapplication.h"
#include "wallideal.h"
#include "polyhedralcone.h"

class WeightVectorApplication : public GFanApplication
{
  SimpleOption optionMultiple;
  SimpleOption optionEcho;
public:
  bool includeInDefaultInstallation()
  {
    return false;
  }
  const char *helpText()
  {
    return "This program computes a strictly positive interior point of the cone given by the marked Groebner basis on the input.\n";
  }
  WeightVectorApplication():
    optionMultiple("-m","Do the same thing for a list of Groebner bases. The output is the list of interior points.\n"),
    optionEcho("-e","Echo the input. The program will output the Groebner basis before outputting its weight vector.\n")
  {
    registerOptions();
  }

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

  void process(PolynomialSet const &g)
  {
    IntegerVectorList normals=wallInequalities(g);

    if(optionEcho.getValue())
      {
	AsciiPrinter(Stdout).printString("(");
	AsciiPrinter(Stdout).printPolynomialSet(g);
	AsciiPrinter(Stdout).printString(",");
      }
    PolyhedralCone C(normals,IntegerVectorList());
    AsciiPrinter(Stdout).printVector(intersection(PolyhedralCone::positiveOrthant(C.ambientDimension()),C).getRelativeInteriorPoint());

    if(optionEcho.getValue())
      AsciiPrinter(Stdout).printString(")");
  }
  int main()
  {
    LpSolver::printList(Stderr);
    lpSetSolver("cddgmp");

    FileParser P(Stdin);



    if(optionMultiple.getValue())
      {
	fprintf(Stdout,"{\n");
	PolynomialSetList l=P.parsePolynomialSetListWithRing();
	for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++)
	  {
	    if(i!=l.begin())fprintf(Stdout,",\n");
	    process(*i);
	  }
	fprintf(Stdout,"}\n");
      }
    else
      {
	PolynomialSet p=P.parsePolynomialSetWithRing();
	process(p);
      }

    //interiorPoint(normals,Stdout,true);

    return 0;
  }
};

static WeightVectorApplication theApplication;