Changeset ac6e45 in git for kernel/gfan.cc


Ignore:
Timestamp:
Oct 1, 2009, 9:15:49 AM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1d9469b7feae9ba3731cc5bd89f2a2a7f1611efd
Parents:
4042c2b632b9f788b2327601ac2d0b4d0d60d508
Message:
Class definitions into gfan.h


git-svn-id: file:///usr/local/Singular/svn/trunk@12145 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r4042c2 rac6e45  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-10-01 06:36:23 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.91 2009-10-01 06:36:23 monerjan Exp $
    6 $Id: gfan.cc,v 1.91 2009-10-01 06:36:23 monerjan Exp $
     4$Date: 2009-10-01 07:15:49 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.92 2009-10-01 07:15:49 monerjan Exp $
     6$Id: gfan.cc,v 1.92 2009-10-01 07:15:49 monerjan Exp $
    77*/
    88
     
    6666#endif
    6767
    68 //#include gcone.h
     68#include <gfan.h>
    6969using namespace std;
    7070
     
    7474*
    7575*/
    76 class facet
     76               
     77                /** The default constructor. Do I need a constructor of type facet(intvec)? */
     78facet::facet()                 
    7779{
    78         private:
    79                 /** \brief Inner normal of the facet, describing it uniquely up to isomorphism */
    80                 intvec *fNormal;
    81                
    82                 /** \brief An interior point of the facet*/
    83                 intvec *interiorPoint;
    84                
    85                 /** \brief Universal Cone Number
    86                 * The number of the cone the facet belongs to, Set in getConeNormals()
    87                 */
    88                 int UCN;
    89                
    90                 /** \brief The codim of the facet
    91                 */
    92                 int codim;
    93                
    94                 /** \brief The Groebner basis on the other side of a shared facet
    95                  *
    96                  * In order not to have to compute the flipped GB twice we store the basis we already get
    97                  * when identifying search facets. Thus in the next step of the reverse search we can
    98                  * just copy the old cone and update the facet and the gcBasis.
    99                  * facet::flibGB is set via facet::setFlipGB() and printed via facet::printFlipGB
    100                  */
    101                 ideal flipGB;           //The Groebner Basis on the other side, computed via gcone::flip               
    102                        
    103         public:
    104                 /** \brief Boolean value to indicate whether a facet is flippable or not
    105                 * This is also used to mark facets that nominally are flippable but which do
    106                 * not intersect with the positive orthant. This check is done in gcone::getCodim2Normals
    107                 */     
    108                 bool isFlippable;       //**flippable facet? */
    109                 bool isIncoming;        //Is the facet incoming or outgoing in the reverse search?
    110                 facet *next;            //Pointer to next facet
    111                 facet *prev;            //Pointer to predecessor. Needed for the SearchList in noRevS
    112                 facet *codim2Ptr;       //Pointer to (codim-2)-facet. Bit of recursion here ;-)
    113                 int numCodim2Facets;    //#of (codim-2)-facets of this facet. Set in getCodim2Normals()
    114                 ring flipRing;          //the ring on the other side of the facet
    115                                                
    116                 /** The default constructor. Do I need a constructor of type facet(intvec)? */
    117                 facet()                 
    118                 {
    119                         // Pointer to next facet.  */
    120                         /* Defaults to NULL. This way there is no need to check explicitly */
    121                         this->fNormal=NULL;
    122                         this->interiorPoint=NULL;               
    123                         this->UCN=0;
    124                         this->codim2Ptr=NULL;
    125                         this->codim=1;          //default for (codim-1)-facets
    126                         this->numCodim2Facets=0;
    127                         this->flipGB=NULL;
    128                         this->isIncoming=FALSE;
    129                         this->next=NULL;
    130                         this->prev=NULL;               
    131                         this->flipRing=NULL;
    132                         this->isFlippable=FALSE;
    133                 }
    134                
    135                 /** \brief Constructor for facets of codim >= 2
    136                 */
    137                 facet(int const &n)
    138                 {
    139                         this->fNormal=NULL;
    140                         this->interiorPoint=NULL;                       
    141                         this->UCN=0;
    142                         this->codim2Ptr=NULL;
    143                         if(n>1)
    144                         {
    145                                 this->codim=n;
    146                         }//NOTE Handle exception here!                 
    147                         this->numCodim2Facets=0;
    148                         this->flipGB=NULL;
    149                         this->isIncoming=FALSE;
    150                         this->next=NULL;
    151                         this->prev=NULL;
    152                         this->flipRing=NULL;
    153                         this->isFlippable=FALSE;
    154                 }
    155                
    156                 /** \brief The copy constructor
    157                 */
    158                 facet(const facet& f)
    159                 {
    160                 }
    161                
    162                 /** The default destructor */
    163                 ~facet();
    164                
    165                
    166                 /** \brief Comparison of facets*/
    167                 bool areEqual(facet &f, facet &g)
    168                 {
    169                         bool res = TRUE;
    170                         intvec *fNormal = new intvec(pVariables);
    171                         intvec *gNormal = new intvec(pVariables);
    172                         fNormal = f.getFacetNormal();
    173                         gNormal = g.getFacetNormal();
    174                         if((fNormal == gNormal))//||(gcone::isParallel(fNormal,gNormal)))
    175                         {
    176                                 if(f.numCodim2Facets==g.numCodim2Facets)
    177                                 {
    178                                         facet *f2Act;
    179                                         facet *g2Act;
    180                                         f2Act = f.codim2Ptr;
    181                                         g2Act = g.codim2Ptr;
    182                                         intvec *f2N = new intvec(pVariables);
    183                                         intvec *g2N = new intvec(pVariables);
    184                                         while(f2Act->next!=NULL && g2Act->next!=NULL)
    185                                         {
    186                                                 for(int ii=0;ii<f2N->length();ii++)
    187                                                 {
    188                                                         if(f2Act->getFacetNormal() != g2Act->getFacetNormal())
    189                                                         {
    190                                                                 res=FALSE;                                                             
    191                                                         }
    192                                                         if (res==FALSE)
    193                                                                 break;
    194                                                 }
    195                                                 if(res==FALSE)
    196                                                         break;
    197                                                
    198                                                 f2Act = f2Act->next;
    199                                                 g2Act = g2Act->next;
    200                                         }//while
    201                                 }//if           
    202                         }//if
    203                         else
    204                         {
    205                                 res = FALSE;
    206                         }
    207                         return res;
    208                 }
    209                
    210                 /** Stores the facet normal \param intvec*/
    211                 void setFacetNormal(intvec *iv)
    212                 {
    213                         this->fNormal = ivCopy(iv);                     
    214                 }
    215                
    216                 /** Hopefully returns the facet normal */
    217                 intvec *getFacetNormal()
    218                 {                               
    219                         return this->fNormal;
    220                 }
    221                
    222                 /** Method to print the facet normal*/
    223                 void printNormal()
    224                 {
    225                         fNormal->show();
    226                 }
    227                
    228                 /** Store the flipped GB*/
    229                 void setFlipGB(ideal I)
    230                 {
    231                         this->flipGB=idCopy(I);
    232                 }
    233                
    234                 /** Return the flipped GB*/
    235                 ideal getFlipGB()
    236                 {
    237                         return this->flipGB;
    238                 }
    239                
    240                 /** Print the flipped GB*/
    241                 void printFlipGB()
    242                 {
    243                         idShow(this->flipGB);
    244                 }
    245                
    246                 /** Set the UCN */
    247                 void setUCN(int n)
    248                 {
    249                         this->UCN=n;
    250                 }
    251                
    252                 /** \brief Get the UCN
    253                 * Returns the UCN iff this != NULL, else -1
    254                 */
    255                 int getUCN()
    256                 {
    257                         if(this!=NULL && ( this!=0xfbfbfbfb || this!=(facet *)0xfbfbfbfbfbfbfbfb) )
    258                                 return this->UCN;
    259                         else
    260                                 return -1;
    261                 }
    262                
    263                 /** Store an interior point of the facet */
    264                 void setInteriorPoint(intvec *iv)
    265                 {
    266                         this->interiorPoint = ivCopy(iv);
    267                 }
    268                
    269                 intvec *getInteriorPoint()
    270                 {
    271                         return this->interiorPoint;
    272                 }       
    273                
    274                 /** \brief Debugging function
    275                 * prints the facet normal an all (codim-2)-facets that belong to it
    276                 */
    277                 void fDebugPrint()
    278                 {                       
    279                         facet *codim2Act;                       
    280                         codim2Act = this->codim2Ptr;
    281                         intvec *fNormal;
    282                         fNormal = this->getFacetNormal();
    283                         intvec *f2Normal;
    284                         cout << "=======================" << endl;
    285                         cout << "Facet normal = (";
    286                         fNormal->show(1,1);
    287                         cout << ")"<<endl;
    288                         /*for(int ii=0;ii<pVariables;ii++)
    289                         {
    290                                 cout << (*fNormal)[ii] << ",";
    291                         }
    292                         if(this->isFlippable==TRUE)
    293                                 cout << ")" << endl;
    294                         else
    295                                 cout << ")*" << endl;*/ //This case should never happen in SLA!
    296                         cout << "-----------------------" << endl;
    297                         cout << "Codim2 facets:" << endl;
    298                         while(codim2Act!=NULL)
    299                         {
    300                                 f2Normal = codim2Act->getFacetNormal();
    301                                 cout << "(";
    302                                 f2Normal->show(1,0);
    303 //                              for(int jj=0;jj<pVariables;jj++)
    304 //                              {
    305 //                                      cout << (*f2Normal)[jj] << ",";
    306 //                              }
    307                                 cout << ")" << endl;
    308                                 codim2Act = codim2Act->next;
    309                         }
    310                         cout << "=======================" << endl;
    311                 }               
    312                
    313                 friend class gcone;     //Bad style
    314 };
    315 
     80        // Pointer to next facet.  */
     81        /* Defaults to NULL. This way there is no need to check explicitly */
     82        this->fNormal=NULL;
     83        this->interiorPoint=NULL;               
     84        this->UCN=0;
     85        this->codim2Ptr=NULL;
     86        this->codim=1;          //default for (codim-1)-facets
     87        this->numCodim2Facets=0;
     88        this->flipGB=NULL;
     89        this->isIncoming=FALSE;
     90        this->next=NULL;
     91        this->prev=NULL;               
     92        this->flipRing=NULL;
     93        this->isFlippable=FALSE;
     94}
     95               
     96/** \brief Constructor for facets of codim >= 2
     97*/
     98facet::facet(int const &n)
     99{
     100        this->fNormal=NULL;
     101        this->interiorPoint=NULL;                       
     102        this->UCN=0;
     103        this->codim2Ptr=NULL;
     104        if(n>1)
     105        {
     106                this->codim=n;
     107        }//NOTE Handle exception here!                 
     108        this->numCodim2Facets=0;
     109        this->flipGB=NULL;
     110        this->isIncoming=FALSE;
     111        this->next=NULL;
     112        this->prev=NULL;
     113        this->flipRing=NULL;
     114        this->isFlippable=FALSE;
     115}
     116               
     117/** \brief The copy constructor
     118*/
     119facet::facet(const facet& f)
     120{
     121}
     122               
     123/** The default destructor */
    316124facet::~facet()
    317125{
     
    324132        //this=NULL;
    325133}
     134               
     135               
     136/** \brief Comparison of facets*/
     137bool facet::areEqual(facet &f, facet &g)
     138{
     139        bool res = TRUE;
     140        intvec *fNormal = new intvec(pVariables);
     141        intvec *gNormal = new intvec(pVariables);
     142        fNormal = f.getFacetNormal();
     143        gNormal = g.getFacetNormal();
     144        if((fNormal == gNormal))//||(gcone::isParallel(fNormal,gNormal)))
     145        {
     146                if(f.numCodim2Facets==g.numCodim2Facets)
     147                {
     148                        facet *f2Act;
     149                        facet *g2Act;
     150                        f2Act = f.codim2Ptr;
     151                        g2Act = g.codim2Ptr;
     152                        intvec *f2N = new intvec(pVariables);
     153                        intvec *g2N = new intvec(pVariables);
     154                        while(f2Act->next!=NULL && g2Act->next!=NULL)
     155                        {
     156                                for(int ii=0;ii<f2N->length();ii++)
     157                                {
     158                                        if(f2Act->getFacetNormal() != g2Act->getFacetNormal())
     159                                        {
     160                                                res=FALSE;                                                             
     161                                        }
     162                                        if (res==FALSE)
     163                                                break;
     164                                }
     165                                if(res==FALSE)
     166                                        break;
     167                               
     168                                f2Act = f2Act->next;
     169                                g2Act = g2Act->next;
     170                        }//while
     171                }//if           
     172        }//if
     173        else
     174        {
     175                res = FALSE;
     176        }
     177        return res;
     178}
     179               
     180/** Stores the facet normal \param intvec*/
     181void facet::setFacetNormal(intvec *iv)
     182{
     183        this->fNormal = ivCopy(iv);                     
     184}
     185               
     186/** Hopefully returns the facet normal */
     187intvec *facet::getFacetNormal()
     188{                               
     189        return this->fNormal;
     190}
     191               
     192/** Method to print the facet normal*/
     193void facet::printNormal()
     194{
     195        fNormal->show();
     196}
     197               
     198/** Store the flipped GB*/
     199void facet::setFlipGB(ideal I)
     200{
     201        this->flipGB=idCopy(I);
     202}
     203               
     204/** Return the flipped GB*/
     205ideal facet::getFlipGB()
     206{
     207        return this->flipGB;
     208}
     209               
     210/** Print the flipped GB*/
     211void facet::printFlipGB()
     212{
     213        idShow(this->flipGB);
     214}
     215               
     216/** Set the UCN */
     217void facet::setUCN(int n)
     218{
     219        this->UCN=n;
     220}
     221               
     222/** \brief Get the UCN
     223* Returns the UCN iff this != NULL, else -1
     224*/
     225int facet::getUCN()
     226{
     227        if(this!=NULL && ( this!=(facet *)0xfbfbfbfb || this!=(facet *)0xfbfbfbfbfbfbfbfb) )
     228                return this->UCN;
     229        else
     230                return -1;
     231}
     232               
     233/** Store an interior point of the facet */
     234void facet::setInteriorPoint(intvec *iv)
     235{
     236        this->interiorPoint = ivCopy(iv);
     237}
     238               
     239intvec *facet::getInteriorPoint()
     240{
     241        return this->interiorPoint;
     242}       
     243               
     244/** \brief Debugging function
     245* prints the facet normal an all (codim-2)-facets that belong to it
     246*/
     247void facet::fDebugPrint()
     248{                       
     249        facet *codim2Act;                       
     250        codim2Act = this->codim2Ptr;
     251        intvec *fNormal;
     252        fNormal = this->getFacetNormal();
     253        intvec *f2Normal;
     254        cout << "=======================" << endl;
     255        cout << "Facet normal = (";
     256        fNormal->show(1,1);
     257        cout << ")"<<endl;
     258        /*for(int ii=0;ii<pVariables;ii++)
     259        {
     260                cout << (*fNormal)[ii] << ",";
     261        }
     262        if(this->isFlippable==TRUE)
     263                cout << ")" << endl;
     264        else
     265                cout << ")*" << endl;*/ //This case should never happen in SLA!
     266        cout << "-----------------------" << endl;
     267        cout << "Codim2 facets:" << endl;
     268        while(codim2Act!=NULL)
     269        {
     270                f2Normal = codim2Act->getFacetNormal();
     271                cout << "(";
     272                f2Normal->show(1,0);
     273//              for(int jj=0;jj<pVariables;jj++)
     274//              {
     275//                              cout << (*f2Normal)[jj] << ",";
     276//              }
     277                cout << ")" << endl;
     278                codim2Act = codim2Act->next;
     279        }
     280        cout << "=======================" << endl;
     281}               
     282               
     283//friend class gcone;   //Bad style
     284
    326285
    327286/**
Note: See TracChangeset for help on using the changeset viewer.