1 // This is a -*- C++ -*- header file.
2 
3 /* Cone.cpp -- Barvinok's decomposition of a cone.
4 
5    Copyright 2002, 2003 Raymond Hemmecke, Ruriko Yoshida
6    Copyright 2006 Matthias Koeppe
7 
8    This file is part of LattE.
9 
10    LattE is free software; you can redistribute it and/or modify it
11    under the terms of the version 2 of the GNU General Public License
12    as published by the Free Software Foundation.
13 
14    LattE is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with LattE; if not, write to the Free Software Foundation,
21    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 */
23 
24 #ifndef BARVINOK_DEC_H
25 #define BARVINOK_DEC_H
26 
27 #include "../flags.h"
28 #include "PolyTree.h"
29 #include "barvinok.h"
30 
31 
32 // The traditional LattE mode: Simply collect all subdivided cones
33 // into a list.
34 class Collecting_Single_Cone_Parameters : public Single_Cone_Parameters {
35 public:
36   Collecting_Single_Cone_Parameters();
37   Collecting_Single_Cone_Parameters(const BarvinokParameters &params);
38   listCone *Decomposed_Cones;
39   virtual int ConsumeCone(listCone *cone);
40 };
41 
42 // Obsolete:
43 listCone*
44 decomposeCones(listCone *cones, int numOfVars, unsigned int Flags,
45 	       const char *File_Name, int max_determinant,
46 	       bool dualize,
47 	       BarvinokParameters::DecompositionType decomposition,
48 	       bool debug_triangulation = false);
49 // Nicer, more general interface:
50 listCone*
51 decomposeCones(listCone *cones, bool dualize,
52 	       BarvinokParameters &param);
53 
54 
55 /* Guess a generic vector; this is simply a random vector. */
56 vec_ZZ
57 guess_generic_vector(int numOfVars);
58 
59 /* Functions can throw this exception when they discover the
60    passed vector was not generic. */
61 struct NotGenericException {};
62 
63 class Generic_Vector_Single_Cone_Parameters : public Single_Cone_Parameters {
64 public:
65   vec_ZZ generic_vector;
66   virtual void InitializeComputation();
Generic_Vector_Single_Cone_Parameters()67   Generic_Vector_Single_Cone_Parameters() {};
Generic_Vector_Single_Cone_Parameters(const BarvinokParameters & params)68   Generic_Vector_Single_Cone_Parameters(const BarvinokParameters &params) :
69     Single_Cone_Parameters(params) {};
70 };
71 
72 /* Pick a tentative generic vector by calling InitializeComputation().
73    Then call barvinokDecomposition_Single on all CONES.  This results
74    in ConsumeCone() being called on all resulting small cones; when
75    any ConsumeCone() call returns with -1, restart the computation by
76    calling InitializeComputation() and start decomposing again. */
77 void
78 barvinokDecomposition_List(listCone *cones,
79 			   Generic_Vector_Single_Cone_Parameters &Parameters);
80 
81 
82 // The "Memory Save" mode: Perform residue calculations immediately
83 // at each subdivided cone in the tree, don't store the cones.
84 //
85 // FIXME: Later we will reduce the slots in this class and use further
86 // subclassing for the individual computation modes.  For instance,
87 // Taylor_Expansion_Result is only used in the "dual" method.  -- mkoeppe
88 
89 class Standard_Single_Cone_Parameters
90   : public Generic_Vector_Single_Cone_Parameters {
91  public:
92 	int		Degree_of_Taylor_Expansion;
93 
94 	ZZ		*Taylor_Expansion_Result;
95 	ZZ		Ten_Power;
96 	ZZ		Total_Lattice_Points;
97 
98 	Node_Controller *Controller;
99  public:
Standard_Single_Cone_Parameters()100   Standard_Single_Cone_Parameters() {};
Standard_Single_Cone_Parameters(const BarvinokParameters & params)101   Standard_Single_Cone_Parameters(const BarvinokParameters &params) :
102     Generic_Vector_Single_Cone_Parameters(params) {};
103   virtual void InitializeComputation();
104   virtual int ConsumeCone(listCone *cone);
105 };
106 
107 // Decompose the polyhedral CONES down to MAX_DETERMINANT.  Then
108 // perform residue calculations and print results.  When DUALIZE is
109 // true, the CONES are given in primal space, so dualize before
110 // triangulating; otherwise CONES must be given in dual space already.
111 // returns the polynomial series.
112 vec_ZZ
113 decomposeAndComputeResidue(listCone *cones, int degree, bool dualize,
114 			   Standard_Single_Cone_Parameters &param);
115 
116 // Likewise, deprecated interface.
117 void decomposeCones_Single (listCone *cones, int numOfVars, int degree,
118 			    unsigned int flags, char *File_Name,
119 			    int max_determinant,
120 			    bool dualize,
121 			    BarvinokParameters::DecompositionType decomposition);
122 
123 #endif
124