[ac4f06e] | 1 | /////////////////////////////////////////////////////////////// |
---|
[16ad44] | 2 | // $Id: grwalk.lib,v 1.3 2005-06-06 11:26:46 Singular Exp $ // |
---|
[ac4f06e] | 3 | /////////////////////////////////////////////////////////////// |
---|
| 4 | |
---|
[16ad44] | 5 | version="$Id: grwalk.lib,v 1.3 2005-06-06 11:26:46 Singular Exp $"; |
---|
| 6 | category="Commutative Algebra"; |
---|
[3c4dcc] | 7 | |
---|
| 8 | info=" |
---|
[16ad44] | 9 | LIBRARY: grwalk.lib Groebner Walk Conversion Algorithms |
---|
| 10 | AUTHOR: I Made Sulandra |
---|
[ac4f06e] | 11 | |
---|
| 12 | PROCEDURES: |
---|
| 13 | fwalk(ideal[,intvec]); standard basis of ideal via fractalwalk alg |
---|
| 14 | twalk(ideal[,intvec]); standard basis of ideal via Tran's alg |
---|
| 15 | awalk1(ideal[,intvec]); standard basis of ideal via the first alt. alg |
---|
| 16 | awalk2(ideal[,intvec]); standard basis of ideal via the second alt. alg |
---|
[16ad44] | 17 | pwalk(ideal[,intvec]); standard basis of ideal via perturbation walk alg |
---|
| 18 | gwalk(ideal[,intvec]); standard basis of ideal via groebnerwalk alg |
---|
[3c4dcc] | 19 | "; |
---|
| 20 | |
---|
[ac4f06e] | 21 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 22 | |
---|
[3c4dcc] | 23 | static proc OrderStringalp(string Wpal,list #) |
---|
[ac4f06e] | 24 | { |
---|
[3c4dcc] | 25 | int n= nvars(basering); |
---|
[ac4f06e] | 26 | string order_str; |
---|
[3c4dcc] | 27 | intvec curr_weight, target_weight; |
---|
| 28 | curr_weight = system("Mivdp",n); |
---|
| 29 | target_weight = system("Mivlp",n); |
---|
[ac4f06e] | 30 | |
---|
| 31 | if(size(#) != 0) |
---|
| 32 | { |
---|
| 33 | if(size(#) == 1) |
---|
| 34 | { |
---|
[3c4dcc] | 35 | if(typeof(#[1]) == "intvec") |
---|
[ac4f06e] | 36 | { |
---|
| 37 | if(Wpal == "al"){ |
---|
| 38 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 39 | } |
---|
| 40 | else { |
---|
| 41 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
[3c4dcc] | 42 | } |
---|
| 43 | curr_weight = #[1]; |
---|
[ac4f06e] | 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | if(typeof(#[1]) == "string") |
---|
| 48 | { |
---|
| 49 | if(#[1] == "Dp") { |
---|
| 50 | order_str = "Dp"; |
---|
| 51 | } |
---|
| 52 | else { |
---|
| 53 | order_str = "dp"; |
---|
| 54 | } |
---|
[3c4dcc] | 55 | } |
---|
[ac4f06e] | 56 | else { |
---|
| 57 | order_str = "dp"; |
---|
[3c4dcc] | 58 | } |
---|
[ac4f06e] | 59 | } |
---|
[3c4dcc] | 60 | } |
---|
| 61 | else |
---|
[ac4f06e] | 62 | { |
---|
| 63 | if(size(#) == 2) |
---|
| 64 | { |
---|
| 65 | if(typeof(#[2]) == "intvec") |
---|
| 66 | { |
---|
[3c4dcc] | 67 | target_weight = #[2]; |
---|
| 68 | } |
---|
[ac4f06e] | 69 | if(typeof(#[1]) == "intvec") |
---|
| 70 | { |
---|
| 71 | if(Wpal == "al"){ |
---|
| 72 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 73 | } |
---|
| 74 | else { |
---|
| 75 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
| 76 | } |
---|
[3c4dcc] | 77 | curr_weight = #[1]; |
---|
[ac4f06e] | 78 | } |
---|
| 79 | else |
---|
| 80 | { |
---|
| 81 | if(typeof(#[1]) == "string") |
---|
| 82 | { |
---|
| 83 | if(#[1] == "Dp") { |
---|
| 84 | order_str = "Dp"; |
---|
[3c4dcc] | 85 | } |
---|
| 86 | else { |
---|
| 87 | order_str = "dp"; |
---|
| 88 | } |
---|
[ac4f06e] | 89 | } |
---|
| 90 | else { |
---|
| 91 | order_str = "dp"; |
---|
| 92 | } |
---|
| 93 | } |
---|
[3c4dcc] | 94 | } |
---|
| 95 | } |
---|
[ac4f06e] | 96 | } |
---|
| 97 | else { |
---|
| 98 | order_str = "dp"; |
---|
| 99 | } |
---|
| 100 | list result; |
---|
| 101 | result[1] = order_str; |
---|
| 102 | result[2] = curr_weight; |
---|
[3c4dcc] | 103 | result[3] = target_weight; |
---|
[ac4f06e] | 104 | return(result); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | static proc OrderStringalp_NP(string Wpal,list #) |
---|
| 108 | { |
---|
| 109 | int n= nvars(basering); |
---|
| 110 | string order_str = "dp"; |
---|
[3c4dcc] | 111 | //string order_str = "Dp"; |
---|
[ac4f06e] | 112 | |
---|
| 113 | int nP = 1;// call LatsGB to compute the wanted GB by pwalk |
---|
| 114 | |
---|
| 115 | //Default: |
---|
| 116 | // if size(#)=0, the Gröbnerwalk algorithm and its developments compute |
---|
| 117 | // a Groebner basis from "dp" to "lp" |
---|
[3c4dcc] | 118 | |
---|
[ac4f06e] | 119 | intvec curr_weight = system("Mivdp",n); //define (1,1,...,1) |
---|
| 120 | intvec target_weight = system("Mivlp",n); //define (1,0,...,0) |
---|
| 121 | |
---|
| 122 | if(size(#) != 0) |
---|
| 123 | { |
---|
| 124 | if(size(#) == 1) |
---|
| 125 | { |
---|
| 126 | if(typeof(#[1]) == "intvec") { |
---|
[3c4dcc] | 127 | curr_weight = #[1]; |
---|
| 128 | |
---|
[ac4f06e] | 129 | if(Wpal == "al"){ |
---|
| 130 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 131 | } |
---|
| 132 | else { |
---|
| 133 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
[3c4dcc] | 134 | } |
---|
[ac4f06e] | 135 | } |
---|
| 136 | else { |
---|
| 137 | if(typeof(#[1]) == "int"){ |
---|
| 138 | nP = #[1]; |
---|
| 139 | } |
---|
| 140 | else { |
---|
| 141 | print("// ** the input must be \"(ideal, int)\" or "); |
---|
| 142 | print("// ** \"(ideal, intvec)\""); |
---|
| 143 | print("// ** a lex. GB will be computed from \"dp\" to \"lp\""); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | if(size(#) == 2) |
---|
| 150 | { |
---|
| 151 | if(typeof(#[1]) == "intvec" and typeof(#[2]) == "int"){ |
---|
[3c4dcc] | 152 | curr_weight = #[1]; |
---|
[ac4f06e] | 153 | |
---|
| 154 | if(Wpal == "al"){ |
---|
| 155 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 156 | } |
---|
| 157 | else { |
---|
| 158 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | else{ |
---|
| 162 | if(typeof(#[1]) == "intvec" and typeof(#[2]) == "intvec"){ |
---|
[3c4dcc] | 163 | curr_weight = #[1]; |
---|
| 164 | target_weight = #[2]; |
---|
| 165 | |
---|
[ac4f06e] | 166 | if(Wpal == "al"){ |
---|
| 167 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 168 | } |
---|
| 169 | else { |
---|
| 170 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | else{ |
---|
| 174 | print("// ** the input must be \"(ideal,intvec,int)\" or "); |
---|
| 175 | print("// ** \"(ideal,intvec,intvec)\""); |
---|
| 176 | print("// ** and a lex. GB will be computed from \"dp\" to \"lp\""); |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | else { |
---|
| 181 | if(size(#) == 3) { |
---|
[3c4dcc] | 182 | if(typeof(#[1]) == "intvec" and typeof(#[2]) == "intvec" and |
---|
[ac4f06e] | 183 | typeof(#[3]) == "int") |
---|
| 184 | { |
---|
[3c4dcc] | 185 | curr_weight = #[1]; |
---|
| 186 | target_weight = #[2]; |
---|
| 187 | nP = #[3]; |
---|
[ac4f06e] | 188 | if(Wpal == "al"){ |
---|
| 189 | order_str = "(a("+string(#[1])+"),lp("+string(n) + "),C)"; |
---|
| 190 | } |
---|
| 191 | else { |
---|
| 192 | order_str = "(Wp("+string(#[1])+"),C)"; |
---|
| 193 | } |
---|
| 194 | } |
---|
| 195 | else{ |
---|
| 196 | print("// ** the input must be \"(ideal,intvec,intvec,int)\""); |
---|
| 197 | print("// ** and a lex. GB will be computed from \"dp\" to \"lp\""); |
---|
[3c4dcc] | 198 | |
---|
| 199 | } |
---|
[ac4f06e] | 200 | } |
---|
| 201 | else{ |
---|
| 202 | print("// ** The given input is wrong"); |
---|
| 203 | print("// ** and a lex. GB will be computed from \"dp\" to \"lp\""); |
---|
| 204 | } |
---|
| 205 | } |
---|
| 206 | } |
---|
[3c4dcc] | 207 | } |
---|
| 208 | |
---|
[ac4f06e] | 209 | list result; |
---|
| 210 | result[1] = nP; |
---|
| 211 | result[2] = order_str; |
---|
| 212 | result[3] = curr_weight; |
---|
| 213 | result[4] = target_weight; |
---|
| 214 | |
---|
| 215 | return(result); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | proc gwalk(ideal Go, list #) |
---|
| 220 | "SYNTAX: gwalk(ideal i); |
---|
| 221 | gwalk(ideal i, intvec v, intvec w); |
---|
| 222 | TYPE: ideal |
---|
[3c4dcc] | 223 | PURPOSE: compute the standard basis of the ideal, calculated via |
---|
| 224 | the improved Groebner walk algorithm from the ordering |
---|
| 225 | \"(a(v),lp)\", \"dp\" or \"Dp\" |
---|
| 226 | to the ordering \"(a(w),lp)\" or \"(a(1,0,...,0),lp)\". |
---|
[ac4f06e] | 227 | SEE ALSO: std, stdfglm, groebner, pwalk, fwalk, twalk, awalk1, awalk2 |
---|
| 228 | KEYWORDS: Groebner walk |
---|
[3c4dcc] | 229 | EXAMPLE: example gwalk; shows an example" |
---|
[ac4f06e] | 230 | { |
---|
| 231 | |
---|
| 232 | /* we use ring with ordering (a(...),lp,C) */ |
---|
| 233 | list OSCTW = OrderStringalp_NP("al", #);//"dp" |
---|
[3c4dcc] | 234 | //list OSCTW = OrderStringalp("al", "Dp");//Dp |
---|
[ac4f06e] | 235 | |
---|
| 236 | string ord_str = OSCTW[2]; |
---|
| 237 | intvec curr_weight = OSCTW[3]; /* original weight vector */ |
---|
| 238 | intvec target_weight = OSCTW[4]; /* terget weight vector */ |
---|
[3b77465] | 239 | kill OSCTW; |
---|
[3c4dcc] | 240 | option(redSB); |
---|
[ac4f06e] | 241 | def xR = basering; |
---|
| 242 | |
---|
| 243 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
| 244 | def old_ring = basering; |
---|
| 245 | |
---|
| 246 | //print("//** help ring = " + string(basering)); |
---|
| 247 | ideal G = fetch(xR, Go); |
---|
| 248 | G = system("Mwalk", G, curr_weight, target_weight); |
---|
[3c4dcc] | 249 | |
---|
| 250 | setring xR; |
---|
[3b77465] | 251 | //kill Go; |
---|
[ac4f06e] | 252 | |
---|
[3c4dcc] | 253 | keepring basering; |
---|
| 254 | ideal result = fetch(old_ring, G); |
---|
[16ad44] | 255 | attrib(result,"isSB",1); |
---|
[3c4dcc] | 256 | return (result); |
---|
| 257 | } |
---|
[ac4f06e] | 258 | example |
---|
| 259 | { |
---|
| 260 | "EXAMPLE:"; echo = 2; |
---|
| 261 | //** compute a Gröbner basis of I w.r.t. lp. |
---|
| 262 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 263 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 264 | gwalk(I); |
---|
[ac4f06e] | 265 | } |
---|
| 266 | |
---|
| 267 | |
---|
| 268 | /* 16 Mai 2003 */ |
---|
| 269 | proc awalk1(ideal G, list #) |
---|
| 270 | "SYNTAX: awalk1(ideal i); |
---|
[3c4dcc] | 271 | awalk1(ideal i, int n); |
---|
[ac4f06e] | 272 | awalk1(ideal i, int n, intvec v, intvec w); |
---|
| 273 | awalk1(ideal i, intvec v, intvec w); |
---|
| 274 | TYPE: ideal |
---|
[3c4dcc] | 275 | PURPOSE: compute the standard basis of the ideal, calculated via |
---|
| 276 | the first alternative algorithm from an ordering |
---|
| 277 | \"(a(v),lp)\", \"dp\" or \"Dp\" to the ordering |
---|
| 278 | \"(a(w),lp)\" or \"(a(1,0,...,0),lp)\" |
---|
| 279 | with a perturbation degree n for the weight vector w. |
---|
[ac4f06e] | 280 | SEE ALSO: std, stdfglm, groebner, gwalk, pwalk, fwalk, twalk, awalk2 |
---|
| 281 | KEYWORDS: the first alternative algorithm |
---|
[3c4dcc] | 282 | EXAMPLE: example awalk1; shows an example" |
---|
[ac4f06e] | 283 | { |
---|
| 284 | if (size(#) == 0) |
---|
| 285 | { |
---|
| 286 | return (awalk1_tmp(G, nvars(basering)-1)); |
---|
| 287 | } |
---|
| 288 | else { |
---|
| 289 | if(typeof(#[1]) == "int") |
---|
| 290 | { |
---|
| 291 | return (awalk1_tmp(G, #[1])); |
---|
| 292 | } |
---|
| 293 | else { |
---|
| 294 | return (awalk1_tmp(G, nvars(basering)-1, #)); |
---|
[3c4dcc] | 295 | } |
---|
| 296 | } |
---|
[ac4f06e] | 297 | } |
---|
| 298 | example |
---|
| 299 | { |
---|
| 300 | "EXAMPLE:"; echo = 2; |
---|
| 301 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 302 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 303 | awalk1(I,3); |
---|
[ac4f06e] | 304 | } |
---|
| 305 | |
---|
| 306 | |
---|
| 307 | proc awalk1_tmp(ideal Go, int n2, list #) |
---|
| 308 | //proc awalk1(ideal Go, int n1, int n2, list #) |
---|
| 309 | { |
---|
| 310 | int nV = nvars(basering); |
---|
| 311 | int n1 = 1; |
---|
| 312 | |
---|
| 313 | //assume(n1 >= 1 && n1 <= nV && n2 >= 1 && n2 <= nV); |
---|
| 314 | if(n1 < 1 || n1 > nV || n2 < 1 || n2 > nV) |
---|
| 315 | { |
---|
| 316 | print("//Erorr: The perturbed degree is wrong!!"); |
---|
| 317 | print("// It must be between 1 and " + string(nV)); |
---|
| 318 | return(); |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | /* we use ring with ordering (a(...),lp,C) */ |
---|
[3c4dcc] | 322 | list OSCTW = OrderStringalp_NP("al", #); |
---|
| 323 | //list OSCTW = OrderStringalp("al", "Dp"); |
---|
[ac4f06e] | 324 | |
---|
| 325 | string ord_str = OSCTW[2]; |
---|
| 326 | intvec curr_weight = OSCTW[3]; /* original weight vector */ |
---|
| 327 | intvec target_weight = OSCTW[4]; /* terget weight vector */ |
---|
[3b77465] | 328 | kill OSCTW; |
---|
[ac4f06e] | 329 | option(redSB); |
---|
| 330 | |
---|
| 331 | def xR = basering; |
---|
| 332 | |
---|
[3c4dcc] | 333 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
| 334 | def old_ring = basering; |
---|
| 335 | //print("//** help ring = " + string(basering)); |
---|
[ac4f06e] | 336 | |
---|
| 337 | ideal G = fetch(xR, Go); |
---|
| 338 | G = system("MAltwalk1", G, n1, n2, curr_weight, target_weight); |
---|
[3c4dcc] | 339 | |
---|
| 340 | setring xR; |
---|
[3b77465] | 341 | //kill Go; |
---|
[ac4f06e] | 342 | |
---|
[3c4dcc] | 343 | keepring basering; |
---|
| 344 | ideal result = fetch(old_ring, G); |
---|
[16ad44] | 345 | attrib(result,"isSB",1); |
---|
[3c4dcc] | 346 | return (result); |
---|
| 347 | } |
---|
[ac4f06e] | 348 | |
---|
| 349 | proc fwalk(ideal Go, list #) |
---|
[3c4dcc] | 350 | "SYNTAX: fwalk(ideal i); |
---|
[ac4f06e] | 351 | fwalk(ideal i, intvec v, intvec w); |
---|
| 352 | TYPE: ideal |
---|
| 353 | PURPOSE: compute the standard basis of the ideal w.r.t. the |
---|
[3c4dcc] | 354 | lexicographical ordering or a weighted-lex ordering, |
---|
| 355 | calculated via the fractal walk algorithm. |
---|
[ac4f06e] | 356 | SEE ALSO: std, stdfglm, groebner, gwalk, pwalk, twalk, awalk1, awalk2 |
---|
| 357 | KEYWORDS: The fractal walk algorithm |
---|
[3c4dcc] | 358 | EXAMPLE: example fwalk; shows an example" |
---|
[ac4f06e] | 359 | { |
---|
| 360 | /* we use ring with ordering (a(...),lp,C) */ |
---|
[3c4dcc] | 361 | list OSCTW = OrderStringalp_NP("al", #); |
---|
[ac4f06e] | 362 | |
---|
| 363 | string ord_str = OSCTW[2]; |
---|
| 364 | intvec curr_weight = OSCTW[3]; /* original weight vector */ |
---|
| 365 | intvec target_weight = OSCTW[4]; /* terget weight vector */ |
---|
[3b77465] | 366 | kill OSCTW; |
---|
[ac4f06e] | 367 | option(redSB); |
---|
| 368 | def xR = basering; |
---|
| 369 | |
---|
[3c4dcc] | 370 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
[ac4f06e] | 371 | def old_ring = basering; |
---|
| 372 | //print("//** help ring = " + string(basering)); |
---|
| 373 | |
---|
| 374 | ideal G = fetch(xR, Go); |
---|
| 375 | G = system("Mfwalk", G, curr_weight, target_weight); |
---|
[3c4dcc] | 376 | |
---|
| 377 | setring xR; |
---|
[3b77465] | 378 | //kill Go; |
---|
[ac4f06e] | 379 | |
---|
[3c4dcc] | 380 | keepring basering; |
---|
| 381 | ideal result = fetch(old_ring, G); |
---|
[16ad44] | 382 | attrib(result,"isSB",1); |
---|
[3c4dcc] | 383 | return (result); |
---|
| 384 | } |
---|
[ac4f06e] | 385 | example |
---|
| 386 | { |
---|
| 387 | "EXAMPLE:"; echo = 2; |
---|
| 388 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 389 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 390 | fwalk(I); |
---|
[ac4f06e] | 391 | } |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | proc awalk2(ideal Go, list #) |
---|
| 395 | "SYNTAX: awalk2(ideal i); |
---|
| 396 | awalk2(ideal i, intvec v, intvec w); |
---|
| 397 | TYPE: ideal |
---|
[3c4dcc] | 398 | PURPOSE: compute the standard basis of the ideal, calculated via |
---|
| 399 | the second alternative algorithm from the ordering |
---|
| 400 | \"(a(v),lp)\", \"dp\" or \"Dp\" |
---|
| 401 | to the ordering \"(a(w),lp)\" or \"(a(1,0,...,0),lp)\". |
---|
[ac4f06e] | 402 | SEE ALSO: std, stdfglm, groebner, gwalk, pwalk, fwalk, twalk, awalk1 |
---|
| 403 | KEYWORDS: Groebner walk |
---|
| 404 | EXAMPLE: example awalk2; shows an example" |
---|
| 405 | { |
---|
| 406 | /* we use ring with ordering (a(...),lp,C) */ |
---|
| 407 | list OSCTW = OrderStringalp_NP("al", #);//"dp" |
---|
[3c4dcc] | 408 | //list OSCTW = OrderStringalp("al", "Dp");//Dp |
---|
[ac4f06e] | 409 | |
---|
| 410 | string ord_str = OSCTW[2]; |
---|
| 411 | intvec curr_weight = OSCTW[3]; /* original weight vector */ |
---|
| 412 | intvec target_weight = OSCTW[4]; /* terget weight vector */ |
---|
[3b77465] | 413 | kill OSCTW; |
---|
[ac4f06e] | 414 | option(redSB); def xR = basering; |
---|
| 415 | |
---|
| 416 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
| 417 | def old_ring = basering; |
---|
| 418 | |
---|
| 419 | //print("//** help ring = " + string(basering)); |
---|
| 420 | ideal G = fetch(xR, Go); |
---|
| 421 | G = system("MAltwalk2", G, curr_weight, target_weight); |
---|
[3c4dcc] | 422 | |
---|
| 423 | setring xR; |
---|
[3b77465] | 424 | //kill Go; |
---|
[ac4f06e] | 425 | |
---|
[3c4dcc] | 426 | keepring basering; |
---|
| 427 | ideal result = fetch(old_ring, G); |
---|
[16ad44] | 428 | attrib(result,"isSB",1); |
---|
[3c4dcc] | 429 | return (result); |
---|
| 430 | } |
---|
[ac4f06e] | 431 | example |
---|
| 432 | { |
---|
| 433 | "EXAMPLE:"; echo = 2; |
---|
| 434 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 435 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 436 | awalk2(I); |
---|
[ac4f06e] | 437 | } |
---|
| 438 | |
---|
| 439 | proc pwalk(ideal Go, int n1, int n2, list #) |
---|
| 440 | "SYNTAX: pwalk(int d, ideal i, int n1, int n2); |
---|
| 441 | pwalk(int d, ideal i, int n1, int n2, intvec v, intvec w); |
---|
| 442 | TYPE: ideal |
---|
[3c4dcc] | 443 | PURPOSE: compute the standard basis of the ideal, calculated via |
---|
| 444 | the perturbation walk algorithm from the ordering |
---|
| 445 | \"(a(v),lp)\", \"dp\" or \"Dp\" |
---|
| 446 | to the ordering \"(a(w),lp)\" or \"(a(1,0,...,0),lp)\" |
---|
| 447 | with a perturbation degree n, m for v and w, resp. |
---|
[ac4f06e] | 448 | SEE ALSO: std, stdfglm, groebner, gwalk, fwalk, twalk, awalk1, awalk2 |
---|
| 449 | KEYWORDS: Perturbation walk |
---|
| 450 | EXAMPLE: example pwalk; shows an example" |
---|
| 451 | { |
---|
| 452 | int nV = nvars(basering); |
---|
| 453 | //assume(n1 >= 1 && n1 <= nV && n2 >= 1 && n2 <= nV); |
---|
| 454 | if(n1 < 1 || n1 > nV || n2 < 1 || n2 > nV) |
---|
| 455 | { |
---|
| 456 | print("//Erorr: The perturbed degree is wrong!!"); |
---|
| 457 | print("// It must be between 1 and " + string(nV)); |
---|
| 458 | return(); |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | /* we use ring with ordering (a(...),lp,C) */ |
---|
[3c4dcc] | 462 | list OSCTW = OrderStringalp_NP("al", #); |
---|
| 463 | //list OSCTW = OrderStringalp("al", "Dp");//Dp |
---|
[ac4f06e] | 464 | int nP = OSCTW[1]; |
---|
[3c4dcc] | 465 | |
---|
[ac4f06e] | 466 | string ord_str = OSCTW[2]; |
---|
| 467 | intvec curr_weight = OSCTW[3]; /* original weight vector */ |
---|
| 468 | intvec target_weight = OSCTW[4]; /* terget weight vector */ |
---|
[3b77465] | 469 | kill OSCTW; |
---|
[ac4f06e] | 470 | option(redSB); |
---|
| 471 | |
---|
| 472 | def xR = basering; |
---|
| 473 | |
---|
| 474 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
| 475 | def old_ring = basering; |
---|
| 476 | |
---|
| 477 | ideal G = fetch(xR, Go); |
---|
| 478 | G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP); |
---|
[3c4dcc] | 479 | |
---|
| 480 | setring xR; |
---|
[3b77465] | 481 | //kill Go; |
---|
[ac4f06e] | 482 | |
---|
[3c4dcc] | 483 | keepring basering; |
---|
| 484 | ideal result = fetch(old_ring, G); |
---|
[16ad44] | 485 | attrib(result,"isSB",1); |
---|
[3c4dcc] | 486 | return (result); |
---|
| 487 | } |
---|
[ac4f06e] | 488 | example |
---|
| 489 | { |
---|
| 490 | "EXAMPLE:"; echo = 2; |
---|
| 491 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 492 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 493 | pwalk(I,2,3); |
---|
[ac4f06e] | 494 | } |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | proc twalk(ideal Go, list #) |
---|
| 498 | "SYNTAX: twalk(ideal i); |
---|
| 499 | twalk(ideal i, intvec v, intvec w); |
---|
| 500 | TYPE: ideal |
---|
[3c4dcc] | 501 | PURPOSE: compute the standard basis of the ideal w.r.t. |
---|
| 502 | the ordering \"(a(w),lp)\" or \"(a(1,0,...,0),lp)\", |
---|
| 503 | calculated via the Tran algorithm. |
---|
[ac4f06e] | 504 | SEE ALSO: std, stdfglm, groebner, gwalk, pwalk, fwalk, awalk1, awalk2 |
---|
| 505 | KEYWORDS: The Tran algorithm |
---|
| 506 | EXAMPLE: example twalk; shows an example" |
---|
| 507 | { |
---|
| 508 | list L = OrderStringalp_NP("al", #); |
---|
| 509 | int nP = L[1]; |
---|
[3c4dcc] | 510 | |
---|
[ac4f06e] | 511 | /* we use ring with ordering (a(...),lp,C) */ |
---|
| 512 | string ord_str = L[2]; |
---|
| 513 | intvec curr_weight = L[3]; |
---|
| 514 | intvec target_weight = L[4]; |
---|
[3b77465] | 515 | kill L; |
---|
[3c4dcc] | 516 | |
---|
[ac4f06e] | 517 | option(redSB); |
---|
| 518 | def xR = basering; |
---|
[3c4dcc] | 519 | |
---|
[ac4f06e] | 520 | execute("ring ostR = ("+charstr(xR)+"),("+varstr(xR)+"),"+ord_str+";"); |
---|
| 521 | def old_ring = basering; |
---|
[3c4dcc] | 522 | |
---|
[ac4f06e] | 523 | //print("//** help ring = " + string(basering)); |
---|
| 524 | ideal G = fetch(xR, Go); |
---|
| 525 | G = system("TranMImprovwalk", G, curr_weight, target_weight, nP); |
---|
[3c4dcc] | 526 | |
---|
| 527 | setring xR; |
---|
[3b77465] | 528 | //kill Go; |
---|
[ac4f06e] | 529 | |
---|
[16ad44] | 530 | keepring basering; |
---|
| 531 | ideal result = fetch(old_ring, G); |
---|
| 532 | attrib(result,"isSB",1); |
---|
| 533 | return (result); |
---|
[3c4dcc] | 534 | } |
---|
[ac4f06e] | 535 | example |
---|
| 536 | { |
---|
| 537 | "EXAMPLE:"; echo = 2; |
---|
| 538 | ring r = 32003,(z,y,x), lp; |
---|
[3c4dcc] | 539 | ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
| 540 | twalk(I); |
---|
[ac4f06e] | 541 | } |
---|