source: git/Singular/LIB/ratgb.lib @ 9689f2

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