Changeset 39a4a17 in git for Singular/LIB/freegb.lib


Ignore:
Timestamp:
Jun 24, 2007, 9:13:20 PM (17 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
fc4d399ad22f1d122a780e118a353cd26e5313e4
Parents:
502966ccc93312cccaa355b8008b73f25689ad2a
Message:
*levandov: new function crs and examples


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/freegb.lib

    r502966 r39a4a17  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: freegb.lib,v 1.2 2007-06-20 15:39:45 Singular Exp $";
     2version="$Id: freegb.lib,v 1.3 2007-06-24 19:13:20 levandov Exp $";
    33category="Noncommutative";
    44info="
     
    551551}
    552552
     553proc crs(list LM, int d)
     554"USAGE:  crs(L, d);  L a list of modules, d an integer
     555RETURN:  ring
     556PURPOSE: create a ring and shift the ideal
     557EXAMPLE: example crs; shows examples
     558"
     559{
     560  // d = up to degree, will be shifted to d+1
     561  if (d<1) {"bad d"; return(0);}
     562
     563  int ppl = printlevel-voice+2;
     564  string err = "";
     565
     566  int i,j,s;
     567  def save = basering;
     568  // determine max no of places in the input
     569  int slm = size(LM); // numbers of polys in the ideal
     570  int sm;
     571  intvec iv;
     572  module M;
     573  for (i=1; i<=slm; i++)
     574  {
     575    // modules, e.g. free polynomials
     576    M  = LM[i];
     577    sm = ncols(M);
     578    for (j=1; j<=sm; j++)
     579    {
     580      //vectors, e.g. free monomials
     581      iv = iv, size(M[j])-1; // 1 place is reserved by the coeff
     582    }
     583  }
     584  int D = Max(iv); // max size of input words
     585  if (d<D) {"bad d"; return(LM);}
     586  D = D + d-1;
     587  //  D = d;
     588  list LR  = ringlist(save);
     589  list L, tmp;
     590  L[1] = LR[1]; // ground field
     591  L[4] = LR[4]; // quotient ideal
     592  tmp  = LR[2]; // varnames
     593  s = size(LR[2]);
     594  for (i=1; i<=D; i++)
     595  {
     596    for (j=1; j<=s; j++)
     597    {
     598      tmp[i*s+j] = string(tmp[j])+"("+string(i)+")";
     599    }
     600  }
     601  for (i=1; i<=s; i++)
     602  {
     603    tmp[i] = string(tmp[i])+"("+string(0)+")";
     604  }
     605  L[2] = tmp;
     606  list OrigNames = LR[2];
     607  // ordering: d blocks of the ord on r
     608  // try to get whether the ord on r is blockord itself
     609  s = size(LR[3]);
     610  if (s==2)
     611  {
     612    // not a blockord, 1 block + module ord
     613    tmp = LR[3][s]; // module ord
     614    for (i=1; i<=D; i++)
     615    {
     616      LR[3][s-1+i] = LR[3][1];
     617    }
     618    LR[3][s+D] = tmp;
     619  }
     620  if (s>2)
     621  {
     622    // there are s-1 blocks
     623    int nb = s-1;
     624    tmp = LR[3][s]; // module ord
     625    for (i=1; i<=D; i++)
     626    {
     627      for (j=1; j<=nb; j++)
     628      {
     629        LR[3][i*nb+j] = LR[3][j];
     630      }
     631    }
     632    //    size(LR[3]);
     633    LR[3][nb*(D+1)+1] = tmp;
     634  }
     635  L[3] = LR[3];
     636  def @R = ring(L);
     637  setring @R;
     638  ideal I;
     639  poly @p;
     640  s = size(OrigNames);
     641  //  "s:";s;
     642  // convert LM to canonical vectors (no powers)
     643  setring save;
     644  kill M; // M was defined earlier
     645  module M;
     646  slm = size(LM); // numbers of polys in the ideal
     647  int sv,k,l;
     648  vector v;
     649  //  poly p;
     650  string sp;
     651  setring @R;
     652  poly @@p=0;
     653  setring save;
     654  for (l=1; l<=slm; l++)
     655  {
     656    // modules, e.g. free polynomials
     657    M  = LM[l];
     658    sm = ncols(M); // in intvec iv the sizes are stored
     659    for (i=0; i<=d-iv[l]; i++)
     660    {
     661      // modules, e.g. free polynomials
     662      for (j=1; j<=sm; j++)
     663      {
     664        //vectors, e.g. free monomials
     665        v  = M[j];
     666        sv = size(v);
     667        //      "sv:";sv;
     668        sp = "@@p = @@p + ";
     669        for (k=2; k<=sv; k++)
     670        {
     671          sp = sp + string(v[k])+"("+string(k-2+i)+")*";
     672        }
     673        sp = sp + string(v[1])+";"; // coef;
     674        setring @R;
     675        execute(sp);
     676        setring save;
     677      }
     678      setring @R;
     679      //      "@@p:"; @@p;
     680      I = I,@@p;
     681      @@p = 0;
     682      setring save;
     683    }
     684  }
     685  setring @R;
     686  export I;
     687  return(@R);
     688}
     689example
     690{
     691  "EXAMPLE:"; echo = 2;
     692  ring r = 0,(x,y,z),(dp(1),dp(2));
     693  module M = [-1,x,y],[-7,y,y],[3,x,x];
     694  module N = [1,x,y,x],[-1,y,x,y];
     695  list L; L[1] = M; L[2] = N;
     696  lst2str(L);
     697  def U = crs(L,5);
     698  setring U; U;
     699  I;
     700}
     701
     702proc ex_shift()
     703{
     704  LIB "freegb.lib";
     705  ring r = 0,(x,y,z),(dp(1),dp(2));
     706  module M = [-1,x,y],[-7,y,y],[3,x,x];
     707  module N = [1,x,y,x],[-1,y,x,y];
     708  list L; L[1] = M; L[2] = N;
     709  lst2str(L);
     710  def U = crs(L,5);
     711  setring U; U;
     712  I;
     713  poly p = I[2]; // I[8];
     714  p;
     715  system("stest",p,7,7,3); // error
     716  poly q1 = system("stest",p,1,7,3); //ok
     717  poly q6 = system("stest",p,6,7,3); //ok
     718  system("btest",p,3);
     719  system("btest",q1,3);
     720  system("btest",q6,3);
     721}
     722
    553723proc ex2()
    554724{
Note: See TracChangeset for help on using the changeset viewer.