source: git/kernel/gfan.h @ dcf8b4b

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