source: git/kernel/gfan.h @ 85bcd6

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