My Project
Loading...
Searching...
No Matches
customstd.cc
Go to the documentation of this file.
2//#include <vector>
3//#include <iostream>
4
5// global variable potentially storing output
6//ideal idealCache=NULL;
7
8// //------------------------------------------------------------------------
9// // example of a routine which changes nothing
10// static BOOLEAN display_sp(kStrategy strat)
11// {
12// // will be call each time a new s-poly is computed (strat->P)
13// // the algorithm assures that strat->P.p!=NULL, in currRing
14// // if strat->P.t_p==NULL: strat->P.p->next is in currRing
15// // otherwise: strat->P.t_p->next==strat->P.p->next, in strat->tailRing
16// // must return TRUE, if strat->P is changed, FALSE otherwise
17// PrintS("a new s-poly found: ");
18// p_Write(strat->P.p,currRing,strat->tailRing);
19// return FALSE;
20// }
21// static BOOLEAN std_with_display(leftv res, leftv args)
22// {
23// if (args!=NULL)
24// {
25// if (args->Typ()==IDEAL_CMD)
26// {
27// ideal I=(ideal)args->Data();
28// I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,display_sp);
29// idSkipZeroes(I);
30// res->data=(char*)I;
31// res->rtyp=IDEAL_CMD;
32// return FALSE;
33// }
34// }
35// WerrorS("expected: std_with_display(`idea;`)");
36// return TRUE;
37// }
38
40{
41 leftv u = args;
42 if ((u!=NULL)
43 && ((u->Typ()==IDEAL_CMD)||(u->Typ()==MODUL_CMD)))
44 {
45 ideal I=(ideal)u->Data();
46 leftv v = u->next;
47
48 res->rtyp=IDEAL_CMD;
49 ideal J;
50 if (v==NULL)
51 {
53 }
54 else
55 {
56 if (v->Typ()==IDEAL_CMD)
57 {
58 J = (ideal) v->Data();
59 }
60 else
61 {
62 args->CleanUp();
63 WerrorS("satstd: unexpected parameters");
64 return TRUE;
65 }
66 }
67 I=id_Satstd(I,J,currRing);
68
69#if 0 /* unused */
70 if (idealCache)
71 {
73 res->data = (char*) idealCache;
74 idealCache = NULL;
75 }
76 else
77#endif
78 {
79 idSkipZeroes(I);
80 res->data=(char*)I;
81 }
82 if (v==NULL) id_Delete(&J,currRing);
83 args->CleanUp();
85 return (res->data==NULL);
86 }
87 WerrorS("satstd: unexpected parameters");
88 return TRUE;
89}
90
92{
93 BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
94 // let it remain FALSE otherwise
95 if (strat->P.t_p==NULL)
96 {
97 poly p=strat->P.p;
98 if (pNext(p)==NULL)
99 {
100 while ((strat->Ll >= 0))
101 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
102 return FALSE;
103 }
104 }
105 else
106 {
107 poly p=strat->P.t_p;
108 if (pNext(p)==NULL)
109 {
110 while ((strat->Ll >= 0))
111 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
112 return FALSE;
113 }
114 }
115 return b; // return TRUE if sp was changed, FALSE if not
116}
117
119{
120 if (args!=NULL)
121 {
122 if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
123 {
124 ideal I=(ideal)args->Data();
126 idSkipZeroes(I);
127 res->rtyp=IDEAL_CMD;
128 res->data=(char*)I;
129 return FALSE;
130 }
131 }
132 WerrorS("monomialabortstd: unexpected parameters");
133 return TRUE;
134}
135
136// static long wDeg(const poly p, const ring r)
137// {
138// if (r->order[0] == ringorder_lp)
139// return p_GetExp(p,1,currRing);
140// if (r->order[0] == ringorder_ls)
141// return -p_GetExp(p,1,currRing);
142
143// if (r->order[0] == ringorder_dp)
144// {
145// long d = 0;
146// for (int i=1; i<=rVar(r); i++)
147// d = d + p_GetExp(p,i,r);
148// return d;
149// }
150// if (r->order[0] == ringorder_wp || r->order[0] == ringorder_a)
151// {
152// long d = 0;
153// for (int i=r->block0[0]; i<=r->block1[0]; i++)
154// d = d + p_GetExp(p,i,r)*r->wvhdl[0][i-1];
155// return d;
156// }
157// if (r->order[0] == ringorder_ws)
158// {
159// long d = 0;
160// for (int i=r->block0[0]; i<=r->block1[0]; i++)
161// d = d - p_GetExp(p,i,r)*r->wvhdl[0][i-1];
162// return d;
163// }
164// }
165
166// static bool isInitialFormMonomial(const poly g, const ring r)
167// {
168// if (g->next==NULL)
169// return true;
170// return wDeg(g,r)!=wDeg(g->next,r);
171// }
172
173// //------------------------------------------------------------------------
174// // routine that checks whether the initial form is a monomial,
175// // breaks computation if it finds one, writing the element into idealCache
176// static BOOLEAN sat_sp_initial(kStrategy strat)
177// {
178// BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
179// // let it remain FALSE otherwise
180// if (strat->P.t_p==NULL)
181// {
182// poly p=strat->P.p;
183// if (pNext(p)==NULL)
184// {
185// // if a term is contained in the ideal, abort std computation
186// // and store the output in idealCache to be returned
187// while ((strat->Ll >= 0))
188// deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
189// idealCache = idInit(1);
190// idealCache->m[0] = p_One(currRing);
191// return FALSE;
192// }
193// if (isInitialFormMonomial(p,currRing))
194// {
195// while ((strat->Ll >= 0))
196// deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
197// idealCache = idInit(1);
198// idealCache->m[0] = p_Copy(p,currRing);
199// }
200// int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
201// int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
202// p_GetExpV(p,mm,currRing);
203// int m_null=0;
204// while(p!=NULL)
205// {
206// m_null=0;
207// p_GetExpV(p,m0,currRing);
208// for(int i=1;i<=rVar(currRing);i++)
209// {
210// mm[i]=si_min(mm[i],m0[i]);
211// if (mm[i]>0) m_null++;
212// }
213// if (m_null==0) break;
214// pIter(p);
215// }
216// if (m_null>0)
217// {
218// std::cout << "simplifying!" << std::endl;
219// p=p_Copy(strat->P.p,currRing);
220// strat->P.p=p;
221// while(p!=NULL)
222// {
223// for(int i=1;i<=rVar(currRing);i++)
224// p_SubExp(p,i,mm[i],currRing);
225// p_Setm(p,currRing);
226// pIter(p);
227// }
228// b = TRUE;
229// }
230// omFree(mm);
231// omFree(m0);
232// }
233// else
234// {
235// poly p=strat->P.t_p;
236// if (pNext(p)==NULL)
237// {
238// // if a term is contained in the ideal, abort std computation
239// // and store the output in idealCache to be returned
240// while ((strat->Ll >= 0))
241// deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
242// idealCache = idInit(1);
243// idealCache->m[0] = p_One(currRing);
244// return FALSE;
245// }
246// if (isInitialFormMonomial(p,strat->tailRing))
247// {
248// while ((strat->Ll >= 0))
249// deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
250// nMapFunc identity = n_SetMap(strat->tailRing,currRing);
251// idealCache = idInit(1);
252// idealCache->m[0] = p_PermPoly(p,NULL,strat->tailRing,currRing,identity,NULL,0);
253// }
254// int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
255// int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
256// p_GetExpV(p,mm,strat->tailRing);
257// int m_null=0;
258// while(p!=NULL)
259// {
260// m_null=0;
261// p_GetExpV(p,m0,strat->tailRing);
262// for(int i=1;i<=rVar(currRing);i++)
263// {
264// mm[i]=si_min(mm[i],m0[i]);
265// if (mm[i]>0) m_null++;
266// }
267// if (m_null==0) break;
268// pIter(p);
269// }
270// if (m_null>0)
271// {
272// std::cout << "simplifying!" << std::endl;
273// p=p_Copy(strat->P.t_p,strat->tailRing);
274// strat->P.t_p=p;
275// strat->P.p=NULL;
276// while(p!=NULL)
277// {
278// for(int i=1;i<=rVar(currRing);i++)
279// p_SubExp(p,i,mm[i],strat->tailRing);
280// p_Setm(p,strat->tailRing);
281// pIter(p);
282// }
283// strat->P.GetP();
284// b = TRUE;
285// }
286// omFree(mm);
287// omFree(m0);
288// }
289// return b; // return TRUE if sp was changed, FALSE if not
290// }
291// static BOOLEAN satstdWithInitialCheck(leftv res, leftv args)
292// {
293// if (args!=NULL)
294// {
295// if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
296// {
297// ideal I=(ideal)args->Data();
298// idealCache = NULL;
299// I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_sp_initial);
300// res->rtyp=IDEAL_CMD;
301// if (idealCache)
302// res->data=(char*)idealCache;
303// else
304// res->data=(char*)I;
305// return FALSE;
306// }
307// }
308// WerrorS("satstdWithInitialCheck: unexpected parameters");
309// return TRUE;
310// }
311
312
313
314//------------------------------------------------------------------------
315// initialisation of the module
316extern "C" int SI_MOD_INIT(customstd)(SModulFunctions* p)
317{
318 // p->iiAddCproc("std_demo","std_with_display",FALSE,std_with_display);
319 p->iiAddCproc("customstd.lib","satstd",FALSE,satstd);
320 // p->iiAddCproc("std_demo","satstdWithInitialCheck",FALSE,satstdWithInitialCheck);
321 p->iiAddCproc("customstd.lib","monomialabortstd",FALSE,monomialabortstd);
322 // PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
323 return (MAX_TOK);
324}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
int Ll
Definition: kutil.h:351
LObject P
Definition: kutil.h:302
LSet L
Definition: kutil.h:327
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
leftv next
Definition: subexpr.h:86
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
static BOOLEAN satstd(leftv res, leftv args)
Definition: customstd.cc:39
static BOOLEAN abort_if_monomial_sp(kStrategy strat)
Definition: customstd.cc:91
int SI_MOD_INIT() customstd(SModulFunctions *p)
Definition: customstd.cc:316
BOOLEAN monomialabortstd(leftv res, leftv args)
Definition: customstd.cc:118
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284
@ MODUL_CMD
Definition: grammar.cc:287
ideal id_Satstd(const ideal I, ideal J, const ring r)
Definition: ideals.cc:3108
#define setFlag(A, F)
Definition: ipid.h:113
#define FLAG_STD
Definition: ipid.h:106
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2447
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1215
#define pNext(p)
Definition: monomials.h:36
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
Definition: simpleideals.cc:98
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
@ testHomog
Definition: structs.h:38
@ MAX_TOK
Definition: tok.h:218