source: git/kernel/f5gb.cc @ 244ed5

spielwiese
Last change on this file since 244ed5 was 244ed5, checked in by Christian Eder, 15 years ago
updated header inclusions due to lplist git-svn-id: file:///usr/local/Singular/svn/trunk@11209 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: f5gb.cc,v 1.13 2008-11-27 17:17:32 ederc Exp $ */
5/*
6* ABSTRACT: f5gb interface
7*/
8#include "mod2.h"
9#ifdef HAVE_F5
10#include "kutil.h"
11#include "structs.h"
12#include "omalloc.h"
13#include "polys.h"
14#include "p_polys.h"
15#include "ideals.h"
16#include "febase.h"
17#include "kstd1.h"
18#include "khstd.h"
19#include "kbuckets.h"
20#include "weight.h"
21#include "intvec.h"
22#include "pInline1.h"
23#include "f5gb.h"
24#include "lpolynomial.h"
25#include "lplist.h"
26
27
28
29/*2
30* sorting ideals by decreasing total degree
31* "left" and "right" are the pointer of the first
32* and last polynomial in the considered ideal
33*/
34void qsort_degree(poly* left, poly* right)
35{
36        poly* ptr1 = left;
37        poly* ptr2 = right;
38        poly p1,p2;
39        p2 = *(left + (right - left >> 1));
40        do{
41                while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)){
42                        ptr1++;
43                }
44                while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)){
45                        ptr2--;
46                }
47                if(ptr1 > ptr2){
48                        break;
49                }
50                p1    = *ptr1;
51                *ptr1 = *ptr2;
52                *ptr2 = p1;
53        } while(++ptr1 <= --ptr2);
54
55        if(left < ptr2){
56                qsort_degree(left,ptr2);
57        }
58        if(ptr1 < right){
59                qsort_degree(ptr1,right);
60        }
61}
62
63
64/*2
65* computes incrementally gbs of subsets of the input
66* gb{f_m} -> gb{f_m,f_(m-1)} -> gb{f_m,...,f_1}
67 
68LPoly *f5_inc(LPoly* lp, LPoly* g_prev)
69{
70        long length = 1;
71       
72        while(g_prev->getNext() != NULL) {
73                length++;
74                g_prev++;
75        }
76        Print("Laenge der Liste: %d\n",length);
77        /*critpair *critpairs = new critpair[length];
78        * int i = 1;
79        *
80        * while(g_prev->getNext()->getNext() != NULL) {
81        *        critpairs[i] = {lp, g_prev, critpairs[i+1]};
82        *        i++;
83        *        g_prev++;
84        * }
85        * *critpairs[length] = {lp, g_prev+length-1, NULL};
86        *
87        * return lp;
88       
89}   
90
91*/
92// generating the list lp of ideal generators and test if 1 is in lp
93bool generate_input_list(LPoly* lp, ideal id, poly ONE)
94{
95        long j;
96        for(j=0; j<IDELEMS(id)-1; j++){
97
98                lp[j].setPoly(id->m[j]);
99               
100                if(pComparePolys(lp[j].getPoly(), ONE)){
101                        Print("1 in GB\n");
102                        return(1);
103                }
104               
105                lp[j].setIndex(j+1);
106                lp[j].setTerm(ONE);
107                lp[j].setDel(false);
108                lp[j].setNext(&lp[j+1]);
109                Print("Labeled Polynomial %ld: ",j+1);
110                Print("Label Term: ");
111                pWrite(lp[j].getTerm());
112                Print("Index: %ld\n", lp[j].getIndex());
113                Print("Delete? %d\n", lp[j].getDel());
114                pWrite(lp[j].getPoly());
115                Print("NEUNEUNEU\n\n");
116        }
117        return(0);
118}
119
120
121/*2
122* computes a gb of the ideal i in the ring r with our f5
123* implementation
124*/
125ideal F5main(ideal i, ring r) {
126
127    long j;
128    LPoly * lp = new LPoly;
129    // definition of one-polynomial as global constant ONE
130    poly one = pInit();
131    pSetCoeff(one, nInit(1));
132    static const poly ONE = one;
133   
134    //
135    for(j=0; j<IDELEMS(i); j++) {
136        if(NULL != i->m[j]) { 
137            if(pComparePolys(i->m[j],ONE)) {
138                Print("One Polynomial in Input => Computations stopped\n");
139                return(i);
140            }   
141        }
142    } 
143   
144    i = kInterRed(i,0); 
145    qsort_degree(&i->m[0],&i->m[IDELEMS(i)-1]);
146    idShow(i);
147           
148    /* if(generate_input_list(lp,iTmp,ONE)) {
149            Print("One Polynomial in Input => Computations stopped");
150            iTmp = idInit(1,0);
151            iTmp->m[0] = ONE;
152            return(iTmp);
153    }
154    */
155    Print("Es klappt!\nWIRKLICH!\n");
156    // only for debugging
157    lp->get();
158    //return(i);
159    LpList lp_list;
160    while(NULL != lp->getNext()) {
161        lp_list.insert(lp);
162        lp = lp->getNext();
163    }
164    lp_list.get();
165    return i;
166
167
168}
169
170
171#endif
Note: See TracBrowser for help on using the repository browser.