Changeset 447527 in git for Singular/LIB/general.lib


Ignore:
Timestamp:
Sep 23, 1999, 2:13:39 PM (24 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
2a3b09c8eb70b6b10b666934a1255aeeebaa2637
Parents:
824241e0feb57039b89a14bd31a86a23e5a87032
Message:
* hannes: system(--ticks-per-second") does not return a string any longer
          (tst.lib)
	  general.lib::ringweights substituted by normal.lib::extraweight


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/general.lib

    r824241 r447527  
    1 // $Id: general.lib,v 1.19 1999-09-21 17:32:15 Singular Exp $
     1// $Id: general.lib,v 1.20 1999-09-23 12:13:38 Singular Exp $
    22//GMG, last modified 18.6.99
    33///////////////////////////////////////////////////////////////////////////////
    44
    5 version="$Id: general.lib,v 1.19 1999-09-21 17:32:15 Singular Exp $";
     5version="$Id: general.lib,v 1.20 1999-09-23 12:13:38 Singular Exp $";
    66info="
    77LIBRARY:  general.lib   PROCEDURES OF GENERAL TYPE
     
    687687}
    688688///////////////////////////////////////////////////////////////////////////////
    689 
    690 proc ringweights (r)
    691 "USAGE:   ringweights(r); r ring
    692 RETURN:  intvec of weights of ring variables. If, say, x(1),...,x(n) are the
    693          variables of the ring r, in this order, the resulting intvec is
    694          deg(x(1)),...,deg(x(n)) where deg denotes the weighted degree if
    695          the monomial ordering of r has only one block of type ws,Ws,wp or Wp.
    696 NOTE:    In all other cases, in particular if there is more than one block,
    697          the resulting intvec is 1,...,1
    698 EXAMPLE: example ringweights; shows an example
    699 "
    700 {
    701    int i; intvec v; setring r;
    702    for (i=1; i<=nvars(basering); i=i+1) { v[i] = deg(var(i)); }
    703    return(v);
    704 }
    705 example
    706 { "EXAMPLE:"; echo = 2;
    707    ring r1=32003,(x,y,z),wp(1,2,3);
    708    ring r2=32003,(x,y,z),Ws(1,2,3);
    709    ring r=0,(x,y,u,v),lp;
    710    intvec vr=ringweights(r1); vr;
    711    ringweights(r2);
    712    ringweights(r);
    713 }
     689proc ringweights (list # )
     690"USAGE:   ringweights (P); P=name of an existing ring (true name, not a string)
     691RETURN:  intvec, size=nvars(P), consisting of the weights of the variables of P
     692NOTE:    This is useful when enlarging P but keeping the weights of the old
     693         variables
     694EXAMPLE: example ringweights;  shows an example
     695"
     696{
     697   int ii,q,fi,fo,fia;
     698   intvec rw,nw;
     699   string os;
     700   def P = #[1];
     701   string osP = ordstr(P);
     702   fo  = 1;
     703//------------------------- find weights in ordstr(P) -------------------------
     704   fi  = find(osP,"(",fo);
     705   fia = find(osP,"a",fo)+find(osP,"w",fo)+find(osP,"W",fo);
     706   while ( fia )
     707   {
     708      os = osP[fi+1,find(osP,")",fi)-fi-1];
     709      if( find(os,",") )
     710      {
     711         execute "nw = "+os+";";
     712         if( size(nw) > ii )
     713         {
     714             rw = rw,nw[ii+1..size(nw)];
     715         }
     716         else  {  ii = ii - size(nw); }
     717
     718         if( find(osP[1,fi],"a",fo) ) { ii = size(nw); }
     719      }
     720      else
     721      {
     722         execute "q = "+os+";";
     723         if( q > ii )
     724         {
     725            nw = 0; nw[q-ii] = 0;
     726            nw = nw + 1;          //creates an intvec 1,...,1 of length q-ii
     727            rw = rw,nw;
     728         }
     729         else { ii = ii - q; }
     730      }
     731      fo  = fi+1;
     732      fi  = find(osP,"(",fo);
     733      fia = find(osP,"a",fo)+find(osP,"w",fo)+find(osP,"W",fo);
     734   }
     735//-------------- adjust weight vector to length = nvars(P)  -------------------
     736   if( fo > 1 )
     737   {                                            // case when weights were found
     738      rw = rw[2..size(rw)];
     739      if( size(rw) > nvars(P) )
     740      {
     741         rw = rw[1..nvars(P)];
     742      }
     743      if( size(rw) < nvars(P) )
     744      {
     745         nw=0; nw[nvars(P)-size(rw)]=0; nw=nw+1; rw=rw,nw;
     746      }
     747   }
     748   else
     749   {                                         // case when no weights were found
     750      rw[nvars(P)]= 0; rw=rw+1;
     751   }
     752   return(rw);
     753}
     754example
     755{"EXAMPLE:";  echo = 2;
     756  ring r0 = 0,(x,y,z),dp;
     757  ringweights(r0);
     758  ring r1 = 0,x(1..5),(ds(3),wp(2,3));
     759  ringweights(r1);
     760  ring r2 = 0,x(1..5),(a(1,2,3,0),dp);
     761  ringweights(r2);
     762  ring r3 = 0,x(1..10),(a(1..5),dp(5),a(10..13),Wp(5..9));
     763  ringweights(r3);
     764  // an example for enlarging the ring:
     765  intvec v = 6,2,3,4,5;
     766  ring R = 0,x(1..10),(a(ringweights(r1),v),dp);
     767  ordstr(R);
     768}
     769
    714770///////////////////////////////////////////////////////////////////////////////
    715771
Note: See TracChangeset for help on using the changeset viewer.