Changeset d2b2a7 in git for Singular/LIB/general.lib
- Timestamp:
- May 5, 1998, 1:55:40 PM (25 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 97f92aa6d280f6022eaae47195ccc02503ccb984
- Parents:
- 4996f5286c7671191ad22e654499fd8b752fe4f0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/general.lib
r4996f52 rd2b2a7 1 // $Id: general.lib,v 1. 6 1998-04-23 17:09:20 Singular Exp $1 // $Id: general.lib,v 1.7 1998-05-05 11:55:27 krueger Exp $ 2 2 //system("random",787422842); 3 3 //(GMG, last modified 22.06.96) 4 4 /////////////////////////////////////////////////////////////////////////////// 5 5 6 version="$Id: general.lib,v 1. 6 1998-04-23 17:09:20 Singular Exp $";6 version="$Id: general.lib,v 1.7 1998-05-05 11:55:27 krueger Exp $"; 7 7 info=" 8 8 LIBRARY: general.lib PROCEDURES OF GENERAL TYPE … … 30 30 31 31 proc A_Z (string s,int n) 32 USAGE: A_Z("a",n); a any letter, n integer (-26<= n <=26, !=0)32 "USAGE: A_Z(\"a\",n); a any letter, n integer (-26<= n <=26, !=0) 33 33 RETURN: string of n small (if a is small) or capital (if a is capital) 34 34 letters, comma seperated, beginning with a, in alphabetical 35 35 order (or revers alphabetical order if n<0) 36 36 EXAMPLE: example A_Z; shows an example 37 " 37 38 { 38 39 if ( n>=-26 and n<=26 and n!=0 ) … … 85 86 86 87 proc binomial (int n, int k, list #) 87 USAGE: binomial(n,k[,p/s]); n,k,p integers, s string88 "USAGE: binomial(n,k[,p/s]); n,k,p integers, s string 88 89 RETURN: binomial(n,k); binomial coefficient n choose k of type int 89 90 (machine integer, limited size! ) … … 92 93 in char of basering if a basering is defined 93 94 EXAMPLE: example binomial; shows an example 95 " 94 96 { 95 97 if ( size(#)==0 ) { int rr=1; } … … 120 122 121 123 proc factorial (int n, list #) 122 USAGE: factorial(n[,string]); n integer124 "USAGE: factorial(n[,string]); n integer 123 125 RETURN: factorial(n); string of n! in char 0 124 126 factorial(n,s); n! of type number (s any string), computed in char of 125 127 basering if a basering is defined 126 128 EXAMPLE: example factorial; shows an example 129 " 127 130 { 128 131 if ( size(#)==0 ) { ring R = 0,x,dp; poly r=1; } … … 148 151 149 152 proc fibonacci (int n, list #) 150 USAGE: fibonacci(n[,string]); (n integer)153 "USAGE: fibonacci(n[,string]); (n integer) 151 154 RETURN: fibonacci(n); string of nth Fibonacci number, 152 155 f(0)=f(1)=1, f(i+1)=f(i-1)+f(i) … … 154 157 computed in characteristic of basering if a basering is defined 155 158 EXAMPLE: example fibonacci; shows an example 159 " 156 160 { 157 161 if ( size(#)==0 ) { ring fibo = 0,x,dp; number f=1; } … … 177 181 178 182 proc kmemory () 179 USAGE: kmemory();183 "USAGE: kmemory(); 180 184 RETURN: memory used by active variables, of type int (in kilobyte) 181 185 EXAMPLE: example kmemory; shows an example 186 " 182 187 { 183 188 if ( voice==2 ) { "// memory used by active variables (kilobyte):"; } … … 191 196 192 197 proc killall 193 USAGE: killall(); (no parameter)194 killall( "type_name");195 killall( "not", "type_name");198 "USAGE: killall(); (no parameter) 199 killall(\"type_name\"); 200 killall(\"not\", \"type_name\"); 196 201 COMPUTE: killall(); kills all user-defined variables but not loaded procedures 197 killall( "type_name"); kills all user-defined variables, of type "type_name"198 killall( "not", "type_name"); kills all user-defined199 variables, except those of type "type_name" and except loaded procedures202 killall(\"type_name\"); kills all user-defined variables, of type \"type_name\" 203 killall(\"not\", \"type_name\"); kills all user-defined 204 variables, except those of type \"type_name\" and except loaded procedures 200 205 RETURN: no return value 201 206 NOTE: killall should never be used inside a procedure 202 207 EXAMPLE: example killall; shows an example AND KILLS ALL YOUR VARIABLES 208 " 203 209 { 204 210 list L=names(); int joni=size(L); … … 255 261 256 262 proc number_e (int n) 257 USAGE: number_e(n); n integer263 "USAGE: number_e(n); n integer 258 264 COMPUTE: exp(1) up to n decimal digits (no rounding) 259 265 by A.H.J. Sale's algorithm … … 262 268 display its decimal format 263 269 EXAMPLE: example number_e; shows an example 270 " 264 271 { 265 272 int i,m,s,t; … … 296 303 297 304 proc number_pi (int n) 298 USAGE: number_pi(n); n positive integer305 "USAGE: number_pi(n); n positive integer 299 306 COMPUTE: pi (area of unit circle) up to n decimal digits (no rounding) 300 307 by algorithm of S. Rabinowitz … … 303 310 its decimal format 304 311 EXAMPLE: example number_pi; shows an example 312 " 305 313 { 306 314 int i,m,t,e,q,N; … … 366 374 367 375 proc primes (int n, int m) 368 USAGE: primes(n,m); n,m integers376 "USAGE: primes(n,m); n,m integers 369 377 RETURN: intvec, consisting of all primes p, prime(n)<=p<=m, in increasing 370 378 order if n<=m, resp. prime(m)<=p<=n, in decreasing order if m<n 371 379 NOTE: prime(n); returns the biggest prime number <= n (if n>=2, else 2) 372 380 EXAMPLE: example primes; shows an example 381 " 373 382 { int change; 374 383 if ( n>m ) { change=n; n=m ; m=change; change=1; } … … 386 395 387 396 proc product (id, list #) 388 USAGE: product(id[,v]); id=ideal/vector/module/matrix397 "USAGE: product(id[,v]); id=ideal/vector/module/matrix 389 398 resp.id=intvec/intmat, v=intvec (e.g. v=1..n, n=integer) 390 399 RETURN: poly resp. int which is the product of all entries of id, with index … … 393 402 identified with corresponding matrix M (columns of M generate m) 394 403 EXAMPLE: example product; shows an example 404 " 395 405 { 396 406 int n,j; … … 431 441 432 442 proc ringweights (r) 433 USAGE: ringweights(r); r ring443 "USAGE: ringweights(r); r ring 434 444 RETURN: intvec of weights of ring variables. If, say, x(1),...,x(n) are the 435 445 variables of the ring r, in this order, the resulting intvec is … … 439 449 the resulting intvec is 1,...,1 440 450 EXAMPLE: example ringweights; shows an example 451 " 441 452 { 442 453 int i; intvec v; setring r; … … 456 467 457 468 proc sort (id, list #) 458 USAGE: sort(id[v,o,n]); id=ideal/module/intvec/list (of intvec's or int's)469 "USAGE: sort(id[v,o,n]); id=ideal/module/intvec/list (of intvec's or int's) 459 470 sort may be called with 1, 2 or 3 arguments in the following way: 460 471 - sort(id[v,n]); v=intvec, n=integer, … … 488 499 Zero generators of ideal/module are deleted 489 500 EXAMPLE: example sort; shows an example 501 " 490 502 { 491 503 int ii,jj,s,n = 0,0,1,0; … … 580 592 581 593 proc sum (id, list #) 582 USAGE: sum(id[,v]); id=ideal/vector/module/matrix resp. id=intvec/intmat,594 "USAGE: sum(id[,v]); id=ideal/vector/module/matrix resp. id=intvec/intmat, 583 595 v=intvec (e.g. v=1..n, n=integer) 584 596 RETURN: poly resp. int which is the sum of all entries of id, with index … … 587 599 identified with corresponding matrix M (columns of M generate m) 588 600 EXAMPLE: example sum; shows an example 601 " 589 602 { 590 603 if( typeof(id)=="poly" or typeof(id)=="ideal" or typeof(id)=="vector" … … 625 638 626 639 proc which (command) 627 USAGE: which(command); command = string expression640 "USAGE: which(command); command = string expression 628 641 RETURN: Absolute pathname of command, if found in search path. 629 642 Empty string, otherwise. 630 643 NOTE: Based on the Unix command 'which'. 631 644 EXAMPLE: example which; shows an example 645 " 632 646 { 633 647 int rs;
Note: See TracChangeset
for help on using the changeset viewer.