source: git/kernel/gfan.h @ 005d00a

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