source: git/kernel/gfan.h @ 2f72c55

spielwiese
Last change on this file since 2f72c55 was 2f72c55, checked in by Martin Monerjan, 14 years ago
Precautions in face::setFacetNormal, (facet,gcone)::setInteriorPoint Computation of interior point for facets in getExtremalRays isHomog, isNotHomog params on kStd depending on hasHomInput hilberFunction git-svn-id: file:///usr/local/Singular/svn/trunk@12559 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.6 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#define gfanp
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                ring flipRing;          //the ring on the other side of the facet
78                unsigned numRays;       //Number of spanning rays of the cone                   
79                /** The default constructor. */
80                facet();
81                /** Constructor for lower dimensional faces*/
82                facet(int const &n);
83                /**  The copy constructor */
84                facet(const facet& f);
85               
86                /** The default destructor */
87                ~facet();
88                               
89                /** \brief Comparison of facets*/
90                inline bool areEqual(facet *f, facet *g);
91                /** Stores the facet normal \param intvec*/
92                inline void setFacetNormal(intvec *iv);
93                /** Hopefully returns the facet normal */
94                inline intvec *getFacetNormal();
95                /** Return a reference to the facet normal*/
96                inline const intvec *getRef2FacetNormal();
97                /** Method to print the facet normal*/
98                inline void printNormal();
99                /** Store the flipped GB*/
100                inline void setFlipGB(ideal I);
101                /** Return the flipped GB*/
102                inline ideal getFlipGB();
103                /** Print the flipped GB*/
104                inline void printFlipGB();
105                /** Set the UCN */
106                inline void setUCN(int n);
107                /** \brief Get the UCN
108                 * Returns the UCN iff this != NULL, else -1
109                 */
110                inline int getUCN();
111                /** Store an interior point of the facet */
112                inline void setInteriorPoint(intvec *iv);
113                inline intvec *getInteriorPoint();
114                /** \brief Debugging function
115                 * prints the facet normal an all (codim-2)-facets that belong to it
116                 */
117                inline void fDebugPrint();
118                friend class gcone;             
119};
120
121/**
122 *\brief Implements the cone structure
123 *
124 * A cone is represented by a linked list of facet normals
125 * @see facet
126 */
127
128class gcone
129{
130        private:               
131//              ring rootRing;          //good to know this -> generic walk
132                ideal inputIdeal;       //the original
133                ring baseRing;          //the basering of the cone                             
134                intvec *ivIntPt;        //an interior point of the cone
135                int UCN;                //unique number of the cone
136                int pred;               //UCN of the cone this one is derived from
137                static int counter;
138               
139        public: 
140                /** \brief Pointer to the first facet */
141                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
142#ifdef gfanp
143                static float time_getConeNormals;
144                static float time_getCodim2Normals;
145                static float t_getExtremalRays;
146                static float time_flip;
147                static float t_areEqual;
148                static float t_ffG;
149                static float t_markings;
150                static float t_dd;
151                static float t_kStd;
152                static float time_enqueue;             
153                static float time_computeInv;
154                static float t_ddMC;
155                static float t_mI;
156                static float t_iP;
157                static unsigned parallelButNotEqual;
158                static unsigned numberOfFacetChecks;
159#endif
160                /** Matrix to contain the homogeneity/lineality space */
161                static dd_MatrixPtr dd_LinealitySpace;
162                static int lengthOfSearchList;
163                /** Maximum size of the searchlist*/
164                static int maxSize;
165                /** is the ideal homogeneous? */
166                static bool hasHomInput;
167                /** # of variables in the ring */
168                int numVars;            //#of variables in the ring
169                /** The hilbert function - for the homogeneous case*/
170                static intvec *hilbertFunction;
171               
172                /** # of facets of the cone
173                 * This value is set by gcone::getConeNormals
174                 */
175                int numFacets;          //#of facets of the cone
176               
177                /**
178                 * At least as a workaround we store the irredundant facets of a matrix here.
179                 * This is needed to compute an interior points of a cone. Note that there
180                 * will be non-flippable facets in it!           
181                 */
182                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
183               
184                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
185                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
186                gcone *next;            //Pointer to next cone
187                gcone *prev;
188               
189                gcone();
190                gcone(ring r, ideal I);
191                gcone(const gcone& gc, const facet &f);
192                ~gcone();
193                inline int getCounter();
194                inline ring getBaseRing();
195                inline void setIntPoint(intvec *iv);
196                inline intvec *getIntPoint();
197                inline void showIntPoint();
198                inline void setNumFacets();
199                inline int getNumFacets();
200                inline int getUCN();
201                inline int getPredUCN();               
202                volatile void showFacets(short codim=1);
203                inline volatile void showSLA(facet &f);
204                inline void idDebugPrint(const ideal &I);
205                inline void invPrint(const ideal &I);
206                inline bool isMonomial(const ideal &I);
207                inline intvec *ivNeg(intvec *iv);
208                inline int dotProduct(intvec &iva, intvec &ivb);
209                inline int dotProduct(const intvec &iva, const intvec &ivb);
210                inline bool isParallel(intvec &a, intvec &b);
211//              inline int dotProduct(const intvec* a, const intvec *b);
212//              inline bool isParallel(const intvec* a, const intvec* b);
213                inline bool areEqual(intvec &a, intvec &b);
214                inline bool areEqual( facet *f,  facet *g);
215                inline int intgcd(int a, int b);
216                inline void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
217                inline void readConeFromFile(int gcNum, gcone *gc);
218                inline intvec f2M(gcone *gc, facet *f, int n=1);
219                inline void sortRays(gcone *gc);
220                //The real stuff
221                inline void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
222                inline void getCodim2Normals(const gcone &gc);
223                inline void getExtremalRays(const gcone &gc);
224                inline void flip(ideal gb, facet *f);
225                inline void computeInv(ideal &gb, ideal &inv, intvec &f);
226//              poly restOfDiv(poly const &f, ideal const &I); removed with r12286
227                inline ideal ffG(const ideal &H, const ideal &G);
228                inline void getGB(ideal const &inputIdeal);             
229                inline void interiorPoint( dd_MatrixPtr &M, intvec &iv);
230//              inline void interiorPoint2(const dd_MatrixPtr &M, intvec &iv);//removed Feb 8th, 2010
231                inline void preprocessInequalities(dd_MatrixPtr &M);
232                ring rCopyAndAddWeight(const ring &r, intvec *ivw);
233                ring rCopyAndChangeWeight(const ring &r, intvec *ivw);         
234//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
235//              bool isSearchFacet(gcone &gcTmp, facet *testfacet);
236                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
237                inline void makeInt(const dd_MatrixPtr &M, const int line, intvec &n);
238                inline void normalize();
239                facet * enqueueNewFacets(facet *f);
240                facet * enqueue2(facet *f);
241                dd_MatrixPtr facets2Matrix(const gcone &gc);
242                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
243                inline dd_MatrixPtr computeLinealitySpace();
244                inline bool iv64isStrictlyPositive(intvec *);
245//              static void gcone::idPrint(ideal &I);           
246                friend class facet;     
247};
248lists lprepareResult(gcone *gc, int n);
249// bool iv64isStrictlyPositive(intvec *);
250#endif
251#endif
Note: See TracBrowser for help on using the repository browser.