Changeset 63be42 in git for Singular/LIB/general.lib


Ignore:
Timestamp:
Sep 30, 1998, 7:25:36 PM (24 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
29aa4bf9f686919f5d281a96fdcd0e9e1008dbc8
Parents:
d3e295ae509633cf6ba993a8680945f24b9ab5ec
Message:
*greuel: updated general.lib, matrix.lib


git-svn-id: file:///usr/local/Singular/svn/trunk@2532 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/general.lib

    rd3e295a r63be42  
    1 // $Id: general.lib,v 1.8 1998-05-14 18:45:03 Singular Exp $
     1// $Id: general.lib,v 1.9 1998-09-30 17:24:31 Singular Exp $
    22//system("random",787422842);
    3 //(GMG, last modified 22.06.96)
    4 ///////////////////////////////////////////////////////////////////////////////
    5 
    6 version="$Id: general.lib,v 1.8 1998-05-14 18:45:03 Singular Exp $";
     3//GMG, last modified 30.9.98
     4///////////////////////////////////////////////////////////////////////////////
     5
     6version="$Id: general.lib,v 1.9 1998-09-30 17:24:31 Singular Exp $";
    77info="
    88LIBRARY:  general.lib   PROCEDURES OF GENERAL TYPE
    99
    1010 A_Z(\"a\",n);            string a,b,... of n comma seperated letters
     11 ASCII([n,m]);          string of printable ASCII characters (number n to m)
    1112 binomial(n,m[,../..]); n choose m (type int), [type string/type number]
    1213 factorial(n[,../..]);  n factorial (=n!) (type int), [type string/number]
     
    2122 sort(ideal/module);    sort generators according to monomial ordering
    2223 sum(vector/id/..[,v]); add components of vector/ideal/...[with indices v]
    23  which(command);        searches for command and returns absolute
    24                         path, if found
     24 which(command);        search for command and return absolute path, if found
    2525           (parameters in square brackets [] are optional)
    2626";
     
    8282   execute sR;
    8383   R;
     84}
     85///////////////////////////////////////////////////////////////////////////////
     86proc ASCII (list #)
     87"USAGE:   ASCII([n,m]); n,m= integers (32 <= n <= m <= 126)
     88RETURN:   printable ASCII characters (no native language support)
     89          ASCII():    string of  all ASCII characters with its numbers,
     90                      no return value
     91          ASCII(n):   string, n-th ASCII charakter
     92          ASCII(n,m): list, n-th up to m-th ASCII character (inclusive)
     93EXAMPLE: example ASCII; shows an example
     94"
     95{
     96  string s1 =
     97 "     !    \"    #    $    %    &    '    (    )    *    +    ,    -    .
     9832   33   34   35   36   37   38   39   40   41   42   43   44   45   46
     99
     100/    0    1    2    3    4    5    6    7    8    9    :    ;    <    =
     10147   48   49   50   51   52   53   54   55   56   57   58   59   60   61
     102
     103>    ?    @    A    B    C    D    E    F    G    H    I    J    K    L
     10462   63   64   65   66   67   68   69   70   71   72   73   74   75   76
     105
     106M    N    O    P    Q    R    S    T    U    V    W    X    Y    Z    [
     10777   78   79   80   81   82   83   84   85   86   87   88   89   90   91
     108
     109\\    ]    ^    _    `    a    b    c    d    e    f    g    h    i    j
     11092   93   94   95   96   97   98   99  100  101  102  103  104  105  10
     111
     112k    l    m    n    o    p    q    r    s    t    u    v    w    x    y
     113107  108  109  110  111  112  113  114  115  116  117  118  119  120  121
     114
     115z    {    |    }    ~
     116122  123  124  125  126 ";
     117
     118   string s2 =
     119 " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
     120
     121   if ( size(#) == 0 )
     122   {
     123      return(s1);
     124   }
     125   if ( size(#) == 1 )
     126   {
     127      return( s2[#[1]-31] );
     128   }
     129   if ( size(#) == 2 )
     130   {
     131      return( s2[#[1]-31,#[2]-#[1]+1] );
     132   }
     133}
     134example
     135{ "EXAMPLE:"; echo = 2;
     136   ASCII();"";
     137   ASCII(42);
     138   ASCII(32,126);
    84139}
    85140///////////////////////////////////////////////////////////////////////////////
     
    262317proc number_e (int n)
    263318"USAGE:   number_e(n);  n integer
    264 COMPUTE: exp(1) up to n decimal digits (no rounding)
     319COMPUTE: Euler number e=exp(1) up to n decimal digits (no rounding)
    265320         by A.H.J. Sale's algorithm
    266321RETURN:  - string of exp(1) if no basering of char 0 is defined;
     
    469524"USAGE:   sort(id[v,o,n]); id=ideal/module/intvec/list (of intvec's or int's)
    470525         sort may be called with 1, 2 or 3 arguments in the following way:
    471          -  sort(id[v,n]); v=intvec, n=integer,
     526         -  sort(id[v,n]); v=intvec of positive integers, n=integer,
    472527         -  sort(id[o,n]); o=string (any allowed ordstr of a ring), n=integer
    473528RETURN:  a list of two elements:
     
    488543             (e.g. sort(id); sorts lexicographically, smaller int's come first)
    489544             WARNING: Since negative exponents create the 0 plynomial in
    490              Singular, id should not contain negative integers: the result might
    491              not be as exspected
     545             Singular, id should not contain negative integers: the result
     546             might not be as exspected
    492547           - if id=intvec: id is treated as list of integers
    493548           - if n!=0 the ordering is inverse, i.e. w.r.t. v(size(v)..1)
    494549             default: n=0
    495550         [2]: intvec, describing the permutation of the input (hence [2]=v if
    496              v is given)
    497 NOTE:    If v is given, id may be any simply indexed object (e.g. any list);
     551             v is given (with positive intergers)
     552NOTE:    If v is given id may be any simply indexed object (e.g. any list or
     553         string); if v[i]<0 and i<=size(id) v[i] is set internally to i;
    498554         entries of v must be pairwise distinct to get a permutation if id.
    499555         Zero generators of ideal/module are deleted
     
    513569      if ( ii != size(id) ) { v = sortvec(id); }
    514570      else  { v = size(id)..1; }
    515       if ( v == 0 ) { v = 1; }
    516571   }
    517572   if ( size(#)>=1 and (typeof(id)=="ideal" or typeof(id)=="module") )
     
    567622   }
    568623   s = size(v);
     624   if( size(id) < s ) { s = size(id); }
    569625   def m = id;
    570    for ( jj=1; jj<=s; jj=jj+1) { m[jj] = id[v[jj]]; }
     626   if ( size(m) != 0 )
     627   {
     628      for ( jj=1; jj<=s; jj=jj+1)
     629      {
     630         if ( v[jj]<=0 ) { v[jj]=jj; }
     631         m[jj] = id[v[jj]];
     632      }
     633   }
     634   if ( v == 0 ) { v = 1; }
    571635   list L=m,v;
    572636   return(L);
Note: See TracChangeset for help on using the changeset viewer.