Changeset 472eeb in git for kernel/gfan.cc


Ignore:
Timestamp:
May 15, 2009, 3:54:46 PM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
294312ffcc6c4d753fa40971861665f124f63851
Parents:
8f63e4c7ff0fb85b12623e48dd7beeb869ab2257
Message:
facets2Matrix


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

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r8f63e4c r472eeb  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-05-14 09:55:36 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.51 2009-05-14 09:55:36 monerjan Exp $
    6 $Id: gfan.cc,v 1.51 2009-05-14 09:55:36 monerjan Exp $
     4$Date: 2009-05-15 13:54:46 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.52 2009-05-15 13:54:46 monerjan Exp $
     6$Id: gfan.cc,v 1.52 2009-05-15 13:54:46 monerjan Exp $
    77*/
    88
     
    212212class gcone
    213213{
    214         private:
    215                 int numFacets;          //#of facets of the cone
     214        private:               
    216215                ring rootRing;          //good to know this -> generic walk
    217216                ideal inputIdeal;       //the original
     
    222221               
    223222        public:
    224                 /** Pointer to the first facet */
     223                /** \brief Pointer to the first facet */
    225224                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
    226225               
    227226                /** # of variables in the ring */
    228227                int numVars;            //#of variables in the ring
     228               
     229                /** # of facets of the cone
     230                * This value is set by gcone::getConeNormals
     231                */
     232                int numFacets;          //#of facets of the cone
    229233               
    230234                /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/
     
    276280                       
    277281                        intvec *ivtmp = new intvec(this->numVars);                                             
    278                         ivtmp = gc.facetPtr->getFacetNormal();
    279                         //ivtmp->show();                       
     282                        ivtmp = gc.facetPtr->getFacetNormal();                 
    280283                       
    281284                        ideal gb;
    282285                        gb=gc.facetPtr->getFlipGB();                   
    283                         this->gcBasis=gb;//gc.facetPtr->getFlipGB();    //this cone's GB is the flipped GB
    284                         //idShow(this->gcBasis);
     286                        this->gcBasis=gb;       //this cone's GB is the flipped GB                     
    285287                       
    286288                        /*Reverse direction of the facet normal to make it an inner normal*/                   
     
    394396                                aktpoly=(poly)I->m[i];          //get aktpoly as i-th component of I
    395397                                pCompCount=pLength(aktpoly);    //How many terms does aktpoly consist of?
     398#ifdef gfan_DEBUG
    396399                                cout << "Poly No. " << i << " has " << pCompCount << " components" << endl;
     400#endif
    397401               
    398402                                int *v=(int *)omAlloc((numvar+1)*sizeof(int));
     
    469473                                for (int jj = 1; jj <ddcols; jj++)
    470474                                {
    471 #ifdef GMPRATIONAL
    472475                                        double foo;
    473476                                        foo = mpq_get_d(ddineq->matrix[kk][jj]);
     
    475478                                        std::cout << "fAct is " << foo << " at " << fAct << std::endl;
    476479#endif
    477                                         (*load)[jj-1] = (int)foo;               //store typecasted entry at pos jj-1 of load
    478 #endif                 
    479 
    480                                         //(*load)[jj-1] = (int)foo;             //store typecasted entry at pos jj-1 of load
    481                                         //check for flipability here
    482 //                                      if (jj<ddcols)                          //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :)
    483 //                                      {
    484                                                 //fAct->next = new facet();     //If so: instantiate new facet. Otherwise this->next=NULL due to the constructor                                               
    485 //                                      }
     480                                        (*load)[jj-1] = (int)foo;               //store typecasted entry at pos jj-1 of load           
    486481                                }//for (int jj = 1; jj <ddcols; jj++)
     482                               
    487483                                /*Quick'n'dirty hack for flippability*/
    488484                                bool isFlippable=FALSE;                         
     
    512508                                delete load;
    513509                        }//for (int kk = 0; kk<ddrows; kk++)
     510                       
    514511                        /*
    515512                        Now we should have a linked list containing the facet normals of those facets that are
     
    526523                                delete iv;
    527524                        }
     525                       
     526                        //Compute the number of facets
     527                        this->numFacets=ddineq->rowsize;
    528528                       
    529529                        //Clean up but don't delete the return value! (Whatever it will turn out to be)                 
     
    11421142                }
    11431143               
    1144                 /**
     1144                /** \brief Checks whether a given facet is a search facet
    11451145                * Determines whether a given facet of a cone is the search facet of a neighbouring cone
    11461146                * This is done in the following way:
     
    13191319                void noRevS(gcone &gc, bool usingIntPoint=FALSE)
    13201320                {
    1321                         facet *fListPtr = new facet();                 
     1321                        facet *fListPtr = new facet();  //The list containing ALL facets we come across                
    13221322                        facet *fAct = new facet();
    13231323                        fAct = gc.facetPtr;
     
    13561356                                        fAct=fAct->next;        //iterate
    13571357                                }       
    1358                         }               
     1358                        }
     1359                        else/*Facets of facets*/
     1360                        {
     1361                                dd_MatrixPtr ddineq,P,ddakt;
     1362                                dd_rowset impl_linset, redset;
     1363                                dd_ErrorType err;
     1364                                dd_rowindex newpos;
     1365                               
     1366                                ddineq = facets2Matrix(gc);
     1367                               
     1368                                /*Now set appropriate linearity*/
     1369                                dd_PolyhedraPtr ddpolyh;
     1370                                for (int ii=0; ii<ddineq->rowsize; ii++)
     1371                                {       
     1372                                        cout << "------------" << endl;
     1373                                        ddakt = dd_CopyMatrix(ddineq);
     1374                                        set_addelem(ddakt->linset,ii+1);
     1375//                                      dd_WriteMatrix(stdout,ddakt);
     1376                                                                               
     1377                                        dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);                   
     1378                                       
     1379//                                      dd_WriteMatrix(stdout,ddakt);
     1380                                        ddpolyh=dd_DDMatrix2Poly(ddakt, &err);
     1381                                        P=dd_CopyGenerators(ddpolyh);
     1382                                        dd_WriteMatrix(stdout,P);
     1383                                       
     1384                                        intvec *load = new intvec(this->numVars);
     1385                                       
     1386                                        dd_FreeMatrix(ddakt);
     1387                                        dd_FreePolyhedra(ddpolyh);
     1388                                }
     1389                               
     1390                        }                               
    13591391                       
    13601392                        //NOTE Hm, comment in and get a crash for free...
     
    13671399                        fAct = fListPtr;
    13681400                        gcone *gcTmp = new gcone(gc);   //copy
    1369                         gcTmp->flip(gcTmp->gcBasis,fAct);
     1401                        //gcTmp->flip(gcTmp->gcBasis,fAct);
    13701402                        //NOTE: gcTmp may be deleted, gcRoot from main proc should probably not!
    13711403                       
    13721404                }//void noRevS(gcone &gc)
     1405               
     1406                /** \brief Construct a ddMatrix from a cone's list of facets
     1407                *
     1408                */
     1409                dd_MatrixPtr facets2Matrix(gcone const &gc)
     1410                {
     1411                        facet *fAct = new facet();
     1412                        fAct = gc.facetPtr;                     
     1413                        dd_MatrixPtr M;
     1414                        dd_rowrange ddrows;
     1415                        dd_colrange ddcols;
     1416                        ddcols=(this->numVars)+1;
     1417                        ddrows=this->numFacets;
     1418                        M=dd_CreateMatrix(ddrows,ddcols);
     1419                       
     1420                        //dd_set_global_constants();                                           
     1421                                               
     1422                        intvec *comp = new intvec(this->numVars);                       
     1423                       
     1424                        for (int jj=0; jj<M->rowsize; jj++)
     1425                        {
     1426                                comp = fAct->getFacetNormal();
     1427                                for (int ii=0; ii<this->numVars; ii++)
     1428                                {
     1429                                        dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]);
     1430                                }
     1431                                fAct = fAct->next;                             
     1432                        }//jj
     1433                        delete comp;           
     1434                       
     1435                        return M;
     1436                }
    13731437               
    13741438                /** \brief Write information about a cone into a file on disk
     
    13901454                        }
    13911455                        else
    1392                         {                       
     1456                        {       /*gcOutputFile << "UCN" << endl;
     1457                                gcOutputFile << this->UCN << endl;*/
    13931458                                gcOutputFile << "RING" << endl;                         
    13941459                                //Write this->gcBasis into file
     
    14021467                                fAct = gc.facetPtr;
    14031468                                gcOutputFile << "FACETS" << endl;                                                               
    1404                                 while(fAct->next!=NULL)
     1469                                while(fAct!=NULL)
    14051470                                {       
    14061471                                        intvec *iv = new intvec(gc.numVars);
Note: See TracChangeset for help on using the changeset viewer.