source: git/kernel/gfan.h @ 147167f

spielwiese
Last change on this file since 147167f was 147167f, checked in by Martin Monerjan, 14 years ago
static facet slEnd Possibility for deletion in enqueue2. Yet disabled Fixed memleak in replaceDouble... poly strPoly into inner loop in readConeFromFile getRef2BaseRing (for lpreparelist) delete gcDel //ed as workaround for crashes with option 0 git-svn-id: file:///usr/local/Singular/svn/trunk@12633 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.3 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                                       
80                /** The default constructor. */
81                facet();
82                /** Constructor for lower dimensional faces*/
83                facet(const int &n);
84                /**  The copy constructor */
85                facet(const facet& f);
86                /** A shallow copy of facets*/
87                facet* shallowCopy(const facet& f);
88                void shallowDelete();
89                /** The default destructor */
90                ~facet();
91                /** Comparison operator*/
92//              inline bool operator==(const facet *f,const facet *g);                 
93                /** \brief Comparison of facets*/
94                inline bool areEqual(facet *f, facet *g);
95                /** Stores the facet normal \param intvec*/
96                inline void setFacetNormal(intvec *iv);
97                /** Returns the facet normal */
98                inline intvec *getFacetNormal();
99                /** Return a reference to the facet normal*/
100                inline const intvec *getRef2FacetNormal();
101                /** Method to print the facet normal*/
102                inline void printNormal();
103                /** Store the flipped GB*/
104                inline void setFlipGB(ideal I);
105                /** Return the flipped GB*/
106                inline ideal getFlipGB();
107                /** Print the flipped GB*/
108                inline void printFlipGB();
109                /** Set the UCN */
110                inline void setUCN(int n);
111                /** \brief Get the UCN
112                 * Returns the UCN iff this != NULL, else -1
113                 */
114                inline int getUCN();
115                /** Store an interior point of the facet */
116                inline void setInteriorPoint(intvec *iv);
117                inline intvec *getInteriorPoint();
118                inline const intvec *getRef2InteriorPoint();
119                /** \brief Debugging function
120                 * prints the facet normal an all (codim-2)-facets that belong to it
121                 */
122                volatile void fDebugPrint();
123                friend class gcone;             
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                //ring rootRing;                //good to know this -> generic walk
137                ideal inputIdeal;       //the original
138                ring baseRing;          //the basering of the cone                             
139                intvec *ivIntPt;        //an interior point of the cone
140                int UCN;                //unique number of the cone
141                int pred;               //UCN of the cone this one is derived from
142                static int counter;
143               
144        public: 
145                /** \brief Pointer to the first facet */
146                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
147#ifdef gfanp
148                static float time_getConeNormals;
149                static float time_getCodim2Normals;
150                static float t_getExtremalRays;
151                static float t_ddPolyh;
152                static float time_flip;
153                static float time_flip2;
154                static float t_areEqual;
155                static float t_ffG;
156                static float t_markings;
157                static float t_dd;
158                static float t_kStd;
159                static float time_enqueue;             
160                static float time_computeInv;
161                static float t_ddMC;
162                static float t_mI;
163                static float t_iP;
164                static float t_isParallel;
165                static unsigned parallelButNotEqual;
166                static unsigned numberOfFacetChecks;
167#endif
168                /** Matrix to contain the homogeneity/lineality space */
169                static dd_MatrixPtr dd_LinealitySpace;
170                static int lengthOfSearchList;
171                /** Maximum size of the searchlist*/
172                static int maxSize;
173                /** is the ideal homogeneous? */
174                static bool hasHomInput;
175                /** # of variables in the ring */
176                static int numVars;             //#of variables in the ring
177                /** The hilbert function - for the homogeneous case*/
178                static intvec *hilbertFunction;
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                intvec **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 setIntPoint(intvec *iv);
208                inline intvec *getIntPoint(bool shallow=FALSE);
209                inline void showIntPoint();
210                inline void setNumFacets();
211                inline int getNumFacets();
212                inline int getUCN();
213                inline int getPredUCN();               
214                volatile void showFacets(short codim=1);
215                inline volatile void showSLA(facet &f);
216                inline void idDebugPrint(const ideal &I);
217                inline void invPrint(const ideal &I);
218                inline bool isMonomial(const ideal &I);
219                inline intvec *ivNeg(const intvec *iv);
220//              inline int dotProduct(intvec &iva, intvec &ivb);
221                inline int dotProduct(const intvec &iva, const intvec &ivb);
222                inline bool isParallel(const intvec &a, const intvec &b);
223//              inline int dotProduct(const intvec* a, const intvec *b);
224//              inline bool isParallel(const intvec* a, const intvec* b);
225                inline bool ivAreEqual(const intvec &a, const intvec &b);
226                inline bool areEqual( facet *f,  facet *g);
227                inline bool areEqual2(facet* f, facet *g);
228                inline int intgcd(const int &a, const int &b);
229                inline void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
230                inline void readConeFromFile(int gcNum, gcone *gc);
231                inline intvec f2M(gcone *gc, facet *f, int n=1);
232                inline void sortRays(gcone *gc);
233                //The real stuff
234                inline void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
235                inline void getCodim2Normals(const gcone &gc);
236                inline void getExtremalRays(const gcone &gc);
237                inline void flip(ideal gb, facet *f);
238                inline void flip2(const ideal gb, facet *f);
239                inline void computeInv(const ideal &gb, ideal &inv, const intvec &f);//                 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                inline void interiorPoint( dd_MatrixPtr &M, intvec &iv);
243                inline void interiorPoint2(); //removed Feb 8th, 2010, new method Feb 19th, 2010
244                inline void preprocessInequalities(dd_MatrixPtr &M);
245                ring rCopyAndAddWeight(const ring &r, intvec *ivw);
246                ring rCopyAndAddWeight2(const ring &, const intvec *, const intvec *);
247                ring rCopyAndChangeWeight(const ring &r, intvec *ivw);         
248//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
249//              bool isSearchFacet(gcone &gcTmp, facet *testfacet);
250                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
251                inline void makeInt(const dd_MatrixPtr &M, const int line, intvec &n);
252                inline void normalize();
253                facet * enqueueNewFacets(facet *f);
254                facet * enqueue2(facet *f);
255                dd_MatrixPtr facets2Matrix(const gcone &gc);
256                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
257                inline dd_MatrixPtr computeLinealitySpace();
258                inline bool iv64isStrictlyPositive(const intvec *);
259                /** Exchange 2 ordertype_a by just 1 */
260                inline void replaceDouble_ringorder_a_ByASingleOne();
261//              static void gcone::idPrint(ideal &I);           
262                friend class facet;     
263};
264lists lprepareResult(gcone *gc, const int n);
265// bool iv64isStrictlyPositive(intvec *);
266#endif
267#endif
Note: See TracBrowser for help on using the repository browser.