source: git/Singular/LIB/JMBTest.lib @ bbf49b8

spielwiese
Last change on this file since bbf49b8 was bbf49b8, checked in by Hans Schoenemann <hannes@…>, 10 years ago
add data types to procedures, p3
  • Property mode set to 100644
File size: 21.1 KB
Line 
1//////////////////////////////////////////////////////////////////////
2version="version JMBTest.lib 4.0.0.0 Jun_2013 "; // $Id$
3category="Algebraic Geometry";
4// summary description of the library
5info="
6LIBRARY:   JMBTest.lib  A library for Singular which performs JM basis test.
7AUTHOR:    Michela Ceria, email: michela.ceria@unito.it
8
9SEE ALSO:  JMSConst_lib
10KEYWORDS:  J-marked schemes
11
12OVERVIEW:
13The library performs the J-marked basis test, as described in [CR], [BCLR].
14Such a test is performed via the criterion explained in [BCLR],
15concerning Eliahou-Kervaire polynomials (EK from now on).
16We point out that all the polynomials are homogeneous
17and they must be arranged by degree.
18The fundamental steps are the following:@*
19-construct the Vm polynomials, via the algorithm VConstructor
20explained in [CR];@*
21-construct the Eliahou-Kervaire polynomials defined in [BCLR];@*
22-reduce the  Eliahou-Kervaire polynomials using the Vm's;@*
23-if it exist an Eliahou-Kervaire polynomial such that its reduction
24mod Vm is different from zero, the given one is not a J-Marked basis.
25
26The algorithm terminates only if the ordering is rp.
27Anyway, the number of reduction steps is bounded.
28
29REFERENCES:
30[CR] Francesca Cioffi, Margherita Roggero,Flat Families by Strongly
31Stable Ideals and a Generalization of Groebner Bases,
32J. Symbolic Comput. 46,  1070-1084, (2011).@*
33[BCLR] Cristina Bertone, Francesca Cioffi, Paolo Lella,
34Margherita Roggero, Upgraded methods for the effective
35computation of marked schemes on a strongly stable ideal,
36Journal of Symbolic Computation
37(2012), http://dx.doi.org/10.1016/j.jsc.2012.07.006 @*
38
39PROCEDURES:
40  Minimus(ideal)            minimal variable in an ideal
41  Maximus(ideal)               maximal variable in an ideal
42  StartOrderingV(list,list)     ordering of polynomials as in [BCLR]
43  TestJMark(list)           tests whether we have a J-marked basis
44";
45LIB "qhmoduli.lib";
46LIB "monomialideal.lib";
47LIB "ring.lib";
48////////////////////////////////////////////////////////////////////
49proc mod_init()
50"USAGE:     mod_init();
51RETURN:   struct: jmp
52EXAMPLE:  example  mod_init; shows an example"
53{
54newstruct("jmp", "poly h, poly t");
55}
56example
57{ "EXAMPLE:"; echo = 2;
58  mod_init();
59}
60////////////////////////////////////////////////////////////////////
61proc Terns(list G, int c)
62"USAGE:    Terns(G,c); G list, c int
63RETURN:   list: T
64NOTE:     Input is a list of J-marked  polynomials
65(arranged by degree) and an integer.
66EXAMPLE:  example Terns; shows an example"
67{
68list T=list();
69int z;
70 for(int k=1; k<=size(G[c]);k=k+1)
71    {
72//Loop on G[c] making positions of polynomials in G[c]
73      z=size(T);
74      T=insert(T,list(1,c,k) ,size(T));
75    }
76return(T);
77}
78example
79{ "EXAMPLE:"; echo = 2;
80ring r=0, (x,y,z), rp;
81jmp r1;
82r1.h=z^3;
83r1.t=poly(0);
84jmp r2;
85r2.h=z^2*y;
86r2.t=poly(0);
87jmp r3;
88r3.h=z*y^2 ;
89r3.t=-x^2*y;
90jmp r4;
91r4.h=y^5;
92r4.t=poly(0);
93list G2F=list(list(r1,r2,r3),list(r4));
94Terns(G2F, 1);
95Terns(G2F, 2);
96}
97////////////////////////////////////////////////////////////////////
98proc VConst(list G, int c)
99"USAGE:    VConst(G, c); G list, c int
100RETURN:   list: V
101NOTES: this procedure computes the Vm polynomials following the
102algorithm in [CR],but it only keeps in memory the monomials by
103which the G's must be multplied and their positions.
104EXAMPLE:  example VConst; shows an example"
105{
106jmp f=G[1][1];
107int aJ=deg(f.h);
108// minimal degree of polynomials in G
109//print(aJ);
110list V=list();
111V[1]=Terns(G,1);
112// V[1]=G[1] (keeping in memory only [head, position])
113//print(c-aJ+1);
114int i;
115int j;
116int m;
117list OO;
118jmp p;
119  for(m=2; m<=c-aJ+1; m=m+1)
120  {
121     //print("entro nel form");
122     if(m>size(G))
123        {V[m]=list();
124//If we have not G[m] we insert a list()
125        //print("vuota prima");
126        }
127     else
128        {V[m]=Terns(G,m);
129        //print("piena prima");
130        }
131     for(i=1; i<nvars(basering)+1; i=i+1)
132        {
133          //print("entrata fori");
134          //print(i);
135          for(j=1; j<=size(V[m-1]); j=j+1)
136             {
137                   p=G[V[m-1][j][2]][V[m-1][j][3]];
138                  //print(p.h);
139                  //print(p.t);
140                  //print(var(i));
141                  //print(Minimus(V[m-1][j][1]*p.h));
142               if(var(i)<=Minimus(variables(V[m-1][j][1]*p.h)))
143                  {
144//Can I multiply by the current variable?
145                    //print("minoremin");
146                    //print("fin qui ci sono");
147                     //print(V[m-1][j][1]);
148                     OO=list(var(i)*V[m-1][j][1],V[m-1][j][2],V[m-1][j][3]);
149                    V[m]=insert(V[m], OO ,size(V[m]));
150                  }
151             }
152        }
153  }
154return (V);}
155example
156{ "EXAMPLE:"; echo = 2;
157 ring r=0, (x,y,z), rp;
158jmp r1;
159r1.h=z^3;
160r1.t=poly(0);
161jmp r2;
162r2.h=z^2*y;
163r2.t=poly(0);
164jmp r3;
165r3.h=z*y^2 ;
166r3.t=-x^2*y;
167jmp r4;
168r4.h=y^5;
169r4.t=poly(0);
170list G2F=list(list(r1,r2,r3),list(r4));
171VConst(G2F,4,basering);}
172////////////////////////////////////////////////////////////////////
173proc Minimus(ideal L)
174"USAGE:    Minimus(L); G list, c int
175RETURN:   list: V
176NOTES: it returns the minimal variable generating the ideal L.@*
177The input must be an ideal generated by variables.
178EXAMPLE:  example Minimus; shows an example"
179{
180poly min=L[1];
181int i;
182for(i=2;i<=size(L); i++)
183  {
184    if(L[i]<min){min=L[i];}
185  }
186return(min);
187}
188example
189{ "EXAMPLE:"; echo = 2;
190 ring r=0, (x,y,z), rp;
191ideal I=y,x,z;
192Minimus(I);
193}
194////////////////////////////////////////////////////////////////////
195proc Maximus(ideal L)
196"USAGE:    Maximus(L); G list, c int
197RETURN:   list: V
198NOTES: it returns the maximal variable generating the ideal L.@*
199The input must be an ideal generated by variables.
200EXAMPLE:  example Maximus; shows an example"
201{
202poly max=L[1];
203int i;
204for(i=2;i<=size(L); i++)
205  {
206    if(L[i]>max){max=L[i];}
207  }
208return(max);
209}
210example
211{ "EXAMPLE:"; echo = 2;
212 ring r=0, (x,y,z), rp;
213ideal I=y,x,z;
214Maximus(I);
215}
216////////////////////////////////////////////////////////////////////
217proc GJmpMins(jmp P, jmp Q)
218"USAGE:    GJmpMins(P,Q); P jmp, Q jmp
219RETURN:   int: d
220EXAMPLE:  example GJmpMins; shows an example"
221{
222  int d=1;
223//-1=lower, 0=equal, 1=higher
224//At the beginning suppose Q is higher
225  if(deg(P.h)<deg(Q.h))
226     {
227//Compare degrees;
228      d=-1;
229      //print("Per Grado");
230     }
231  if(deg(P.h)==deg(Q.h))
232     {
233      if(P.h==Q.h)
234         {
235          if(P.t==Q.t)
236              {
237//head=tail
238               d=0;
239               //print("Uguali");
240              }
241         }
242     else
243        {
244//print(Minimus(variables(P.h/gcdMon(P.h,Q.h))));
245//print(Minimus(variables(Q.h/gcdMon(P.h,Q.h))));
246          if(Minimus(variables(P.h/gcdMon(P.h,Q.h)))<Minimus(variables(Q.h/gcdMon(P.h,Q.h))))
247             {
248             d=-1;
249            //print("Per Indice");
250             }
251        }
252     }
253 return(d);
254}
255example
256{ "EXAMPLE:"; echo = 2;
257 ring r=0, (x,y,z), rp;
258jmp p1;
259p1.h=poly(1);
260p1.t=poly(1);
261jmp p2;
262p2.h=x^2;
263p2.t=poly(0);
264jmp p3;
265p3.h=x;
266p3.t=poly(0);
267 GJmpMins(p1, p2);
268 GJmpMins(p2, p3);
269GJmpMins(p1,p1);
270}
271////////////////////////////////////////////////////////////////////
272proc TernCompare(list A, list B, list G)
273"USAGE:    TernCompare(A,B,C); A list, B list, G list
274RETURN:   int: d
275NOTE:     A and B are terns, while G is the given list of
276J-marked polynomials.
277EXAMPLE:  example TernCompare; shows an example"
278{
279int d=-1;
280//Start: A<B
281if(A[1]==B[1])
282  {
283   if(A[2]==B[2]&& A[3]==B[3])
284     {
285      //print("Uguali");
286      d=0;
287     }
288   else
289     {
290jmp g1=G[A[2]][A[3]];
291jmp g2=G[B[2]][B[3]];
292       if(GJmpMins(g1, g2)==1)
293          {
294            //print("Maggiore per il G");
295            d=1;
296          }
297     }
298  }
299else
300  {
301    if(A[1]>B[1])
302      {
303//the ordering MUST be rp
304        //print("Maggiore per Lex");
305        d=1;
306      }
307  }
308return(d);
309}
310example
311{ "EXAMPLE:"; echo = 2;
312 ring r=0, (x,y,z), rp;
313jmp r1;
314r1.h=z^3;
315r1.t=poly(0);
316jmp r2;
317r2.h=z^2*y;
318r2.t=poly(0);
319jmp r3;
320r3.h=z*y^2 ;
321r3.t=-x^2*y;
322jmp r4;
323r4.h=y^5;
324r4.t=poly(0);
325list G2F=list(list(r1,r2,r3),list(r4));
326TernCompare([1,1,1],[x,1,1],G2F);
327}
328////////////////////////////////////////////////////////////////////
329proc MinOfV(list V, list G)
330"USAGE:    Minimal(V,G); V list, G list
331RETURN:   int: R
332NOTE:     Input=lista(terne), G.
333EXAMPLE:  example Minimal; shows an example"
334{
335//Minimal element for a given degree
336list R=list();
337list MIN=V[1];
338int h=1;
339int i;
340for(i=2; i<=size(V); i++)
341    {
342//I consider the first as minimum
343//If I find something smaller I change minimum
344     if(TernCompare(V[i],MIN,G)<=0)
345       {
346        MIN=V[i];
347        h=i;
348       }
349    }
350//Return: [minimum,position of the minimum]
351R=MIN,h;
352return(R);
353}
354example
355{ "EXAMPLE:"; echo = 2;
356 ring r=0, (x,y,z), rp;
357jmp r1;
358r1.h=z^3;
359r1.t=poly(0);
360jmp r2;
361r2.h=z^2*y;
362r2.t=poly(0);
363jmp r3;
364r3.h=z*y^2 ;
365r3.t=-x^2*y;
366jmp r4;
367r4.h=y^5;
368r4.t=poly(0);
369list G2F=list(list(r1,r2,r3),list(r4));
370MinOfV(VConst(G2F,4,basering)[1],G2F);
371}
372////////////////////////////////////////////////////////////////////
373proc OrderingV(list V,list G,list R)
374"USAGE:   OrderingV(V,G,R); V list, G list, R list
375RETURN:   list: R
376NOTE:     Input: Vm,G,emptylist
377EXAMPLE:  example OrderingV; shows an example"
378{
379//Order V[m]
380//R  will contain results but at the beginning it is empty
381list M=list();
382if(size(V)==1)
383  {
384    R=insert(R,V[1],size(R));
385  }
386else
387  {
388   M=MinOfV(V,G);
389   R=insert(R,M[1],size(R));
390   V=delete(V,M[2]);
391//recursive call
392   R=OrderingV(V,G,R);
393  }
394return(R);
395}
396example
397{ "EXAMPLE:"; echo = 2;
398 ring r=0, (x,y,z), rp;
399jmp r1;
400r1.h=z^3;
401r1.t=poly(0);
402jmp r2;
403r2.h=z^2*y;
404r2.t=poly(0);
405jmp r3;
406r3.h=z*y^2;
407r3.t=-x^2*y;
408jmp r4;
409r4.h=y^5;
410r4.t=poly(0);
411list G2F=list(list(r1,r2,r3),list(r4));
412OrderingV(VConst(G2F,4,basering)[1],G2F,list());
413}
414////////////////////////////////////////////////////////////////////
415proc StartOrderingV(list V,list G)
416"USAGE:   StartOrdina(V,G); V list, G list
417RETURN:   list: R
418NOTE:     Input Vm,G. This procedure uses OrderingV to get
419the ordered polynomials as in [BCLR].
420EXAMPLE:  example StartOrderingV; shows an example"
421{
422 return(OrderingV(V,G, list()));
423}
424example
425{ "EXAMPLE:"; echo = 2;
426 ring r=0, (x,y,z), rp;
427jmp r1;
428r1.h=z^3;
429r1.t=poly(0);
430jmp r2;
431r2.h=z^2*y;
432r2.t=poly(0);
433jmp r3;
434r3.h=z*y^2;
435r3.t=-x^2*y;
436jmp r4;
437r4.h=y^5;
438r4.t=poly(0);
439list G2F=list(list(r1,r2,r3),list(r4));
440StartOrderingV(VConst(G2F,4,basering)[1],G2F);
441}
442////////////////////////////////////////////////////////////////////
443proc Multiply(list L, list G)
444"USAGE:    moltiplica(L,G); L list, G list
445RETURN:   jmp: K
446NOTE:     Input: a 3-ple,G. It performs the product associated
447to the 3-uple.
448EXAMPLE:  example Multiply; shows an example"
449{
450jmp g=G[L[2]][L[3]];
451jmp K;
452K.h=L[1]*g.h;
453K.t=L[1]*g.t;
454 return(K);
455}
456example
457{ "EXAMPLE:"; echo = 2;
458 ring r=0, (x,y,z), rp;
459 list P=x^2,1,1;
460jmp r1;
461r1.h=z^3;
462r1.t=poly(0);
463jmp r2;
464r2.h=z^2*y;
465r2.t=poly(0);
466jmp r3;
467r3.h=z*y^2 ;
468r3.t=-x^2*y;
469jmp r4;
470r4.h=y^5;
471r4.t=poly(0);
472list G2F=list(list(r1,r2,r3),list(r4));
473Multiply(P,G2F);
474}
475////////////////////////////////////////////////////////////////////
476proc IdealOfV(list V)
477"USAGE:    IdealOfV(V); V list
478RETURN:   ideal: I
479NOTES: this procedure takes a list of Vm's of a certain degree
480and construct their ideal, multiplying the head by the weighted
481variable t.
482EXAMPLE:  example IdealOfV; shows an example"
483{
484ideal I=0;
485int i;
486if (size(V)!=0)
487  {
488   list M=list();
489jmp g;
490   for(i=1; i<= size(V); i++)
491       {
492         g=V[i];
493         g.h=t*g.h;
494         M[i]=g.h+g.t;
495       }
496   I=M[1..size(M)];
497//print("IdealOfV");
498  //I=std(I);
499  }
500return(I);
501}
502example
503{ "EXAMPLE:"; echo = 2;
504 ring r=0, (x,y,z,t), rp;
505jmp r1;
506r1.h=z^3;
507r1.t=poly(0);
508jmp r2;
509r2.h=z^2*y;
510r2.t=poly(0);
511jmp r3;
512r3.h=z*y^2 ;
513r3.t=-x^2*y;
514jmp r4;
515r4.h=y^5;
516r4.t=poly(0);
517list G2F=list(list(r1,r2,r3),list(r4));
518IdealOfV(G2F[1]);
519}
520////////////////////////////////////////////////////////////////////
521proc NewWeight(int n)
522"USAGE:    NewWeight(n); n int
523RETURN:   intvec: u
524EXAMPLE:  example NewWeight; shows an example"
525{
526intvec u=0;
527u[n]=1;
528return(u);
529}
530example
531{ "EXAMPLE:"; echo = 2;
532 NewWeight(3);
533}
534////////////////////////////////////////////////////////////////////
535proc FinalVm(list V1 , list G1 ,def r)
536"USAGE:     FinalVm(V1, G1, r);  V1 list,  G1 list , r
537RETURN:   intvec: u
538EXAMPLE:  example NewWeight; shows an example"
539{
540//multiply and reduce, degree by degree
541intvec u=NewWeight(nvars(r)+1);
542list L=ringlist(r);
543L[2]=insert(L[2],"t",size(L[2]));
544//print(L[2]);
545list ordlist="a",u;
546L[3]=insert(L[3],ordlist,0);
547def H=ring(L);
548//print(V1);
549//print(G1);
550list M=list();
551jmp p;
552list N;
553poly q;
554poly s;
555int i;
556int j;
557for(i=1; i<=size(G1); i++)
558   {
559           N=list();
560           for(j=1; j<=size(G1[i]); j++)
561              {
562                p=G1[i][j];
563                q=p.h;
564                s=p.t;
565                N[j]=list(q,s);
566               }
567           M[i]=N;
568    }
569p.h=poly(0);
570p.t=poly(0);
571setring H;
572list R=list();
573list S=list();
574//print("anello definito");
575def V=imap(r,V1);
576//def G=imap(r,G1);
577//print(V);
578def MM=imap(r,M);
579list G=list();
580list N=list();
581for(i=1; i<=size(MM); i++)
582   {
583           for(j=1; j<=size(MM[i]); j++)
584              {
585                p.h=MM[i][j][1];
586                p.t=MM[i][j][2];
587                N[j]=p;
588               }
589           G[i]=N;
590    }
591ideal I=0;
592jmp LL;
593jmp UU;
594 for(i=1; i<=size(V);i++)
595    {
596       R[i]=list();
597       S[i]=list();
598       I=0;
599       for(j=1;j<=size(V[i]); j++)
600          {
601            LL=Multiply(V[i][j],G);
602            LL.t=reduce(t*LL.t,I);
603//I only reduce the tail
604              LL.t=subst(LL.t,t,1);
605              S[i]=insert(S[i],LL,size(S[i]));
606              LL.h=t*LL.h;
607            R[i]=insert(R[i],LL,size(R[i]));
608             UU=R[i][j];
609              I=I+ideal(UU.h+UU.t);
610              attrib(I,"isSB",1);
611          }
612    }
613list M=list();
614poly q;
615poly s;
616for(i=1; i<=size(S); i++)
617   {
618           N=list();
619           for(j=1; j<=size(S[i]); j++)
620              {
621                p=S[i][j];
622                q=p.h;
623                s=p.t;
624                N[j]=list(q,s);
625               }
626           M[i]=N;
627    }
628p.h=poly(0);
629p.t=poly(0);
630setring r;
631def MM=imap(H,M);
632list MMM=list();
633for(i=1; i<=size(MM); i++)
634   {
635           N=list();
636           for(j=1; j<=size(MM[i]); j++)
637              {
638                p.h=MM[i][j][1];
639                p.t=MM[i][j][2];
640                N[j]=p;
641               }
642           MMM[i]=N;
643    }
644return(MMM);
645}
646example
647{ "EXAMPLE:"; echo = 2;
648 ring r=0, (x,y,z), rp;
649jmp r1;
650r1.h=z^3;
651r1.t=poly(0);
652jmp r2;
653r2.h=z^2*y;
654r2.t=poly(0);
655jmp r3;
656r3.h=z*y^2 ;
657r3.t=-x^2*y;
658jmp r4;
659r4.h=y^5;
660r4.t=poly(0);
661list G2F=list(list(r1,r2,r3),list(r4));
662 FinalVm(VConst(G2F,6,r) , G2F, r);
663}
664////////////////////////////////////////////////////////////////////
665proc ConstructorMain(list G, int c,def r)
666"USAGE:    Costruttore(G,c); G list, c int
667RETURN:   list: R
668NOTE:     At the end separated by degree.
669EXAMPLE:  example Costruttore; shows an example"
670{
671list V=list();
672V= VConst(G,c);
673//print("VConst");
674//V non ordered
675list L=list();
676list R=list();
677int i;
678// head, position
679//order the different degrees
680for(i=1; i<=size(V); i++)
681   {
682    L[i]=StartOrderingV(V[i], G);
683   }
684//multiply and reduce
685//print("Ordinare");
686R=FinalVm(L, G, r);
687//print("FinalVm");
688return(R);
689}
690example
691{ "EXAMPLE:"; echo = 2;
692 ring r=0, (x,y,z), rp;
693jmp r1;
694r1.h=z^3;
695r1.t=poly(0);
696jmp r2;
697r2.h=z^2*y;
698r2.t=poly(0);
699jmp r3;
700r3.h=z*y^2 ;
701r3.t=-x^2*y;
702jmp r4;
703r4.h=y^5;
704r4.t=poly(0);
705list G2F=list(list(r1,r2,r3),list(r4));
706ConstructorMain(G2F,6,r);
707}
708////////////////////////////////////////////////////////////////////
709proc EKCouples(jmp A, jmp B)
710"USAGE:    CoppiaEK(A,B); A list, B list
711RETURN:   list: L
712NOTE:     At the end the monomials involved by EK.
713EXAMPLE:  example EKCouples; shows an example"
714{
715poly E;
716list L=0,0;
717string s=varstr(basering);
718list VVV=varstr(basering);
719//L will contain results
720poly h=Minimus(variables(A.h));
721//print(h);
722int l=findvars(h,1)[2][1];
723if(l!=nvars(basering))
724 {
725//print("vero");
726//print(l);
727  for(int j=l+1;j<=nvars(basering); j++)
728   {
729    //print("entrata");
730    //print(var(j));
731    E=var(j)*A.h/B.h;
732//Candidate for * product
733    //print(E);
734    if(E!=0)
735      {
736        //print("primo if passato");
737        if(Minimus(variables(B.h))>=Maximus(variables(E)))
738           {
739//Does it work with * ?
740            //print("secondo if passato");
741            L[1]=j;
742            L[2]=E;
743            break;
744           }
745      }
746   }
747  }
748return (L);
749}
750example
751{ "EXAMPLE:"; echo = 2;
752 ring r=0, (x,y,z), rp;
753jmp A;
754A.h=y*z^2;
755A.t=poly(0);
756jmp B;
757B.h=y^2*z;
758B.t=poly(0);
759EKCouples(A,B);
760EKCouples(B,A);
761}
762////////////////////////////////////////////////////////////////////
763proc EKPolys(list G)
764"USAGE:    PolysEK(G); G list
765RETURN:   list: EK, list: D
766NOTE:     At the end EK polynomials and their degrees
767
768EXAMPLE:  example PolysEK; shows an example"
769{
770list D=list();
771list C=list();
772list N=0,0;
773list EK=list();
774int i;
775int j;
776int k;
777int l;
778jmp p;
779for(i=1; i<=size(G); i++)
780   {
781     for(j=1; j<=size(G[i]); j++)
782        {
783         for(k=1; k<=size(G); k++)
784             {
785               for(l=1; l<=size(G[k]); l++)
786                  {
787                     if(i!=k||j!=l)
788                       {
789//Loop on polynomials
790                        C=EKCouples(G[i][j], G[k][l]);
791//print("coppia");
792                        if(C[2]!=0)
793                          {
794                           C=insert(C,list(i,j,k,l),size(C));
795                           EK=insert(EK,C,size(EK));
796                           p=G[k][l];
797                           D=insert(D,deg(C[2]*p.h),size(D));
798                          }
799                       }
800                  }
801             }
802        }
803   }
804//Double Return
805return(EK, D);
806}
807example
808{ "EXAMPLE:"; echo = 2;
809  ring r=0, (x,y,z), rp;
810jmp r1;
811r1.h=z^3;
812r1.t=poly(0);
813jmp r2;
814r2.h=z^2*y;
815r2.t=poly(0);
816jmp r3;
817r3.h=z*y^2;
818r3.t=-x^2*y;
819jmp r4;
820r4.h=y^5;
821r4.t=poly(0);
822list G2F=list(list(r1,r2,r3),list(r4));
823EKPolys(G2F);
824}
825////////////////////////////////////////////////////////////////////
826proc EKPolynomials(list EK, list G)
827"USAGE:     EKPolynomials(EK,G); EK list, G list
828RETURN:   list: p
829NOTE:     At the end I obtain the EK polynomials and
830their degrees.
831EXAMPLE:  example SpolyEK; shows an example"
832{
833jmp u=G[EK[3][1]][EK[3][2]];
834jmp q=G[EK[3][3]][EK[3][4]];
835return(var(EK[1])*(u.h+u.t)-EK[2]*(q.h+q.t));
836}
837example
838{ "EXAMPLE:"; echo = 2;
839 ring r=0, (x,y,z), rp;
840jmp r1;
841r1.h=z^3;
842r1.t=poly(0);
843jmp r2;
844r2.h=z^2*y;
845r2.t=poly(0);
846jmp r3;
847r3.h=z*y^2;
848r3.t=-x^2*y;
849jmp r4;
850r4.h=y^5;
851r4.t=poly(0);
852list G2F=list(list(r1,r2,r3),list(r4));
853list EK,D=EKPolys(G2F);
854EKPolynomials(EK[1],G2F);
855}
856////////////////////////////////////////////////////////////////////
857proc TestJMark(list G1,def r)
858"USAGE:    TestJMark(G);  G list
859RETURN:    int: i
860NOTE:
861This procedure performs J-marked basis test.@*
862The input is a list of J-marked polynomials (jmp) arranged
863by degree, so G1 is a list of list.@*
864The output is a boolean evaluation:
865True=1/False=0
866EXAMPLE:  example TestJMark; shows an example"
867{int flag=1;
868if(size(G1)==1 && size(G1[1])==1)
869 {
870  //Hypersurface
871  print("Only One Polynomial");
872  flag=1;
873 }
874else
875  {
876   int d=0;
877   list EK,D=EKPolys(G1);
878//print("PolysEK");
879   //I found EK couples
880   int massimo=Max(D);
881   list V1=ConstructorMain(G1,massimo,r);
882//print("Costruttore");
883//print(V1);
884   jmp mi=V1[1][1];
885   int minimo=Min(deg(mi.h));
886   intvec u=NewWeight(nvars(r)+1);
887list L=ringlist(r);
888L[2]=insert(L[2],"t",size(L[2]));
889//print(L[2]);
890list ordlist="a",u;
891L[3]=insert(L[3],ordlist,0);
892def H=ring(L);
893list JJ=list();
894jmp pp;
895jmp qq;
896int i;
897int j;
898list NN;
899for(i=size(V1);i>0;i--)
900    {
901     NN=list();
902     for(j=size(V1[i]);j>0;j--)
903         {
904          //print(j);
905          pp=V1[i][j];
906          NN[j]=list(pp.h,pp.t);
907          }
908//print(NN);
909JJ[i]=NN;
910//print(JJ[i]);
911//print(i);
912    }
913//print(JJ);
914list KK=list();
915list UU=list();
916//jmp qq;
917for(i=size(G1);i>0;i--)
918    {
919     for(j=size(G1[i]);j>0;j--)
920         {
921          //print(j);
922          qq=G1[i][j];
923          UU[j]=list(qq.h,qq.t);
924          }
925//print(UU);
926KK[i]=UU;
927    }
928setring H;
929//I defined the new ring with the weighted
930//variable t
931poly p;
932//print("anello definito");
933def JJJ=imap(r,JJ);
934def EK=imap(r,EK);
935//print(flag);
936//imap(r,D);
937list V=list();
938jmp fp;
939//int i;
940//int j;
941list N;
942for(i=size(JJJ); i>0; i--)
943   {
944           N=list();
945           for(j=size(JJJ[i]); j>0; j--)
946              {
947                fp.h=JJJ[i][j][1];
948                fp.t=JJJ[i][j][2];
949                N[j]=fp;
950               }
951           V[i]=N;
952            }
953//print(V);
954def KKJ=imap(r,KK);
955list G=list();
956list U=list();
957for(i=1; i<=size(KKJ); i++)
958   {
959           for(j=1; j<=size(KKJ[i]); j++)
960              {
961                fp.h=KKJ[i][j][1];
962                fp.t=KKJ[i][j][2];
963                U[j]=fp;
964               }
965           G[i]=U;
966    }
967// print(V);
968//print(G);
969//I imported in H everithing I need
970poly q;
971ideal I;
972   for(j=1; j<=size(EK);j++)
973      {
974       d=D[j];
975       p=EKPolynomials(EK[j],G);
976       //print("arrivo");
977       I=IdealOfV(V[d-minimo+1]);
978attrib(I,"isSB",1);
979//print(I);
980q=reduce(t*p,I);
981//print(I[1]);
982//print(t*p);
983q=subst(q,t,1);
984//I reduce all the EK polynomials
985//       q=RiduzPoly(V[d-minimo+1], p);
986       if(q!=0)
987         {
988//check whether reduction is 0
989          print("NOT A BASIS");
990         flag=0;
991          break;
992         }
993     }
994  }
995//print(flag);
996setring r;
997//typeof(flag);
998return(flag);
999}
1000example
1001{ "EXAMPLE:"; echo = 2;
1002 ring r=0, (x,y,z), rp;
1003jmp r1;
1004r1.h=z^3;
1005r1.t=poly(0);
1006jmp r2;
1007r2.h=z^2*y;
1008r2.t=poly(0);
1009jmp r3;
1010r3.h=z*y^2 ;
1011r3.t=-x^2*y;
1012jmp r4;
1013r4.h=y^5;
1014r4.t=poly(0);
1015list G2F=list(list(r1,r2,r3),list(r4));
1016TestJMark(G2F,r);
1017}
Note: See TracBrowser for help on using the repository browser.