1 #include "parser.h"
2 #include "printer.h"
3 #include "polynomial.h"
4 #include "division.h"
5 #include "buchberger.h"
6 #include "wallideal.h"
7 #include "lp.h"
8 #include "reversesearch.h"
9 #include "termorder.h"
10 #include "ep_standard.h"
11 #include "ep_xfig.h"
12 #include "gfanapplication.h"
13 #include "polyhedralcone.h"
14 #include "polyhedralfan.h"
15 #include "tropical.h"
16 #include "tropical2.h"
17 #include "symmetry.h"
18 #include "halfopencone.h"
19 #include "log.h"
20 #include "field_rationals.h"
21 
22 class TropicalFunctionApplication : public GFanApplication
23 {
24   SimpleOption exponentOption;
25 public:
helpText()26   const char *helpText()
27   {
28     return "This program takes a polynomial and tropicalizes it. The output is piecewise linear function represented by a fan whose cones are the linear regions. Each ray of the fan gets the value of the tropical function assigned to it. In other words this program computes the normal fan of the Newton polytope of the input polynomial with additional information.";
29   }
TropicalFunctionApplication()30   TropicalFunctionApplication():
31     exponentOption("--exponents","Tell program to read a list of exponent vectors instead.")
32   {
33     registerOptions();
34   }
name()35   const char *name()
36   {
37     return "_tropicalfunction";
38   }
inner(PolynomialSet const & f)39   void inner(PolynomialSet const &f)
40   {
41     PolyhedralFan F=PolyhedralFan::normalFanOfNewtonPolytope(*f.begin());
42 
43     {
44       AsciiPrinter p(Stdout);
45       PolyhedralFan a=F;
46       a.printWithIndices(&p,FPF_default|FPF_values);
47     }
48   }
main()49   int main()
50   {
51     FileParser P(Stdin);
52 
53 
54     if(!exponentOption.getValue())
55       {
56         PolynomialSet f=P.parsePolynomialSetWithRing();
57         inner(f);
58       }
59     else
60       {
61         IntegerVectorList exponents=P.parseIntegerVectorList();
62         assert(exponents.size());
63         int n=exponents.begin()->size();
64         PolynomialRing R(Q,n);
65         Polynomial p(R);
66         for(IntegerVectorList::const_iterator i=exponents.begin();i!=exponents.end();i++)
67           {
68             p+=Term(Q.zHomomorphism(1),Monomial(R,*i));
69           }
70         PolynomialSet f(R);
71         f.push_back(p);
72         inner(f);
73       }
74 
75     return 0;
76   }
77 };
78 
79 static TropicalFunctionApplication theApplication;
80