source: git/kernel/gfan.h @ c5940e

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