Changeset ff8d25 in git
- Timestamp:
- Dec 31, 2000, 2:55:11 AM (22 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- bb7da752a854cf4b094e8dde30a8a98f0c5bb32f
- Parents:
- 2b4e7066de6a1ca22687a95c7411269e78fe38d8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/poly.lib
r2b4e70 rff8d25 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: poly.lib,v 1. 29 2000-12-22 14:22:23greuel Exp $";2 version="$Id: poly.lib,v 1.30 2000-12-31 01:55:11 greuel Exp $"; 3 3 category="General purpose"; 4 4 info=" … … 133 133 proc freerank 134 134 "USAGE: freerank(M[,any]); M=poly/ideal/vector/module/matrix 135 COMPUTE: rank of module presented by M in case it is free. By definition this 136 is vdim(coker(M)/m*coker(M)) if coker(M) is free, where m = maximal 137 ideal of basering and M is considered as matrix (the 0-module is 138 free of rank 0) 135 COMPUTE: rank of module presented by M in case it is free. 136 By definition this is vdim(coker(M)/m*coker(M)) if coker(M) 137 is free, where m = maximal ideal of the variables of the 138 basering and M is considered as matrix. 139 (the 0-module is free of rank 0) 139 140 RETURN: rank of coker(M) if coker(M) is free and -1 else; 140 141 in case of a second argument return a list: … … 159 160 ideal i=x; 160 161 module M=[x,0,1],[-x,0,-1]; 161 freerank(M); // should be 2, coker(M) is not free 162 freerank(syz (M),""); // [1] should be 1, coker(syz(M))=M is free of rank 1 163 // [2] should be gen(2)+gen(1) (minimal relation of M) 162 freerank(M); // should be 2, coker(M) is not free 163 freerank(syz (M),""); 164 // [1] should be 1, coker(syz(M))=M is free of rank 1 165 // [2] should be gen(2)+gen(1) (minimal relation of M) 164 166 freerank(i); 165 freerank(syz(i)); 167 freerank(syz(i)); // should be 1, coker(syz(i))=i is free of rank 1 166 168 } 167 169 /////////////////////////////////////////////////////////////////////////////// … … 208 210 proc is_zero 209 211 "USAGE: is_zero(M[,any]); M=poly/ideal/vector/module/matrix 210 RETURN: integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is considered211 as matrix212 if a second argument is given, return a list:212 RETURN: integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is 213 considered as matrix. 214 If a second argument is given, return a list: 213 215 L[1] = 1 if coker(M)=0 resp. 0 if coker(M)!=0 214 216 L[2] = dim(M) … … 230 232 is_zero(j); 231 233 } 232 /////////////////////////////////////////////////////////////////////////////// /234 /////////////////////////////////////////////////////////////////////////////// 233 235 234 236 proc maxcoef (f) … … 273 275 RETURN: int/intmat, each component equals maximal degree of monomials in the 274 276 corresponding component of id, independent of ring ordering 275 (maxdeg of each var is 1) 276 of type int if id is of type poly, of type intmat else277 (maxdeg of each var is 1). 278 Of type int if id is of type poly, of type intmat else 277 279 NOTE: proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has 278 280 an option for computing weighted degrees … … 316 318 ring r = 0,(x,y,z),wp(-1,-2,-3); 317 319 poly f = x+y2+z3; 318 deg(f); 320 deg(f); //deg; returns weighted degree (in case of 1 block)! 319 321 maxdeg(f); 320 322 matrix m[2][2]=f+x10,1,0,f^2; … … 396 398 ring r = 0,(x,y,z),wp(-1,-2,-3); 397 399 poly f = x+y2+z3; 398 deg(f); 400 deg(f); //deg returns weighted degree (in case of 1 block)! 399 401 maxdeg1(f); 400 402 intvec v = ringweights(r); 401 maxdeg1(f,v); 403 maxdeg1(f,v); //weighted maximal degree 402 404 matrix m[2][2]=f+x10,1,0,f^2; 403 maxdeg1(m,v); 405 maxdeg1(m,v); //absolut weighted maximal degree 404 406 } 405 407 /////////////////////////////////////////////////////////////////////////////// … … 452 454 ring r = 0,(x,y,z),ls; 453 455 poly f = x5+y2+z3; 454 ord(f); 455 mindeg(f); 456 ord(f); // ord returns weighted order of leading term! 457 mindeg(f); // computes minimal degree 456 458 matrix m[2][2]=x10,1,0,f^2; 457 mindeg(m); 459 mindeg(m); // computes matrix of minimum degrees 458 460 } 459 461 /////////////////////////////////////////////////////////////////////////////// … … 532 534 ring r = 0,(x,y,z),ls; 533 535 poly f = x5+y2+z3; 534 ord(f); 536 ord(f); // ord returns weighted order of leading term! 535 537 intvec v = 1,-3,2; 536 mindeg1(f,v); 538 mindeg1(f,v); // computes minimal weighted degree 537 539 matrix m[2][2]=x10,1,0,f^2; 538 mindeg1(m,1..3); 540 mindeg1(m,1..3); // computes absolut minimum of weighted degrees 539 541 } 540 542 /////////////////////////////////////////////////////////////////////////////// … … 550 552 //-------------------------------- examples ----------------------------------- 551 553 example 552 { 554 { "EXAMPLE:"; echo = 2; 553 555 ring r = 0,(x,y,z),ls; 554 556 poly f = 2x5+3y2+4z3; … … 559 561 module m=[9xy,0,3z3],[4z,6y,2x]; 560 562 normalize(m); 561 normalize(matrix(m)); // by automatic type conversion to module! 562 } 563 /////////////////////////////////////////////////////////////////////////////// 564 565 //////////////////////////////////////////////////////////////////////////////// 563 } 564 /////////////////////////////////////////////////////////////////////////////// 565 566 /////////////////////////////////////////////////////////////////////////////// 566 567 // Input: <ideal>=<f1,f2,...,fm> and <polynomial> g 567 568 // Question: Does g lie in the radical of <ideal>? 568 // Solution: Compute a standard basis G for <f1,f2,...,fm,gz-1> where z is a new569 // variable. Then g is contained in the radical of <ideal> <=> 1 is570 // generator in G.571 /////////////////////////////////////////////////////////////////////////////// /569 // Solution: Compute a standard basis G for <f1,f2,...,fm,gz-1> where z is a 570 // new variable. Then g is contained in the radical of <ideal> <=> 571 // 1 is generator in G. 572 /////////////////////////////////////////////////////////////////////////////// 572 573 proc rad_con (poly g,ideal I) 573 " USAGE: rad_con(<poly>,<ideal>);574 RETURNS: 1 (TRUE) (type <int>) if <poly> is contained in the radical of 575 <ideal>, 0 (FALSE) (type <int>) otherwise576 574 "USAGE: rad_con(g,I); g polynomial, I ideal 575 RETURN: 1 (TRUE) (type int) if g is contained in the radical of I 576 @* 0 (FALSE) (type int) otherwise 577 EXAMPLE: example rad_con; shows an example 577 578 " 578 579 { def br=basering; … … 597 598 } 598 599 example 599 { " EXAMPLE: Sturmfels: Algorithms in Invariant Theory 2.3.7.";600 echo=2;601 ring R=0,(x,y,z),dp;602 ideal I=x2+y2,z2;603 poly f=x4+y4;604 rad_con(f,I);605 ideal J=x2+y2,z2,x4+y4;606 poly g=z;607 rad_con(g,I); 608 } 609 610 /////////////////////////////////////////////////////////////////////////////// 611 612 proc lcm (ideal i) 613 "USAGE: lcm(i); i ideal 614 RETURN: poly = lcm(i[1],...,i[size(i)]) 615 NOTE: 600 { "EXAMPLE:"; echo=2; 601 ring R=0,(x,y,z),dp; 602 ideal I=x2+y2,z2; 603 poly f=x4+y4; 604 rad_con(f,I); 605 ideal J=x2+y2,z2,x4+y4; 606 poly g=z; 607 rad_con(g,I); 608 } 609 /////////////////////////////////////////////////////////////////////////////// 610 611 proc lcm (id, list #) 612 "USAGE: lcm(p[,q]); p int/intve q a list of integers or 613 p poly/ideal q a list of polynomials 614 RETURN: the least common multiple of the common entries of p and q: 615 @* - of type int if p is an int/intvec 616 @* - of type poly if p is a poly/ideal 616 617 EXAMPLE: example lcm; shows an example 617 618 " 618 619 { 619 620 int k,j; 620 poly p,q; 621 i=simplify(i,10); 622 for(j=1;j<=size(i);j++) 623 { 624 if(deg(i[j])>0) 625 { 626 p=i[j]; 627 break; 628 } 629 } 630 if(deg(p)==-1) 631 { 632 return(1); 633 } 634 for (k=j+1;k<=size(i);k++) 635 { 636 if(deg(i[k])!=0) 621 //------------------------------ integer case -------------------------------- 622 if( typeof(id) == "int" or typeof(id) == "intvec" ) 623 { 624 intvec i = id; 625 if (size(#)!=0) 637 626 { 638 q=gcd(p,i[k]); 639 if(deg(q)==0) 627 for (j = 1; j<=size(#); j++) 640 628 { 641 p=p*i[k]; 629 if (typeof(#[j]) !="int" and typeof(#[j]) !="intvec") 630 { ERROR("// ** list element must be an integer");} 631 else 632 { i = i,#[j]; } 642 633 } 643 else 634 } 635 int p,q; 636 if( i == 0 ) 637 { 638 return(0); 639 } 640 for(j=1;j<=size(i);j++) 641 { 642 if( i[j] != 0 ) 643 { 644 p=i[j]; 645 break; 646 } 647 } 648 for (k=j+1;k<=size(i);k++) 649 { 650 if( i[k] !=0) 644 651 { 652 q=gcd(p,i[k]); 645 653 p=p/q; 646 654 p=p*i[k]; 647 655 } 648 656 } 649 } 650 return(p); 657 if(p <0 ) 658 {return(-p);} 659 return(p); 660 } 661 662 //----------------------------- polynomial case ------------------------------ 663 if( typeof(id) == "poly" or typeof(id) == "ideal" ) 664 { 665 ideal i = id; 666 if (size(#)!=0) 667 { 668 for (j = 1; j<=size(#); j++) 669 { 670 if (typeof(#[j]) !="poly" and typeof(#[j]) !="ideal" 671 and typeof(#[j]) !="int" and typeof(#[j]) !="intvec") 672 { ERROR("// ** list element must be a polynomial");} 673 else 674 { i = i,#[j]; } 675 } 676 } 677 poly p,q; 678 i=simplify(i,10); 679 if(size(i) == 0) 680 { 681 return(0); 682 } 683 for(j=1;j<=size(i);j++) 684 { 685 if(maxdeg(i[j])!= 0) 686 { 687 p=i[j]; 688 break; 689 } 690 } 691 if(deg(p)==-1) 692 { 693 return(1); 694 } 695 for (k=j+1;k<=size(i);k++) 696 { 697 if(maxdeg(i[k])!=0) 698 { 699 q=gcd(p,i[k]); 700 if(maxdeg(q)==0) 701 { 702 p=p*i[k]; 703 } 704 else 705 { 706 p=p/q; 707 p=p*i[k]; 708 } 709 } 710 } 711 return(p); 712 } 651 713 } 652 714 example … … 655 717 poly p = (x+y)*(y+z); 656 718 poly q = (z4+2)*(y+z); 657 ideal l=p,q; 658 poly pr= lcm(l); 659 pr; 660 l=1,-1,p,1,-1,q,1; 661 pr=lcm(l); 662 pr; 719 lcm(p,q); 720 ideal i=p,q,y+z; 721 lcm(i,p); 722 lcm(2,3,6); 723 lcm(2..6); 663 724 } 664 725 … … 683 744 /////////////////////////////////////////////////////////////////////////////// 684 745 685 686 746 proc numerator(number n) 687 747 "USAGE: numerator(n); n number … … 701 761 numerator(n); 702 762 } 763 /////////////////////////////////////////////////////////////////////////////// 703 764 704 765 proc denominator(number n) … … 721 782 //////////////////////////////////////////////////////////////////////// 722 783 784 //////////////////////////////////////////////////////////////////////// 785 // The idea of the procedures mod2id, id2mod and subrInterred is, to 786 // perform standard basis computation or interreduction of a submodule 787 // of a free module with generators gen(1),...,gen(n) over a ring R 788 // in a ring R[t1,...,tn]/<ti*tj> with gen(i) maped to ti 789 //////////////////////////////////////////////////////////////////////// 790 723 791 proc mod2id(matrix M,intvec vpos) 724 "USAGE: 725 ASSUME: 726 to var(vpos[i])727 the basering contains variables var(vpos[i]) which do not occur728 in M729 NOTE: this procedure should be used in the following situation: 730 one wants to pass to a ring with new variables, say e(1),..,e(s),731 which correspond to the components gen(1),..,gen(s) of the732 module M such that e(i)*e(j)=0 for all i,j 733 the new ring should already exist and be the current ring734 RETURN: ideal i in which each gen(i) from the module is replaced by 735 var(vpos[i]) and all monomials var(vpos[i])*var(vpos[j]) have736 been added to the generating set of i737 EXAMPLE: 792 "USAGE: mod2id(M,vpos); M matrix, vpos intvec 793 ASSUME: vpos is an integer vector such that gen(i) corresponds 794 to var(vpos[i]). 795 The basering contains variables var(vpos[i]) which do not occur 796 in M. 797 RETURN: ideal I in which each gen(i) from the module is replaced by 798 var(vpos[i]) and all monomials var(vpos[i])*var(vpos[j]) have 799 been added to the generating set of I. 800 NOTE: This procedure should be used in the following situation: 801 one wants to pass to a ring with new variables, say e(1),..,e(s), 802 which correspond to the components gen(1),..,gen(s) of the 803 module M such that e(i)*e(j)=0 for all i,j. 804 The new ring should already exist and be the current ring 805 EXAMPLE: example mod2id; shows an example" 738 806 { 739 807 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) … … 771 839 772 840 proc id2mod(ideal i,intvec vpos) 773 "USAGE: 774 NOTE: * use this procedure only makes sense if the ideal contains 775 all var(vpos[i])*var(vpos[j]) as monomial generators and776 all other generators are linear combinations of the 777 var(vpos[i]) over the ring in the other variables778 * this is the inverse procedure to mod2id and should be applied779 only to ideals created by mod2id using the same intvec vpos780 (possibly after a standard basis computation)781 RETURN: module corresponding to the ideal by replacing var(vpos[i]) by 782 gen(i) and omitting all generators var(vpos[i])*var(vpos[j])783 EXAMPLE: 841 "USAGE: id2mod(I,vpos); I ideal, vpos intvec 842 RETURN: module corresponding to the ideal by replacing var(vpos[i]) by 843 gen(i) and omitting all generators var(vpos[i])*var(vpos[j]) 844 NOTE: * This procedure only makes sense if the ideal contains 845 all var(vpos[i])*var(vpos[j]) as monomial generators and 846 all other generators of I are linear combinations of the 847 var(vpos[i]) over the ring in the other variables. 848 * This is the inverse procedure to mod2id and should be applied 849 only to ideals created by mod2id using the same intvec vpos 850 (possibly after a standard basis computation) 851 EXAMPLE: example id2mod; shows an example" 784 852 { 785 853 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) … … 820 888 e.g. x_1,..,x_n and t_1,..,t_s 821 889 mon: ideal with monomial generators (not divisible by 822 oneof the t_i) such that sm is contained in the module890 any of the t_i) such that sm is contained in the module 823 891 k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)] 824 892 iv: intvec listing the variables which are supposed to be used … … 828 896 l[2]=their coefficients after interreduction 829 897 l[3]=l[1]*l[2] 830 (interreduced system of generators of sm seen as a submodule 831 of k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)]) 832 EXAMPLE: example subrInterred; shows an example" 898 PUPOSE: Do interred only w.r.t. a subset of variables. 899 The procedure returns an interreduced system of generators of 900 sm considered as a k[t_1,..,t_s]-submodule of the free module 901 k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)]). 902 EXAMPLE: example subrInterred; shows an example 903 " 833 904 { 834 905 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1)
Note: See TracChangeset
for help on using the changeset viewer.