source: git/kernel/gfan.h @ 4e654a2

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