source: git/kernel/gfan.h @ de4e64

spielwiese
Last change on this file since de4e64 was 4199b3, checked in by Martin Monerjan, 13 years ago
HAVE_GFAN merged with HAVE_FANS defined USE_ZFAN gcRays2IntMat prepareGfanLib cleanup git-svn-id: file:///usr/local/Singular/svn/trunk@14011 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.8 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_FANS
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
23#include <Singular/bbfan.h>
24#include <Singular/bbcone.h>
25extern int gfanHeuristic;
26
27#ifndef USE_ZFAN
28#define USE_ZFAN
29#endif
30#ifndef USE_ZFAN
31lists grfan(ideal inputIdeal, int heuristic, bool singleCone);
32#else
33#include <../gfanlib/gfanlib.h>
34gfan::ZFan *grfan(ideal inputIdeal, int h, bool singleCone);
35#endif
36// lists grcone_by_intvec(ideal inputIdeal);
37
38class facet
39{
40        private:
41                /** \brief Inner normal of the facet, describing it uniquely up to isomorphism */
42                int64vec *fNormal;
43               
44                /** \brief An interior point of the facet*/
45                int64vec *interiorPoint;
46               
47                /** \brief Universal Cone Number
48                 * The number of the cone the facet belongs to, Set in getConeNormals()
49                 */
50                int UCN;
51               
52                /** \brief The codim of the facet
53                 */
54                short codim;
55               
56                /** \brief The Groebner basis on the other side of a shared facet
57                 *
58                 * In order not to have to compute the flipped GB twice we store the basis we already get
59                 * when identifying search facets. Thus in the next step of the reverse search we can
60                 * just copy the old cone and update the facet and the gcBasis.
61                 * facet::flibGB is set via facet::setFlipGB() and printed via facet::printFlipGB
62                 */
63                ideal flipGB;           //The Groebner Basis on the other side, computed via gcone::flip
64               
65        public: 
66                /** \brief Boolean value to indicate whether a facet is flippable or not
67                * This is also used to mark facets that nominally are flippable but which do
68                * not intersect with the positive orthant. This check is done in gcone::getCodim2Normals
69                 */     
70                bool isFlippable;       //**flippable facet? */
71                //bool isIncoming;      //Is the facet incoming or outgoing in the reverse search? No longer in use
72                facet *next;            //Pointer to next facet
73                facet *prev;            //Pointer to predecessor. Needed for the SearchList in noRevS
74                facet *codim2Ptr;       //Pointer to (codim-2)-facet. Bit of recursion here ;-)
75                int numCodim2Facets;    //#of (codim-2)-facets of this facet. Set in getCodim2Normals()
76                unsigned numRays;       //Number of spanning rays of the facet
77                ring flipRing;          //the ring on the other side of the facet
78//              int64vec **fRays;
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);//Now static
95                /** Stores the facet normal \param int64vec*/
96                inline void setFacetNormal(int64vec *iv);
97                /** Returns the facet normal */
98                inline int64vec *getFacetNormal() const;
99                /** Return a reference to the facet normal*/
100                inline const int64vec *getRef2FacetNormal() const;
101                /** Method to print the facet normal*/
102                inline void printNormal() const;
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(int64vec *iv);
117                inline int64vec *getInteriorPoint();
118                inline const int64vec *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/**
128 *\brief Implements the cone structure
129 *
130 * A cone is represented by a linked list of facet normals
131 * @see facet
132 */
133
134class gcone
135{
136        private:               
137                ideal inputIdeal;       //the original
138                ring baseRing;          //the basering of the cone                             
139                int64vec *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 int64vec *hilbertFunction;
179                /** The zero vector. Needed in case of fNormal mismatch*/
180                static int64vec *ivZeroVector;
181               
182                /** # of facets of the cone
183                 * This value is set by gcone::getConeNormals
184                 */
185                int numFacets;          //#of facets of the cone
186               
187                /**
188                 * At least as a workaround we store the irredundant facets of a matrix here.
189                 * This is needed to compute an interior points of a cone. Note that there
190                 * will be non-flippable facets in it!           
191                 */
192                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
193               
194                /** Array of intvecs representing the rays of the cone*/
195                int64vec **gcRays;
196                unsigned numRays;       //#rays of the cone
197                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
198                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
199                gcone *next;            //Pointer to next cone
200                gcone *prev;
201               
202                gcone();
203                gcone(ring r, ideal I);
204                gcone(const gcone& gc, const facet &f);
205                ~gcone();
206                inline int getCounter();
207                inline ring getBaseRing();
208                inline ring getRef2BaseRing();
209                inline void setBaseRing(ring r);
210                inline void setIntPoint(int64vec *iv);
211                inline int64vec *getIntPoint(bool shallow=FALSE);
212                inline void showIntPoint();
213                inline void setNumFacets();
214                inline int getNumFacets();
215                inline int getUCN();
216                inline int getPredUCN();               
217                volatile void showFacets(short codim=1);
218//              volatile void showSLA(facet &f);
219//              void idDebugPrint(const ideal &I);
220//              void invPrint(const ideal &I);
221//              bool isMonomial(const ideal &I);
222//              int64vec *ivNeg(const int64vec *iv);
223//              inline int dotProduct(int64vec &iva, int64vec &ivb);
224//              inline int dotProduct(const int64vec &iva, const int64vec &ivb);
225//              inline bool isParallel(const int64vec &a, const int64vec &b);                           
226                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
227//              inline int intgcd(const int &a, const int &b);
228                void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
229                void readConeFromFile(int gcNum, gcone *gc);
230                int64vec f2M(gcone *gc, facet *f, int n=1);
231//              inline void sortRays(gcone *gc);
232                //The real stuff
233                void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
234                void getCodim2Normals(const gcone &gc);
235                void getExtremalRays(const gcone &gc);
236                void orderRays();
237                void flip(ideal gb, facet *f);
238                void flip2(const ideal &gb, facet *f);
239                void computeInv(const ideal &gb, ideal &inv, const int64vec &f);
240                //poly restOfDiv(poly const &f, ideal const &I); removed with r12286
241                inline ideal ffG(const ideal &H, const ideal &G);
242                inline void getGB(ideal const &inputIdeal);             
243                void interiorPoint( dd_MatrixPtr &M, int64vec &iv);//used from flip and optionally from getConeNormals
244//              void interiorPoint2(); //removed Feb 8th, 2010, new method Feb 19th, 2010, again removed Mar 16th, 2010
245                void preprocessInequalities(dd_MatrixPtr &M);
246                ring rCopyAndAddWeight(const ring &r, int64vec *ivw);
247                ring rCopyAndAddWeight2(const ring &, const int64vec *, const int64vec *);
248//              ring rCopyAndChangeWeight(const ring &r, int64vec *ivw);        //NOTE remove   
249//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
250//              bool isSearchFacet(gcone &gcTmp, facet *testfacet); //NOTE remove
251                void makeInt(const dd_MatrixPtr &M, const int line, int64vec &n);
252//              void normalize();//NOTE REMOVE
253                facet * enqueueNewFacets(facet *f);
254                facet * enqueue2(facet *f);
255//              dd_MatrixPtr facets2Matrix(const gcone &gc);//NOTE remove
256                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
257                dd_MatrixPtr computeLinealitySpace();
258                inline bool iv64isStrictlyPositive(const int64vec *);
259                /** Exchange 2 ordertype_a by just 1 */
260                void replaceDouble_ringorder_a_ByASingleOne();
261//              static void gcone::idPrint(ideal &I);           
262//              friend class facet;     
263};
264lists lprepareResult(gcone *gc, const int n);
265static int64 int64gcd(const int64 &a, const int64 &b);
266static int intgcd(const int &a, const int &b);
267static int dotProduct(const int64vec &iva, const int64vec &ivb);
268static bool isParallel(const int64vec &a, const int64vec &b);
269static int64vec *ivNeg(/*const*/ int64vec *iv);
270static void idDebugPrint(const ideal &I);
271static volatile void showSLA(facet &f);
272static bool isMonomial(const ideal &I);
273static bool ivAreEqual(const int64vec &a, const int64vec &b);
274static bool areEqual2(facet *f, facet *g);
275static bool areEqual( facet *f, facet *g);
276// bool iv64isStrictlyPositive(int64vec *);
277#endif
278#endif
Note: See TracBrowser for help on using the repository browser.