Changeset 7708934 in git for Singular/LIB/general.lib
 Timestamp:
 Dec 30, 2000, 4:00:57 AM (22 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
 Children:
 9f8a0c36a14214c0b8e9241e2b54aee67001707d
 Parents:
 584f84d6e8c6f3340af1d80fff4224b3f977de76
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/LIB/general.lib
r584f84d r7708934 2 2 //anne, added deleteSublist and watchdog 12.12.2000 3 3 /////////////////////////////////////////////////////////////////////////////// 4 version="$Id: general.lib,v 1.3 2 20001229 02:19:24greuel Exp $";4 version="$Id: general.lib,v 1.33 20001230 03:00:57 greuel Exp $"; 5 5 category="General purpose"; 6 6 info=" … … 660 660 A module m is identified with the corresponding matrix M (columns 661 661 of M generate m). 662 @* If v is outside the range of id, we have the empty product and the 663 result will be 1 (of type int). 662 664 EXAMPLE: example product; shows an example 663 665 " 664 { 666 { 667 // initialization and special feature  665 668 int n,j,tt; 666 string ty; 669 string ty; //will become type of id 667 670 list l; 671 672 // We wish to allow something like product(x(1..10)) if x(1),...,x(10) are 673 // variables. x(1..10) is a list of polys and enters the procedure with 674 // id=x(1) and # a list with 9 polys, #[1]= x(2),...,#[9]= x(10). Hence, in 675 // this case # is never empty. If an additional intvec v is given, 676 // it is added to #, so we have to separate it first and make 677 // the rest a list which has to be multiplied. 678 668 679 int s = size(#); 669 680 if( s!=0 ) 670 { if ( typeof(#[s])=="intvec" ) 671 { intvec v = #[s]; 672 tt=1; s=s1; 681 { if ( typeof(#[s])=="intvec" or typeof(#[s])=="int") 682 { 683 intvec v = #[s]; 684 tt=1; 685 s=s1; 673 686 if ( s>0 ) { # = #[1..s]; } 674 687 } … … 676 689 if ( s>0 ) 677 690 { 678 l = list(id)+#; 679 kill id; 680 list id = l; 681 ty = "list"; 691 l = list(id)+#; 692 kill id; 693 list id = l; //case: id = list 694 ty = "list"; 695 n = size(id); 682 696 } 683 697 else 684 { ty = typeof(id); 685 } 686 if( ty=="list" ) 687 { n = size(id); 688 def f(1) = id[1]; 689 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j1)*id[j]; } 690 return(f(n)); 691 } 698 { 699 ty = typeof(id); 700 if( ty == "list" ) 701 { n = size(id); } 702 } 703 // reduce to 3 cases  692 704 if( ty=="poly" or ty=="ideal" or ty=="vector" 693 705 or ty=="module" or ty=="matrix" ) … … 695 707 ideal i = ideal(matrix(id)); 696 708 kill id; 697 ideal id = i; 698 if( tt!=0 ) { id = id[v]; } 699 n = ncols(id); poly f(1)=id[1]; 709 ideal id = i; //case: id = ideal 710 n = ncols(id); 700 711 } 701 712 if( ty=="int" or ty=="intvec" or ty=="intmat" ) … … 705 716 intvec i = S[1..nrows(S),1..ncols(S)]; 706 717 kill id; 707 intvec id = i; 708 if( tt!=0 ) { id = id[v]; } 709 n = size(id); int f(1)=id[1]; 710 } 718 intvec id = i; //case: id = intvec 719 n = size(id); 720 } 721 // consider intvec v and empty product  722 if( tt!=0 ) 723 { 724 for (j=1; j<=size(v); j++) 725 { 726 if ( v[j] <= 0 or v[j] > n ) //v outside range of id 727 { 728 return(1); //empty product is 1 729 } 730 } 731 id = id[v]; //consider part of id 732 } //corresponding to v 733 // special case: one factor is zero  734 if ( typeof(id) == "ideal") 735 { 736 if( size(id) < ncols(id) ) 737 { 738 poly f; return(f); 739 } 740 } 741 // finally, multiply objects  742 n = size(id); 743 def f(1) = id[1]; 711 744 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j1)*id[j]; } 712 745 return(f(n)); … … 947 980 RETURN: The sum of all entries of id [with index given by v] of type 948 981 depending on the entries of id. 949 NOTE: 982 NOTE: If id is not a list, id is treated as a list of polys resp. integers. 950 983 A module m is identified with the corresponding matrix M (columns 951 984 of M generate m). 985 @* If v is outside the range of id, we have the empty sum and the 986 result will be 0 (of type int). 952 987 EXAMPLE: example sum; shows an example 953 988 " 954 989 { 990 // initialization and special feature  955 991 int n,j,tt; 956 string ty; 992 string ty; // will become type of id 957 993 list l; 994 995 // We wish to allow something like sum(x(1..10)) if x(1),...,x(10) are 996 // variables. x(1..10) is a list of polys and enters the procedure with 997 // id=x(1) and # a list with 9 polys, #[1]= x(2),...,#[9]= x(10). Hence, in 998 // this case # is never empty. If an additional intvec v is given, 999 // it is added to #, so we have to separate it first and make 1000 // the rest a list which has to be added. 1001 958 1002 int s = size(#); 959 1003 if( s!=0 ) 960 { if ( typeof(#[s])=="intvec" )1004 { if ( typeof(#[s])=="intvec" or typeof(#[s])=="int") 961 1005 { intvec v = #[s]; 962 tt=1; s=s1; 1006 tt=1; 1007 s=s1; 963 1008 if ( s>0 ) { # = #[1..s]; } 964 1009 } … … 966 1011 if ( s>0 ) 967 1012 { 968 l = list(id)+#;969 kill id;970 list id = l;971 ty = "list";1013 l = list(id)+#; 1014 kill id; 1015 list id = l; //case: id = list 1016 ty = "list"; 972 1017 } 973 1018 else 974 { ty = typeof(id); 975 } 976 if( ty=="list" ) 977 { n = size(id); 978 def f(1) = id[1]; 979 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j1)+id[j]; } 980 return(f(n)); 981 } 1019 { 1020 ty = typeof(id); 1021 } 1022 // reduce to 3 cases  982 1023 if( ty=="poly" or ty=="ideal" or ty=="vector" 983 1024 or ty=="module" or ty=="matrix" ) 984 { 1025 { //case: id = ideal 985 1026 ideal i = ideal(matrix(id)); 986 1027 kill id; 987 ideal id = i; 988 if( tt!=0 ) { id = id[v]; } 989 n = ncols(id); poly f(1)=id[1]; 1028 ideal id = simplify(i,2); //delete 0 entries 990 1029 } 991 1030 if( ty=="int" or ty=="intvec" or ty=="intmat" ) … … 995 1034 intvec i = S[1..nrows(S),1..ncols(S)]; 996 1035 kill id; 997 intvec id = i; 998 if( tt!=0 ) { id = id[v]; } 999 n = size(id); int f(1)=id[1]; 1000 } 1036 intvec id = i; //case: id = intvec 1037 } 1038 // consider intvec v and empty sum  1039 if( tt!=0 ) 1040 { 1041 for (j=1; j<=size(v); j++) 1042 { 1043 if ( v[j] <= 0 or v[j] > size(id) ) //v outside range of id 1044 { 1045 return(0); //empty sum is 0 1046 } 1047 } 1048 id = id[v]; //consider part of id 1049 } //corresponding to v 1050 1051 // finally, add objects  1052 n = size(id); 1053 def f(1) = id[1]; 1001 1054 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j1)+id[j]; } 1002 1055 return(f(n)); int n,j,tt;
Note: See TracChangeset
for help on using the changeset viewer.