source: git/dyn_modules/callgfanlib/gfan.h @ 6aee8f

spielwiese
Last change on this file since 6aee8f was 24aeb0f, checked in by Hans Schoenemann <hannes@…>, 10 years ago
fix: cddlib detection for fedora
  • Property mode set to 100644
File size: 9.7 KB
Line 
1/*
2gfan.h Interface to gfan.cc
3
4Author: monerjan
5*/
6#ifndef GFAN_H
7#define GFAN_H
8
9#include <libpolys/misc/int64vec.h>
10
11#include <gfanlib/config.h>
12#ifdef HAVE_CDD_SETOPER_H
13#include <cdd/setoper.h>
14#include <cdd/cdd.h>
15#include <cdd/cddmp.h>
16#elif HAVE_CDDLIB_SETOPER_H
17#include <cddlib/setoper.h>
18#include <cddlib/cdd.h>
19#include <cddlib/cddmp.h>
20#else
21#include <setoper.h>
22#include <cdd.h>
23#include <cddmp.h>
24#endif
25#include <bbfan.h>
26#include <bbcone.h>
27extern int gfanHeuristic;
28
29#ifndef USE_ZFAN
30#define USE_ZFAN
31#endif
32#ifndef USE_ZFAN
33  lists grfan(ideal inputIdeal, int heuristic, bool singleCone);
34#else
35  #include <gfanlib/gfanlib.h>
36  gfan::ZFan *grfan(ideal inputIdeal, int h, bool singleCone);
37#endif
38// lists grcone_by_intvec(ideal inputIdeal);
39
40class facet
41{
42        private:
43                /** \brief Inner normal of the facet, describing it uniquely up to isomorphism */
44                int64vec *fNormal;
45
46                /** \brief An interior point of the facet*/
47                int64vec *interiorPoint;
48
49                /** \brief Universal Cone Number
50                 * The number of the cone the facet belongs to, Set in getConeNormals()
51                 */
52                int UCN;
53
54                /** \brief The codim of the facet
55                 */
56                short codim;
57
58                /** \brief The Groebner basis on the other side of a shared facet
59                 *
60                 * In order not to have to compute the flipped GB twice we store the basis we already get
61                 * when identifying search facets. Thus in the next step of the reverse search we can
62                 * just copy the old cone and update the facet and the gcBasis.
63                 * facet::flibGB is set via facet::setFlipGB() and printed via facet::printFlipGB
64                 */
65                ideal flipGB;           //The Groebner Basis on the other side, computed via gcone::flip
66
67        public:
68                /** \brief Boolean value to indicate whether a facet is flippable or not
69                * This is also used to mark facets that nominally are flippable but which do
70                * not intersect with the positive orthant. This check is done in gcone::getCodim2Normals
71                 */
72                bool isFlippable;       //**flippable facet? */
73                //bool isIncoming;      //Is the facet incoming or outgoing in the reverse search? No longer in use
74                facet *next;            //Pointer to next facet
75                facet *prev;            //Pointer to predecessor. Needed for the SearchList in noRevS
76                facet *codim2Ptr;       //Pointer to (codim-2)-facet. Bit of recursion here ;-)
77                int numCodim2Facets;    //#of (codim-2)-facets of this facet. Set in getCodim2Normals()
78                unsigned numRays;       //Number of spanning rays of the facet
79                ring flipRing;          //the ring on the other side of the facet
80//              int64vec **fRays;
81
82                /** The default constructor. */
83                facet();
84                /** Constructor for lower dimensional faces*/
85                facet(const int &n);
86                /**  The copy constructor */
87                facet(const facet& f);
88                /** A shallow copy of facets*/
89                facet* shallowCopy(const facet& f);
90                void shallowDelete();
91                /** The default destructor */
92                ~facet();
93                /** Comparison operator*/
94//              inline bool operator==(const facet *f,const facet *g);
95                /** \brief Comparison of facets*/
96//              inline bool areEqual(facet *f, facet *g);//Now static
97                /** Stores the facet normal \param int64vec*/
98                inline void setFacetNormal(int64vec *iv);
99                /** Returns the facet normal */
100                inline int64vec *getFacetNormal() const;
101                /** Return a reference to the facet normal*/
102                inline const int64vec *getRef2FacetNormal() const;
103                /** Method to print the facet normal*/
104                inline void printNormal() const;
105                /** Store the flipped GB*/
106                inline void setFlipGB(ideal I);
107                /** Return the flipped GB*/
108                inline ideal getFlipGB();
109                /** Print the flipped GB*/
110                inline void printFlipGB();
111                /** Set the UCN */
112                inline void setUCN(int n);
113                /** \brief Get the UCN
114                 * Returns the UCN iff this != NULL, else -1
115                 */
116                inline int getUCN();
117                /** Store an interior point of the facet */
118                inline void setInteriorPoint(int64vec *iv);
119                inline int64vec *getInteriorPoint();
120                inline const int64vec *getRef2InteriorPoint();
121                /** \brief Debugging function
122                 * prints the facet normal an all (codim-2)-facets that belong to it
123                 */
124                volatile void fDebugPrint();
125                friend class gcone;
126};
127
128
129/**
130 *\brief Implements the cone structure
131 *
132 * A cone is represented by a linked list of facet normals
133 * @see facet
134 */
135
136class gcone
137{
138        private:
139                ideal inputIdeal;       //the original
140                ring baseRing;          //the basering of the cone
141                int64vec *ivIntPt;      //an interior point of the cone
142                int UCN;                //unique number of the cone
143                int pred;               //UCN of the cone this one is derived from
144                static int counter;
145
146        public:
147                /** \brief Pointer to the first facet */
148                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
149#ifdef gfanp
150                static float time_getConeNormals;
151                static float time_getCodim2Normals;
152                static float t_getExtremalRays;
153                static float t_ddPolyh;
154                static float time_flip;
155                static float time_flip2;
156                static float t_areEqual;
157                static float t_ffG;
158                static float t_markings;
159                static float t_dd;
160                static float t_kStd;
161                static float time_enqueue;
162                static float time_computeInv;
163                static float t_ddMC;
164                static float t_mI;
165                static float t_iP;
166                static float t_isParallel;
167                static unsigned parallelButNotEqual;
168                static unsigned numberOfFacetChecks;
169#endif
170                /** Matrix to contain the homogeneity/lineality space */
171                static dd_MatrixPtr dd_LinealitySpace;
172                static int lengthOfSearchList;
173                /** Maximum size of the searchlist*/
174                static int maxSize;
175                /** is the ideal homogeneous? */
176                static bool hasHomInput;
177                /** # of variables in the ring */
178                static int numVars;             //#of variables in the ring
179                /** The hilbert function - for the homogeneous case*/
180                static int64vec *hilbertFunction;
181                /** The zero vector. Needed in case of fNormal mismatch*/
182                static int64vec *ivZeroVector;
183
184                /** # of facets of the cone
185                 * This value is set by gcone::getConeNormals
186                 */
187                int numFacets;          //#of facets of the cone
188
189                /**
190                 * At least as a workaround we store the irredundant facets of a matrix here.
191                 * This is needed to compute an interior points of a cone. Note that there
192                 * will be non-flippable facets in it!
193                 */
194                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
195
196                /** Array of intvecs representing the rays of the cone*/
197                int64vec **gcRays;
198                unsigned numRays;       //#rays of the cone
199                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
200                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
201                gcone *next;            //Pointer to next cone
202                gcone *prev;
203
204                gcone();
205                gcone(ring r, ideal I);
206                gcone(const gcone& gc, const facet &f);
207                ~gcone();
208                inline int getCounter();
209                inline ring getBaseRing();
210                inline ring getRef2BaseRing();
211                inline void setBaseRing(ring r);
212                inline void setIntPoint(int64vec *iv);
213                inline int64vec *getIntPoint(bool shallow=FALSE);
214                inline void showIntPoint();
215                inline void setNumFacets();
216                inline int getNumFacets();
217                inline int getUCN();
218                inline int getPredUCN();
219                volatile void showFacets(short codim=1);
220//              volatile void showSLA(facet &f);
221//              void idDebugPrint(const ideal &I);
222//              void invPrint(const ideal &I);
223//              bool isMonomial(const ideal &I);
224//              int64vec *ivNeg(const int64vec *iv);
225//              inline int dotProduct(int64vec &iva, int64vec &ivb);
226//              inline int dotProduct(const int64vec &iva, const int64vec &ivb);
227//              inline bool isParallel(const int64vec &a, const int64vec &b);
228                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
229//              inline int intgcd(const int &a, const int &b);
230                void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
231                void readConeFromFile(int gcNum, gcone *gc);
232                int64vec f2M(gcone *gc, facet *f, int n=1);
233//              inline void sortRays(gcone *gc);
234                //The real stuff
235                void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
236                void getCodim2Normals(const gcone &gc);
237                void getExtremalRays(const gcone &gc);
238                void orderRays();
239                void flip(ideal gb, facet *f);
240                void flip2(const ideal &gb, facet *f);
241                void computeInv(const ideal &gb, ideal &inv, const int64vec &f);
242                //poly restOfDiv(poly const &f, ideal const &I); removed with r12286
243                inline ideal ffG(const ideal &H, const ideal &G);
244                inline void getGB(ideal const &inputIdeal);
245                void interiorPoint( dd_MatrixPtr &M, int64vec &iv);//used from flip and optionally from getConeNormals
246//              void interiorPoint2(); //removed Feb 8th, 2010, new method Feb 19th, 2010, again removed Mar 16th, 2010
247                void preprocessInequalities(dd_MatrixPtr &M);
248                ring rCopyAndAddWeight(const ring &r, int64vec *ivw);
249                ring rCopyAndAddWeight2(const ring &, const int64vec *, const int64vec *);
250//              ring rCopyAndChangeWeight(const ring &r, int64vec *ivw);        //NOTE remove
251//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
252//              bool isSearchFacet(gcone &gcTmp, facet *testfacet); //NOTE remove
253                void makeInt(const dd_MatrixPtr &M, const int line, int64vec &n);
254//              void normalize();//NOTE REMOVE
255                facet * enqueueNewFacets(facet *f);
256                facet * enqueue2(facet *f);
257//              dd_MatrixPtr facets2Matrix(const gcone &gc);//NOTE remove
258                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
259                dd_MatrixPtr computeLinealitySpace();
260                inline bool iv64isStrictlyPositive(const int64vec *);
261                /** Exchange 2 ordertype_a by just 1 */
262                void replaceDouble_ringorder_a_ByASingleOne();
263//              static void gcone::idPrint(ideal &I);
264//              friend class facet;
265};
266lists lprepareResult(gcone *gc, const int n);
267/* static int64 int64gcd(const int64 &a, const int64 &b); */
268/* static int intgcd(const int &a, const int &b); */
269/* static int dotProduct(const int64vec &iva, const int64vec &ivb); */
270/* static bool isParallel(const int64vec &a, const int64vec &b); */
271/* static int64vec *ivNeg(/\*const*\/ int64vec *iv); */
272/* static void idDebugPrint(const ideal &I); */
273/* static volatile void showSLA(facet &f); */
274/* static bool isMonomial(const ideal &I); */
275/* static bool ivAreEqual(const int64vec &a, const int64vec &b); */
276/* static bool areEqual2(facet *f, facet *g); */
277/* static bool areEqual( facet *f, facet *g); */
278// bool iv64isStrictlyPositive(int64vec *);
279#endif
Note: See TracBrowser for help on using the repository browser.