Changeset 65546eb in git for Singular/LIB/general.lib
- Timestamp:
- Jan 16, 2001, 2:03:54 PM (22 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 49bec69100d73ab84e1edda6408fd13e13cd5ab0
- Parents:
- f01a1ae78d8a706cd6d590585b8a8a76a80cad52
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/general.lib
rf01a1a r65546eb 2 2 //anne, added deleteSublist and watchdog 12.12.2000 3 3 /////////////////////////////////////////////////////////////////////////////// 4 version="$Id: general.lib,v 1.3 7 2001-01-11 12:04:17 pfister Exp $";4 version="$Id: general.lib,v 1.38 2001-01-16 13:03:54 Singular Exp $"; 5 5 category="General purpose"; 6 6 info=" … … 419 419 @* - killall(\"not\", \"type_name\"); kills all user-defined variables, 420 420 except those of type \"type_name\" and except loaded procedures 421 @* - killall(\"not\", \"name_1\", \"name_2\", ...); 422 kills all user-defined variables, except those of name \"name_i\" 421 @* - killall(\"not\", \"name_1\", \"name_2\", ...); 422 kills all user-defined variables, except those of name \"name_i\" 423 423 and except loaded procedures 424 424 NOTE: killall should never be used inside a procedure … … 435 435 } 436 436 } 437 437 438 438 // kills all user-defined variables but not loaded procedures 439 439 if( size(#)==0 ) … … 441 441 for ( @joni=size(@marie); @joni>0; @joni-- ) 442 442 { 443 if( @marie[@joni]!="LIB" and typeof(`@marie[@joni]`)!="proc" ) 443 if( @marie[@joni]!="LIB" and typeof(`@marie[@joni]`)!="proc" ) 444 444 { kill `@marie[@joni]`; } 445 445 } … … 455 455 for ( @joni=size(@marie); @joni>0; @joni-- ) 456 456 { 457 if((@marie[@joni]!="killall") and (@marie[@joni]=="LIB" or 457 if((@marie[@joni]!="killall") and (@marie[@joni]=="LIB" or 458 458 typeof(`@marie[@joni]`)=="proc")) 459 459 { kill `@marie[@joni]`; } … … 461 461 } 462 462 else 463 { 463 { 464 464 // other types 465 465 for ( @joni=size(@marie); @joni>2; @joni-- ) 466 466 { 467 if(typeof(`@marie[@joni]`)==#[1] and @marie[@joni]!="LIB" 468 and typeof(`@marie[@joni]`)!="proc") 467 if(typeof(`@marie[@joni]`)==#[1] and @marie[@joni]!="LIB" 468 and typeof(`@marie[@joni]`)!="proc") 469 469 { kill `@marie[@joni]`; } 470 470 } … … 473 473 else 474 474 { 475 // kills all user-defined variables whose name or type is not #i 475 // kills all user-defined variables whose name or type is not #i 476 476 for ( @joni=size(@marie); @joni>2; @joni-- ) 477 477 { … … 654 654 v intvec (default: v=1..number of entries of id) 655 655 ASSUME: list members can be multiplied. 656 RETURN: The product of all entries of id [with index given by v] of type 656 RETURN: The product of all entries of id [with index given by v] of type 657 657 depending on the entries of id. 658 658 NOTE: If id is not a list, id is treated as a list of polys resp. integers. … … 663 663 EXAMPLE: example product; shows an example 664 664 " 665 { 665 { 666 666 //-------------------- initialization and special feature --------------------- 667 667 int n,j,tt; 668 string ty; 668 string ty; //will become type of id 669 669 list l; 670 670 671 671 // We wish to allow something like product(x(1..10)) if x(1),...,x(10) are 672 // variables. x(1..10) is a list of polys and enters the procedure with 672 // variables. x(1..10) is a list of polys and enters the procedure with 673 673 // id=x(1) and # a list with 9 polys, #[1]= x(2),...,#[9]= x(10). Hence, in 674 674 // this case # is never empty. If an additional intvec v is given, … … 678 678 int s = size(#); 679 679 if( s!=0 ) 680 { if ( typeof(#[s])=="intvec" or typeof(#[s])=="int") 681 { 680 { if ( typeof(#[s])=="intvec" or typeof(#[s])=="int") 681 { 682 682 intvec v = #[s]; 683 tt=1; 683 tt=1; 684 684 s=s-1; 685 685 if ( s>0 ) { # = #[1..s]; } … … 695 695 } 696 696 else 697 { 697 { 698 698 ty = typeof(id); 699 if( ty == "list" ) 699 if( ty == "list" ) 700 700 { n = size(id); } 701 701 } … … 716 716 kill id; 717 717 intvec id = i; //case: id = intvec 718 n = size(id); 718 n = size(id); 719 719 } 720 720 //--------------- consider intvec v and empty product ----------------------- 721 if( tt!=0 ) 721 if( tt!=0 ) 722 722 { 723 723 for (j=1; j<=size(v); j++) 724 724 { 725 725 if ( v[j] <= 0 or v[j] > n ) //v outside range of id 726 { 726 { 727 727 return(1); //empty product is 1 728 } 728 } 729 729 } 730 730 id = id[v]; //consider part of id … … 739 739 } 740 740 //-------------------------- finally, multiply objects ----------------------- 741 n = size(id); 741 n = size(id); 742 742 def f(1) = id[1]; 743 743 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j-1)*id[j]; } … … 885 885 ideal i = x3,z3,xyz; 886 886 sort(i); //sorts using lex ordering, smaller polys come first 887 887 888 888 sort(i,3..1); 889 889 … … 900 900 v intvec (default: v=1..number of entries of id) 901 901 ASSUME: list members can be added. 902 RETURN: The sum of all entries of id [with index given by v] of type 902 RETURN: The sum of all entries of id [with index given by v] of type 903 903 depending on the entries of id. 904 904 NOTE: If id is not a list, id is treated as a list of polys resp. integers. … … 916 916 917 917 // We wish to allow something like sum(x(1..10)) if x(1),...,x(10) are 918 // variables. x(1..10) is a list of polys and enters the procedure with 918 // variables. x(1..10) is a list of polys and enters the procedure with 919 919 // id=x(1) and # a list with 9 polys, #[1]= x(2),...,#[9]= x(10). Hence, in 920 920 // this case # is never empty. If an additional intvec v is given, … … 926 926 { if ( typeof(#[s])=="intvec" or typeof(#[s])=="int") 927 927 { intvec v = #[s]; 928 tt=1; 928 tt=1; 929 929 s=s-1; 930 930 if ( s>0 ) { # = #[1..s]; } … … 939 939 } 940 940 else 941 { 941 { 942 942 ty = typeof(id); 943 943 } … … 959 959 } 960 960 //------------------- consider intvec v and empty sum ----------------------- 961 if( tt!=0 ) 961 if( tt!=0 ) 962 962 { 963 963 for (j=1; j<=size(v); j++) 964 964 { 965 965 if ( v[j] <= 0 or v[j] > size(id) ) //v outside range of id 966 { 966 { 967 967 return(0); //empty sum is 0 968 } 968 } 969 969 } 970 970 id = id[v]; //consider part of id … … 972 972 973 973 //-------------------------- finally, add objects --------------------------- 974 n = size(id); 974 n = size(id); 975 975 def f(1) = id[1]; 976 976 for( j=2; j<=n; j=j+1 ) { def f(j)=f(j-1)+id[j]; } … … 1055 1055 the string "Killed" is returned and the global variable 1056 1056 'watchdog_interrupt' is defined. 1057 NOTE: * the MP package must be enabled 1058 * the current basering should not be watchdog_rneu, since 1057 NOTE: * the MP package must be enabled 1058 * the current basering should not be watchdog_rneu, since 1059 1059 watchdog_rneu will be killed 1060 1060 * if there are variable names of the structure x(i) all … … 1077 1077 int j=10; 1078 1078 int k=999999; 1079 // fork, get the pid of the child and send it the command 1079 // fork, get the pid of the child and send it the command 1080 1080 link l_fork="MPtcp:fork"; 1081 1081 open(l_fork); … … 1138 1138 } 1139 1139 ERROR("MP-support is not enabled in this version of Singular."); 1140 } 1140 } 1141 1141 } 1142 1142 example
Note: See TracChangeset
for help on using the changeset viewer.