1 | // $Id: standard.lib,v 1.25 1998-06-19 08:01:51 Singular Exp $ |
---|
2 | ////////////////////////////////////////////////////////////////////////////// |
---|
3 | |
---|
4 | version="$Id: standard.lib,v 1.25 1998-06-19 08:01:51 Singular Exp $"; |
---|
5 | info=" |
---|
6 | LIBRARY: standard.lib PROCEDURES WHICH ARE ALWAYS LOADED AT START-UP |
---|
7 | |
---|
8 | stdfglm(ideal[,ord]) standard basis of the ideal via fglm [and ordering ord] |
---|
9 | stdhilb(ideal) standard basis of the ideal using the Hilbert function |
---|
10 | groebner(ideal/module) standard basis of ideal or module using a |
---|
11 | heuristically choosen method |
---|
12 | quot(any,any[,n]) a general quotient procedure calling several algorithms |
---|
13 | allows module/module, ideal/ideal, module/ideal and a |
---|
14 | pre-definition of the algorithm by the parameter n |
---|
15 | quotient1(m1,m2) computes quotients by every vector of m2 and intersects them |
---|
16 | quotient2(m1,m2) a heuristic variant: the quotient is just defined by a |
---|
17 | (not really) general element of m2 which has to be proved |
---|
18 | quotient3(m1,m2) the homogeneous variant of quotient5(m1,m2) |
---|
19 | quotient4(m1,m2) the same as quotient5(m1,m2) using the modulo-command |
---|
20 | instead of the quotient-command from the kernel |
---|
21 | quotient5(m1,m2) computes with a real general element of m2 by adjoining |
---|
22 | a new variable |
---|
23 | "; |
---|
24 | |
---|
25 | ////////////////////////////////////////////////////////////////////////////// |
---|
26 | |
---|
27 | proc stdfglm (ideal i, list #) |
---|
28 | "USAGE: stdfglm(i[,s]); i ideal, s string (any allowed ordstr of a ring) |
---|
29 | RETURN: stdfglm(i): standard basis of i in the basering, calculated via fglm |
---|
30 | from ordering \"dp\" to the ordering of the basering. |
---|
31 | stdfglm(i,s): standard basis of i in the basering, calculated via |
---|
32 | fglm from ordering s to the ordering of the basering. |
---|
33 | EXAMPLE: example stdfglm; shows an example" |
---|
34 | { |
---|
35 | string os; |
---|
36 | def dr= basering; |
---|
37 | if( (size(#)==0) or (typeof(#[1]) != "string") ) |
---|
38 | { |
---|
39 | os = "dp(" + string( nvars(dr) ) + ")"; |
---|
40 | if ( (find( ordstr(dr), os ) != 0) and (find( ordstr(dr), "a") == 0) ) |
---|
41 | { |
---|
42 | os= "Dp"; |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | os= "dp"; |
---|
47 | } |
---|
48 | } |
---|
49 | else { os = #[1]; } |
---|
50 | execute "ring sr=("+charstr(dr)+"),("+varstr(dr)+"),"+os+";"; |
---|
51 | ideal i= fetch(dr,i); |
---|
52 | intvec opt= option(get); |
---|
53 | option(redSB); |
---|
54 | i=std(i); |
---|
55 | option(set,opt); |
---|
56 | setring dr; |
---|
57 | return (fglm(sr,i)); |
---|
58 | } |
---|
59 | example |
---|
60 | { "EXAMPLE:"; echo = 2; |
---|
61 | ring r = 0,(x,y,z),lp; |
---|
62 | ideal i = y3+x2, x2y+x2, x3-x2, z4-x2-y; |
---|
63 | ideal i1= stdfglm(i); //uses fglm from "dp" to "lp" |
---|
64 | i1; |
---|
65 | ideal i2= stdfglm(i,"Dp"); //uses fglm from "Dp" to "lp" |
---|
66 | i2; |
---|
67 | } |
---|
68 | ///////////////////////////////////////////////////////////////////////////// |
---|
69 | |
---|
70 | proc stdhilb(ideal i,list #) |
---|
71 | "USAGE: stdhilb(i); i ideal |
---|
72 | stdhilb(i,v); i homogeneous ideal, v intvec (the Hilbert function) |
---|
73 | RETURN: stdhilb(i): a standard basis of i (computing v internally) |
---|
74 | stdhilb(i,v): standard basis of i, using the given Hilbert function |
---|
75 | EXAMPLE: example stdhilb; shows an example" |
---|
76 | { |
---|
77 | def R=basering; |
---|
78 | |
---|
79 | if((homog(i)==1)||(ordstr(basering)[1]=="d")) |
---|
80 | { |
---|
81 | if ((size(#)!=0)&&(homog(i)==1)) |
---|
82 | { |
---|
83 | return(std(i,#[1])); |
---|
84 | } |
---|
85 | return(std(i)); |
---|
86 | } |
---|
87 | |
---|
88 | execute "ring S = ("+charstr(R)+"),("+varstr(R)+",@t),dp;"; |
---|
89 | ideal i=homog(imap(R,i),@t); |
---|
90 | intvec v=hilb(std(i),1); |
---|
91 | execute "ring T = ("+charstr(R)+"),("+varstr(R)+",@t),("+ordstr(R)+");"; |
---|
92 | ideal i=fetch(S,i); |
---|
93 | ideal a=std(i,v); |
---|
94 | setring R; |
---|
95 | map phi=T,maxideal(1),1; |
---|
96 | ideal a=phi(a); |
---|
97 | |
---|
98 | int k,j; |
---|
99 | poly m; |
---|
100 | int c=size(i); |
---|
101 | |
---|
102 | for(j=1;j<c;j++) |
---|
103 | { |
---|
104 | if(deg(a[j])==0) |
---|
105 | { |
---|
106 | a=ideal(1); |
---|
107 | attrib(a,"isSB",1); |
---|
108 | return(a); |
---|
109 | } |
---|
110 | if(deg(a[j])>0) |
---|
111 | { |
---|
112 | m=lead(a[j]); |
---|
113 | for(k=j+1;k<=c;k++) |
---|
114 | { |
---|
115 | if(size(lead(a[k])/m)>0) |
---|
116 | { |
---|
117 | a[k]=0; |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | a=simplify(a,2); |
---|
123 | attrib(a,"isSB",1); |
---|
124 | return(a); |
---|
125 | } |
---|
126 | example |
---|
127 | { "EXAMPLE:"; echo = 2; |
---|
128 | ring r = 0,(x,y,z),lp; |
---|
129 | ideal i = y3+x2, x2y+x2, x3-x2, z4-x2-y; |
---|
130 | ideal i1= stdhilb(i); i1; |
---|
131 | // is in this case equivalent to: |
---|
132 | intvec v=1,0,0,-3,0,1,0,3,-1,-1; |
---|
133 | ideal i2=stdhilb(i,v); |
---|
134 | } |
---|
135 | ////////////////////////////////////////////////////////////////////////// |
---|
136 | |
---|
137 | proc groebner(def i, list #) |
---|
138 | "USAGE: groebner(i[, wait]) i -- ideal/module; wait -- int |
---|
139 | RETURNS: Standard basis of ideal or module which is computed using a |
---|
140 | heuristically choosen method: |
---|
141 | If the ordering of the current ring is a local ordering, or |
---|
142 | if it is a non-block ordering and the current ring has no |
---|
143 | parameters, then std(i) is returned. |
---|
144 | Otherwise, i is mapped into a ring with no parameters and |
---|
145 | ordering dp, where its Hilbert series is computed. This is |
---|
146 | followed by a Hilbert-series based std computation in the |
---|
147 | original ring. |
---|
148 | NOTE: If a 2nd argument 'wait' is given, then the computation proceeds |
---|
149 | at most 'wait' seconds. That is, if no result could be computed in |
---|
150 | 'wait' seconds, then the computation is interrupted, 0 is returned, |
---|
151 | a warning message is displayed, and the global variable |
---|
152 | 'groebner_error' is defined. |
---|
153 | EXAMPLE: example groebner; shows an example" |
---|
154 | { |
---|
155 | def P=basering; |
---|
156 | |
---|
157 | // we have two arguments -- try to use MPfork links |
---|
158 | if (size(#) > 0) |
---|
159 | { |
---|
160 | if (system("with", "MP")) |
---|
161 | { |
---|
162 | if (typeof(#[1]) == "int") |
---|
163 | { |
---|
164 | int wait = #[1]; |
---|
165 | int j = 10; |
---|
166 | |
---|
167 | string bs = nameof(basering); |
---|
168 | link l_fork = "MPtcp:fork"; |
---|
169 | open(l_fork); |
---|
170 | write(l_fork, quote(system("pid"))); |
---|
171 | int pid = read(l_fork); |
---|
172 | write(l_fork, quote(groebner(eval(i)))); |
---|
173 | |
---|
174 | // sleep in small intervalls for appr. one second |
---|
175 | if (wait > 0) |
---|
176 | { |
---|
177 | while(j < 1000000) |
---|
178 | { |
---|
179 | if (status(l_fork, "read", "ready", j)) {break;} |
---|
180 | j = j + j; |
---|
181 | } |
---|
182 | } |
---|
183 | |
---|
184 | // sleep in intervalls of one second from now on |
---|
185 | j = 1; |
---|
186 | while (j < wait) |
---|
187 | { |
---|
188 | if (status(l_fork, "read", "ready", 1000000)) {break;} |
---|
189 | j = j + 1; |
---|
190 | } |
---|
191 | |
---|
192 | if (status(l_fork, "read", "ready")) |
---|
193 | { |
---|
194 | def result = read(l_fork); |
---|
195 | if (bs != nameof(basering)) |
---|
196 | { |
---|
197 | def PP = basering; |
---|
198 | setring P; |
---|
199 | def result = imap(PP, result); |
---|
200 | kill PP; |
---|
201 | } |
---|
202 | if (defined(groebner_error)) |
---|
203 | { |
---|
204 | kill(groebner_error); |
---|
205 | } |
---|
206 | kill (l_fork); |
---|
207 | } |
---|
208 | else |
---|
209 | { |
---|
210 | ideal result; |
---|
211 | if (! defined(groebner_error)) |
---|
212 | { |
---|
213 | int groebner_error = 1; |
---|
214 | export groebner_error; |
---|
215 | } |
---|
216 | "// ** groebner did not finish"; |
---|
217 | j = system("sh", "kill " + string(pid)); |
---|
218 | } |
---|
219 | return (result); |
---|
220 | } |
---|
221 | else |
---|
222 | { |
---|
223 | "// ** groebner needs int as 2nd arg"; |
---|
224 | } |
---|
225 | } |
---|
226 | else |
---|
227 | { |
---|
228 | "// ** groebner with two args is not supported in this configuration"; |
---|
229 | } |
---|
230 | } |
---|
231 | |
---|
232 | // we are still here -- do the actual computation |
---|
233 | string ordstr_P = ordstr(P); |
---|
234 | if (find(ordstr_P,"s") > 0) |
---|
235 | { |
---|
236 | //spaeter den lokalen fall ueber lp oder aehnlich behandeln |
---|
237 | return(std(i)); |
---|
238 | } |
---|
239 | |
---|
240 | int IsSimple_P; |
---|
241 | if (system("nblocks") <= 2) |
---|
242 | { |
---|
243 | if (find(ordstr_P, "M") <= 0) |
---|
244 | { |
---|
245 | IsSimple_P = 1; |
---|
246 | } |
---|
247 | } |
---|
248 | int npars_P = npars(P); |
---|
249 | |
---|
250 | // return std if no parameters and (dp or wp) |
---|
251 | if ((npars_P <= 1) && IsSimple_P) |
---|
252 | { |
---|
253 | if (find(ordstr_P, "d") > 0) |
---|
254 | { |
---|
255 | return (std(i)); |
---|
256 | } |
---|
257 | if (find(ordstr_P,"w") > 0) |
---|
258 | { |
---|
259 | return (std(i)); |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | // reset options |
---|
264 | intvec opt=option(get); |
---|
265 | int p_opt; |
---|
266 | string s_opt = option(); |
---|
267 | option(none); |
---|
268 | // turn on option(prot) and/or option(mem), if previously set |
---|
269 | if (find(s_opt, "prot")) |
---|
270 | { |
---|
271 | option(prot); |
---|
272 | p_opt = 1; |
---|
273 | } |
---|
274 | if (find(s_opt, "mem")) |
---|
275 | { |
---|
276 | option(mem); |
---|
277 | } |
---|
278 | |
---|
279 | // construct ring in which first std computation is done |
---|
280 | string varstr_P = varstr(P); |
---|
281 | string parstr_P = parstr(P); |
---|
282 | int is_homog = (homog(i) && (npars_P <= 1)); |
---|
283 | int add_vars = 0; |
---|
284 | string ri = "ring Phelp ="; |
---|
285 | |
---|
286 | // more than one parameters are converted to ring variables |
---|
287 | if (npars_P > 1) |
---|
288 | { |
---|
289 | ri = ri + string(char(P)) + ",(" + varstr_P + "," + parstr_P; |
---|
290 | add_vars = npars_P; |
---|
291 | } |
---|
292 | else |
---|
293 | { |
---|
294 | ri = ri + "(" + charstr(P) + "),(" + varstr_P; |
---|
295 | } |
---|
296 | |
---|
297 | // a homogenizing variable is added, if necessary |
---|
298 | if (! is_homog) |
---|
299 | { |
---|
300 | ri = ri + ",@t"; |
---|
301 | add_vars = add_vars + 1; |
---|
302 | } |
---|
303 | // ordering is set to (dp, C) |
---|
304 | ri = ri + "),(dp,C);"; |
---|
305 | |
---|
306 | // change the ring |
---|
307 | execute(ri); |
---|
308 | |
---|
309 | // get ideal from previous ring |
---|
310 | if (is_homog) |
---|
311 | { |
---|
312 | ideal qh = imap(P, i); |
---|
313 | } |
---|
314 | else |
---|
315 | { |
---|
316 | // and homogenize |
---|
317 | ideal qh=homog(imap(P,i),@t); |
---|
318 | } |
---|
319 | |
---|
320 | // compute std and hilbert series |
---|
321 | if (p_opt) |
---|
322 | { |
---|
323 | "std in " + ri[13, size(ri) - 13]; |
---|
324 | } |
---|
325 | ideal qh1=std(qh); |
---|
326 | intvec hi=hilb(qh1,1); |
---|
327 | |
---|
328 | if (add_vars == 0) |
---|
329 | { |
---|
330 | // no additional variables were introduced |
---|
331 | setring P; // can immediately change to original ring |
---|
332 | // simply compute std with hilbert series in original ring |
---|
333 | if (p_opt) |
---|
334 | { |
---|
335 | "std with hilb in basering"; |
---|
336 | i = std(i, hi); |
---|
337 | } |
---|
338 | } |
---|
339 | else |
---|
340 | { |
---|
341 | // additional variables were introduced |
---|
342 | // need another intermediate ring |
---|
343 | ri = "ring Phelp1 = (" + charstr(Phelp) |
---|
344 | + "),(" + varstr(Phelp) + "),(" + ordstr_P; |
---|
345 | |
---|
346 | // for lp wit at most one parameter, we do not need a block ordering |
---|
347 | if ( ! (IsSimple_P && (add_vars <2) && find(ordstr_P, "l"))) |
---|
348 | { |
---|
349 | // need block ordering |
---|
350 | ri = ri + ", dp(" + string(add_vars) + ")"; |
---|
351 | } |
---|
352 | ri = ri + ");"; |
---|
353 | |
---|
354 | // change to intermediate ring |
---|
355 | execute(ri); |
---|
356 | ideal qh = imap(Phelp, qh); |
---|
357 | kill Phelp; |
---|
358 | if (p_opt) |
---|
359 | { |
---|
360 | "std with hilb in " + ri[14,size(ri)-14]; |
---|
361 | } |
---|
362 | // compute std with Hilbert series |
---|
363 | qh = std(qh, hi); |
---|
364 | // subst 1 for homogenizing var |
---|
365 | if (!is_homog) |
---|
366 | { |
---|
367 | qh = subst(qh, @t, 1); |
---|
368 | } |
---|
369 | |
---|
370 | // go back to original ring |
---|
371 | setring P; |
---|
372 | // get ideal, delete zeros and clean SB |
---|
373 | i = imap(Phelp1,qh); |
---|
374 | i = simplify(i, 34); |
---|
375 | kill Phelp1; |
---|
376 | } |
---|
377 | |
---|
378 | // clean-up time |
---|
379 | option(set, opt); |
---|
380 | if (find(s_opt, "redSB") > 0) |
---|
381 | { |
---|
382 | i=interred(i); |
---|
383 | } |
---|
384 | attrib(i, "isSB", 1); |
---|
385 | return (i); |
---|
386 | } |
---|
387 | example |
---|
388 | { |
---|
389 | "EXAMPLE: "; echo = 2; |
---|
390 | ring r = 0, (a,b,c,d), lp; |
---|
391 | option(prot); |
---|
392 | ideal i = a+b+c+d, ab+ad+bc+cd, abc+abd+acd+bcd, abcd-1; // cyclic 4 |
---|
393 | groebner(i); |
---|
394 | ring rp = (0, a, b), (c,d), lp; |
---|
395 | ideal i = imap(r, i); |
---|
396 | ideal j = groebner(i); |
---|
397 | option(noprot); |
---|
398 | j; simplify(j, 1); std(i); |
---|
399 | if (system("with", "MP")) {groebner(i, 0);} |
---|
400 | defined(groebner_error); |
---|
401 | } |
---|
402 | |
---|
403 | |
---|
404 | ////////////////////////////////////////////////////////////////////////// |
---|
405 | proc res(list #) |
---|
406 | { |
---|
407 | def P=basering; |
---|
408 | def m=#[1]; //the ideal or module |
---|
409 | |
---|
410 | int i=#[2]; //the length of the resolution |
---|
411 | //if size(#)>2 a minimal resolution is computed |
---|
412 | |
---|
413 | //LaScala for the homogeneous case |
---|
414 | if(homog(m)==1) |
---|
415 | { |
---|
416 | resolution re=lres(m,i); |
---|
417 | if(size(#)>2) |
---|
418 | { |
---|
419 | re=minres(re); |
---|
420 | } |
---|
421 | return(re); |
---|
422 | } |
---|
423 | |
---|
424 | //mres for the global non homogeneous case |
---|
425 | if(find(ordstr(P),"s")==0) |
---|
426 | { |
---|
427 | string ri= "ring Phelp =" |
---|
428 | +string(char(P))+",("+varstr_P+"),(dp,C);"; |
---|
429 | execute(ri); |
---|
430 | def m=imap(P,m); |
---|
431 | list re=mres(m,i); |
---|
432 | setring P; |
---|
433 | resolution result=imap(Phelp,re); |
---|
434 | return(result); |
---|
435 | } |
---|
436 | |
---|
437 | //sres for the local case and not minimal resolution |
---|
438 | if(size(#)<=2) |
---|
439 | { |
---|
440 | string ri= "ring Phelp =" |
---|
441 | +string(char(P))+",("+varstr_P+"),(ls,c);"; |
---|
442 | execute(ri); |
---|
443 | def m=imap(P,m); |
---|
444 | m=std(m); |
---|
445 | list re=sres(m,i); |
---|
446 | setring P; |
---|
447 | resolution result=imap(Phelp,re); |
---|
448 | return(result); |
---|
449 | } |
---|
450 | |
---|
451 | //mres for the local case and minimal resolution |
---|
452 | string ri= "ring Phelp =" |
---|
453 | +string(char(P))+",("+varstr_P+"),(ls,C);"; |
---|
454 | execute(ri); |
---|
455 | def m=imap(P,m); |
---|
456 | list re=mres(m,i); |
---|
457 | setring P; |
---|
458 | resolution result=imap(Phelp,re); |
---|
459 | return(result); |
---|
460 | } |
---|
461 | |
---|
462 | proc quot (m1,m2,list #) |
---|
463 | "USAGE: quot(m1, m2[, n]); m1, m2 two submodules of k^s, |
---|
464 | n (optional) integer (1<= n <=5) |
---|
465 | RETURN: the quotient of m1 and m2 |
---|
466 | EXAMPLE: example quot; shows an example" |
---|
467 | { |
---|
468 | if (((typeof(m1)!="ideal") and (typeof(m1)!="module")) |
---|
469 | or ((typeof(m2)!="ideal") and (typeof(m2)!="module"))) |
---|
470 | { |
---|
471 | "USAGE: quot(m1, m2[, n]); m1, m2 two submodules of k^s,"; |
---|
472 | " n (optional) integer (1<= n <=5)"; |
---|
473 | "RETURN: the quotient of m1 and m2"; |
---|
474 | "EXAMPLE: example quot; shows an example"; |
---|
475 | return(); |
---|
476 | } |
---|
477 | if (typeof(m1)!=typeof(m2)) |
---|
478 | { |
---|
479 | return(quotient(m1,m2)); |
---|
480 | } |
---|
481 | if (size(#)>0) |
---|
482 | { |
---|
483 | if (typeof(#[1])=="int" ) |
---|
484 | { |
---|
485 | return(quot1(m1,m2,#[1])); |
---|
486 | } |
---|
487 | } |
---|
488 | else |
---|
489 | { |
---|
490 | return(quot1(m1,m2,2)); |
---|
491 | } |
---|
492 | } |
---|
493 | example |
---|
494 | { "EXAMPLE:"; echo = 2; |
---|
495 | ring r=181,(x,y,z),(c,ls); |
---|
496 | ideal id1=maxideal(4); |
---|
497 | ideal id2=x2+xyz,y2-z3y,z3+y5xz; |
---|
498 | option(prot); |
---|
499 | ideal id6=quotient(id1,id2); |
---|
500 | id6; |
---|
501 | ideal id7=quot(id1,id2,1); |
---|
502 | id7; |
---|
503 | ideal id8=quot(id1,id2,2); |
---|
504 | id8; |
---|
505 | } |
---|
506 | |
---|
507 | static proc quot1 (module m1, module m2,int n) |
---|
508 | "USAGE: quot1(m1, m2, n); m1, m2 two submodules of k^s, |
---|
509 | n integer (1<= n <=5) |
---|
510 | RETURN: the quotient of m1 and m2 |
---|
511 | EXAMPLE: example quot1; shows an example" |
---|
512 | { |
---|
513 | if (n==1) |
---|
514 | { |
---|
515 | return(quotient1(m1,m2)); |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | if (n==2) |
---|
520 | { |
---|
521 | return(quotient2(m1,m2)); |
---|
522 | } |
---|
523 | else |
---|
524 | { |
---|
525 | if (n==3) |
---|
526 | { |
---|
527 | return(quotient3(m1,m2)); |
---|
528 | } |
---|
529 | else |
---|
530 | { |
---|
531 | if (n==4) |
---|
532 | { |
---|
533 | return(quotient4(m1,m2)); |
---|
534 | } |
---|
535 | else |
---|
536 | { |
---|
537 | if (n==5) |
---|
538 | { |
---|
539 | return(quotient5(m1,m2)); |
---|
540 | } |
---|
541 | else |
---|
542 | { |
---|
543 | return(quotient(m1,m2)); |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | } |
---|
548 | } |
---|
549 | } |
---|
550 | example |
---|
551 | { "EXAMPLE:"; echo = 2; |
---|
552 | ring r=181,(x,y,z),(c,ls); |
---|
553 | ideal id1=maxideal(4); |
---|
554 | ideal id2=x2+xyz,y2-z3y,z3+y5xz; |
---|
555 | option(prot); |
---|
556 | ideal id6=quotient(id1,id2); |
---|
557 | id6; |
---|
558 | ideal id7=quot1(id1,id2,1); |
---|
559 | id7; |
---|
560 | ideal id8=quot1(id1,id2,2); |
---|
561 | id8; |
---|
562 | } |
---|
563 | |
---|
564 | static proc quotient0(module a,module b) |
---|
565 | { |
---|
566 | module mm=b+a; |
---|
567 | resolution rs=lres(mm,0); |
---|
568 | list I=list(rs); |
---|
569 | matrix M=I[2]; |
---|
570 | matrix A[1][nrows(M)]=M[1..nrows(M),1]; |
---|
571 | ideal i=A; |
---|
572 | return (i); |
---|
573 | } |
---|
574 | proc quotient1(module a,module b) //17sec |
---|
575 | "USAGE: quotient1(m1, m2); m1, m2 two submodules of k^s, |
---|
576 | RETURN: the quotient of m1 and m2" |
---|
577 | { |
---|
578 | int i; |
---|
579 | a=std(a); |
---|
580 | module dummy; |
---|
581 | module B=NF(b,a)+dummy; |
---|
582 | ideal re=quotient(a,module(B[1])); |
---|
583 | for(i=2;i<=size(B);i++) |
---|
584 | { |
---|
585 | re=intersect1(re,quotient(a,module(B[i]))); |
---|
586 | } |
---|
587 | return(re); |
---|
588 | } |
---|
589 | proc quotient2(module a,module b) //13sec |
---|
590 | "USAGE: quotient2(m1, m2); m1, m2 two submodules of k^s, |
---|
591 | RETURN: the quotient of m1 and m2" |
---|
592 | { |
---|
593 | a=std(a); |
---|
594 | module dummy; |
---|
595 | module bb=NF(b,a)+dummy; |
---|
596 | int i=size(bb); |
---|
597 | ideal re=quotient(a,module(bb[i])); |
---|
598 | bb[i]=0; |
---|
599 | module temp; |
---|
600 | module temp1; |
---|
601 | module bbb; |
---|
602 | int mx; |
---|
603 | i=i-1; |
---|
604 | while (1) |
---|
605 | { |
---|
606 | if (i==0) break; |
---|
607 | temp = a+bb*re; |
---|
608 | temp1 = lead(interred(temp)); |
---|
609 | mx=ncols(a); |
---|
610 | if (ncols(temp1)>ncols(a)) |
---|
611 | { |
---|
612 | mx=ncols(temp1); |
---|
613 | } |
---|
614 | temp1 = matrix(temp1,1,mx)-matrix(lead(a),1,mx); |
---|
615 | temp1 = dummy+temp1; |
---|
616 | if (deg(temp1[1])<0) break; |
---|
617 | re=intersect1(re,quotient(a,module(bb[i]))); |
---|
618 | bb[i]=0; |
---|
619 | i = i-1; |
---|
620 | } |
---|
621 | return(re); |
---|
622 | } |
---|
623 | proc quotient3(module a,module b) //89sec |
---|
624 | "USAGE: quotient3(m1, m2); m1, m2 two submodules of k^s, |
---|
625 | only for global rings |
---|
626 | RETURN: the quotient of m1 and m2" |
---|
627 | { |
---|
628 | string s="ring @newr=("+charstr(basering)+ |
---|
629 | "),("+varstr(basering)+",@t,@w),dp;"; |
---|
630 | def @newP=basering; |
---|
631 | execute s; |
---|
632 | module b=imap(@newP,b); |
---|
633 | module a=imap(@newP,a); |
---|
634 | int i; |
---|
635 | int j=size(b); |
---|
636 | vector @b; |
---|
637 | for(i=1;i<=j;i++) |
---|
638 | { |
---|
639 | @b=@b+@t^(i-1)*@w^(j-i+1)*b[i]; |
---|
640 | } |
---|
641 | ideal re=quotient(a,module(@b)); |
---|
642 | setring @newP; |
---|
643 | ideal re=imap(@newr,re); |
---|
644 | return(re); |
---|
645 | } |
---|
646 | proc quotient5(module a,module b) //89sec |
---|
647 | "USAGE: quotient5(m1, m2); m1, m2 two submodules of k^s, |
---|
648 | only for global rings |
---|
649 | RETURN: the quotient of m1 and m2" |
---|
650 | { |
---|
651 | string s="ring @newr=("+charstr(basering)+ |
---|
652 | "),("+varstr(basering)+",@t),dp;"; |
---|
653 | def @newP=basering; |
---|
654 | execute s; |
---|
655 | module b=imap(@newP,b); |
---|
656 | module a=imap(@newP,a); |
---|
657 | int i; |
---|
658 | int j=size(b); |
---|
659 | vector @b; |
---|
660 | for(i=1;i<=j;i++) |
---|
661 | { |
---|
662 | @b=@b+@t^(i-1)*b[i]; |
---|
663 | } |
---|
664 | @b=homog(@b,@w); |
---|
665 | ideal re=quotient(a,module(@b)); |
---|
666 | setring @newP; |
---|
667 | ideal re=imap(@newr,re); |
---|
668 | return(re); |
---|
669 | } |
---|
670 | proc quotient4(module a,module b) //95sec |
---|
671 | "USAGE: quotient4(m1, m2); m1, m2 two submodules of k^s, |
---|
672 | only for global rings |
---|
673 | RETURN: the quotient of m1 and m2" |
---|
674 | { |
---|
675 | string s="ring @newr=("+charstr(basering)+ |
---|
676 | "),("+varstr(basering)+",@t),dp;"; |
---|
677 | def @newP=basering; |
---|
678 | execute s; |
---|
679 | module b=imap(@newP,b); |
---|
680 | module a=imap(@newP,a); |
---|
681 | int i; |
---|
682 | vector @b=b[1]; |
---|
683 | for(i=2;i<=size(b);i++) |
---|
684 | { |
---|
685 | @b=@b+@t^(i-1)*b[i]; |
---|
686 | } |
---|
687 | matrix sy=modulo(@b,a); |
---|
688 | ideal re=sy; |
---|
689 | setring @newP; |
---|
690 | ideal re=imap(@newr,re); |
---|
691 | return(re); |
---|
692 | } |
---|
693 | static proc intersect1(ideal i,ideal j) |
---|
694 | { |
---|
695 | def R=basering; |
---|
696 | execute "ring gnir = ("+charstr(basering)+"), |
---|
697 | ("+varstr(basering)+",@t),(C,dp);"; |
---|
698 | ideal i=var(nvars(basering))*imap(R,i)+(var(nvars(basering))-1)*imap(R,j); |
---|
699 | ideal j=eliminate(i,var(nvars(basering))); |
---|
700 | setring R; |
---|
701 | map phi=gnir,maxideal(1); |
---|
702 | return(phi(j)); |
---|
703 | } |
---|
704 | |
---|
705 | /* |
---|
706 | proc minres(list #) |
---|
707 | { |
---|
708 | if (size(#) == 2) |
---|
709 | { |
---|
710 | if (typeof(#[1]) == "ideal" || typeof(#[1]) == "module") |
---|
711 | { |
---|
712 | if (typeof(#[2] == "int")) |
---|
713 | { |
---|
714 | return (res(#[1],#[2],1)); |
---|
715 | } |
---|
716 | } |
---|
717 | } |
---|
718 | |
---|
719 | if (typeof(#[1]) == "resolution") |
---|
720 | { |
---|
721 | return minimizeres(#[1]); |
---|
722 | } |
---|
723 | else |
---|
724 | { |
---|
725 | return minimizeres(#); |
---|
726 | } |
---|
727 | |
---|
728 | } |
---|
729 | |
---|
730 | */ |
---|