1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: f5gb.cc,v 1.6 2008-06-01 15:14:37 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 | #ifdef HAVE_F5 |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | void lpoly::setPoly(poly* p){ |
---|
29 | p_ptr = p; |
---|
30 | } |
---|
31 | |
---|
32 | void lpoly::setTerm(poly* t){ |
---|
33 | t_ptr = t; |
---|
34 | } |
---|
35 | |
---|
36 | void lpoly::setIndex(long* i){ |
---|
37 | i_ptr = i; |
---|
38 | } |
---|
39 | |
---|
40 | poly* lpoly::getPoly(){ |
---|
41 | return p_ptr; |
---|
42 | } |
---|
43 | |
---|
44 | poly* lpoly::getTerm(){ |
---|
45 | return t_ptr; |
---|
46 | } |
---|
47 | |
---|
48 | long* lpoly::getIndex(){ |
---|
49 | return i_ptr; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | /*2 |
---|
56 | * sorting ideals by decreasing total degree |
---|
57 | * "left" and "right" are the pointer of the first |
---|
58 | * and last polynomial in the considered ideal |
---|
59 | */ |
---|
60 | void qsort_degree(poly* left, poly* right) |
---|
61 | { |
---|
62 | poly* ptr1 = left; |
---|
63 | poly* ptr2 = right; |
---|
64 | poly p1,p2; |
---|
65 | |
---|
66 | p2 = *(left + (right - left >> 1)); |
---|
67 | do{ |
---|
68 | while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)){ |
---|
69 | ptr1++; |
---|
70 | } |
---|
71 | while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)){ |
---|
72 | ptr2--; |
---|
73 | } |
---|
74 | if(ptr1 > ptr2){ |
---|
75 | break; |
---|
76 | } |
---|
77 | p1 = *ptr1; |
---|
78 | *ptr1 = *ptr2; |
---|
79 | *ptr2 = p1; |
---|
80 | } while(++ptr1 <= --ptr2); |
---|
81 | |
---|
82 | if(left < ptr2){ |
---|
83 | qsort_degree(left,ptr2); |
---|
84 | } |
---|
85 | if(ptr1 < right){ |
---|
86 | qsort_degree(ptr1,right); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | /*2 |
---|
92 | * computes a gb of the ideal i in the ring r with our f5 |
---|
93 | * implementation |
---|
94 | */ |
---|
95 | ideal F5main(ideal i, ring r) |
---|
96 | { |
---|
97 | ideal iTmp, g; |
---|
98 | int j; |
---|
99 | lpoly* lp; |
---|
100 | intvec* sort; |
---|
101 | iTmp = idInit(IDELEMS(i),i->rank); |
---|
102 | |
---|
103 | for(j=0; j<IDELEMS(i); j++) |
---|
104 | { |
---|
105 | if(NULL != i->m[j]) |
---|
106 | { |
---|
107 | iTmp->m[j] = i->m[j]; |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | iTmp = kInterRed(i,0); |
---|
112 | qsort_degree(&iTmp->m[0],&iTmp->m[IDELEMS(iTmp)-1]); |
---|
113 | idShow(iTmp); |
---|
114 | |
---|
115 | lp = new lpoly[IDELEMS(iTmp)]; |
---|
116 | for(j=0; j <IDELEMS(iTmp); j++){ |
---|
117 | lp[j].setPoly(&iTmp->m[j]); |
---|
118 | Print("Labeled Polynomial %d: ",j+1); |
---|
119 | pWrite(*(lp[j].getPoly())); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | return iTmp; |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | #endif |
---|