source: git/kernel/gfan.h @ f2b6f0b

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