Changeset d63ce7 in git
- Timestamp:
- Jan 28, 2015, 8:10:16 PM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- a0082e2e3d7a68676ebf9aa816c2ca887ea0c56c
- Parents:
- 6fcbe89e09cb8c0ccfddde65e57da4c5a60c8854
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/gradedModules.lib
r6fcbe89 rd63ce7 32 32 "; 33 33 34 35 36 34 37 ////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 38 // . view graded module/map … … 204 207 } 205 208 209 // Q@Wolfram: what should be done with zero gens!? 206 210 proc grdeg( def M, list # ) 207 211 "graded degrees of gens(i.e. columns)" 208 209 212 { 210 213 // use initial grading if given … … 221 224 kill w; 222 225 } 223 224 // try to homogenize otherwise 225 if( typeof(attrib( M, "isHomog")) != "intvec" ) 226 { // no such attribute? // ERROR("No grading!"); 227 ASSUME(0, /* input must be graded: cannot compute homogenizing grading */ homog(M) ); 228 } 229 230 231 ASSUME(0, /* input must be graded! */ typeof(attrib(M, "isHomog")) == "intvec" ); 232 // input should be graded: 226 227 ASSUME(1, grtest(M) ); 228 233 229 def w = attrib(M, "isHomog"); // grading weights? 234 ASSUME(0, /* input must be correctly graded! */ nrows(M) == size(w) ); 235 236 if( size(M) == 0 ) { return (w); } // TODO??? 230 231 if( size(M) == 0 ){ return (w); } // TODO: Q@Wolfram!??? 237 232 238 233 int m = ncols(M); // m > 0 in Singular! … … 251 246 } 252 247 253 254 static proc order( def M, int s, list #) 255 "helper for reorder: compute graded degrees and the permutation to sort them" 256 { 257 if( size(#) > 0 ) { intvec gr = grdeg( M, #[1] ); } 258 else { intvec gr = grdeg( M ); } 259 248 static proc reorder(def M, int s) 249 " 250 Reorder gens of M: compute graded degrees and the permutation to sort them 251 " 252 { 253 // input should be graded: 254 ASSUME(1, grtest(M) ); 255 256 intvec w = attrib(M, "isHomog"); // grading weights 257 258 intvec gr = grdeg( M ); 260 259 261 260 // intvec d = deg(M[1..nocls(M)]); // no need to deal with un-weighted degrees??! … … 263 262 intvec pivot = mysort(gr, s); 264 263 264 // grades & ordering permutation for N. gr[pivot] should be sorted! 265 265 ASSUME(1, issorted(gr[pivot], s)); 266 266 267 return (gr, pivot); 268 } 269 270 271 static proc reorder(def M, int s, list #) 272 " 273 helper for Reorder gens of M 274 " 275 { 276 // use initial grading if given 277 if( size(#) == 1 ) 278 { 279 def w = #[1]; 280 if( typeof(w) == "intvec" ) 281 { 282 if( nrows(M) == size(w) ) 283 { 284 attrib(M, "isHomog", w); 285 } 286 } 287 kill w; 288 } 289 290 // try to homogenize otherwise 291 if( typeof(attrib( M, "isHomog")) != "intvec" ) 292 { // no such attribute? // ERROR("No grading!"); 293 ASSUME(0, /* input must be graded: cannot compute homogenizing grading */ homog(M) ); 294 } 295 296 ASSUME(0, /* input must be graded! */ typeof(attrib(M, "isHomog")) == "intvec" ); 297 // input should be graded: 298 def w = attrib(M, "isHomog"); // grading weights? 299 ASSUME(0, /* input must be correctly graded! */ nrows(M) == size(w) ); 300 301 302 intvec d, p; 303 304 if( size(#) > 0 ) { (d, p) = order( M, s, #[1] ); } 305 else { (d, p) = order( M, s ); } 306 307 // grades & ordering permutation for N. d[p] should be sorted! 308 309 def N = grobj(module(M[p]), w); // reorder the starting ideal/module 310 311 d = d[p]; 267 module N = grobj(module(M[pivot]), w); // reorder the starting ideal/module 312 268 313 269 // "reorder: "; grview(N); 314 270 315 return (N, d); 316 } 317 318 /* 319 // only for whole resolutions, please use grorder instead! 320 static proc ordres( list L, list # ) 321 " 322 reorder a resolution given by the list (and optionnaly a grading for its 1st entry) 323 " 324 { 325 int k = 1; // "k: ", k; 326 327 // check 1st syzygy property? 328 // if( 0 != size( module( matrix(transpose(L[k+1]))*matrix(transpose(L[k-1+1])) ) ) ){L[k];"";L[k+1];module( matrix(transpose(L[k+1]))*matrix(transpose(L[k-1+1])) );ERROR( "Exactness test failed!!!!" );} 329 330 331 // TODO: rewrite with reorder 332 intvec d, p, pp; 333 module N = L[1]; 334 (d, p) = order( N, 1, # ); // grades & ordering permutation for N. d[p] should be sorted! 335 N = module(N[p]); // reorder the starting ideal/module 336 attrib( N, "isHomog", w ); // set the grading 337 L[1] = N; // put it back into the list of modules 338 339 // grview(N); 340 kill w, N; 341 342 /////////////////////////////////// 343 k++; 344 while( k <= size(L) ) 345 { 346 // "k: ", k; 347 module N = L[k]; 348 349 if( size(N) == 0 ) { break; } // resolution should finish with 0 module? 350 351 if( typeof(attrib( N, "isHomog")) != "intvec" ) 352 { 353 attrib( N, "isHomog", d); // ERROR("Non-graded input!"); 354 } 355 356 // grview(N); 357 358 intvec w = attrib( N, "isHomog"); 359 (d, pp) = order( N, w, 1 ); // grades & ordering permutation : d[p] should be sorted! 360 361 // reorder k-th syzygy (columns): 362 module T = module(N[pp]); 363 kill N; 364 module N = transpose(T); 365 kill T; 366 367 // reorder k-th syzygy (rows): 368 module T = module(N[p]); 369 kill N; 370 module N = transpose(T); 371 kill T; 372 373 w = intvec(w[p]); attrib( N, "isHomog", w); // corresponding ordered grading 374 375 L[k] = N; // grview(N); 376 377 // check syz. property? 378 // if( 0 != size( module( matrix(transpose(N))*matrix(transpose(L[k-1])) ) ) ) { N; L[k-1]; module( matrix(transpose(N))*matrix(transpose(L[k-1])) ); ERROR( "Exactness test failed!!!!" ); } 379 kill N, w; 380 p = pp; 381 k++; 382 } 383 384 return (list( L[1 .. (k-1)] )); 385 } 386 */ 387 388 389 390 391 proc grtranspose(def M, list #) 271 return (N, intvec(gr[pivot])); 272 } 273 274 proc grtranspose(def M) 392 275 " 393 276 transpose graded module/map or a chain complex?... … … 434 317 ////// 435 318 // "a"; grview(M); 319 ASSUME(1, grtest(M) ); 436 320 437 321 // TODO: something is wrong here: … … 439 323 intvec d; module N; 440 324 441 if( size(#) > 0 ) { (N,d) = reorder(M, -1, #[1]); } 442 else { (N,d) = reorder(M, -1); } 325 (N,d) = reorder(M, -1); 443 326 444 327 kill M; module M = grobj(transpose(N), -d); … … 461 344 462 345 463 proc grorder(def M , list #)346 proc grorder(def M) 464 347 " 465 348 reorder graded module/map or a chain complex?... … … 498 381 return (L); // ? 499 382 } 383 384 ASSUME(1, grtest(M) ); 500 385 501 386 // "a"; grview(M); … … 503 388 intvec d; module N; 504 389 505 if( size(#) > 0 ) { (N,d) = reorder(M, 1, #[1]); }506 else { (N,d) = reorder(M, 1); }507 kill M; module M = grobj(transpose(N), -d);390 (N,d) = reorder(M, 1); kill M; 391 392 module M = grobj(transpose(N), -d); kill N,d; 508 393 509 394 // "b"; grview(M); 510 395 511 kill N,d;module N; intvec d;396 module N; intvec d; 512 397 // reverse order: 513 398 (N,d) = reorder(M, -1); kill M; … … 533 418 " = Ring: ", string(basering); 534 419 535 I = groebner(I); attrib(I, "isHomog", intvec(0)); 420 I = groebner(I); attrib(I, "isHomog", intvec(0)); 421 ASSUME(0, grtest(I)); 536 422 // " = Input degrees: "; grview(I); 537 423 … … 587 473 ///////////////////////////////////////////////////////// 588 474 589 // ????475 // Q@Woflram? 590 476 proc grzero() 591 477 "presentation of S(0)^1 … … 593 479 " 594 480 { 595 module Z = 0; 596 return ( grobj(Z,intvec(0)) ); 481 return ( grobj(module([0]), intvec(0)) ); 597 482 } 598 483 … … 602 487 " 603 488 { 604 if(p==0){ return ( grzero() ); } // just ERROR ???489 if(p==0){ ERROR("Sorry, we don't know what is A^0!?!?"); } // grzero!? 605 490 606 491 ASSUME(0, p > 0); 492 ASSUME(1, grtest(A) ); 607 493 608 494 if(p==1){ return(A); } … … 626 512 " 627 513 { 514 ASSUME(1, grtest(A) ); 515 ASSUME(1, grtest(B) ); 516 628 517 intvec a = attrib(A, "isHomog"); 629 518 intvec b = attrib(B, "isHomog"); … … 631 520 int r = nrows(A); 632 521 633 ASSUME( 0, r == size(a) ); 634 635 module T; T[r] = 0; T = T, module(transpose(B)); 636 module AB = module(A), transpose(T); 637 638 return(grobj(AB, c)); 522 module T = align(module(B), r); // T; print(T); nrows(T); // BUG!!!! 523 module S = module(A), T; 524 525 return(grobj(S, c)); 639 526 } 640 527 example … … 705 592 } 706 593 594 595 proc grtest(def N) 596 "test if N is a matrix/module with matching isHomog attribute (intvec)" 597 { 598 string t = typeof(N); 599 if( (t != "ideal") && (t != "module") && (t != "matrix") ) { return (0); }; // N should be something like a matrix 600 601 // N must be graded! 602 if ( typeof(attrib(N, "isHomog")) != "intvec" ){ return (0); }; 603 604 intvec gr = attrib(N, "isHomog"); // grading weights... 605 if ( nrows(N) > size(gr) ) { return (0); }; // wrong number of rows? 606 607 // if( attrib(N, "rank") != size(gr) ){ return (0); } // wrong rank :( 608 609 610 // if( !homog(N) ) { return (0); }; // N should be homogenous 611 612 613 return (1); 614 } 615 707 616 proc grisequal (def A, def B) 708 617 "TODO" 709 { 710 return (1==1); // TODO! 618 { 619 ASSUME(1, grtest(A) ); 620 ASSUME(1, grtest(B) ); 621 622 int ra = nrows(A); 623 int rb = nrows(B); 624 625 intvec wa = attrib(A, "isHomog"); 626 intvec wb = attrib(B, "isHomog"); 627 628 if( (ra != rb) || (ncols(A) != ncols(B)) ){ return (0); } // TODO: ??? 629 return ( (wa == wb) && 630 (size(module(matrix(A) - matrix(B))) == 0) ); // TODO: ??? 711 631 } 712 632 … … 716 636 " 717 637 { 718 module Z; Z[a] = 0;719 Z = grobj(Z, -intvec(d:a)); 720 721 ASSUME(2, grisequal(Z, grpower( grshift(grzero(), -d), a ) )); // optional check638 module Z; Z[a] = [0]; 639 Z = grobj(Z, -intvec(d:a)); // will set the rank as well 640 641 ASSUME(2, grisequal(Z, grpower( grshift(grzero(), d), a ) )); // optional check 722 642 return(Z); 723 643 } 724 644 725 proc grobj( module M, intvec w)645 proc grobj(def A, intvec w) 726 646 "" 727 647 { 648 module M = module(A); 649 ASSUME(0, size(w) >= nrows(M) ); 650 attrib(M, "rank", size(w)); 728 651 attrib(M, "isHomog", w); 729 attrib(M, "rank", size(w));652 ASSUME(1, grtest(M) ); 730 653 return (M); 731 654 } 655 656 657 static proc align( def A, int d) 658 "analog of align kernel command for older Singular versions 659 this is static since it should not be used by @code{align}-able (newer) 660 Singular releases. 661 Note that this proc does not care about any attributes (of A) 662 " 663 { 664 module T; T[d] = 0; 665 T = T, module(transpose(A)); 666 return( module(transpose(T)) ); 667 }
Note: See TracChangeset
for help on using the changeset viewer.