source: git/kernel/gfan.h @ 8ed813

spielwiese
Last change on this file since 8ed813 was 8ed813, checked in by Martin Monerjan, 14 years ago
int64 und int64vec git-svn-id: file:///usr/local/Singular/svn/trunk@12686 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.4 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 "int64vec.h"
15// #include "int64vec.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                int64vec *fNormal;
32               
33                /** \brief An interior point of the facet*/
34                int64vec *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//              int64vec **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 int64vec*/
85                inline void setFacetNormal(int64vec *iv);
86                /** Returns the facet normal */
87                inline int64vec *getFacetNormal() const;
88                /** Return a reference to the facet normal*/
89                inline const int64vec *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(int64vec *iv);
106                inline int64vec *getInteriorPoint();
107                inline const int64vec *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                int64vec *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 int64vec *hilbertFunction;
168                /** The zero vector. Needed in case of fNormal mismatch*/
169                static int64vec *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                int64vec **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 setBaseRing(ring r);
199                inline void setIntPoint(int64vec *iv);
200                inline int64vec *getIntPoint(bool shallow=FALSE);
201                inline void showIntPoint();
202                inline void setNumFacets();
203                inline int getNumFacets();
204                inline int getUCN();
205                inline int getPredUCN();               
206                volatile void showFacets(short codim=1);
207//              volatile void showSLA(facet &f);
208//              void idDebugPrint(const ideal &I);
209//              void invPrint(const ideal &I);
210//              bool isMonomial(const ideal &I);
211//              int64vec *ivNeg(const int64vec *iv);
212//              inline int dotProduct(int64vec &iva, int64vec &ivb);
213//              inline int dotProduct(const int64vec &iva, const int64vec &ivb);
214//              inline bool isParallel(const int64vec &a, const int64vec &b);                           
215                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
216//              inline int intgcd(const int &a, const int &b);
217                void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
218                void readConeFromFile(int gcNum, gcone *gc);
219                int64vec f2M(gcone *gc, facet *f, int n=1);
220//              inline void sortRays(gcone *gc);
221                //The real stuff
222                void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
223                void getCodim2Normals(const gcone &gc);
224                void getExtremalRays(const gcone &gc);
225                void flip(ideal gb, facet *f);
226                void flip2(const ideal &gb, facet *f);
227                void computeInv(const ideal &gb, ideal &inv, const int64vec &f);
228                //poly restOfDiv(poly const &f, ideal const &I); removed with r12286
229                inline ideal ffG(const ideal &H, const ideal &G);
230                inline void getGB(ideal const &inputIdeal);             
231                void interiorPoint( dd_MatrixPtr &M, int64vec &iv);//used from flip and optionally from getConeNormals
232//              void interiorPoint2(); //removed Feb 8th, 2010, new method Feb 19th, 2010, again removed Mar 16th, 2010
233                void preprocessInequalities(dd_MatrixPtr &M);
234                ring rCopyAndAddWeight(const ring &r, int64vec *ivw);
235                ring rCopyAndAddWeight2(const ring &, const int64vec *, const int64vec *);
236//              ring rCopyAndChangeWeight(const ring &r, int64vec *ivw);        //NOTE remove   
237//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
238//              bool isSearchFacet(gcone &gcTmp, facet *testfacet); //NOTE remove
239                void makeInt(const dd_MatrixPtr &M, const int line, int64vec &n);
240//              void normalize();//NOTE REMOVE
241                facet * enqueueNewFacets(facet *f);
242                facet * enqueue2(facet *f);
243//              dd_MatrixPtr facets2Matrix(const gcone &gc);//NOTE remove
244                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
245                dd_MatrixPtr computeLinealitySpace();
246                inline bool iv64isStrictlyPositive(const int64vec *);
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 int64 &a, const int64 &b);
254static int dotProduct(const int64vec &iva, const int64vec &ivb);
255static bool isParallel(const int64vec &a, const int64vec &b);
256static int64vec *ivNeg(/*const*/ int64vec *iv);
257static void idDebugPrint(const ideal &I);
258static volatile void showSLA(facet &f);
259static bool isMonomial(const ideal &I);
260static bool ivAreEqual(const int64vec &a, const int64vec &b);
261static bool areEqual2(facet *f, facet *g);
262static bool areEqual( facet *f, facet *g);
263// bool iv64isStrictlyPositive(int64vec *);
264#endif
265#endif
Note: See TracBrowser for help on using the repository browser.