Changeset 2e10a0 in git


Ignore:
Timestamp:
Jan 23, 2014, 5:03:31 PM (10 years ago)
Author:
Adi Popescu <adi_popescum@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
c274a029c85d80fc1e67a20a94756f2afdcefd08
Parents:
fd1101c51f85808be5f4f270758360b46a425a4f
Message:
added a new alg from Roune to compute the Hilbert Series. Still a lot to do
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/hilb.cc

    rfd1101 r2e10a0  
    2222#include<gmp.h>
    2323#include<vector>
     24//TIMER
     25#include<time.h>
    2426
    2527
     
    3133static mpz_t ec;
    3234static mpz_ptr hilbertcoef = (mpz_ptr)omAlloc(NNN*sizeof(mpz_t));
    33 std::vector<int> hilbertpowers;
    34 std::vector<int> hilbertpowerssorted;
    35    
     35static std::vector<int> hilbertpowers;
     36static std::vector<int> hilbertpowerssorted;
     37static std::vector<int> degsort;
     38static std::vector<int> eulerprop;
     39static ideal eulersimp;
     40static int steps, prune = 0, moreprune = 0, eulerstep, eulerskips=0;
     41   
    3642
    3743static int hMinModulweight(intvec *modulweight)
     
    228234// ---------------------------------- ADICHANGES ---------------------------------------------
    229235//!!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
     236
     237//idQuot(I,p) for I monomial ideal, p a ideal with a single monomial.
     238ideal idQuotMon(ideal I, ideal p)
     239{
     240    #if 0
     241    if(idIs0(I))
     242    {
     243        return(I);
     244    }
     245    if(idIs0(p))
     246    {
     247        ideal res = idInit(1,1);
     248        res->m[0] = pOne();
     249        return(res);
     250    }
     251    ideal res = idInit(IDELEMS(I),1);
     252    int i,j;
     253    bool flag;
     254    int dummy;
     255    for(i = 0; i<IDELEMS(I); i++)
     256    {
     257        res->m[i] = p_Copy(I->m[i], currRing);
     258        flag = TRUE;
     259        for(j = 1; (j<=currRing->N) && (flag); j++)
     260        {
     261            dummy = p_GetExp(p->m[0], j, currRing);
     262            if(dummy > 0)
     263            {
     264                if(p_GetExp(I->m[i], j, currRing) < dummy)
     265                {
     266                    flag = FALSE;
     267                }
     268                else
     269                {
     270                    p_SetExp(res->m[i], j, p_GetExp(I->m[i], j, currRing) - dummy, currRing);
     271                }
     272            }
     273        }
     274        if(!flag)
     275        {
     276            res->m[i] = NULL;
     277        }
     278        else
     279        {
     280            p_Setm(res->m[i], currRing);
     281        }
     282    }
     283    idSkipZeroes(res);
     284    if(idIs0(res))
     285    {
     286        for(i = 0; i< IDELEMS(I); i++)
     287        {
     288            res->m[i] = p_Copy(I->m[i], currRing);
     289        }
     290    }
     291    printf("\n      ------ idQuotMon\n");
     292    idPrint(I);
     293    idPrint(p);
     294    idPrint(res);getchar();
     295    return(res);
     296    #else
     297    ideal res;
     298    res = idQuot(I,p,TRUE,TRUE);
     299    //printf("\n      ------ idQuotMon\n");
     300    //idPrint(I);
     301    //idPrint(p);
     302    //idPrint(res);getchar();
     303    return(res);
     304    #endif
     305}
     306
     307//puts in hilbertpowerssorted the two new entries and shifts if needed the old ones
    230308static void PutInVector(int degvalue, int oldposition, int where)
    231309{
     
    240318}
    241319
     320//sorts hilbertpowers (new finds the positions)
    242321static void SortPowerVec()
    243322{
     
    245324    int test;
    246325    bool flag;
     326    //printf("Size of hilbertpowers: %i", hilbertpowers.size());
    247327    hilbertpowerssorted.resize(2);
    248328    hilbertpowerssorted[0] = hilbertpowers[0];
     
    272352            }
    273353        }
    274         //printf("\n----------------TEST----------------\n");
    275         //for(test=0;test<hilbertpowerssorted.size();test++)
    276         //    {
    277         //        printf(" %d ", hilbertpowerssorted[test]);
    278         //    }   
    279        
    280     }
    281 }
    282 
    283 static int DegMon(poly p, ring tailRing)
     354    }
     355}
     356
     357//returns the degree of the monomial
     358static int DegMon(poly p)
    284359{
    285360    int i,deg;
    286361    deg = 0;
    287     for(i=1;i<=tailRing->N;i++)
    288     {
    289         deg = deg + p_GetExp(p, i, tailRing);
     362    for(i=1;i<=currRing->N;i++)
     363    {
     364        deg = deg + p_GetExp(p, i, currRing);
    290365    }
    291366    return(deg);
    292367}
    293368
    294 static poly SearchP(ideal I, ring tailRing)
    295 {
    296     int i,j,exp;
    297     poly res;
    298     for(i=IDELEMS(I)-1;i>=0;i--)
    299     {
    300         if(DegMon(I->m[i], tailRing)>=2)
    301         {
    302             res = p_ISet(1, tailRing);
    303             res = p_Copy(I->m[i], tailRing);
    304             for(j=1;j<=tailRing->N;j++)
    305             {
    306                 exp = p_GetExp(I->m[i], j, tailRing);
    307                 if(exp > 0)
     369//divides all monomials by the last entry
     370static ideal idSimplify(ideal I)
     371{
     372    int i,j;
     373    bool flag;
     374    #if 0
     375    for(i=IDELEMS(I)-2;i>=0;i--)
     376    {
     377        flag=TRUE;
     378        for(j=1;(j<=currRing->N)&&(flag);j++)
     379        {
     380            if(p_GetExp(I->m[i], j, currRing) < p_GetExp(I->m[IDELEMS(I)-1], j, currRing))
     381            {
     382                flag=FALSE;
     383            }
     384        }
     385        if(flag)
     386        {
     387            I->m[i]=NULL;
     388        }
     389    }
     390    #else
     391    for(i=IDELEMS(I)-2;i>=0;i--)
     392    {
     393        if(p_DivisibleBy(I->m[IDELEMS(I)-1], I->m[i], currRing))
     394        {
     395            I->m[i] = NULL;
     396        }
     397    }
     398    #endif
     399    idSkipZeroes(I);
     400    return(I);
     401}
     402
     403//Puts in sorted vector the degrees of generators of I
     404static void PutIn(int degvalue, int oldposition, int where)
     405{
     406    int i;
     407    for(i=degsort.size()-1;i>=where+2;i--)
     408    {
     409        degsort[i] = degsort[i-2];
     410    }
     411    degsort[where] = degvalue;
     412    degsort[where+1] = oldposition;
     413}
     414
     415//it sorts the ideal by the degrees
     416static ideal SortByDeg(ideal I)
     417{
     418    //idPrint(I);
     419    clock_t t;
     420    t=clock();
     421    if(idIs0(I))
     422    {
     423        return(I);
     424    }
     425    ideal res = idInit(IDELEMS(I),1);
     426    std::vector<int> deg;
     427    deg.resize(IDELEMS(I));
     428    int i,j;
     429    bool flag;
     430    for(i=0;i<IDELEMS(I);i++)
     431    {
     432        deg[i] = DegMon(I->m[i]);
     433    }
     434    degsort.resize(2);
     435    degsort[0] = deg[0];
     436    degsort[1] = 0;
     437    for(i=1;i<IDELEMS(I);i++)
     438    {
     439        degsort.resize(degsort.size()+2);
     440        flag=TRUE;
     441        if(deg[i]<=degsort[0])
     442        {
     443            flag=FALSE;
     444            PutIn(deg[i], i, 0);
     445        }
     446        if((deg[i]>=degsort[degsort.size()-2]) && (flag == TRUE))
     447        {
     448            flag=FALSE;
     449            PutIn(deg[i], i, degsort.size()-2);
     450        }
     451        if(flag==TRUE)
     452        {
     453            for(j=2;(j<=degsort.size()-4)&&(flag);j=j+2)
     454            {
     455                if(deg[i]<=degsort[j])
    308456                {
    309                     p_SetExp(res, j, exp - 1, tailRing);
    310                     return(res);
     457                    flag=FALSE;
     458                    PutIn(deg[i], i, j);
    311459                }
    312460            }
    313461        }
    314462    }
    315     return(NULL);
    316 }
    317 
    318 static poly ChoosePVar (ideal I, ring tailRing)
    319 {
     463    //for(i = 0;i<degsort.size();i++)
     464    //{printf(" %i",degsort[i]);}printf("\n");printf("I has %i el",IDELEMS(I));getchar();
     465    for(i=0;i<IDELEMS(I);i++)
     466    {
     467        res->m[i] = pCopy(I->m[degsort[2*i+1]]);
     468    }
     469    //idPrint(res);
     470    degsort.clear();
     471    degsort.resize(0);
     472    /*if(((float)(clock()-t)/CLOCKS_PER_SEC)!=0)
     473    {
     474        printf("\nSortDeg took %f\n",(float)(clock()-t)/CLOCKS_PER_SEC);
     475    }*/
     476    return(res);
     477}
     478
     479//id_Add for monomials (hoping it is faster)
     480static ideal idAddMon(ideal I, ideal p)
     481{
     482    //printf("\nI and p\n");idPrint(I);pWrite(p->m[0]);
     483    #if 1
     484    idInsertPoly(I,p->m[0]);
     485    #else
     486    I = id_Add(I,p,currRing);
     487    #endif
     488    idSkipZeroes(I);
     489    I = idSimplify(I);
     490    //printf("\nBLA in idAddMon\n");idPrint(I);
     491    I = SortByDeg(I);
     492    return(I);
     493}
     494
     495#if 0
     496//Constructs a list of the simplices (for which we have to compute the Euler Characteristic)
     497static void eulerSimpAdd(ideal newsimp)
     498{
     499    if(idIs0(newsimp))
     500    {
     501        return;
     502    }
     503    ideal P;
     504    int i;
     505    bool flag;
     506    P = idInit(1,1);
     507    for(i=0;i<IDELEMS(newsimp);i++)
     508    {
     509        P->m[0] = pAdd(P->m[0], pCopy(newsimp->m[i]));
     510    }
     511    poly p = pCopy(P->m[0]);
     512    //idPrint(eulersimp);
     513    //idPrint(newsimp);
     514    //idPrint(P);
     515    int terms = 0, deg = 0, howmanyvars = 0;
     516    terms = IDELEMS(newsimp);
     517    deg = DegMon(newsimp->m[0]);
     518    flag=TRUE;
     519    for(i=1;(i<IDELEMS(newsimp))&&(flag==TRUE);i++)
     520    {
     521       
     522        if(deg != DegMon(newsimp->m[i]))
     523        {
     524            //The ideal is not homogenous
     525            flag=FALSE;
     526        }
     527    }
     528    if(!flag)
     529    {
     530        deg = 0;
     531    }
     532    int* e;
     533    howmanyvars = pGetVariables(p, e);
     534    flag = FALSE;
     535    int thisone;
     536    //idPrint(eulersimp);
     537    if(idIs0(eulersimp))
     538    {
     539        eulersimp = idAddMon(eulersimp, P);
     540        eulerprop.resize(eulerprop.size()+3);
     541        eulerprop[eulerprop.size()-3] = terms ;
     542        eulerprop[eulerprop.size()-2] = deg ;
     543        eulerprop[eulerprop.size()-1] = howmanyvars ;
     544        return;
     545    }
     546    //for(i=0;i<IDELEMS(eulersimp);i++)
     547    //{
     548    //    printf("\n%i %i %i\n",eulerprop[3*i],eulerprop[3*i+1],eulerprop[3*i+2]);
     549    //}
     550    i=0;
     551   
     552    for(i = 0; (i<IDELEMS(eulersimp)) && (!flag);i++)
     553    {
     554        if((eulerprop[3*i] == terms) && (eulerprop[3*i+1] == deg) && (eulerprop[3*i+2] == howmanyvars))
     555        {
     556            //  !!!!!!!!!!!!!!!!!!!have to do it!!!!!!!!!!!!!!!!!!!!!!!!!!
     557            //if(TestIfIsSame(p, eulersimp->m[i]))
     558            {
     559                flag = TRUE;
     560                thisone = i;
     561                //It is the the same simplex, and hence we already know it's euler characteristic
     562            }
     563        }
     564    }
     565    if(!flag)
     566    {
     567        eulersimp = idAddMon(eulersimp, P);
     568        eulerprop.resize(eulerprop.size()+3);
     569        eulerprop[eulerprop.size()-3] = terms ;
     570        eulerprop[eulerprop.size()-2] = deg ;
     571        eulerprop[eulerprop.size()-1] = howmanyvars ;
     572    }
     573    if(flag)
     574    {
     575        eulerskips++;
     576        hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
     577        mpz_init(&hilbertcoef[NNN]);
     578        mpz_set(&hilbertcoef[NNN], &hilbertcoef[thisone]);
     579        hilbertpowers.resize(NNN+1);
     580        NNN++;
     581    }
     582    return;
     583}
     584#endif
     585
     586//searches for a variable that is not yet used (assumes that the ideal is sqrfree)
     587static poly ChoosePVar (ideal I)
     588{
     589    idPrint(I);
     590    printf("\nThere is a variable which is not yet used... ChangePVar\n");getchar();
    320591    bool flag=TRUE;
    321592    int i,j;
    322593    poly res;
    323     for(i=1;i<=tailRing->N;i++)
     594    for(i=1;i<=currRing->N;i++)
    324595    {
    325596        flag=TRUE;
    326597        for(j=IDELEMS(I)-1;(j>=0)&&(flag);j--)
    327598        {
    328             if(p_GetExp(I->m[j], i, tailRing)>0)
     599            if(p_GetExp(I->m[j], i, currRing)>0)
    329600            {
    330601                flag=FALSE;
     
    334605        if(flag == TRUE)
    335606        {
    336             res = p_ISet(1, tailRing);
    337             p_SetExp(res, i, 1, tailRing);
    338             //idPrint(I);
    339             //pWrite(res);
     607            res = p_ISet(1, currRing);
     608            p_SetExp(res, i, 1, currRing);
     609            p_Setm(res,currRing);
    340610            return(res);
    341611        }
     612        else
     613        {
     614            p_Delete(&res, currRing);
     615        }
    342616    }
    343617    return(NULL); //i.e. it is the maximal ideal
    344618}
    345619
    346 static ideal idSimplify(ideal I, ring tailRing)
    347 {
    348     int i,j;
    349     bool flag;
    350     /*std::vector<int>  var;
    351     for(i=1;i<=tailRing->N;i++)
    352     {
    353         if(p_GetExp(I->[IDELEMS(I)-1], tailRing)>0)
    354         {
    355             var.resize(var.size()+1);
    356             var[var.size()-1] = i;
    357         }
    358     }
    359     */
    360     for(i=IDELEMS(I)-2;i>=0;i--)
    361     {
    362         flag=TRUE;
    363         for(j=1;(j<=tailRing->N)&&(flag);j++)
    364         {
    365             if(p_GetExp(I->m[i], j, tailRing) < p_GetExp(I->m[IDELEMS(I)-1], j, tailRing))
    366             {
    367                 flag=FALSE;
     620//choice XL: last entry divided by x (xy10z15 -> y9z14)
     621static poly ChoosePXL(ideal I)
     622{
     623    int i,j,dummy=0;
     624    poly m;
     625    for(i = IDELEMS(I)-1; (i>=0) && (dummy == 0); i--)
     626    {
     627        for(j = 1; (j<=currRing->N) && (dummy == 0); j++)
     628        {
     629            if(p_GetExp(I->m[i],j, currRing)>1)
     630            {
     631                dummy = 1;
    368632            }
    369633        }
    370         if(flag)
    371         {
    372             I->m[i]=NULL;
    373         }
    374     }
    375     idSkipZeroes(I);
    376     return(I);
    377 }
    378 
    379 
    380 /*static void eulerchar (ideal I, ring tailRing)
    381 {
    382     //gmp_printf("\nEuler char: %Zd\n", ec);
    383     mpz_t dummy;
    384     if( idElem(I) == 0)
    385     {
    386         mpz_init(dummy);
    387         mpz_set_si(dummy, 1);
    388         mpz_sub(ec, ec, dummy);
    389         return;
    390     }
    391     if( idElem(I) == 1)
    392     {
    393         if(!p_IsOne(I->m[0], tailRing))
    394         {
    395             return;
     634    }
     635    m = p_Copy(I->m[i+1],currRing);
     636    for(j = 1; j<=currRing->N; j++)
     637    {
     638        dummy = p_GetExp(m,j,currRing);
     639        if(dummy >= 1)
     640        {
     641            p_SetExp(m, j, dummy-1, currRing);
     642        }
     643    }
     644    if(!p_IsOne(m, currRing))
     645    {
     646        p_Setm(m, currRing);
     647        return(m);
     648    }
     649    m = ChoosePVar(I);
     650    return(m);
     651}
     652
     653//choice XF: first entry divided by x (xy10z15 -> y9z14)
     654static poly ChoosePXF(ideal I)
     655{
     656    int i,j,dummy=0;
     657    poly m;
     658    for(i =0 ; (i<=IDELEMS(I)-1) && (dummy == 0); i++)
     659    {
     660        for(j = 1; (j<=currRing->N) && (dummy == 0); j++)
     661        {
     662            if(p_GetExp(I->m[i],j, currRing)>1)
     663            {
     664                dummy = 1;
     665            }
     666        }
     667    }
     668    m = p_Copy(I->m[i-1],currRing);
     669    for(j = 1; j<=currRing->N; j++)
     670    {
     671        dummy = p_GetExp(m,j,currRing);
     672        if(dummy >= 1)
     673        {
     674            p_SetExp(m, j, dummy-1, currRing);
     675        }
     676    }
     677    if(!p_IsOne(m, currRing))
     678    {
     679        p_Setm(m, currRing);
     680        return(m);
     681    }
     682    m = ChoosePVar(I);
     683    return(m);
     684}
     685
     686//choice OL: last entry the first power (xy10z15 -> xy9z15)
     687static poly ChoosePOL(ideal I)
     688{
     689    int i,j,dummy;
     690    poly m;
     691    for(i = IDELEMS(I)-1;i>=0;i--)
     692    {
     693        m = p_Copy(I->m[i],currRing);
     694        for(j=1;j<=currRing->N;j++)
     695        {
     696            dummy = p_GetExp(m,j,currRing);
     697            if(dummy > 0)
     698            {
     699                p_SetExp(m,j,dummy-1,currRing);
     700                p_Setm(m,currRing);
     701            }       
     702        }
     703        if(!p_IsOne(m, currRing))
     704        {
     705            return(m);
    396706        }
    397707        else
    398708        {
    399             mpz_init(dummy);
    400             mpz_set_si(dummy, 1);
    401             mpz_sub(ec, ec, dummy);
    402             return;
    403         }
    404     }
    405     ideal p = idInit(1,1);
    406     p->m[0] = SearchP(I, tailRing);
     709            p_Delete(&m,currRing);
     710        }
     711    }
     712    m = ChoosePVar(I);
     713    return(m);
     714}
     715
     716//choice OF: first entry the first power (xy10z15 -> xy9z15)
     717static poly ChoosePOF(ideal I)
     718{
     719    int i,j,dummy;
     720    poly m;
     721    for(i = 0 ;i<=IDELEMS(I)-1;i++)
     722    {
     723        m = p_Copy(I->m[i],currRing);
     724        for(j=1;j<=currRing->N;j++)
     725        {
     726            dummy = p_GetExp(m,j,currRing);
     727            if(dummy > 0)
     728            {
     729                p_SetExp(m,j,dummy-1,currRing);
     730                p_Setm(m,currRing);
     731            }       
     732        }
     733        if(!p_IsOne(m, currRing))
     734        {
     735            return(m);
     736        }
     737        else
     738        {
     739            p_Delete(&m,currRing);
     740        }
     741    }
     742    m = ChoosePVar(I);
     743    return(m);
     744}
     745
     746//choice VL: last entry the first variable with power (xy10z15 -> y)
     747static poly ChoosePVL(ideal I)
     748{
     749    int i,j,dummy;
     750    bool flag = TRUE;
     751    poly m = p_ISet(1,currRing);
     752    for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
     753    {
     754        flag = TRUE;
     755        for(j=1;(j<=currRing->N) && (flag);j++)
     756        {
     757            dummy = p_GetExp(I->m[i],j,currRing);
     758            if(dummy >= 2)
     759            {
     760                p_SetExp(m,j,1,currRing);
     761                p_Setm(m,currRing);
     762                flag = FALSE;
     763            }       
     764        }
     765        if(!p_IsOne(m, currRing))
     766        {
     767            return(m);
     768        }
     769    }
     770    m = ChoosePVar(I);
     771    return(m);
     772}
     773
     774//choice VF: first entry the first variable with power (xy10z15 -> y)
     775static poly ChoosePVF(ideal I)
     776{
     777    int i,j,dummy;
     778    bool flag = TRUE;
     779    poly m = p_ISet(1,currRing);
     780    for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
     781    {
     782        flag = TRUE;
     783        for(j=1;(j<=currRing->N) && (flag);j++)
     784        {
     785            dummy = p_GetExp(I->m[i],j,currRing);
     786            if(dummy >= 2)
     787            {
     788                p_SetExp(m,j,1,currRing);
     789                p_Setm(m,currRing);
     790                flag = FALSE;
     791            }       
     792        }
     793        if(!p_IsOne(m, currRing))
     794        {
     795            return(m);
     796        }
     797    }
     798    m = ChoosePVar(I);
     799    return(m);
     800}
     801
     802//choice JL: last entry just variable with power (xy10z15 -> y10)
     803static poly ChoosePJL(ideal I)
     804{
     805    int i,j,dummy;
     806    bool flag = TRUE;
     807    poly m = p_ISet(1,currRing);
     808    for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
     809    {
     810        flag = TRUE;
     811        for(j=1;(j<=currRing->N) && (flag);j++)
     812        {
     813            dummy = p_GetExp(I->m[i],j,currRing);
     814            if(dummy >= 2)
     815            {
     816                p_SetExp(m,j,dummy-1,currRing);
     817                p_Setm(m,currRing);
     818                flag = FALSE;
     819            }       
     820        }
     821        if(!p_IsOne(m, currRing))
     822        {
     823            return(m);
     824        }
     825    }
     826    m = ChoosePVar(I);
     827    return(m);
     828}
     829
     830//choice JF: last entry just variable with power -1 (xy10z15 -> y9)
     831static poly ChoosePJF(ideal I)
     832{
     833    int i,j,dummy;
     834    bool flag = TRUE;
     835    poly m = p_ISet(1,currRing);
     836    for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
     837    {
     838        flag = TRUE;
     839        for(j=1;(j<=currRing->N) && (flag);j++)
     840        {
     841            dummy = p_GetExp(I->m[i],j,currRing);
     842            if(dummy >= 2)
     843            {
     844                p_SetExp(m,j,dummy-1,currRing);
     845                p_Setm(m,currRing);
     846                flag = FALSE;
     847            }       
     848        }
     849        if(!p_IsOne(m, currRing))
     850        {
     851            return(m);
     852        }
     853    }
     854    m = ChoosePVar(I);
     855    return(m);
     856}
     857
     858//chooses 1 \neq p \not\in S. This choice should be made optimal
     859static poly ChooseP(ideal I)
     860{
    407861    //idPrint(I);
    408     //printf("\nSearchP founded: \n");pWrite(p->m[0]);
    409     if(p->m[0] == NULL)
    410     {
    411         mpz_init(dummy);
    412         mpz_set_si(dummy, IDELEMS(I)-1);
    413         mpz_add(ec, ec, dummy);
    414         return;
    415     }
    416     ideal Ip = idQuot(I,p,TRUE,TRUE);
    417     ideal Iplusp = id_Add(I,p,tailRing);
    418     Iplusp=idSimplify(Iplusp, tailRing);
    419     eulerchar(Ip, tailRing);
    420     eulerchar(Iplusp, tailRing);
    421     return;
    422 }*/
    423 
    424 static bool JustVar(ideal I, ring tailRing)
    425 {
     862    poly m;
     863    //  TEST TO SEE WHICH ONE IS BETTER
     864    //m = ChoosePXL(I);
     865    //m = ChoosePXF(I);
     866    //m = ChoosePOL(I);
     867    //m = ChoosePOF(I);
     868    //m = ChoosePVL(I);
     869    //m = ChoosePVF(I);
     870    //m = ChoosePJL(I);
     871    m = ChoosePJF(I);
     872    //printf("\nMy choice was \n");pWrite(m);getchar();
     873    return(m);
     874}
     875
     876//searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)
     877static poly SearchP(ideal I)
     878{
     879    int i,j,exp;
     880    poly res;
     881    if(DegMon(I->m[IDELEMS(I)-1])<=1)
     882    {
     883        res = ChoosePVar(I);
     884        return(res);
     885    }
     886    i = IDELEMS(I)-1;
     887    res = p_Copy(I->m[i], currRing);
     888    for(j=1;j<=currRing->N;j++)
     889    {
     890        exp = p_GetExp(I->m[i], j, currRing);
     891        if(exp > 0)
     892        {
     893            p_SetExp(res, j, exp - 1, currRing);
     894            p_Setm(res,currRing);
     895            return(res);
     896        }
     897    }
     898}
     899
     900//test if the ideal is of the form (x1, ..., xr)
     901static bool JustVar(ideal I)
     902{
     903    #if 0
    426904    int i,j;
    427905    bool foundone;
     
    429907    {
    430908        foundone = FALSE;
    431         for(j = 1;j<=tailRing->N;j++)
    432         {
    433             if(p_GetExp(I->m[i], j, tailRing)>0)
     909        for(j = 1;j<=currRing->N;j++)
     910        {
     911            if(p_GetExp(I->m[i], j, currRing)>0)
    434912            {
    435913                if(foundone == TRUE)
     
    442920    }
    443921    return(TRUE);
    444 }
    445 
    446 static void eulerchar (ideal I, ring tailRing, int variables)
    447 {
    448     //gmp_printf("\nEuler char: %Zd\n", ec);
     922    #else
     923    if(DegMon(I->m[IDELEMS(I)-1])>1)
     924    {
     925        return(FALSE);
     926    }
     927    return(TRUE);
     928    #endif
     929}
     930
     931//computes the Euler Characteristic of the ideal
     932static void eulerchar (ideal I, int variables)
     933{
     934  loop
     935  {
     936    //idPrint(I);printf("%i", variables);
     937    eulerstep++;
    449938    mpz_t dummy;
    450     if(JustVar(I, tailRing) == TRUE)
     939    if(JustVar(I) == TRUE)
    451940    {
    452941        if(IDELEMS(I) == variables)
     
    459948            mpz_add(ec, ec, dummy);
    460949        }
     950        //mpz_clear(dummy);
    461951        return;       
    462952    }
    463953    ideal p = idInit(1,1);
    464     p->m[0] = SearchP(I, tailRing);
    465     //idPrint(I);
    466     //printf("\nSearchP founded: \n");pWrite(p->m[0]);
    467     ideal Ip = idQuot(I,p,TRUE,TRUE);
    468     ideal Iplusp = id_Add(I,p,tailRing);
    469     Iplusp=idSimplify(Iplusp, tailRing);
     954    p->m[0] = SearchP(I);
     955    //pWrite(p->m[0]);
     956    ideal Ip = idQuotMon(I,p);
     957    Ip = SortByDeg(Ip);
    470958    int i,howmanyvarinp = 0;
    471     for(i = 1;i<=tailRing->N;i++)
    472     {
    473         if(p_GetExp(p->m[0],i,tailRing)>0)
     959    for(i = 1;i<=currRing->N;i++)
     960    {
     961        if(p_GetExp(p->m[0],i,currRing)>0)
    474962        {
    475963            howmanyvarinp++;
    476964        }
    477965    }   
    478     eulerchar(Ip, tailRing, variables-howmanyvarinp);
    479     eulerchar(Iplusp, tailRing, variables);
    480     return;
    481 }
    482 
    483 static poly SqFree (ideal I, ring tailRing)
     966    eulerchar(Ip, variables-howmanyvarinp);
     967    id_Delete(&Ip, currRing);
     968    //ideal Iplusp = idAddMon(I,p);
     969    //eulerchar(Iplusp, variables);
     970    //id_Delete(&Iplusp, currRing);
     971    //return;
     972    I = idAddMon(I,p);
     973  }
     974}
     975
     976//tests if an ideal is Square Free, if no, returns the variable which appears at powers >1
     977static poly SqFree (ideal I)
    484978{
    485979    int i,j;
    486980    bool flag=TRUE;
    487981    poly notsqrfree = NULL;
     982    if(DegMon(I->m[IDELEMS(I)-1])<=1)
     983    {
     984        return(notsqrfree);
     985    }
    488986    for(i=IDELEMS(I)-1;(i>=0)&&(flag);i--)
    489987    {
    490         for(j=1;(j<=tailRing->N)&&(flag);j++)
    491         {
    492             if(p_GetExp(I->m[i],j,tailRing)>1)
     988        for(j=1;(j<=currRing->N)&&(flag);j++)
     989        {
     990            if(p_GetExp(I->m[i],j,currRing)>1)
    493991            {
    494992                flag=FALSE;
    495                 notsqrfree = p_ISet(1,tailRing);
    496                 p_SetExp(notsqrfree,j,1,tailRing);
     993                notsqrfree = p_ISet(1,currRing);
     994                p_SetExp(notsqrfree,j,1,currRing);
    497995            }
    498996        }
    499997    }
     998    if(notsqrfree != NULL)
     999    {
     1000        p_Setm(notsqrfree,currRing);
     1001    }
    5001002    return(notsqrfree);
    5011003}
    5021004
    503 static void rouneslice(ideal I, ideal S, poly q, ring tailRing, poly x)
    504 {
     1005//checks if a polynomial is in I
     1006static bool IsIn(poly p, ideal I)
     1007{
     1008    //assumes that I is ordered by degree
     1009    if(idIs0(I))
     1010    {
     1011        if(p==poly(0))
     1012        {
     1013            return(TRUE);
     1014        }
     1015        else
     1016        {
     1017            return(FALSE);
     1018        }
     1019    }
     1020    if(p==poly(0))
     1021    {
     1022        return(FALSE);
     1023    }
     1024    //if(DegMon(p)<DegMon(I->m[IDELEMS(I)-1]))
     1025    //{
     1026    //    return(FALSE);
     1027    //}
     1028    #if 0
     1029    if(p == NULL)
     1030    {
     1031        if(IDELEMS(I) == 0)
     1032        {
     1033            return(TRUE);
     1034        }
     1035        if(IDELEMS(I) == 1)
     1036        {
     1037            if(I->m[0] == poly(0))
     1038            {
     1039                return(TRUE);
     1040            }
     1041        }
     1042        return(FALSE);
     1043    }
     1044    if(IDELEMS(I)==0)
     1045    {
     1046        return(FALSE);
     1047    }
     1048    if(IDELEMS(I) == 1)
     1049    {
     1050        if(I->m[0] == poly(0))
     1051            {
     1052                return(FALSE);
     1053            }   
     1054    }
     1055    #endif
     1056    int i,j;
     1057    bool flag;
     1058    for(i = 0;i<IDELEMS(I);i++)
     1059    {
     1060        flag = TRUE;
     1061        for(j = 1;(j<=currRing->N) &&(flag);j++)
     1062        {
     1063            if(p_GetExp(p, j, currRing)<p_GetExp(I->m[i], j, currRing))
     1064            {
     1065                flag = FALSE;
     1066            }
     1067        }
     1068        if(flag)
     1069        {
     1070            return(TRUE);
     1071        }
     1072    }
     1073    return(FALSE);
     1074}
     1075
     1076//computes the lcm of min I, I monomial ideal
     1077static poly LCMmon(ideal I)
     1078{
     1079    if(idIs0(I))
     1080    {
     1081        return(NULL);
     1082    }
     1083    poly m;
     1084    int dummy,i,j;
     1085    m = p_ISet(1,currRing);
     1086    for(i=1;i<=currRing->N;i++)
     1087    {
     1088        dummy=0;
     1089        for(j=IDELEMS(I)-1;j>=0;j--)
     1090        {
     1091            if(p_GetExp(I->m[j],i,currRing) > dummy)
     1092            {
     1093                dummy = p_GetExp(I->m[j],i,currRing);
     1094            }
     1095        }
     1096        p_SetExp(m,i,dummy,currRing);
     1097    }
     1098    p_Setm(m,currRing);
     1099    return(m);
     1100}
     1101
     1102#if 0
     1103//return TRUE if a | b, a, b monomials
     1104static bool Divides(poly a, poly b)
     1105{
     1106    if(a == NULL)
     1107    {
     1108        return(FALSE);
     1109    }
     1110    if(b == NULL)
     1111    {
     1112        return(TRUE);
     1113    }
     1114    int i;
     1115    for(i=1;i<=currRing->N;i++)
     1116    {
     1117        if(p_GetExp(a,i,currRing) > p_GetExp(b,i,currRing))
     1118        {
     1119            return(FALSE);
     1120        }
     1121    }
     1122    return(TRUE);
     1123}
     1124#endif
     1125
     1126//the Roune Slice Algorithm
     1127void rouneslice(ideal I, ideal S, poly q, poly x)
     1128{
     1129  loop
     1130  {
     1131    steps++;
    5051132    int i,j;
    5061133    int dummy;
    5071134    mpz_t dummympz;
    5081135    poly m;
     1136    clock_t t;
     1137    t=clock();
    5091138    ideal p, koszsimp;
    510     I = idMinBase(I);
     1139    //----------- PRUNING OF S ---------------
     1140    //S SHOULD IN THIS POINT BE ORDERED BY DEGREE
     1141    for(i=IDELEMS(S)-1;i>=0;i--)
     1142    {
     1143        if(IsIn(S->m[i],I))
     1144        {
     1145            //idPrint(I);idPrint(S);getchar();
     1146            S->m[i]=NULL;
     1147            prune++;
     1148        }
     1149    }
     1150    idSkipZeroes(S);
     1151    /*if(((float)(clock()-t)/CLOCKS_PER_SEC)!=0)
     1152    {
     1153        printf("\nPruning S took %f\n",(float)(clock()-t)/CLOCKS_PER_SEC);
     1154        //idPrint(I);idPrint(S);getchar();
     1155    }*/
     1156    //----------------------------------------
     1157    t = clock();
     1158    for(i=IDELEMS(I)-1;i>=0;i--)
     1159    {
     1160        m = p_Copy(I->m[i],currRing);
     1161        for(j=1;j<=currRing->N;j++)
     1162        {
     1163            dummy = p_GetExp(m,j,currRing);
     1164            if(dummy > 0)
     1165            {
     1166                p_SetExp(m,j,dummy-1,currRing);
     1167            }       
     1168        }
     1169        p_Setm(m, currRing);
     1170        //printf("\n Check if m is in S: %i\n", IsIn(m,S));pWrite(m);idPrint(S);
     1171        if(IsIn(m,S))
     1172        {
     1173            //printf("\nIt was deleted: \n");pWrite(I->m[i]);
     1174            I->m[i]=NULL;
     1175            //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
     1176        }
     1177    }
     1178    idSkipZeroes(I);
     1179    /*if(((float)(clock()-t)/CLOCKS_PER_SEC)!=0)
     1180    {
     1181        printf("\nConstructing I' took %f\n",(float)(clock()-t)/CLOCKS_PER_SEC);
     1182    }*/
     1183    //----------- MORE PRUNING OF S ------------
     1184    t = clock();
     1185    m = LCMmon(I);
     1186    if(m != NULL)
     1187    {
     1188        for(i=0;i<IDELEMS(S);i++)
     1189        {     
     1190            if(!(p_DivisibleBy(S->m[i], m, currRing))) 
     1191            {
     1192                S->m[i] = NULL;
     1193                j++;
     1194                moreprune++;
     1195            }
     1196            else
     1197            {
     1198                if(pLmEqual(S->m[i],m))
     1199                {
     1200                    S->m[i] = NULL;
     1201                    moreprune++;
     1202                }
     1203            }
     1204        }
     1205    idSkipZeroes(S);
     1206    }
     1207    /*if(((float)(clock()-t)/CLOCKS_PER_SEC)!=0)
     1208    {
     1209        printf("\nMore Pruning S took %f\n",(float)(clock()-t)/CLOCKS_PER_SEC);
     1210    }*/
     1211    //------------------------------------------
     1212    I = SortByDeg(I);
     1213    //printf("\n---------------------------\n");
     1214    //printf("\n      I\n");idPrint(I);
     1215    //printf("\n      S\n");idPrint(S);
     1216    //printf("\n      q\n");pWrite(q);
     1217    //getchar();
    5111218   
    512     //Work on it
    513     //----------- PRUNING OF S ---------------
    514     S = idMinBase(S);
    515     for(i=IDELEMS(S)-1;i>=0;i--)
    516     {
    517         if(kNF(I,NULL,S->m[i],NULL,NULL)==NULL)
    518         {
    519             S->m[i]=NULL;
    520         }
    521     }
    522     idSkipZeroes(S);
    523     //----------------------------------------
    524     for(i=IDELEMS(I)-1;i>=0;i--)
    525     {
    526         m = p_Copy(I->m[i],tailRing);
    527         for(j=1;j<=tailRing->N;j++)
    528         {
    529             dummy = p_GetExp(m,j,tailRing);
    530             if(dummy > 0)
    531             {
    532                 p_SetExp(m,j,dummy-1,tailRing);
    533             }       
    534         }
    535         if(kNF(S,NULL,m,NULL,NULL)==NULL)
    536         {
    537             I->m[i]=NULL;
    538             //printf("\n Check if m is in S: \n");pWrite(m);idPrint(S);
    539             //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
    540         }
    541     }
    542     idSkipZeroes(I);
    543    
    544     //----------- MORE PRUNING OF S ------------
    545     //strictly divide???   
    546     //------------------------------------------
    547 
    548     //printf("Ideal I: \n");idPrint(I);
    549     //printf("Ideal S: \n");idPrint(S);
    550     //printf("Poly  q: \n");pWrite(q);
    551     if(idElem(I)==0)
    552     {
    553         //I = 0
    554         //printf("\nx does not divide lcm(I)");
    555         //pWrite(x);pWrite(m);idPrint(I);
    556         printf("\nEmpty Set: ");pWrite(q);
    557         return;
    558     }
    559     m = p_ISet(1,tailRing);
    560     for(i=1;i<=tailRing->N;i++)
    561     {
    562         dummy=0;
    563         for(j=IDELEMS(I)-1;j>=0;j--)
    564         {
    565             if(p_GetExp(I->m[j],i,tailRing) > dummy)
    566             {
    567                 dummy = p_GetExp(I->m[j],i,tailRing);
    568             }
    569         }
    570         p_SetExp(m,i,dummy,tailRing);
    571     }
    572     p_Setm(m,tailRing);
    573     if(p_DivisibleBy(x,m,tailRing)==FALSE)
     1219    if(idIs0(I))
     1220    {
     1221        /*if(!pIsConstantPoly(q))
     1222        {
     1223            mpz_init(dummympz);
     1224            mpz_set_si(dummympz, -1);
     1225            hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
     1226            mpz_init(&hilbertcoef[NNN]);
     1227            mpz_set(&hilbertcoef[NNN], dummympz);
     1228            hilbertpowers.resize(NNN+1);
     1229            hilbertpowers[NNN] = DegMon(q);
     1230            NNN++;
     1231            pWrite(q);
     1232            //printf("\nOld ERROR\n");getchar();
     1233        }*/
     1234        id_Delete(&I, currRing);
     1235        id_Delete(&S, currRing);
     1236        p_Delete(&m, currRing);
     1237        break;
     1238        //return;
     1239    }
     1240    S = SortByDeg(S);
     1241    m = LCMmon(I);
     1242    if(!p_DivisibleBy(x,m, currRing))
    5741243    {
    5751244        //printf("\nx does not divide lcm(I)");
    5761245        //pWrite(x);pWrite(m);idPrint(I);
    5771246        //printf("\nEmpty set");pWrite(q);
    578         return;
    579     }
    580     m = SqFree(I, tailRing);
     1247        //idPrint(S);pWrite(q);
     1248        //getchar();
     1249        id_Delete(&I, currRing);
     1250        id_Delete(&S, currRing);
     1251        p_Delete(&m, currRing);
     1252        //return;
     1253        break;
     1254    }
     1255    m = SqFree(I);
    5811256    koszsimp = idInit(IDELEMS(I),1);
    5821257    if(m==NULL)
    5831258    {
    584         printf("\n      Corner: ");
    585         pWrite(q);
    586         printf("\n      With the facets of the simplex:\n");
     1259        //printf("\n      Corner: ");
     1260        //pWrite(q);
     1261        //printf("\n      With the facets of the dual simplex:\n");
    5871262        for(i=IDELEMS(I)-1;i>=0;i--)
    5881263        {
    589             m = p_ISet(1,tailRing);
    590             //m = p_Divide(x,I->m[i],tailRing);
    591             //      THIS IS FOR THE OTHER IDEA FOR COMPUTING THE EULER CHARACTERISTIC!!!! INSTEAD
    592             m = I->m[i];
    593             /*for(j=tailRing->N; j>=1; j--)
    594             {
    595                 p_SetExp(m,j, p_GetExp(x,j,tailRing)- p_GetExp(I->m[i],j,tailRing),tailRing);
     1264            koszsimp->m[i] = I->m[i];
     1265            //pWrite(koszsimp->m[i]);
     1266            /*for(j = 1;j<=currRing->N;j++)
     1267            {
     1268                if(p_GetExp(koszsimp->m[i],j,currRing)!=0)
     1269                {
     1270                    p_SetExp(koszsimp->m[i],j,0,currRing);
     1271                }
     1272                else
     1273                {
     1274                    p_SetExp(koszsimp->m[i],j,1,currRing);
     1275                }
    5961276            }*/
    597            
    598             printf("    ");
    599             p_Setm(m, tailRing);
    600             p_Write(m, tailRing);
    601             koszsimp->m[i] = p_Copy(m, tailRing);
    602         }
    603         printf("\n Euler Characteristic = ");
     1277            //pWrite(koszsimp->m[i]);
     1278        }
     1279        //idPrint(koszsimp);
     1280        //getchar();
     1281        //printf("\n Euler Characteristic = ");
    6041282        mpz_init(dummympz);
    605         eulerchar(koszsimp, tailRing, tailRing->N);
     1283        t = clock();
     1284        eulerstep=0;
     1285        //idPrint(koszsimp);
     1286        //getchar();
     1287        eulerchar(koszsimp, currRing->N);
     1288        if(((float)(clock()-t)/CLOCKS_PER_SEC)!=0)
     1289        {
     1290            //printf("\nEulerChar took %f \n",(float)(clock()-t)/CLOCKS_PER_SEC);
     1291            //idPrint(koszsimp);getchar();
     1292        }
     1293        //printf("\nEulerChar tooked %i steps\n", eulerstep);
    6061294        //gmp_printf("dummy %Zd \n", dummympz);
    607         gmp_printf("ec %Zd \n", ec);
     1295        //gmp_printf("ec %Zd \n", ec);
     1296        //getchar();
     1297        //if(DegMon(q)==7) {getchar();}
    6081298        mpz_set(dummympz, ec);
    6091299        mpz_sub(ec, ec, ec);
     
    6111301        mpz_init(&hilbertcoef[NNN]);
    6121302        mpz_set(&hilbertcoef[NNN], dummympz);
     1303        mpz_clear(dummympz);
    6131304        hilbertpowers.resize(NNN+1);
    614         hilbertpowers[NNN] = DegMon(q, tailRing);
     1305        hilbertpowers[NNN] = DegMon(q);
    6151306        NNN++;
    616         return;
    617     }
     1307        break;
     1308        //return;
     1309    }
     1310    #if 0
    6181311    if(IDELEMS(S)!=1)
    6191312    {
    620         m = SearchP(S, tailRing);
     1313        m = SearchP(S);
    6211314        if(m == NULL)
    6221315        {
    623             m = ChoosePVar(S, tailRing);
    624         }
    625     }
     1316            m = ChoosePVar(S);
     1317        }
     1318    }
     1319    #else
     1320    m = ChooseP(I);
     1321    #endif
    6261322    p = idInit(1,1);
    6271323    p->m[0] = m;
    628     printf("Poly  p: \n");pWrite(m);
    629     ideal Ip = idQuot(I,p,TRUE,TRUE);
    630     ideal Sp = idQuot(S,p,TRUE,TRUE);
    631     ideal Splusp = id_Add(S,p,tailRing);
    632     Splusp = idSimplify(Splusp, tailRing);
    633     poly pq = pp_Mult_mm(q,m,tailRing);
    634     rouneslice(Ip, Sp, pq, tailRing, x);
    635     rouneslice(I, Splusp, q, tailRing, x);
    636     return;
    637 }
    638 
    639 static void slicehilb(ideal I, ring tailRing)
    640 {
     1324    //idPrint(I);idPrint(p);
     1325    //idTest(I);idTest(p);
     1326    ideal Ip = idQuotMon(I,p);
     1327    Ip = SortByDeg(Ip);
     1328    ideal Sp = idQuotMon(S,p);
     1329    Sp = SortByDeg(Sp);
     1330    //printf("\np, q = \n");pWrite(m);pWrite(q);
     1331    poly pq = pp_Mult_mm(q,m,currRing);
     1332    rouneslice(Ip, Sp, pq, x);
     1333    //idPrint(Ip);
     1334    //id_Delete(&Ip, currRing);
     1335    //id_Delete(&Sp, currRing);
     1336    S = idAddMon(S,p);
     1337    //p->m[0]=NULL; id_Delete(&p, currRing); // p->m[0] was also in S
     1338    p_Delete(&pq,currRing);
     1339    //Splusp = idSimplify(Splusp);
     1340  //  rouneslice(I, S, q, x);  tail-recursion solved via loop
     1341
     1342    //id_Delete(&Splusp, currRing);
     1343    //return;
     1344  }
     1345}
     1346
     1347
     1348//it computes the first hilbert series by means of Roune Slice Algorithm
     1349void slicehilb(ideal I)
     1350{
     1351    I = SortByDeg(I);
    6411352    printf("Adi changes are here: \n");
    6421353    int i;
    643     ideal S = idInit(0,1);
    644     poly q = p_ISet(1,tailRing);
     1354    eulersimp = idInit(1,1);
     1355    ideal S = idInit(1,1);
     1356    poly q = p_ISet(1,currRing);
    6451357    ideal X = idInit(1,1);
    646     X->m[0]=p_One(tailRing);
    647     for(i=1;i<=tailRing->N;i++)
    648     {
    649             p_SetExp(X->m[0],i,1,tailRing);   
    650     }
    651     p_Setm(X->m[0],tailRing);
    652     I = id_Mult(I,X,tailRing);
     1358    X->m[0]=p_One(currRing);
     1359    for(i=1;i<=currRing->N;i++)
     1360    {
     1361            p_SetExp(X->m[0],i,1,currRing);   
     1362    }
     1363    p_Setm(X->m[0],currRing);
     1364    I = id_Mult(I,X,currRing);
    6531365    printf("\n-------------RouneSlice--------------\n");
    654     rouneslice(I,S,q,tailRing,X->m[0]);
    655     for(i=0;i<NNN;i++)
     1366    steps=0;
     1367    rouneslice(I,S,q,X->m[0]);
     1368    printf("\nIn total Prune got rid of %i elements\n",prune);
     1369    printf("\nIn total More Prune got rid of %i elements\n",moreprune);
     1370    //printf("\nWe skipped computing the EulerChar for %i simplices\n",eulerskips);
     1371    printf("\nSteps of rouneslice: %i\n\n", steps);
     1372    /*for(i=0;i<NNN;i++)
    6561373    {
    6571374        gmp_printf(" %Zd ", &hilbertcoef[i]);
     
    6611378    {
    6621379        printf(" %d ", hilbertpowers[i]);
    663     }
    664     SortPowerVec(); 
    665     printf("\n");
     1380    }*/
     1381    SortPowerVec();
     1382    /*printf("\n");
    6661383    for(i=0;i<hilbertpowerssorted.size();i++)
    6671384    {
    6681385        printf(" %d ", hilbertpowerssorted[i]);
    669     }
     1386    }*/
    6701387    mpz_t coefhilb;
    6711388    mpz_t dummy;
    6721389    mpz_init(coefhilb);
    6731390    mpz_init(dummy);
    674     printf("\n//        1 t^0");
     1391    printf("\n//  %8d t^0",1);
    6751392    for(i=0;i<hilbertpowerssorted.size();i=i+2)
    6761393    {
     
    6841401        if(mpz_sgn(coefhilb)!=0)
    6851402        {
    686             gmp_printf("\n//        %Zd t^%d",coefhilb,hilbertpowerssorted[i]);
     1403            gmp_printf("\n//  %8Zd t^%d",coefhilb,hilbertpowerssorted[i]);
    6871404        }
    6881405        mpz_sub(coefhilb, coefhilb, coefhilb);
     
    6961413                int /*notstc*/, intvec *wdegree, ideal Q, ring tailRing)
    6971414{
    698   slicehilb(S,tailRing); // ADICHANGES
    6991415  intvec *work, *hseries1=NULL;
    7001416  int  mc;
     
    9311647void hLookSeries(ideal S, intvec *modulweight, ideal Q)
    9321648{
     1649  clock_t t;    // ADICHANGES
     1650  t = clock(); // ADICHANGES
    9331651  int co, mu, l;
    9341652  intvec *hseries2;
    9351653  intvec *hseries1 = hFirstSeries(S, modulweight, Q);
    9361654  hPrintHilb(hseries1);
     1655  printf("\nTime for Original: %f\n",((float)(clock()-t))/CLOCKS_PER_SEC); getchar(); // ADICHANGES
     1656  #if 0
    9371657  l = hseries1->length()-1;
    9381658  if (l > 1)
     
    9501670    delete hseries1;
    9511671  delete hseries2;
    952 }
    953 
    954 
    955 
     1672  #endif
     1673  clock_t now;    // ADICHANGES
     1674  now = clock(); // ADICHANGES
     1675  slicehilb(S); // ADICHANGES
     1676  printf("\nTime for Slice Algorithm: %f \n\n", ((float)(clock()-now))/CLOCKS_PER_SEC);    // ADICHANGES
     1677 
     1678}
     1679
     1680
     1681
  • kernel/kutil.cc

    rfd1101 r2e10a0  
    396396      if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return ; // does not divide
    397397      #ifdef HAVE_RINGS
    398       ///should check also if the lc is a zero divisor, if it divides all the others
     398      // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
     399      //       domains), no zerodivisor test needed  CAUTION
    399400      if (rField_is_Ring(currRing) && currRing->OrdSgn == -1)
    400401        if(n_DivBy(p_GetCoeff(h,r->cf),lc,r->cf) == 0)
Note: See TracChangeset for help on using the changeset viewer.