Changeset b5726c in git


Ignore:
Timestamp:
Jan 7, 2001, 2:50:32 AM (22 years ago)
Author:
Gert-Martin Greuel <greuel@…>
Branches:
(u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
Children:
4cb6b8049b916680b0af4440be038380e9c4ac37
Parents:
e143c4c97746c0b2a52b6ee135eb652962690f84
Message:
* GMG: Kosmetik; proc ringweights entfernt und in ring.lib eingefuegt


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/general.lib

    re143c4 rb5726c  
    22//anne, added deleteSublist and watchdog 12.12.2000
    33///////////////////////////////////////////////////////////////////////////////
    4 version="$Id: general.lib,v 1.34 2000-12-31 15:14:46 obachman Exp $";
     4version="$Id: general.lib,v 1.35 2001-01-07 01:50:32 greuel Exp $";
    55category="General purpose";
    66info="
     
    2020 primes(n,m);           intvec of primes p, n<=p<=m
    2121 product(../..[,v]);    multiply components of vector/ideal/...[indices v]
    22  ringweights(r);        intvec of weights of ring variables of ring r
    2322 sort(ideal/module);    sort generators according to monomial ordering
    2423 sum(vector/id/..[,v]); add components of vector/ideal/...[with indices v]
     
    271270EXAMPLE:  example factorial; shows an example
    272271"
    273 {   int l,p;
     272{   int str,l,p;
    274273//---------------------------- initialization -------------------------------
    275274   if ( size(#) == 0 )
    276    { 
     275   {  str = 1;
    277276      ring bin = 0,x,dp;
    278277      number r=1;
     
    284283      {
    285284         if ( p == char(basering) )
    286          {
    287            // do it clever !
    288            if (n < 1) {return (0);}
    289            if (! defined(sv_factorials))
    290            {
    291              ideal sv_factorials;
    292              sv_factorials[1] = 1;
    293              export(sv_factorials);
    294            }
    295            if (n > size(sv_factorials))
    296            {
    297              int i = size(sv_factorials);
    298              sv_factorials[n] = 0;
    299              number fi = number(sv_factorials[i]);
    300              for (i++;i<=n;i++)
    301              {
    302                fi = fi * i;
    303                sv_factorials[i] = fi;
    304              }
    305              return (fi);
    306            }
    307            else
    308            {
    309              return (number(sv_factorials[n]));
    310            }
     285         {  number r=1;
    311286         }
    312287         else
    313          { 
     288         {  str = 1;
    314289            ring bin = p,x,dp;
    315290            number r=1;
     
    317292      }
    318293      else
    319       { 
     294      {  str = 1;
    320295         ring bin = p,x,dp;
    321296         number r=1;
     
    327302      r=r*l;
    328303   }
    329    return(string(r));
     304   if ( str==1 ) { return(string(r)); }
     305   else { return(r); }
    330306}
    331307example
     
    336312   p;
    337313}
    338    
    339        
    340314///////////////////////////////////////////////////////////////////////////////
    341315
     
    787761}
    788762///////////////////////////////////////////////////////////////////////////////
    789 proc ringweights (list # )
    790 "USAGE:   ringweights(P); P=name of an existing ring (true name, not a string)
    791 RETURN:  intvec consisting of the weights of the variables of P, as they
    792          appear when typing P;.
    793 NOTE:    This is useful when enlarging P but keeping the weights of the old
    794          variables.
    795 EXAMPLE: example ringweights; shows an example
    796 "
    797 {
    798    int ii,q,fi,fo,fia;
    799    intvec rw,nw;
    800    string os;
    801    def P = #[1];
    802    string osP = ordstr(P);
    803    fo  = 1;
    804 //------------------------- find weights in ordstr(P) -------------------------
    805    fi  = find(osP,"(",fo);
    806    fia = find(osP,"a",fo)+find(osP,"w",fo)+find(osP,"W",fo);
    807    while ( fia )
    808    {
    809       os = osP[fi+1,find(osP,")",fi)-fi-1];
    810       if( find(os,",") )
    811       {
    812          execute("nw = "+os+";");
    813          if( size(nw) > ii )
    814          {
    815              rw = rw,nw[ii+1..size(nw)];
    816          }
    817          else  {  ii = ii - size(nw); }
    818 
    819          if( find(osP[1,fi],"a",fo) ) { ii = size(nw); }
    820       }
    821       else
    822       {
    823          execute("q = "+os+";");
    824          if( q > ii )
    825          {
    826             nw = 0; nw[q-ii] = 0;
    827             nw = nw + 1;          //creates an intvec 1,...,1 of length q-ii
    828             rw = rw,nw;
    829          }
    830          else { ii = ii - q; }
    831       }
    832       fo  = fi+1;
    833       fi  = find(osP,"(",fo);
    834       fia = find(osP,"a",fo)+find(osP,"w",fo)+find(osP,"W",fo);
    835    }
    836 //-------------- adjust weight vector to length = nvars(P)  -------------------
    837    if( fo > 1 )
    838    {                                            // case when weights were found
    839       rw = rw[2..size(rw)];
    840       if( size(rw) > nvars(P) )
    841       {
    842          rw = rw[1..nvars(P)];
    843       }
    844       if( size(rw) < nvars(P) )
    845       {
    846          nw=0; nw[nvars(P)-size(rw)]=0; nw=nw+1; rw=rw,nw;
    847       }
    848    }
    849    else
    850    {                                         // case when no weights were found
    851       rw[nvars(P)]= 0; rw=rw+1;
    852    }
    853    return(rw);
    854 }
    855 example
    856 {"EXAMPLE:";  echo = 2;
    857   ring r0 = 0,(x,y,z),dp;
    858   ringweights(r0);
    859   ring r1 = 0,x(1..5),(ds(3),wp(2,3));
    860   ringweights(r1);"";
    861   // an example for enlarging the ring, keeping the first weights:
    862   intvec v = ringweights(r1),6,2,3,4,5;
    863   ring R = 0,x(1..10),(a(v),dp);
    864   ordstr(R);
    865 }
    866 
    867 ///////////////////////////////////////////////////////////////////////////////
    868763
    869764proc sort (id, list #)
    870 "USAGE:   sort(id[v,o,n]); id=ideal/module/intvec/list(of intvec's or int's)
     765"USAGE:   sort(id[v,o,n]); id = ideal/module/intvec/list(of intvec's or int's)
    871766@*       sort may be called with 1, 2 or 3 arguments in the following way:
    872767@*       sort(id[v,n]); v=intvec of positive integers, n=integer,
     
    907802   intvec v;
    908803   if ( defined(basering) ) { def P = basering; }
    909    if ( size(#)==0 and (typeof(id)=="ideal" or typeof(id)=="module") )
     804   if ( size(#)==0 and (typeof(id)=="ideal" or typeof(id)=="module"
     805                        or typeof(id)=="matrix"))
    910806   {
    911807      id = simplify(id,2);
     
    917813      else  { v = size(id)..1; }
    918814   }
    919    if ( size(#)>=1 and (typeof(id)=="ideal" or typeof(id)=="module") )
     815   if ( size(#)>=1 and (typeof(id)=="ideal" or typeof(id)=="module"
     816                        or typeof(id)=="matrix") )
    920817   {
    921818      if ( typeof(#[1])=="string" )
Note: See TracChangeset for help on using the changeset viewer.