source: git/kernel/gfan.h @ e58dbb

spielwiese
Last change on this file since e58dbb was e58dbb, checked in by Martin Monerjan, 13 years ago
cleanup git-svn-id: file:///usr/local/Singular/svn/trunk@14068 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.7 KB
RevLine 
[6623f3]1/*
2gfan.h Interface to gfan.cc
3
[5cd07b]4$Author: monerjan $
[7c0ec6]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 $
[341696]7$Id$
[6623f3]8*/
[4199b3]9#ifdef HAVE_FANS
[005d00a]10
11#ifndef GFAN_H
12#define GFAN_H
13
[599326]14#include <kernel/int64vec.h>
[50ab25a]15
[1d9469]16#define p800
17#ifdef p800
[599326]18#include <kernel/../../cddlib/include/setoper.h>
19#include <kernel/../../cddlib/include/cdd.h>
20#include <kernel/../../cddlib/include/cddmp.h>
[1d9469]21#endif
[4199b3]22#include <Singular/bbfan.h>
23#include <Singular/bbcone.h>
[d2cd515]24extern int gfanHeuristic;
[73809b]25
[4199b3]26#ifndef USE_ZFAN
27#define USE_ZFAN
28#endif
29#ifndef USE_ZFAN
[e58dbb]30  lists grfan(ideal inputIdeal, int heuristic, bool singleCone);
[4199b3]31#else
[e58dbb]32  #include <../gfanlib/gfanlib.h>
33  gfan::ZFan *grfan(ideal inputIdeal, int h, bool singleCone);
[4199b3]34#endif
35// lists grcone_by_intvec(ideal inputIdeal);
[ac6e45]36
37class facet
38{
39        private:
40                /** \brief Inner normal of the facet, describing it uniquely up to isomorphism */
[8ed813]41                int64vec *fNormal;
[4199b3]42               
[ac6e45]43                /** \brief An interior point of the facet*/
[8ed813]44                int64vec *interiorPoint;
[4199b3]45               
[ac6e45]46                /** \brief Universal Cone Number
47                 * The number of the cone the facet belongs to, Set in getConeNormals()
48                 */
49                int UCN;
[4199b3]50               
[ac6e45]51                /** \brief The codim of the facet
52                 */
[ec6c52]53                short codim;
[4199b3]54               
[ac6e45]55                /** \brief The Groebner basis on the other side of a shared facet
56                 *
57                 * In order not to have to compute the flipped GB twice we store the basis we already get
[4199b3]58                 * when identifying search facets. Thus in the next step of the reverse search we can
[ac6e45]59                 * just copy the old cone and update the facet and the gcBasis.
60                 * facet::flibGB is set via facet::setFlipGB() and printed via facet::printFlipGB
61                 */
62                ideal flipGB;           //The Groebner Basis on the other side, computed via gcone::flip
[4199b3]63               
64        public: 
[ac6e45]65                /** \brief Boolean value to indicate whether a facet is flippable or not
66                * This is also used to mark facets that nominally are flippable but which do
67                * not intersect with the positive orthant. This check is done in gcone::getCodim2Normals
[4199b3]68                 */     
[ac6e45]69                bool isFlippable;       //**flippable facet? */
[ce41a2e]70                //bool isIncoming;      //Is the facet incoming or outgoing in the reverse search? No longer in use
[ac6e45]71                facet *next;            //Pointer to next facet
72                facet *prev;            //Pointer to predecessor. Needed for the SearchList in noRevS
73                facet *codim2Ptr;       //Pointer to (codim-2)-facet. Bit of recursion here ;-)
74                int numCodim2Facets;    //#of (codim-2)-facets of this facet. Set in getCodim2Normals()
[68eb0c]75                unsigned numRays;       //Number of spanning rays of the facet
[ac6e45]76                ring flipRing;          //the ring on the other side of the facet
[8ed813]77//              int64vec **fRays;
[4199b3]78                               
[e2e3ad]79                /** The default constructor. */
[ac6e45]80                facet();
[e2e3ad]81                /** Constructor for lower dimensional faces*/
[73809b]82                facet(const int &n);
[e2e3ad]83                /**  The copy constructor */
[ac6e45]84                facet(const facet& f);
[68eb0c]85                /** A shallow copy of facets*/
[73809b]86                facet* shallowCopy(const facet& f);
87                void shallowDelete();
[ac6e45]88                /** The default destructor */
89                ~facet();
[be7ab3f]90                /** Comparison operator*/
[4199b3]91//              inline bool operator==(const facet *f,const facet *g);                 
[ac6e45]92                /** \brief Comparison of facets*/
[ce41a2e]93//              inline bool areEqual(facet *f, facet *g);//Now static
[8ed813]94                /** Stores the facet normal \param int64vec*/
95                inline void setFacetNormal(int64vec *iv);
[68eb0c]96                /** Returns the facet normal */
[8ed813]97                inline int64vec *getFacetNormal() const;
[85583b]98                /** Return a reference to the facet normal*/
[8ed813]99                inline const int64vec *getRef2FacetNormal() const;
[ac6e45]100                /** Method to print the facet normal*/
[ce41a2e]101                inline void printNormal() const;
[ac6e45]102                /** Store the flipped GB*/
[a23a297]103                inline void setFlipGB(ideal I);
[ac6e45]104                /** Return the flipped GB*/
[a23a297]105                inline ideal getFlipGB();
[ac6e45]106                /** Print the flipped GB*/
[a23a297]107                inline void printFlipGB();
[ac6e45]108                /** Set the UCN */
[a23a297]109                inline void setUCN(int n);
[4199b3]110                /** \brief Get the UCN
[ac6e45]111                 * Returns the UCN iff this != NULL, else -1
112                 */
[a23a297]113                inline int getUCN();
[ac6e45]114                /** Store an interior point of the facet */
[8ed813]115                inline void setInteriorPoint(int64vec *iv);
116                inline int64vec *getInteriorPoint();
117                inline const int64vec *getRef2InteriorPoint();
[ac6e45]118                /** \brief Debugging function
119                 * prints the facet normal an all (codim-2)-facets that belong to it
120                 */
[be7ab3f]121                volatile void fDebugPrint();
[4199b3]122                friend class gcone;             
[1d9469]123};
124
[4199b3]125               
[1d9469]126/**
127 *\brief Implements the cone structure
128 *
129 * A cone is represented by a linked list of facet normals
130 * @see facet
131 */
132
133class gcone
134{
[4199b3]135        private:               
[1d9469]136                ideal inputIdeal;       //the original
[4199b3]137                ring baseRing;          //the basering of the cone                             
[8ed813]138                int64vec *ivIntPt;      //an interior point of the cone
[1d9469]139                int UCN;                //unique number of the cone
[e2e3ad]140                int pred;               //UCN of the cone this one is derived from
[0d278cd]141                static int counter;
[4199b3]142               
143        public: 
[1d9469]144                /** \brief Pointer to the first facet */
145                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
[42660f]146#ifdef gfanp
147                static float time_getConeNormals;
148                static float time_getCodim2Normals;
[4c4a80]149                static float t_getExtremalRays;
[73809b]150                static float t_ddPolyh;
[42660f]151                static float time_flip;
[be7ab3f]152                static float time_flip2;
[85583b]153                static float t_areEqual;
[2e06300]154                static float t_ffG;
155                static float t_markings;
156                static float t_dd;
157                static float t_kStd;
[4199b3]158                static float time_enqueue;             
[42660f]159                static float time_computeInv;
160                static float t_ddMC;
161                static float t_mI;
162                static float t_iP;
[73809b]163                static float t_isParallel;
[4c4a80]164                static unsigned parallelButNotEqual;
165                static unsigned numberOfFacetChecks;
[42660f]166#endif
[72e467]167                /** Matrix to contain the homogeneity/lineality space */
168                static dd_MatrixPtr dd_LinealitySpace;
169                static int lengthOfSearchList;
170                /** Maximum size of the searchlist*/
171                static int maxSize;
172                /** is the ideal homogeneous? */
173                static bool hasHomInput;
[1d9469]174                /** # of variables in the ring */
[5151ac]175                static int numVars;             //#of variables in the ring
[2f72c55]176                /** The hilbert function - for the homogeneous case*/
[8ed813]177                static int64vec *hilbertFunction;
[b3bb13]178                /** The zero vector. Needed in case of fNormal mismatch*/
[8ed813]179                static int64vec *ivZeroVector;
[4199b3]180               
[1d9469]181                /** # of facets of the cone
182                 * This value is set by gcone::getConeNormals
183                 */
184                int numFacets;          //#of facets of the cone
[4199b3]185               
[1d9469]186                /**
187                 * At least as a workaround we store the irredundant facets of a matrix here.
[4199b3]188                 * This is needed to compute an interior points of a cone. Note that there
189                 * will be non-flippable facets in it!           
[1d9469]190                 */
191                dd_MatrixPtr ddFacets;  //Matrix to store irredundant facets of the cone
[4199b3]192               
[68eb0c]193                /** Array of intvecs representing the rays of the cone*/
[8ed813]194                int64vec **gcRays;
[68eb0c]195                unsigned numRays;       //#rays of the cone
[1d9469]196                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
197                ideal gcBasis;          //GB of the cone, set by gcone::getGB();
[c5940e]198                gcone *next;            //Pointer to next cone
199                gcone *prev;
[4199b3]200               
[1d9469]201                gcone();
202                gcone(ring r, ideal I);
203                gcone(const gcone& gc, const facet &f);
204                ~gcone();
[a23a297]205                inline int getCounter();
206                inline ring getBaseRing();
[147167f]207                inline ring getRef2BaseRing();
[8ed813]208                inline void setBaseRing(ring r);
209                inline void setIntPoint(int64vec *iv);
210                inline int64vec *getIntPoint(bool shallow=FALSE);
[a23a297]211                inline void showIntPoint();
212                inline void setNumFacets();
213                inline int getNumFacets();
214                inline int getUCN();
[4199b3]215                inline int getPredUCN();               
[5ece85]216                volatile void showFacets(short codim=1);
[ec6c52]217//              volatile void showSLA(facet &f);
218//              void idDebugPrint(const ideal &I);
219//              void invPrint(const ideal &I);
220//              bool isMonomial(const ideal &I);
[8ed813]221//              int64vec *ivNeg(const int64vec *iv);
222//              inline int dotProduct(int64vec &iva, int64vec &ivb);
223//              inline int dotProduct(const int64vec &iva, const int64vec &ivb);
[4199b3]224//              inline bool isParallel(const int64vec &a, const int64vec &b);                           
[ec6c52]225                void noRevS(gcone &gcRoot, bool usingIntPoint=FALSE);
[b3bb13]226//              inline int intgcd(const int &a, const int &b);
[ec6c52]227                void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE);
228                void readConeFromFile(int gcNum, gcone *gc);
[8ed813]229                int64vec f2M(gcone *gc, facet *f, int n=1);
[ec6c52]230//              inline void sortRays(gcone *gc);
[e2e3ad]231                //The real stuff
[ec6c52]232                void getConeNormals(const ideal &I, bool compIntPoint=FALSE);
233                void getCodim2Normals(const gcone &gc);
234                void getExtremalRays(const gcone &gc);
[305057]235                void orderRays();
[ec6c52]236                void flip(ideal gb, facet *f);
[11a7dc]237                void flip2(const ideal &gb, facet *f);
[8ed813]238                void computeInv(const ideal &gb, ideal &inv, const int64vec &f);
[ec6c52]239                //poly restOfDiv(poly const &f, ideal const &I); removed with r12286
[a23a297]240                inline ideal ffG(const ideal &H, const ideal &G);
[4199b3]241                inline void getGB(ideal const &inputIdeal);             
[8ed813]242                void interiorPoint( dd_MatrixPtr &M, int64vec &iv);//used from flip and optionally from getConeNormals
[11a7dc]243//              void interiorPoint2(); //removed Feb 8th, 2010, new method Feb 19th, 2010, again removed Mar 16th, 2010
[ec6c52]244                void preprocessInequalities(dd_MatrixPtr &M);
[8ed813]245                ring rCopyAndAddWeight(const ring &r, int64vec *ivw);
246                ring rCopyAndAddWeight2(const ring &, const int64vec *, const int64vec *);
[4199b3]247//              ring rCopyAndChangeWeight(const ring &r, int64vec *ivw);        //NOTE remove   
[197a82]248//              void reverseSearch(gcone *gcAct); //NOTE both removed from r12286
[11a7dc]249//              bool isSearchFacet(gcone &gcTmp, facet *testfacet); //NOTE remove
[8ed813]250                void makeInt(const dd_MatrixPtr &M, const int line, int64vec &n);
[11a7dc]251//              void normalize();//NOTE REMOVE
[1d37196]252                facet * enqueueNewFacets(facet *f);
[72e467]253                facet * enqueue2(facet *f);
[11a7dc]254//              dd_MatrixPtr facets2Matrix(const gcone &gc);//NOTE remove
[72e467]255                /** Compute the lineality space Ax=0 and return it as dd_MatrixPtr dd_LinealitySpace*/
[ec6c52]256                dd_MatrixPtr computeLinealitySpace();
[8ed813]257                inline bool iv64isStrictlyPositive(const int64vec *);
[be7ab3f]258                /** Exchange 2 ordertype_a by just 1 */
[ec6c52]259                void replaceDouble_ringorder_a_ByASingleOne();
[4199b3]260//              static void gcone::idPrint(ideal &I);           
261//              friend class facet;     
[ac6e45]262};
[73809b]263lists lprepareResult(gcone *gc, const int n);
[f91fddc]264static int64 int64gcd(const int64 &a, const int64 &b);
[4199b3]265static int intgcd(const int &a, const int &b);
[8ed813]266static int dotProduct(const int64vec &iva, const int64vec &ivb);
267static bool isParallel(const int64vec &a, const int64vec &b);
268static int64vec *ivNeg(/*const*/ int64vec *iv);
[ec6c52]269static void idDebugPrint(const ideal &I);
270static volatile void showSLA(facet &f);
271static bool isMonomial(const ideal &I);
[8ed813]272static bool ivAreEqual(const int64vec &a, const int64vec &b);
[ce41a2e]273static bool areEqual2(facet *f, facet *g);
274static bool areEqual( facet *f, facet *g);
[8ed813]275// bool iv64isStrictlyPositive(int64vec *);
[4b81d75]276#endif
[005d00a]277#endif
Note: See TracBrowser for help on using the repository browser.