1 | #include "mod2.h" |
---|
2 | #include "janet.h" |
---|
3 | #include "kstd1.h" |
---|
4 | |
---|
5 | #define pow_(x) pTotaldegree((x)) |
---|
6 | |
---|
7 | //extern int (*ListGreatMove)(jList *,jList *,poly); |
---|
8 | extern int ComputeBasis(jList *,jList *); |
---|
9 | extern void Initialization(char *); |
---|
10 | |
---|
11 | BOOLEAN jjJanetBasis(leftv res, leftv v) |
---|
12 | { |
---|
13 | Initialization(rOrdStr(currRing)); |
---|
14 | |
---|
15 | jList *Q=(jList *)GCM(sizeof(jList)); |
---|
16 | Q->root=NULL; |
---|
17 | |
---|
18 | jList *T=(jList *)GCM(sizeof(jList)); |
---|
19 | T->root=NULL; |
---|
20 | |
---|
21 | for (int i=0; i < ((ideal)(v->Data()))->idelems(); i++) |
---|
22 | { |
---|
23 | if (pIsConstant(((ideal)(v->Data()))->m[i])) |
---|
24 | { |
---|
25 | Werror("Constant in input"); |
---|
26 | goto zero; |
---|
27 | } |
---|
28 | |
---|
29 | Poly *beg=NewPoly(pCopy(((ideal)(v->Data()))->m[i])); |
---|
30 | |
---|
31 | InitHistory(beg); |
---|
32 | InitProl(beg); |
---|
33 | InitLead(beg); |
---|
34 | |
---|
35 | InsertInCount(Q,beg); |
---|
36 | } |
---|
37 | |
---|
38 | ideal result; |
---|
39 | int dpO; |
---|
40 | |
---|
41 | if (ComputeBasis(T,Q)) |
---|
42 | { |
---|
43 | dpO=(strstr(rOrdStr(currRing),"dp")!=NULL); |
---|
44 | int ideal_length= dpO ? GB_length() : CountList(T); |
---|
45 | result=idInit(ideal_length,1); |
---|
46 | int ideal_index=0; |
---|
47 | |
---|
48 | LCI iT=T->root; |
---|
49 | |
---|
50 | while(iT) |
---|
51 | { |
---|
52 | pTest(iT->info->root); |
---|
53 | if (dpO) |
---|
54 | { |
---|
55 | if (pow_(iT->info->lead) == pow_(iT->info->history)) |
---|
56 | { |
---|
57 | result->m[ideal_length-ideal_index-1]=pCopy(iT->info->root); |
---|
58 | if (!nGreaterZero(pGetCoeff(iT->info->root))) |
---|
59 | result->m[ideal_length-ideal_index-1]=pNeg(result->m[ideal_length-ideal_index-1]); |
---|
60 | |
---|
61 | ideal_index++; |
---|
62 | } |
---|
63 | } |
---|
64 | else |
---|
65 | { |
---|
66 | result->m[ideal_length-ideal_index-1]=pCopy(iT->info->root); |
---|
67 | if (!nGreaterZero(pGetCoeff(iT->info->root))) |
---|
68 | result->m[ideal_length-ideal_index-1]=pNeg(result->m[ideal_length-ideal_index-1]); |
---|
69 | |
---|
70 | ideal_index++; |
---|
71 | } |
---|
72 | iT=iT->next; |
---|
73 | } |
---|
74 | } |
---|
75 | else |
---|
76 | { |
---|
77 | zero: |
---|
78 | result=idInit(1,1); |
---|
79 | result->m[0]=pOne(); |
---|
80 | } |
---|
81 | |
---|
82 | if (!dpO) |
---|
83 | { |
---|
84 | Print ("interred\n"); |
---|
85 | result=kInterRed(result); |
---|
86 | idSkipZeroes(result); |
---|
87 | } |
---|
88 | res->data = (char *)result; |
---|
89 | res->rtyp = IDEAL_CMD; |
---|
90 | |
---|
91 | DestroyList(Q); |
---|
92 | DestroyList(T); |
---|
93 | |
---|
94 | return FALSE; |
---|
95 | } |
---|