source: git/kernel/gfan.h @ 706b89

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