Changeset 94aed9 in git for kernel/gfan.cc


Ignore:
Timestamp:
Jul 15, 2009, 11:49:09 AM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d4f44f4f228fbb8258ce8e9927141d37d4470719
Parents:
7ae94bb7c3176ec1860c1447b4e220578a2affa3
Message:
Implemented codim2 check
Workaround for problems with intPointMatrix in flip


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

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r7ae94b r94aed9  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-07-13 09:03:37 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.76 2009-07-13 09:03:37 monerjan Exp $
    6 $Id: gfan.cc,v 1.76 2009-07-13 09:03:37 monerjan Exp $
     4$Date: 2009-07-15 09:49:09 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.77 2009-07-15 09:49:09 monerjan Exp $
     6$Id: gfan.cc,v 1.77 2009-07-15 09:49:09 monerjan Exp $
    77*/
    88
     
    656656                        ddFacets = dd_CopyMatrix(ddineq);
    657657#ifdef gfan_DEBUG
    658                         cout << "Having removed redundancies, the normals now read:" << endl;
    659                         dd_WriteMatrix(stdout,ddineq);
     658//                      cout << "Having removed redundancies, the normals now read:" << endl;
     659//                      dd_WriteMatrix(stdout,ddineq);
    660660//                      cout << "Rows = " << ddrows << endl;
    661661//                      cout << "Cols = " << ddcols << endl;
     
    664664                        /*Write the normals into class facet*/
    665665#ifdef gfan_DEBUG
    666                         cout << "Creating list of normals" << endl;
     666//                      cout << "Creating list of normals" << endl;
    667667#endif
    668668                        /*The pointer *fRoot should be the return value of this function*/
     
    673673                        //fAct = fRoot;                 //Seems to do the trick. fRoot and fAct have to point to the same adress!
    674674                        //std::cout << "fRoot = " << fRoot << ", fAct = " << fAct << endl;
     675                        int numNonFlip=0;
    675676                        for (int kk = 0; kk<ddrows; kk++)
    676677                        {
     
    687688                               
    688689                                /*Quick'n'dirty hack for flippability*/
    689                                 bool isFlip=FALSE;                             
     690                                bool isFlip=FALSE;
     691                                                               
    690692                                for (int jj = 0; jj<load->length(); jj++)
    691693                                {
     
    703705                                {
    704706                                        this->numFacets++;
     707                                        numNonFlip++;
    705708                                        if(this->numFacets==1)
    706709                                        {
     
    742745                                        fAct->setUCN(this->getUCN());                                   
    743746                                }//if (isFlippable==FALSE)
    744                                 //delete load;
     747                                //delete load;                         
    745748                        }//for (int kk = 0; kk<ddrows; kk++)
     749                       
     750                        //In cases like I=<x-1,y-1> there are only non-flippable facets...
     751                        if(numNonFlip==this->numFacets)
     752                        {                                       
     753                                cerr << "Only non-flippable facets. Terminating..." << endl;
     754                        }
    746755                       
    747756                        /*
     
    799808                        /*Now set appropriate linearity*/
    800809                        dd_PolyhedraPtr ddpolyh;
    801                         for (int ii=0; ii<this->numFacets; ii++)
    802                         //while(fAct!=NULL)
     810                        for (int ii=0; ii<this->numFacets; ii++)                       
    803811                        {                               
    804812                                ddakt = dd_CopyMatrix(ddineq);
     
    840848                                        codim2Act->setFacetNormal(n);
    841849                                        delete n;                                       
    842                                         /*intvec *n = new intvec(this->numVars);
    843                                         makeInt(P,jj,*n);                                               
    844                                         codim2Act->setFacetNormal(n);
    845                                         this->facetPtr->numCodim2Facets++;      //Honor the creation of a codim-2-facet
    846                                         codim2Act->next = new facet(2);
    847                                         codim2Act = codim2Act->next;                                           
    848                                         delete n;*/
    849                                 }                                                                               
     850                                }               
     851                                /*We check whether the facet spanned by the codim-2 facets
     852                                * intersects with the positive orthant. Otherwise we define this
     853                                * facet to be non-flippable
     854                                */
     855                                intvec *iv_intPoint = new intvec(this->numVars);
     856                                dd_MatrixPtr shiftMatrix;
     857                                dd_MatrixPtr intPointMatrix;
     858                                shiftMatrix = dd_CreateMatrix(this->numVars,this->numVars+1);
     859                                for(int kk=0;kk<this->numVars;kk++)
     860                                {
     861                                        dd_set_si(shiftMatrix->matrix[kk][0],1);
     862                                        dd_set_si(shiftMatrix->matrix[kk][kk+1],1);
     863                                }
     864                                intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);
     865                                //dd_WriteMatrix(stdout,intPointMatrix);
     866                                interiorPoint(intPointMatrix,*iv_intPoint);
     867                                for(int ll=0;ll<this->numVars;ll++)
     868                                {
     869                                        if( (*iv_intPoint)[ll] < 0 )
     870                                        {
     871                                                fAct->isFlippable=FALSE;
     872                                                break;
     873                                        }
     874                                }
     875                                /*End of check*/                                       
    850876                                fAct = fAct->next;     
    851877                                dd_FreeMatrix(ddakt);
     
    972998                        ina=idrCopyR(initialForm,srcRing);                     
    973999#ifdef gfan_DEBUG
    974                         cout << "ina=";
    975                         idShow(ina); cout << endl;
     1000//                      cout << "ina=";
     1001//                      idShow(ina); cout << endl;
    9761002#endif
    9771003                        ideal H;
     
    9801006                        idSkipZeroes(H);
    9811007#ifdef gfan_DEBUG
    982                         cout << "H="; idShow(H); cout << endl;
     1008//                      cout << "H="; idShow(H); cout << endl;
    9831009#endif
    9841010                        /*Substep 2.2
     
    9901016                        srcRing_H=idrCopyR(H,tmpRing);
    9911017#ifdef gfan_DEBUG
    992                         cout << "srcRing_H = ";
    993                         idShow(srcRing_H); cout << endl;
     1018//                      cout << "srcRing_H = ";
     1019//                      idShow(srcRing_H); cout << endl;
    9941020#endif
    9951021                        srcRing_HH=ffG(srcRing_H,this->gcBasis);               
    9961022#ifdef gfan_DEBUG
    997                         cout << "srcRing_HH = ";
    998                         idShow(srcRing_HH); cout << endl;
     1023//                      cout << "srcRing_HH = ";
     1024//                      idShow(srcRing_HH); cout << endl;
    9991025#endif
    10001026                        /*Substep 2.2.1
     
    10191045                        construction of the differences
    10201046                        */
    1021                         intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1);
     1047                        intPointMatrix = dd_CreateMatrix(iPMatrixRows+10,this->numVars+1);
    10221048                        intPointMatrix->numbtype=dd_Integer;    //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational
    10231049                       
     
    13291355               
    13301356                /** \brief Compute an interior point of a given cone
    1331                 * Result will be written into intvec iv
     1357                * Result will be written into intvec iv.
     1358                * Any rational point is automatically converted into an integer.
    13321359                */
    13331360                void interiorPoint(dd_MatrixPtr const &M, intvec &iv) //no const &M here since we want to remove redundant rows
     
    17581785                       
    17591786                        fAct = gcAct->facetPtr;                 
    1760                         gcAct->writeConeToFile(*gcAct);
     1787                        //gcAct->writeConeToFile(*gcAct);
    17611788                       
    17621789                        /*End of initialisation*/
     
    17811808                                        gcTmp->getCodim2Normals(*gcTmp);
    17821809                                        gcTmp->normalize();
    1783                                         gcTmp->writeConeToFile(*gcTmp);
     1810                                        //gcTmp->writeConeToFile(*gcTmp);
    17841811                                        /*add facets to SLA here*/
    17851812                                        SearchListRoot=gcTmp->enqueueNewFacets(*SearchListRoot);
    1786                                         gcTmp->showSLA(*SearchListRoot);
     1813                                        if(SearchListRoot!=NULL)
     1814                                                gcTmp->showSLA(*SearchListRoot);
    17871815                                        rChangeCurrRing(gcAct->baseRing);
    17881816                                        gcPtr->next=gcTmp;
     
    18141842                                SearchListAct = SearchListRoot;
    18151843                        }
     1844                        cout << endl << "Found " << counter << " cones - terminating" << endl;
    18161845               
    18171846                        //NOTE Hm, comment in and get a crash for free...
     
    20382067                                                                {
    20392068                                                                        slHead = slAct->next;
    2040                                                                         slHead->prev = NULL;
     2069                                                                        if(slHead!=NULL)
     2070                                                                                slHead->prev = NULL;
    20412071                                                                        //set a bool flag to mark slAct as to be deleted
    20422072                                                                }
Note: See TracChangeset for help on using the changeset viewer.