Changeset 5435c3 in git


Ignore:
Timestamp:
May 12, 2009, 5:30:29 PM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
cb6cdaaa807284703d4425ec7714979ea30194ae
Parents:
1fcefdd0abdf3767dc01bd67bbda1d17b3674379
Message:
UCN
Setters and getters
method gcone:noRevS


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

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r1fcefd r5435c3  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-05-11 14:27:44 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.49 2009-05-11 14:27:44 monerjan Exp $
    6 $Id: gfan.cc,v 1.49 2009-05-11 14:27:44 monerjan Exp $
     4$Date: 2009-05-12 15:30:29 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.50 2009-05-12 15:30:29 monerjan Exp $
     6$Id: gfan.cc,v 1.50 2009-05-12 15:30:29 monerjan Exp $
    77*/
    88
     
    2121#include "ring.h"
    2222#include "prCopy.h"
    23 #include <iostream>     //deprecated
     23#include <iostream>
    2424#include <bitset>
    2525#include <fstream>      //read-write cones to files
     
    6767                intvec *fNormal;
    6868               
     69                /** \brief An interior point of the facet*/
     70                intvec *interiorPoint;
     71               
     72                /** \brief Universal Cone Number
     73                * The number of the cone the facet belongs to
     74                */
     75                int UCN;
     76               
    6977                /** \brief The Groebner basis on the other side of a shared facet
    7078                 *
     
    129137                {
    130138                        idShow(this->flipGB);
     139                }
     140               
     141                void setUCN(int n)
     142                {
     143                        this->UCN=n;
     144                }
     145               
     146                int getUCN()
     147                {
     148                        return this->UCN;
     149                }
     150               
     151                void setInteriorPoint(intvec *iv)
     152                {
     153                        this->interiorPoint = ivCopy(iv);
     154                }
     155               
     156                intvec *getInteriorPoint()
     157                {
     158                        return this->interiorPoint;
    131159                }
    132160               
     
    191219                /* TODO in order to save memory use pointers to rootRing and inputIdeal instead */
    192220                intvec *ivIntPt;        //an interior point of the cone
     221                int UCN;                //unique number of the cone
    193222               
    194223        public:
     
    212241                        this->facetPtr=NULL;
    213242                        this->baseRing=currRing;
     243                        this->UCN=1;
    214244                }
    215245               
     
    228258                        this->inputIdeal=I;
    229259                        this->baseRing=currRing;
     260                        this->UCN=1;
    230261                }
    231262               
     
    238269                {
    239270                        this->next=NULL;
    240                         this->numVars=gc.numVars;                       
     271                        this->numVars=gc.numVars;
     272                        this->UCN=(gc.UCN)+1;   //add 1 to the UCN of previous cone
    241273                        facet *fAct= new facet();                       
    242274                        this->facetPtr=fAct;
     
    244276                        intvec *ivtmp = new intvec(this->numVars);                                             
    245277                        ivtmp = gc.facetPtr->getFacetNormal();
    246                         ivtmp->show();                 
     278                        //ivtmp->show();                       
    247279                       
    248280                        ideal gb;
     
    280312                {
    281313                        ivIntPt->show();
     314                }
     315               
     316                /** \brief Set gcone::numFacets */
     317                void setNumFacets()
     318                {
     319                }
     320               
     321                /** \brief Get gcone::numFacets */
     322                int getNumFacets()
     323                {
     324                        return this->numFacets;
     325                }
     326               
     327                int getUCN()
     328                {
     329                        return this->UCN;
    282330                }
    283331               
     
    431479                                        //(*load)[jj-1] = (int)foo;             //store typecasted entry at pos jj-1 of load
    432480                                        //check for flipability here
    433                                         if (jj<ddcols)                          //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :)
    434                                         {
     481//                                      if (jj<ddcols)                          //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :)
     482//                                      {
    435483                                                //fAct->next = new facet();     //If so: instantiate new facet. Otherwise this->next=NULL due to the constructor                                               
    436                                         }
     484//                                      }
    437485                                }//for (int jj = 1; jj <ddcols; jj++)
    438486                                /*Quick'n'dirty hack for flippability*/
     
    473521                        {
    474522                                intvec *iv = new intvec(this->numVars);
    475                                 interiorPoint(ddineq, *iv);
     523                                interiorPoint(ddineq, *iv);     //NOTE ddineq contains non-flippable facets
    476524                                this->setIntPoint(iv);  //stores the interior point in gcone::ivIntPt
    477525                                delete iv;
     
    945993               
    946994                /** \brief Compute an interior point of a given cone
     995                * Result will be written into intvec iv
    947996                */
    948997                void interiorPoint(dd_MatrixPtr const &M, intvec &iv) //no const &M here since we want to remove redundant rows
     
    9571006                        //M->representation=dd_Inequality;
    9581007                        //M->objective-dd_LPMin;  //Not sure whether this is needed
    959                         dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
    960                         //cout << "TICK 1" << endl;
    961                                                
     1008                       
     1009                        //NOTE: Make this n-dimensional!
     1010                        //dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
     1011                                                                       
    9621012                        //dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err);
    9631013                        //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;}
     
    9751025                        if (err!=dd_NoError){cout << "Error during dd_MakeLPForInteriorFinding in gcone::interiorPoint" << endl;}
    9761026#ifdef gfan_DEBUG
    977 //                      dd_WriteLP(stdout,lpInt);
     1027//                      dd_WriteLP(stdout,lpInt);
    9781028#endif                 
    9791029
     
    12631313                        }//while(fAct->next!=NULL)
    12641314                }//reverseSearch
     1315               
     1316                /** \brief The new method of Markwig and Jensen
     1317                */
     1318                void noRevS(gcone &gc)
     1319                {
     1320                        facet *fListPtr = new facet();                 
     1321                        facet *fAct = new facet();
     1322                        fAct = gc.facetPtr;
     1323                                               
     1324                        dd_set_global_constants();
     1325                        dd_rowrange ddrows;
     1326                        dd_colrange ddcols;
     1327                        ddrows=2;       //Each facet is described by its normal
     1328                        ddcols=gc.numVars+1;    // plus one for the standard simplex
     1329                       
     1330                        while(fAct->next!=NULL)
     1331                        {
     1332                                /*Compute an interior point for each facet*/                           
     1333                                dd_MatrixPtr ddineq;   
     1334                                ddineq=dd_CreateMatrix(ddrows,ddcols);
     1335                                intvec *comp = new intvec(this->numVars);
     1336                                comp=fAct->getFacetNormal();                           
     1337                                for(int ii=0; ii<this->numVars; ii++)                                   
     1338                                {                                                                               
     1339                                        dd_set_si(ddineq->matrix[0][ii+1],(*comp)[ii]);
     1340                                        dd_set_si(ddineq->matrix[1][ii+1],1);   //Assure we search in the pos. orthant                 
     1341                                }
     1342                                set_addelem(ddineq->linset,1);  //We want equality in the first row
     1343                                //dd_WriteMatrix(stdout,ddineq);
     1344                                interiorPoint(ddineq,*comp);                           
     1345                                /**/
     1346#ifdef gfan_DEBUG
     1347                                cout << "IP is";
     1348                                comp->show(); cout << endl;
     1349#endif
     1350                                //Store the interior point and the UCN
     1351                                fListPtr->setInteriorPoint( comp );                             
     1352                                fListPtr->setUCN( gc.getUCN() );       
     1353                                                       
     1354                                dd_FreeMatrix(ddineq);
     1355                                fAct=fAct->next;        //iterate
     1356                        }                       
     1357                       
     1358                        //NOTE Hm, comment in and get a crash for free...
     1359                        //dd_free_global_constants();                           
     1360                        gc.writeConeToFile(gc);
     1361                       
     1362                        /*2nd step
     1363                        Choose a facet from fListPtr, flip it and forget the previous cone
     1364                        */
     1365                        fAct = fListPtr;
     1366                        gcone *gcTmp = new gcone(gc);   //copy
     1367                        gcTmp->flip(gcTmp->gcBasis,fAct);
     1368                        //NOTE: gcTmp may be deleted, gcRoot from main proc should probably not!
     1369                       
     1370                }//void noRevS(gcone &gc)
    12651371               
    12661372                /** \brief Write information about a cone into a file on disk
     
    13131419                               
    13141420                                gcOutputFile.close();
     1421                                delete fAct; fAct=NULL;
    13151422                        }
    13161423                }//writeConeToFile(gcone const &gc)
     
    13361443        searchMethod method;
    13371444        method = noRevS;
    1338         //method = reverseSearch;
     1445//      method = reverseSearch;
    13391446       
    13401447#ifdef gfan_DEBUG
     
    13941501                gcAct->numVars=pVariables;
    13951502                gcAct->getGB(inputIdeal);
    1396                 gcAct->getConeNormals(gcAct->gcBasis);         
    1397                 gcAct->writeConeToFile(*gcAct);
     1503                gcAct->getConeNormals(gcAct->gcBasis);
     1504                cout << "ding" << endl;         
     1505                gcAct->noRevS(*gcAct);         
    13981506                res=gcAct->gcBasis;     
    13991507        }
Note: See TracChangeset for help on using the changeset viewer.