source: git/Singular/LIB/ratgb.lib @ 285d21

spielwiese
Last change on this file since 285d21 was 285d21, checked in by Viktor Levandovskyy <levandov@…>, 16 years ago
*levandov: fixes, new procs, cleanup git-svn-id: file:///usr/local/Singular/svn/trunk@10608 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 7.3 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2version="$Id: ratgb.lib,v 1.12 2008-02-26 23:36:12 levandov Exp $";
3category="Noncommutative";
4info="
5LIBRARY: ratgb.lib  Groebner bases in Ore localizations
6AUTHOR: Viktor Levandovskyy,     levandov@risc.uni-linz.ac.at
7
8PROCEDURES:
9ratstd(ideal I, int n);   compute Groebner basis in Ore localization of the basering wrt first n variables
10
11SUPPORT: SpezialForschungsBereich F1301 of the Austrian FWF
12"
13
14LIB "poly.lib";
15
16//static
17proc rm_content_id(def J)
18"USAGE:  rm_content_id(I);  I an ideal/module
19RETURN:  the same type as input
20PURPOSE: remove the content of every generator of I
21EXAMPLE: example rm_content_id; shows examples
22"
23{
24  def  I = J;
25  int i;
26  int s = ncols(I);
27  for (i=1; i<=s; i++)
28  {
29    if (I[i]!=0)
30    {
31      I[i] = I[i]/content(I[i]);
32    }
33  }
34  return(I);
35}
36example
37{
38  "EXAMPLE:"; echo = 2;
39  ring r = (0,k,n),(K,N),dp;
40  ideal I = n*((k+1)*K - (n-k)), k*((n-k+1)*N - (n+1));
41  I;
42  rm_content_id(I);
43  module M = I[1]*gen(1), I[2]*gen(2);
44  print(rm_content_id(M));
45}
46
47proc ratstd(def I, int is, list #)
48"USAGE:  ratstd(I, n [,eng]);  I an ideal/module, n an integer, eng an optional integer
49RETURN:  ring
50PURPOSE: compute the Groebner basis of I in the Ore localization of
51the basering with respect to the subalgebra, generated by first n variables
52ASSUME: the variables are organized in two blocks and
53@* the first block of length n contains the elements
54@*     with respect to which one localizes,
55@* the basering is equipped with the elimination ordering
56@*     for the variables in the second block
57NOTE: the output ring O is commutative. The ideal rGBid in O
58represents the rational form of the output ideal pGBid in the basering.
59@* During the computation, the D-dimension of I and the corresponding
60vector space D-dimension of I are computed and printed out.
61@* Setting optional integer eng to 1, slimgb is taken as Groebner engine
62TRACING: In order to see the steps of the computation, set printlevel to >=2
63EXAMPLE: example ratstd; shows examples
64"
65{
66  int ppl = printlevel-voice+1;
67  int eng = 0;
68  // optional arguments
69  if (size(#)>0)
70  {
71    if (typeof(#[1]) == "int")
72    {
73      eng = int(#[1]);
74    }
75  }
76
77  dbprint(ppl,"engine chosen to be");
78  dbprint(ppl,eng);
79
80  // 0. do the subst's /reformulations
81  // for the time being, ASSUME
82  // the ord. is an elim. ord. for D
83  // and the block of X's is on the left
84  // its length is 'is'
85
86  int i,j,k;
87  dbprint(ppl,"// -1- creating K(x)[D]");
88
89  // 1. create K(x)[D], commutative
90  def save = basering;
91  list L = ringlist(save);
92  list RL, tmp1,tmp2,tmp3,tmp4;
93  intvec iv;
94  // copy: field, enlarge it with Xs
95
96  if ( size(L[1]) == 0)
97  {
98    // i.e. the field with char only
99    tmp2[1] = L[1];
100    //    tmp1 = L[2];
101    j    = size(L[2]);
102    iv   = 1;
103    for (i=1; i<=is; i++)
104    {
105      tmp1[i] = L[2][i];
106      iv = iv,1;
107    }
108    iv = iv[1..size(iv)-1]; //extra 1
109    tmp2[2]       = tmp1;
110    tmp3[1] = "lp";
111    tmp3[2] = iv;
112    //    tmp2[3] = 0;
113    tmp4[1] = tmp3;
114    tmp2[3] = tmp4;
115    //[1] = "lp";
116    //    tmp2[3][2] = iv;
117    tmp2[4]       = ideal(0);
118    RL[1] = tmp2;
119  }
120
121  if ( size(L[1]) >0 )
122  {
123    // TODO!!!!!
124    tmp2[1] = L[1][1]; //char K
125    // there are parameters
126    // add to them X's, IGNORE alg.extension
127    // the ordering on pars
128    tmp1 = L[1][2]; // param names
129    j    = size(tmp1);
130    iv = L[1][3][1][2];
131    for (i=1; i<=is; i++)
132    {
133      tmp1[j+i] = L[2][i];
134      iv = iv,1;
135    }
136    tmp2[2] = tmp1;
137    tmp2[3] = L[1][3];
138    tmp2[3][1][2] = iv;
139    tmp2[4] = ideal(0);
140    RL[1] = tmp2;
141  }
142
143  // vars: leave only D's
144  kill tmp1; list tmp1;
145  //  tmp1 = L[2];
146  for (i=is+1; i<= size(L[2]); i++)
147  {
148    tmp1[i-is] = L[2][i];
149  }
150  RL[2] = tmp1;
151
152  // assume the ordering is the block with (a(0:is),ORD)
153  // set up ORD as the ordering
154  //  L; "RL:"; RL;
155  if (size(L[3]) != 3)
156  {
157    "note: strange ordering";
158  }
159  kill tmp2; list tmp2;
160  tmp2[1] = L[3][2];
161  tmp2[2] = L[3][3];
162  RL[3]   = tmp2;
163
164  // factor ideal is ignored
165  RL[4] = ideal(0);
166
167  def @RAT = ring(RL);
168
169  dbprint(ppl,"// -2- preprocessing with content");
170  // 2. preprocess input with rm_content_id
171  setring @RAT;
172  dbprint(ppl-1, @RAT);
173  //  ideal CI = imap(save,I);
174  def CI = imap(save,I);
175  CI = rm_content_id(CI);
176  dbprint(ppl-1, CI);
177
178  dbprint(ppl,"// -3- running groebner");
179  // 3. compute G = GB(I) wrt. the elim. ord. for D
180  setring save;
181  //  ideal CI = imap(@RAT,CI);
182  def CI = imap(@RAT,CI);
183  option(redSB);
184  option(redTail);
185  if (eng)
186  {
187    def G = slimgb(CI);
188  }
189  else
190  {
191    def G = groebner(CI);
192  }
193  //  ideal G = groebner(CI); // although slimgb looks better
194  // def G = slimgb(CI);
195  G = simplify(G,2); // to be sure there are no 0's
196  dbprint(ppl-1, G);
197
198  dbprint(ppl,"// -4- postprocessing with content");
199  // 4. postprocess the output with 1) rm_content_id,  2) lm-minimization;
200  setring @RAT;
201  // ideal CG = imap(save,G);
202  def CG = imap(save,G);
203  CG = rm_content_id(CG);
204  CG = simplify(CG,2);
205  dbprint(ppl-1, CG);
206
207  // warning: a bugfarm! in this ring, the ordering might change!!! (see appelF4)
208  // so, simplify(32) should take place in the orig. ring! and NOT here
209  //  CG = simplify(CG,2+32);
210
211  // 4b. create L(G) with X's as coeffs (for minimization)
212  setring save;
213  G = imap(@RAT,CG);
214  int sG  = ncols(G);
215  //  ideal LG;
216  def LG = G;
217   for (i=1; i<= sG; i++)
218   {
219     LG[i] = lead(G[i]);
220   }
221  // compute the D-dimension of the ideal in the ring @RAT
222  setring @RAT;
223  //  ideal LG = imap(save,LG);
224  def LG = imap(save,LG);
225  //  ideal LGG = groebner(LG); // cosmetics
226  def LGG = groebner(LG); // cosmetics
227  int d = dim(LGG);
228  int Ddim = d;
229  printf("the D-dimension is %s",d);
230  if (d==0)
231  {
232    d = vdim(LGG);
233    int Dvdim = d;
234    printf("the K-dimension is %s",d);
235  }
236  //  ideal SLG = simplify(LG,8+32); //contains zeros
237  def SLG = simplify(LG,8+32); //contains zeros
238  setring save;
239  //  ideal SLG = imap(@RAT,SLG);
240  def SLG = imap(@RAT,SLG);
241  // simplify(LG,8+32); //contains zeros
242  intvec islg;
243  if (SLG[1] == 0)
244  {  islg = 0;  }
245  else
246  {    islg = 1;  }
247  for (i=2; i<= ncols(SLG); i++)
248  {
249    if (SLG[i] == 0)
250    {
251      islg = islg, 0;
252    }
253    else
254    {
255      islg = islg, 1;
256    }
257  }
258  for (i=1; i<= ncols(LG); i++)
259  {
260    if (islg[i] == 0)
261    {
262      G[i] = 0;
263    }
264  }
265  G = simplify(G,2); // ready!
266  //  G = imap(@RAT,CG);
267  // return the result
268  //  ideal pGBid = G;
269  def pGBid = G;
270  export pGBid;
271  //  export Ddim;
272  //  export Dvdim;
273  setring @RAT;
274  //  ideal rGBid = imap(save,G);
275  def rGBid = imap(save,G);
276  // CG;
277  export rGBid;
278  setring save;
279  return(@RAT);
280  //  kill @RAT;
281  //  return(G);
282}
283example
284{
285  "EXAMPLE:"; echo = 2;
286  ring r = 0,(k,n,K,N),(a(0,1),dp);
287  matrix D[4][4];
288  D[1,3] = K;
289  D[2,4] = N;
290  def S = nc_algebra(1,D);
291  setring S;
292  ideal I = (k+1)*K - (n-k), (n-k+1)*N - (n+1);
293  int is = 1;
294  def A  = ratstd(I,is);
295  pGBid; // polynomial form
296  setring A;
297  rGBid; // rational form
298}
299
300static proc exParam()
301{
302  // Appel F4
303  LIB "ratgb.lib";
304  ring r = (0,a,b,c,d),(x,y,Dx,Dy),(a(0,0,1,1),dp);
305  matrix @D[4][4];
306  @D[1,3]=1; @D[2,4]=1;
307  def S=nc_algebra(1,@D);
308  setring S;
309  ideal I =
310    x*Dx*(x*Dx+c-1) - x*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b),
311    y*Dy*(y*Dy+d-1) - y*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b);
312  def A = ratstd(I,2);
313  pGBid; // polynomial form
314  setring A;
315  rGBid; // rational form
316}
Note: See TracBrowser for help on using the repository browser.