Changeset 9bb97e in git


Ignore:
Timestamp:
Feb 6, 2009, 9:12:35 PM (14 years ago)
Author:
Christian Eder
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
fcb80223d452f79f3b3e1a62b71d291a5fc64943
Parents:
b3e45f80f34104e744829011d4460dcee8e1e365
Message:
implementation of computeSPols, start of reduction and topReduction


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

Legend:

Unmodified
Added
Removed
  • kernel/f5data.cc

    rb3e45f r9bb97e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5data.cc,v 1.2 2009-02-03 20:55:43 ederc Exp $ */
     4/* $Id: f5data.cc,v 1.3 2009-02-06 20:12:35 ederc Exp $ */
    55/*
    66* ABSTRACT: lpolynomial definition
     
    3030================================================================
    3131*/
    32 LPoly::LPoly(poly* t,int* i,poly* p) {
    33     set(t,i,p);
     32LPoly::LPoly(poly t,int i,poly p,bool d) {
     33    set(t,i,p,d);
    3434}
    3535
    36 void LPoly::setPoly(poly* p)  {
    37     polynomial = *p;
     36void LPoly::setPoly(poly p)  {
     37    polynomial = p;
    3838}
    3939
    40 void LPoly::setTerm(poly* t) {
    41     term = *t;
     40void LPoly::setTerm(poly t) {
     41    term = t;
    4242}
    4343
    44 void LPoly::setIndex(int* i) {
    45     index = *i;
     44void LPoly::setIndex(int i) {
     45    index = i;
    4646}
    4747
     
    6666}
    6767
    68 void LPoly::set(poly* t, int* i, poly* p) {
     68void LPoly::set(poly t, int i, poly p, bool d) {
    6969    this->setTerm(t);
    7070    this->setIndex(i);
    7171    this->setPoly(p);
     72    this->setDel(d);
    7273}
    7374
     
    9899}
    99100
     101poly* CPair::getAdT1() {
     102    return &t1;
     103}
     104
     105poly* CPair::getAdT2() {
     106    return &t2;
     107}
     108
    100109poly CPair::getT2() {
    101110    return t2;
     111}
     112
     113LPoly* CPair::getAdLp1() {
     114    return lp1;
     115}
     116
     117LPoly* CPair::getAdLp2() {
     118    return lp2;
    102119}
    103120
     
    135152===================================
    136153*/
    137 Rule::Rule(int* i, poly* t) {
     154Rule::Rule(int i, poly t, LPoly* l) {
    138155    index   =   i;
    139156    term    =   t;
     157    origin  =   l;
    140158}
    141159
    142160int Rule::getIndex() {
    143     return *index;
     161    return index;
    144162}
    145163
    146164poly Rule::getTerm() {
    147     return *term;
     165    return term;
    148166}
    149167
  • kernel/f5data.h

    rb3e45f r9bb97e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5data.h,v 1.2 2009-02-03 20:55:43 ederc Exp $ */
     4/* $Id: f5data.h,v 1.3 2009-02-06 20:12:35 ederc Exp $ */
    55/*
    66* ABSTRACT: labeled polynomial interface
     
    3333        bool    del; //for deletion in TopReduction Subalgorithm
    3434    public:
    35                 LPoly(poly*t,int* i,poly* p);
    36         void    setPoly(poly* p);
     35                LPoly(poly t, int i, poly p, bool d = false);
     36        void    setPoly(poly p);
    3737        poly    getPoly();
    38         void    setTerm(poly* t);
     38        void    setTerm(poly t);
    3939        poly    getTerm();
    40         void    setIndex(int* i);
     40        void    setIndex(int i);
    4141        int     getIndex();
    4242        void    setDel(bool b);
    4343        bool    getDel() const;
    44         void    set(poly* t, int* i, poly* p);
     44        void    set(poly t, int i, poly p, bool d);
    4545        LPoly*  get();
    4646};
     
    6363        long    getDeg();
    6464        poly    getT1();
     65        poly*   getAdT1();
     66        LPoly*  getAdLp1();
    6567        poly    getLp1Poly();
    6668        poly    getLp1Term();
    6769        int     getLp1Index();
    6870        poly    getT2();
     71        poly*   getAdT2();
     72        LPoly*  getAdLp2();
    6973        poly    getLp2Poly();
    7074        poly    getLp2Term();
     
    8185class Rule {
    8286    private:
    83         int*    index;      // index of the labeled polynomial the rule comes from
    84         poly*   term;       // term of the labeled polynomial the rule comes from
     87        int     index;      // index of the labeled polynomial the rule comes from
     88        poly    term;       // term of the labeled polynomial the rule comes from
    8589        LPoly*  origin;     // pointer of the LPoly which generated this rule (needed in criterion2())
    8690    public:
    87                 Rule(int* i, poly* term);
     91                Rule(int i, poly term, LPoly* l);
    8892        int     getIndex();
    8993        poly    getTerm();
  • kernel/f5gb.cc

    rb3e45f r9bb97e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5gb.cc,v 1.22 2009-02-04 19:27:11 ederc Exp $ */
     4/* $Id: f5gb.cc,v 1.23 2009-02-06 20:12:35 ederc Exp $ */
    55/*
    66* ABSTRACT: f5gb interface
     
    2626
    2727
     28
    2829/*
    2930====================================================================
     
    6162
    6263
     64
    6365/*
    6466==================================================
     
    6769==================================================
    6870*/
    69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE) {
     71LList* F5inc(int i, poly f_i, LList* gPrev, ideal gbPrev, poly ONE, int* reductionsToZero) {
     72    int j;
    7073    // tag the first element of index i-1 for criterion 1
    7174    LTagList* lTag  =   new LTagList(gPrev->getFirst());
     
    7376    RTagList* rTag  =   new RTagList();
    7477    gPrev->insert(ONE,i,f_i);
    75     CList* critPairs    =   new CList();
    76     critPairs           =   criticalPair(gPrev, critPairs, lTag, rTag);
    77    
     78    Print("1st gPrev: ");
     79    pWrite(gPrev->getFirst()->getPoly());
     80    Print("2nd gPrev: ");
     81    pWrite(gPrev->getFirst()->getNext()->getPoly());   
     82    CList* critPairs        =   new CList();
     83    RList* rules            =   new RList();
     84    CNode* critPairsMinDeg  =   new CNode();   
     85    LNode* sPolys           =   new LNode();
     86    // computation of critical pairs with checking of criterion 1 and criterion 2
     87    critPairs               =   criticalPair(gPrev, critPairs, lTag, rTag);
     88    LList* sPolyList        =   new LList();
     89    // labeled polynomials which have passed reduction() and have to be added to list gPrev
     90    LList* completed        =   new LList();
     91    // the reduced labeled polynomials which are returned from subalgorithm reduction()
     92    LNode* reducedLPolys     =   new LNode();
     93    // while there are critical pairs to be further checked and deleted/computed
     94    while(NULL != critPairs->getFirst()->getData()) {
     95        // critPairs->getMinDeg() deletes the first elements of minimal degree from
     96        // critPairs, thus the while loop is not infinite.
     97        critPairsMinDeg =   critPairs->getMinDeg();
     98        // adds all to be reduced S-polynomials in the list sPolyList and adds
     99        // the corresponding rules to the list rules
     100        // NOTE: inside there is a second check of criterion 2 if new rules are
     101        // added
     102        computeSPols(critPairsMinDeg,rTag,rules,sPolyList,reductionsToZero);
     103         
     104        reducedLPolys   =   reduction(sPolyList, completed, gbPrev, reductionsToZero);
     105    }
    78106    return gPrev;
    79107}
     108
    80109
    81110
     
    91120    number nOne         =   nInit(1);
    92121    LNode* first        =   gPrev->getFirst();
    93     LNode* l            =   gPrev->getFirst()->getNext();
     122    LNode* l            =   first->getNext();
    94123    poly* u1            =   new poly(pInit());
    95124    poly* u2            =   new poly(pInit());
     
    110139        if(!criterion1(u1, first, lTag) && !criterion1(u2, l, lTag) &&
    111140           !criterion2(u1, first, rTag) && !criterion2(u2, l, rTag)) {
    112             Print("Criteria passed\n");
    113141            // if they pass the test, add them to CList critPairs, having the LPoly with greater
    114142            // label as first element in the CPair
     
    126154        }
    127155        else {
    128             Print("Criteria not passed\n");
    129156        }
    130157       
     
    135162        l   =   l->getNext();
    136163    }
    137     Print("ENDE CRITPAIRS\n");
    138164    return critPairs;
    139165}
     166
     167
    140168
    141169/*
     
    151179    while(NULL != testNode) {
    152180        if(pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1)) {
     181            Print("Criterion 1 NOT passed!\n");
    153182            return true;
    154183        }
     
    157186    return false;
    158187}
     188
     189
    159190
    160191/*
     
    169200    poly u1 = ppMult_qq(*t,l->getTerm());
    170201    // first element added to rTag was NULL, check for this
    171     Print("Hier1\n");
    172202    while(NULL != testNode && testNode->getRule()->getOrigin() != l->getLPoly()) {
    173         Print("Hier2\n");
    174203        if(pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) {
     204            Print("Criterion 2 NOT passed!\n");
    175205            return true;
    176206        }
     
    180210}
    181211
    182 /*
    183 ==========================================================================================================
    184 Criterion 2, i.e. Rewritten Criterion, for its second call in sPols(), with added lastRuleTested parameter
    185 ==========================================================================================================
    186 */
    187 bool criterion2(poly* t, LNode* l, RTagList* rTag, Rule* lastRuleTested) {
     212
     213
     214/*
     215=================================================================================================================
     216Criterion 2, i.e. Rewritten Criterion, for its second call in computeSPols(), with added lastRuleTested parameter
     217=================================================================================================================
     218*/
     219bool criterion2(poly* t, LPoly* l, RTagList* rTag, Rule* lastRuleTested) {
    188220    // start at the previously added element to gPrev, as all other elements will have the same index for sure
    189221    RNode* testNode =   rTag->getFirst();
     
    191223    poly u1 = ppMult_qq(*t,l->getTerm());
    192224    // first element added to rTag was NULL, check for this
    193     Print("Hier1\n");
    194     while(NULL != testNode && testNode->getRule()->getOrigin() != l->getLPoly()) {
    195         Print("Hier2\n");
     225    while(NULL != testNode && testNode->getRule() != lastRuleTested) {
    196226        if(pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) {
     227            Print("Criterion 2 NOT passed!\n");
    197228            return true;
    198229        }
     
    201232    return false;
    202233}
     234
     235
     236
     237/*
     238==================================
     239Computation of S-Polynomials in F5
     240==================================
     241*/
     242void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, int* reductionsToZero) {
     243    CNode* temp =   first;
     244    poly zero   =   pInit();
     245    while(NULL != temp->getData()) {
     246        // only if a new rule was added since the last test in subalgorithm criticalPair()
     247        if(rules->getFirst() != rTag->getFirst()) {
     248            Print("IN SPOLS => NEW RULES AVAILABLE\n");
     249            if(!criterion2(temp->getAdT1(),temp->getAdLp1(),rTag,temp->getLastRuleTested())) {
     250                // the second component is tested only when it has the actual index, otherwise there is
     251                // no new rule to test since the last test in subalgorithm criticalPair()
     252                if(temp->getLp2Index() == temp->getLp1Index()) {
     253                    if(!criterion2(temp->getAdT2(),temp->getAdLp2(),rTag,temp->getLastRuleTested())) {
     254                        // computation of S-polynomial
     255                        poly sp =   pInit();
     256                        sp      =   pSub(ppMult_qq(temp->getT1(),temp->getLp1Poly()),
     257                                         ppMult_qq(temp->getT2(),temp->getLp2Poly()));
     258                        Print("BEGIN SPOLY\n====================\n");
     259                        pWrite(sp);
     260                        Print("END SPOLY\n====================\n");
     261                        if(!pCmp(sp,zero)) {
     262                            // as rules consist only of pointers we need to save the labeled
     263                            // S-polynomial also of a zero S-polynomial
     264                            //zeroList->insert(temp->getAdT1(),temp->getLp1Index(),&sp);
     265                            // origin of rule can be set NULL as the labeled polynomial
     266                            // will never be used again as it is zero => no problems with
     267                            // further criterion2() tests and termination conditions
     268                            *reductionsToZero++;
     269                            rules->insert(temp->getLp1Index(),temp->getT1(),NULL);
     270                        }
     271                        else {
     272                            sPolyList->insert(temp->getT1(),temp->getLp1Index(),sp);
     273                            rules->insert(temp->getLp1Index(),temp->getT1(),sPolyList->getFirst()->getLPoly());
     274                        }
     275                        // data is saved in sPolyList or zero => delete sp
     276                        pDelete(&sp);
     277                    }
     278                }
     279                else { // temp->getLp2Index() < temp->getLp1Index()
     280                    // computation of S-polynomial
     281                    poly sp =   pInit();
     282                    sp      =   pSub(ppMult_qq(temp->getT1(),temp->getLp1Poly()),
     283                                     ppMult_qq(temp->getT2(),temp->getLp2Poly()));
     284                    Print("BEGIN SPOLY\n====================\n");
     285                    pWrite(sp);
     286                    Print("END SPOLY\n====================\n");
     287                    if(!pCmp(sp,zero)) {
     288                        // zeroList->insert(temp->getAdT1(),temp->getLp1Index(),&sp);
     289                        // origin of rule can be set NULL as the labeled polynomial
     290                        // will never be used again as it is zero => no problems with
     291                        // further criterion2() tests and termination conditions
     292                        *reductionsToZero++;
     293                        rules->insert(temp->getLp1Index(),temp->getT1(),NULL);
     294                    }
     295                    else {
     296                        sPolyList->insert(temp->getT1(),temp->getLp1Index(),sp);
     297                        rules->insert(temp->getLp1Index(),temp->getT1(),sPolyList->getFirst()->getLPoly());
     298                    }
     299                    // data is saved in sPolyList or zero => delete sp
     300                    pDelete(&sp);
     301                }
     302            }
     303        }
     304        temp    =   temp->getNext();
     305    }
     306    // these critical pairs can be deleted now as they are either useless for further computations or
     307    // already saved as an S-polynomial to be reduced in the following
     308    delete first;   
     309}
     310
     311
     312
     313/*
     314========================================================================
     315reduction including subalgorithm topReduction() using Faugere's criteria
     316========================================================================
     317*/
     318LNode* reduction(LList* sPolyList, LList* completed, ideal gbPrev, int* reductionsToZero) {
     319    poly zero   =   pInit();
     320    // compute only if there are any S-polynomials to be reduced
     321    if(NULL != sPolyList->getFirst()->getLPoly()) {
     322        LNode* temp =   sPolyList->getFirst();
     323        while(NULL != temp->getLPoly()) {
     324            temp->setPoly(kNF(gbPrev,currQuotient,temp->getPoly()));
     325            Print("Nach NORMAL FORM: ");
     326            pWrite(temp->getPoly());
     327            // test if temp->getPoly() is zero polynomial
     328            if(!pCmp(temp->getPoly(),zero)) {
     329                *reductionsToZero++;
     330                // TODO: sPolyList -> delete first element of list as it is zero and done
     331            }
     332            //completed   =   topReduction();
     333            // in topReduction() the investigated first element of sPolyList will be deleted after its
     334            // reduction has finished => the next to be investigated element is the newly first element
     335            // in sPolyList => the while loop is finite
     336            // first possible after implementation of topReduction(): temp = sPolyList->getFirst();
     337            temp    =   temp->getNext();
     338        }
     339    }
     340    return NULL;
     341}   
     342
     343
     344
     345/*
     346=====================================================================================
     347top reduction in F5, i.e. reduction of a given S-polynomial by labeled polynomials of
     348the same index whereas the labels are taken into account
     349=====================================================================================
     350*/
     351LNode* topReduction(LNode* l, LList* gPrev, LList* completed) {
     352    LPoly* red  =   findReductor(l, gPrev, completed);
     353    return NULL;
     354}
     355
     356
     357
     358/*
     359=====================================================================
     360subalgorithm to find a possible reductor for the labeled polynomial l
     361=====================================================================
     362*/
     363LPoly* findReductor(LNode* l, LList* gPrev, LList* completed) {
     364    return NULL;
     365}
     366
     367
    203368
    204369/*
     
    209374ideal F5main(ideal id, ring r) {
    210375    int i,j;
     376    int* reductionsToZero   =   new int;
     377    *reductionsToZero       =   0;
    211378    // 1 polynomial for defining initial labels & further tests
    212379    poly ONE = pOne();
    213     // list of rules
    214     RList* rules    =   new RList();
    215380    i = 1;
    216     LList* gPrev    =   new LList( &ONE, &i, &id->m[0]);
    217     poly* lcm = new poly;
     381        poly* lcm = new poly;
    218382    // initialization for usage in pLcm()
    219383    *lcm = pOne();
     
    242406    qsortDegree(&id->m[0],&id->m[IDELEMS(id)-1]);
    243407    idShow(id);
     408    LList* gPrev    =   new LList(ONE, i, id->m[0]);
     409    pWrite(id->m[0]);
    244410    poly p = pHead(id->m[0]);
    245411    pWrite(p);
    246412    poly q = pHead(id->m[2]);
    247413    pWrite(q);
     414   
     415    // computing the groebner basis of the elements of index < actual index
     416    Print("Laenge der bisherigen Groebner Basis: %d\n",gPrev->getLength());
     417    ideal gbPrev    =   idInit(gPrev->getLength(),1);
     418    // initializing the groebner basis of elements of index < actual index
     419    gbPrev->m[0]    =   gPrev->getFirst()->getPoly();
     420    idShow(gbPrev);
     421    idShow(currQuotient);
     422
    248423    for(i=2; i<=IDELEMS(id); i++) {
    249         gPrev   =   F5inc(&i, &id->m[i-1], gPrev, &ONE);
     424        gPrev   =   F5inc(i, id->m[i-1], gPrev, gbPrev, ONE, reductionsToZero);
    250425        Print("JA\n");
     426        //TODO: idAdd for computing gbPrev with the actual index!
    251427    }
    252428    // only for debugging
     
    263439        //}
    264440    //}
     441    Print("\n\nNumber of zero-reductions:  %d\n",*reductionsToZero);
    265442    return(id);
    266443
  • kernel/f5gb.h

    rb3e45f r9bb97e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5gb.h,v 1.21 2009-02-04 19:27:12 ederc Exp $ */
     4/* $Id: f5gb.h,v 1.22 2009-02-06 20:12:35 ederc Exp $ */
    55/*
    66* ABSTRACT: f5gb interface
     
    3535==================================================
    3636*/
    37 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE);
     37LList* F5inc(int i, poly f_i, LList* gPrev, ideal gbPrev, poly ONE, int* reductionToZero);
    3838
    3939/*
     
    6565==========================================================================================================
    6666*/
    67 bool criterion2(poly* t, LNode* l, RTagList* rTag, Rule* lastRuleTested);
    68  
     67bool criterion2(poly* t, LPoly* l, RTagList* rTag, Rule* lastRuleTested);
     68
     69/*
     70==================================
     71Computation of S-Polynomials in F5
     72==================================
     73*/
     74void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, int* reductionsToZero);
     75
     76/*
     77========================================================================
     78reduction including subalgorithm topReduction() using Faugere's criteria
     79========================================================================
     80*/
     81LNode* reduction(LList* sPolyList, LList* completed, ideal gbPrev, int* reductionsToZero);
     82
     83/*
     84=====================================================================================
     85top reduction in F5, i.e. reduction of a given S-polynomial by labeled polynomials of
     86the same index whereas the labels are taken into account
     87=====================================================================================
     88*/
     89LNode* topReduction(LNode* l, LList* gPrev, LList* completed);
     90
     91/*
     92=====================================================================
     93subalgorithm to find a possible reductor for the labeled polynomial l
     94=====================================================================
     95*/
     96LPoly* findReductor(LNode* l, LList* gPrev, LList* completed);
     97
    6998/*
    7099======================================
  • kernel/f5lists.cc

    rb3e45f r9bb97e  
    2626
    2727// generating new list elements (labeled / classical polynomial / LNode view)
    28 LNode::LNode(LPoly* lp) {
     28LNode::LNode() {
     29    data = NULL;
     30    next = NULL;
     31}
     32 LNode::LNode(LPoly* lp) {
    2933    data = lp;
    3034    next = NULL;
     
    3539    next = l;
    3640}
    37 LNode::LNode(poly* t, int* i, poly* p) {
     41LNode::LNode(poly t, int i, poly p) {
    3842    LPoly* lp = new LPoly(t,i,p);
    3943    data = lp;
     
    4145}
    4246       
    43 LNode::LNode(poly* t, int* i, poly* p, LNode* l) {
     47LNode::LNode(poly t, int i, poly p, LNode* l) {
    4448    LPoly* lp = new LPoly(t,i,p);
    4549    data = lp;
     
    6367}
    6468       
    65 LNode* LNode::insert(poly* t, int* i, poly* p) {
     69LNode* LNode::insert(poly t, int i, poly p) {
    6670    LNode* newElement = new LNode(t, i, p, this);
    6771    return newElement;
     
    7074// insert new elemets to the list w.r.t. increasing labels
    7175// only used for the S-polys to be reduced (TopReduction building new S-polys with higher label)
    72 LNode* LNode::insertByLabel(LPoly* lp) {
    73     if( lp->getTerm() <= this->data->getTerm() ) {
    74         LNode* newElement   =   new LNode(lp, this);
     76LNode* LNode::insertByLabel(poly t, int i, poly p) {
     77    if(0 == pLmCmp(t,this->getTerm()) || -1 == pLmCmp(t,this->getTerm())) {
     78        LNode* newElement   =   new LNode(t, i, p, this);
    7579        return newElement;
    7680    }
    7781    else {
    7882        LNode* temp = this;
    79         while( NULL != temp->next ) {
    80             if( lp->getTerm() <= temp->next->data->getTerm() ) {
    81                 LNode* newElement   =   new LNode(lp, temp->next);
     83        while( NULL != temp->next->data ) {
     84            if( 0 == pLmCmp(t,temp->next->getTerm()) || -1 == pLmCmp(t,temp->next->getTerm())) {
     85                LNode* newElement   =   new LNode(t, i, p, temp->next);
    8286                temp->next          =   newElement;
    8387                return this;
     
    8791            }
    8892        }
    89         LNode* newElement   =   new LNode(lp, NULL);
     93        LNode* newElement   =   new LNode(t, i, p, NULL);
    9094        temp->next          =   newElement;
    9195        return this;
     
    120124int LNode::getIndex() {
    121125    return data->getIndex();
     126}
     127
     128bool LNode::getDel() {
     129    return data->getDel();
     130}
     131
     132// set the data from the LPoly saved in LNode
     133void LNode::setPoly(poly p) {
     134    data->setPoly(p);
     135}
     136
     137void LNode::setTerm(poly t) {
     138    data->setTerm(t);
     139}
     140
     141void LNode::setIndex(int i) {
     142    data->setIndex(i);
     143}
     144
     145void LNode::setDel(bool d) {
     146    data->setDel(d);
    122147}
    123148
     
    144169*/
    145170
     171LList::LList() {
     172    first   =   new LNode();
     173    length  =   0;
     174}
     175
    146176LList::LList(LPoly* lp) {
    147     first   = new LNode(lp);
    148 }
    149 
    150 LList::LList(poly* t,int* i,poly* p) {
    151     first   = new LNode(t,i,p);
     177    first   =   new LNode(lp);
     178    length  =   1;
     179}
     180
     181LList::LList(poly t,int i,poly p) {
     182    first   =   new LNode(t,i,p);
     183    length  =   1;
    152184}
    153185
     
    159191void LList::insert(LPoly* lp) {
    160192    first = first->insert(lp);
    161 }
    162 
    163 void LList::insert(poly* t,int* i, poly* p) {
     193    length++;
     194}
     195
     196void LList::insert(poly t,int i, poly p) {
    164197    first = first->insert(t,i,p);
    165 }
    166 
    167 void LList::insertByLabel(LPoly* lp) {
    168     first = first->insertByLabel(lp);
     198    length++;
     199}
     200
     201void LList::insertByLabel(poly t, int i, poly p) {
     202    first = first->insertByLabel(t,i,p);
     203    length++;
    169204}
    170205
     
    183218LNode* LList::getNext(LNode* l) {
    184219    return l->getNext();
     220}
     221
     222int LList::getLength() {
     223    return length;
    185224}
    186225
     
    299338            if(0 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term())) ||
    300339               -1 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term()))) {
    301                 Print("Leck mich am Arsch: ");
    302340                pWrite(u1);
    303341                Print("Multi-Term in CritPairs Sortierung altes Element: ");
     
    386424    CNode* temp = this;
    387425    while( NULL != temp->data ) {
    388         while( temp->next->data->getDeg() == this->data->getDeg() ) {
     426        while(NULL != temp->next->data && temp->next->data->getDeg() == this->data->getDeg()) {
    389427            temp = temp->next;
    390428        }
    391429        CNode* returnCNode  =   temp->next;   
    392         temp->next          =   NULL;
     430        // every CList should end with a (NULL,NULL) element for a similar behaviour
     431        // using termination conditions throughout the algorithm
     432        temp->next          =   new CNode();
    393433        return returnCNode;
    394434    }
    395435    return NULL;
     436}
     437
     438CPair* CNode::getData() {
     439    return data;
     440}
     441
     442CNode* CNode::getNext() {
     443    return next;
     444}
     445
     446LPoly* CNode::getAdLp1() {
     447    return this->data->getAdLp1();
     448}
     449
     450LPoly* CNode::getAdLp2() {
     451    return this->data->getAdLp2();
    396452}
    397453
     
    424480}
    425481
     482poly* CNode::getAdT1() {
     483    return this->data->getAdT1();
     484}
     485
    426486poly CNode::getT2() {
    427487    return this->data->getT2();
     488}
     489
     490poly* CNode::getAdT2() {
     491    return this->data->getAdT2();
     492}
     493
     494Rule* CNode::getLastRuleTested() {
     495    return this->data->getLastRuleTested();
    428496}
    429497
     
    472540}
    473541
     542CNode* CList::getFirst() {
     543    return first;
     544}
     545
    474546// get the first elements from CList which by the above sorting have minimal degree
    475547// returns the pointer on the first element of those
     
    510582}
    511583
     584RNode* RNode::insert(int i, poly t, LPoly* l) {
     585    Rule*   r           =   new Rule(i,t,l);
     586    RNode* newElement   =   new RNode(r);
     587    newElement->next    =   this;
     588    return newElement;
     589}
     590
    512591RNode* RNode::getNext() {
    513592    return next;
     
    537616RList::RList(Rule* r) {
    538617    first = new RNode(r);
     618}
     619
     620void RList::insert(int i, poly t, LPoly* l) {
     621    first = first->insert(i,t,l);
    539622}
    540623
  • kernel/f5lists.h

    rb3e45f r9bb97e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: f5lists.h,v 1.5 2009-02-04 19:27:12 ederc Exp $ */
     4/* $Id: f5lists.h,v 1.6 2009-02-06 20:12:35 ederc Exp $ */
    55/*
    66* ABSTRACT: list interface
     
    4141    public:
    4242        // generating new list elements from the labeled / classical polynomial view
     43                LNode();
    4344                LNode(LPoly* lp);
    4445                LNode(LPoly* lp, LNode* l);
    45                 LNode(poly* t, int* i, poly* p);
    46                 LNode(poly* t, int* i, poly* p, LNode* l);
     46                LNode(poly t, int i, poly p);
     47                LNode(poly t, int i, poly p, LNode* l);
    4748                LNode(LNode* ln);
    4849                ~LNode();
    4950        // insert new elements to the list in first place from the labeled / classical polynomial view
    5051        LNode*  insert(LPoly* lp);
    51         LNode*  insert(poly* t, int* i, poly* p);
     52        LNode*  insert(poly t, int i, poly p);
    5253        // insert new elements to the list with resp. to increasing labels
    5354        // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label)
    54         LNode*  insertByLabel(LPoly* lp);
     55        LNode*  insertByLabel(poly t, int i, poly p);
    5556        // deletes the first elements of the list with the same degree
    5657        // get next from current LNode
     
    6364        poly    getPoly();
    6465        poly    getTerm();
    65         int     getIndex();
     66        int     getIndex();
     67        bool    getDel();
     68        // set the data from the LPoly saved in LNode
     69        void    setPoly(poly p);
     70        void    setTerm(poly t);
     71        void    setIndex(int i);
     72        void    setDel(bool d);
    6673        // test if for any list element the polynomial part of the data is equal to *p
    6774        bool    polyTest(poly* p);
     
    7885    private:
    7986        LNode*  first;
    80     public:
     87        int     length;
     88    public:
     89                LList();
    8190                LList(LPoly* lp);
    82                 LList(poly* t,int* i,poly* p);
     91                LList(poly t,int i,poly p);
    8392                ~LList();
    8493        void    insert(LPoly* lp);
    8594        // insertion in front of the list
    86         void    insert(poly* t,int* i, poly* p);
    87         void    insertByLabel(LPoly* lp);
     95        void    insert(poly t,int i, poly p);
     96        void    insertByLabel(poly t, int i, poly p);
    8897        void    deleteByDeg();
    8998        bool    polyTest(poly* p);
    9099        LNode*  getFirst();
    91100        LNode*  getNext(LNode* l);
     101        int     getLength();
    92102};
    93103
     
    147157        CNode*  insert(CPair* c, CNode* last);
    148158        CNode*  getMinDeg();
     159        CPair*  getData();
     160        CNode*  getNext();
     161        LPoly*  getAdLp1();
     162        LPoly*  getAdLp2();
    149163        poly    getLp1Poly();
    150164        poly    getLp2Poly();
    151165        poly    getLp1Term();
    152166        poly    getLp2Term();
    153         poly    getT1();   
     167        poly    getT1();
     168        poly*   getAdT1(); 
    154169        poly    getT2();
     170        poly*   getAdT2(); 
    155171        int     getLp1Index();
    156172        int     getLp2Index();
     173        Rule*   getLastRuleTested();
    157174        void    print();
    158175};
     
    174191                CList(CPair* c);
    175192                ~CList();
     193        CNode*  getFirst();
    176194        void    insert(CPair* c);
    177195        CNode*  getMinDeg();
     
    194212                ~RNode();
    195213        RNode*  insert(Rule* r);
     214        RNode*  insert(int i, poly t, LPoly* l);
    196215        RNode*  getNext();
    197216        Rule*   getRule();
     
    215234                ~RList();
    216235        void    insert(Rule* r);
     236        void    insert(int i, poly t, LPoly* l);
    217237        RNode*  getFirst();
    218238        Rule*   getRule();
     
    257277        // declaration with first as parameter in LTagNode due to sorting of LTagList
    258278        void    insert(RNode* r);
     279        void    insert(int i, poly* t, LPoly* l);
    259280        RNode*  getFirst();
    260281        RNode*  get(int idx);
Note: See TracChangeset for help on using the changeset viewer.