Changeset 4a0d86 in git


Ignore:
Timestamp:
Jul 29, 2004, 6:47:07 PM (19 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
f12d4f65e05f0c6728f1743580a54e40d44c0f21
Parents:
c78800c4f81d04521b30784cfce28ba3589d6539
Message:
*levandov: updated version from Granada plus several more changes by me


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/nctools.lib

    rc78800 r4a0d86  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: nctools.lib,v 1.5 2004-05-12 11:36:15 levandov Exp $";
     2version="$Id: nctools.lib,v 1.6 2004-07-29 16:47:07 levandov Exp $";
    33category="Noncommutative";
    44info="
     
    3838
    3939proc Gweights(def r)
    40 "USAGE:   Gweights(r); r a ring
    41 RETURN:  a weights vector for the G-Algebra r
    42 NOTE:    with Gweights you only obtain a vector, then you must use it to redefine the G-Algebra. Another posibility is to use wRing or weightedRing to obtain directly the G-Algebra.
     40"USAGE:   Gweights(r); r a ring or a square matrix
     41RETURN:  a weights vector for the G-algebra r or for a G-algebra which tails matrix is r
     42NOTE:    with Gweights you only obtain a vector, then you must use it to redefine the G-Algebra. If the input is a matrix and the output is the zero vector then there is not a G-algebra structure associated to these relations with respect to the given variables. Another possibility is to use wRing or weightedRing to obtain directly the G-Algebra.
    4343EXAMPLE: example Gweights; shows examples
    4444SEE ALSO: wRing, weightedRing
    4545"{
    46   if (typeof(r)=="ring")
     46  matrix tails;
     47  int novalid=0;
     48  if (typeof(r)=="ring") //a ring is admissible as input
    4749  {
    4850    setring r;
    49     def l=NCRelations(r);
    50     intmat IM=SimplMat(l[2]); // l=C,D we need D
    51     if (size(IM)>1)
    52     {
    53       int n=nvars(basering);
    54       int m=nrows(IM)-1;
    55       int m1=0;
    56       int m2=m;
    57       int m3=0;
     51    def l = NCRelations(r);
     52    tails = l[2]; // l=C,D we need D, the tails of the relations
     53  }
     54  else
     55  {
     56    if ( (typeof(r)=="matrix") || (typeof(r)=="intmat") )
     57    {
     58      if ( nrows(r)==ncols(r) ) //the input is a square matrix
     59      {
     60        tails = matrix(r);
     61      }
     62      else
     63      {
     64        novalid = 1;
     65      }
     66    }
     67    else
     68    {
     69      novalid=1;
     70    }
     71  }
     72  if (novalid==0)
     73  {
     74    intmat IM = SimplMat(tails);
     75    if ( size(IM)>1 )
     76    {
     77      int n  = ncols(tails);
     78      int m  = nrows(IM)-1;
     79      int m1 = 0;
     80      int m2 = m;
     81      int m3 = 0;
    5882      ring simplexring=(real,10),(x),lp;// The simplex procedure requires a basering of this type
    59       matrix M=IM;
    60       list sol=simplex (M,m,n,m1,m2,m3);
     83      matrix M = IM;
     84      list sol = simplex (M,m,n,m1,m2,m3);
    6185      return(weightvector(sol));
    62     } 
    63     else 
    64     {
    65       "Invalid input.";
     86    }
     87    else
     88    {
     89      "Invalid input"; //usually because the input is a one variable ring
    6690      return();
    6791    }
    68   } 
    69   else 
    70   {
    71     "The input must be a ring.";
     92  }
     93  else
     94  {
     95    "The input must be a ring or a square matrix";
    7296    return();
    7397  }
     
    92116  setring r; r;
    93117  Gweights(r);
     118  Gweights(D);
     119  Gweights(C);
    94120}
    95121
     
    121147      m[i,n+2-i]=1;
    122148    }
    123     // End of generating.
     149    // End of generation.
    124150    def lr=NCRelations(r);
    125151    string newringstring="ring newring=("+charstr(r)+"),("+varstr(r)+"),M("+string(m)+")";
     
    128154    ncalgebra(lnewring[1],lnewring[2]);
    129155    return(newring);
    130   } 
    131   else 
    132   {
    133     "Invalid input.";
     156  }
     157  else
     158  {
     159    "Invalid input.";//usually because the input is a one variable ring
    134160    return();
    135161  }
     
    166192  "Error";
    167193  return();
    168 } 
    169 example 
     194}
     195example
    170196{
    171197  "EXAMPLE:";echo=2;
     
    202228    N=N[2..size(N)]; // Deleting the zero added in the definition of N
    203229    M=intmat(N,size(N)/nc,nc); // Conversion from vector to matrix
    204   } 
    205   else 
     230  }
     231  else
    206232  {
    207233    intmat M[1][1]=0;
     
    216242static proc Ct(matrix P)
    217243{
    218   int k=ncols(P);
    219   int n=nvars(basering);
    220   intvec T=0;
    221   int i,j;
     244  int    k = ncols(P);
     245  intvec T = 0;
     246  int    i,j;
     247//  int notails=1;
     248  def S;
    222249  for (j=2; j<=k; j++)
    223250  {
    224251    for (i=1; i<j; i++)
    225252    {
    226       if (deg(P[i,j])>0)
     253      if ( P[i,j] != 0 )
    227254      {
    228         def S=Newton(P[i,j]);
    229         S=Cij(S,i,j);
    230         if (size(S)>1) {T=T,S;}
     255//        notails=0;
     256        S = Newton(P[i,j]);
     257        S = Cij(S,i,j);
     258        if ( size(S)>1 )
     259        {
     260          T = T,S;
     261        }
    231262      }
    232263    }
    233264  }
    234   if (size(T)==1)
    235   { 
    236     intmat C[1][1];
    237   }
    238   else 
     265  if ( size(T)==1 )
     266  {
     267    intmat C[1][1] = 0;
     268  }
     269  else
    239270  {
    240271    T=T[2..size(T)]; // Deleting the zero added in the definition of T
    241     intmat C=intmat(T,size(T)/n,n); // Conversion from vector to matrix
     272    intmat C = intmat(T,size(T)/k,k); // Conversion from vector to matrix
    242273  }
    243274  return (C);
     
    251282{
    252283  intmat C=Ct(P);
    253   if (size(C)>1)
    254   {
    255     int r=nrows(C);
    256     int n=nvars(basering);
    257     int f=1+n+r;
     284  if (size(C)>1)
     285  {
     286    int r = nrows(C);
     287    int n = ncols(C);
     288    int f = 1+n+r;
     289    intmat M[f][n+1]=0;
     290    int i;
     291    for (i=2; i<=(n+1); i++)
     292    {
     293      M[1,i]=-1; // (0,-1,-1,-1,...) objective function in the first row
     294    }
     295    for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1
     296    for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix
     297    M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ...
     298  }
     299  else
     300  {
     301    int n = ncols(P);
     302    int f = 1+n;
    258303    intmat M[f][n+1]=0;
    259304    int i;
     
    261306    for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1
    262307    for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix
    263     M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ...
    264   }
    265   else
    266   {
    267     intmat M=C;
    268308  }
    269309  return (M);
     
    276316
    277317static proc weightvector(list l)
     318
    278319"ASSUME:  l is the output of simplex.
    279320RETURNS: if there is a solution, an intvec with the solution."
     
    286327  intmat wv[1][N]=0;
    287328  int i;
    288   if (sol) 
     329  if (sol)
    289330  {
    290331    "no solution satisfies the given constraints";
    291332  }
    292   else 
    293   {
    294     for ( i = 2; i <= rows; i++ ) 
    295     {
    296       if ( nv[i-1] <= N ) 
     333  else
     334  {
     335    for ( i = 2; i <= rows; i++ )
     336    {
     337      if ( nv[i-1] <= N )
    297338      {
    298339        wv[1,nv[i-1]]=int(m[i,1]);
     
    316357  int n=nvars(basering);
    317358  intvec N=0;
    318   if (deg(f)>0)
    319   {
    320     while (leadexp(f)!=0)
    321     {
    322       N=N, leadexp(f);
    323       f=f-lead(f);
    324     }
    325   } 
    326   else 
    327   { 
    328     N=N, leadexp(f); 
    329   }
    330   N=N[2..size(N)]; // Deletes the zero added in the definition of T
     359  if ( f != 0 )
     360  {
     361    while ( f != 0 )
     362    {
     363      N = N, leadexp(f);
     364      f = f-lead(f);
     365    }
     366  }
     367  else
     368  {
     369    N=N, leadexp(f);
     370  }
     371  N = N[2..size(N)]; // Deletes the zero added in the definition of T
    331372  intmat M=intmat(N,(size(N)/n),n); // Conversion from vector to matrix
    332373  return (M);
     
    373414              C[j,i]=leadcoef(f);
    374415              D[j,i]=D[j,i]+f-lead(f);
    375             } 
    376             else 
     416            }
     417            else
    377418            {
    378419              D[j,i]=D[j,i]+lead(f);
     
    384425      l=C,D;
    385426    }
    386     else { "The ring must have two or more variables"; } 
     427    else { "The ring must have two or more variables"; }
    387428  }
    388429  else { "The input must be of a type ring";}
     
    417458  {
    418459    if ( typeof(#[1])!="ring" ) { return();}
    419     else 
     460    else
    420461    {
    421462      def @R1 = #[1];
     
    433474  {
    434475    for (j=i; j<=n; j++)
    435     { 
     476    {
    436477      p=var(i)*var(j)-M[i,j];
    437478      if ( (size(I)==1) && (I[1]==0) )   { I=p; }
     
    463504  S[2,3]=a*x(1); S[3,2]=-b*x(1);
    464505  Fin_dim_algebra(S);
    465   Quot = system("twostd",Quot);
     506  Quot = twostd(Quot);
    466507  qring Qr = Quot;
    467508  Qr;
     
    475516EXAMPLE: example IsCentral; shows examples
    476517"{
    477   int N=nvars(basering);
     518  int N = nvars(basering);
    478519  int in;
    479   int flag=1;
    480   poly q=0;
     520  int flag = 1;
     521  poly   q = 0;
    481522  for (in=1; in<=N; in++)
    482523  {
    483     q=p*var(in)-var(in)*p;
     524    q = p*var(in)-var(in)*p;
    484525    if (q!=0)
    485526    {
     
    502543  D[2,3]=-2*y;
    503544  ncalgebra(1,D); // this is U(sl_2)
    504   poly c=4*x*y+z^2-2*z;
    505   IsCentral(c,1);
    506 }
    507 
    508 ///////////////////////////////////////////////////////////////////////////////
    509 
    510 proc UpOneMatrix (int N)
     545  poly c = 4*x*y+z^2-2*z;
     546  IsCentral(c,0);
     547  poly h = x*c;
     548  IsCentral(h,1);
     549}
     550
     551///////////////////////////////////////////////////////////////////////////////
     552
     553proc UpOneMatrix(int N)
    511554"USAGE:   UpOneMatrix(N); N an integer, the number of columns
    512555RETURN:  intmat, NxN matrix with 1's in the whole upper triagle
     
    537580///////////////////////////////////////////////////////////////////////////////
    538581
    539 proc ndc (list #)
     582proc ndc(list #)
    540583"USAGE:   ndc([v]); v an optional integer. If v!=0 procedure will be verbose
    541584RETURN:  ideal of non-degeneracy conditions
     
    544587// if the second argument is given, produces ndc wrt powers x^N
    545588{
    546   int N=1;
    547   int Verbose=0;
     589  int N = 1;
     590  int Verbose = 0;
    548591  if ( size(#)>=1 ) { Verbose = int(#[1]); }
    549592  if ( size(#)>=2 ) { N = int(#[2]); }
    550   int cnt=1;
    551   int numvars=nvars(basering);
     593  int cnt = 1;
     594  int numvars = nvars(basering);
    552595  int a,b,c;
    553   poly p=1;
    554   ideal res=0;
    555   for (cnt=1;cnt<=N;cnt++)
     596  poly p = 1;
     597  ideal res = 0;
     598  for (cnt=1; cnt<=N; cnt++)
    556599  {
    557600    if (Verbose) { "Processing degree :",cnt;}
     
    562605        for(c=b+1; c<=numvars; c++)
    563606        {
    564           p=(var(c)^cnt)*(var(b)^cnt);
    565           p=p*(var(a)^cnt);
    566           p=p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt));
     607          p = (var(c)^cnt)*(var(b)^cnt);
     608          p = p*(var(a)^cnt);
     609          p = p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt));
    567610          if (Verbose) {a,".",b,".",c,".";}
    568           if (p!=0) 
     611          if (p!=0)
    569612          {
    570613            if ( res==0 )
    571614            {
    572               res[1]=p;
     615              res[1] = p;
    573616            }
    574617            else
    575618            {
    576               res=res,p;
     619              res = res,p;
    577620            }
    578621            if (Verbose) { "failed:",p; }
     
    615658  }
    616659  if (n<1) { return(0); }
    617   number mp = par(1); 
     660  number mp = par(1);
    618661  if (n==1) { return(mp-1); }
    619662  if (n==2) { return(mp+1); }
     
    623666  int j=1;
    624667  while ( (CH[j] !=",") && (j<=size(CH)))
    625   { 
     668  {
    626669    MCH=MCH+CH[j]; j++;
    627670  }
     
    644687    if ( deg(@l[j]) == d) { @d[cnt]=@l[j]; cnt++; }
    645688  }
    646   if ( size(@d)==1 ) 
    647   { 
    648     res = poly(@d[1]); 
     689  if ( size(@d)==1 )
     690  {
     691    res = poly(@d[1]);
    649692  }
    650693  else
     
    652695    j=1;
    653696    while  ( j <= size(@d) )
    654     { 
     697    {
    655698      res = @d[j]-lead(@d[j]);
    656699      if ( leadcoef(res) >=0 ) { j++; }
     
    777820{
    778821  "EXAMPLE:";echo=2;
    779   def a=Heisenberg(2);
     822  def a = Heisenberg(2);
    780823  setring a;
    781824  a;
     
    809852    Q[i] = var(i)^2;
    810853  }
    811   Q = system("twostd",Q);
     854  Q = twostd(Q);
    812855  qring @EA = Q;
    813856  return(@EA);
     
    846889    }
    847890  }
    848   ring @rr=@p,(x(1..n),D(1..n)),dp;
     891  if (n ==1)
     892  {
     893    ring @rr = @p,(x,D),dp;
     894  }
     895  else
     896  {
     897    ring @rr = @p,(x(1..n),D(1..n)),dp;
     898  }
     899  setring @rr;
    849900  Weyl();
    850901  return(@rr);
Note: See TracChangeset for help on using the changeset viewer.