Changeset 66e7b5 in git for kernel/f5gb.cc


Ignore:
Timestamp:
Jan 29, 2009, 6:59:30 PM (15 years ago)
Author:
Christian Eder
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
5d0556d9643aab314fbe86e3ef4cbcd69d864661
Parents:
5376a6afb7e0e9c5e8ba37a9e7964552e94edc3b
Message:
subalgorithms criticalPairs, criterion1 and criterion2 added


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

Legend:

Unmodified
Added
Removed
  • kernel/f5gb.cc

    r5376a6 r66e7b5  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5gb.cc,v 1.18 2009-01-28 17:20:49 Singular Exp $ */
     4/* $Id: f5gb.cc,v 1.19 2009-01-29 17:59:30 ederc Exp $ */
    55/*
    66* ABSTRACT: f5gb interface
     
    6767==================================================
    6868*/
    69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE) {
     69LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE, RList* rules, LTagList* lTag) {
    7070    gPrev->insert(ONE,i,f_i);
    71     CList* critPairs    =   criticalPair(gPrev);
    72      
     71    CList* critPairs    =   new CList();
     72    critPairs           =   criticalPair(gPrev, critPairs, rules, lTag);
     73   
    7374    return gPrev;
    7475}
     
    8283================================================================
    8384*/
    84 CList* criticalPair(LList* gPrev) {
    85     poly lcm   = pInit();
    86     number n    = nInit(2);
    87     nWrite(n);
    88     pWrite(lcm);
     85CList* criticalPair(LList* gPrev, CList* critPairs, RList* rules, LTagList* lTag) {
    8986    // initialization for usage in pLcm()
     87    number nOne         =   nInit(1);
    9088    LNode* first        =   gPrev->getFirst();
    9189    LNode* l            =   gPrev->getFirst()->getNext();
    92     poly t1, t2         =   pInit();
    93     t1                  =   pHead(*first->getPoly());
    94     poly u1             =   pOne();
    95     poly u2             =   pOne();
    96     CList*  critpairs   =   NULL;
     90    poly* u1            =   new poly(pInit());
     91    poly* u2            =   new poly(pInit());
     92    poly* lcm           =   new poly(pInit());
    9793    // computation of critical pairs
    9894    while( NULL != l) {
    9995        //pWrite( *(gPrev->getFirst()->getPoly()) );
    10096        //pWrite( *(l->getPoly()) );
    101         pLcm(*first->getPoly(), *l->getPoly(), t1);
    102         pWrite(t1);
    103         pWrite(u1);
    104         pWrite(u2);
    105         pSetCoeff0(lcm,n);
    106         poly p = lcm;
    107         pWrite(p);
    108         Print("%ld\n",pDeg(t1));
     97        pLcm(first->getPoly(), l->getPoly(), *lcm);
     98        pSetCoeff(*lcm,nOne);
    10999        // computing factors u1 & u2 for new labels
    110         u1  = pDivide(lcm, t1);
    111         pWrite(u1);
    112         pWrite(t1);
    113         Print("%ld\n",pDeg(t1));
    114         //pSetCoeff(u1,pGetCoeff(pOne()));
    115         pWrite(u1);
    116         t2  = pHead(*l->getPoly());
    117         pWrite(t2);
    118         // testing stuff
    119         u1 = ppMult_qq(t1,t2);
    120         pWrite(u1);
    121         pWrite(t2);
    122         Print("%ld\n",pDeg(u1));
    123         Print("%ld\n",pDeg(t2));
    124         u2  = pDivide(lcm, t2);
    125         pSetCoeff(u2, pGetCoeff(pOne()));
    126         pWrite(u2);
    127         Print("%ld\n",pDeg(u2));
     100        *u1 = pDivide(*lcm,pHead(first->getPoly()));
     101        pSetCoeff(*u1,nOne);
     102        *u2 = pDivide(*lcm, pHead(l->getPoly()));
     103        pSetCoeff(*u2,nOne);
     104        pWrite(*u2);
    128105        // testing both new labels by the F5 Criterion
    129         if(!criterion1(first, gPrev) &&
    130            !criterion1(l, gPrev)) {
    131             if(*first->getIndex() == *l->getIndex()) {
    132                 if(pMult(u1, *first->getTerm()) < pMult(u2, *l->getTerm())) {
    133                     //if(!critPairs) {
    134                         CPair* cp   =   new CPair(pDeg(lcm), u1, first->getLPoly(), u2,
    135                                         l->getLPoly());                   
    136                     //}
    137                 }
    138             }
    139         }
    140 
    141         Print("\n");
     106        if(!criterion1(u1, first, lTag) && !criterion1(u2, l, lTag) &&
     107           !criterion2(u1, first, rules) && !criterion2(u2, l, rules)) {
     108            Print("Criteria passed\n");
     109            // if they pass the test, add them to CList critPairs, having the LPoly with greater
     110            // label as first element in the CPair
     111            if(first->getIndex() == l->getIndex() &&
     112            pMult(*u1, first->getTerm()) < pMult(*u2, l->getTerm())) {
     113                CPair* cp   =   new CPair(pDeg(ppMult_qq(*u2,pHead(l->getPoly()))), *u2,
     114                                l->getLPoly(), *u1, first->getLPoly());                   
     115                    critPairs->insert(cp);
     116            }
     117            else {
     118                CPair* cp   =   new CPair(pDeg(ppMult_qq(*u2,pHead(l->getPoly()))), *u1,
     119                                first->getLPoly(), *u2, l->getLPoly());                   
     120                    critPairs->insert(cp);
     121            }
     122        }
     123        else {
     124            Print("Criteria not passed\n");
     125        }
     126       
     127        // for debugging
     128        if(NULL != critPairs) {
     129            critPairs->print();
     130        }
    142131        l   =   l->getNext();
    143132    }
    144     return NULL;
     133    Print("ENDE CRITPAIRS\n");
     134    return critPairs;
    145135}
    146136
     
    150140========================================
    151141*/
    152 bool criterion1(LNode* l, LList* gPrev) {
    153     LNode* testNode =   l->getNext();
     142bool criterion1(poly* t, LNode* l, LTagList* lTag) {
     143    // start at the previously added element to gPrev, as all other elements will have the same index for sure
     144    LNode* testNode =   lTag->get(l->getIndex());
     145    // save the monom t1*label_term(l) as it is tested various times in the following
     146    poly u1 = ppMult_qq(*t,l->getTerm());
    154147    while(NULL != testNode) {
    155         while(*testNode->getIndex() == *l->getIndex()) {
     148        //while(NULL != testNode && testNode->getIndex() == l->getIndex()) {
     149        //    testNode = testNode->getNext();
     150        //}
     151        Print("%d\n", pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1));
     152        if(NULL != testNode && pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1)) {
     153            return true;
     154        }
     155        testNode    =   testNode->getNext();
     156       
     157    }
     158    // 25/01/2009: TO DO -> change return value, until now no element is added to CList!
     159    return false;
     160}
     161
     162/*
     163=====================================
     164Criterion 2, i.e. Rewritten Criterion
     165=====================================
     166*/
     167bool criterion2(poly* t, LNode* l, RList* rules) {
     168    // start at the previously added element to gPrev, as all other elements will have the same index for sure
     169    RNode* testNode =   rules->getFirst();
     170    while(NULL != testNode->getRule()) {
     171        while(NULL != testNode->getRule() && testNode->getRuleIndex() == l->getIndex()) {
    156172            testNode = testNode->getNext();
    157173        }
    158     }
     174        if(NULL != testNode->getRule() &&
     175           pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) {
     176            return true;
     177        }
     178        testNode    =   testNode->getNext();
    159179       
    160 
    161     return true;
    162 }
     180    }
     181    // 25/01/2009: TO DO -> change return value, until now no element is added to CList!
     182   
     183    return false;
     184}
     185
    163186
    164187/*
    165188==========================================================================
    166 MAIN:computes a gb of the ideal i in the ring r with our f5 implementation
     189MAIN:computes a gb of the ideal i in the ring r with our F5 implementation
    167190==========================================================================
    168191*/
     
    170193    int i,j;
    171194    // 1 polynomial for defining initial labels & further tests
    172     static poly ONE = pOne();
     195    poly ONE = pOne();
     196    // list of rules
     197    RList* rules    =   new RList();
    173198    i = 1;
    174     LList* gPrev = new LList( &ONE, &i, &id->m[0]);
     199    LList* gPrev    =   new LList( &ONE, &i, &id->m[0]);
     200    LTagList* lTag  =   new LTagList(gPrev->getFirst());
    175201    poly* lcm = new poly;
    176202    // initialization for usage in pLcm()
     
    205231    pWrite(q);
    206232    for(i=2; i<=IDELEMS(id); i++) {
    207         gPrev   =   F5inc( &i, &id->m[i-1], gPrev, &ONE );
     233        gPrev   =   F5inc(&i, &id->m[i-1], gPrev, &ONE, rules, lTag);
     234        lTag->insert(gPrev->getFirst());
     235        Print("JA\n");
    208236    }
    209237    // only for debugging
Note: See TracChangeset for help on using the changeset viewer.