source: git/kernel/gfan.h @ b3bb13

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