1 | #include "Singular/libsingular.h" |
---|
2 | |
---|
3 | #ifdef HAVE_SHIFTBBA |
---|
4 | static BOOLEAN freegb(leftv res, leftv args) |
---|
5 | { |
---|
6 | const short t1[]={2,RING_CMD,INT_CMD}; |
---|
7 | if (iiCheckTypes(args,t1,1)) |
---|
8 | { |
---|
9 | ring r=(ring)args->Data(); |
---|
10 | int d=(int)(long)args->next->Data(); |
---|
11 | if (d<2) |
---|
12 | { |
---|
13 | WerrorS("degree must be >=2"); |
---|
14 | return TRUE; |
---|
15 | } |
---|
16 | int i=0; |
---|
17 | while(r->order[i]!=0) |
---|
18 | { |
---|
19 | if ((r->order[i]==ringorder_c) ||(r->order[i]==ringorder_C)) i++; |
---|
20 | else if ((r->block0[i]==1)&&(r->block1[i]==r->N)) i++; |
---|
21 | else |
---|
22 | { |
---|
23 | WerrorS("only for rings with a global ordering of one block"); |
---|
24 | return TRUE; |
---|
25 | } |
---|
26 | } |
---|
27 | if ((r->order[i]!=0) |
---|
28 | || (rHasLocalOrMixedOrdering(r))) |
---|
29 | { |
---|
30 | WerrorS("only for rings with a global ordering of one block"); |
---|
31 | //Werror("only for rings with a global ordering of one block,i=%d, o=%d",i,r->order[i]); |
---|
32 | return TRUE; |
---|
33 | } |
---|
34 | ring R=freeAlgebra(r,d); |
---|
35 | res->rtyp=RING_CMD; |
---|
36 | res->data=R; |
---|
37 | return R==NULL; |
---|
38 | } |
---|
39 | return TRUE; |
---|
40 | } |
---|
41 | |
---|
42 | static BOOLEAN stest(leftv res, leftv args) |
---|
43 | { |
---|
44 | const short t[]={2,POLY_CMD,INT_CMD}; |
---|
45 | if (iiCheckTypes(args,t,1)) |
---|
46 | { |
---|
47 | poly p=(poly)args->CopyD(); |
---|
48 | args=args->next; |
---|
49 | int sh=(int)((long)(args->Data())); |
---|
50 | if (sh<0) |
---|
51 | { |
---|
52 | WerrorS("negative shift for pLPshift"); |
---|
53 | return TRUE; |
---|
54 | } |
---|
55 | int L = pLastVblock(p); |
---|
56 | if (L+sh > currRing->N/currRing->isLPring) |
---|
57 | { |
---|
58 | WerrorS("pLPshift: too big shift requested\n"); |
---|
59 | return TRUE; |
---|
60 | } |
---|
61 | p_LPshift(p,sh,currRing); |
---|
62 | res->data = p; |
---|
63 | res->rtyp = POLY_CMD; |
---|
64 | return FALSE; |
---|
65 | } |
---|
66 | else return TRUE; |
---|
67 | } |
---|
68 | |
---|
69 | static BOOLEAN btest(leftv res, leftv h) |
---|
70 | { |
---|
71 | const short t[]={1,POLY_CMD}; |
---|
72 | if (iiCheckTypes(h,t,1)) |
---|
73 | { |
---|
74 | poly p=(poly)h->Data(); |
---|
75 | res->rtyp = INT_CMD; |
---|
76 | res->data = (void*)(long)pLastVblock(p); |
---|
77 | return FALSE; |
---|
78 | } |
---|
79 | else return TRUE; |
---|
80 | } |
---|
81 | |
---|
82 | /*==================== divide-test for freeGB =================*/ |
---|
83 | static BOOLEAN lpLmDivides(leftv res, leftv h) |
---|
84 | { |
---|
85 | const short t1[]={2,POLY_CMD,POLY_CMD}; |
---|
86 | const short t2[]={2,IDEAL_CMD,POLY_CMD}; |
---|
87 | if (iiCheckTypes(h,t1,0)) |
---|
88 | { |
---|
89 | poly p=(poly)h->Data(); |
---|
90 | poly q=(poly)h->next->Data(); |
---|
91 | res->rtyp = INT_CMD; |
---|
92 | res->data = (void*)(long)p_LPDivisibleBy(p, q, currRing); |
---|
93 | return FALSE; |
---|
94 | } |
---|
95 | else if (iiCheckTypes(h,t2,1)) |
---|
96 | { |
---|
97 | ideal I=(ideal)h->Data(); |
---|
98 | poly q=(poly)h->next->Data(); |
---|
99 | res->rtyp = INT_CMD; |
---|
100 | for(int i=0;i<IDELEMS(I);i++) |
---|
101 | { |
---|
102 | if (p_LPDivisibleBy(I->m[i],q, currRing)) |
---|
103 | { |
---|
104 | res->data=(void*)(long)1; |
---|
105 | return FALSE; |
---|
106 | } |
---|
107 | } |
---|
108 | res->data=(void*)(long)0; |
---|
109 | return FALSE; |
---|
110 | } |
---|
111 | else return TRUE; |
---|
112 | } |
---|
113 | |
---|
114 | /*==================== get var for freeGB ====================*/ |
---|
115 | static BOOLEAN lpVarAt(leftv res, leftv h) |
---|
116 | { |
---|
117 | const short t[]={2,POLY_CMD,INT_CMD}; |
---|
118 | if (iiCheckTypes(h,t,1)) |
---|
119 | { |
---|
120 | poly p=(poly)h->Data(); |
---|
121 | int pos=(int)((long)(h->next->Data())); |
---|
122 | res->rtyp = POLY_CMD; |
---|
123 | res->data = p_LPVarAt(p, pos, currRing); |
---|
124 | return FALSE; |
---|
125 | } |
---|
126 | else return TRUE; |
---|
127 | } |
---|
128 | #endif |
---|
129 | |
---|
130 | //------------------------------------------------------------------------ |
---|
131 | // initialisation of the module |
---|
132 | extern "C" int SI_MOD_INIT(freegb)(SModulFunctions* p) |
---|
133 | { |
---|
134 | #ifdef HAVE_SHIFTBBA |
---|
135 | p->iiAddCproc("freegb.so","freeAlgebra",FALSE,freegb); |
---|
136 | p->iiAddCproc("freegb.so","lpLmDivides",FALSE,lpLmDivides); |
---|
137 | p->iiAddCproc("freegb.so","lpVarAt",FALSE,lpVarAt); |
---|
138 | p->iiAddCproc("freegb.so","stest",TRUE,stest); |
---|
139 | p->iiAddCproc("freegb.so","btest",TRUE,btest); |
---|
140 | #endif |
---|
141 | return (MAX_TOK); |
---|
142 | } |
---|