1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: f5gb.cc,v 1.5 2008-06-01 12:49:42 ederc Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: f5gb interface |
---|
7 | */ |
---|
8 | |
---|
9 | #include "mod2.h" |
---|
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 "lpoly.h" |
---|
25 | #ifdef HAVE_F5 |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | /*2 |
---|
31 | * sorting ideals by decreasing total degree |
---|
32 | * "left" and "right" are the pointer of the first |
---|
33 | * and last polynomial in the considered ideal |
---|
34 | */ |
---|
35 | void qsort_degree(poly* left, poly* right) |
---|
36 | { |
---|
37 | poly* ptr1 = left; |
---|
38 | poly* ptr2 = right; |
---|
39 | poly p1,p2; |
---|
40 | |
---|
41 | p2 = *(left + (right - left >> 1)); |
---|
42 | do{ |
---|
43 | while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)){ |
---|
44 | ptr1++; |
---|
45 | } |
---|
46 | while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)){ |
---|
47 | ptr2--; |
---|
48 | } |
---|
49 | if(ptr1 > ptr2){ |
---|
50 | break; |
---|
51 | } |
---|
52 | p1 = *ptr1; |
---|
53 | *ptr1 = *ptr2; |
---|
54 | *ptr2 = p1; |
---|
55 | } while(++ptr1 <= --ptr2); |
---|
56 | |
---|
57 | if(left < ptr2){ |
---|
58 | qsort_degree(left,ptr2); |
---|
59 | } |
---|
60 | if(ptr1 < right){ |
---|
61 | qsort_degree(ptr1,right); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | /*2 |
---|
67 | * computes a gb of the ideal i in the ring r with our f5 |
---|
68 | * implementation |
---|
69 | */ |
---|
70 | ideal F5main(ideal i, ring r) |
---|
71 | { |
---|
72 | ideal iTmp, g; |
---|
73 | int j; |
---|
74 | lpoly* lp; |
---|
75 | intvec* sort; |
---|
76 | iTmp = idInit(IDELEMS(i),i->rank); |
---|
77 | |
---|
78 | for(j=0; j<IDELEMS(i); j++) |
---|
79 | { |
---|
80 | if(NULL != i->m[j]) |
---|
81 | { |
---|
82 | iTmp->m[j] = i->m[j]; |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | iTmp = kInterRed(i,0); |
---|
87 | qsort_degree(&iTmp->m[0],&iTmp->m[IDELEMS(iTmp)-1]); |
---|
88 | idShow(iTmp); |
---|
89 | |
---|
90 | lp = new lpoly[IDELEMS(iTmp)]; |
---|
91 | for(j=0; j <IDELEMS(iTmp); j++){ |
---|
92 | lp[j].setPoly(&iTmp->m[j]); |
---|
93 | pWrite(*(lp[j].getPoly())); |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | return iTmp; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | #endif |
---|