Changeset 42660f in git


Ignore:
Timestamp:
Dec 8, 2009, 6:18:09 PM (14 years ago)
Author:
Martin Monerjan
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
49322598c9584a3eeea285d54df58555dad65365
Parents:
44b47da220f802c0fbdacb637c0db51c885e3b6f
Message:
Crude profiling via gfanp
removed unnecessary includes
shrinked scope of several variables throughout the code, hopefully
removing some memory leaks



git-svn-id: file:///usr/local/Singular/svn/trunk@12376 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r44b47d r42660f  
    1212
    1313#include "kstd1.h"
    14 #include "kutil.h"
    15 #include "intvec.h"
     14#include "kutil.h"      //ksCreateSpoly
     15// #include "intvec.h"
    1616#include "polys.h"
    1717#include "ideals.h"
    18 #include "kmatrix.h"
     18// #include "kmatrix.h"
    1919//#include "fast_maps.h"        //Mapping of ideals
    20 #include "maps.h"
    21 #include "ring.h"
    22 #include "structs.h"
     20// #include "maps.h"
     21// #include "ring.h"    //apparently not needed
     22// #include "structs.h"
    2323#include "../Singular/lists.h"
    24 #include "prCopy.h"
     24#include "prCopy.h"     //Needed for idrCopyR
    2525#include <iostream>
    26 #include <bitset>
     26// #include <bitset>
    2727#include <fstream>      //read-write cones to files
    28 #include <gmp.h>
     28// #include <gmp.h>
    2929#include <string>
    3030#include <sstream>
    3131#include <time.h>
    32 
     32#include <sys/time.h>
    3333//#include <gmpxx.h>
    3434
     
    6969#endif
    7070#endif
    71 
     71#define gfanp
    7272#include <gfan.h>
    7373using namespace std;
     
    621621inline void gcone::getConeNormals(const ideal &I, bool compIntPoint)
    622622{
     623#ifdef gfanp
     624        timeval start, end;
     625        gettimeofday(&start, 0);
     626#endif
    623627        poly aktpoly;
    624628        int rows;                       // will contain the dimensions of the ineq matrix - deprecated by
     
    650654                //simpler version of storing expvect diffs
    651655                int *leadexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
    652                 int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
     656//              int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
    653657                pGetExpV(aktpoly,leadexpv);
    654658                while(pNext(aktpoly)!=NULL)
    655659                {
    656660                        aktpoly=pNext(aktpoly);
     661                        int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
    657662                        pGetExpV(aktpoly,tailexpv);
    658663                        for(int kk=1;kk<=this->numVars;kk++)
     
    661666                        }
    662667                        aktmatrixrow += 1;
    663                 }
    664                 omFree(tailexpv);
     668                        omFree(tailexpv);
     669                }               
    665670                omFree(leadexpv);       
    666671        } //for
     
    891896        set_free(ddredrows);
    892897        set_free(ddlinset);
    893         //free(ddnewpos);
     898        free(ddnewpos);
     899#ifdef gfanp
     900        gettimeofday(&end, 0);
     901        time_getConeNormals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
     902#endif
    894903       
    895904
     
    901910 * the facet is marked as non-flippable.
    902911 */
    903 inline void gcone::getCodim2Normals(gcone const &gc)
    904 {
     912inline void gcone::getCodim2Normals(const gcone &gc)
     913{
     914#ifdef gfanp
     915        timeval start, end;
     916        gettimeofday(&start, 0);
     917#endif
    905918        //this->facetPtr->codim2Ptr = new facet(2);     //instantiate a (codim-2)-facet
    906919        facet *fAct;
     
    908921        facet *codim2Act;
    909922        //codim2Act = this->facetPtr->codim2Ptr;
    910         dd_MatrixPtr ddineq,P,ddakt;
    911         dd_rowset impl_linset, redset;
     923        dd_MatrixPtr ddineq;//,P,ddakt;
    912924        dd_ErrorType err;
    913         dd_rowindex newpos;             
    914 
    915925        //ddineq = facets2Matrix(gc);   //get a matrix representation of the cone
    916926        ddineq = dd_CopyMatrix(gc.ddFacets);
    917                                
    918927        /*Now set appropriate linearity*/
    919         dd_PolyhedraPtr ddpolyh;
    920928        for (int ii=0; ii<this->numFacets; ii++)                       
    921         {                               
    922                 ddakt = dd_CopyMatrix(ddineq);
     929        {       
     930//              dd_rowset LL;
     931//              set_initialize(&LL,ddineq->rowsize);
     932//              set_copy(LL,ddineq->linset);
     933//              set_copy(ddineq->linset,LL);
     934                dd_rowset impl_linset, redset;
     935                dd_rowindex newpos;
     936                dd_MatrixPtr ddakt;
     937                ddakt = dd_CopyMatrix(ddineq);
    923938                ddakt->representation=dd_Inequality;
    924                 set_addelem(ddakt->linset,ii+1);/*Now set appropriate linearity*/                               
    925                 dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);                   
     939                set_addelem(ddakt->linset,ii+1);/*Now set appropriate linearity*/
     940#ifdef gfanp
     941                timeval t_ddMC_start, t_ddMC_end;
     942                gettimeofday(&t_ddMC_start,0);
     943#endif                         
     944                dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);
     945//              set_copy(LL,ddakt->linset);
     946                dd_PolyhedraPtr ddpolyh;
    926947                ddpolyh=dd_DDMatrix2Poly(ddakt, &err);
    927                 P=dd_CopyGenerators(ddpolyh);                           
     948                dd_MatrixPtr P;
     949                P=dd_CopyGenerators(ddpolyh);
     950                dd_FreePolyhedra(ddpolyh);
     951#ifdef gfanp
     952                gettimeofday(&t_ddMC_end,0);
     953                t_ddMC += (t_ddMC_end.tv_sec - t_ddMC_start.tv_sec + 1e-6*(t_ddMC_end.tv_usec - t_ddMC_start.tv_usec));
     954#endif                         
    928955                /* We loop through each row of P normalize it by making all
    929956                * entries integer ones and add the resulting vector to the
     
    943970                        }
    944971                        intvec *n = new intvec(this->numVars);
     972#ifdef gfanp
     973                        timeval t_mI_start, t_mI_end;
     974                        gettimeofday(&t_mI_start,0);
     975#endif
    945976                        makeInt(P,jj,*n);
     977#ifdef gfanp
     978                        gettimeofday(&t_mI_end,0);
     979                        t_mI += (t_mI_end.tv_sec - t_mI_start.tv_sec + 1e-6*(t_mI_end.tv_usec - t_mI_start.tv_usec));
     980#endif
    946981                        codim2Act->setFacetNormal(n);
    947982                        delete n;                                       
     
    960995                        dd_set_si(shiftMatrix->matrix[kk][kk+1],1);
    961996                }
    962                 intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);             
     997                intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);
     998#ifdef gfanp
     999                timeval t_iP_start, t_iP_end;
     1000                gettimeofday(&t_iP_start, 0);
     1001#endif         
    9631002                interiorPoint(intPointMatrix,*iv_intPoint);
     1003#ifdef gfanp
     1004                gettimeofday(&t_iP_end, 0);
     1005                t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
     1006#endif
    9641007                for(int ll=0;ll<this->numVars;ll++)
    9651008                {
     
    9731016                fAct = fAct->next;     
    9741017                dd_FreeMatrix(ddakt);
    975 //              dd_FreeMatrix(ddineq);
    9761018                dd_FreeMatrix(shiftMatrix);
    977                 dd_FreeMatrix(intPointMatrix);
    978                 dd_FreePolyhedra(ddpolyh);
     1019                dd_FreeMatrix(intPointMatrix);         
    9791020                delete iv_intPoint;
    9801021                dd_FreeMatrix(P);
    9811022                set_free(impl_linset);
    982                 set_free(redset);
     1023                set_free(redset);               
    9831024                free(newpos);
    984         }//for
     1025//              set_free(LL);
     1026        }//for 
    9851027        dd_FreeMatrix(ddineq);
    986 //      dd_FreeMatrix(P);
    987 //      set_free(impl_linset);
    988 //      set_free(redset);
    989 //      free(newpos);
    990        
     1028#ifdef gfanp
     1029        gettimeofday(&end, 0);
     1030        time_getCodim2Normals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
     1031#endif
    9911032}
    9921033               
     
    10051046 */
    10061047inline void gcone::flip(ideal gb, facet *f)             //Compute "the other side"
    1007 {                       
     1048{       
     1049#ifdef gfanp
     1050        timeval start, end;
     1051        gettimeofday(&start, 0);
     1052#endif         
    10081053        intvec *fNormal;// = new intvec(this->numVars); //facet normal, check for parallelity                   
    10091054        fNormal = f->getFacetNormal();  //read this->fNormal;
     
    10721117        idDelete(&initialForm);
    10731118        ideal H;
    1074 //      H=kStd(ina,NULL,isHomog,NULL);  //we know it is homogeneous
     1119//      H=kStd(ina,NULL,isHomog,NULL);  //we know it is homogeneous
    10751120        H=kStd(ina,NULL,testHomog,NULL);        //This is \mathcal(G)_{>_-\alpha}(in_v(I))
    10761121        idSkipZeroes(H);
     
    11461191                        omFree(dst_ExpV);
    11471192                }//for (int jj=0;jj<IDELEMS(H);jj++)
    1148                                
    1149                 int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
     1193               
    11501194                int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
    11511195                if (markingsAreCorrect==TRUE)
     
    11621206                while (pNext(aktpoly)!=NULL)
    11631207                {
     1208                        int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
    11641209                        /*The following if-else-block makes sure the first term (i.e. the wrongly marked term)
    11651210                        is not omitted when computing the differences*/
     
    11811226                        }
    11821227                        aktrow +=1;
     1228                        omFree(v);
    11831229                }
    1184                 omFree(v);
     1230//              omFree(v);
    11851231                omFree(leadExpV);
    11861232        }//for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
     
    12441290        idDelete(&tmpI);
    12451291        idNorm(dstRing_I);                     
    1246         //kInterRed(dstRing_I);
     1292//      kInterRed(dstRing_I);
    12471293        idSkipZeroes(dstRing_I);
    12481294        test=save;
     
    12591305        rChangeCurrRing(srcRing);       //return to the ring we started the computation of flipGB in
    12601306        rDelete(dstRing);
     1307#ifdef gfanp
     1308        gettimeofday(&end, 0);
     1309        time_flip += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
     1310#endif
    12611311}//void flip(ideal gb, facet *f)
    12621312
     
    12681318inline void gcone::computeInv(ideal &gb, ideal &initialForm, intvec &fNormal)
    12691319{
    1270         intvec *check = new intvec(this->numVars);
    1271         poly initialFormElement;//[IDELEMS(gb)];
    1272 //      poly aktpoly;
    1273        
     1320#ifdef gfanp
     1321        timeval start, end;
     1322        gettimeofday(&start, 0);
     1323#endif
    12741324        for (int ii=0;ii<IDELEMS(gb);ii++)
    12751325        {
    1276 //              aktpoly = pCopy((poly)gb->m[ii]);
     1326                poly initialFormElement;
    12771327                poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly)
    1278                 int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
    12791328                int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
    12801329                pGetExpV(aktpoly,leadExpV);     //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p)
    12811330//              initialFormElement[ii]=pHead(aktpoly);
    12821331                initialFormElement=pHead(aktpoly);
    1283                                
    12841332                while(pNext(aktpoly)!=NULL)     /*loop trough terms and check for parallelity*/
    12851333                {
     1334                        intvec *check = new intvec(this->numVars);
    12861335                        aktpoly=pNext(aktpoly); //next term
    12871336//                      pSetm(aktpoly);
     1337                        int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
    12881338                        pGetExpV(aktpoly,v);           
    12891339                        /* Convert (int)v into (intvec)check */                 
    12901340                        for (int jj=0;jj<this->numVars;jj++)
    12911341                        {
    1292                                                 //cout << "v["<<jj+1<<"]="<<v[jj+1]<<endl;
    1293                                                 //cout << "leadExpV["<<jj+1<<"]="<<leadExpV[jj+1]<<endl;
    12941342                                (*check)[jj]=v[jj+1]-leadExpV[jj+1];
    12951343                        }
     
    12991347//                              initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly));
    13001348                                initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));
    1301                         }                                               
     1349                        }
     1350                        omFree(v);
     1351                        delete check;
    13021352                }//while
    13031353#ifdef gfan_DEBUG
     
    13121362                pDelete(&initialFormElement);
    13131363                omFree(leadExpV);
    1314                 omFree(v);             
     1364//              delete check;
    13151365        }//for
    1316         delete check;
    1317 //      pDelete(&aktpoly);
     1366#ifdef gfanp
     1367        gettimeofday(&end, 0);
     1368        time_computeInv += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
     1369#endif
    13181370}
    13191371
     
    13371389        int size=IDELEMS(H);
    13381390        ideal res=idInit(size,1);
    1339         poly temp1;//=pInit();
    1340         poly temp2;//=pInit();
    1341         poly temp3;//=pInit();  //polys to temporarily store values for pSub
     1391//      poly temp1;//=pInit();
     1392//      poly temp2;//=pInit();
     1393//      poly temp3;//=pInit();  //polys to temporarily store values for pSub
    13421394        for (int ii=0;ii<size;ii++)
    13431395        {
     1396                poly temp1=pInit();
     1397                poly temp2=pInit();
     1398                poly temp3=pInit();
    13441399//              res->m[ii]=restOfDiv(H->m[ii],G);
    13451400//              res->m[ii]=pCopy(kNF(G, NULL,H->m[ii],0,0));
    13461401                temp1=pCopy(H->m[ii]);
    13471402//              temp2=pCopy(res->m[ii]);
     1403                //NOTE if gfanHeuristic=0 (sic!) this results in dPolyErrors - mon from wrong ring
    13481404                temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));
    13491405                temp3=pSub(temp1, temp2);
    13501406                res->m[ii]=pCopy(temp3);
    1351                 //res->m[ii]=pSub(temp1,temp2); //buggy
    1352                 //pSort(res->m[ii]);
    1353                 //pSetm(res->m[ii]);
    1354                 //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);       
    1355         }       
    1356         pDelete(&temp1);               
    1357 //      pDelete(&temp2);
    1358 //      pDelete(&temp3);
     1407                //res->m[ii]=pSub(temp1,temp2); //buggy         
     1408                //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);
     1409                pDelete(&temp1);
     1410//              pDelete(&temp2);
     1411//              pDelete(&temp3); //NOTE does not work, so commented out
     1412        }
    13591413        return res;
    13601414}
     
    14371491        dd_LPSolutionPtr lpSol=NULL;
    14381492        dd_rowset ddlinset,ddredrows;   //needed for dd_FindRelativeInterior
    1439         dd_rowindex ddnewpos;
     1493//      dd_rowindex ddnewpos;
    14401494        dd_NumberType numb;     
    14411495                        //M->representation=dd_Inequality;
     
    15251579        dd_FreeLPData(lp);
    15261580        set_free(ddlinset);
    1527         set_free(ddredrows);
    1528 //      free(ddnewpos); //segfaults
     1581        set_free(ddredrows);   
    15291582                       
    15301583}//void interiorPoint(dd_MatrixPtr const &M)
     
    17761829                        {
    17771830                                gcTmp->writeConeToFile(*gcTmp);
    1778                                 for(int ii=0;ii<IDELEMS(gcTmp->gcBasis);ii++)
    1779                                 {
    1780                                         pDelete(&gcTmp->gcBasis->m[ii]);
    1781                                 }
    1782 //                              idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
    1783 //                              rDelete(gcTmp->baseRing);
     1831                                //The for loop is no longer needed
     1832//                              for(int ii=0;ii<IDELEMS(gcTmp->gcBasis);ii++)
     1833//                              {
     1834//                                      pDelete(&gcTmp->gcBasis->m[ii]);
     1835//                              }
     1836                                idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
     1837                                //If you use the following make sure it is uncommented in readConeFromFile
     1838                                //rDelete(gcTmp->baseRing);
    17841839                        }                       
    1785 // #ifdef gfan_DEBUG
     1840#ifdef gfan_DEBUG
    17861841//                      if(SearchListRoot!=NULL)
    17871842//                              gcTmp->showSLA(*SearchListRoot);
    1788 // #endif
     1843#endif
    17891844                        rChangeCurrRing(gcAct->baseRing);
    1790                         //rDelete(rTmp);
     1845                        rDelete(rTmp);
    17911846                        //doubly linked for easier removal
    17921847                        gcTmp->prev = gcPtr;
     
    19522007facet * gcone::enqueueNewFacets(facet *f)
    19532008{
     2009#ifdef gfanp
     2010        timeval start, end;
     2011        gettimeofday(&start, 0);
     2012#endif
    19542013        facet *slHead;
    19552014        slHead = f;
     
    21492208                        fAct = fAct->next;
    21502209                }
    2151         }//while(fAct!=NULL)                                           
     2210        }//while(fAct!=NULL)
     2211#ifdef gfanp
     2212        gettimeofday(&end, 0);
     2213        time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
     2214#endif                                         
    21522215        return slHead;
    21532216}//addC2N
     
    21722235               
    21732236/** \brief Construct a dd_MatrixPtr from a cone's list of facets
    2174  *
     2237 * NO LONGER USED
    21752238 */
    21762239inline dd_MatrixPtr gcone::facets2Matrix(const gcone &gc)
     
    22012264                fAct=fAct->next;                               
    22022265        }                       
    2203                        
    22042266        return M;
    22052267}
     
    23162378        ss << UCN;
    23172379        string UCNstr = ss.str();
    2318         string line;
    2319         string strGcBasisLength;
    2320         string strMonom, strCoeff, strCoeffNom, strCoeffDenom;         
     2380//      string line;
     2381//      string strGcBasisLength;
     2382//      string strMonom, strCoeff, strCoeffNom, strCoeffDenom;
    23212383        int gcBasisLength=0;
    23222384//      int intCoeff=1;
     
    23242386//      int intCoeffDenom=1;
    23252387       
    2326         bool hasCoeffInQ = FALSE;       //does the polynomial have rational coeff?
    2327         bool hasNegCoeff = FALSE;       //or a negative one?
     2388//      bool hasCoeffInQ = FALSE;       //does the polynomial have rational coeff?
     2389//      bool hasNegCoeff = FALSE;       //or a negative one?
    23282390        size_t found;                   //used for find_first_(not)_of
    23292391
     
    23402402        //Comment the following if you uncomment the if(line=="RING") part below
    23412403        rChangeCurrRing(gc->baseRing);
    2342 //      string::iterator EOL;
    2343 //      int terms=1;    //#Terms in the poly
    23442404       
    23452405        while( !gcInputFile.eof() )
    23462406        {
     2407                string line;
    23472408                getline(gcInputFile,line);
    2348                 hasCoeffInQ = FALSE;
    2349                 hasNegCoeff = FALSE;
     2409//              hasCoeffInQ = FALSE;
     2410//              hasNegCoeff = FALSE;
    23502411               
    23512412                if(line=="RING")
    2352                 {
    2353 //                      getline(gcInputFile,line);
    2354 //                      found = line.find("a(");
    2355 //                      line.erase(0,found+2);
    2356 //                      string strweight;
    2357 //                      strweight=line.substr(0,line.find_first_of(")"));
    2358 //                      intvec *iv=new intvec(this->numVars);
    2359 //                      for(int ii=0;ii<this->numVars;ii++)
    2360 //                      {
    2361 //                              string weight;
    2362 //                              weight=line.substr(0,line.find_first_of(",)"));                         
    2363 //                              (*iv)[ii]=atoi(weight.c_str());
    2364 //                              line.erase(0,line.find_first_of(",)")+1);
    2365 //                      }
    2366 //                      ring newRing;
    2367 //                      if(currRing->order[0]!=ringorder_a)
    2368 //                      {
    2369 //                              newRing=rCopyAndAddWeight(currRing,iv);
    2370 //                      }
    2371 //                      else
    2372 //                      {                       
    2373 //                              newRing=rCopy0(currRing);
    2374 //                              int length=this->numVars;
    2375 //                              int *A=(int *)omAlloc0(length*sizeof(int));
    2376 //                              for(int jj=0;jj<length;jj++)
    2377 //                              {
    2378 //                                      A[jj]=-(*iv)[jj];
    2379 //                              }
    2380 //                              omFree(newRing->wvhdl[0]);
    2381 //                              newRing->wvhdl[0]=(int*)A;
    2382 //                              newRing->block1[0]=length;
    2383 //                      }
    2384 //                      delete iv;
    2385 //                      rComplete(newRing);
    2386 //                      gc->baseRing=rCopy(newRing);
    2387 //                      if(currRing!=gc->baseRing)
    2388 //                              rChangeCurrRing(gc->baseRing);
     2413                {/*
     2414                        getline(gcInputFile,line);
     2415                        found = line.find("a(");
     2416                        line.erase(0,found+2);
     2417                        string strweight;
     2418                        strweight=line.substr(0,line.find_first_of(")"));
     2419                        intvec *iv=new intvec(this->numVars);
     2420                        for(int ii=0;ii<this->numVars;ii++)
     2421                        {
     2422                                string weight;
     2423                                weight=line.substr(0,line.find_first_of(",)"));                         
     2424                                (*iv)[ii]=atoi(weight.c_str());
     2425                                line.erase(0,line.find_first_of(",)")+1);
     2426                        }
     2427                        ring newRing;
     2428                        if(currRing->order[0]!=ringorder_a)
     2429                        {
     2430                                newRing=rCopyAndAddWeight(currRing,iv);
     2431                        }
     2432                        else
     2433                        {                       
     2434                                newRing=rCopy0(currRing);
     2435                                int length=this->numVars;
     2436                                int *A=(int *)omAlloc0(length*sizeof(int));
     2437                                for(int jj=0;jj<length;jj++)
     2438                                {
     2439                                        A[jj]=-(*iv)[jj];
     2440                                }
     2441                                omFree(newRing->wvhdl[0]);
     2442                                newRing->wvhdl[0]=(int*)A;
     2443                                newRing->block1[0]=length;
     2444                        }
     2445                        delete iv;
     2446                        rComplete(newRing);
     2447                        gc->baseRing=rCopy(newRing);
     2448                        if(currRing!=gc->baseRing)
     2449                                rChangeCurrRing(gc->baseRing);*/
    23892450                }
    23902451               
    23912452                if(line=="GCBASISLENGTH")
    23922453                {
     2454                        string strGcBasisLength;
    23932455                        getline(gcInputFile, line);
    23942456                        strGcBasisLength = line;
     
    23992461                if(line=="GCBASIS")
    24002462                {
    2401                         number nCoeff=nInit(1);
    2402                         number nCoeffNom=nInit(1);
    2403                         number nCoeffDenom=nInit(1);                   
    24042463                        for(int jj=0;jj<gcBasisLength;jj++)
    24052464                        {
     
    24082467                                //polys.cc:p_Read
    24092468                                //check until first occurance of + or -
    2410                                 //data or c_str
    2411                                 poly strPoly=pInit();
    2412                                 poly resPoly=pInit();   //The poly to be read in
     2469                                //data or c_str 
     2470                                poly strPoly=pInit();//Ought to be inside the while loop, but that will eat your memory
     2471                                poly resPoly=pInit();   //The poly to be read in                                                       
    24132472                                while(!line.empty())
    24142473                                {
    2415                                         hasNegCoeff = FALSE;
    2416                                         hasCoeffInQ = FALSE;
     2474//                                      poly strPoly=pInit();
     2475                                        number nCoeff=nInit(1);
     2476                                        number nCoeffNom=nInit(1);
     2477                                        number nCoeffDenom=nInit(1);
     2478                                        string strMonom, strCoeff, strCoeffNom, strCoeffDenom;
     2479                                        bool hasCoeffInQ = FALSE;       //does the polynomial have rational coeff?
     2480                                        bool hasNegCoeff = FALSE;       //or a negative one?
    24172481                                        found = line.find_first_of("+-");       //get the first monomial
    24182482                                        string tmp;
     
    24572521                                        const char* monom = strMonom.c_str();
    24582522                                               
    2459                                         p_Read(monom,strPoly,currRing);
     2523                                        p_Read(monom,strPoly,currRing); //strPoly:=monom                               
    24602524                                        switch (hasCoeffInQ)
    24612525                                        {
     
    24632527                                                        if(hasNegCoeff)
    24642528                                                                nCoeffNom=nNeg(nCoeffNom);
    2465 //                                                              intCoeffNom *= -1;
    2466 //                                                      pSetCoeff(strPoly, nDiv((number)intCoeffNom, (number)intCoeffDenom));
    24672529                                                        pSetCoeff(strPoly, nDiv(nCoeffNom, nCoeffDenom));
    24682530                                                        break;
    24692531                                                case FALSE:
    24702532                                                        if(hasNegCoeff)
    2471                                                                 nCoeff=nNeg(nCoeff);
    2472 //                                                              intCoeff *= -1;
     2533                                                                nCoeff=nNeg(nCoeff);                                                   
    24732534                                                        if(!nIsOne(nCoeff))
    24742535                                                        {
     
    24852546                                                resPoly=pCopy(strPoly);                                                 
    24862547                                        else
    2487                                                 resPoly=pAdd(resPoly,strPoly);                                 
     2548                                                resPoly=pAdd(resPoly,strPoly);
     2549                                        nDelete(&nCoeff);
     2550                                        nDelete(&nCoeffNom);
     2551                                        nDelete(&nCoeffDenom);
     2552//                                      pDelete(&strPoly);
    24882553                                }//while(!line.empty())                 
    24892554                                gc->gcBasis->m[jj]=pCopy(resPoly);
    24902555                                pDelete(&resPoly);      //reset
    2491 //                              pDelete(&strPoly);      //NOTE Crashes
    2492                         }
    2493                         nDelete(&nCoeff);
    2494                         nDelete(&nCoeffNom);
    2495                         nDelete(&nCoeffDenom);
     2556//                              pDelete(&strPoly);      //NOTE Crashes                         
     2557                        }
    24962558                        break;
    24972559                }//if(line=="GCBASIS")         
     
    25322594                * set to (poly)NULL in noRevS we need to get this back here.
    25332595                */
    2534                 if(gcAct->gcBasis->m[0]==(poly)NULL)
     2596//              if(gcAct->gcBasis->m[0]==(poly)NULL)
     2597                if(gfanHeuristic==1)
    25352598                        gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
    25362599//              ring saveRing=currRing;
     
    25772640{
    25782641        facet *fAct;
    2579         intvec *res=new intvec(this->numVars);
    2580         intvec *fNormal;
     2642        intvec *res;//=new intvec(this->numVars);       
    25812643//      int codim=n;
    25822644//      int bound;
     
    26022664        while(fAct!=NULL )//&& ii < bound )
    26032665        {
     2666                intvec *fNormal;
    26042667                fNormal = fAct->getFacetNormal();
    26052668                for(int jj=0;jj<this->numVars;jj++)
     
    26092672                }
    26102673                fAct = fAct->next;
    2611         }
    2612         delete fNormal;
     2674                delete fNormal;
     2675        }       
    26132676        return *res;
    26142677}
     
    26162679int gcone::counter=0;
    26172680int gfanHeuristic;
     2681#ifdef gfanp
     2682float gcone::time_getConeNormals;
     2683float gcone::time_getCodim2Normals;
     2684float gcone::time_flip;
     2685float gcone::time_enqueue;
     2686float gcone::time_computeInv;
     2687float gcone::t_ddMC;
     2688float gcone::t_mI;
     2689float gcone::t_iP;
     2690#endif
    26182691// ideal gfan(ideal inputIdeal, int h)
    26192692lists gfan(ideal inputIdeal, int h)
     
    26912764        //gcone::counter=0;
    26922765        /*Return result*/
     2766#ifdef gfanp
     2767        cout << "t_getConeNormals:" << gcone::time_getConeNormals << endl;
     2768        cout << "t_getCodim2Normals:" << gcone::time_getCodim2Normals << endl;
     2769        cout << "  t_ddMC:" << gcone::t_ddMC << endl;
     2770        cout << "  t_mI:" << gcone::t_mI << endl;
     2771        cout << "  t_iP:" << gcone::t_iP << endl;
     2772        cout << "t_Flip:" << gcone::time_flip << endl;
     2773        cout << "t_computeInv:" << gcone::time_computeInv << endl;
     2774        cout << "t_enqueue:" << gcone::time_enqueue << endl;
     2775#endif
    26932776        return lResList;
    26942777}
  • kernel/gfan.h

    r44b47d r42660f  
    2121#endif
    2222extern int gfanHeuristic;
     23#define gfanp
     24// #ifdef gfanp
     25// extern       static float time_getConeNormals;
     26// extern       static float time_getCodim2Normals;
     27// extern       static float time_flip;
     28// extern       static float time_enqueue;
     29// extern       static float time_computeInv;
     30// #endif
    2331//ideal getGB(ideal inputIdeal);
    2432// ideal gfan(ideal inputIdeal, int heuristic);
     
    105113                 */
    106114                inline void fDebugPrint();
    107                
    108115                friend class gcone;             
    109116};
     
    130137                /** \brief Pointer to the first facet */
    131138                facet *facetPtr;        //Will hold the adress of the first facet; set by gcone::getConeNormals
    132                
     139#ifdef gfanp
     140                static float time_getConeNormals;
     141                static float time_getCodim2Normals;
     142                static float time_flip;
     143                static float time_enqueue;             
     144                static float time_computeInv;
     145                static float t_ddMC;
     146                static float t_mI;
     147                static float t_iP;
     148#endif
     149
    133150                /** # of variables in the ring */
    134151                int numVars;            //#of variables in the ring
Note: See TracChangeset for help on using the changeset viewer.