source: git/kernel/gfan.h @ 341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2gfan.h Interface to gfan.cc
3
4$Author: monerjan $
5$Date: 2009-10-23 14:56:55 $
6$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.h,v 1.12 2009-10-23 14:56:55 monerjan Exp $
7$Id$
8*/
9#ifdef HAVE_GFAN
10#include "intvec.h"
11
12#define p800
13#ifdef p800
14#include "../../cddlib/include/setoper.h"
15#include "../../cddlib/include/cdd.h"
16#include "../../cddlib/include/cddmp.h"
17#endif
18extern int gfanHeuristic;
19//ideal getGB(ideal inputIdeal);
20ideal gfan(ideal inputIdeal, int heuristic);
21//int dotProduct(intvec a, intvec b);
22//bool isParallel(intvec a, intvec b);
23
24class facet
25{
26        private:
27                /** \brief Inner normal of the facet, describing it uniquely up to isomorphism */
28                intvec *fNormal;
29               
30                /** \brief An interior point of the facet*/
31                intvec *interiorPoint;
32               
33                /** \brief Universal Cone Number
34                 * The number of the cone the facet belongs to, Set in getConeNormals()
35                 */
36                int UCN;
37               
38                /** \brief The codim of the facet
39                 */
40                int codim;
41               
42                /** \brief The Groebner basis on the other side of a shared facet
43                 *
44                 * In order not to have to compute the flipped GB twice we store the basis we already get
45                 * when identifying search facets. Thus in the next step of the reverse search we can
46                 * just copy the old cone and update the facet and the gcBasis.
47                 * facet::flibGB is set via facet::setFlipGB() and printed via facet::printFlipGB
48                 */
49                ideal flipGB;           //The Groebner Basis on the other side, computed via gcone::flip
50               
51        public: 
52                /** \brief Boolean value to indicate whether a facet is flippable or not
53                * This is also used to mark facets that nominally are flippable but which do
54                * not intersect with the positive orthant. This check is done in gcone::getCodim2Normals
55                 */     
56                bool isFlippable;       //**flippable facet? */
57                bool isIncoming;        //Is the facet incoming or outgoing in the reverse search?
58                facet *next;            //Pointer to next facet
59                facet *prev;            //Pointer to predecessor. Needed for the SearchList in noRevS
60                facet *codim2Ptr;       //Pointer to (codim-2)-facet. Bit of recursion here ;-)
61                int numCodim2Facets;    //#of (codim-2)-facets of this facet. Set in getCodim2Normals()
62                ring flipRing;          //the ring on the other side of the facet
63                                       
64                /** The default constructor. Do I need a constructor of type facet(intvec)? */
65                facet();
66                facet(int const &n);
67                /** \brief The copy constructor
68                 */
69                facet(const facet& f);
70               
71                /** The default destructor */
72                ~facet();
73                               
74                /** \brief Comparison of facets*/
75                bool areEqual(facet &f, facet &g);
76                /** Stores the facet normal \param intvec*/
77                void setFacetNormal(intvec *iv);
78                /** Hopefully returns the facet normal */
79                intvec *getFacetNormal();
80                /** Method to print the facet normal*/
81                void printNormal();
82                /** Store the flipped GB*/
83                void setFlipGB(ideal I);
84                /** Return the flipped GB*/
85                ideal getFlipGB();
86                /** Print the flipped GB*/
87                void printFlipGB();
88                /** Set the UCN */
89                void setUCN(int n);
90                /** \brief Get the UCN
91                 * Returns the UCN iff this != NULL, else -1
92                 */
93                int getUCN();
94                /** Store an interior point of the facet */
95                void setInteriorPoint(intvec *iv);
96                intvec *getInteriorPoint();
97                /** \brief Debugging function
98                 * prints the facet normal an all (codim-2)-facets that belong to it
99                 */
100                void fDebugPrint();
101                friend class gcone;             
102};
103
104/**
105 *\brief Implements the cone structure
106 *
107 * A cone is represented by a linked list of facet normals
108 * @see facet
109 */
110
111class gcone
112{
113        private:               
114                ring rootRing;          //good to know this -> generic walk
115                ideal inputIdeal;       //the original
116                ring baseRing;          //the basering of the cone                             
117                intvec *ivIntPt;        //an interior point of the cone
118                int UCN;                //unique number of the cone
119                static int counter;
120               
121        public: 
122                /** \brief Pointer to the first facet */
123                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
124               
125                /** # of variables in the ring */
126                int numVars;            //#of variables in the ring
127               
128                /** # of facets of the cone
129                 * This value is set by gcone::getConeNormals
130                 */
131                int numFacets;          //#of facets of the cone
132               
133                /**
134                 * At least as a workaround we store the irredundant facets of a matrix here.
135                 * Otherwise, since we throw away non-flippable facets, facets2Matrix will not
136                 * yield all the necessary information
137                 */
138                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
139               
140                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
141                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
142                gcone *next;            //Pointer to next cone
143                gcone *prev;
144               
145                gcone();
146                gcone(ring r, ideal I);
147                gcone(const gcone& gc, const facet &f);
148                ~gcone();
149                void setIntPoint(intvec *iv);
150                intvec *getIntPoint();
151                void showIntPoint();
152                void showFacets(short codim=1);
153                void showSLA(facet &f);
154                void idDebugPrint(ideal const &I);
155                bool isMonomial(ideal const &I);
156                void setNumFacets();
157                int getNumFacets();
158                int getUCN();
159                void getConeNormals(ideal const &I, bool compIntPoint=FALSE);
160                void getCodim2Normals(gcone const &gc);
161                void flip(ideal gb, facet *f);
162                poly restOfDiv(poly const &f, ideal const &I);
163                ideal ffG(ideal const &H, ideal const &G);
164                void getGB(ideal const &inputIdeal);
165                intvec *ivNeg(const intvec *iv);
166                int dotProduct(intvec const &iva, intvec const &ivb);
167                bool isParallel(intvec const &a, intvec const &b);
168                void interiorPoint(dd_MatrixPtr const &M, intvec &iv);
169                ring rCopyAndAddWeight(ring const &r, intvec const *ivw);
170                ring rCopyAndChangeWeight(ring const &r, intvec *ivw);
171                bool isSearchFacet(gcone &gcTmp, facet *testfacet);
172                bool areEqual(intvec const &a, intvec const &b);
173                void reverseSearch(gcone *gcAct);
174                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
175                void makeInt(dd_MatrixPtr const &M, int const line, intvec &n);
176                void normalize();
177                facet * enqueueNewFacets(facet &f);
178                int intgcd(int a, int b);
179                dd_MatrixPtr facets2Matrix(gcone const &gc);
180                void writeConeToFile(gcone const &gc, bool usingIntPoints=FALSE);
181                void readConeFromFile(int gcNum, gcone *gc);
182                friend class facet;     
183};
184
185#endif
Note: See TracBrowser for help on using the repository browser.