source: git/kernel/gfan.h @ 670ad3

spielwiese
Last change on this file since 670ad3 was 4c4a80, checked in by Martin Monerjan, 14 years ago
gfanp::parallelButNotEqual Homogeneity preprocessing now works changed to intvec::compare in gcone::areEqual Correct way to set gcone::dd_LinealitySpace git-svn-id: file:///usr/local/Singular/svn/trunk@12459 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.0 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
16#define p800
17#ifdef p800
18#include "../../cddlib/include/setoper.h"
19#include "../../cddlib/include/cdd.h"
20#include "../../cddlib/include/cddmp.h"
21#endif
22extern int gfanHeuristic;
23// extern dd_MatrixPtr ddLinealitySpace;
24#define gfanp
25// #ifdef gfanp
26// extern       static float time_getConeNormals;
27// extern       static float time_getCodim2Normals;
28// extern       static float time_flip;
29// extern       static float time_enqueue;
30// extern       static float time_computeInv;
31// #endif
32//ideal getGB(ideal inputIdeal);
33// ideal gfan(ideal inputIdeal, int heuristic);
34lists gfan(ideal inputIdeal, int heuristic);
35
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                                       
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                /** Method to print the facet normal*/
96                inline void printNormal();
97                /** Store the flipped GB*/
98                inline void setFlipGB(ideal I);
99                /** Return the flipped GB*/
100                inline ideal getFlipGB();
101                /** Print the flipped GB*/
102                inline void printFlipGB();
103                /** Set the UCN */
104                inline void setUCN(int n);
105                /** \brief Get the UCN
106                 * Returns the UCN iff this != NULL, else -1
107                 */
108                inline int getUCN();
109                /** Store an interior point of the facet */
110                inline void setInteriorPoint(intvec *iv);
111                inline intvec *getInteriorPoint();
112                /** \brief Debugging function
113                 * prints the facet normal an all (codim-2)-facets that belong to it
114                 */
115                inline void fDebugPrint();
116                friend class gcone;             
117};
118
119/**
120 *\brief Implements the cone structure
121 *
122 * A cone is represented by a linked list of facet normals
123 * @see facet
124 */
125
126class gcone
127{
128        private:               
129//              ring rootRing;          //good to know this -> generic walk
130                ideal inputIdeal;       //the original
131                ring baseRing;          //the basering of the cone                             
132                intvec *ivIntPt;        //an interior point of the cone
133                int UCN;                //unique number of the cone
134                int pred;               //UCN of the cone this one is derived from
135                static int counter;
136               
137        public: 
138                /** \brief Pointer to the first facet */
139                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
140#ifdef gfanp
141                static float time_getConeNormals;
142                static float time_getCodim2Normals;
143                static float t_getExtremalRays;
144                static float time_flip;
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 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                int numVars;            //#of variables in the ring
166               
167                /** # of facets of the cone
168                 * This value is set by gcone::getConeNormals
169                 */
170                int numFacets;          //#of facets of the cone
171               
172                /**
173                 * At least as a workaround we store the irredundant facets of a matrix here.
174                 * This is needed to compute an interior points of a cone. Note that there
175                 * will be non-flippable facets in it!           
176                 */
177                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
178               
179                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
180                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
181                gcone *next;            //Pointer to next cone
182                gcone *prev;
183               
184                gcone();
185                gcone(ring r, ideal I);
186                gcone(const gcone& gc, const facet &f);
187                ~gcone();
188                inline int getCounter();
189                inline ring getBaseRing();
190                inline void setIntPoint(intvec *iv);
191                inline intvec *getIntPoint();
192                inline void showIntPoint();
193                inline void setNumFacets();
194                inline int getNumFacets();
195                inline int getUCN();
196                inline int getPredUCN();               
197                inline void showFacets(short codim=1);
198                inline volatile void showSLA(facet &f);
199                inline void idDebugPrint(const ideal &I);
200                inline void invPrint(const ideal &I);
201                inline bool isMonomial(const ideal &I);
202                inline intvec *ivNeg(const intvec *iv);
203                inline int dotProduct(const intvec &iva, const intvec &ivb);
204                inline bool isParallel(const intvec &a, const intvec &b);
205                inline bool areEqual(const intvec &a, const intvec &b);
206                inline bool areEqual(facet *f, facet *g);
207                inline int intgcd(int a, int b);
208                inline void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
209                inline void readConeFromFile(int gcNum, gcone *gc);
210                inline intvec f2M(gcone *gc, facet *f, int n=1);
211               
212                //The real stuff
213                inline void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
214                inline void getCodim2Normals(const gcone &gc);
215                inline void getExtremalRays(const gcone &gc);
216                inline void flip(ideal gb, facet *f);
217                inline void computeInv(ideal &gb, ideal &inv, intvec &f);
218//              poly restOfDiv(poly const &f, ideal const &I); removed with r12286
219                inline ideal ffG(const ideal &H, const ideal &G);
220                inline void getGB(ideal const &inputIdeal);             
221                inline void interiorPoint( dd_MatrixPtr &M, intvec &iv);
222                inline void interiorPoint2(const dd_MatrixPtr &M, intvec &iv);
223                inline void preprocessInequalities(dd_MatrixPtr &M);
224                ring rCopyAndAddWeight(const ring &r, const intvec *ivw);
225                ring rCopyAndChangeWeight(const ring &r, intvec *ivw);         
226//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
227//              bool isSearchFacet(gcone &gcTmp, facet *testfacet);
228                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
229                inline void makeInt(const dd_MatrixPtr &M, const int line, intvec &n);
230                inline void normalize();
231                facet * enqueueNewFacets(facet *f);
232                facet * enqueue2(facet *f);
233                dd_MatrixPtr facets2Matrix(const gcone &gc);
234                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
235                inline dd_MatrixPtr computeLinealitySpace();           
236//              static void gcone::idPrint(ideal &I);           
237                friend class facet;     
238};
239lists lprepareResult(gcone *gc, int n);
240#endif
241#endif
Note: See TracBrowser for help on using the repository browser.