Changeset 7d10b3 in git


Ignore:
Timestamp:
May 19, 2009, 5:49:04 PM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
7853542cfd96856d73fbeb9148ebfe5b4637561b
Parents:
a0e0a80f7016d7e5784251e3e3e4a6b26ae2f3fb
Message:
Added and debugged method gcone::normalize to make the rows of a mpq_t matrix into intvecs
BUG: Singular crashes, while Singularg terminates normally...


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

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    ra0e0a80 r7d10b3  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-05-18 15:11:53 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.53 2009-05-18 15:11:53 monerjan Exp $
    6 $Id: gfan.cc,v 1.53 2009-05-18 15:11:53 monerjan Exp $
     4$Date: 2009-05-19 15:49:04 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.54 2009-05-19 15:49:04 monerjan Exp $
     6$Id: gfan.cc,v 1.54 2009-05-19 15:49:04 monerjan Exp $
    77*/
    88
     
    8989                bool isIncoming;        //Is the facet incoming or outgoing?
    9090                facet *next;            //Pointer to next facet
    91                 intvec *codim2Normals;
     91                intvec *codim2Normals;  //Integer matrix containing the (codim-2)-facets
    9292                               
    9393                /** The default constructor. Do I need a constructor of type facet(intvec)? */
     
    9797                        /* Defaults to NULL. This way there is no need to check explicitly */
    9898                        this->next=NULL;
     99                        this->UCN=NULL;
     100                        this->codim2Normals=NULL;
    99101                }
    100102               
     
    325327                        intvec *iv = new intvec(this->numVars);
    326328                       
    327                         while (f!=NULL)
     329                        while (f->next!=NULL)
    328330                        {
    329331                                iv = f->getFacetNormal();
     
    13951397                                dd_ErrorType err;
    13961398                                dd_rowindex newpos;                     
     1399                               
     1400                                fAct = fListPtr;
    13971401
    13981402#ifdef gfan_DEBUG
     
    14061410                                /*Now set appropriate linearity*/
    14071411                                dd_PolyhedraPtr ddpolyh;
    1408                                 for (int ii=0; ii<ddineq->rowsize; ii++)
     1412                                for (int ii=0; ii<this->numFacets; ii++)
    14091413                                {       
    14101414                                        cout << "------------" << endl;
    14111415                                        ddakt = dd_CopyMatrix(ddineq);
    14121416                                        set_addelem(ddakt->linset,ii+1);
    1413 //                                      dd_WriteMatrix(stdout,ddakt);
    14141417                                                                               
    14151418                                        dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);                   
     
    14201423                                        dd_WriteMatrix(stdout,P);
    14211424                                       
     1425                                        /* We loop through each row of P
     1426                                        * normalize it by making all entries integer ones
     1427                                        * and add the resulting vector to the int matrix facet::codim2Facets
     1428                                        */
     1429                                        for (int jj=1;jj<=P->rowsize;jj++)
     1430                                        {
     1431                                                intvec *n = new intvec(this->numVars);
     1432                                                n = normalize(P,jj);
     1433                                                //fAct->addCodim2Facet(n);                                                             
     1434                                        }
     1435                                       
    14221436                                        //intvec *load = new intvec(this->numVars);
    14231437                                       
     
    14281442                               
    14291443                        }                       
    1430 #ifdef gfan_DEBUG
    1431                         cout << "Before writeConeToFile" << endl;
    1432                         gc.showFacets();
    1433 #endif         
    1434                
     1444       
    14351445                       
    14361446                        //NOTE Hm, comment in and get a crash for free...
    14371447                        //dd_free_global_constants();                           
    14381448                        gc.writeConeToFile(gc);
    1439 #ifdef gfan_DEBUG                       
    1440                         cout << "After writeConeToFile" << endl;
    1441                         gc.showFacets();                       
    1442 #endif
    14431449                       
    14441450                        /*2nd step
     
    14521458                }//void noRevS(gcone &gc)
    14531459               
    1454                 /** \brief Construct a ddMatrix from a cone's list of facets
     1460                intvec *normalize(dd_MatrixPtr const &M, int line)
     1461                {                       
     1462                        mpz_t denom[this->numVars];
     1463                        for(int ii=0;ii<this->numVars;ii++)
     1464                        {
     1465                                mpz_init_set_str(denom[ii],"0",10);
     1466                        }
     1467               
     1468                        mpz_t kgV;
     1469                        mpz_init(kgV);
     1470                        intvec *ivres = new intvec(this->numVars);
     1471                       
     1472                        for (int ii=0;ii<(M->colsize)-1;ii++)
     1473                        {
     1474                                mpz_t z;
     1475                                mpz_init(z);
     1476                                mpq_get_den(z,M->matrix[line-1][ii+1]);
     1477                                //mpz_out_str(stdout,10,z);
     1478                                mpz_set( denom[ii], z);
     1479                                mpz_clear(z);                           
     1480                        }
     1481                        /*Compute lcm of the denominators*/
     1482                        mpz_set(kgV,denom[0]);
     1483                        for (int ii=0;ii<(M->colsize)-1;ii++)
     1484                        {
     1485                                mpz_lcm(kgV,kgV,denom[ii+1]);                           
     1486                        }
     1487                        /*Multiply the nominators by kgV*/
     1488                        mpq_t qkgV,res;
     1489                        mpq_init(qkgV);
     1490                        mpq_init(res);
     1491                        mpq_set_z(qkgV,kgV);
     1492                        for (int ii=0;ii<(M->colsize)-1;ii++)
     1493                        {
     1494                                mpq_mul(res,qkgV,M->matrix[line-1][ii+1]);
     1495                                (*ivres)[ii]=(int)mpz_get_d(mpq_numref(res));
     1496                        }                       
     1497                        return ivres;
     1498                }
     1499               
     1500                /** \brief Construct a dd_MatrixPtr from a cone's list of facets
    14551501                *
    14561502                */
     
    14591505                        facet *fAct = new facet();
    14601506                        fAct = gc.facetPtr;
    1461 #ifdef gfan_DEBUG
    1462                         cout << "gcFacetPtr is at" << &gc.facetPtr << endl;
    1463                         cout << "fAct is at" << &fAct << endl;
    1464 #endif 
     1507       
    14651508                        dd_MatrixPtr M;
    14661509                        dd_rowrange ddrows;
     
    14681511                        ddcols=(this->numVars)+1;
    14691512                        ddrows=this->numFacets;
     1513                        dd_NumberType numb = dd_Integer;
    14701514                        M=dd_CreateMatrix(ddrows,ddcols);                       
    1471 #ifdef gfan_DEBUG                       
    1472                         cout << "in f2M" << endl;
    1473                         showFacets();
    1474 #endif
    14751515                       
    14761516                        //dd_set_global_constants();                                           
     
    14871527                                fAct = fAct->next;                             
    14881528                        }//jj
    1489 #ifdef gfan_DEBUG               
    1490                         cout << "in f2M" << endl;
    1491                         showFacets();
    1492 #endif
    14931529                       
    14941530                        //delete fAct;
     
    15291565                               
    15301566                                gcOutputFile << "FACETS" << endl;                                                               
    1531                                 while(fAct!=NULL)
     1567                                while(fAct->next!=NULL)
    15321568                                {       
    15331569                                        intvec *iv = new intvec(gc.numVars);
Note: See TracChangeset for help on using the changeset viewer.