Changeset c99fd4 in git for Singular/LIB/mregular.lib
- Timestamp:
- Oct 6, 2008, 7:04:28 PM (16 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 886b0dae50b58b9f8b0863c63abf2f0ddacf9a26
- Parents:
- 100025a806c37776e35dd4b839e192304f203af8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/mregular.lib
r100025 rc99fd4 1 1 // IB/PG/GMG, last modified: 15.10.2004 2 2 ////////////////////////////////////////////////////////////////////////////// 3 version = "$Id: mregular.lib,v 1. 8 2005-05-06 14:38:47 hannesExp $";3 version = "$Id: mregular.lib,v 1.9 2008-10-06 17:04:27 Singular Exp $"; 4 4 category="Commutative Algebra"; 5 5 info=" … … 91 91 //----- If the ideal i is not proper: 92 92 if ( d == -1 ) 93 94 95 93 { 94 dbprint(printlevel-voice+2, 95 "// The ideal i is (1)! 96 96 // Its Castelnuovo-Mumford regularity is:"); 97 98 97 return (0); 98 } 99 99 //----- If the ideal i is 0: 100 100 if ( size(I) == 0 ) 101 102 103 101 { 102 dbprint(printlevel-voice+2, 103 "// The ideal i is (0)! 104 104 // Its Castelnuovo-Mumford regularity is:"); 105 106 105 return (0); 106 } 107 107 //----- When the ideal i is 0-dimensional: 108 108 if ( d == 0 ) 109 110 111 112 113 114 115 116 117 109 { 110 H=maxdeg1(minbase(quotient(I,maxideal(1))))+1; 111 time=rtimer-time; 112 // Additional information: 113 dbprint(printlevel-voice+2, 114 "// Dimension of S/i : 0"); 115 dbprint(printlevel-voice+2, 116 "// Time for computing regularity: " + string(time) + " sec."); 117 dbprint(printlevel-voice+2, 118 118 "// The Castelnuovo-Mumford regularity of i coincides with its satiety, and 119 119 // with the regularity of the Hilbert function of S/i. Its value is:"); 120 121 120 return (H); 121 } 122 122 //----- Determine the situation: NT, or NP, or nothing. 123 123 //----- Choose the method depending on the situation, on the … … 125 125 //----- in order to get the mon. ideal of nested type associated to i 126 126 if ( e == 1 ) 127 { 128 ch=0; 129 } 127 { ch=0; } 130 128 NPtest=is_NP(I); 131 129 if ( NPtest == 1 ) 132 133 134 130 { 131 nesttest=is_nested(I); 132 } 135 133 if ( ch != 0 ) 136 { 134 { 135 if ( NPtest == 0 ) 136 { 137 N=d*n-d*(d-1)/2; 138 s = "ring rtr = (ch,t(1..N)),x(0..n),dp;"; 139 execute(s); 140 ideal chcoord,m,i,I; 141 poly P; 142 map phi; 143 i=imap(r1,i); 144 chcoord=select1(maxideal(1),1..(n-d+1)); 145 acc=0; 146 for ( ii = 1; ii<=d; ii++ ) 147 { 148 matrix trex[1][n-d+ii+1]=t((1+acc)..(n-d+ii+acc)),1; 149 m=select1(maxideal(1),1..(n-d+1+ii)); 150 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 151 { 152 P=P+trex[1,jj]*m[jj]; 153 } 154 chcoord[n-d+1+ii]=P; 155 P=0; 156 acc=acc+n-d+ii; 157 kill trex; 158 } 159 phi=rtr,chcoord; 160 I=simplify(lead(std(phi(i))),1); 161 setring r1; 162 I=imap(rtr,I); 163 attrib(I,"isSB",1); 164 } 165 else 166 { 167 if ( nesttest == 0 ) 168 { 169 N=d*(d-1)/2; 170 s = "ring rtr = (ch,t(1..N)),x(0..n),dp;"; 171 execute(s); 172 ideal chcoord,m,i,I; 173 poly P; 174 map phi; 175 i=imap(r1,i); 176 chcoord=select1(maxideal(1),1..(n-d+2)); 177 acc=0; 178 for ( ii = 1; ii<=d-1; ii++ ) 179 { 180 matrix trex[1][ii+1]=t((1+acc)..(ii+acc)),1; 181 m=select1(maxideal(1),(n-d+2)..(n-d+2+ii)); 182 for ( jj = 1; jj<=ii+1; jj++ ) 183 { 184 P=P+trex[1,jj]*m[jj]; 185 } 186 chcoord[n-d+2+ii]=P; 187 P=0; 188 acc=acc+ii; 189 kill trex; 190 } 191 phi=rtr,chcoord; 192 I=simplify(lead(std(phi(i))),1); 193 setring r1; 194 I=imap(rtr,I); 195 attrib(I,"isSB",1); 196 } 197 } 198 } 199 else 200 { 201 if ( NPtest == 0 ) 202 { 203 while ( nl < 30 ) 204 { 205 chcoord=select1(maxideal(1),1..(n-d+1)); 206 nl=nl+1; 207 for ( ii = 1; ii<=d; ii++ ) 208 { 209 ran=random(100,1,n-d+ii); 210 ran=intmat(ran,1,n-d+ii+1); 211 ran[1,n-d+ii+1]=1; 212 m=select1(maxideal(1),1..(n-d+1+ii)); 213 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 214 { 215 P=P+ran[1,jj]*m[jj]; 216 } 217 chcoord[n-d+1+ii]=P; 218 P=0; 219 } 220 phi=r1,chcoord; 221 dbprint(printlevel-voice+2,"// (1 random change of coord.)"); 222 I=simplify(lead(std(phi(i))),1); 223 attrib(I,"isSB",1); 224 NPtest=is_NP(I); 225 if ( NPtest == 1 ) 226 { 227 break; 228 } 229 } 137 230 if ( NPtest == 0 ) 138 { 139 N=d*n-d*(d-1)/2; 140 s = "ring rtr = (ch,t(1..N)),x(0..n),dp;"; 141 execute(s); 142 ideal chcoord,m,i,I; 143 poly P; 144 map phi; 145 i=imap(r1,i); 146 chcoord=select1(maxideal(1),1,(n-d+1)); 147 acc=0; 148 for ( ii = 1; ii<=d; ii++ ) 149 { 150 matrix trex[1][n-d+ii+1]=t((1+acc)..(n-d+ii+acc)),1; 151 m=select1(maxideal(1),1,(n-d+1+ii)); 152 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 153 { 154 P=P+trex[1,jj]*m[jj]; 155 } 156 chcoord[n-d+1+ii]=P; 157 P=0; 158 acc=acc+n-d+ii; 159 kill trex; 160 } 161 phi=rtr,chcoord; 162 I=simplify(lead(std(phi(i))),1); 163 setring r1; 164 I=imap(rtr,I); 165 attrib(I,"isSB",1); 166 } 167 else 168 { 169 if ( nesttest == 0 ) 170 { 171 N=d*(d-1)/2; 172 s = "ring rtr = (ch,t(1..N)),x(0..n),dp;"; 173 execute(s); 174 ideal chcoord,m,i,I; 175 poly P; 176 map phi; 177 i=imap(r1,i); 178 chcoord=select1(maxideal(1),1,(n-d+2)); 179 acc=0; 180 for ( ii = 1; ii<=d-1; ii++ ) 181 { 182 matrix trex[1][ii+1]=t((1+acc)..(ii+acc)),1; 183 m=select1(maxideal(1),(n-d+2),(n-d+2+ii)); 184 for ( jj = 1; jj<=ii+1; jj++ ) 185 { 186 P=P+trex[1,jj]*m[jj]; 187 } 188 chcoord[n-d+2+ii]=P; 189 P=0; 190 acc=acc+ii; 191 kill trex; 192 } 193 phi=rtr,chcoord; 194 I=simplify(lead(std(phi(i))),1); 195 setring r1; 196 I=imap(rtr,I); 197 attrib(I,"isSB",1); 198 } 199 } 200 } 201 else 202 { 203 if ( NPtest == 0 ) 204 { 205 while ( nl < 30 ) 206 { 207 chcoord=select1(maxideal(1),1,(n-d+1)); 208 nl=nl+1; 209 for ( ii = 1; ii<=d; ii++ ) 210 { 211 ran=random(100,1,n-d+ii); 212 ran=intmat(ran,1,n-d+ii+1); 213 ran[1,n-d+ii+1]=1; 214 m=select1(maxideal(1),1,(n-d+1+ii)); 215 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 216 { 217 P=P+ran[1,jj]*m[jj]; 218 } 219 chcoord[n-d+1+ii]=P; 220 P=0; 221 } 222 phi=r1,chcoord; 223 dbprint(printlevel-voice+2,"// (1 random change of coord.)"); 224 I=simplify(lead(std(phi(i))),1); 225 attrib(I,"isSB",1); 226 NPtest=is_NP(I); 227 if ( NPtest == 1 ) 228 { 229 break; 230 } 231 } 232 if ( NPtest == 0 ) 233 { 231 { 234 232 "// WARNING from proc regIdeal from lib mregular.lib: 235 233 // The procedure has entered in 30 loops and could not put the variables … … 237 235 // of coordinates may enter an infinite loop when the field is finite. 238 236 // Try removing this optional argument."; 239 return (-1); 240 } 241 i=phi(i); 242 nesttest=is_nested(I); 243 } 237 return (-1); 238 } 239 i=phi(i); 240 nesttest=is_nested(I); 241 } 242 if ( nesttest == 0 ) 243 { 244 while ( nl < 30 ) 245 { 246 chcoord=select1(maxideal(1),1..(n-d+2)); 247 nl=nl+1; 248 for ( ii = 1; ii<=d-1; ii++ ) 249 { 250 ran=random(100,1,ii); 251 ran=intmat(ran,1,ii+1); 252 ran[1,ii+1]=1; 253 m=select1(maxideal(1),(n-d+2)..(n-d+2+ii)); 254 for ( jj = 1; jj<=ii+1; jj++ ) 255 { 256 P=P+ran[1,jj]*m[jj]; 257 } 258 chcoord[n-d+2+ii]=P; 259 P=0; 260 } 261 phi=r1,chcoord; 262 dbprint(printlevel-voice+2,"// (1 random change of coord.)"); 263 I=simplify(lead(std(phi(i))),1); 264 attrib(I,"isSB",1); 265 nesttest=is_nested(I); 266 if ( nesttest == 1 ) 267 { 268 break; 269 } 270 } 244 271 if ( nesttest == 0 ) 245 { 246 while ( nl < 30 ) 247 { 248 chcoord=select1(maxideal(1),1,(n-d+2)); 249 nl=nl+1; 250 for ( ii = 1; ii<=d-1; ii++ ) 251 { 252 ran=random(100,1,ii); 253 ran=intmat(ran,1,ii+1); 254 ran[1,ii+1]=1; 255 m=select1(maxideal(1),(n-d+2),(n-d+2+ii)); 256 for ( jj = 1; jj<=ii+1; jj++ ) 257 { 258 P=P+ran[1,jj]*m[jj]; 259 } 260 chcoord[n-d+2+ii]=P; 261 P=0; 262 } 263 phi=r1,chcoord; 264 dbprint(printlevel-voice+2,"// (1 random change of coord.)"); 265 I=simplify(lead(std(phi(i))),1); 266 attrib(I,"isSB",1); 267 nesttest=is_nested(I); 268 if ( nesttest == 1 ) 269 { 270 break; 271 } 272 } 273 if ( nesttest == 0 ) 274 { 272 { 275 273 "// WARNING from proc regIdeal from lib mregular.lib: 276 274 // The procedure has entered in 30 loops and could not find a monomial … … 279 277 // infinite loop when the field is finite. 280 278 // Try removing this optional argument."; 281 return (-1);282 283 284 279 return (-1); 280 } 281 } 282 } 285 283 // 286 284 // At this stage, we have obtained a monomial ideal I of nested type … … 289 287 //----- When S/i is Cohen-Macaulay: 290 288 for ( ii = n-d+2; ii <= n+1; ii++ ) 291 292 293 289 { 290 K=K+select(I,ii); 291 } 294 292 if ( size(K) == 0 ) 295 296 297 298 299 300 301 302 303 293 { 294 s="ring nr = ",charstr(r0),",x(0..n-d),dp;"; 295 execute(s); 296 ideal I; 297 I = imap(r1,I); 298 H=maxdeg1(minbase(quotient(I,maxideal(1))))+1; 299 time=rtimer-time; 300 // Additional information: 301 dbprint(printlevel-voice+2, 304 302 "// S/i is Cohen-Macaulay"); 305 303 dbprint(printlevel-voice+2, 306 304 "// Dimension of S/i ( = depth(S/i) ): "+string(d)); 307 305 dbprint(printlevel-voice+2, 308 306 "// Regularity attained at the last step of m.g.f.r. of i: YES"); 309 307 dbprint(printlevel-voice+2, 310 308 "// Regularity of the Hilbert function of S/i: " + string(H-d)); 311 309 dbprint(printlevel-voice+2, 312 310 "// Time for computing regularity: " + string(time) + " sec."); 313 311 dbprint(printlevel-voice+2, 314 312 "// The Castelnuovo-Mumford regularity of i is:"); 315 316 313 return(H); 314 } 317 315 //----- When d=1: 318 316 if ( d == 1 ) 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 317 { 318 H=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1; 319 sat=H; 320 J=subst(I,x(n),1); 321 s = "ring nr = ",charstr(r0),",x(0..n-1),dp;"; 322 execute(s); 323 ideal J=imap(r1,J); 324 attrib(J,"isSB",1); 325 h=maxdeg1(minbase(quotient(J,maxideal(1))))+1; 326 time=rtimer-time; 327 if ( h > H ) 328 { 329 H=h; 330 } 331 // Additional information: 332 dbprint(printlevel-voice+2, 335 333 "// Dimension of S/i: 1"); 336 334 dbprint(printlevel-voice+2, 337 335 "// Depth of S/i: 0"); 338 336 dbprint(printlevel-voice+2, 339 337 "// Satiety of i: "+string(sat)); 340 338 dbprint(printlevel-voice+2, 341 339 "// Upper bound for the a-invariant of S/i: end(H^1(S/i)) <= "+ 342 340 string(h-2)); 343 344 345 341 if ( H == sat ) 342 { 343 dbprint(printlevel-voice+2, 346 344 "// Regularity attained at the last step of m.g.f.r. of i: YES"); 347 345 dbprint(printlevel-voice+2, 348 346 "// Regularity of the Hilbert function of S/i: "+string(H)); 349 350 351 352 347 } 348 else 349 { 350 dbprint(printlevel-voice+2, 353 351 "// Regularity attained at the last step of m.g.f.r. of i: NO"); 354 355 352 } 353 dbprint(printlevel-voice+2, 356 354 "// Time for computing regularity: "+ string(time) + " sec."); 357 355 dbprint(printlevel-voice+2, 358 356 "// The Castelnuovo-Mumford regularity of i is:"); 359 360 357 return(H); 358 } 361 359 //----- Now d>1 and S/i is not Cohen-Macaulay: 362 360 // 363 361 //----- First, determine the last variable really occuring 364 365 366 367 368 369 370 371 372 373 374 375 376 377 362 lastv=n-d; 363 h=n; 364 while ( lastv == n-d and h > n-d ) 365 { 366 K=select(I,h+1); 367 if ( size(K) == 0 ) 368 { 369 h=h-1; 370 } 371 else 372 { 373 lastv=h; 374 } 375 } 378 376 //----- and compute Castelnuovo-Mumford regularity: 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 377 s = "ring nr = ",charstr(r0),",x(0..lastv),dp;"; 378 execute(s); 379 ideal I,K,KK,LL; 380 I=imap(r1,I); 381 attrib(I,"isSB",1); 382 K=simplify(reduce(quotient(I,maxideal(1)),I),2); 383 H=maxdeg1(K)+1; 384 firstind=H; 385 KK=minbase(subst(I,x(lastv),1)); 386 for ( ii = n-lastv; ii<=d-2; ii++ ) 387 { 388 LL=minbase(subst(I,x(n-ii-1),1)); 389 attrib(LL,"isSB",1); 390 s = "ring mr = ",charstr(r0),",x(0..n-ii-1),dp;"; 391 execute(s); 392 ideal K,KK; 393 KK=imap(nr,KK); 394 attrib(KK,"isSB",1); 395 K=simplify(reduce(quotient(KK,maxideal(1)),KK),2); 396 h=maxdeg1(K)+1; 397 if ( h > H ) 398 { 399 H=h; 400 } 401 setring nr; 402 kill mr; 403 KK=LL; 404 } 405 // We must determine one more sat. index: 406 s = "ring mr = ",charstr(r0),",x(0..n-d),dp;"; 407 execute(s); 408 ideal KK,K; 409 KK=imap(nr,KK); 410 attrib(KK,"isSB",1); 411 K=simplify(reduce(quotient(KK,maxideal(1)),KK),2); 412 h=maxdeg1(K)+1; 413 lastind=h; 414 if ( h > H ) 415 { 416 H=h; 417 } 418 setring nr; 419 kill mr; 420 time=rtimer-time; 421 // Additional information: 422 dbprint(printlevel-voice+2, 425 423 "// Dimension of S/i: "+string(d)); 426 424 dbprint(printlevel-voice+2, 427 425 "// Depth of S/i: "+string(n-lastv)); 428 426 dbprint(printlevel-voice+2, 429 427 "// end(H^"+string(n-lastv)+"(S/i)) = " 430 428 +string(firstind-n+lastv-1)); 431 429 dbprint(printlevel-voice+2, 432 430 "// Upper bound for the a-invariant of S/i: end(H^" 433 431 +string(d)+"(S/i)) <= "+string(lastind-d-1)); 434 435 436 432 if ( H == firstind ) 433 { 434 dbprint(printlevel-voice+2, 437 435 "// Regularity attained at the last step of m.g.f.r. of i: YES"); 438 436 dbprint(printlevel-voice+2, 439 437 "// Regularity of the Hilbert function of S/i: " 440 438 +string(H-n+lastv)); 441 442 443 444 439 } 440 else 441 { 442 dbprint(printlevel-voice+2, 445 443 "// Regularity attained at the last step of m.g.f.r. of i: NO"); 446 447 444 } 445 dbprint(printlevel-voice+2, 448 446 "// Time for computing regularity: "+ string(time) + " sec."); 449 447 dbprint(printlevel-voice+2, 450 448 "// The Castelnuovo-Mumford regularity of i is:"); 451 449 return(H); 452 450 } 453 451 example … … 648 646 map phi; 649 647 i=imap(r1,i); 650 chcoord=select1(maxideal(1),1 ,(n-d+1));648 chcoord=select1(maxideal(1),1..(n-d+1)); 651 649 acc=0; 652 650 for ( ii = 1; ii<=d; ii++ ) 653 651 { 654 652 matrix trex[1][n-d+ii+1]=t((1+acc)..(n-d+ii+acc)),1; 655 m=select1(maxideal(1),1 ,(n-d+1+ii));653 m=select1(maxideal(1),1..(n-d+1+ii)); 656 654 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 657 655 { … … 680 678 map phi; 681 679 i=imap(r1,i); 682 chcoord=select1(maxideal(1),1 ,(n-d+2));680 chcoord=select1(maxideal(1),1..(n-d+2)); 683 681 acc=0; 684 682 for ( ii = 1; ii<=d-1; ii++ ) 685 683 { 686 684 matrix trex[1][ii+1]=t((1+acc)..(ii+acc)),1; 687 m=select1(maxideal(1),(n-d+2) ,(n-d+2+ii));685 m=select1(maxideal(1),(n-d+2)..(n-d+2+ii)); 688 686 for ( jj = 1; jj<=ii+1; jj++ ) 689 687 { … … 709 707 while ( nl < 30 ) 710 708 { 711 chcoord=select1(maxideal(1),1 ,(n-d+1));709 chcoord=select1(maxideal(1),1..(n-d+1)); 712 710 nl=nl+1; 713 711 for ( ii = 1; ii<=d; ii++ ) … … 716 714 ran=intmat(ran,1,n-d+ii+1); 717 715 ran[1,n-d+ii+1]=1; 718 m=select1(maxideal(1),1 ,(n-d+1+ii));716 m=select1(maxideal(1),1..(n-d+1+ii)); 719 717 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 720 718 { … … 750 748 while ( nl < 30 ) 751 749 { 752 chcoord=select1(maxideal(1),1 ,(n-d+2));750 chcoord=select1(maxideal(1),1..(n-d+2)); 753 751 nl=nl+1; 754 752 for ( ii = 1; ii<=d-1; ii++ ) … … 757 755 ran=intmat(ran,1,ii+1); 758 756 ran[1,ii+1]=1; 759 m=select1(maxideal(1),(n-d+2) ,(n-d+2+ii));757 m=select1(maxideal(1),(n-d+2)..(n-d+2+ii)); 760 758 for ( jj = 1; jj<=ii+1; jj++ ) 761 759 { … … 1030 1028 while ( nl < 30 ) 1031 1029 { 1032 chcoord=select1(maxideal(1),1 ,(n-d+1));1030 chcoord=select1(maxideal(1),1..(n-d+1)); 1033 1031 nl=nl+1; 1034 1032 for ( ii = 1; ii<=d; ii++ ) … … 1037 1035 ran=intmat(ran,1,n-d+ii+1); 1038 1036 ran[1,n-d+ii+1]=1; 1039 m=select1(maxideal(1),1 ,(n-d+1+ii));1037 m=select1(maxideal(1),1..(n-d+1+ii)); 1040 1038 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 1041 1039 { … … 1071 1069 while ( nl < 30 ) 1072 1070 { 1073 chcoord=select1(maxideal(1),1 ,(n-d+2));1071 chcoord=select1(maxideal(1),1..(n-d+2)); 1074 1072 nl=nl+1; 1075 1073 for ( ii = 1; ii<=d-1; ii++ ) … … 1078 1076 ran=intmat(ran,1,ii+1); 1079 1077 ran[1,ii+1]=1; 1080 m=select1(maxideal(1),(n-d+2) ,(n-d+2+ii));1078 m=select1(maxideal(1),(n-d+2)..(n-d+2+ii)); 1081 1079 for ( jj = 1; jj<=ii+1; jj++ ) 1082 1080 { … … 1536 1534 while ( nl < 30 ) 1537 1535 { 1538 chcoord=select1(maxideal(1),1 ,(n-d+1));1536 chcoord=select1(maxideal(1),1..(n-d+1)); 1539 1537 nl=nl+1; 1540 1538 for ( ii = 1; ii<=d; ii++ ) … … 1543 1541 ran=intmat(ran,1,n-d+ii+1); 1544 1542 ran[1,n-d+ii+1]=1; 1545 m=select1(maxideal(1),1 ,(n-d+1+ii));1543 m=select1(maxideal(1),1..(n-d+1+ii)); 1546 1544 for ( jj = 1; jj<=n-d+ii+1; jj++ ) 1547 1545 {
Note: See TracChangeset
for help on using the changeset viewer.