My Project
Functions | Variables
customstd.cc File Reference
#include "Singular/libsingular.h"
#include "libpolys/polys/prCopy.h"

Go to the source code of this file.

Functions

static BOOLEAN satstd (leftv res, leftv args)
 
static BOOLEAN abort_if_monomial_sp (kStrategy strat)
 
static BOOLEAN print_spoly (kStrategy strat)
 
static BOOLEAN print_syz (kStrategy strat)
 
static BOOLEAN std_print_spoly (leftv res, leftv args)
 
static ideal idGroebner_print (ideal temp, int syzComp, intvec *w=NULL, tHomog hom=testHomog)
 
static ideal idPrepare_print (ideal h1, ideal h11, tHomog hom, int syzcomp, intvec **w)
 
static ideal idSyzygies_print (ideal h1, tHomog h, intvec **w)
 
static BOOLEAN syz_print_spoly (leftv res, leftv args)
 
static BOOLEAN monomialabortstd (leftv res, leftv args)
 
int SI_MOD_INIT() customstd (SModulFunctions *p)
 

Variables

STATIC_VAR char * si_filename
 
STATIC_VAR int si_filenr
 

Function Documentation

◆ abort_if_monomial_sp()

static BOOLEAN abort_if_monomial_sp ( kStrategy  strat)
static

Definition at line 92 of file customstd.cc.

93{
94 BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
95 // let it remain FALSE otherwise
96 if (strat->P.t_p==NULL)
97 {
98 poly p=strat->P.p;
99 if (pNext(p)==NULL)
100 {
101 while ((strat->Ll >= 0))
102 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
103 return FALSE;
104 }
105 }
106 else
107 {
108 poly p=strat->P.t_p;
109 if (pNext(p)==NULL)
110 {
111 while ((strat->Ll >= 0))
112 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
113 return FALSE;
114 }
115 }
116 return b; // return TRUE if sp was changed, FALSE if not
117}
int BOOLEAN
Definition: auxiliary.h:87
#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
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

◆ customstd()

int SI_MOD_INIT() customstd ( SModulFunctions p)

Definition at line 653 of file customstd.cc.

654{
655 // p->iiAddCproc("std_demo","std_with_display",FALSE,std_with_display);
656 p->iiAddCproc("customstd.lib","satstd",FALSE,satstd);
657 // p->iiAddCproc("std_demo","satstdWithInitialCheck",FALSE,satstdWithInitialCheck);
658 p->iiAddCproc("customstd.lib","monomialabortstd",FALSE,monomialabortstd);
659 // PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
660 p->iiAddCproc("customstd.lib","std_print_spoly",FALSE,std_print_spoly);
661 p->iiAddCproc("customstd.lib","syz_print_spoly",FALSE,std_print_spoly);
662
663 return (MAX_TOK);
664}
static BOOLEAN satstd(leftv res, leftv args)
Definition: customstd.cc:40
static BOOLEAN std_print_spoly(leftv res, leftv args)
Definition: customstd.cc:169
static BOOLEAN monomialabortstd(leftv res, leftv args)
Definition: customstd.cc:455
@ MAX_TOK
Definition: tok.h:218

◆ idGroebner_print()

static ideal idGroebner_print ( ideal  temp,
int  syzComp,
intvec w = NULL,
tHomog  hom = testHomog 
)
static

Definition at line 189 of file customstd.cc.

190{
191 ideal temp1;
192 if (w==NULL)
193 {
194 if (hom==testHomog)
195 hom=(tHomog)idHomModule(temp,currRing->qideal,&w); //sets w to weight vector or NULL
196 }
197 else
198 {
199 w=ivCopy(w);
200 hom=isHomog;
201 }
202 temp1 = kStd(temp,currRing->qideal,hom,&w,NULL,syzComp,0,NULL,print_syz);
203 idDelete(&temp);
204 if (w!=NULL) delete w;
205 return temp1;
206}
static BOOLEAN print_syz(kStrategy strat)
Definition: customstd.cc:141
const CanonicalForm & w
Definition: facAbsFact.cc:51
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
intvec * ivCopy(const intvec *o)
Definition: intvec.h:145
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:2449
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
tHomog
Definition: structs.h:35
@ isHomog
Definition: structs.h:37
@ testHomog
Definition: structs.h:38

◆ idPrepare_print()

static ideal idPrepare_print ( ideal  h1,
ideal  h11,
tHomog  hom,
int  syzcomp,
intvec **  w 
)
static

Definition at line 208 of file customstd.cc.

209{
210 ideal h2,h22;
211 int j,k;
212 poly p,q;
213
214 assume(!idIs0(h1));
216 if (h11!=NULL)
217 {
218 k = si_max(k,(int)id_RankFreeModule(h11,currRing));
219 h22=idCopy(h11);
220 }
221 h2=idCopy(h1);
222 int i = IDELEMS(h2);
223 if (h11!=NULL) i+=IDELEMS(h22);
224 if (k == 0)
225 {
226 id_Shift(h2,1,currRing);
227 if (h11!=NULL) id_Shift(h22,1,currRing);
228 k = 1;
229 }
230 if (syzcomp<k)
231 {
232 Warn("syzcomp too low, should be %d instead of %d",k,syzcomp);
233 syzcomp = k;
235 }
236 h2->rank = syzcomp+i;
237
238 for (j=0; j<IDELEMS(h2); j++)
239 {
240 p = h2->m[j];
241 q = pOne();
242 pSetComp(q,syzcomp+1+j);
243 pSetmComp(q);
244 if (p!=NULL)
245 {
246 {
247 while (pNext(p)) pIter(p);
248 p->next = q;
249 }
250 }
251 else
252 h2->m[j]=q;
253 }
254 if (h11!=NULL)
255 {
256 ideal h=id_SimpleAdd(h2,h22,currRing);
257 id_Delete(&h2,currRing);
258 id_Delete(&h22,currRing);
259 h2=h;
260 }
261
262 idTest(h2);
263 #if 0
265 PrintS(" --------------before std------------------------\n");
266 ipPrint_MA0(TT,"T");
267 PrintLn();
268 idDelete((ideal*)&TT);
269 #endif
270
271 ideal h3;
272 if (w!=NULL) h3=idGroebner_print(h2,syzcomp,*w,hom);
273 else h3=idGroebner_print(h2,syzcomp,NULL,hom);
274 return h3;
275}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
static ideal idGroebner_print(ideal temp, int syzComp, intvec *w=NULL, tHomog hom=testHomog)
Definition: customstd.cc:189
#define Warn
Definition: emacs.cc:77
int j
Definition: facHensel.cc:110
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idTest(id)
Definition: ideals.h:47
ideal idCopy(ideal A)
Definition: ideals.h:60
void ipPrint_MA0(matrix m, const char *name)
Definition: ipprint.cc:57
STATIC_VAR Poly * h
Definition: janet.cc:971
#define assume(x)
Definition: mod2.h:389
#define pIter(p)
Definition: monomials.h:37
#define pSetComp(p, v)
Definition: polys.h:38
#define pSetmComp(p)
TODO:
Definition: polys.h:273
#define pOne()
Definition: polys.h:315
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5147
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
matrix id_Module2Matrix(ideal mod, const ring R)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
void id_Shift(ideal M, int s, const ring r)
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ idSyzygies_print()

static ideal idSyzygies_print ( ideal  h1,
tHomog  h,
intvec **  w 
)
static

Definition at line 277 of file customstd.cc.

278{
279 ideal s_h1;
280 int j, k, length=0,reg;
281 BOOLEAN isMonomial=TRUE;
282 int ii, idElemens_h1;
283
284 assume(h1 != NULL);
285
286 idElemens_h1=IDELEMS(h1);
287#ifdef PDEBUG
288 for(ii=0;ii<idElemens_h1 /*IDELEMS(h1)*/;ii++) pTest(h1->m[ii]);
289#endif
290 if (idIs0(h1))
291 {
292 ideal result=idFreeModule(idElemens_h1/*IDELEMS(h1)*/);
293 return result;
294 }
295 int slength=(int)id_RankFreeModule(h1,currRing);
296 k=si_max(1,slength /*id_RankFreeModule(h1)*/);
297
298 assume(currRing != NULL);
299 ring orig_ring=currRing;
300 ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
301 rSetSyzComp(k,syz_ring);
302
303 if (orig_ring != syz_ring)
304 {
305 rChangeCurrRing(syz_ring);
306 s_h1=idrCopyR_NoSort(h1,orig_ring,syz_ring);
307 }
308 else
309 {
310 s_h1 = h1;
311 }
312
313 idTest(s_h1);
314
315 BITSET save_opt;
316 SI_SAVE_OPT1(save_opt);
318
319 ideal s_h3=idPrepare_print(s_h1,NULL,h,k,w); // main (syz) GB computation
320
321 SI_RESTORE_OPT1(save_opt);
322
323 if (orig_ring != syz_ring)
324 {
325 idDelete(&s_h1);
326 for (j=0; j<IDELEMS(s_h3); j++)
327 {
328 if (s_h3->m[j] != NULL)
329 {
330 if (p_MinComp(s_h3->m[j],syz_ring) > k)
331 p_Shift(&s_h3->m[j], -k,syz_ring);
332 else
333 p_Delete(&s_h3->m[j],syz_ring);
334 }
335 }
336 idSkipZeroes(s_h3);
337 s_h3->rank -= k;
338 rChangeCurrRing(orig_ring);
339 s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
340 rDelete(syz_ring);
341 #ifdef HAVE_PLURAL
342 if (rIsPluralRing(orig_ring))
343 {
344 id_DelMultiples(s_h3,orig_ring);
345 idSkipZeroes(s_h3);
346 }
347 #endif
348 idTest(s_h3);
349 return s_h3;
350 }
351
352 ideal e = idInit(IDELEMS(s_h3), s_h3->rank);
353
354 for (j=IDELEMS(s_h3)-1; j>=0; j--)
355 {
356 if (s_h3->m[j] != NULL)
357 {
358 if (p_MinComp(s_h3->m[j],syz_ring) <= k)
359 {
360 e->m[j] = s_h3->m[j];
361 isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
362 p_Delete(&pNext(s_h3->m[j]),syz_ring);
363 s_h3->m[j] = NULL;
364 }
365 }
366 }
367
368 idSkipZeroes(s_h3);
369
370 idDelete(&e);
371 assume(orig_ring==currRing);
372 idTest(s_h3);
373 if (currRing->qideal != NULL)
374 {
375 ideal ts_h3=kStd(s_h3,currRing->qideal,h,w);
376 idDelete(&s_h3);
377 s_h3 = ts_h3;
378 }
379 return s_h3;
380}
#define TRUE
Definition: auxiliary.h:100
static ideal idPrepare_print(ideal h1, ideal h11, tHomog hom, int syzcomp, intvec **w)
Definition: customstd.cc:208
return result
Definition: facAbsBiFact.cc:76
ideal idFreeModule(int i)
Definition: ideals.h:111
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
VAR unsigned si_opt_1
Definition: options.c:5
#define OPT_REDTAIL_SYZ
Definition: options.h:87
#define SI_SAVE_OPT1(A)
Definition: options.h:21
#define SI_RESTORE_OPT1(A)
Definition: options.h:24
#define Sy_bit(x)
Definition: options.h:31
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4706
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:313
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
void rChangeCurrRing(ring r)
Definition: polys.cc:15
#define pTest(p)
Definition: polys.h:414
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:261
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:205
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4444
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define BITSET
Definition: structs.h:16

◆ monomialabortstd()

static BOOLEAN monomialabortstd ( leftv  res,
leftv  args 
)
static

Definition at line 455 of file customstd.cc.

456{
457 if (args!=NULL)
458 {
459 if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
460 {
461 ideal I=(ideal)args->Data();
463 idSkipZeroes(I);
464 res->rtyp=IDEAL_CMD;
465 res->data=(char*)I;
466 return FALSE;
467 }
468 }
469 WerrorS("monomialabortstd: unexpected parameters");
470 return TRUE;
471}
int Typ()
Definition: subexpr.cc:1030
void * Data()
Definition: subexpr.cc:1173
leftv next
Definition: subexpr.h:86
static BOOLEAN abort_if_monomial_sp(kStrategy strat)
Definition: customstd.cc:92
CanonicalForm res
Definition: facAbsFact.cc:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284

◆ print_spoly()

static BOOLEAN print_spoly ( kStrategy  strat)
static

Definition at line 120 of file customstd.cc.

121{
122 char *s;
123 if (strat->P.t_p==NULL)
124 {
125 s=pString(strat->P.p);
126 }
127 else
128 {
129 poly p=strat->P.t_p;
130 s=p_String(strat->P.t_p,strat->tailRing);
131 }
132 FILE *f=fopen(si_filename,"a");
133 fwrite(s,strlen(s),1,f);
134 fwrite("\n",1,1,f);
135 fflush(f);
136 fclose(f);
137 return FALSE; // return TRUE if sp was changed, FALSE if not
138}
FILE * f
Definition: checklibs.c:9
ring tailRing
Definition: kutil.h:343
STATIC_VAR char * si_filename
Definition: customstd.cc:119
const CanonicalForm int s
Definition: facAbsFact.cc:51
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:322
char * pString(poly p)
Definition: polys.h:306

◆ print_syz()

static BOOLEAN print_syz ( kStrategy  strat)
static

Definition at line 141 of file customstd.cc.

142{
143 char *s=NULL;
144 if (strat->P.t_p==NULL)
145 {
146 if (pGetComp(strat->P.p)>=strat->syzComp)
147 s=pString(strat->P.p);
148 }
149 else
150 {
151 if (p_GetComp(strat->P.t_p,strat->tailRing)>=strat->syzComp)
152 s=p_String(strat->P.t_p,strat->tailRing);
153 }
154 if (s!=NULL)
155 {
156 size_t len=strlen(si_filename)+12;
157 char *fn=(char*)malloc(len);
158 snprintf(fn,len, "%s.%d",si_filename,si_filenr);
159 si_filenr++;
160 FILE *f=fopen(fn,"w");
161 fwrite(s,strlen(s),1,f);
162 fwrite("\n",1,1,f);
163 fclose(f);
164 free(fn);
165 }
166 return FALSE; // return TRUE if sp was changed, FALSE if not
167}
unsigned syzComp
Definition: kutil.h:354
STATIC_VAR int si_filenr
Definition: customstd.cc:140
#define p_GetComp(p, r)
Definition: monomials.h:64
#define free
Definition: omAllocFunc.c:14
void * malloc(size_t size)
Definition: omalloc.c:85
#define pGetComp(p)
Component.
Definition: polys.h:37

◆ satstd()

static BOOLEAN satstd ( leftv  res,
leftv  args 
)
static

Definition at line 40 of file customstd.cc.

41{
42 leftv u = args;
43 if ((u!=NULL)
44 && ((u->Typ()==IDEAL_CMD)||(u->Typ()==MODUL_CMD)))
45 {
46 ideal I=(ideal)u->Data();
47 leftv v = u->next;
48
49 res->rtyp=IDEAL_CMD;
50 ideal J;
51 if (v==NULL)
52 {
54 }
55 else
56 {
57 if (v->Typ()==IDEAL_CMD)
58 {
59 J = (ideal) v->Data();
60 }
61 else
62 {
63 args->CleanUp();
64 WerrorS("satstd: unexpected parameters");
65 return TRUE;
66 }
67 }
68 I=id_Satstd(I,J,currRing);
69
70#if 0 /* unused */
71 if (idealCache)
72 {
74 res->data = (char*) idealCache;
75 idealCache = NULL;
76 }
77 else
78#endif
79 {
80 idSkipZeroes(I);
81 res->data=(char*)I;
82 }
83 if (v==NULL) id_Delete(&J,currRing);
84 args->CleanUp();
86 return (res->data==NULL);
87 }
88 WerrorS("satstd: unexpected parameters");
89 return TRUE;
90}
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
@ MODUL_CMD
Definition: grammar.cc:287
ideal id_Satstd(const ideal I, ideal J, const ring r)
Definition: ideals.cc:3116
#define setFlag(A, F)
Definition: ipid.h:113
#define FLAG_STD
Definition: ipid.h:106
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
Definition: simpleideals.cc:98

◆ std_print_spoly()

static BOOLEAN std_print_spoly ( leftv  res,
leftv  args 
)
static

Definition at line 169 of file customstd.cc.

170{
171 if (args!=NULL)
172 {
173 if ((args->Typ()==IDEAL_CMD) && (args->next!=NULL)
174 && (args->next->Typ()==STRING_CMD))
175 {
176 si_filename=(char*)args->next->Data();
177 ideal I=(ideal)args->Data();
179 idSkipZeroes(I);
180 res->rtyp=IDEAL_CMD;
181 res->data=(char*)I;
182 return FALSE;
183 }
184 }
185 WerrorS("std_print_spoly: unexpected parameters");
186 return TRUE;
187}
static BOOLEAN print_spoly(kStrategy strat)
Definition: customstd.cc:120
@ STRING_CMD
Definition: tok.h:185

◆ syz_print_spoly()

static BOOLEAN syz_print_spoly ( leftv  res,
leftv  args 
)
static

Definition at line 382 of file customstd.cc.

383{
384 if (args!=NULL)
385 {
386 if (((args->Typ()==IDEAL_CMD)||(args->Typ()==MODUL_CMD)) && (args->next!=NULL)
387 && (args->next->Typ()==STRING_CMD))
388 {
389 si_filename=(char*)args->next->Data();
390 si_filenr=0;
391 ideal v_id=(ideal)args->Data();
392 intvec *ww=(intvec *)atGet(args,"isHomog",INTVEC_CMD);
393 intvec *w=NULL;
394 tHomog hom=testHomog;
395 if (ww!=NULL)
396 {
397 if (idTestHomModule(v_id,currRing->qideal,ww))
398 {
399 w=ivCopy(ww);
400 int add_row_shift=w->min_in();
401 (*w)-=add_row_shift;
402 hom=isHomog;
403 }
404 else
405 {
406 //WarnS("wrong weights");
407 delete ww; ww=NULL;
408 hom=testHomog;
409 }
410 }
411 else
412 {
413 if (args->Typ()==IDEAL_CMD)
414 if (idHomIdeal(v_id,currRing->qideal))
415 hom=isHomog;
416 }
417 ideal S=idSyzygies_print(v_id,hom,&w);
418 res->data = (char *)S;
419 res->rtyp=args->Typ();
420 if (hom==isHomog)
421 {
422 int vl=S->rank;
423 intvec *vv=new intvec(vl);
424 if ((args->Typ()==IDEAL_CMD)||(ww==NULL))
425 {
426 for(int i=0;i<vl;i++)
427 {
428 if (v_id->m[i]!=NULL)
429 (*vv)[i]=p_Deg(v_id->m[i],currRing);
430 }
431 }
432 else
433 {
435 for(int i=0;i<vl;i++)
436 {
437 if (v_id->m[i]!=NULL)
438 (*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
439 }
441 }
442 if (idTestHomModule(S,currRing->qideal,vv))
443 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
444 else
445 delete vv;
446 }
447 if (w!=NULL) delete w;
448 return FALSE;
449 }
450 }
451 WerrorS("syz_print_spoly: unexpected parameters");
452 return TRUE;
453}
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:132
Definition: intvec.h:23
static ideal idSyzygies_print(ideal h1, tHomog h, intvec **w)
Definition: customstd.cc:277
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition: ideals.cc:2077
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:91
#define omStrDup(s)
Definition: omAllocDecl.h:263
void p_SetModDeg(intvec *w, ring r)
Definition: p_polys.cc:3673
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
@ INTVEC_CMD
Definition: tok.h:101

Variable Documentation

◆ si_filename

STATIC_VAR char* si_filename

Definition at line 119 of file customstd.cc.

◆ si_filenr

STATIC_VAR int si_filenr

Definition at line 140 of file customstd.cc.