source: git/kernel/f5gb.cc @ 948192

spielwiese
Last change on this file since 948192 was 948192, checked in by Christian Eder, 16 years ago
implementation of labeled polynomials git-svn-id: file:///usr/local/Singular/svn/trunk@10944 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: f5gb.cc,v 1.8 2008-08-05 20:44:08 ederc Exp $ */
5/*
6* ABSTRACT: f5gb interface
7*/
8#include "mod2.h"
9#include "kutil.h"
10#include "structs.h"
11#include "omalloc.h"
12#include "polys.h"
13#include "p_polys.h"
14#include "ideals.h"
15#include "febase.h"
16#include "kstd1.h"
17#include "khstd.h"
18#include "kbuckets.h"
19#include "weight.h"
20#include "intvec.h"
21#include "pInline1.h"
22#include "f5gb.h"
23#include "lpolynom.h"
24#ifdef HAVE_F5
25
26
27/*2
28* sorting ideals by decreasing total degree
29* "left" and "right" are the pointer of the first
30* and last polynomial in the considered ideal
31*/
32void qsort_degree(poly* left, poly* right)
33{
34        poly* ptr1 = left;
35        poly* ptr2 = right;
36        poly p1,p2;
37        p2 = *(left + (right - left >> 1));
38        do{
39                while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)){
40                        ptr1++;
41                }
42                while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)){
43                        ptr2--;
44                }
45                if(ptr1 > ptr2){
46                        break;
47                }
48                p1    = *ptr1;
49                *ptr1 = *ptr2;
50                *ptr2 = p1;
51        } while(++ptr1 <= --ptr2);
52
53        if(left < ptr2){
54                qsort_degree(left,ptr2);
55        }
56        if(ptr1 < right){
57                qsort_degree(ptr1,right);
58        }
59}
60
61
62/*2
63* computes incrementally gbs of subsets of the input
64* gb{f_m} -> gb{f_m,f_(m-1)} -> gb{f_m,...,f_1}
65*/ 
66lpoly *f5_inc(lpoly* lp, lpoly* g_prev)
67{
68       
69       
70        return lp;
71}   
72
73
74/*2
75* computes a gb of the ideal i in the ring r with our f5
76* implementation
77*/
78ideal F5main(ideal i, ring r)
79{
80      ideal iTmp, g_basis;
81      long j, k;
82      poly one = pInit();
83      pSetCoeff(one, nInit(1));
84      pWrite(one);
85      lpoly *lp, *gb;
86      intvec* sort;
87      iTmp = idInit(IDELEMS(i),i->rank);
88 
89      for(j=0; j<IDELEMS(i); j++)
90      {
91              if(NULL != i->m[j])
92              {
93                      iTmp->m[j] = i->m[j];
94              }
95      }
96
97      iTmp = kInterRed(i,0); 
98      qsort_degree(&iTmp->m[0],&iTmp->m[IDELEMS(iTmp)-1]);
99      idShow(iTmp);
100     
101      lp = new lpoly[IDELEMS(iTmp)];
102     
103      for(j=0; j <IDELEMS(iTmp); j++){
104                lp[j].setPoly(iTmp->m[j]);
105               
106                if(pComparePolys(lp[j].getPoly(), one)){
107                                Print("1 in GB");
108                                return(NULL);
109                }
110               
111                lp[j].setIndex(j+1);
112                lp[j].setTerm(one);
113                Print("Labeled Polynomial %d: ",j+1);
114                Print("Signature Term: ");
115                pWrite(lp[j].getTerm());
116                Print("Signature Index: %d\n", lp[j].getIndex());
117                pWrite(lp[j].getPoly());
118                Print("\n\n");
119                         
120      }
121     
122      // PROBLEM: muss signatur mitliefern, daher datentyp
123      //          ideal nicht zu gebrauchen?
124      gb = new lpoly;
125      gb = &lp[IDELEMS(iTmp)-1];
126      pWrite((*gb).getPoly());
127
128      for(j=IDELEMS(iTmp)-2; j>0; j--){
129             //PROBLEM: muss dynamisch Speicher allozieren
130             gb = f5_inc(&lp[j], gb);
131             for(k=0; k< IDELEMS(iTmp); k++){
132                    if(gb[k].getPoly()){
133                    }
134             }
135
136
137
138               
139      }
140               
141                       
142
143
144        return iTmp;
145}
146
147
148#endif
Note: See TracBrowser for help on using the repository browser.