source: git/Singular/LIB/swalk.lib @ ffd4a9

spielwiese
Last change on this file since ffd4a9 was ffd4a9, checked in by Stephan Oberfranz <oberfran@…>, 10 years ago
Groebner Walk, Sagbi Walk
  • Property mode set to 100755
File size: 20.4 KB
Line 
1////////////////////////////////////////////////////////
2version="version swalk.lib 4.0.0.0 Jun_2013 "; // $Id$
3category="Commutative Algebra";
4info="
5LIBRARY: swalk.lib               Sagbi Walk Conversion Algorithm
6AUTHOR:  Junaid Alam Khan        junaidalamkhan@gmail.com
7
8OVERVIEW:
9 A library for computing the Sagbi basis of subalgebra through Sagbi walk
10 algorithm.
11
12THEORY: The concept of SAGBI ( Subalgebra Analog to Groebner Basis for Ideals)
13 is defined in [L. Robbiano, M. Sweedler: Subalgebra Bases, volume 42, volume
14 1430 of Lectures Note in Mathematics series, Springer-Verlag (1988),61-87].
15 The Sagbi Walk algorithm is the subalgebra analogue to the Groebner Walk
16 algorithm which has been proposed in [S. Collart, M. Kalkbrener and D.Mall:
17 Converting bases with the Grobner Walk. J. Symbolic Computation 24 (1997),
18 465-469].
19
20PROCEDURE:
21 swalk(ideal[,intvec]);   Sagbi basis of subalgebra via Sagbi walk algorithm
22";
23
24LIB "sagbi.lib";
25LIB "crypto.lib";
26LIB "atkins.lib";
27LIB "random.lib";
28//////////////////////////////////////////////////////////////////////////////
29proc swalk(ideal Gox, list #)
30"USAGE:  swalk(i[,v,w]); i ideal, v,w int vectors
31RETURN: The sagbi basis of the subalgebra defined by the generators of i,
32        calculated via the Sagbi walk algorithm from the ordering dp to lp
33        if v,w are not given (resp. from the ordering (a(v),lp) to the
34        ordering (a(w),lp) if v and w are given).
35EXAMPLE: example swalk; shows an example
36"
37{
38  /* we use ring with ordering (a(...),lp,C) */
39  list OSCTW    = OrderStringalp_NP("al", #);//"dp"
40  string ord_str =   OSCTW[2];
41  intvec icurr_weight   =   OSCTW[3]; /* original weight vector */
42  intvec itarget_weight =   OSCTW[4]; /* terget weight vector */
43  kill OSCTW;
44      option(redSB);
45  def xR = basering;
46  list rl=ringlist(xR);
47  if(size(#) == 0)
48  {
49    rl[3][1][1]="dp";
50  }
51  def ostR=ring(rl);
52  setring ostR;
53  def new_ring = basering;
54  ideal Gnew = fetch(xR, Gox);
55  Gnew=sagbi(Gnew,1);
56  Gnew=interreduceSd(Gnew);
57  vector curr_weight=changeTypeInt(icurr_weight);
58  vector target_weight=changeTypeInt(itarget_weight);
59  curr_weight;
60  ideal Gold;
61  list l;
62  intvec v;
63  int n=0;
64  while(n==0)
65    {
66       Gold=Gnew;
67       def old_ring=new_ring;
68       setring old_ring;
69       number ulast;
70       kill new_ring;
71       if(curr_weight==target_weight){n=1;}
72       else {
73              l=collectDiffExpo(Gold);
74              ulast=last(curr_weight, target_weight, l);
75              vector new_weight=(1-ulast)*curr_weight+ulast*target_weight;
76              vector w=cleardenom(new_weight);
77              v=changeType(w);
78              list p= ringlist(old_ring);
79              p[3][1][2]= v;
80              def new_ring=ring(p);
81              setring new_ring;
82              ideal Gold=fetch(old_ring,Gold);
83              vector curr_weight=fetch(old_ring,new_weight);
84              vector target_weight=fetch(old_ring,target_weight);
85              kill old_ring;
86              ideal Gnew=Convert(Gold);
87              Gnew=interreduceSd(Gnew);
88         }
89    }
90   setring xR;
91   ideal result = fetch(old_ring, Gnew);
92   kill old_ring;
93   attrib(result,"isSB",1);
94   return (result);
95}
96example
97{
98  "EXAMPLE:";echo = 2;
99  ring r = 0,(x,y), lp;
100  ideal I =x2,y2,xy+y,2xy2+y3;
101  swalk(I);
102}
103//////////////////////////////////////////////////////////////////////////////
104proc rswalk(ideal Gox, int weight_rad, int pdeg, list #)
105"USAGE:  rswalk(i[,v,w]); i ideal, v,w int vectors
106RETURN: The sagbi basis of the subalgebra defined by the generators of i,
107        calculated via the Sagbi walk algorithm from the ordering dp to lp
108        if v,w are not given (resp. from the ordering (a(v),lp) to the
109        ordering (a(w),lp) if v and w are given).
110EXAMPLE: example swalk; shows an example
111"
112{
113  /* we use ring with ordering (a(...),lp,C) */
114  list OSCTW    = OrderStringalp_NP("al", #);//"dp"
115  string ord_str =   OSCTW[2];
116  intvec icurr_weight   =   OSCTW[3]; /* original weight vector */
117  intvec itarget_weight =   OSCTW[4]; /* terget weight vector */
118  kill OSCTW;
119  option(redSB);
120  def xR = basering;
121  list rl=ringlist(xR);
122  rl[3][1][1]="dp";
123  def ostR=ring(rl);
124  setring ostR;
125  def new_ring = basering;
126  ideal Gnew = fetch(xR, Gox);
127  Gnew=sagbi(Gnew,1);
128  Gnew=interreduceSd(Gnew);
129  vector curr_weight=changeTypeInt(icurr_weight);
130  vector target_weight=changeTypeInt(itarget_weight);
131  ideal Gold;
132  list l;
133  intvec v;
134  int n=0;
135  while(n==0)
136    {
137       Gold=Gnew;
138       def old_ring=new_ring;
139       setring old_ring;
140       
141       kill new_ring;
142       if(curr_weight==target_weight){n=1;}
143       else {
144              l=collectDiffExpo(Gold);
145              vector new_weight=RandomNextWeight(Gold, l, curr_weight, target_weight, weight_rad, pdeg);
146              vector w=cleardenom(new_weight);
147              v=changeType(w);
148              list p= ringlist(old_ring);
149              p[3][1][2]= v;
150              def new_ring=ring(p);
151              setring new_ring;
152              ideal Gold=fetch(old_ring,Gold);
153              vector curr_weight=fetch(old_ring,new_weight);
154              vector target_weight=fetch(old_ring,target_weight);
155              kill old_ring;
156              ideal Gnew=Convert(Gold);
157              Gnew=interreduceSd(Gnew);
158           }
159    }
160   setring xR;
161   ideal result = fetch(old_ring, Gnew);
162   attrib(result,"isSB",1);
163   return (result);
164}
165example
166{
167  "EXAMPLE:";echo = 2;
168  ring r = 0,(x,y), lp;
169  ideal I =x2,y2,xy+y,2xy2+y3;
170  swalk(I,7);
171}
172//////////////////////////////////////////////////////////////////////////////
173static proc inprod(vector v,vector w)
174"USAGE:  inprod(v,w); v,w vectors
175RETURN:  inner product of vector v and w
176EXAMPLE: example inprod; shows an example
177"
178{
179  poly a;
180  int i;
181  for(i=1;i<=nvars(basering);i++)
182    {
183      a=a+v[i]*w[i] ;
184    }
185  return(a);
186}
187example
188{ "EXAMPLE:"; echo = 2;
189   ring r=0,(x,y,z),lp;
190   vector v =[1,-1,2];
191   vector w = [1,0,3];
192   inprod(v,w);
193}
194
195//////////////////////////////////////////////////////////////////////////////
196static proc diffExpo(poly f)
197"USAGE:  diffExpo(f); f polynomial
198RETURN:  a list of integers vectors which are the difference of exponent
199         vector of leading monomial of f with the exponent vector of of other
200         monmials in f.
201EXAMPLE: example diffExpo; shows an example
202"
203{
204  list l;
205  int i;
206  intvec v;
207  for(i=size(f);i>=2;i--)
208   {
209     v=leadexp(f[1])-leadexp(f[i]);
210     l[i-1]=v;
211   }
212 return(l);
213}
214example
215{ "EXAMPLE:"; echo = 2;
216   ring r=0,(x,y,z),lp;
217   poly f = xy+z2 ;
218   diffExpo(f);
219}
220
221//////////////////////////////////////////////////////////////////////////////
222static proc collectDiffExpo( ideal i)
223"USAGE:  collectDiffExpo(i); i ideal
224RETURN:  a list which contains diffExpo(f), for all generators f of ideal i
225EXAMPLE: example collectDiffExpo; shows an example
226"
227{
228 list l;
229 int j;
230 for(j=ncols(i); j>=1;j--)
231  {
232   l[j]=diffExpo(i[j]);
233  }
234  return(l);
235}
236example
237{ "EXAMPLE:"; echo = 2;
238   ring r=0,(x,y,z),lp;
239   ideal I = xy+z2,y3+x2y2;
240   collectDiffExpo(I);
241}
242
243//////////////////////////////////////////////////////////////////////////////
244static proc changeType(vector v)
245"USAGE:  changeType(v); v  vector
246RETURN:  change the type of  vector
247         v into integer vector.
248
249EXAMPLE: example changeType; shows an example
250"
251{
252  intvec w ;
253  int j ;
254  for(j=1;j<=nvars(basering);j++)
255   {
256     w[j]=int(leadcoef(v[j]));
257   }
258  return(w);
259}
260example
261{ "EXAMPLE:"; echo = 2;
262   ring r=0,(x,y,z),lp;
263   vector v = [2,1,3];
264   changeType(v);
265}
266//////////////////////////////////////////////////////////////////////////////
267static proc changeTypeInt( intvec v)
268"USAGE:  changeTypeInt(v); v integer vector
269RETURN:  change the type of integer vector v into vector.
270EXAMPLE: example changeTypeInt; shows an example
271"
272{
273   vector w;
274   int j ;
275   for(j=1;j<=size(v);j++)
276   {
277     w=w+v[j]*gen(j);
278   }
279   return(w);
280}
281example
282{ "EXAMPLE:"; echo = 2;
283   ring r=0,(x,y,z),lp;
284   intvec v = 4,2,3;
285   changeTypeInt(v);
286}
287
288//////////////////////////////////////////////////////////////////////////////
289static proc test_in_cone(vector w, list l)
290{
291 int i,j,k;
292 vector v;
293 poly n;
294 number a;
295 for(i=1;i<=size(l);i++)
296 {
297    for(j=1;j<=size(l[i]);j++)
298    {
299        v=0;
300        for(k=1;k<=size(l[i][j]);k++)
301        {
302            v=v+l[i][j][k]*gen(k);
303        }
304        n = inprod(w,v);
305        a = leadcoef(n);
306        if(a<0)
307        {
308           return(0);
309        }
310    }
311 }
312 return(1);
313}
314
315
316//////////////////////////////////////////////////////////////////////////////
317static proc last( vector c, vector t,list l)
318"USAGE: last(c,t,l); c,t vectors, l list
319RETURN: a  parametric value which corresponds to vector lies along the path
320        between c and t using list l of integer vectors. This vector is the
321        last vector on old Sagbi cone
322EXAMPLE: example last; shows an example
323"
324{
325 number ul=1;
326 int i,j,k;
327 number a,b,z,u;
328 poly n,q;
329 vector v;
330 for(i=1;i<=size(l);i++)
331 {
332    for(j=1;j<=size(l[i]);j++)
333    {
334        v=0;
335        for(k=1;k<=size(l[i][j]);k++)
336        {
337            v=v+l[i][j][k]*gen(k);
338        }
339        n= inprod(c,v);
340        q= inprod(t,v);
341        a=leadcoef(n);
342        b=leadcoef(q);
343        z=a-b;
344        if(b<0)
345            {
346            u=a/z;
347            if(u<ul)
348            {
349               ul=u;
350             }
351        }
352    }
353 }~
354 kill a,b,z,n,q,u;
355 return(ul);
356}
357example
358{ "EXAMPLE:"; echo = 2;
359   ring r=0,(x,y,z),(a(0,0,1),lp);
360   vector v= [0,0,1];
361   vector w=[1,0,0];
362   ideal i=z2+xy,x2y2+y3;
363    list l=collectDiffExpo(i);
364    last(v,w,l)
365}
366
367//////////////////////////////////////////////////////////////////////////////
368static proc initialForm(poly P)
369"USAGE:  initialForm(P); P polynomial
370RETURN:  sum of monomials of P with maximum w-degree
371         where w is first row of matrix of a given monomial ordering
372EXAMPLE: example initialForm; shows an example
373"
374{
375 poly q;
376 int i=1;
377 while(deg(P[i])==deg(P[1]))
378 {
379     q=q+P[i];
380     i++;
381     if(i>size(P)) {break;}
382 }
383 return(q);
384}
385example
386{ "EXAMPLE:"; echo = 2;
387   ring r=0,(x,y,z),dp;
388   poly f = x2+yz+z;
389   initialForm(f);
390}
391
392//////////////////////////////////////////////////////////////////////////////
393static proc Initial(ideal I)
394"USAGE:  Initial(I); I ideal
395RETURN:  an ideal which is generate by the InitialForm
396         of the generators of I.
397EXAMPLE: example Initial; shows an example
398"
399{
400 ideal J;
401 int i;
402 for(i=1;i<=ncols(I);i++)
403 {
404     J[i]=initialForm(I[i]);
405 }
406 return(J);
407}
408example
409{ "EXAMPLE:"; echo = 2;
410   ring r=0,(x,y,z),dp;
411   ideal I = x+1,x+y+1;
412   Initial(I);
413}
414
415//////////////////////////////////////////////////////////////////////////////
416static proc Lift(ideal In,ideal InG,ideal Gold)
417"USAGE:  Lift(In, InG, Gold); In, InG, Gold ideals;
418         Gold given by Sagbi basis {g_1,...,g_t},
419         In given by tne initial forms In(g_1),...,In(g_t),
420         InG = {h_1,...,h_s} a Sagbi basis of In
421RETURN:  P_j, a polynomial in K[y_1,..,y_t] such that h_j =
422         P_j(In(g_1),...,In_(g_t))
423         and return f_j = P_j(g_1,...,g_t)
424EXAMPLE: example Lift; shows an example
425"
426{
427  int i;
428  ideal J;
429  for(i=1;i<=ncols(InG);i++)
430  {
431    poly f=InG[i];
432    list l=algebra_containment(f,In,1);
433    def s=l[2];
434    map F=s,maxideal(1),Gold ;
435    poly g=F(check);
436    ideal k=g;
437    J=J+k;
438    kill g,l,s,F,f,k;
439  }
440  return(J);
441 }
442example
443{ "EXAMPLE:"; echo = 2;
444   ring r=0,(x,y,z),(a(2,0,3),lp);
445   ideal In = xy+z2,x2y2;
446   ideal InG=xy+z2,x2y2,xyz2+1/2z4;
447   ideal Gold=xy+z2,y3+x2y2;
448   Lift(In,InG,Gold);
449}
450//////////////////////////////////////////////////////////////////////////////
451static proc PertVectors(ideal Gold, vector target_weight, int pdeg)
452{
453int nV = nvars(basering);
454int nG = size(Gold);
455int i;
456number ntemp, maxAi, maxA;
457if(pdeg > nV || pdeg <= 0)
458  {
459    intvec v_null=0;
460    return v_null;
461  }
462if(pdeg == 1)
463  {
464    return target_weight;
465  }
466maxAi=0;
467for(i=1; i<=nV; i++)
468  {
469    ntemp = leadcoef(inprod(target_weight,gen(i)));
470    if(ntemp < 0)
471      {
472        ntemp = -ntemp;
473      }
474    if(maxAi < ntemp)
475      {
476        maxAi = ntemp;
477      }
478  }
479maxA = maxAi+pdeg-1;
480number epsilon = maxA*deg(Gold)+1;
481vector pert_weight = epsilon^(pdeg-1)*target_weight;
482for(i=2; i<=pdeg; i++)
483  {
484    pert_weight = pert_weight + epsilon^(pdeg-i)*gen(i);
485  }
486return(pert_weight);
487}
488
489
490//////////////////////////////////////////////////////////////////////////////
491static proc RandomNextWeight(ideal Gold, list L, vector curr_weight, vector target_weight,int weight_rad, int pdeg)
492"USAGE: RandomNextWeight(Gold, L, curr_weight, target_weight);
493RETURN: Intermediate next weight vector
494EXAMPLE: example RandomNextWeight; shows an example
495"
496{
497  int i,n1,n2,n3;
498  number norm, weight_norm;
499  def Rold = basering;
500  int nV = nvars(basering);
501  number ulast=last(curr_weight, target_weight, L);
502  vector new_weight=(1-ulast)*curr_weight+ulast*target_weight;
503  vector w1=cleardenom(new_weight);
504  intvec v1=changeType(w1);
505  list p= ringlist(Rold);
506  p[3][1][2]= v1;
507  def new_ring=ring(p);
508  setring new_ring;
509  ideal Gold = fetch(Rold, Gold);
510  n1=size(Initial(Gold));
511  setring Rold;
512  intvec next_weight;
513  kill new_ring;
514  while(1)
515  {
516    weight_norm = 0;
517    while(weight_norm == 0)
518    {
519      for(i=1; i<=nV; i++)
520      {
521        next_weight[i] = random(1,10000)-5000;
522        weight_norm = weight_norm + next_weight[i]^2;
523      }
524      norm = 0;
525      while(norm^2 < weight_norm)
526      {
527         norm=norm+1;
528      }
529      weight_norm = 1+norm;
530    }
531    new_weight = 0;
532    for(i=1; i<=nV;i++)
533    {
534      if(next_weight[i] < 0)
535      {
536        new_weight = new_weight + (1 + round(weight_rad*leadcoef(next_weight[i])/weight_norm))*gen(i);
537      }
538      else
539      {
540        new_weight = new_weight + ( round(weight_rad*leadcoef(next_weight[i])/weight_norm))*gen(i);
541      }
542    }
543    new_weight = new_weight + curr_weight;
544    if(test_in_cone(new_weight, L)==1)
545    {
546      break;
547    }
548  }
549  kill next_weight;
550  kill norm;
551  vector w2=cleardenom(new_weight);
552  intvec v2=changeType(w2);
553  p[3][1][2]= v2;
554  def new_ring=ring(p);
555  setring new_ring;
556  ideal Gold = fetch(Rold, Gold);
557  n2=size(Initial(Gold));
558  setring Rold;
559  kill new_ring;
560
561  vector w3=cleardenom(PertVectors(Gold,target_weight,pdeg));
562  intvec v3=changeType(w3);
563  p[3][1][2]= v1;
564  def new_ring=ring(p);
565  setring new_ring;
566  ideal Gold = fetch(Rold, Gold);
567  n3=size(Initial(Gold));
568  setring Rold;
569  kill new_ring;
570  kill p;
571
572  if(n2<n1)
573  {
574    if(n3<n2)
575    {
576      // n3<n2<n1
577      return(w3);
578    }
579    else
580    {
581      // n2<n1 und n2<=n3
582      return(w2);
583    }
584  }
585  else
586  {
587    if(n3<n1)
588    {
589      //n3<n1<=n2
590      return(w3);
591    }
592    else
593    {
594      // n1<=n3 und n1<=n2
595      return(w1);
596    }
597  }
598}
599
600//////////////////////////////////////////////////////////////////////////////
601static proc Convert( ideal Gold )
602"USAGE: Convert(I); I ideal
603RETURN: Convert old Sagbi basis into new Sagbi basis
604EXAMPLE: example Convert; shows an example
605"
606{
607 ideal In=Initial(Gold);
608 ideal InG=sagbi(In); //+In;
609 ideal Gnew=Lift(In,InG,Gold);
610 return(Gnew);
611}
612example
613{ "EXAMPLE:"; echo = 2;
614   ring r=0,(x,y,z),lp;
615   ideal I=xy+z2, y3+x2y2;
616   Convert(I);
617}
618
619//////////////////////////////////////////////////////////////////////////////
620static proc interreduceSd(ideal I)
621"USAGE:  interreduceSd(I); I ideal
622RETURN:  interreduceSd the set of generators if I with
623         respect to a given term ordering
624EXAMPLE: example interreduceSd; shows an example
625"
626{
627  list l,M;
628  ideal J,B;
629  int i,j,k;
630  poly f;
631  for(k=1;k<=ncols(I);k++)
632  {l[k]=I[k];}
633  for(j=1;j<=size(l);j++)
634  {
635     f=l[j];
636     M=delete(l,j);
637     for(i=1;i<=size(M);i++)
638     { B[i]=M[i];}
639     f=sagbiNF(f,B,1)[1];
640     J=J+f;
641  }
642  return(J);
643}
644example
645{ "EXAMPLE:"; echo = 2;
646   ring r=0,(x,y,z),lp;
647   ideal I = xy+z2,x2y2+y3;
648   interreduceSd(I);
649}
650
651//////////////////////////////////////////////////////////////////////////////
652static proc OrderStringalp(string Wpal,list #)
653{
654  int n= nvars(basering);
655  string order_str;
656  intvec curr_weight, target_weight;
657  curr_weight = system("Mivdp",n);
658  target_weight = system("Mivlp",n);
659
660   if(size(#) != 0)
661   {
662     if(size(#) == 1)
663     {
664       if(typeof(#[1]) == "intvec")
665       {
666         if(Wpal == "al"){
667           order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
668         }
669         else {
670           order_str = "(Wp("+string(#[1])+"),C)";
671         }
672         curr_weight = #[1];
673       }
674       else
675       {
676        if(typeof(#[1]) == "string")
677        {
678          if(#[1] == "Dp") {
679            order_str = "Dp";
680          }
681          else {
682            order_str = "dp";
683          }
684        }
685        else {
686          order_str = "dp";
687        }
688     }
689    }
690    else
691    {
692     if(size(#) == 2)
693     {
694       if(typeof(#[2]) == "intvec")
695       {
696         target_weight = #[2];
697       }
698       if(typeof(#[1]) == "intvec")
699       {
700         if(Wpal == "al"){
701           order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
702         }
703         else {
704           order_str = "(Wp("+string(#[1])+"),C)";
705         }
706         curr_weight = #[1];
707       }
708       else
709       {
710        if(typeof(#[1]) == "string")
711        {
712          if(#[1] == "Dp") {
713            order_str = "Dp";
714           }
715           else {
716              order_str = "dp";
717           }
718        }
719        else {
720           order_str = "dp";
721        }
722      }
723     }
724    }
725   }
726   else {
727     order_str = "dp";
728   }
729   list result;
730   result[1] = order_str;
731   result[2] = curr_weight;
732   result[3] = target_weight;
733   return(result);
734}
735
736//////////////////////////////////////////////////////////////////////////////
737static proc OrderStringalp_NP(string Wpal,list #)
738{
739  int n= nvars(basering);
740  string order_str = "dp";
741  int nP = 1;// call LatsGB to compute the wanted GB  by pwalk
742  intvec curr_weight = system("Mivdp",n); //define (1,1,...,1)
743  intvec target_weight = system("Mivlp",n); //define (1,0,...,0)
744  if(size(#) != 0)
745  {
746    if(size(#) == 1)
747    {
748      if(typeof(#[1]) == "intvec")
749      {
750        curr_weight = #[1];
751
752        if(Wpal == "al")
753        {
754          order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
755        }
756        else
757        {
758          order_str = "(Wp("+string(#[1])+"),C)";
759        }
760      }
761      else {
762        if(typeof(#[1]) == "int")
763        {
764          nP = #[1];
765        }
766        else
767        {
768          print("// ** the input must be \"(ideal, int)\" or ");
769          print("// **                   \"(ideal, intvec)\"");
770          print("// ** a lex. GB will be computed from \"dp\" to \"lp\"");
771        }
772      }
773    }
774    else
775    {
776     if(size(#) == 2)
777     {
778       if(typeof(#[1]) == "intvec" and typeof(#[2]) == "int")
779       {
780         curr_weight = #[1];
781
782         if(Wpal == "al")
783         {
784           order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
785         }
786         else
787         {
788           order_str = "(Wp("+string(#[1])+"),C)";
789         }
790       }
791       else
792       {
793         if(typeof(#[1]) == "intvec" and typeof(#[2]) == "intvec")
794         {
795           curr_weight = #[1];
796           target_weight = #[2];
797
798           if(Wpal == "al")
799           {
800             order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
801           }
802           else
803           {
804             order_str = "(Wp("+string(#[1])+"),C)";
805           }
806         }
807         else
808         {
809           print("// ** the input  must be \"(ideal,intvec,int)\" or ");
810           print("// **                    \"(ideal,intvec,intvec)\"");
811           print("// ** and a lex. GB will be computed from \"dp\" to \"lp\"");
812         }
813       }
814     }
815     else {
816       if(size(#) == 3)
817       {
818         if(typeof(#[1]) == "intvec" and typeof(#[2]) == "intvec" and
819            typeof(#[3]) == "int")
820         {
821           curr_weight = #[1];
822           target_weight = #[2];
823           nP = #[3];
824           if(Wpal == "al")
825           {
826             order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)";
827           }
828           else
829           {
830             order_str = "(Wp("+string(#[1])+"),C)";
831           }
832         }
833         else
834         {
835           print("// ** the input must be \"(ideal,intvec,intvec,int)\"");
836           print("// ** and a lex. GB will be computed from \"dp\" to \"lp\"");
837
838         }
839       }
840       else
841       {
842         print("// ** The given input is wrong");
843         print("// ** and a lex. GB will be computed from \"dp\" to \"lp\"");
844       }
845     }
846    }
847  }
848  list result;
849  result[1] = nP;
850  result[2] = order_str;
851  result[3] = curr_weight;
852  result[4] = target_weight;
853  return(result);
854}
855
856///////////////////////////////////////////////////////////////////////////////*
857/*Further examples
858ring r=0,(x,y,z),lp;
859
860ideal I=x2y4, y4z2, xy4z+y2z, xy6z2+y10z5;
861
862ideal Q=x2y4, y4z2, xy4z+y2z, xy6z2+y14z7;
863
864ideal J=x2y4, y4z2, xy4z+y2z, xy6z2+y18z9;
865
866ideal K=x2,y2,xy+y,2xy2+y5,z3+x;
867
868ideal L=x2+y,y2+z,x+z2;
869*/
870
871
Note: See TracBrowser for help on using the repository browser.