source: git/Singular/LIB/elim.lib @ 380a17b

spielwiese
Last change on this file since 380a17b was 380a17b, checked in by Hans Schoenemann <hannes@…>, 11 years ago
fix: new version numbers for libs
  • Property mode set to 100644
File size: 30.6 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2version="version elim.lib 4.0.0.0 Jun_2013 ";
3category="Commutative Algebra";
4info="
5LIBRARY:  elim.lib      Elimination, Saturation and Blowing up
6
7PROCEDURES:
8 blowup0(j[,s1,s2])   create presentation of blownup ring of ideal j
9 elimRing(p)          create ring with block ordering for elimating vars in p
10 elim(id,..)          variables .. eliminated from id (ideal/module)
11 elim1(id,p)          variables .. eliminated from id (different algorithm)
12 elim2(id,..)         variables .. eliminated from id (different algorithm)
13 nselect(id,v)        select generators not containing variables given by v
14 sat(id,j)            saturated quotient of ideal/module id by ideal j
15 select(id,v])        select generators containing all variables given by v
16 select1(id,v)        select generators containing one variable given by v
17           (parameters in square brackets [] are optional)
18";
19
20LIB "inout.lib";
21LIB "general.lib";
22LIB "poly.lib";
23LIB "ring.lib";
24///////////////////////////////////////////////////////////////////////////////
25
26proc blowup0 (ideal J,ideal C, list #)
27"USAGE:   blowup0(J,C [,W]); J,C,W ideals
28@*       C = ideal of center of blowup, J = ideal to be blown up,
29         W = ideal of ambient space
30ASSUME:  inclusion of ideals : W in J, J in C.
31         If not, the procedure replaces J by J+W and C by C+J+W
32RETURN:  a ring, say B, containing the ideals C,J,W and the ideals
33@*         - bR (ideal defining the blown up basering)
34@*         - aS (ideal of blown up ambient space)
35@*         - eD (ideal of exceptional divisor)
36@*         - tT (ideal of total transform)
37@*         - sT (ideal of strict transform)
38@*         - bM (ideal of the blowup map from basering to B)
39@*       such that B/bR is isomorphic to the blowup ring BC.
40PURPOSE: compute the projective blowup of the basering in the center C, the
41         exceptional locus, the total and strict tranform of J,
42         and the blowup map.
43         The projective blowup is a presentation of the blowup ring
44         BC = R[C] = R + t*C + t^2*C^2 + ... (also called Rees ring) of the
45         ideal C in the ring basering R.
46THEORY:  If basering = K[x1,...,xn] and C = <f1,...,fk> then let
47         B = K[x1,...,xn,y1,...,yk] and aS the preimage in B of W
48         under the map B -> K[x1,...,xn,t], xi -> xi, yi -> t*fi.
49         aS is homogeneous in the variables yi and defines a variety
50         Z=V(aS) in  A^n x P^(k-1), the ambient space of the blowup of V(W).
51         The projection Z -> A^n is an isomorphism outside the preimage
52         of the center V(C) in A^n and is called the blowup of the center.
53         The preimage of V(C) is called the exceptional set, the preimage of
54         V(J) is called the total transform of V(J). The strict transform
55         is the closure of (total transform minus the exceptional set).
56@*       If C = <x1,...,xn> then aS = <yi*xj - yj*xi | i,j=1,...,n>
57         and Z is the blowup of A^n in 0, the exceptional set is P^(k-1).
58NOTE:    The procedure creates a new ring with variables y(1..k) and x(1..n)
59         where n=nvars(basering) and k=ncols(C). The ordering is a block
60         ordering where the x-block has the ordering of the basering and
61         the y-block has ordering dp if C is not homogeneous
62         resp. the weighted ordering wp(b1,...bk) if C is homogeneous
63         with deg(C[i])=bi.
64SEE ALSO:blowUp, blowUp2
65EXAMPLE: example blowup0; shows examples
66"{
67   def br = basering;
68   list l = ringlist(br);
69   int n,k,i = nvars(br),ncols(C),0;
70   ideal W;
71   if (size(#) !=0)
72   { W = #[1];}
73   J = J,W;
74   //J = interred(J+W);
75//------------------------- create rings for blowup ------------------------
76//Create rings tr = K[x(1),...,x(n),t] and nr = K[x(1),...,x(n),y(1),...,y(k)]
77//and map Bl: nr --> tr, x(i)->x(i), y(i)->t*fi.
78//Let ord be the ordering of the basering.
79//We change the ringlist l by changing l[2] and l[3]
80//For K[t,x(1),...,x(n),t]
81// - l[2]: the variables to x(1),...,x(n),t
82// - l[3]: the ordering to a block ordering (ord,dp(1))
83//For K[x(1),...,x(n),y(1),...,y(k)]
84// - l[2]: the variables to x(1),...,x(n),y(1),...,y(k),
85// - l[3]: the ordering to a block ordering (ord,dp) if C is
86//         not homogeneous or to (ord,wp(b1,...bk),ord) if C is
87//         homogeneous with deg(C[i])=bi;
88
89//--------------- create tr = K[x(1),...,x(n),t] ---------------------------
90   int s = size(l[3]);
91   for ( i=n; i>=1; i--)
92   {
93      l[2][i]="x("+string(i)+")";
94   }
95   l[2]=insert(l[2],"t",n);
96   l[3]=insert(l[3],list("dp",1),s-1);
97   def tr = ring(l);
98
99//--------------- create nr = K[x(1),...,x(n),y(1),...,y(k)] ---------------
100   l[2]=delete(l[2],n+1);
101   l[3]=delete(l[3],s);
102   for ( i=k; i>=1; i--)
103   {
104      l[2][n+i]="y("+string(i)+")";
105   }
106
107   //---- change l[3]:
108   l[3][s+1] = l[3][s];         // save the module ordering of the basering
109   intvec w=1:k;
110   intvec v;                    // containing the weights for the varibale
111   if( homog(C) )
112   {
113      for( i=k; i>=1; i--)
114      {
115         v[i]=deg(C[i]);
116      }
117      if (v != w)
118      {
119         l[3][s]=list("wp",v);
120      }
121      else
122      {
123         l[3][s]=list("dp",v);
124      }
125   }
126   else
127   {
128      v=1:k;
129      l[3][s]=list("dp",v);
130   }
131   def nr = ring(l);
132
133//-------- create blowup map Bl: nr --> tr, x(i)->x(i), y(i)->t*fi ---------
134   setring tr;
135   ideal C = fetch(br,C);
136   ideal bl = x(1..n);
137   for( i=1; i<=k; i++) { bl = bl,t*C[i]; }
138   map Bl = nr,bl;
139   ideal Z;
140//------------------ compute blown up objects and return  -------------------
141   setring nr;
142   ideal bR = preimage(tr,Bl,Z);   //ideal of blown up affine space A^n
143   ideal C = fetch(br,C);
144   ideal J = fetch(br,J);
145   ideal W = fetch(br,W);
146   ideal aS = interred(bR+W);                //ideal of ambient space
147   ideal tT = interred(J+bR+W);              //ideal of total transform
148   ideal eD = interred(C+J+bR+W);            //ideal of exceptional divisor
149   ideal sT = sat(tT,C)[1];       //ideal of strict transform
150   ideal bM = x(1..n);            //ideal of blowup map br --> nr
151
152   export(bR,C,J,W,aS,tT,eD,sT,bM);
153   return(nr);
154}
155example
156{ "EXAMPLE:"; echo = 2;
157   ring r  = 0,(x,y),dp;
158   poly f  = x2+y3;
159   ideal C = x,y;           //center of blowup
160   def B1 = blowup0(f,C);
161   setring B1;
162   aS;                      //ideal of blown up ambient space
163   tT;                      //ideal of total transform of f
164   sT;                      //ideal of strict transform of f
165   eD;                      //ideal of exceptional divisor
166   bM;                      //ideal of blowup map r --> B1
167
168   ring R  = 0,(x,y,z),ds;
169   poly f  = y2+x3+z5;
170   ideal C = y2,x,z;
171   ideal W = z-x;
172   def B2 = blowup0(f,C,W);
173   setring B2;
174   B2;                       //weighted ordering
175   bR;                       //ideal of blown up R
176   aS;                       //ideal of blown up R/W
177   sT;                       //strict transform of f
178   eD;                       //ideal of exceptional divisor
179   //Note that the different affine charts are {y(i)=1}
180 }
181
182//////////////////////////////////////////////////////////////////////////////
183proc elimRing ( poly vars, list #)
184"USAGE:   elimRing(vars [,w,str]); vars = product of variables to be eliminated
185         (type poly), w = intvec (specifying weights for all variables),
186         str = string either \"a\" or \"b\" (default: w=ringweights, str=\"a\")
187RETURN:  a list, say L, with R:=L[1] a ring and L[2] an intvec.
188         The ordering in R is an elimination ordering for the variables
189         appearing in vars depending on \"a\" resp. \"b\". Let w1 (resp. w2)
190         be the intvec of weights of the variables to be eliminated (resp. not
191         to be eliminated).
192         The monomial ordering of R has always 2 blocks, the first
193         block corresponds to the (given) variables to be eliminated.
194@*       If str = \"a\" the first block is a(w1,0..0) and the second block is
195         wp(w) resp. ws(w) if the first variable not to be eliminated is local.
196@*       If str = \"b\" the 1st block has ordering wp(w1) and the 2nd block
197         is wp(w2) resp. ws(w2) if the first variable not to be eliminated is
198         local.
199@*       If the basering is a quotient ring P/Q, then R is also a quotient ring
200         with Q replaced by a standard basis of Q w.r.t. the new ordering
201         (parameters are not touched).
202@*       The intvec L[2] is the intvec of variable weights (or the given w)
203         with weights <= 0 replaced by 1.
204PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by
205         computing a standard basis in R with a fast monomial ordering.
206         This procedure is used by the procedure elim.
207EXAMPLE: example elimRing; shows an example
208"
209{
210  def BR = basering;
211  int nvarBR = nvars(BR);
212  list BRlist = ringlist(BR);
213  //------------------ set resp. compute ring weights ----------------------
214  int ii;
215  intvec @w;              //to store weights of all variables
216  @w[nvarBR] = 0;
217  @w = @w + 1;            //initialize @w as 1..1
218  string str = "a";       //default for specifying elimination ordering
219  if (size(#) == 0)       //default values
220  {
221     @w = ringweights(BR);     //compute the ring weights (proc from ring.lib)
222  }
223
224  if (size(#) == 1)
225  {
226    if ( typeof(#[1]) == "intvec" )
227    {
228       @w = #[1];              //take the given weights
229    }
230    if ( typeof(#[1]) == "string" )
231    {
232       str = #[1];             //string for specifying elimination ordering
233    }
234  }
235
236  if (size(#) >= 2)
237  {
238    if ( typeof(#[1]) == "intvec" and typeof(#[2]) == "string" )
239    {
240       @w = #[1];              //take the given weights
241       str = #[2];             //string for specifying elimination ordering
242
243    }
244    if ( typeof(#[1]) == "string" and typeof(#[2]) == "intvec" )
245    {
246       str = #[1];             //string for specifying elimination ordering
247       @w = #[2];              //take the given weights
248    }
249  }
250
251  for ( ii=1; ii<=size(@w); ii++ )
252  {
253    if ( @w[ii] <= 0 )
254    {
255       @w[ii] = 1;             //replace non-positive weights by 1
256    }
257  }
258
259  //------ get variables to be eliminated together with their weights -------
260  intvec w1,w2;  //for ringweights of first (w1) and second (w2) block
261  list v1,v2;    //for variables of first (to be liminated) and second block
262
263  for( ii=1; ii<=nvarBR; ii++ )
264  {
265     if( vars/var(ii)==0 )    //treat variables not to be eliminated
266     {
267        w2 = w2,@w[ii];
268        v2 = v2+list(string(var(ii)));
269        if ( ! defined(local) )
270        {
271           int local = (var(ii) < 1);
272         }
273     }
274     else
275     {
276        w1 = w1,@w[ii];
277        v1 = v1+list(string(var(ii)));
278     }
279  }
280
281  if ( size(w1) <= 1 )
282  {
283    return(BR);
284  }
285  if ( size(w2) <= 1 )
286  {
287    ERROR("## elimination of all variables is not possible");
288  }
289
290  w1 = w1[2..size(w1)];
291  w2 = w2[2..size(w2)];
292  BRlist[2] = v1 + v2;         //put variables to be eliminated in front
293
294  //-------- create elimination ordering with two blocks and weights ---------
295  //Assume that the first r of the n variables are to be eliminated.
296  //Then, in case of an a-ordering (default), the new ring ordering will be
297  //of the form (a(1..1,0..0),dp) with r 1's and n-r 0's or (a(w1,0..0),wp(@w))
298  //if there are varaible weights which are not 1.
299  //In the case of a b-ordering the ordering will be a block ordering with two
300  //blocks of the form (dp(r),dp(n-r))  resp. (wp(w1),dp(w2))
301
302  list B3;                     //this will become the list for new ordering
303
304  //----- b-ordering case:
305  if ( str == "b" )
306  {
307    if( w1==1 )              //weights for vars to be eliminated are all 1
308    {
309       B3[1] = list("dp", w1);
310    }
311    else
312    {
313       B3[1] = list("wp", w1);
314    }
315
316    if( w2==1 )              //weights for vars not to be eliminated are all 1
317    {
318       if ( local )
319       {
320          B3[2] = list("ds", w2);
321       }
322       else
323       {
324          B3[2] = list("dp", w2);
325       }
326    }
327    else
328    {
329       if ( local )
330       {
331          B3[2] = list("ws", w2);
332       }
333       else
334       {
335          B3[2] = list("wp", w2);
336       }
337    }
338  }
339
340  //----- a-ordering case:
341  else
342  {
343    //define first the second block
344    if( @w==1 )              //weights for all vars are 1
345    {
346       if ( local )
347       {
348          B3[2] = list("ls", @w);
349       }
350       else
351       {
352          B3[2] = list("dp", @w);
353       }
354    }
355    else
356    {
357       if ( local )
358       {
359          B3[2] = list("ws", @w);
360       }
361       else
362       {
363          B3[2] = list("wp", @w);
364       }
365    }
366
367    //define now the first a-block of the form a(w1,0..0)
368    intvec @v;
369    @v[nvarBR] = 0;
370    @v = @v+w1;
371    B3[1] = list("a", @v);
372  }
373  BRlist[3] = B3;
374
375  //----------- put module ordering always at the end and return -------------
376
377  BRlist[3] = insert(BRlist[3],list("C",intvec(0)),size(B3));
378
379  def eRing = ring(quotientList(BRlist));
380  list result = eRing, @w;
381  return (result);
382}
383example
384{ "EXAMPLE:"; echo = 2;
385   ring R = 0,(x,y,z,u,v),(c,lp);
386   def P = elimRing(yu);  P;
387   intvec w = 1,1,3,4,5;
388   elimRing(yu,w);
389
390   ring S =  (0,a),(x,y,z,u,v),ws(1,2,3,4,5);
391   minpoly = a2+1;
392   qring T = std(ideal(x+y2+v3,(x+v)^2));
393   def Q = elimRing(yv)[1];
394   setring Q; Q;
395}
396///////////////////////////////////////////////////////////////////////////////
397
398proc elim (id, list #)
399"USAGE:   elim(id,arg[,s]);  id ideal/module, arg can be either an intvec v or
400         a product p of variables (type poly), s a string determining the
401         method which can be \"slimgb\" or \"std\" or, additionally,
402         \"withWeigts\".
403RETURN: ideal/module obtained from id by eliminating either the variables
404        with indices appearing in v or the variables appearing in p.
405        Works also in a qring.
406METHOD: elim uses elimRing to create a ring with an elimination ordering for
407        the variables to be eliminated and then applies std if \"std\"
408        is given, or slimgb if \"slimgb\" is given, or a heuristically chosen
409        method.
410@*      If the variables in the basering have weights these weights are used
411        in elimRing. If a string \"withWeigts\" as (optional) argument is given
412        @sc{Singular} computes weights for the variables to make the input as
413        homogeneous as possible.
414@*      The method is different from that used by eliminate and elim1;
415        depending on the example, any of these commands can be faster.
416NOTE:   No special monomial ordering is required, i.e. the ordering can be
417        local or mixed. The result is a SB with respect to the ordering of
418        the second block used by elimRing. E.g. if the first var not to be
419        eliminated is global, resp. local, this ordering is dp, resp. ds
420        (or wp, resp. ws, with the given weights for these variables).
421        If printlevel > 0 the ring for which the output is a SB is shown.
422SEE ALSO: eliminate, elim1
423EXAMPLE: example elim; shows an example
424"
425{
426  if (size(#) == 0)
427  {
428    ERROR("## specify variables to be eliminated");
429  }
430  int pr = printlevel - voice + 2;   //for ring display if printlevel > 0
431  def BR = basering;
432  list lER;                          //for list returned by elimRing
433//-------------------------------- check input -------------------------------
434  poly vars;
435  int ne;                           //for number of vars to be eliminated
436  int ii;
437  if (size(#) > 0)
438  {
439    if ( typeof(#[1]) == "poly" )
440    {
441      vars = #[1];
442      for( ii=1; ii<=nvars(BR); ii++ )
443      {
444        if ( vars/var(ii) != 0)
445        { ne++; }
446      }
447    }
448    if ( typeof(#[1]) == "intvec" or typeof(#[1]) == "int")
449    {
450      ne = size(#[1]);
451      vars=1;
452      for( ii=1; ii<=ne; ii++ )
453      {
454        vars=vars*var(#[1][ii]);
455      }
456    }
457  }
458
459  string method;                    //for "std" or "slimgb" or "withWeights"
460  if (size(#) >= 2)
461  {
462    if ( typeof(#[2]) == "string" )
463    {
464       if ( #[2] == "withWeights" )
465       {
466         intvec @w = weight(id);        //computation of weights
467       }
468       if ( #[2] == "std" ) { method = "std"; }
469       if ( #[2] == "slimgb" ) { method = "slimgb"; }
470
471    }
472    else
473    {
474      ERROR("expected `elim(ideal,intvec[,string])`");
475    }
476
477    if (size(#) == 3)
478    {
479       if ( typeof(#[3]) == "string" )
480       {
481          if ( #[3] == "withWeights" )
482          {
483            intvec @w = weight(id);        //computation of weights
484          }
485          if ( #[3] == "std" ) { method = "std"; }
486          if ( #[3] == "slimgb" ) { method = "slimgb"; }
487       }
488    }
489
490    if ( method == "" )
491    {
492      ERROR("expected \"std\" or \"slimgb\" or \"withWeights\" as the optional string parameters");
493    }
494  }
495
496//-------------- create new ring and map objects to new ring ------------------
497   if ( defined(@w) )
498   {
499      lER = elimRing(vars,@w);  //in this case lER[2] = @w
500   }
501   else
502   {
503      lER = elimRing(vars);
504      intvec @w = lER[2];      //in this case w is the intvec of
505                               //variable weights as computed in elimRing
506   }
507   def ER = lER[1];
508   setring ER;
509   def id = imap(BR,id);
510   poly vars = imap(BR,vars);
511
512//---------- now eliminate in new ring and map back to old ring ---------------
513  //if possible apply std(id,hi,w) where hi is the first hilbert function
514  //of id with respect to the weights w. If w is not defined (i.e. good weights
515  //@w are computed then id is only approximately @w-homogeneous and
516  //the hilbert driven std cannot be used directly; however, stdhilb
517  //homogenizes first and applies the hilbert driven std to the homogenization
518
519   option(redThrough);
520   if (typeof(id)=="matrix")
521   {
522     id = matrix(stdhilb(module(id),method,@w));
523   }
524   else
525   {
526     id = stdhilb(id,method,@w);
527   }
528
529   //### Todo: hier sollte id = groebner(id, "hilb"); verwendet werden.
530   //da z.Zt. (Jan 09) groebener bei extra Gewichtsvektor a(...) aber stets std
531   //aufruft und ausserdem "withWeigts" nicht kennt, ist groebner(id, "hilb")
532   //zunaechst nicht aktiviert. Ev. nach Ueberarbeitung von groebner aktivieren
533
534   id = nselect(id,1..ne);
535   if ( pr > 0 )
536   {
537     "// result is a SB in the following ring:";
538      ER;
539   }
540   setring BR;
541   return(imap(ER,id));
542}
543example
544{ "EXAMPLE:"; echo = 2;
545   ring r=0,(x,y,u,v,w),dp;
546   ideal i=x-u,y-u2,w-u3,v-x+y3;
547   elim(i,3..4);
548   elim(i,uv);
549   int p = printlevel;
550   printlevel = 2;
551   elim(i,uv,"withWeights","slimgb");
552   printlevel = p;
553
554   ring S =  (0,a),(x,y,z,u,v),ws(1,2,3,4,5);
555   minpoly = a2+1;
556   qring T = std(ideal(ax+y2+v3,(x+v)^2));
557   ideal i=x-u,y-u2,az-u3,v-x+ay3;
558   module m=i*gen(1)+i*gen(2);
559   m=elim(m,xy);
560   show(m);
561}
562///////////////////////////////////////////////////////////////////////////////
563
564proc elim2 (id, intvec va)
565"USAGE:   elim2(id,v);  id ideal/module, v intvec
566RETURNS: ideal/module obtained from id by eliminating variables in v
567NOTE:    no special monomial ordering is required, result is a SB with
568         respect to ordering dp (resp. ls) if the first var not to be
569         eliminated belongs to a -p (resp. -s) blockordering
570         This proc uses 'execute' or calls a procedure using 'execute'.
571SEE ALSO: elim1, eliminate, elim
572EXAMPLE: example elim2; shows examples
573"
574{
575//---- get variables to be eliminated and create string for new ordering ------
576   int ii; poly vars=1;
577   for( ii=1; ii<=size(va); ii++ ) { vars=vars*var(va[ii]); }
578   if(  attrib(basering,"global")) { string ordering = "),dp;"; }
579   else { string ordering = "),ls;"; }
580   string mpoly=string(minpoly);
581//-------------- create new ring and map objects to new ring ------------------
582   def br = basering;
583   string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering;
584   execute(str);
585   if (mpoly!="0") { execute("minpoly="+mpoly+";"); }
586   def i = imap(br,id);
587   poly vars = imap(br,vars);
588//---------- now eliminate in new ring and map back to old ring ---------------
589   i = eliminate(i,vars);
590   setring br;
591   return(imap(@newr,i));
592}
593example
594{ "EXAMPLE:"; echo = 2;
595   ring r=0,(x,y,u,v,w),dp;
596   ideal i=x-u,y-u2,w-u3,v-x+y3;
597   elim2(i,3..4);
598   module m=i*gen(1)+i*gen(2);
599   m=elim2(m,3..4);show(m);
600}
601
602///////////////////////////////////////////////////////////////////////////////
603proc elim1 (id, list #)
604"USAGE:   elim1(id,arg); id ideal/module, arg can be either an intvec v or a
605         product p of variables (type poly)
606RETURN: ideal/module obtained from id by eliminating either the variables
607        with indices appearing in v or the variables appearing in p
608METHOD:  elim1 calls eliminate but in a ring with ordering dp (resp. ls)
609         if the first var not to be eliminated belongs to a -p (resp. -s)
610         ordering.
611NOTE:    no special monomial ordering is required.
612         This proc uses 'execute' or calls a procedure using 'execute'.
613SEE ALSO: elim, eliminate
614EXAMPLE: example elim1; shows examples
615"
616{
617   def br = basering;
618   if ( size(ideal(br)) != 0 )
619   {
620      ERROR ("elim1 cannot eliminate in a qring");
621   }
622//------------- create product vars of variables to be eliminated -------------
623  poly vars;
624  int ii;
625  if (size(#) > 0)
626  {
627    if ( typeof(#[1]) == "poly" ) {  vars = #[1]; }
628    if ( typeof(#[1]) == "intvec" or typeof(#[1]) == "int")
629    {
630      vars=1;
631      for( ii=1; ii<=size(#[1]); ii++ )
632      {
633        vars=vars*var(#[1][ii]);
634      }
635    }
636  }
637//---- get variables to be eliminated and create string for new ordering ------
638   for( ii=1; ii<=nvars(basering); ii++ )
639   {
640      if( vars/var(ii)==0 ) { poly p = 1+var(ii); break;}
641   }
642   if( ord(p)==0 ) { string ordering = "),ls;"; }
643   if( ord(p)>0 ) { string ordering = "),dp;"; }
644//-------------- create new ring and map objects to new ring ------------------
645   string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering;
646   execute(str);
647   def id = fetch(br,id);
648   poly vars = fetch(br,vars);
649//---------- now eliminate in new ring and map back to old ring ---------------
650   id = eliminate(id,vars);
651   setring br;
652   return(imap(@newr,id));
653}
654example
655{ "EXAMPLE:"; echo = 2;
656   ring r=0,(x,y,t,s,z),dp;
657   ideal i=x-t,y-t2,z-t3,s-x+y3;
658   elim1(i,ts);
659   module m=i*gen(1)+i*gen(2);
660   m=elim1(m,3..4); show(m);
661}
662///////////////////////////////////////////////////////////////////////////////
663
664proc nselect (id, intvec v)
665"USAGE:   nselect(id,v); id = ideal, module or matrix, v = intvec
666RETURN:  generators (or columns) of id not containing the variables with index
667         an entry of v
668SEE ALSO: select, select1
669EXAMPLE: example nselect; shows examples
670"
671{
672   if (typeof(id) != "ideal")
673   {
674      if (typeof(id)=="module" || typeof(id)=="matrix")
675      {
676        module id1 = module(id);
677      }
678      else
679      {
680        ERROR("// *** input must be of type ideal or module or matrix");
681      }
682   }
683   else
684   {
685      ideal id1 = id;
686   }
687   int j,k;
688   int n,m = size(v), ncols(id1);
689   for( k=1; k<=m; k++ )
690   {
691      for( j=1; j<=n; j++ )
692      {
693        if( size(id1[k]/var(v[j]))!=0 )
694        {
695           id1[k]=0; break;
696        }
697      }
698   }
699   if(typeof(id)=="matrix")
700   {
701      return(matrix(simplify(id1,2)));
702   }
703   return(simplify(id1,2));
704}
705example
706{ "EXAMPLE:"; echo = 2;
707   ring r=0,(x,y,t,s,z),(c,dp);
708   ideal i=x-y,y-z2,z-t3,s-x+y3;
709   nselect(i,3);
710   module m=i*(gen(1)+gen(2));
711   m;
712   nselect(m,3..4);
713   nselect(matrix(m),3..4);
714}
715///////////////////////////////////////////////////////////////////////////////
716
717proc sat (id, ideal j)
718"USAGE:   sat(id,j);  id=ideal/module, j=ideal
719RETURN:  list of an ideal/module [1] and an integer [2]:
720         [1] = saturation of id with respect to j (= union_(k=1...) of id:j^k)
721         [2] = saturation exponent (= min( k | id:j^k = id:j^(k+1) ))
722NOTE:    [1] is a standard basis in the basering
723DISPLAY: saturation exponent during computation if printlevel >=1
724EXAMPLE: example sat; shows an example
725"{
726   int ii,kk;
727   def i=id;
728   id=std(id);
729   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
730   while( ii<=size(i) )
731   {
732      dbprint(p-1,"// compute quotient "+string(kk+1));
733      i=quotient(id,j);
734      for( ii=1; ii<=size(i); ii++ )
735      {
736         if( reduce(i[ii],id,1)!=0 ) break;
737      }
738      id=std(i); kk++;
739   }
740   dbprint(p-1,"// saturation becomes stable after "+string(kk-1)+" iteration(s)","");
741   list L = id,kk-1;
742   return (L);
743}
744example
745{ "EXAMPLE:"; echo = 2;
746   int p      = printlevel;
747   ring r     = 2,(x,y,z),dp;
748   poly F     = x5+y5+(x-y)^2*xyz;
749   ideal j    = jacob(F);
750   sat(j,maxideal(1));
751   printlevel = 2;
752   sat(j,maxideal(2));
753   printlevel = p;
754}
755///////////////////////////////////////////////////////////////////////////////
756
757proc select (id, intvec v)
758"USAGE:   select(id,n[,m]); id = ideal/module/matrix, v = intvec
759RETURN:  generators/columns of id containing all variables with index
760         an entry of v
761NOTE:    use 'select1' for selecting generators/columns containing at least
762         one of the variables with index an entry of v
763SEE ALSO: select1, nselect
764EXAMPLE: example select; shows examples
765"
766{
767   if (typeof(id) != "ideal")
768   {
769      if (typeof(id)=="module" || typeof(id)=="matrix")
770      {
771        module id1 = module(id);
772      }
773      else
774      {
775        ERROR("// *** input must be of type ideal or module or matrix");
776      }
777   }
778   else
779   {
780      ideal id1 = id;
781   }
782   int j,k;
783   int n,m = size(v), ncols(id1);
784   for( k=1; k<=m; k++ )
785   {
786      for( j=1; j<=n; j++ )
787      {
788         if( size(id1[k]/var(v[j]))==0)
789         {
790            id1[k]=0; break;
791         }
792      }
793   }
794   if(typeof(id)=="matrix")
795   {
796      return(matrix(simplify(id1,2)));
797   }
798   return(simplify(id1,2));
799}
800example
801{ "EXAMPLE:"; echo = 2;
802   ring r=0,(x,y,t,s,z),(c,dp);
803   ideal i=x-y,y-z2,z-t3,s-x+y3;
804   ideal j=select(i,1);
805   j;
806   module m=i*(gen(1)+gen(2));
807   m;
808   select(m,1..2);
809   select(matrix(m),1..2);
810}
811///////////////////////////////////////////////////////////////////////////////
812
813proc select1 (id, intvec v)
814"USAGE:   select1(id,v); id = ideal/module/matrix, v = intvec
815RETURN:  generators/columns of id containing at least one of the variables
816         with index an entry of v
817NOTE:    use 'select' for selecting generators/columns containing all variables
818         with index an entry of v
819SEE ALSO: select, nselect
820EXAMPLE: example select1; shows examples
821"
822{
823   if (typeof(id) != "ideal")
824   {
825      if (typeof(id)=="module" || typeof(id)=="matrix")
826      {
827        module id1 = module(id);
828        module I;
829      }
830      else
831      {
832        ERROR("// *** input must be of type ideal or module or matrix");
833      }
834   }
835   else
836   {
837      ideal id1 = id;
838      ideal I;
839   }
840   int j,k;
841   int n,m = size(v), ncols(id1);
842   for( k=1; k<=m; k++ )
843   {  for( j=1; j<=n; j++ )
844      {
845         if( size(subst(id1[k],var(v[j]),0)) != size(id1[k]) )
846         {
847            I = I,id1[k]; break;
848         }
849      }
850   }
851   if(typeof(id)=="matrix")
852   {
853      return(matrix(simplify(I,2)));
854   }
855   return(simplify(I,2));
856}
857example
858{ "EXAMPLE:"; echo = 2;
859   ring r=0,(x,y,t,s,z),(c,dp);
860   ideal i=x-y,y-z2,z-t3,s-x+y3;
861   ideal j=select1(i,1);j;
862   module m=i*(gen(1)+gen(2)); m;
863   select1(m,1..2);
864   select1(matrix(m),1..2);
865}
866/*
867///////////////////////////////////////////////////////////////////////////////
868//                      EXAMPLEs
869///////////////////////////////////////////////////////////////////////////////
870// Siehe auch file 'tst-elim' mit grossem Beispiel;
871example blowup0;
872example elimRing;
873example elim;
874example elim1;
875example nselect;
876example sat;
877example select;
878example select1;
879//===========================================================================
880//         Rationale Normalkurve vom Grad d im P^d bzw. im A^d:
881//homogen s:t -> (t^d:t^(d-1)s: ...: s^d), inhomogen t ->(t^d:t^(d-1): ...:t)
882
883//------------------- 1. Homogen:
884//Varianten der Methode
885int d = 5;
886ring R = 0,(s,t,x(0..d)),dp;
887ideal I;
888for( int ii=0; ii<=d; ii++) {I = I,ideal(x(ii)-t^(d-ii)*s^ii); }
889
890int tt = timer;
891ideal eI = elim(I,1..2,"std");
892ideal eI = elim(I,1..2,"slimgb");
893ideal eI = elim(I,st,"withWeights");
894ideal eI = elim(I,st,"std","withWeights");
895//komplizierter
896int d = 50;
897ring R = 0,(s,t,x(0..d)),dp;
898ideal I;
899for( int ii=0; ii<=d; ii++) {I = I,ideal(x(ii)-t^(d-ii)*s^ii); }
900int tt = timer;
901ideal eI = elim(I,1..2);               //56(44)sec (slimgb 22(17),hilb 33(26))
902timer-tt; tt = timer;
903ideal eI = elim1(I,1..2);              //71(53)sec
904timer-tt; tt = timer;
905ideal eI = eliminate(I,st);            //70(51)sec (wie elim1)
906timer-tt;
907timer-tt; tt = timer;
908ideal eI = elim(I,1..2,"withWeights"); //190(138)sec
909                                //(weights73(49), slimgb43(33), hilb71(53)
910timer-tt;
911//------------------- 2. Inhomogen
912int d = 50;
913ring r = 0,(t,x(0..d)),dp;
914ideal I;
915for( int ii=0; ii<=d; ii++) {I = I+ideal(x(ii)-t^(d-ii)); }
916int tt = timer;
917ideal eI = elim(I,1,);                //20(15)sec (slimgb13(10), hilb6(5))
918ideal eI = elim(I,1,"std");           //17sec (std 11, hilb 6)
919timer-tt; tt = timer;
920ideal eI = elim1(I,t);               //8(6)sec
921timer-tt; tt = timer;
922ideal eI = eliminate(I,t);           //7(6)sec
923timer-tt;
924timer-tt; tt = timer;
925ideal eI = elim(I,1..1,"withWeights"); //189(47)sec
926//(weights73(42), slimgb43(1), hilb70(2)
927timer-tt;
928
929//===========================================================================
930//        Zufaellige Beispiele, homogen
931system("random",37);
932ring R = 0,x(1..6),lp;
933ideal I = sparseid(4,3);
934
935int tt = timer;
936ideal eI = elim(I,1);                //108(85)sec (slimgb 29(23), hilb79(61)
937timer-tt; tt = timer;
938ideal eI = elim(I,1,"std");          //(139)sec (std 77, hilb 61)
939timer-tt; tt = timer;
940ideal eI = elim1(I,1);               //(nach 45 min abgebrochen)
941timer-tt; tt = timer;
942ideal eI = eliminate(I,x(1));        //(nach 45 min abgebrochen)
943timer-tt; tt = timer;
944
945//        Zufaellige Beispiele, inhomogen
946system("random",37);
947ring R = 32003,x(1..5),dp;
948ideal I = sparseid(4,2,3);
949option(prot,redThrough);
950
951intvec w = 1,1,1,1,1,1;
952int tt = timer;
953ideal eI = elim(I,1,w);            //(nach 5min abgebr.) hilb schlaegt nicht zu
954timer-tt; tt = timer;              //BUG!!!!!!
955
956int tt = timer;
957ideal eI = elim(I,1);              //(nach 5min abgebr.) hilb schlaegt nicht zu
958timer-tt; tt = timer;              //BUG!!!!!!
959ideal eI = elim1(I,1);             //8(7.8)sec
960timer-tt; tt = timer;
961ideal eI = eliminate(I,x(1));      //8(7.8)sec
962timer-tt; tt = timer;
963
964                              BUG!!!!
965//        Zufaellige Beispiele, inhomogen, lokal
966system("random",37);
967ring R = 32003,x(1..6),ds;
968ideal I = sparseid(4,1,2);
969option(prot,redThrough);
970int tt = timer;
971ideal eI = elim(I,1);                //(haengt sich auf)
972timer-tt; tt = timer;
973ideal eI = elim1(I,1);               //(0)sec !!!!!!
974timer-tt; tt = timer;
975ideal eI = eliminate(I,x(1));        //(ewig mit ...., abgebrochen)
976timer-tt; tt = timer;
977
978ring R1 =(32003),(x(1),x(2),x(3),x(4),x(5),x(6)),(a(1,0,0,0,0,0),ds,C);
979ideal I = imap(R,I);
980I = std(I);                           //(haengt sich auf) !!!!!!!
981
982ideal eI = elim(I,1..1,"withWeights"); //(47)sec (weights42, slimgb1, hilb2)
983timer-tt;
984
985ring R1 =(32003),(x(1),x(2),x(3),x(4),x(5),x(6)),(a(1,0,0,0,0,0),ds,C);
986ideal I = imap(R,I);
987I = std(I);                           //(haengt sich auf) !!!!!!!
988
989ideal eI = elim(I,1..1,"withWeights"); //(47)sec (weights42, slimgb1, hilb2)
990timer-tt;
991*/
Note: See TracBrowser for help on using the repository browser.