[f22a08] | 1 | // $Id: standard.lib,v 1.23 1998-06-18 18:03:19 Singular Exp $ |
---|
[6149f4f] | 2 | ////////////////////////////////////////////////////////////////////////////// |
---|
[2f2af5] | 3 | |
---|
[f22a08] | 4 | version="$Id: standard.lib,v 1.23 1998-06-18 18:03:19 Singular Exp $"; |
---|
[5480da] | 5 | info=" |
---|
[82716e] | 6 | LIBRARY: standard.lib PROCEDURES WHICH ARE ALWAYS LOADED AT START-UP |
---|
[2f2af5] | 7 | |
---|
| 8 | stdfglm(ideal[,ord]) standard basis of the ideal via fglm [and ordering ord] |
---|
[78388a] | 9 | stdhilb(ideal) standard basis of the ideal using the Hilbert function |
---|
[3939bc] | 10 | groebner(ideal/module) standard basis of ideal or module using a |
---|
| 11 | heuristically choosen method |
---|
[aa6e78] | 12 | quotient(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 |
---|
[5480da] | 23 | "; |
---|
| 24 | |
---|
[6149f4f] | 25 | ////////////////////////////////////////////////////////////////////////////// |
---|
[2f2af5] | 26 | |
---|
| 27 | proc stdfglm (ideal i, list #) |
---|
[d2b2a7] | 28 | "USAGE: stdfglm(i[,s]); i ideal, s string (any allowed ordstr of a ring) |
---|
[0fbdd1] | 29 | RETURN: stdfglm(i): standard basis of i in the basering, calculated via fglm |
---|
[d2b2a7] | 30 | from ordering \"dp\" to the ordering of the basering. |
---|
[0fbdd1] | 31 | stdfglm(i,s): standard basis of i in the basering, calculated via |
---|
| 32 | fglm from ordering s to the ordering of the basering. |
---|
[5011fd] | 33 | EXAMPLE: example stdfglm; shows an example" |
---|
[2f2af5] | 34 | { |
---|
| 35 | string os; |
---|
| 36 | def dr= basering; |
---|
[f2ae935] | 37 | if( (size(#)==0) or (typeof(#[1]) != "string") ) |
---|
[2f2af5] | 38 | { |
---|
| 39 | os = "dp(" + string( nvars(dr) ) + ")"; |
---|
[f2ae935] | 40 | if ( (find( ordstr(dr), os ) != 0) and (find( ordstr(dr), "a") == 0) ) |
---|
[2f2af5] | 41 | { |
---|
| 42 | os= "Dp"; |
---|
[f2ae935] | 43 | } |
---|
| 44 | else |
---|
[2f2af5] | 45 | { |
---|
| 46 | os= "dp"; |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | else { os = #[1]; } |
---|
[283282f] | 50 | execute "ring sr=("+charstr(dr)+"),("+varstr(dr)+"),"+os+";"; |
---|
[2f2af5] | 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; |
---|
[f2ae935] | 61 | ring r = 0,(x,y,z),lp; |
---|
[0fbdd1] | 62 | ideal i = y3+x2, x2y+x2, x3-x2, z4-x2-y; |
---|
| 63 | ideal i1= stdfglm(i); //uses fglm from "dp" to "lp" |
---|
[f2ae935] | 64 | i1; |
---|
[0fbdd1] | 65 | ideal i2= stdfglm(i,"Dp"); //uses fglm from "Dp" to "lp" |
---|
| 66 | i2; |
---|
[2f2af5] | 67 | } |
---|
[6149f4f] | 68 | ///////////////////////////////////////////////////////////////////////////// |
---|
[bb0968] | 69 | |
---|
[78388a] | 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" |
---|
[bb0968] | 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 | } |
---|
[f2ae935] | 87 | |
---|
[bb0968] | 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); |
---|
[f2ae935] | 107 | attrib(a,"isSB",1); |
---|
[bb0968] | 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 | } |
---|
[f2ae935] | 122 | a=simplify(a,2); |
---|
| 123 | attrib(a,"isSB",1); |
---|
| 124 | return(a); |
---|
[bb0968] | 125 | } |
---|
| 126 | example |
---|
| 127 | { "EXAMPLE:"; echo = 2; |
---|
[f2ae935] | 128 | ring r = 0,(x,y,z),lp; |
---|
[0fbdd1] | 129 | ideal i = y3+x2, x2y+x2, x3-x2, z4-x2-y; |
---|
[78388a] | 130 | ideal i1= stdhilb(i); i1; |
---|
[0fbdd1] | 131 | // is in this case equivalent to: |
---|
| 132 | intvec v=1,0,0,-3,0,1,0,3,-1,-1; |
---|
[78388a] | 133 | ideal i2=stdhilb(i,v); |
---|
[bb0968] | 134 | } |
---|
[6149f4f] | 135 | ////////////////////////////////////////////////////////////////////////// |
---|
[bb0968] | 136 | |
---|
[45f7bf] | 137 | proc groebner(def i, list #) |
---|
[6149f4f] | 138 | "USAGE: groebner(i[, wait]) i -- ideal/module; wait -- int |
---|
[3939bc] | 139 | RETURNS: Standard basis of ideal or module which is computed using a |
---|
| 140 | heuristically choosen method: |
---|
[6149f4f] | 141 | If the ordering of the current ring is a local ordering, or |
---|
[45f7bf] | 142 | if it is a non-block ordering and the current ring has no |
---|
[3939bc] | 143 | parameters, then std(i) is returned. |
---|
[45f7bf] | 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. |
---|
[6149f4f] | 148 | NOTE: If a 2nd argument 'wait' is given, then the computation proceeds |
---|
[3939bc] | 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. |
---|
[45f7bf] | 153 | EXAMPLE: example groebner; shows an example" |
---|
| 154 | { |
---|
| 155 | def P=basering; |
---|
[6149f4f] | 156 | |
---|
| 157 | // we have two arguments -- try to use MPfork links |
---|
[45f7bf] | 158 | if (size(#) > 0) |
---|
| 159 | { |
---|
| 160 | if (system("with", "MP")) |
---|
| 161 | { |
---|
| 162 | if (typeof(#[1]) == "int") |
---|
| 163 | { |
---|
[e665360] | 164 | int wait = #[1]; |
---|
| 165 | int j = 10; |
---|
[3939bc] | 166 | |
---|
[45f7bf] | 167 | string bs = nameof(basering); |
---|
| 168 | link l_fork = "MPtcp:fork"; |
---|
| 169 | open(l_fork); |
---|
| 170 | write(l_fork, quote(system("pid"))); |
---|
[6149f4f] | 171 | int pid = read(l_fork); |
---|
[45f7bf] | 172 | write(l_fork, quote(groebner(eval(i)))); |
---|
[3939bc] | 173 | |
---|
[e665360] | 174 | // sleep in small intervalls for appr. one second |
---|
| 175 | if (wait > 0) |
---|
[45f7bf] | 176 | { |
---|
[e665360] | 177 | while(j < 1000000) |
---|
| 178 | { |
---|
| 179 | if (status(l_fork, "read", "ready", j)) {break;} |
---|
| 180 | j = j + j; |
---|
| 181 | } |
---|
[45f7bf] | 182 | } |
---|
[3939bc] | 183 | |
---|
[e665360] | 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 | } |
---|
[3939bc] | 191 | |
---|
[45f7bf] | 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 | } |
---|
[6149f4f] | 202 | if (defined(groebner_error)) |
---|
| 203 | { |
---|
| 204 | kill(groebner_error); |
---|
| 205 | } |
---|
[45f7bf] | 206 | kill (l_fork); |
---|
| 207 | } |
---|
| 208 | else |
---|
| 209 | { |
---|
| 210 | ideal result; |
---|
| 211 | if (! defined(groebner_error)) |
---|
| 212 | { |
---|
[6149f4f] | 213 | int groebner_error = 1; |
---|
[45f7bf] | 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 | { |
---|
[6fa72f7] | 228 | "// ** groebner with two args is not supported in this configuration"; |
---|
[45f7bf] | 229 | } |
---|
| 230 | } |
---|
| 231 | |
---|
[6149f4f] | 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 | } |
---|
[3939bc] | 239 | |
---|
[6149f4f] | 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); |
---|
[45f7bf] | 249 | |
---|
[6149f4f] | 250 | // return std if no parameters and (dp or wp) |
---|
[6fa72f7] | 251 | if ((npars_P <= 1) && IsSimple_P) |
---|
[6149f4f] | 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 | } |
---|
[45f7bf] | 262 | |
---|
[6149f4f] | 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 | } |
---|
[3939bc] | 278 | |
---|
[6149f4f] | 279 | // construct ring in which first std computation is done |
---|
| 280 | string varstr_P = varstr(P); |
---|
| 281 | string parstr_P = parstr(P); |
---|
[6fa72f7] | 282 | int is_homog = (homog(i) && (npars_P <= 1)); |
---|
| 283 | int add_vars = 0; |
---|
| 284 | string ri = "ring Phelp ="; |
---|
[bcd557] | 285 | |
---|
[6fa72f7] | 286 | // more than one parameters are converted to ring variables |
---|
| 287 | if (npars_P > 1) |
---|
[6149f4f] | 288 | { |
---|
[6fa72f7] | 289 | ri = ri + string(char(P)) + ",(" + varstr_P + "," + parstr_P; |
---|
| 290 | add_vars = npars_P; |
---|
[6149f4f] | 291 | } |
---|
[6fa72f7] | 292 | else |
---|
| 293 | { |
---|
| 294 | ri = ri + "(" + charstr(P) + "),(" + varstr_P; |
---|
| 295 | } |
---|
| 296 | |
---|
[6149f4f] | 297 | // a homogenizing variable is added, if necessary |
---|
| 298 | if (! is_homog) |
---|
| 299 | { |
---|
| 300 | ri = ri + ",@t"; |
---|
[6fa72f7] | 301 | add_vars = add_vars + 1; |
---|
[6149f4f] | 302 | } |
---|
| 303 | // ordering is set to (dp, C) |
---|
| 304 | ri = ri + "),(dp,C);"; |
---|
[45f7bf] | 305 | |
---|
[6149f4f] | 306 | // change the ring |
---|
| 307 | execute(ri); |
---|
[3939bc] | 308 | |
---|
[6149f4f] | 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 | } |
---|
[3939bc] | 319 | |
---|
[6149f4f] | 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); |
---|
[45f7bf] | 327 | |
---|
[6fa72f7] | 328 | if (add_vars == 0) |
---|
[6149f4f] | 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 |
---|
[bcd557] | 343 | ri = "ring Phelp1 = (" + charstr(Phelp) |
---|
[6fa72f7] | 344 | + "),(" + varstr(Phelp) + "),(" + ordstr_P; |
---|
[3939bc] | 345 | |
---|
[6fa72f7] | 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"))) |
---|
[6149f4f] | 348 | { |
---|
| 349 | // need block ordering |
---|
[6fa72f7] | 350 | ri = ri + ", dp(" + string(add_vars) + ")"; |
---|
[6149f4f] | 351 | } |
---|
| 352 | ri = ri + ");"; |
---|
[3939bc] | 353 | |
---|
[6149f4f] | 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 | } |
---|
[3939bc] | 369 | |
---|
[6149f4f] | 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 | } |
---|
[45f7bf] | 377 | |
---|
[6149f4f] | 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); |
---|
[45f7bf] | 386 | } |
---|
| 387 | example |
---|
| 388 | { |
---|
| 389 | "EXAMPLE: "; echo = 2; |
---|
| 390 | ring r = 0, (a,b,c,d), lp; |
---|
[3939bc] | 391 | option(prot); |
---|
[45f7bf] | 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); |
---|
[6149f4f] | 399 | if (system("with", "MP")) {groebner(i, 0);} |
---|
| 400 | defined(groebner_error); |
---|
[45f7bf] | 401 | } |
---|
| 402 | |
---|
[6149f4f] | 403 | |
---|
| 404 | ////////////////////////////////////////////////////////////////////////// |
---|
[3939bc] | 405 | proc res(list #) |
---|
[6149f4f] | 406 | { |
---|
| 407 | def P=basering; |
---|
| 408 | def m=#[1]; //the ideal or module |
---|
[3939bc] | 409 | |
---|
[6149f4f] | 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; |
---|
[64c6d1] | 433 | resolution result=imap(Phelp,re); |
---|
[3939bc] | 434 | return(result); |
---|
[6149f4f] | 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; |
---|
[64c6d1] | 447 | resolution result=imap(Phelp,re); |
---|
[6149f4f] | 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; |
---|
[64c6d1] | 458 | resolution result=imap(Phelp,re); |
---|
[3939bc] | 459 | return(result); |
---|
[6149f4f] | 460 | } |
---|
| 461 | |
---|
[f22a08] | 462 | proc quotient (any m1,any m2,list #) |
---|
[300a34] | 463 | "USAGE: quotient(m1, m2[, n]); m1, m2 two submodules of k^s, |
---|
[aa6e78] | 464 | n (optional) integer (1<= n <=5) |
---|
| 465 | RETURN: the quotient of m1 and m2 |
---|
[300a34] | 466 | EXAMPLE: example quot; shows an example" |
---|
[aa6e78] | 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 quot(m1,m2); |
---|
| 480 | } |
---|
[f22a08] | 481 | if (size(#)>0) |
---|
[aa6e78] | 482 | { |
---|
[f22a08] | 483 | if (typeof(#[1])=="int" ) |
---|
[aa6e78] | 484 | { |
---|
[f22a08] | 485 | return quot1(m1,m2,#[1]); |
---|
[aa6e78] | 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=quot(id1,id2); |
---|
| 500 | id6; |
---|
| 501 | ideal id7=quotient(id1,id2,1); |
---|
| 502 | id7; |
---|
| 503 | ideal id8=quotient(id1,id2,2); |
---|
| 504 | id8; |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | static proc quot1 (module m1, module m2,int n) |
---|
[300a34] | 508 | "USAGE: quot1(m1, m2, n); m1, m2 two submodules of k^s, |
---|
[aa6e78] | 509 | n integer (1<= n <=5) |
---|
| 510 | RETURN: the quotient of m1 and m2 |
---|
[300a34] | 511 | EXAMPLE: example quot; shows an example" |
---|
[aa6e78] | 512 | { |
---|
| 513 | if (n==1) |
---|
| 514 | { |
---|
| 515 | return(quotient1(m1,m2)); |
---|
| 516 | } |
---|
[300a34] | 517 | else |
---|
| 518 | { |
---|
[aa6e78] | 519 | if (n==2) |
---|
| 520 | { |
---|
| 521 | return(quotient2(m1,m2)); |
---|
| 522 | } |
---|
[300a34] | 523 | else |
---|
| 524 | { |
---|
[aa6e78] | 525 | if (n==3) |
---|
| 526 | { |
---|
| 527 | return(quotient3(m1,m2)); |
---|
| 528 | } |
---|
[300a34] | 529 | else |
---|
| 530 | { |
---|
[aa6e78] | 531 | if (n==4) |
---|
| 532 | { |
---|
| 533 | return(quotient4(m1,m2)); |
---|
| 534 | } |
---|
[300a34] | 535 | else |
---|
| 536 | { |
---|
[aa6e78] | 537 | if (n==5) |
---|
| 538 | { |
---|
| 539 | return(quotient5(m1,m2)); |
---|
| 540 | } |
---|
| 541 | else |
---|
| 542 | { |
---|
| 543 | return(quotient(m1,m2)); |
---|
| 544 | } |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | } |
---|
[300a34] | 548 | } |
---|
[aa6e78] | 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=quot(id1,id2); |
---|
| 557 | id6; |
---|
| 558 | ideal id7=quot1(id1,id2,1); |
---|
| 559 | id7; |
---|
| 560 | ideal id8=quot1(id1,id2,2); |
---|
| 561 | id8; |
---|
| 562 | } |
---|
| 563 | |
---|
[300a34] | 564 | static proc quotient0(module a,module b) |
---|
[aa6e78] | 565 | { |
---|
| 566 | module mm=b+a; |
---|
| 567 | resolution rs=system("LaScala",mm); |
---|
| 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 |
---|
[300a34] | 575 | "USAGE: quotient1(m1, m2); m1, m2 two submodules of k^s, |
---|
| 576 | RETURN: the quotient of m1 and m2" |
---|
[aa6e78] | 577 | { |
---|
| 578 | int i; |
---|
| 579 | a=std(a); |
---|
| 580 | module dummy; |
---|
| 581 | module B=NF(b,a)+dummy; |
---|
| 582 | ideal re=quot(a,module(B[1])); |
---|
| 583 | for(i=2;i<=size(B);i++) |
---|
| 584 | { |
---|
| 585 | re=intersect1(re,quot(a,module(B[i]))); |
---|
| 586 | } |
---|
[300a34] | 587 | return(re); |
---|
[aa6e78] | 588 | } |
---|
| 589 | proc quotient2(module a,module b) //13sec |
---|
[300a34] | 590 | "USAGE: quotient2(m1, m2); m1, m2 two submodules of k^s, |
---|
| 591 | RETURN: the quotient of m1 and m2" |
---|
[aa6e78] | 592 | { |
---|
| 593 | a=std(a); |
---|
| 594 | module dummy; |
---|
| 595 | module bb=NF(b,a)+dummy; |
---|
| 596 | int i=size(bb); |
---|
| 597 | ideal re=(quot(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,quot(a,module(bb[i])))); |
---|
| 618 | bb[i]=0; |
---|
| 619 | i = i-1; |
---|
| 620 | } |
---|
[300a34] | 621 | return(re); |
---|
[aa6e78] | 622 | } |
---|
| 623 | proc quotient3(module a,module b) //89sec |
---|
[300a34] | 624 | "USAGE: quotient3(m1, m2); m1, m2 two submodules of k^s, |
---|
[aa6e78] | 625 | only for global rings |
---|
[300a34] | 626 | RETURN: the quotient of m1 and m2" |
---|
[aa6e78] | 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=quot(a,module(@b)); |
---|
| 642 | setring @newP; |
---|
| 643 | ideal re=imap(@newr,re); |
---|
[300a34] | 644 | return(re); |
---|
[aa6e78] | 645 | } |
---|
| 646 | proc quotient5(module a,module b) //89sec |
---|
[300a34] | 647 | "USAGE: quotient5(m1, m2); m1, m2 two submodules of k^s, |
---|
[aa6e78] | 648 | only for global rings |
---|
[300a34] | 649 | RETURN: the quotient of m1 and m2" |
---|
[aa6e78] | 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=quot(a,module(@b)); |
---|
| 666 | setring @newP; |
---|
| 667 | ideal re=imap(@newr,re); |
---|
[300a34] | 668 | return(re); |
---|
[aa6e78] | 669 | } |
---|
| 670 | proc quotient4(module a,module b) //95sec |
---|
[300a34] | 671 | "USAGE: quotient4(m1, m2); m1, m2 two submodules of k^s, |
---|
[aa6e78] | 672 | only for global rings |
---|
[300a34] | 673 | RETURN: the quotient of m1 and m2" |
---|
[aa6e78] | 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); |
---|
[300a34] | 691 | return(re); |
---|
[aa6e78] | 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 | } |
---|
[300a34] | 704 | |
---|
[64c6d1] | 705 | /* |
---|
| 706 | proc minres(list #) |
---|
[6149f4f] | 707 | { |
---|
[64c6d1] | 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 | } |
---|
[bcd557] | 718 | |
---|
[64c6d1] | 719 | if (typeof(#[1]) == "resolution") |
---|
| 720 | { |
---|
| 721 | return minimizeres(#[1]); |
---|
| 722 | } |
---|
| 723 | else |
---|
| 724 | { |
---|
| 725 | return minimizeres(#); |
---|
| 726 | } |
---|
[bcd557] | 727 | |
---|
[6149f4f] | 728 | } |
---|
[64c6d1] | 729 | |
---|
| 730 | */ |
---|