Changeset 7f3ad4 in git


Ignore:
Timestamp:
Jan 14, 2009, 5:07:05 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
0721816437af5ddabc83aa203a12d9b58b42a33c
Parents:
95edd5641377e851d4a1d4e986853687991d0895
Message:
*hannes: format


git-svn-id: file:///usr/local/Singular/svn/trunk@11306 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular/LIB
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/bfct.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: bfct.lib,v 1.10 2009-01-12 19:31:23 Singular Exp $";
     2version="$Id: bfct.lib,v 1.11 2009-01-14 16:07:03 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    3535AUXILIARY PROCEDURES:
    3636
    37 allPositive(v);  checks whether all entries of an intvec are positive 
     37allPositive(v);  checks whether all entries of an intvec are positive
    3838scalarProd(v,w); computes the standard scalar product of two intvecs
    3939vec2poly(v[,i]); constructs an univariate poly with given coefficients
     
    7979EXAMPLE: example gradedWeyl; shows examples
    8080NOTE:    u[i] is the weight of x(i), v[i] the weight of D(i).
    81 @*       u+v has to be a non-negative intvec. 
     81@*       u+v has to be a non-negative intvec.
    8282"
    8383{
     
    8888  {
    8989    ERROR("weight vectors have wrong dimension");
    90   } 
     90  }
    9191  intvec uv,gr;
    9292  uv = u+v;
     
    9797      if (uv[i]==0)
    9898      {
    99         gr[i] = 0;
     99        gr[i] = 0;
    100100      }
    101101      else
    102102      {
    103         gr[i] = 1;
     103        gr[i] = 1;
    104104      }
    105105    }
     
    114114  for (i=1; i<=n; i++)
    115115  {
    116     if (gr[i] == 1) 
     116    if (gr[i] == 1)
    117117    {
    118118       l2[n+i] = "xi("+string(i)+")";
     
    231231RETURN:  ideal/list, linear reductum (over field) of f by elements from I
    232232PURPOSE: reduce a poly only by linear reductions (no monomial multiplications)
    233 NOTE:    If s<>0, a list consisting of the reduced ideal and the coefficient 
     233NOTE:    If s<>0, a list consisting of the reduced ideal and the coefficient
    234234@*       vectors of the used reductions given as module is returned.
    235235@*       Otherwise (and by default), only the reduced ideal is returned.
     
    255255      if (typeof(#[2])=="int" || typeof(#[2])=="number")
    256256      {
    257         redtail = #[2];
     257        redtail = #[2];
    258258      }
    259259    }
     
    273273      for (i=1; i<=sI; i++)
    274274      {
    275         if (I[i] == 0)
    276         {
    277           j++;
    278           J[j] = 0;
    279           ordJ[j] = -1;
    280           M[j] = gen(i);
    281         }
    282         else
    283         {
    284           M[i+sZeros-j] = gen(lJ[2][i-j]+j);
    285         }
     275        if (I[i] == 0)
     276        {
     277          j++;
     278          J[j] = 0;
     279          ordJ[j] = -1;
     280          M[j] = gen(i);
     281        }
     282        else
     283        {
     284          M[i+sZeros-j] = gen(lJ[2][i-j]+j);
     285        }
    286286      }
    287287    }
     
    290290      for (i=1; i<=sZeros; i++)
    291291      {
    292         J[i] = 0;
    293         ordJ[i] = -1;
     292        J[i] = 0;
     293        ordJ[i] = -1;
    294294      }
    295295    }
     
    327327      for (j=sZeros+1; j<i; j++)
    328328      {
    329         if (lm == 0) { break; }
    330         if (ordlm > maxordJ) { break; }
    331         if (ordlm == ordJ[j])
    332         {           
    333           if (lm > maxlmJ) { break; }
    334           if (lm == lmJ[j])
    335           {
    336             dbprint(ppl,"reducing " + string(redpoly));
    337             dbprint(ppl," with " + string(J[j]));
    338             c = leadcoef(redpoly)/leadcoef(J[j]);
    339             redpoly = redpoly - c*J[j];
    340             dbprint(ppl," to " + string(redpoly));
    341             lm = leadmonom(redpoly);
    342             ordlm = ord(lm);
    343             if (remembercoeffs <> 0) { M[i] = M[i] - c * M[j]; }
    344             reduction = 1;
    345           }
    346         }
     329        if (lm == 0) { break; }
     330        if (ordlm > maxordJ) { break; }
     331        if (ordlm == ordJ[j])
     332        {
     333          if (lm > maxlmJ) { break; }
     334          if (lm == lmJ[j])
     335          {
     336            dbprint(ppl,"reducing " + string(redpoly));
     337            dbprint(ppl," with " + string(J[j]));
     338            c = leadcoef(redpoly)/leadcoef(J[j]);
     339            redpoly = redpoly - c*J[j];
     340            dbprint(ppl," to " + string(redpoly));
     341            lm = leadmonom(redpoly);
     342            ordlm = ord(lm);
     343            if (remembercoeffs <> 0) { M[i] = M[i] - c * M[j]; }
     344            reduction = 1;
     345          }
     346        }
    347347      }
    348348    }
     
    354354    lmJ = insertGenerator(lmJ,lm,j);
    355355    ordJ = insertGenerator(ordJ,poly(ordlm),j);
    356     if (remembercoeffs <> 0) 
     356    if (remembercoeffs <> 0)
    357357    {
    358358      v = M[i];
     
    373373      for (j=i+1; j<=sI; j++)
    374374      {
    375         for (k=2; k<=size(J[j]); k++) // run over all terms in J[j]
    376         {
    377           if (ordJ[i] == ord(J[j][k]))
    378           {   
    379             if (lm == normalize(J[j][k]))
    380             {
    381               c = leadcoef(J[j][k])/leadcoef(J[i]);
    382               dbprint(ppl,"reducing " + string(J[j]));
    383               dbprint(ppl," with " + string(J[i]));
    384               J[j] = J[j] - c*J[i];
    385               dbprint(ppl," to " + string(J[j]));
    386               if (remembercoeffs <> 0) { M[j] = M[j] - c * M[i]; }
    387             }
    388           }
    389         }
     375        for (k=2; k<=size(J[j]); k++) // run over all terms in J[j]
     376        {
     377          if (ordJ[i] == ord(J[j][k]))
     378          {
     379            if (lm == normalize(J[j][k]))
     380            {
     381              c = leadcoef(J[j][k])/leadcoef(J[i]);
     382              dbprint(ppl,"reducing " + string(J[j]));
     383              dbprint(ppl," with " + string(J[i]));
     384              J[j] = J[j] - c*J[i];
     385              dbprint(ppl," to " + string(J[j]));
     386              if (remembercoeffs <> 0) { M[j] = M[j] - c * M[i]; }
     387            }
     388          }
     389        }
    390390      }
    391391    }
     
    410410RETURN:  poly/list, linear reductum (over field) of f by elements from I
    411411PURPOSE: reduce a poly only by linear reductions (no monomial multiplications)
    412 NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient 
     412NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient
    413413@*       vector of the used reductions is returned, otherwise (and by default)
    414414@*       only reduced poly is returned.
     
    433433      if (typeof(#[2])=="int" || typeof(#[2])=="number")
    434434      {
    435         redtail = #[2];
     435        redtail = #[2];
    436436      }
    437437      if (size(#)>2)
    438438      {
    439         if (typeof(#[3])=="int" || typeof(#[3])=="number")
     439        if (typeof(#[3])=="int" || typeof(#[3])=="number")
    440440        {
    441           prepareideal = #[3];
    442         }
     441          prepareideal = #[3];
     442        }
    443443      }
    444444    }
     
    469469      for (i=1; i<=sI; i++)
    470470      {
    471         M[i] = gen(i);
     471        M[i] = gen(i);
    472472      }
    473473    }
     
    495495      if (ordf == ordI[i])
    496496      {
    497         if (lm == lmI[i])
    498         {
    499           c = leadcoef(f)/lcI[i];
    500           f = f - c*I[i];
    501           lm = leadmonom(f);
    502           ordf = ord(lm);
    503           if (remembercoeffs <> 0)
    504           {
    505             v = v - c * M[i];
    506           }
    507         }
     497        if (lm == lmI[i])
     498        {
     499          c = leadcoef(f)/lcI[i];
     500          f = f - c*I[i];
     501          lm = leadmonom(f);
     502          ordf = ord(lm);
     503          if (remembercoeffs <> 0)
     504          {
     505            v = v - c * M[i];
     506          }
     507        }
    508508      }
    509509    }
     
    518518      for (j=1; j<=size(f); j++)
    519519      {
    520         if (ord(f[j]) == ordI[i])
    521         {
    522           if (normalize(f[j]) == lmI[i])
    523           {
    524             c = leadcoef(f[j])/lcI[i];
    525             f = f - c*I[i];
    526             dbprint(ppl,"reducing poly to ",f);
    527             if (remembercoeffs <> 0)
    528             {
    529               v = v - c * M[i];
    530             }
    531           }
    532         }
     520        if (ord(f[j]) == ordI[i])
     521        {
     522          if (normalize(f[j]) == lmI[i])
     523          {
     524            c = leadcoef(f[j])/lcI[i];
     525            f = f - c*I[i];
     526            dbprint(ppl,"reducing poly to ",f);
     527            if (remembercoeffs <> 0)
     528            {
     529              v = v - c * M[i];
     530            }
     531          }
     532        }
    533533      }
    534534    }
     
    556556  f = x3 + y2 + x2 + y + x;
    557557  I = x3 - y3, y3 - x2, x3 - y2, x2 - y, y2-x;
    558   list l = linReduce(f, I, 1); 
     558  list l = linReduce(f, I, 1);
    559559  l;
    560560  module M = I;
     
    601601      if (p <> 0)
    602602      {
    603         whichengine = 1;
     603        whichengine = 1;
    604604      }
    605605    }
     
    668668proc pIntersect (poly s, ideal I)
    669669"USAGE:  pIntersect(f, I);  f a poly, I an ideal
    670 RETURN:  vector, coefficient vector of the monic polynomial 
     670RETURN:  vector, coefficient vector of the monic polynomial
    671671PURPOSE: compute the intersection of ideal I with the subalgebra K[f]
    672672ASSUME:  I is given as Groebner basis.
     
    712712      if (degs[j] == 0)
    713713      {
    714         if (degI[i][j] <> 0)
    715         {
    716           break;
    717         }
     714        if (degI[i][j] <> 0)
     715        {
     716          break;
     717        }
    718718      }
    719719      if (j == n)
    720720      {
    721         k++;
    722         possdegbounds[k] = Max(degI[i]);
     721        k++;
     722        possdegbounds[k] = Max(degI[i]);
    723723      }
    724724    }
     
    749749      if (tobracket==0) // todo bug in bracket?
    750750      {
    751         toNF = 0;
     751        toNF = 0;
    752752      }
    753753      else
    754754      {
    755         toNF = bracket(tobracket,secNF);
     755        toNF = bracket(tobracket,secNF);
    756756      }
    757757      newNF = NF(toNF+oldNF*secNF,I);  // = NF(s^i,I)
     
    802802    v = v + m[j,1]*gen(j);
    803803  }
    804   setring save; 
     804  setring save;
    805805  v = imap(@R,v);
    806806  kill @R;
     
    864864      if (size(#)>2)
    865865      {
    866         if (typeof(#[3])=="int" || typeof(#[3])=="number")
    867         {
    868           modengine = int(#[3]);
    869         }
     866        if (typeof(#[3])=="int" || typeof(#[3])=="number")
     867        {
     868          modengine = int(#[3]);
     869        }
    870870      }
    871871    }
     
    909909      if (tobracket!=0)
    910910      {
    911         toNF = bracket(tobracket,NI[2]) + NI[i]*NI[2];
     911        toNF = bracket(tobracket,NI[2]) + NI[i]*NI[2];
    912912      }
    913913      else
    914914      {
    915         toNF = NI[i]*NI[2];
     915        toNF = NI[i]*NI[2];
    916916      }
    917917      newNF =  NF(toNF,I);
     
    927927      if (v!=0) // there is a modular solution
    928928      {
    929         dbprint(ppl,"got solution in char ",solveincharp," of degree " ,i);
    930         setring save;
    931         v = linSyzSolve(NI,whichengine);
    932         if (v==0)
    933         {
    934           break;
    935         }
     929        dbprint(ppl,"got solution in char ",solveincharp," of degree " ,i);
     930        setring save;
     931        v = linSyzSolve(NI,whichengine);
     932        if (v==0)
     933        {
     934          break;
     935        }
    936936      }
    937937      else // no modular solution
    938938      {
    939         setring save;
    940         v = 0;
     939        setring save;
     940        v = 0;
    941941      }
    942942    }
     
    965965      {
    966966        dbprint(ppl,"linSyzSolve: got solution!");
    967         // "got solution!";
     967        // "got solution!";
    968968        break;
    969969      }
     
    10151015      if (typeof(#[2])=="int" || typeof(#[2])=="number")
    10161016      {
    1017         ringvar = int(#[2]);
     1017        ringvar = int(#[2]);
    10181018      }
    10191019    }
     
    11211121      while (b == 0)
    11221122      {
    1123         dbprint(ppl,"number of run in the loop: "+string(i));
    1124         int q = prime(random(lb,ub));
    1125         if (findFirst(usedprimes,q)==0) // if q was not already used
     1123        dbprint(ppl,"number of run in the loop: "+string(i));
     1124        int q = prime(random(lb,ub));
     1125        if (findFirst(usedprimes,q)==0) // if q was not already used
    11261126        {
    1127           usedprimes = usedprimes,q;
    1128           dbprint(ppl,"used prime is: "+string(q));
    1129           b = pIntersectSyz(s,J,q,whichengine,modengine);
    1130         }
    1131         i++;
    1132       }
    1133     }
    1134     else // pIntersectSyz::non-modular 
     1127          usedprimes = usedprimes,q;
     1128          dbprint(ppl,"used prime is: "+string(q));
     1129          b = pIntersectSyz(s,J,q,whichengine,modengine);
     1130        }
     1131        i++;
     1132      }
     1133    }
     1134    else // pIntersectSyz::non-modular
    11351135    {
    11361136      b = pIntersectSyz(s,J,0,whichengine);
     
    11581158RETURN:  list of ideal and intvec
    11591159PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    1160 @*       for the hypersurface defined by f. 
     1160@*       for the hypersurface defined by f.
    11611161ASSUME:  The basering is a commutative polynomial ring in char 0.
    1162 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 
     1162BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
    11631163@*       by Masayuki Noro and then a system of linear equations is solved by linear reductions.
    1164 NOTE:    In the output list, the ideal contains all the roots 
     1164NOTE:    In the output list, the ideal contains all the roots
    11651165@*       and the intvec their multiplicities.
    11661166@*       If s<>0, @code{std} is used for GB computations,
    1167 @*       otherwise, and by default, @code{slimgb} is used. 
     1167@*       otherwise, and by default, @code{slimgb} is used.
    11681168@*       If t<>0, a matrix ordering is used for Groebner basis computations,
    11691169@*       otherwise, and by default, a block ordering is used.
    1170 @*       If v is a positive weight vector, v is used for homogenization computations, 
     1170@*       If v is a positive weight vector, v is used for homogenization computations,
    11711171@*       otherwise and by default, no weights are used.
    11721172DISPLAY: If printlevel=1, progress debug messages will be printed,
     
    11991199      if (size(#)>2)
    12001200      {
    1201         if (typeof(#[3])=="intvec" && size(#[3])==n && allPositive(#[3])==1)
     1201        if (typeof(#[3])=="intvec" && size(#[3])==n && allPositive(#[3])==1)
    12021202        {
    1203           u0 = #[3];
    1204         }
     1203          u0 = #[3];
     1204        }
    12051205      }
    12061206    }
     
    12221222"USAGE:  bfctSyz(f [,r,s,t,u,v]);  f a poly, r,s,t,u optional ints, v an optional intvec
    12231223RETURN:  list of ideal and intvec
    1224 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 
     1224PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    12251225@*       for the hypersurface defined by f
    12261226ASSUME:  The basering is a commutative polynomial ring in char 0.
    1227 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 
     1227BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
    12281228@*       by Masayuki Noro and then a system of linear equations is solved by computing syzygies.
    1229 NOTE:    In the output list, the ideal contains all the roots 
     1229NOTE:    In the output list, the ideal contains all the roots
    12301230@*       and the intvec their multiplicities.
    1231 @*       If r<>0, @code{std} is used for GB computations in characteristic 0, 
    1232 @*       otherwise, and by default, @code{slimgb} is used. 
    1233 @*       If s<>0, a matrix ordering is used for GB computations, otherwise, 
     1231@*       If r<>0, @code{std} is used for GB computations in characteristic 0,
     1232@*       otherwise, and by default, @code{slimgb} is used.
     1233@*       If s<>0, a matrix ordering is used for GB computations, otherwise,
    12341234@*       and by default, a block ordering is used.
    1235 @*       If t<>0, the computation of the intersection is solely performed over 
     1235@*       If t<>0, the computation of the intersection is solely performed over
    12361236@*       charasteristic 0, otherwise and by default, a modular method is used.
    1237 @*       If u<>0 and by default, @code{std} is used for GB computations in 
    1238 @*       characteristic >0, otherwise, @code{slimgb} is used. 
    1239 @*       If v is a positive weight vector, v is used for homogenization 
     1237@*       If u<>0 and by default, @code{std} is used for GB computations in
     1238@*       characteristic >0, otherwise, @code{slimgb} is used.
     1239@*       If v is a positive weight vector, v is used for homogenization
    12401240@*       computations, otherwise and by default, no weights are used.
    12411241DISPLAY: If printlevel=1, progress debug messages will be printed,
     
    12751275        if (typeof(#[3])=="int" || typeof(#[3])=="number")
    12761276        {
    1277           pIntersectchar = int(#[3]);
    1278         }
    1279         if (size(#)>3)
     1277          pIntersectchar = int(#[3]);
     1278        }
     1279        if (size(#)>3)
    12801280        {
    1281           if (typeof(#[4])=="int" || typeof(#[4])=="number")
     1281          if (typeof(#[4])=="int" || typeof(#[4])=="number")
    12821282          {
    1283             modengine = int(#[4]);
    1284           }
    1285           if (size(#)>4)
    1286           {
    1287             if (typeof(#[5])=="intvec" && size(#[5])==n && allPositive(#[5])==1)
    1288             {
    1289               u0 = #[5];
    1290             }
    1291           }
    1292         }
     1283            modengine = int(#[4]);
     1284          }
     1285          if (size(#)>4)
     1286          {
     1287            if (typeof(#[5])=="intvec" && size(#[5])==n && allPositive(#[5])==1)
     1288            {
     1289              u0 = #[5];
     1290            }
     1291          }
     1292        }
    12931293      }
    12941294    }
     
    13151315BACKGROUND:  In this proc, the initial ideal of I is computed according to the algorithm by
    13161316@*       Masayuki Noro and then a system of linear equations is solved by linear reductions.
    1317 NOTE:    In the output list, the ideal contains all the roots 
     1317NOTE:    In the output list, the ideal contains all the roots
    13181318@*       and the intvec their multiplicities.
    13191319@*       If s<>0, @code{std} is used for GB computations in characteristic 0,
    1320 @*       otherwise, and by default, @code{slimgb} is used. 
     1320@*       otherwise, and by default, @code{slimgb} is used.
    13211321@*       If t<>0, a matrix ordering is used for GB computations, otherwise,
    13221322@*       and by default, a block ordering is used.
     
    13741374"USAGE:  bfctOneGB(f [,s,t]);  f a poly, s,t optional ints
    13751375RETURN:  list of ideal and intvec
    1376 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the 
     1376PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the
    13771377@*       hypersurface defined by f, using only one GB computation
    13781378ASSUME:  The basering is a commutative polynomial ring in char 0.
    1379 BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the 
     1379BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the
    13801380@*       algorithm by Masayuki Noro and combined with an elimination ordering.
    1381 NOTE:    In the output list, the ideal contains all the roots 
     1381NOTE:    In the output list, the ideal contains all the roots
    13821382@*       and the intvec their multiplicities.
    13831383@*       If s<>0, @code{std} is used for the GB computation, otherwise,
    1384 @*       and by default, @code{slimgb} is used. 
     1384@*       and by default, @code{slimgb} is used.
    13851385@*       If t<>0, a matrix ordering is used for GB computations,
    13861386@*       otherwise, and by default, a block ordering is used.
     
    14921492"USAGE:  bfctAnn(f [,r]);  f a poly, r an optional int
    14931493RETURN:  list of ideal and intvec
    1494 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 
     1494PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    14951495@*       for the hypersurface defined by f
    14961496ASSUME:  The basering is a commutative polynomial ring in char 0.
    14971497BACKGROUND: In this proc, ann(f^s) is computed and then a system of linear
    14981498@*       equations is solved by linear reductions.
    1499 NOTE:    In the output list, the ideal contains all the roots 
     1499NOTE:    In the output list, the ideal contains all the roots
    15001500@*       and the intvec their multiplicities.
    15011501@*       If r<>0, @code{std} is used for GB computations,
    1502 @*       otherwise, and by default, @code{slimgb} is used. 
     1502@*       otherwise, and by default, @code{slimgb} is used.
    15031503DISPLAY: If printlevel=1, progress debug messages will be printed,
    15041504@*       if printlevel>=2, all the debug messages will be printed.
  • Singular/LIB/classify.lib

    r95edd5 r7f3ad4  
    11// KK,GMG last modified: 17.12.00
    22///////////////////////////////////////////////////////////////////////////////
    3 version  = "$Id: classify.lib,v 1.54 2008-12-08 14:24:41 dreyer Exp $";
     3version  = "$Id: classify.lib,v 1.55 2009-01-14 16:07:03 Singular Exp $";
    44category="Singularities";
    55info="
     
    14741474
    14751475  s = s +" has 4-jet equal to zero. (F47), mu="+string(Mu);
    1476  
     1476
    14771477  s; // +"  ("+SG_Typ+")";
    14781478  s = "No further classification available.";
     
    22222222  list v;
    22232223
    2224   if(sg[1]==1 && sg[2]==0 && sg[3]==1) { 
    2225       v=HKclass7_teil_1(sg, SG_Typ, cnt); 
     2224  if(sg[1]==1 && sg[2]==0 && sg[3]==1) {
     2225      v=HKclass7_teil_1(sg, SG_Typ, cnt);
    22262226  }
    22272227  else {
  • Singular/LIB/compregb.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: compregb.lib,v 1.2 2007-06-20 15:39:44 Singular Exp $";
     2version="$Id: compregb.lib,v 1.3 2009-01-14 16:07:03 Singular Exp $";
    33category="General purpose";
    44info="
     
    7979      for (j = 1; j <= size(CoefLsub); j ++)
    8080      {
    81         if (CoefLsub[j] > 1)
     81        if (CoefLsub[j] > 1)
    8282        {
    83           CoefL = insert(CoefL, CoefLsub[j]);
    84         }
     83          CoefL = insert(CoefL, CoefLsub[j]);
     84        }
    8585      }
    8686    }
     
    9494      if (Coef == CoefL[j])
    9595      {
    96         CoefL = delete(CoefL, j);
    97         j --;
     96        CoefL = delete(CoefL, j);
     97        j --;
    9898      }
    9999    }
  • Singular/LIB/decodegb.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: decodegb.lib,v 1.8 2008-10-22 13:31:48 bulygin Exp $";
     2version="$Id: decodegb.lib,v 1.9 2009-01-14 16:07:03 Singular Exp $";
    33category="Coding theory";
    44info="
    55LIBRARY: decodegb.lib         Decoding and min distance of linear codes with GB
    6 AUTHOR:  Stanislav Bulygin,   bulygin@mathematik.uni-kl.de                     
     6AUTHOR:  Stanislav Bulygin,   bulygin@mathematik.uni-kl.de
    77
    88OVERVIEW:
    99 In this library we generate several systems used for decoding cyclic codes and
    10  finding their minimum distance. Namely, we work with the Cooper's philosophy 
    11  and generalized Newton identities. The original method of quadratic equations 
    12  is worked out here as well. We also (for comparison) enable to work with the 
    13  system of Fitzgerald-Lax. We provide some auxiliary functions for further 
    14  manipulations and decoding. For an overview of the methods mentioned above @ref{Decoding codes with GB} 
    15  For the vanishing ideal computation the algorithm of Farr and Gao is 
     10 finding their minimum distance. Namely, we work with the Cooper's philosophy
     11 and generalized Newton identities. The original method of quadratic equations
     12 is worked out here as well. We also (for comparison) enable to work with the
     13 system of Fitzgerald-Lax. We provide some auxiliary functions for further
     14 manipulations and decoding. For an overview of the methods mentioned above @ref{Decoding codes with GB}
     15 For the vanishing ideal computation the algorithm of Farr and Gao is
    1616 implemented.
    1717
    18 MAIN PROCEDURES: 
     18MAIN PROCEDURES:
    1919 sysCRHT(..);        generates the CRHT-ideal as in Cooper's philosophy
    2020 sysCRHTMindist(..); CRHT-ideal to find the minimum distance in the binary case
     
    2929 genMDSMat(n,a);     generates an MDS (actually an RS) matrix
    3030 mindist(check);     computes the minimum distance of a code
    31  decode(rec);        decoding of a word using the system of quadratic equations 
     31 decode(rec);        decoding of a word using the system of quadratic equations
    3232 decodeRandom(..); a procedure for manipulation with random codes
    3333 decodeCode(..);   a procedure for manipulation with the given code
     
    3535 sysFL(..);          generates the Fitzgerald-Lax system
    3636 decodeRandomFL(..); manipulation with random codes via Fitzgerald-Lax
    37  
    38 
    39 KEYWORDS:  Cyclic code; Linear code; Decoding; 
     37
     38
     39KEYWORDS:  Cyclic code; Linear code; Decoding;
    4040           Minimum distance; Groebner bases
    4141";
     
    7676
    7777///////////////////////////////////////////////////////////////////////////////
    78 // the polynomial for Sala's restrictions 
     78// the polynomial for Sala's restrictions
    7979static proc p_poly(int n, int a, int b)
    8080{
     
    9292"USAGE:   sysCRHT(n,defset,e,q,m,[k]); n,e,q,m,k int, defset list of int's
    9393@format
    94          - n length of the cyclic code, 
     94         - n length of the cyclic code,
    9595         - defset is a list representing the defining set,
    96          - e the error-correcting capacity, 
     96         - e the error-correcting capacity,
    9797         - q field size
    98          - m degree extension of the splitting field, 
    99          - if k>0 additional equations representing the fact that every two 
     98         - m degree extension of the splitting field,
     99         - if k>0 additional equations representing the fact that every two
    100100         error positions are either different or at least one of them is zero
    101101@end format
    102 RETURN: the ring to work with the CRHT-ideal (with Sala's additions), 
     102RETURN: the ring to work with the CRHT-ideal (with Sala's additions),
    103103        containig an ideal with name 'crht'
    104 THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs 
    105          the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht'. With its 
     104THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs
     105         the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht'. With its
    106106         help one can solve the decoding problem. For basics of the method @ref{Cooper philosophy}.
    107107SEE ALSO: sysNewton, sysBin
     
    109109"
    110110{
    111   int r=size(defset); 
     111  int r=size(defset);
    112112  ring @crht=(q,a),(Y(e..1),Z(1..e),X(r..1)),lp;
    113113  ideal crht;
     
    115115  poly sum;
    116116  int k;
    117   if ( size(#) > 0) 
    118   { 
    119     k = #[1]; 
    120   }
    121  
     117  if ( size(#) > 0)
     118  {
     119    k = #[1];
     120  }
     121
    122122  //---------------------- add check equations --------------------------
    123123  for (i=1; i<=r; i++)
     
    130130    crht[i]=sum-X(i);
    131131  }
    132  
     132
    133133  //--------------------- field equations on syndromes ------------------
    134134  for (i=1; i<=r; i++)
     
    136136    crht=crht,X(i)^(q^m)-X(i);
    137137  }
    138  
     138
    139139  //------ restrictions on error-locations: n-th roots of unity ----------
    140140  for (i=1; i<=e; i++)
     
    142142    crht=crht,Z(i)^(n+1)-Z(i);
    143143  }
    144  
     144
    145145  for (i=1; i<=e; i++)
    146146  {
    147147    crht=crht,Y(i)^(q-1)-1;
    148   } 
    149  
     148  }
     149
    150150  //--------- add Sala's additional conditions if necessary --------------
    151151  if ( k > 0 )
    152  
     152
    153153  {
    154154    for (i=1; i<=e; i++)
     
    159159      }
    160160    }
    161   } 
    162   export crht; 
    163   return(@crht);   
    164 } 
     161  }
     162  export crht;
     163  return(@crht);
     164}
    165165example
    166166{ "EXAMPLE:"; echo=2;
     
    168168  intvec v = option(get);
    169169
    170   list defset=1,3;           // defining set 
     170  list defset=1,3;           // defining set
    171171  int n=15;                  // length
    172172  int e=2;                   // error-correcting capacity
     
    174174  int m=4;                   // degree extension of the splitting field
    175175  int sala=1;                // indicator to add additional equations
    176    
    177   def A=sysCRHT(n,defset,e,q,m); 
     176
     177  def A=sysCRHT(n,defset,e,q,m);
    178178  setring A;
    179179  A;                         // shows the ring we are working in
    180   print(crht);               // the CRHT-ideal 
     180  print(crht);               // the CRHT-ideal
    181181  option(redSB);
    182182  ideal red_crht=std(crht);  // reduced Groebner basis
    183183  print(red_crht);
    184  
     184
    185185  //============================
    186   A=sysCRHT(n,defset,e,q,m,sala); 
    187   setring A; 
     186  A=sysCRHT(n,defset,e,q,m,sala);
     187  setring A;
    188188  print(crht);                // CRHT-ideal with additional equations from Sala
    189189  option(redSB);
    190190  ideal red_crht=std(crht);   // reduced Groebner basis
    191   print(red_crht);           
     191  print(red_crht);
    192192  red_crht[5];                // general error-locator polynomial for this code
    193193  option(set,v);
     
    198198
    199199proc sysCRHTMindist (int n, list defset, int w)
    200 "USAGE:  sysCRHTMindist(n,defset,w);  n,w are int, defset is list of int's 
     200"USAGE:  sysCRHTMindist(n,defset,w);  n,w are int, defset is list of int's
    201201@format
    202         - n length of the cyclic code, 
     202        - n length of the cyclic code,
    203203        - defset is a list representing the defining set,
    204204        - w is a candidate for the minimum distance
    205205@end format
    206 RETURN:  the ring to work with the Sala's ideal for the minimum distance 
     206RETURN:  the ring to work with the Sala's ideal for the minimum distance
    207207         containing the ideal with name 'crht_md'
    208 THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs 
    209          the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht_md'. With 
    210          its help one can find minimum distance of the code in the binary 
     208THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs
     209         the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht_md'. With
     210         its help one can find minimum distance of the code in the binary
    211211         case. For basics of the method @ref{Cooper philosophy}.
    212212EXAMPLE: example sysCRHTMindist; shows an example
    213213"
    214214{
    215   int r=size(defset); 
     215  int r=size(defset);
    216216  ring @crht_md=2,Z(1..w),lp;
    217217  ideal crht_md;
    218218  int i,j;
    219219  poly sum;
    220  
     220
    221221  //------------ add check equations --------------
    222222  for (i=1; i<=r; i++)
     
    228228    }
    229229    crht_md[i]=sum;
    230   } 
    231  
    232  
     230  }
     231
     232
    233233  //----------- locations are n-th roots of unity ------------
    234234  for (i=1; i<=w; i++)
    235235  {
    236236    crht_md=crht_md,Z(i)^n-1;
    237   } 
    238  
     237  }
     238
    239239  //------------ adding conditions on locations being different ------------
    240240  for (i=1; i<=w; i++)
     
    245245    }
    246246  }
    247    
    248   export crht_md; 
    249   return(@crht_md);   
    250 } 
     247
     248  export crht_md;
     249  return(@crht_md);
     250}
    251251example
    252252{
     
    254254  intvec v = option(get);
    255255  // binary cyclic [15,7,5] code with defining set (1,3)
    256  
    257   list defset=1,3;             // defining set 
    258   int n=15;                    // length 
    259   int d=5;                     // candidate for the minimum distance 
    260      
    261   def A=sysCRHTMindist(n,defset,d); 
     256
     257  list defset=1,3;             // defining set
     258  int n=15;                    // length
     259  int d=5;                     // candidate for the minimum distance
     260
     261  def A=sysCRHTMindist(n,defset,d);
    262262  setring A;
    263263  A;                           // shows the ring we are working in
    264264  print(crht_md);              // the Sala's ideal for mindist
    265265  option(redSB);
    266   ideal red_crht_md=std(crht_md);     
     266  ideal red_crht_md=std(crht_md);
    267267  print(red_crht_md);          // reduced Groebner basis
    268  
     268
    269269  option(set,v);
    270270}
     
    281281
    282282proc sysNewton (int n, list defset, int t, int q, int m, list #)
    283 "USAGE:   sysNewton (n,defset,t,q,m,[tr]); n,t,q,m,tr int, defset list int's 
     283"USAGE:   sysNewton (n,defset,t,q,m,[tr]); n,t,q,m,tr int, defset list int's
    284284@format
    285          - n is length, 
     285         - n is length,
    286286         - defset is the defining set,
    287          - t is the number of errors, 
    288          - q is basefield size, 
     287         - t is the number of errors,
     288         - q is basefield size,
    289289         - m is degree extension of the splitting field,
    290          - if tr>0 it indicates that Newton identities in triangular 
     290         - if tr>0 it indicates that Newton identities in triangular
    291291           form should be constructed
    292292@end format
    293 RETURN:  the ring to work with the generalized Newton identities (in 
     293RETURN:  the ring to work with the generalized Newton identities (in
    294294         triangular form if applicable) containing the ideal with name 'newton'
    295 THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs 
    296          the corresponding ideal 'newton' with the generalized Newton 
    297          identities. With its help one can solve the decoding problem. For 
     295THEORY:  Based on 'defset' of the given cyclic code, the procedure constructs
     296         the corresponding ideal 'newton' with the generalized Newton
     297         identities. With its help one can solve the decoding problem. For
    298298         basics of the method @ref{Cooper philosophy}.
    299299SEE ALSO: sysCRHT, sysBin
    300300EXAMPLE:  example sysNewton; shows an example
    301301"
    302 { 
     302{
    303303 string s="ring @newton=("+string(q)+",a),(";
    304304 int i,j;
    305305 int flag;
    306306 int tr;
    307  
     307
    308308 if (size(#)>0)
    309309 {
    310310  tr=#[1];
    311311 }
    312  
     312
    313313 for (i=n; i>=1; i--)
    314314 {
     
    319319    {
    320320      flag=0;
    321       break;     
     321      break;
    322322    }
    323323  }
     
    332332  s=s+"S("+string(defset[i])+"),";
    333333 }
    334  s=s+"S("+string(defset[1])+")),lp;"; 
    335  
     334 s=s+"S("+string(defset[1])+")),lp;";
     335
    336336 execute(s);
    337  
    338  ideal newton; 
     337
     338 ideal newton;
    339339 poly sum;
    340  
    341  
     340
     341
    342342 //------------ generate generalized Newton identities ----------
    343343 if (tr)
     
    353353  }
    354354 } else
    355  { 
     355 {
    356356  for (i=1; i<=t; i++)
    357357  {
     
    372372  }
    373373  newton=newton,S(t+i)+sum;
    374  } 
    375  
     374 }
     375
    376376 //----------- add field equations on sigma's --------------
    377377 for (i=1; i<=t; i++)
     
    379379  newton=newton,sigma(i)^(q^m)-sigma(i);
    380380 }
    381  
     381
    382382 //----------- add conjugacy relations ------------------
    383383 for (i=1; i<=n; i++)
     
    387387 newton=simplify(newton,2);
    388388 export newton;
    389  return(@newton); 
    390 } 
    391 example 
     389 return(@newton);
     390}
     391example
    392392{
    393393     "EXAMPLE:";  echo = 2;
    394      // Newton identities for a binary 3-error-correcting cyclic code of 
     394     // Newton identities for a binary 3-error-correcting cyclic code of
    395395     //length 31 with defining set (1,5,7)
    396      
     396
    397397     int n=31;          // length
    398398     list defset=1,5,7; //defining set
     
    401401     int m=5;           // degree extension of the splitting field
    402402     int tr=1;          // indicator of triangular form of Newton identities
    403      
    404      
     403
     404
    405405     def A=sysNewton(n,defset,t,q,m);
    406406     setring A;
    407407     A;                 // shows the ring we are working in
    408408     print(newton);     // generalized Newton identities
    409      
     409
    410410     //===============================
    411411     A=sysNewton(n,defset,t,q,m,tr);
    412      setring A;     
     412     setring A;
    413413     print(newton);     // generalized Newton identities in triangular form
    414414}
    415415
    416416///////////////////////////////////////////////////////////////////////////////
    417 // forms a list of special combinations needed for computation of Waring's 
     417// forms a list of special combinations needed for computation of Waring's
    418418//function
    419419static proc combinations_sum (int m, int n)
     
    438438   count++;
    439439  }
    440   if (flag) 
     440  if (flag)
    441441  {
    442442   for (j=2; j<=m; j++)
     
    444444    interm[i][j]=interm[i][j] div j;
    445445   }
    446    result[size(result)+1]=interm[i]; 
     446   result[size(result)+1]=interm[i];
    447447  }
    448448 }
     
    470470"USAGE:    sysBin (v,Q,n,[odd]);  v,n,odd are int, Q is list of int's
    471471@format
    472           - v a number if errors, 
    473           - Q is a generating set of the code, 
    474           - n the length, 
    475           - odd is an additional parameter: if 
    476            set to 1, then the generating set is enlarged by odd elements, 
     472          - v a number if errors,
     473          - Q is a generating set of the code,
     474          - n the length,
     475          - odd is an additional parameter: if
     476           set to 1, then the generating set is enlarged by odd elements,
    477477           which are 2^(some power)*(some elment in the gen.set) mod n
    478478@end format
    479479RETURN:    the ring with the resulting system called 'bin'
    480 THEORY:  Based on Q of the given cyclic code, the procedure constructs 
    481          the corresponding ideal 'bin' with the use of Waring function. 
    482          With its help one can solve the decoding problem. 
     480THEORY:  Based on Q of the given cyclic code, the procedure constructs
     481         the corresponding ideal 'bin' with the use of Waring function.
     482         With its help one can solve the decoding problem.
    483483         For basics of the method @ref{Generalized Newton identities}.
    484484SEE ALSO: sysNewton, sysCRHT
     
    527527  Q_update=Q;
    528528 }
    529  
    530  //---- form polynomials for the Bin system via Waring's function --------- 
     529
     530 //---- form polynomials for the Bin system via Waring's function ---------
    531531 for (i=1; i<=size(Q_update); i++)
    532532 {
     
    541541   }
    542542   count1=0;
    543    for (j=2; j<=upper-1; j++) 
     543   for (j=2; j<=upper-1; j++)
    544544   {
    545545    count1=count1+exp_count(j,2);
     
    564564   sum_=sum_+coef_*mon;
    565565  }
    566   result=result,S(Q_update[i])-sum_; 
     566  result=result,S(Q_update[i])-sum_;
    567567 }
    568568 ideal bin=simplify(result,2);
    569569 export bin;
    570570 return(r);
    571 } 
    572 example 
     571}
     572example
    573573{
    574574     "EXAMPLE:";  echo = 2;
     
    592592 if (ncols(x)!=nrows(g)) {print("ERRORencode2!");}
    593593 return(x*g);
    594 } 
    595 example 
     594}
     595example
    596596{
    597597     "EXAMPLE:";  echo = 2;
     
    603603                    0,0,0,1,1,1,0;
    604604     //encode x with the generator matrix g
    605      print(encode(x,g)); 
     605     print(encode(x,g));
    606606}
    607607
     
    616616 if (nrows(c)>1) {print("ERRORsyndrome1!");}
    617617 if (ncols(c)!=ncols(h)) {print("ERRORsyndrome2!");}
    618  return(h*transpose(c)); 
    619 } 
    620 example 
     618 return(h*transpose(c));
     619}
     620example
    621621{
    622622     "EXAMPLE:";  echo = 2;
     
    636636     print(syndrome(check,c));
    637637     c[1,3]=1;
    638      //now c is a codeword 
     638     //now c is a codeword
    639639     print(syndrome(check,c));
    640640}
     
    657657"USAGE:   sysQE(check,y,t,[fieldeq,formal]);check,y matrix;t,fieldeq,formal int
    658658@format
    659         - check is the check matrix of the code   
    660         - y is a received word, 
    661         - t the number of errors to be corrected, 
    662         - if fieldeq=1, then field equations are added, 
    663         - if formal=0, field equations on (known) syndrome variables 
    664           are not added, in order to add them (note that the exponent should 
     659        - check is the check matrix of the code
     660        - y is a received word,
     661        - t the number of errors to be corrected,
     662        - if fieldeq=1, then field equations are added,
     663        - if formal=0, field equations on (known) syndrome variables
     664          are not added, in order to add them (note that the exponent should
    665665          be as a number of elements in the INITIAL alphabet) one
    666666          needs to set formal>0 for the exponent
    667667@end format
    668668RETURN:   the ring to work with together with the resulting system called 'qe'
    669 THEORY:  Based on 'check' of the given linear code, the procedure constructs 
     669THEORY:  Based on 'check' of the given linear code, the procedure constructs
    670670         the corresponding ideal that gives an opportunity to compute
    671671         unknown syndrome of the received word y. Further
    672          one is able to solve the decoding problem. 
     672         one is able to solve the decoding problem.
    673673         For basics of the method @ref{Decoding method based on quadratic equations}.
    674674SEE ALSO: sysFL
     
    686686  formal=#[2];
    687687 }
    688  
    689  def br=basering; 
     688
     689 def br=basering;
    690690 list rl=ringlist(br);
    691  
     691
    692692 int red=nrows(check);
    693693 int n=ncols(check);
    694694 int q=rl[1][1];
    695  
     695
    696696 if (formal==0)
    697  { 
     697 {
    698698  ring work=(q,a),(V(1..t),U(1..n)),dp;
    699699 } else
     
    701701  ring work=(q,a),(V(1..t),U(1..n),s(1..red)),(dp(t),lp(n),dp(red));
    702702 }
    703  
     703
    704704 matrix check=imap(br,check);
    705705 matrix y=imap(br,y);
    706  
     706
    707707 matrix h_full=genMDSMat(n,a);
    708708 matrix h=submat(h_full,1..red,1..n);
    709709 if (nrows(y)!=1) {print("ERROR1Pell");}
    710710 if (ncols(y)!=n) {print("ERROR2Pell");}
    711  
     711
    712712 ideal result;
    713  
     713
    714714 list c;
    715715 list a;
     
    722722  c[i]=tmp;
    723723 }
    724  
     724
    725725 int tim=rtimer;
    726726 matrix transf=inverse(transpose(h_full));
    727  
     727
    728728 //------ expression matrix of check vectors w.r.t. the MDS basis -----------
    729729 tim=rtimer;
     
    733733  a[i]=transf*a[i];
    734734 }
    735  
     735
    736736 //----------- compute the structure constants ------------------------
    737737 tim=rtimer;
    738  matrix te[n][1]; 
     738 matrix te[n][1];
    739739 for (i=1; i<=n; i++)
    740740 {
     
    742742  {
    743743   if ((j<i)&&(i<=t+1)) {c[i][j]=c[j][i];}
    744    else 
     744   else
    745745   {
    746     if (i+j<=n+1) 
     746    if (i+j<=n+1)
    747747    {
    748748     c[i][j]=te;
    749      c[i][j][i+j-1,1]=1; 
     749     c[i][j][i+j-1,1]=1;
    750750    }
    751751    else
     
    753753     c[i][j]=star(h_full,i,j);
    754754     c[i][j]=transf*c[i][j];
    755     }   
     755    }
    756756   }
    757757  }
    758758 }
    759  
    760  
    761  tim=rtimer; 
     759
     760
     761 tim=rtimer;
    762762 if (formal==0)
    763763 {
     
    798798     result=result,V(j)^q-V(j);
    799799  }
    800  } 
    801  
     800 }
     801
    802802 //----- form the quadratic equations according to the theory -----------
    803803 for (i=1; i<=n; i++)
     
    819819  }
    820820  result=result,sum1-sum3;
    821  } 
    822  
     821 }
     822
    823823 result=simplify(result,2);
    824  
     824
    825825 ideal qe=result;
    826826 export qe;
    827  return(work); 
    828 } 
    829 example 
     827 return(work);
     828}
     829example
    830830{
    831831     "EXAMPLE:";  echo = 2;
    832832     intvec v = option(get);
    833      
     833
    834834     //correct 2 errors in [7,3] 8-ary code RS code
    835835     int t=2; int q=8; int n=7; int redun=4;
     
    840840     matrix x[1][3]=0,0,1,0;
    841841     matrix y[1][7]=encode(x,g);
    842      
     842
    843843     //disturb with 2 errors
    844      matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a)); 
    845      
     844     matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a));
     845
    846846     //generate the system
    847847     def A=sysQE(h,rec,t);
    848848     setring A;
    849849     print(qe);
    850      
     850
    851851     //let us decode
    852852     option(redSB);
    853853     ideal sys_qe=std(qe);
    854      print(sys_qe);     
    855      
     854     print(sys_qe);
     855
    856856     option(set,v);
    857857}
     
    862862"USAGE:  errorInsert(y,pos,val); y is matrix, pos,val list of int's
    863863@format
    864         - y is a (code) word, 
    865         - pos = positions where errors occured, 
     864        - y is a (code) word,
     865        - pos = positions where errors occured,
    866866        - val = their corresponding values
    867867@end format
     
    877877 }
    878878 return(result);
    879 } 
    880 example 
     879}
     880example
    881881{
    882882     "EXAMPLE:";  echo = 2;
     
    890890     matrix y[1][7]=encode(x,g);
    891891     print(y);
    892      
     892
    893893     //disturb with 2 errors
    894894     matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a));
     
    902902"USAGE:    errorRand(y, num, e); y matrix, num,e int
    903903@format
    904           - y is a (code) word, 
    905           - num is the number of errors, 
     904          - y is a (code) word,
     905          - num is the number of errors,
    906906          - e is an extension degree (if one wants values to be from GF(p^e))
    907907@end format
     
    926926   }
    927927   if (flag) {pos[i]=temp;break;}
    928   } 
    929  }
    930  
     928  }
     929 }
     930
    931931 for (i=1; i<=num; i++)
    932932 {
    933933  flag=1;
    934934  while(flag)
    935   {   
    936    tempnum=randomvector(1,e);   
    937    if (tempnum!=0) {flag=0;}   
    938   }
    939   val[i]=tempnum; 
    940  }
    941  
     935  {
     936   tempnum=randomvector(1,e);
     937   if (tempnum!=0) {flag=0;}
     938  }
     939  val[i]=tempnum;
     940 }
     941
    942942 for (i=1; i<=size(pos); i++)
    943943 {
     
    945945 }
    946946 return(result);
    947 } 
    948 example 
     947}
     948example
    949949{
    950950  "EXAMPLE:";  echo = 2;
     
    957957     matrix x[1][3]=0,0,1,0;
    958958     matrix y[1][7]=encode(x,g);
    959      
     959
    960960     //disturb with 2 random errors
    961961     matrix rec[1][7]=errorRand(y,2,3);
    962962     print(rec);
    963      print(rec-y);     
     963     print(rec-y);
    964964}
    965965
     
    969969"USAGE:    randomCheck(m, n, e); m,n,e are int
    970970@format
    971           - m x n are dimensions of the matrix, 
     971          - m x n are dimensions of the matrix,
    972972          - e is an extension degree (if one wants values to be from GF(p^e))
    973973@end format
     
    986986  {
    987987   rand[i,j]=temp[j,1];
    988   } 
     988  }
    989989 }
    990990 result=concat(rand,unitmat(m));
    991991 return(result);
    992 } 
    993 example 
    994 {
    995   "EXAMPLE:";  echo = 2;     
     992}
     993example
     994{
     995  "EXAMPLE:";  echo = 2;
    996996     int redun=5; int n=15;
    997997     ring r=2,x,dp;
    998      
     998
    999999     //generate random check matrix for a [15,5] binary code
    10001000     matrix h=randomCheck(redun,n,1);
    10011001     print(h);
    1002      
     1002
    10031003     //corresponding generator matrix
    10041004     matrix g=dual_code(h);
    1005      print(g);     
     1005     print(g);
    10061006}
    10071007
     
    10111011"USAGE:   genMDSMat(n, a); n is int, a is number
    10121012@format
    1013         - n x n are dimensions of the MDS matrix, 
     1013        - n x n are dimensions of the MDS matrix,
    10141014        - a is a primitive element of the field.
    1015 @end format   
    1016 NOTE:   An MDS matrix is constructed in the following way. We take a to be a 
    1017         generator of the multiplicative group of the field. Then we construct 
     1015@end format
     1016NOTE:   An MDS matrix is constructed in the following way. We take a to be a
     1017        generator of the multiplicative group of the field. Then we construct
    10181018        the Vandermonde matrix with this a.
    1019 ASSUME:   extension field should already be defined 
     1019ASSUME:   extension field should already be defined
    10201020RETURN:   a matrix with the MDS property
    1021 EXAMPLE:  example genMDSMat; shows an example 
     1021EXAMPLE:  example genMDSMat; shows an example
    10221022"
    10231023{
     
    10291029  {
    10301030   result[j+1,i+1]=(a^i)^j;
    1031   } 
     1031  }
    10321032 }
    10331033 return(result);
    1034 } 
    1035 example 
     1034}
     1035example
    10361036{
    10371037     "EXAMPLE:";  echo = 2;
    10381038     int q=16; int n=15;
    10391039     ring r=(q,a),x,dp;
    1040      
     1040
    10411041     //generate an MDS (Vandermonde) matrix
    10421042     matrix h_full=genMDSMat(n,a);
    1043      print(h_full);     
     1043     print(h_full);
    10441044}
    10451045
     
    10501050"USAGE:  mindist (check, q); check matrix, q int
    10511051@format
    1052         - check is a check matrix, 
     1052        - check is a check matrix,
    10531053        - q is the field size
    10541054@end format
    1055 RETURN:  minimum distance of the code together with the time needed for its 
     1055RETURN:  minimum distance of the code together with the time needed for its
    10561056         calculation
    1057 EXAMPLE: example mindist; shows an example 
     1057EXAMPLE: example mindist; shows an example
    10581058"
    10591059{
     
    10611061
    10621062 int n=ncols(check); int redun=nrows(check); int t=redun+1;
    1063  
    1064  def br=basering; 
    1065  list rl=ringlist(br); 
     1063
     1064 def br=basering;
     1065 list rl=ringlist(br);
    10661066 int q=rl[1][1];
    1067  
    1068  ring work=(q,a),(V(1..t),U(1..n)),dp; 
    1069  matrix check=imap(br,check); 
    1070  
     1067
     1068 ring work=(q,a),(V(1..t),U(1..n)),dp;
     1069 matrix check=imap(br,check);
     1070
    10711071 ideal temp;
    10721072 int count=1;
     
    10741074 int flag2;
    10751075 int i, tim, timsolve;
    1076  matrix z[1][n]; 
     1076 matrix z[1][n];
    10771077 option(redSB);
    10781078 def A=sysQE(check,z,count);
    10791079
    1080  //proceed with solving the system w.r.t zero vector until some solutions 
     1080 //proceed with solving the system w.r.t zero vector until some solutions
    10811081 //are found
    10821082 while (flag)
     
    10871087    tim=rtimer;
    10881088    temp=std(temp);
    1089     timsolve=timsolve+rtimer-tim; 
     1089    timsolve=timsolve+rtimer-tim;
    10901090    flag2=1;
    10911091    setring work;
    1092     temp=imap(A,temp);   
     1092    temp=imap(A,temp);
    10931093    for (i=1; i<=n; i++)
    10941094    {
    1095       if 
    1096         (temp[i]!=U(n-i+1)) 
     1095      if
     1096        (temp[i]!=U(n-i+1))
    10971097        {
    10981098          flag2=0;
    10991099        }
    11001100    }
    1101     if (!flag2) 
     1101    if (!flag2)
    11021102    {
    11031103      flag=0;
    11041104    }
    1105     else 
     1105    else
    11061106    {
    11071107      count++;
    11081108    }
    11091109 }
    1110  list result=list(count,timsolve); 
    1111  
     1110 list result=list(count,timsolve);
     1111
    11121112 option(set,vopt);
    1113  return(result); 
    1114 } 
    1115 example 
     1113 return(result);
     1114}
     1115example
    11161116{
    11171117     "EXAMPLE:";  echo = 2;
    1118      //determine a minimum distance for a [7,3] binary code 
    1119      int q=8; int n=7; int redun=4; int t=redun+1; 
    1120      ring r=(q,a),x,dp;     
    1121                
     1118     //determine a minimum distance for a [7,3] binary code
     1119     int q=8; int n=7; int redun=4; int t=redun+1;
     1120     ring r=(q,a),x,dp;
     1121
    11221122     //generate random check matrix
    11231123     matrix h=randomCheck(redun,n,1);
    11241124     print(h);
    1125      list l=mindist(h);     
    1126      print(l[1]); 
    1127      //time for the comutation in secs   
    1128      print(l[2]);     
     1125     list l=mindist(h);
     1126     print(l[1]);
     1127     //time for the comutation in secs
     1128     print(l[2]);
    11291129}
    11301130
     
    11351135@format
    11361136          - check is the check matrix of the code,
    1137           - rec is a received word, 
     1137          - rec is a received word,
    11381138          - t is an upper bound for the number of errors one wants to correct
    11391139@end format
    1140 ASSUME:   Errors in rec should be correctable, otherwise the output is 
     1140ASSUME:   Errors in rec should be correctable, otherwise the output is
    11411141          unpredictable
    11421142RETURN:   a codeword that is closest to rec
    1143 EXAMPLE:  example decode; shows an example 
     1143EXAMPLE:  example decode; shows an example
    11441144"
    11451145{
    1146  intvec vopt = option(get); 
    1147  
     1146 intvec vopt = option(get);
     1147
    11481148 def br=basering;
    1149  int n=ncols(check); 
    1150  
    1151  int count=1; 
     1149 int n=ncols(check);
     1150
     1151 int count=1;
    11521152 def A=sysQE(check,rec,count);
    11531153 while(1)
    11541154 {
    11551155  A=sysQE(check,rec,count);
    1156   setring A;     
     1156  setring A;
    11571157  matrix h_full=genMDSMat(n,a);
    11581158  matrix rec=imap(br,rec);
    11591159  option(redSB);
    1160   ideal qe_red=std(qe);   
     1160  ideal qe_red=std(qe);
    11611161  if (qe_red[1]!=1)
    11621162  {
    11631163    break;
    11641164  }
    1165   else 
     1165  else
    11661166  {
    11671167    count++;
     
    11691169  setring br;
    11701170 }
    1171  
    1172  setring A; 
    1173      
     1171
     1172 setring A;
     1173
    11741174 //obtain a codeword
    11751175 //this works only if our code is indeed can correct these errors
     
    11781178 {
    11791179  syn[i,1]=-qe_red[n-i+1]+lead(qe_red[n-i+1]);
    1180  }   
    1181  
    1182  matrix real_syn=inverse(h_full)*syn; 
     1180 }
     1181
     1182 matrix real_syn=inverse(h_full)*syn;
    11831183 setring br;
    11841184 matrix real_syn=imap(A,real_syn);
    1185  
     1185
    11861186 option(set,vopt);
    1187  return(rec-transpose(real_syn));     
    1188 } 
    1189 example 
    1190 {
    1191      "EXAMPLE:";  echo = 2;     
    1192      //correct 1 error in [15,7] binary code 
     1187 return(rec-transpose(real_syn));
     1188}
     1189example
     1190{
     1191     "EXAMPLE:";  echo = 2;
     1192     //correct 1 error in [15,7] binary code
    11931193     int t=1; int q=16; int n=15; int redun=10;
    1194      ring r=(q,a),x,dp;     
    1195              
     1194     ring r=(q,a),x,dp;
     1195
    11961196     //generate random check matrix
    1197      matrix h=randomCheck(redun,n,1);     
     1197     matrix h=randomCheck(redun,n,1);
    11981198     matrix g=dual_code(h);
    11991199     matrix x[1][n-redun]=0,0,1,0,1,0,1;
    12001200     matrix y[1][n]=encode(x,g);
    12011201     print(y);
    1202      
     1202
    12031203     // find out the minimum distance of the code
    12041204     list l=mindist(h);
    1205      
     1205
    12061206     //disturb with errors
    12071207     "Correct ",(l[1]-1) div 2," errors";
    12081208     matrix rec[1][n]=errorRand(y,(l[1]-1) div 2,1);
    1209      print(rec);     
    1210      
     1209     print(rec);
     1210
    12111211     //let us decode
    12121212     matrix dec_word=decode(h,rec);
    1213      print(dec_word);     
     1213     print(dec_word);
    12141214}
    12151215
     
    12211221@format
    12221222          - redun is a redundabcy of a (random) code,
    1223           - q is the field size, 
     1223          - q is the field size,
    12241224          - ncodes is the number of random codes to be processed,
    12251225          - ntrials is the number of received vectors per code to be corrected
    1226           - If e is given it sets the correction capacity explicitly. It 
     1226          - If e is given it sets the correction capacity explicitly. It
    12271227          should be used in case one expects some lower bound,
    1228           otherwise the procedure tries to compute the real minimum distance 
     1228          otherwise the procedure tries to compute the real minimum distance
    12291229          to find out the error-correction capacity
    12301230@end format
    1231 RETURN:    nothing; 
    1232 EXAMPLE:   example decodeRandom; shows an example 
     1231RETURN:    nothing;
     1232EXAMPLE:   example decodeRandom; shows an example
    12331233"
    12341234{
     
    12481248 option(redSB);
    12491249 def br=basering;
    1250  matrix h_full=genMDSMat(n,a); 
     1250 matrix h_full=genMDSMat(n,a);
    12511251 matrix z[1][ncols(h_full)];
    12521252
     
    12681268     dist=tmp[1];
    12691269     printf("d= %p",dist);
    1270      t=(dist-1) div 2; 
    1271   }     
    1272   tim2=rtimer; 
     1270     t=(dist-1) div 2;
     1271  }
     1272  tim2=rtimer;
    12731273  tim3=rtimer;
    12741274
     
    12791279  ideal sys2,sys3;
    12801280  matrix h=imap(br,h);
    1281   matrix g=dual_code(h); 
     1281  matrix g=dual_code(h);
    12821282  ideal sys=qe;
    12831283  print("The system is generated");
    1284   timdec3=timdec3+rtimer-tim3; 
     1284  timdec3=timdec3+rtimer-tim3;
    12851285
    12861286  //------ modify the template according to every received word --------------
    12871287  for (j=1; j<=ntrials; j++)
    12881288  {
    1289    word=randomvector(n-redun,1);   
     1289   word=randomvector(n-redun,1);
    12901290   y=encode(transpose(word),g);
    1291    rec=errorRand(y,t,1);   
    1292    sys2=add_synd(rec,h,redun,sys); 
    1293  
     1291   rec=errorRand(y,t,1);
     1292   sys2=add_synd(rec,h,redun,sys);
     1293
    12941294   tim=rtimer;
    1295    sys3=std(sys2);   
    1296    timdec=timdec+rtimer-tim;   
    1297   } 
     1295   sys3=std(sys2);
     1296   timdec=timdec+rtimer-tim;
     1297  }
    12981298  timdec2=timdec2+rtimer-tim2;
    12991299  kill A;
    13001300  option(set,vopt);
    1301  } 
     1301 }
    13021302 printf("Time for mindist: %p", timdist);
    13031303 printf("Time for GB in mindist: %p", timdist);
    13041304 printf("Time for decoding: %p", timdec2);
    13051305 printf("Time for GB in decoding: %p", timdec);
    1306  printf("Time for sysQE in decoding: %p", timdec3); 
    1307 } 
    1308 example 
     1306 printf("Time for sysQE in decoding: %p", timdec3);
     1307}
     1308example
    13091309{
    13101310     "EXAMPLE:";  echo = 2;
    13111311     int q=32; int n=25; int redun=n-11; int t=redun+1;
    13121312     ring r=(q,a),x,dp;
    1313      
     1313
    13141314     // correct 2 errors in 5 random binary codes, 50 trials each
    1315      decodeRandom(n,redun,5,50,2); 
     1315     decodeRandom(n,redun,5,50,2);
    13161316}
    13171317
     
    13201320
    13211321proc decodeCode(matrix check, int ntrials, list #)
    1322 "USAGE:     decodeCode(check, ntrials, [e]); check matrix, ntrials,e int 
    1323 @format           
    1324            - check is a check matrix for the code, 
    1325            - ntrials is the number of received vectors per code to be 
     1322"USAGE:     decodeCode(check, ntrials, [e]); check matrix, ntrials,e int
     1323@format
     1324           - check is a check matrix for the code,
     1325           - ntrials is the number of received vectors per code to be
    13261326           corrected.
    1327            - If e is given it sets the correction capacity explicitly. It 
     1327           - If e is given it sets the correction capacity explicitly. It
    13281328           should be used in case one expects some lower bound,
    1329            otherwise the procedure tries to compute the real minimum distance 
     1329           otherwise the procedure tries to compute the real minimum distance
    13301330           to find out the error-correction capacity
    13311331@end format
    1332 RETURN:     nothing; 
    1333 EXAMPLE:    example decodeCode; shows an example 
     1332RETURN:     nothing;
     1333EXAMPLE:    example decodeCode; shows an example
    13341334"
    13351335{
     
    13511351 option(redSB);
    13521352 def br=basering;
    1353  matrix h_full=genMDSMat(n,a); 
     1353 matrix h_full=genMDSMat(n,a);
    13541354 matrix z[1][ncols(h_full)];
    13551355 setring br;
     
    13691369   dist=tmp[1];
    13701370   printf("d= %p",dist);
    1371    t=(dist-1) div 2; 
    1372  }     
    1373  tim2=rtimer; 
     1371   t=(dist-1) div 2;
     1372 }
     1373 tim2=rtimer;
    13741374 tim3=rtimer;
    13751375
     
    13801380 ideal sys2,sys3;
    13811381 matrix h=imap(br,h);
    1382  matrix g=dual_code(h); 
     1382 matrix g=dual_code(h);
    13831383 ideal sys=qe;
    13841384 print("The system is generated");
    1385  timdec3=timdec3+rtimer-tim3; 
    1386 
    1387  //--- modify the template according to every received word --------------- 
     1385 timdec3=timdec3+rtimer-tim3;
     1386
     1387 //--- modify the template according to every received word ---------------
    13881388 for (j=1; j<=ntrials; j++)
    13891389 {
    1390    word=randomvector(n-redun,1);   
     1390   word=randomvector(n-redun,1);
    13911391   y=encode(transpose(word),g);
    1392    rec=errorRand(y,t,1);   
    1393    sys2=add_synd(rec,h,redun,sys); 
    1394    
     1392   rec=errorRand(y,t,1);
     1393   sys2=add_synd(rec,h,redun,sys);
     1394
    13951395   tim=rtimer;
    1396    sys3=std(sys2);   
    1397    timdec=timdec+rtimer-tim;   
    1398  } 
    1399  timdec2=timdec2+rtimer-tim2; 
    1400  
     1396   sys3=std(sys2);
     1397   timdec=timdec+rtimer-tim;
     1398 }
     1399 timdec2=timdec2+rtimer-tim2;
     1400
    14011401 printf("Time for mindist: %p", timdist);
    14021402 printf("Time for GB in mindist: %p", timdist);
    14031403 printf("Time for decoding: %p", timdec2);
    14041404 printf("Time for GB in decoding: %p", timdec);
    1405  printf("Time for sysQE in decoding: %p", timdec3); 
    1406  
     1405 printf("Time for sysQE in decoding: %p", timdec3);
     1406
    14071407 option(set,vopt);
    1408 } 
    1409 example 
     1408}
     1409example
    14101410{
    14111411     "EXAMPLE:";  echo = 2;
     
    14131413     ring r=(q,a),x,dp;
    14141414     matrix check=randomCheck(redun,n,1);
    1415      
    1416      // correct 2 errors in using the code above, 50 trials 
    1417      decodeCode(check,50,2); 
     1415
     1416     // correct 2 errors in using the code above, 50 trials
     1417     decodeCode(check,50,2);
    14181418}
    14191419
     
    14261426     matrix s[redun][1]=syndrome(check,rec);
    14271427     for (int i=1; i<=redun; i++)
    1428      
    1429      {
    1430           result[i]=result[i]-s[i,1];         
     1428
     1429     {
     1430          result[i]=result[i]-s[i,1];
    14311431     }
    14321432     return(result);
     
    14481448
    14491449///////////////////////////////////////////////////////////////////////////////
    1450 // return index of an element in the ideal where it does not vanish at the 
     1450// return index of an element in the ideal where it does not vanish at the
    14511451//given point
    14521452static proc find_index (ideal G, matrix p)
     
    14881488
    14891489///////////////////////////////////////////////////////////////////////////////
    1490 // check whether given polynomial is divisible by some leading monomial of the 
     1490// check whether given polynomial is divisible by some leading monomial of the
    14911491//ideal
    14921492static proc divisible (poly m, ideal G)
     
    14941494     for (int i=1; i<=size(G); i++)
    14951495     {
    1496           if (m/leadmonom(G[i])!=0) {return(1);}         
     1496          if (m/leadmonom(G[i])!=0) {return(1);}
    14971497     }
    14981498     return(0);
     
    15031503proc vanishId (list points)
    15041504"USAGE:  vanishId (points); point is a list of matrices
    1505         'points' is a list of points for which the vanishing ideal is to be 
    1506         constructed       
     1505        'points' is a list of points for which the vanishing ideal is to be
     1506        constructed
    15071507RETURN:  Vanishing ideal corresponding to the given set of points
    1508 EXAMPLE: example vanishId; shows an example 
     1508EXAMPLE: example vanishId; shows an example
    15091509"
    15101510{
    15111511     int m=size(points[1]);
    15121512     int n=size(points);
    1513      
     1513
    15141514     ideal G=1;
    15151515     int i,k,j;
     
    15191519     //------------- proceed according to Farr-Gao algorithm ----------------
    15201520     for (k=1; k<=n; k++)
    1521      {         
     1521     {
    15221522          i=find_index(G,points[k]);
    1523           cur=G[i];         
     1523          cur=G[i];
    15241524          for(j=i+1; j<=size(G); j++)
    15251525          {
     
    15291529          temp=ideal2list(G);
    15301530          temp=delete(temp,i);
    1531           G=list2ideal(temp);         
     1531          G=list2ideal(temp);
    15321532          for (j=1; j<=m; j++)
    15331533          {
     
    15351535               {
    15361536                    attrib(G,"isSB",1);
    1537                     h=NF((x(j)-points[k][j,1])*cur,G);                   
     1537                    h=NF((x(j)-points[k][j,1])*cur,G);
    15381538                    temp=ideal2list(G);
    15391539                    temp=insert(temp,h);
    15401540                    G=list2ideal(temp);
    1541                     G=sort(G)[1];     
     1541                    G=sort(G)[1];
    15421542               }
    15431543          }
     
    15451545     attrib(G,"isSB",1);
    15461546     return(G);
    1547 } 
    1548 example 
     1547}
     1548example
    15491549{
    15501550     "EXAMPLE:";  echo = 2;
    15511551      ring r=3,(x(1..3)),dp;
    1552      
     1552
    15531553     //generate all 3-vectors over GF(3)
    15541554     list points=pointsGen(3,1);
    1555      
     1555
    15561556     list points2=convPoints(points);
    1557      
     1557
    15581558     //grasps the first 11 points
    15591559     list p=graspList(points2,1,11);
    15601560     print(p);
    1561      
     1561
    15621562     //construct the vanishing ideal
    15631563     ideal id=vanishId(p);
     
    15661566
    15671567///////////////////////////////////////////////////////////////////////////////
    1568 // construct the list of all vectors of length m with elements in p^e, where p 
     1568// construct the list of all vectors of length m with elements in p^e, where p
    15691569//is characteristics
    15701570proc pointsGen (int m, int e)
     
    15881588          count++;
    15891589          for (j=1; j<=charac^(e)-1; j++)
    1590           {               
     1590          {
    15911591               result[count][m]=a^j;
    15921592               count++;
     
    15941594          return(result);
    15951595     }
    1596      list prev=pointsGen(m-1,e);     
     1596     list prev=pointsGen(m-1,e);
    15971597     for (i=1; i<=size(prev); i++)
    15981598     {
     
    16091609     return(result);
    16101610     }
    1611      
     1611
    16121612     if (e==1)
    16131613     {
     
    16161616     int i,j;
    16171617     list l=ringlist(basering);
    1618      int charac=l[1][1];     
     1618     int charac=l[1][1];
    16191619     list tmp;
    16201620     for (i=1; i<=charac^m; i++)
     
    16251625     {
    16261626          for (j=0; j<=charac-1; j++)
    1627           {               
     1627          {
    16281628               result[count][m]=number(j);
    16291629               count++;
     
    16311631          return(result);
    16321632     }
    1633      list prev=pointsGen(m-1,e);     
     1633     list prev=pointsGen(m-1,e);
    16341634     for (i=1; i<=size(prev); i++)
    16351635     {
     
    16431643     return(result);
    16441644     }
    1645      
     1645
    16461646}
    16471647
     
    16881688{
    16891689     poly prod=1;
    1690      list rl=ringlist(basering);     
     1690     list rl=ringlist(basering);
    16911691     int charac=rl[1][1];
    16921692     int l;
     
    17301730"USAGE:    sysFL (check,y,t,e,s); check,y matrix, t,e,s int
    17311731@format
    1732           - check is a check matrix of the code, 
    1733           - y is a received word, 
     1732          - check is a check matrix of the code,
     1733          - y is a received word,
    17341734          - t the number of errors to correct,
    1735           - e is the extension degree, 
     1735          - e is the extension degree,
    17361736          - s is the dimension of the point for the vanishing ideal
    17371737@end format
    17381738RETURN:  the system of Fitzgerald-Lax for the given decoding problem
    1739 THEORY:  Based on 'check' of the given linear code, the procedure constructs 
     1739THEORY:  Based on 'check' of the given linear code, the procedure constructs
    17401740         the corresponding ideal constructed with a generalization of
    17411741         Cooper's philosophy. For basics of the method @ref{Fitzgerald-Lax method}.
     
    17441744"
    17451745{
    1746      list rl=ringlist(basering);       
    1747      int charac=rl[1][1];     
     1746     list rl=ringlist(basering);
     1747     int charac=rl[1][1];
    17481748     int n=ncols(check);
    1749      int m=nrows(check);         
     1749     int m=nrows(check);
    17501750     list points=pointsGen(s,e);
    17511751     list points2=convPoints(points);
    1752      list p=graspList(points2,1,n);     
    1753      ideal id=vanishId(p,e);     
    1754      ideal funcs=gener_funcs(check,p,e,id,s);         
    1755      
     1752     list p=graspList(points2,1,n);
     1753     ideal id=vanishId(p,e);
     1754     ideal funcs=gener_funcs(check,p,e,id,s);
     1755
    17561756     ideal result;
    17571757     poly temp;
    17581758     int i,j,k;
    1759      
     1759
    17601760     //--------------- add vanishing realtions ---------------------
    17611761     for (i=1; i<=t; i++)
    1762      {         
     1762     {
    17631763          for (j=1; j<=size(id); j++)
    17641764          {
    1765                temp=id[j];               
     1765               temp=id[j];
    17661766               for (k=1; k<=s; k++)
    17671767               {
    17681768                    temp=subst(temp,x(k),x_var(i,k,s));
    1769                }               
     1769               }
    17701770               result=result,temp;
    17711771          }
    1772      }         
    1773      
     1772     }
     1773
    17741774     //--------------- add field equations --------------------
    17751775     for (i=1; i<=t; i++)
     
    17841784          result=result,e(i)^(charac^e-1)-1;
    17851785     }
    1786      
     1786
    17871787     result=simplify(result,8);
    1788      
     1788
    17891789     //--------------- add check realtions --------------------
    17901790     poly sum;
    1791      matrix syn[m][1]=syndrome(check,y);         
     1791     matrix syn[m][1]=syndrome(check,y);
    17921792     for (i=1; i<=size(funcs); i++)
    1793      {         
     1793     {
    17941794          sum=0;
    17951795          for (j=1; j<=t; j++)
     
    18001800                    temp=subst(temp,x(k),x_var(j,k,s));
    18011801               }
    1802                sum=sum+temp*e(j);         
     1802               sum=sum+temp*e(j);
    18031803          }
    18041804          result=result,sum-syn[i,1];
    18051805     }
    1806      
     1806
    18071807     result=simplify(result,2);
    1808      
     1808
    18091809     points=points2;
    1810      export points;     
     1810     export points;
    18111811     return(result);
    1812 } 
     1812}
    18131813example
    18141814{
    18151815     "EXAMPLE:";  echo = 2;
    18161816     intvec vopt = option(get);
    1817      
     1817
    18181818     list l=FLpreprocess(3,1,11,2,"");
    18191819     def r=l[1];
    18201820     setring r;
    1821      int s_work=l[2];     
    1822      
     1821     int s_work=l[2];
     1822
    18231823     //the check matrix of [11,6,5] ternary code
    18241824     matrix h[5][11]=1,0,0,0,0,1,1,1,-1,-1,0,
     
    18331833     matrix rec[1][11]=errorInsert(y,list(2,4),list(1,-1));
    18341834
    1835      //the Fitzgerald-Lax system     
     1835     //the Fitzgerald-Lax system
    18361836     ideal sys=sysFL(h,rec,2,1,s_work);
    18371837     print(sys);
    18381838     option(redSB);
    18391839     ideal red_sys=std(sys);
    1840      red_sys; 
     1840     red_sys;
    18411841     // read the solutions from this redGB
    18421842     // the points are (0,0,1) and (0,1,0) with error values 1 and -1 resp.
    18431843     // use list points to find error positions;
    18441844     points;
    1845      
     1845
    18461846     option(set,vopt);
    18471847}
     
    18561856     {
    18571857          s++;
    1858      }     
     1858     }
    18591859     list var_ord;
    18601860     int i,j;
     
    18741874               count++;
    18751875          }
    1876      }     
    1877      
     1876     }
     1877
    18781878     list rl;
    18791879     list tmp;
    1880      
     1880
    18811881     if (e>1)
    18821882     {
     
    18861886          rl[1][2][1]=string("a");
    18871887          rl[1][3]=tmp;
    1888           rl[1][3][1]=tmp;         
     1888          rl[1][3][1]=tmp;
    18891889          rl[1][3][1][1]=string("lp");
    18901890          rl[1][3][1][2]=1;
     
    18931893          rl[1]=p;
    18941894     }
    1895      
     1895
    18961896     rl[2]=var_ord;
    1897      
     1897
    18981898     rl[3]=tmp;
    1899      rl[3][1]=tmp;     
     1899     rl[3][1]=tmp;
    19001900     rl[3][1][1]=string("lp");
    19011901     intvec v=1;
     
    19041904          v=v,1;
    19051905     }
    1906      rl[3][1][2]=v; 
     1906     rl[3][1][2]=v;
    19071907     rl[3][2]=tmp;
    1908      rl[3][2][1]=string("C");   
     1908     rl[3][2][1]=string("C");
    19091909     rl[3][2][2]=intvec(0);
    1910      
    1911      rl[4]=ideal(0);     
    1912      
     1910
     1911     rl[4]=ideal(0);
     1912
    19131913     def r2=ring(rl);
    19141914     setring r2;
    1915      list l=ringlist(r2);     
     1915     list l=ringlist(r2);
    19161916     if (e>1)
    19171917     {
    1918           execute(string("poly f="+minp));     
    1919           ideal id=f;     
     1918          execute(string("poly f="+minp));
     1919          ideal id=f;
    19201920          l[1][4]=id;
    19211921     }
    1922      
     1922
    19231923     def r=ring(l);
    1924      setring r;     
    1925      
     1924     setring r;
     1925
    19261926     return(list(r,s));
    19271927}
     
    19301930// imitating two indeces
    19311931static proc x_var (int i, int j, int s)
    1932 {     
     1932{
    19331933     return(x1(s*(i-1)+j));
    19341934}
     
    19371937// random vector of length n with entries from p^e, p the characteristic
    19381938static proc randomvector(int n, int e)
    1939 {     
     1939{
    19401940    int i;
    19411941    matrix result[n][1];
     
    19441944        result[i,1]=asElement(random_prime_vector(e));
    19451945    }
    1946     return(result);       
    1947 }
    1948 
    1949 ///////////////////////////////////////////////////////////////////////////////
    1950 // "convert" representation of an element from the field extension from vector 
     1946    return(result);
     1947}
     1948
     1949///////////////////////////////////////////////////////////////////////////////
     1950// "convert" representation of an element from the field extension from vector
    19511951//to an elelemnt
    19521952static proc asElement(list l)
     
    19551955  int i;
    19561956  number w=1;
    1957   if (size(l)>1) {w=par(1);} 
     1957  if (size(l)>1) {w=par(1);}
    19581958  for (i=0; i<=size(l)-1; i++)
    19591959  {
     
    19661966// random vector of length n with entries from p, p the characteristic
    19671967static proc random_prime_vector (int n)
    1968 { 
     1968{
    19691969  list rl=ringlist(basering);
    19701970  int i, charac;
     
    19721972  {
    19731973    if (rl[1][1] mod i ==0)
    1974     {     
     1974    {
    19751975      break;
    19761976    }
    19771977  }
    1978   charac=i; 
    1979  
     1978  charac=i;
     1979
    19801980  list l;
    1981  
     1981
    19821982  for (i=1; i<=n; i++)
    19831983  {
     
    19901990
    19911991proc decodeRandomFL(int n, int redun, int p, int e, int t, int ncodes, int ntrials, string minpol)
    1992 "USAGE:    decodeRandomFL(redun,p,e,n,t,ncodes,ntrials,minpol); 
     1992"USAGE:    decodeRandomFL(redun,p,e,n,t,ncodes,ntrials,minpol);
    19931993@format
    1994           - n is length of codes generated, redun = redundancy of codes 
    1995           generated, 
    1996           - p is characteristics, 
    1997           - e is the extension degree, 
    1998           - t is the number of errors to correct, 
     1994          - n is length of codes generated, redun = redundancy of codes
     1995          generated,
     1996          - p is characteristics,
     1997          - e is the extension degree,
     1998          - t is the number of errors to correct,
    19991999          - ncodes is the number of random codes to be processed,
    20002000          - ntrials is the number of received vectors per code to be corrected,
    2001           - minpol: due to some pecularities of SINGULAR one needs to provide 
     2001          - minpol: due to some pecularities of SINGULAR one needs to provide
    20022002          minimal polynomial for the extension explicitly
    20032003@end format
     
    20082008 intvec vopt = option(get);
    20092009
    2010  list l=FLpreprocess(p,e,n,t,minpol); 
    2011  
     2010 list l=FLpreprocess(p,e,n,t,minpol);
     2011
    20122012 def r=l[1];
    2013  int s_work=l[2]; 
     2013 int s_work=l[2];
    20142014 export(s_work);
    20152015 setring r;
    2016  
     2016
    20172017 int i,j;
    20182018 matrix h, g, word, y, rec;
    20192019 int dist, tim, tim2, tim3, timdist, timdec, timdist2, timdec2, timdec3;
    20202020 ideal sys, sys2, sys3;
    2021  list tmp; 
    2022 
    2023  option(redSB); 
    2024  matrix z[1][n]; 
    2025  
     2021 list tmp;
     2022
     2023 option(redSB);
     2024 matrix z[1][n];
     2025
    20262026 for (i=1; i<=ncodes; i++)
    20272027 {
    2028      h=randomCheck(redun,n,e);           
     2028     h=randomCheck(redun,n,e);
    20292029     g=dual_code(h);
    2030      tim2=rtimer;       
     2030     tim2=rtimer;
    20312031     tim3=rtimer;
    20322032
    2033      //---------------- generate the template system ----------------------- 
    2034      sys=sysFL(h,z,t,e,s_work);     
     2033     //---------------- generate the template system -----------------------
     2034     sys=sysFL(h,z,t,e,s_work);
    20352035     timdec3=timdec3+rtimer-tim3;
    2036    
     2036
    20372037     //------ modifying the template according to the received word ---------
    20382038     for (j=1; j<=ntrials; j++)
     
    20412041          y=encode(transpose(word),g);
    20422042          rec=errorRand(y,t,e);
    2043           sys2=LF_add_synd(rec,h,sys);   
     2043          sys2=LF_add_synd(rec,h,sys);
    20442044          tim=rtimer;
    20452045          sys3=std(sys2);
    20462046          timdec=timdec+rtimer-tim;
    2047      }           
     2047     }
    20482048     timdec2=timdec2+rtimer-tim2;
    2049  } 
    2050  
     2049 }
     2050
    20512051 printf("Time for decoding: %p", timdec2);
    20522052 printf("Time for GB in decoding: %p", timdec);
    2053  printf("Time for generating Fitzgerald-Lax system during decoding: %p", timdec3); 
    2054  
     2053 printf("Time for generating Fitzgerald-Lax system during decoding: %p", timdec3);
     2054
    20552055 option(set,vopt);
    2056 } 
     2056}
    20572057example
    20582058{
    20592059     "EXAMPLE:";  echo = 2;
    2060      
    2061      // correcting one error for one random binary code of length 25, 
     2060
     2061     // correcting one error for one random binary code of length 25,
    20622062     //redundancy 14; 300 words are processed
    20632063     decodeRandomFL(25,14,2,1,1,1,300,"");
     
    20842084
    20852085"EXAMPLE:";  echo = 2;
    2086 int q=128; int n=120; int redun=n-30; 
     2086int q=128; int n=120; int redun=n-30;
    20872087ring r=(q,a),x,dp;
    20882088decodeRandom(n,redun,1,1,6);
    20892089
    2090 int q=128; int n=120; int redun=n-20; 
     2090int q=128; int n=120; int redun=n-20;
    20912091ring r=(q,a),x,dp;
    20922092decodeRandom(n,redun,1,1,9);
     
    21062106
    21072107"EXAMPLE:";  echo = 2;
    2108 int q=128; int n=120; int redun=n-40; 
     2108int q=128; int n=120; int redun=n-40;
    21092109ring r=(q,a),x,dp;
    21102110decodeRandom(n,redun,1,1,6);
     
    21192119decodeRandom(n,redun,1,1,24);
    21202120
    2121 int q=256; int n=150; int redun=n-10; 
     2121int q=256; int n=150; int redun=n-10;
    21222122ring r=(q,a),x,dp;
    21232123decodeRandom(n,redun,1,1,26);
     
    21562156setring A;
    21572157print(qe);
    2158 ideal red_qe=stdfglm(qe); 
     2158ideal red_qe=stdfglm(qe);
    21592159
    21602160*/
  • Singular/LIB/discretize.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: discretize.lib,v 1.4 2009-01-07 16:11:35 Singular Exp $";
     2version="$Id: discretize.lib,v 1.5 2009-01-14 16:07:04 Singular Exp $";
    33category="Applications";
    44info="
     
    108108RETURN:  string
    109109PURPOSE: replaces in 's' all the substrings 'what' with substring 'with'
    110 NOTE: 
     110NOTE:
    111111EXAMPLE: example replace; shows examples
    112112"{
     
    419419      if ( (sout[i]=="+") || (sout[i]=="-") )
    420420      {
    421         NisPoly = 1;
     421        NisPoly = 1;
    422422      }
    423423    }
     
    709709 " ideal I = decoef(p,dt);";
    710710 " difpoly2tex(I,L);";
    711  difpoly2tex(I,L); // the nodal form of the scheme in TeX 
     711 difpoly2tex(I,L); // the nodal form of the scheme in TeX
    712712 "* Preparations for the semi-factorized form: ";
    713713 poly pi1 = subst(I[2],B,0);
  • Singular/LIB/dmod.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: dmod.lib,v 1.33 2008-12-23 21:39:31 levandov Exp $";
     2version="$Id: dmod.lib,v 1.34 2009-01-14 16:07:04 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    12851285  {
    12861286    bs[i-1] = P[1][i]; bs[i-1] = subst(bs[i-1],s,-s-1);
    1287     m[i-1]  = P[2][i]; 
     1287    m[i-1]  = P[2][i];
    12881288  }
    12891289  int sP = minIntRoot(bs,1);
     
    14651465  dbprint(ppl,"// -2-1- the ring @R3 i.e. K[s] is ready");
    14661466  ideal K3 = imap(@R2,K2);
    1467   poly p = K3[1]; 
     1467  poly p = K3[1];
    14681468  p = s*p; // mult with the lost (s+1) factor
    14691469  dbprint(ppl,"// -2-2- factorization");
     
    14801480  {
    14811481    bs[i-1] = P[1][i]; bs[i-1] = subst(bs[i-1],s,-s-1);
    1482     m[i-1]  = P[2][i]; 
     1482    m[i-1]  = P[2][i];
    14831483  }
    14841484  int sP = minIntRoot(bs,1);
     
    19231923      if ( leadmonom(K[i,2]) == 1)
    19241924      {
    1925         t = K[i,1];
    1926         n = leadcoef(K[i,2]);
    1927         t = t/n;
    1928         //        J = J, K[i][2];
    1929         break;
     1925        t = K[i,1];
     1926        n = leadcoef(K[i,2]);
     1927        t = t/n;
     1928        //        J = J, K[i][2];
     1929        break;
    19301930      }
    19311931    }
     
    35613561  kill s;
    35623562  kill NName;
    3563   tmp[1]      = "C"; 
     3563  tmp[1]      = "C";
    35643564  Lord[2]     = tmp;  tmp = 0;
    35653565  L[3]        = Lord;
  • Singular/LIB/dmodapp.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: dmodapp.lib,v 1.15 2009-01-12 19:31:23 Singular Exp $";
     2version="$Id: dmodapp.lib,v 1.16 2009-01-14 16:07:04 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    99GUIDE: Let R = K[x1,..xN] and D be the Weyl algebra in variables x1,..xN,d1,..dN.
    1010In this library there are the following procedures for algebraic D-modules:
    11 @* - localization of a holonomic module D/I with respect to a mult. closed set 
     11@* - localization of a holonomic module D/I with respect to a mult. closed set
    1212of all powers of a given polynomial F from R. Our aim is to compute an ideal L
    13 in D, such that D/L is a presentation of a localized module. Such L always exists, since 
    14 such localizations are known to be holonomic and thus cyclic modules. 
     13in D, such that D/L is a presentation of a localized module. Such L always exists, since
     14such localizations are known to be holonomic and thus cyclic modules.
    1515The procedures for the localization are DLoc, SDLoc and DLoc0.
    1616
     
    423423  {
    424424    return(I);
    425   } 
     425  }
    426426  int j,i,s,m;
    427427  list l;
     
    442442      else
    443443      {
    444         if (s > m)
    445         {
    446           m = s;
    447           g = l[i][2];
    448         }
     444        if (s > m)
     445        {
     446          m = s;
     447          g = l[i][2];
     448        }
    449449      }
    450450    }
     
    587587
    588588
    589 proc appelF1() 
     589proc appelF1()
    590590"USAGE:  appelF1();
    591591RETURN:  ring
     
    613613  "EXAMPLE:"; echo = 2;
    614614  ring r = 0,x,dp;
    615   def A = appelF1(); 
     615  def A = appelF1();
    616616  setring A;
    617617  IAppel1;
     
    643643  "EXAMPLE:"; echo = 2;
    644644  ring r = 0,x,dp;
    645   def A = appelF2(); 
     645  def A = appelF2();
    646646  setring A;
    647647  IAppel2;
    648648}
    649649
    650 proc appelF4() 
     650proc appelF4()
    651651"USAGE:  appelF4();
    652652RETURN:  ring
     
    673673  "EXAMPLE:"; echo = 2;
    674674  ring r = 0,x,dp;
    675   def A = appelF4(); 
     675  def A = appelF4();
    676676  setring A;
    677677  IAppel4;
     
    716716PURPOSE: check whether the ideal I is F-saturated
    717717NOTE:    1 is returned if I is F-saturated, otherwise 0 is returned.
    718 @*   we check indeed that Ker(D --F--> D/I) is (0) 
     718@*   we check indeed that Ker(D --F--> D/I) is (0)
    719719EXAMPLE: example isFsat; shows examples
    720720"
     
    13321332  LD;
    13331333  // Now, compare with the output of Macaulay2:
    1334   ideal tst = 3*x*Dx + 2*y*Dy + 1, y^3*Dy^2 - x^2*Dy^2 + 6*y^2*Dy + 6*y, 
    1335 9*y^2*Dx^2*Dy - 4*y*Dy^3 + 27*y*Dx^2 + 2*Dy^2, 9*y^3*Dx^2 - 4*y^2*Dy^2 + 10*y*Dy -10; 
     1334  ideal tst = 3*x*Dx + 2*y*Dy + 1, y^3*Dy^2 - x^2*Dy^2 + 6*y^2*Dy + 6*y,
     13359*y^2*Dx^2*Dy - 4*y*Dy^3 + 27*y*Dx^2 + 2*Dy^2, 9*y^3*Dx^2 - 4*y^2*Dy^2 + 10*y*Dy -10;
    13361336 option(redSB); option(redTail);
    13371337 LD = groebner(LD);
     
    14051405}
    14061406
    1407 /* DIFFERENT EXAMPLES 
     1407/* DIFFERENT EXAMPLES
    14081408
    14091409//static proc exCusp()
     
    15041504*/
    15051505
    1506 proc engine(ideal I, int i) 
     1506proc engine(ideal I, int i)
    15071507"USAGE:  engine(I,i);  I an ideal, i an int
    15081508RETURN:  ideal
     
    15271527  return(J);
    15281528}
    1529 example 
     1529example
    15301530{
    15311531  "EXAMPLE:"; echo = 2;
     
    15621562    else
    15631563    {
    1564       if (inp1 == "ideal") 
     1564      if (inp1 == "ideal")
    15651565      {
    1566         ERROR("second argument has to be a poly if first argument is an ideal");
     1566        ERROR("second argument has to be a poly if first argument is an ideal");
    15671567      }
    15681568      else { vector f = #[2]; }
     
    15791579      if (k<=0)
    15801580      {
    1581         ERROR("third argument has to be positive");
     1581        ERROR("third argument has to be positive");
    15821582      }
    15831583    }
  • Singular/LIB/elim.lib

    r95edd5 r7f3ad4  
    1 // $Id: elim.lib,v 1.25 2008-11-13 10:50:17 Singular Exp $
    2 ///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: elim.lib,v 1.25 2008-11-13 10:50:17 Singular Exp $";
     1// $Id: elim.lib,v 1.26 2009-01-14 16:07:04 Singular Exp $
     2///////////////////////////////////////////////////////////////////////////////
     3version="$Id: elim.lib,v 1.26 2009-01-14 16:07:04 Singular Exp $";
    44category="Commutative Algebra";
    55info="
     
    186186///////////////////////////////////////////////////////////////////////////////
    187187proc elimRing ( poly vars, list #)
    188 "USAGE:   elimRing(vars [,w]); vars = product of variables to be eliminated 
     188"USAGE:   elimRing(vars [,w]); vars = product of variables to be eliminated
    189189         (type poly), w = intvec (specifying weights for all variables)
    190 RETURN:  a ring, say R, s.t. the monomial ordering of R has 2 blocks. 
     190RETURN:  a ring, say R, s.t. the monomial ordering of R has 2 blocks.
    191191         The first block corresponds to the (given) variables to be eliminated
    192          and has ordering dp if these variables have weight all 1; if w is 
    193          given or if not all variables in vars have weight 1 the ordering is 
    194          wp(w1) where w1 is the intvec of weights of the variables to be 
    195          eliminated. 
    196          The second block corresponds to variables not to be eliminated. 
    197 @*       If the first variable not to be eliminated is global (i.e. > 1), 
    198          resp. local (i.e. < 1), the second block has ordering dp, resp. ds, 
    199          (or wp(w2), resp. ws(w2), where w2 is the intvec of weights of the 
     192         and has ordering dp if these variables have weight all 1; if w is
     193         given or if not all variables in vars have weight 1 the ordering is
     194         wp(w1) where w1 is the intvec of weights of the variables to be
     195         eliminated.
     196         The second block corresponds to variables not to be eliminated.
     197@*       If the first variable not to be eliminated is global (i.e. > 1),
     198         resp. local (i.e. < 1), the second block has ordering dp, resp. ds,
     199         (or wp(w2), resp. ws(w2), where w2 is the intvec of weights of the
    200200         variables not to be eliminated).
    201 @*       If the basering is a quotient ring P/Q, then R a quotient ring 
     201@*       If the basering is a quotient ring P/Q, then R a quotient ring
    202202         with Q replaced by a standard basis of Q w.r.t. the new ordering
    203          (parameters are not touched). 
     203         (parameters are not touched).
    204204NOTE:    The ordering in R is an elimination ordering for the variables
    205205         appearing in vars.
    206 PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by 
    207          computing a standard basis in R with a fast monomial ordering. 
     206PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by
     207         computing a standard basis in R with a fast monomial ordering.
    208208         This procedure is used by the procedure elim.
    209209EXAMPLE: example elimRing; shows an example
     
    219219  {
    220220    if ( typeof(#[1]) == "intvec" )
    221     { 
     221    {
    222222       @w = #[1];              //take the given weights
    223223    }
     
    236236  {
    237237     if( vars/var(ii)==0 )    //treat variables not to be eliminated
    238      { 
     238     {
    239239        w2 = w2,@w[ii];
    240240        v2 = v2+list(string(var(ii)));
     
    244244         }
    245245     }
    246      else 
     246     else
    247247     {
    248248        w1 = w1,@w[ii];
     
    263263
    264264  w1 = w1[2..size(w1)];
    265   w2 = w2[2..size(w2)]; 
     265  w2 = w2[2..size(w2)];
    266266
    267267  //--- put variables to be eliminated in front:
    268   BRlist[2] = v1 + v2; 
    269              
     268  BRlist[2] = v1 + v2;
     269
    270270  //--- create a block ordering with two blocks and weights:
    271271  int nblock = size(BRlist[3]);      //number of blocks
     
    318318  }
    319319
    320   def eRing = ring(quotientList(BRlist)); 
     320  def eRing = ring(quotientList(BRlist));
    321321  return (eRing);
    322322}
     
    327327   intvec w = 1,1,3,4,5;
    328328   elimRing(yu,w);
    329  
     329
    330330   ring S =  (0,a),(x,y,z,u,v),ws(1,2,3,4,5);
    331331   minpoly = a2+1;
    332332   qring T = std(ideal(x+y2+v3,(x+v)^2));
    333    def Q = elimRing(yv); 
     333   def Q = elimRing(yv);
    334334   setring Q; Q;
    335335}
     
    337337
    338338proc elim (id, list #)
    339 "USAGE:   elim(id,arg[,\"withWeights\"]);  id ideal/module, arg can be either 
    340         an intvec vor a product p of variables (type poly) 
    341 RETURN: ideal/module obtained from id by eliminating either the variables 
    342         with indices appearing in v or the variables appearing in p. 
     339"USAGE:   elim(id,arg[,\"withWeights\"]);  id ideal/module, arg can be either
     340        an intvec vor a product p of variables (type poly)
     341RETURN: ideal/module obtained from id by eliminating either the variables
     342        with indices appearing in v or the variables appearing in p.
    343343        Works also in a qring.
    344344METHOD: elim uses elimRing to create a ring with block ordering with two
    345         blocks where the first block contains the variables to be eliminated 
     345        blocks where the first block contains the variables to be eliminated
    346346        and then uses groebner. If the variables in the basering have weights
    347347        these weights are used in elimRing.
    348 @*      If a string \"withWeigts\" as second, optional argument is given, 
    349         Singular computes weights for the variables to make the input as 
     348@*      If a string \"withWeigts\" as second, optional argument is given,
     349        Singular computes weights for the variables to make the input as
    350350        homogeneous as possible.
    351351@*      The method is different from that used by eliminate and elim1;
    352352        in some examples elim can be significantly faster.
    353 NOTE:   No special monomial ordering is required, i.e. the ordering can be 
    354         local or mixed. The result is a SB with respect to the ordering of 
    355         the second block used by elimRing. E.g. if the first var not to be 
    356         eliminated is global, resp. local, this ordering is dp, resp. ds 
    357         (or wp, resp. ws, with the given weights for these variables). 
    358         If printlevel > 0 the ring for which the output is a SB is shown. 
     353NOTE:   No special monomial ordering is required, i.e. the ordering can be
     354        local or mixed. The result is a SB with respect to the ordering of
     355        the second block used by elimRing. E.g. if the first var not to be
     356        eliminated is global, resp. local, this ordering is dp, resp. ds
     357        (or wp, resp. ws, with the given weights for these variables).
     358        If printlevel > 0 the ring for which the output is a SB is shown.
    359359SEE ALSO: eliminate, elim1
    360360EXAMPLE: example elim; shows an example
    361361"
    362 { 
     362{
    363363  if (size(#) == 0)
    364364  {
     
    369369//-------------------------------- check input -------------------------------
    370370  poly vars;
    371   int ii; 
     371  int ii;
    372372  if (size(#) > 0)
    373373  {
    374374    if ( typeof(#[1]) == "poly" )
    375     { 
     375    {
    376376      vars = #[1];
    377377    }
    378378    if ( typeof(#[1]) == "intvec")
    379     { 
     379    {
    380380      vars=1;
    381       for( ii=1; ii<=size(#[1]); ii++ ) 
    382       { 
    383         vars=vars*var(#[1][ii]); 
     381      for( ii=1; ii<=size(#[1]); ii++ )
     382      {
     383        vars=vars*var(#[1][ii]);
    384384      }
    385385    }
     
    388388  {
    389389    if ( typeof(#[2]) == "string" )
    390     { 
     390    {
    391391       if ( #[2] == "withWeights" )
    392        { 
     392       {
    393393         intvec @w = weight(id);
    394394       }
     
    411411  id = groebner(id);
    412412  id = nselect(id,1..size(ringlist(ER)[3][1][2]));
    413   if ( pr > 0 ) 
    414   { 
     413  if ( pr > 0 )
     414  {
    415415     "// result is a SB in the following ring:";
    416416     ER;
     
    424424   ideal i=x-u,y-u2,w-u3,v-x+y3;
    425425   elim(i,3..4);
    426    elim(i,uv); 
     426   elim(i,uv);
    427427   int p = printlevel;
    428428   printlevel = 2;
  • Singular/LIB/findifs.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: findifs.lib,v 1.3 2009-01-07 16:11:35 Singular Exp $";
     2version="$Id: findifs.lib,v 1.4 2009-01-14 16:07:04 Singular Exp $";
    33category="Applications";
    44info="
     
    66AUTHORS: Viktor Levandovskyy,     levandov@risc.uni-linz.ac.at
    77
    8 THEORY: We provide the presentation of difference operators in a polynomial, 
    9         semi-factorized and a nodal form. Running @code{findifs_example();} 
    10         will show how we generate finite difference schemes of linear PDE's 
     8THEORY: We provide the presentation of difference operators in a polynomial,
     9        semi-factorized and a nodal form. Running @code{findifs_example();}
     10        will show how we generate finite difference schemes of linear PDE's
    1111        from given approximations.
    1212
     
    6767RETURN:  string
    6868PURPOSE: converts special characters to TeX in s
    69 NOTE: the convention is the following: 
    70       'Tx' goes to 'T_x', 
     69NOTE: the convention is the following:
     70      'Tx' goes to 'T_x',
    7171      'dx' to '\\tri x' (the same for dt, dy, dz),
    7272      'theta', 'ro', 'A', 'V' are converted to greek letters.
     
    114114RETURN:  string
    115115PURPOSE: replaces in 's' all the substrings 'what' with substring 'with'
    116 NOTE: 
     116NOTE:
    117117EXAMPLE: example replace; shows examples
    118118"{
     
    425425      if ( (sout[i]=="+") || (sout[i]=="-") )
    426426      {
    427         NisPoly = 1;
     427        NisPoly = 1;
    428428      }
    429429    }
     
    722722 " ideal I = decoef(p,dt);";
    723723 " difpoly2tex(I,L);";
    724  difpoly2tex(I,L); // the nodal form of the scheme in TeX 
     724 difpoly2tex(I,L); // the nodal form of the scheme in TeX
    725725 "* Preparations for the semi-factorized form: ";
    726726 poly pi1 = subst(I[2],B,0);
  • Singular/LIB/freegb.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: freegb.lib,v 1.14 2009-01-14 15:48:37 Singular Exp $";
     2version="$Id: freegb.lib,v 1.15 2009-01-14 16:07:04 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    1010freegbasis(L, int n);   compute two-sided Groebner basis of ideal, encoded via L, up to degree n
    1111
    12 AUXILIARY PROCEDURES: 
     12AUXILIARY PROCEDURES:
    1313
    1414lp2lstr(K, s);      convert letter-place ideal to a list of modules
     
    310310"USAGE:  isVar(p);  poly p
    311311RETURN:  int
    312 PURPOSE: checks whether p is a power of a single variable from the basering. 
     312PURPOSE: checks whether p is a power of a single variable from the basering.
    313313@* Returns the exponent or 0 is p is not a power of  a single variable.
    314314EXAMPLE: example isVar; shows examples
     
    913913}
    914914
    915 /* EXAMPLES: 
     915/* EXAMPLES:
    916916
    917917//static proc ex_shift()
     
    10651065}
    10661066
    1067 // END COMMENTED EXAMPLES 
     1067// END COMMENTED EXAMPLES
    10681068
    10691069*/
     
    15311531  // Adem rels modulo 2 are interesting
    15321532
    1533 //static 
     1533//static
    15341534proc stringpoly2lplace(string s)
    15351535{
     
    17061706}
    17071707
    1708 //static 
     1708//static
    17091709proc sent2lplace(string s)
    17101710{
     
    21022102{
    21032103  "EXAMPLE:"; echo = 2;
    2104   intmat A[3][3] = 
     2104  intmat A[3][3] =
    21052105    2, -1, 0,
    21062106    -1, 2, -3,
     
    23452345}
    23462346
    2347 /* EXAMPLES AGAIN: 
     2347/* EXAMPLES AGAIN:
    23482348//static proc get_ls3nilp()
    23492349{
  • Singular/LIB/general.lib

    r95edd5 r7f3ad4  
    33//eric, added absValue 11.04.2002
    44///////////////////////////////////////////////////////////////////////////////
    5 version="$Id: general.lib,v 1.58 2008-12-12 11:26:34 Singular Exp $";
     5version="$Id: general.lib,v 1.59 2009-01-14 16:07:04 Singular Exp $";
    66category="General purpose";
    77info="
     
    197197   binomial(200,100);"";                 //type bigint
    198198   int n,k = 200,100;
    199    bigint b1 = binomial(n,k);           
     199   bigint b1 = binomial(n,k);
    200200   ring r = 0,x,dp;
    201201   poly b2 = coeffs((x+1)^n,x)[k+1,1];  //coefficient of x^k in (x+1)^n
     
    10881088          def watchdog_rneu=basering;
    10891089          setring rsave;
    1090           if (!defined(result))
    1091           {
    1092             def result=fetch(watchdog_rneu,result);
    1093           }
     1090          if (!defined(result))
     1091          {
     1092            def result=fetch(watchdog_rneu,result);
     1093          }
    10941094        }
    10951095        if(defined(watchdog_interrupt))
  • Singular/LIB/jacobson.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: jacobson.lib,v 1.7 2009-01-07 16:11:37 Singular Exp $";
     2version="$Id: jacobson.lib,v 1.8 2009-01-14 16:07:04 Singular Exp $";
    33category="System and Control Theory";
    44info="
     
    66AUTHOR: Kristina Schindelar,     Kristina.Schindelar@math.rwth-aachen.de
    77
    8 THEORY: We work over a ring R, that is a principal ideal domain. 
     8THEORY: We work over a ring R, that is a principal ideal domain.
    99@*   If R is commutative, we suppose R to be a polynomial ring in one variable.
    10 @* If R is non-commutative, we suppose R to be in two variables, say x and d. 
     10@* If R is non-commutative, we suppose R to be in two variables, say x and d.
    1111@* We treat then the basering as principal ideal ring with d a polynomial
    12 @* variable and x an invertible one. That is, we work in the Ore localization of R 
    13 @* with respect to the mult. closed set S = K[x] without 0. 
     12@* variable and x an invertible one. That is, we work in the Ore localization of R
     13@* with respect to the mult. closed set S = K[x] without 0.
    1414@* Note, that in computations no division by x will actually happen.
    15 @*   Given a rectangular matrix M over R, one can compute unimodular (that is invertible) 
    16 @* square matrices U and V, such that U*M*V=D is a diagonal matrix. 
     15@*   Given a rectangular matrix M over R, one can compute unimodular (that is invertible)
     16@* square matrices U and V, such that U*M*V=D is a diagonal matrix.
    1717@*   Depending on the ring, the diagonal entries of D have certain properties.
    1818
    19 REFERENCES: 
     19REFERENCES:
    2020@* N. Jacobson, 'The theory of rings', AMS, 1943.
    2121@* Manuel Avelino Insua Hermo, 'Varias perspectives sobre las bases de Groebner: Forma normal de Smith, Algorithme de Berlekamp y algebras de Leibniz'. PhD thesis, Universidad de Santiago de Compostela, 2005.
     
    3535"USAGE: smith(M[, eng1, eng2]);  M matrix, eng1 and eng2 are optional integers
    3636RETURN: matrix or list
    37 ASSUME: The current ring is assumed to be the commutative polynomial ring in 
     37ASSUME: The current ring is assumed to be the commutative polynomial ring in
    3838        one variable
    3939PURPOSE: compute the Smith Normal Form of M with transformation matrices (optionally)
    40 NOTE: If the optional integer eng1 is non-zero, returns the list {U,D,V}, 
     40NOTE: If the optional integer eng1 is non-zero, returns the list {U,D,V},
    4141where U*M*V = D and the diagonal field entries of D are not normalized.
    4242@*    Otherwise only the matrix D, that is the Smith Normal Form of M, is returned.
     
    4848EXAMPLE: example smith; shows examples
    4949"
    50 { 
     50{
    5151  def R = basering;
    5252  // check assume: R must be a polynomial ring in 1 variable
     
    7070  {
    7171  BASIS=#[2];
    72   } 
     72  }
    7373  else{BASIS=0;}
    74  
     74
    7575
    7676  int ROW=ncols(MA);
     
    100100  if(eng==1)
    101101  {
    102     list rueckLI=diagonal_with_trafo(R,MA,BASIS); 
     102    list rueckLI=diagonal_with_trafo(R,MA,BASIS);
    103103    list rueckLII=divisibility(rueckLI[2]);
    104104    matrix CON=divideByContent(rueckLII[2]);
     
    108108  else
    109109  {
    110     matrix rueckm=diagonal_without_trafo(R,MA,BASIS); 
     110    matrix rueckm=diagonal_without_trafo(R,MA,BASIS);
    111111    list rueckL=divisibility(rueckm);
    112112    matrix CON=divideByContent(rueckm);
     
    152152  if(k==0){adrow++;}
    153153  }
    154    
     154
    155155    m=transpose(m);
    156156    for(i=1;i<=adrow;i++){m=m,0;}
     
    181181
    182182    int s,st,p,ff;
    183    
     183
    184184    module LT,TSTD;
    185185    module STD=transpose(m);
     
    189189    matrix END;
    190190    matrix ENDSTD;
    191     matrix STDFIN; 
    192     STDFIN=STD; 
     191    matrix STDFIN;
     192    STDFIN=STD;
    193193    list COMPARE=STDFIN;
    194194
     
    200200      {
    201201        STD_EX=EXL,transpose(STD);
    202       } 
    203       else 
     202      }
     203      else
    204204      {
    205205        STD_EX=EXR,transpose(STD);
    206206      }
    207         dbprint(ppl,"Computing Groebner basis: start");
    208         dbprint(ppl-1,STD);
     207        dbprint(ppl,"Computing Groebner basis: start");
     208        dbprint(ppl-1,STD);
    209209      STD=engine(STD,BASIS);
    210         dbprint(ppl,"Computing Groebner basis: finished");
    211         dbprint(ppl-1,STD);
     210        dbprint(ppl,"Computing Groebner basis: finished");
     211        dbprint(ppl-1,STD);
    212212
    213213      if(flag mod 2==1){s=ROW; st=COL;}else{s=COL; st=ROW;}
    214         dbprint(ppl,"Computing Groebner basis for transformation matrix: start");
    215         dbprint(ppl-1,STD_EX);
     214        dbprint(ppl,"Computing Groebner basis for transformation matrix: start");
     215        dbprint(ppl-1,STD_EX);
    216216      STD_EX=transpose(STD_EX);
    217217      STD_EX=engine(STD_EX,BASIS);
    218         dbprint(ppl,"Computing Groebner basis for transformation matrix: finished");
    219         dbprint(ppl-1,STD_EX);
     218        dbprint(ppl,"Computing Groebner basis for transformation matrix: finished");
     219        dbprint(ppl-1,STD_EX);
    220220
    221221      //////// split STD_EX in STD and the transformation matrix
     
    241241
    242242      ////////////////////// compute the transformation matrices
    243      
     243
    244244      if (flag mod 2 ==1)
    245       { 
     245      {
    246246        TrafoL=transpose(LT)*TrafoL;
    247247      }
    248       else 
    249       { 
     248      else
     249      {
    250250        TrafoR=TrafoR*LT;
    251251      }
    252252
    253253
    254       STDFIN=STD; 
     254      STDFIN=STD;
    255255      /////////////////////////////////// check if the D-th row is finished ///////////////////////////////////
    256256      COMPARE=insert(COMPARE,STDFIN);
    257         if(size(COMPARE)>=3)
    258        {   
     257             if(size(COMPARE)>=3)
     258       {
    259259        if(STD==COMPARE[3]){finish=1;}
    260260       }
     
    268268
    269269   if (flag mod 2!=0) { STD=transpose(STD); }
    270    
    271    
     270
     271
    272272   //zero colums to the end
    273273    matrix STDMM=STD;
     
    278278      for(i=1; i<=ncols(STDMM); i++)
    279279      {
    280         ff=0; 
     280        ff=0;
    281281        for(j=1; j<=nrows(STDMM); j++)
    282282        {
     
    291291    int fehlposc=fehlpos;
    292292    module SORT;
    293     for(i=1; i<=fehlpos; i++) 
     293    for(i=1; i<=fehlpos; i++)
    294294    {
    295295      SORT=gen(2);
    296296      for (j=3;j<=ROW;j++)
    297       { 
     297      {
    298298        SORT=SORT,gen(j);
    299299      }
     
    308308    fehlpos=0;
    309309    while( size(transpose(STD))+fehlpos-ncols(STDMM) < 0)
    310     { 
     310    {
    311311      for(i=1; i<=ncols(STDMM); i++)
    312312      {
     
    319319    int fehlposr=fehlpos;
    320320
    321     for(i=1; i<=fehlpos; i++) 
     321    for(i=1; i<=fehlpos; i++)
    322322    {
    323323      SORT=gen(2);
     
    328328      TrafoL=SORT*TrafoL;
    329329    }
    330      
     330
    331331    setring R;
    332332    map MAPinv=r,var(1);
     
    338338    matrix STDM=STD;
    339339
    340     //Test 
     340    //Test
    341341    if(TrafoLM*m*TrafoRM!=STDM){ return(0); }
    342    
     342
    343343    list RUECK=TrafoRM;
    344344    RUECK=insert(RUECK,STDM);
     
    393393      for(j=i+1; j<=Sort; j++)
    394394      {
    395         GCDL=UNITL;
    396         GCDR=UNITR;
    397         G=gcd(STDM[i,i],STDM[j,j]);
    398         ideal Z=STDM[i,i],STDM[j,j];
    399         matrix T=lift(Z,G);
    400         GCDL[i,i]=T[1,1];
    401         GCDL[i,j]=T[2,1];
    402         GCDL[j,i]=-STDM[j,j]/G;
    403         GCDL[j,j]=STDM[i,i]/G;
    404         GCDR[i,j]=T[2,1]*STDM[j,j]/G;
    405         GCDR[j,j]=T[2,1]*STDM[j,j]/G-1;
    406         GCDR[j,i]=1;
    407         STDM=GCDL*STDM*GCDR;
    408         TrafoLM=GCDL*TrafoLM;
    409         TrafoRM=TrafoRM*GCDR;
     395        GCDL=UNITL;
     396        GCDR=UNITR;
     397        G=gcd(STDM[i,i],STDM[j,j]);
     398        ideal Z=STDM[i,i],STDM[j,j];
     399        matrix T=lift(Z,G);
     400        GCDL[i,i]=T[1,1];
     401        GCDL[i,j]=T[2,1];
     402        GCDL[j,i]=-STDM[j,j]/G;
     403        GCDL[j,j]=STDM[i,i]/G;
     404        GCDR[i,j]=T[2,1]*STDM[j,j]/G;
     405        GCDR[j,j]=T[2,1]*STDM[j,j]/G-1;
     406        GCDR[j,i]=1;
     407        STDM=GCDL*STDM*GCDR;
     408        TrafoLM=GCDL*TrafoLM;
     409        TrafoRM=TrafoRM*GCDR;
    410410      }
    411411    }
     
    418418static proc diagonal_without_trafo( R, matrix MA, int B)
    419419{
    420   int ppl = printlevel-voice+2; 
     420  int ppl = printlevel-voice+2;
    421421
    422422  int BASIS=B;
     
    452452    int finish=0;
    453453    matrix STDFIN;
    454     STDFIN=STD; 
     454    STDFIN=STD;
    455455    list COMPARE=STDFIN;
    456456
     
    463463      dbprint(ppl,"Computing Groebner basis: finished");
    464464      dbprint(ppl-1,STD);
    465       STDFIN=STD; 
     465      STDFIN=STD;
    466466      /////////////////////////////////// check if the D-th row is finished ///////////////////////////////////
    467467      COMPARE=insert(COMPARE,STDFIN);
    468         if(size(COMPARE)>=3)
    469        {   
     468             if(size(COMPARE)>=3)
     469       {
    470470        if(STD==COMPARE[3]){finish=1;}
    471        }     
    472         ////////////////////////////////// change to the opposite module
    473 
    474         TSTD=transpose(STD);
    475         STD=TSTD;
    476         flag++;
     471       }
     472        ////////////////////////////////// change to the opposite module
     473
     474        TSTD=transpose(STD);
     475        STD=TSTD;
     476        flag++;
    477477        dbprint(ppl,"Finished one while cycle");
    478478    }
     
    485485      for(i=1; i<=ncols(STDMM); i++)
    486486      {
    487         ff=0; 
     487        ff=0;
    488488        for(j=1; j<=nrows(STDMM); j++)
    489489        {
     
    498498   int fehlposc=fehlpos;
    499499    module SORT;
    500     for(i=1; i<=fehlpos; i++) 
     500    for(i=1; i<=fehlpos; i++)
    501501    {
    502502      SORT=gen(2);
    503503      for (j=3;j<=ROW;j++)
    504       { 
     504      {
    505505        SORT=SORT,gen(j);
    506506      }
     
    514514    fehlpos=0;
    515515    while( size(transpose(STD))+fehlpos-ncols(STDMM) < 0)
    516     { 
     516    {
    517517      for(i=1; i<=ncols(STDMM); i++)
    518518      {
     
    525525    int fehlposr=fehlpos;
    526526
    527     for(i=1; i<=fehlpos; i++) 
     527    for(i=1; i<=fehlpos; i++)
    528528    {
    529529      SORT=gen(2);
     
    533533      STD=SORT*STD;
    534534    }
    535    
     535
    536536   //add zero rows or columns
    537537
     
    573573proc jacobson(matrix MA, list #)
    574574 "USAGE:  jacobson(M, eng);  M matrix, eng an optional int
    575 RETURN: list 
     575RETURN: list
    576576ASSUME: Basering is a noncommutative ring in two variables.
    577577PURPOSE: compute a weak Jacobson Normal Form of M over a noncommutative ring
     
    585585EXAMPLE: example jacobson; shows examples
    586586"
    587 { 
     587{
    588588  def R = basering;
    589589  // check assume: R must be a polynomial ring in 2 variables
     
    626626  def r=ring(RINGLIST);
    627627  setring r;
    628  
     628
    629629  //fix the required ordering
    630630  map MAP=R,var(1),var(2);
     
    638638  module m=TRIANGLE[2];
    639639
    640   //back to the ring 
     640  //back to the ring
    641641  setring R;
    642642  map MAPR=r,var(1),var(2);
     
    646646  module TR=MAPR(TrafoR);
    647647  matrix CON=divideByContent(MAA);
    648  
     648
    649649list RUECK=CON*TL, CON*MAA, TR;
    650650return(RUECK);
    651651}
    652652example
    653 { 
     653{
    654654  "EXAMPLE:"; echo = 2;
    655655  ring r = 0,(x,d),Dp;
     
    663663  def R2 = nc_algebra(1,s);   setring R2; // the 1st shift algebra
    664664  matrix m[2][2] = s,x,0,s; print(m); // matrix of the same for as above
    665   list J = jacobson(m); 
     665  list J = jacobson(m);
    666666  print(J[2]); // a Jacobson Form D, quite different from above
    667667  print(J[1]*m*J[3] - J[2]); // check that U*M*V = D
     
    670670static proc triangle( matrix MA, int B)
    671671{
    672  int ppl = printlevel-voice+2; 
     672 int ppl = printlevel-voice+2;
    673673
    674674  map inv=ncdetection();
     
    713713    module STD_EX,LT,TSTD, L, Trafo;
    714714
    715    
    716    
     715
     716
    717717    module STD=transpose(m);
    718718    int finish=0;
     
    734734      dbprint(ppl-1,STD);
    735735      if(flag mod 2==1){s=ROW; st=COL;}else{s=COL; st=ROW;}
    736  
     736
    737737      STD_EX=transpose(STD_EX);
    738738      dbprint(ppl,"Computing Groebner basis for transformation matrix: start");
     
    745745      COM_EX=1;
    746746      for(i=2; i<=size(STD); i++)
    747          { COM=COM[1..size(COM)],i; COM_EX=COM_EX[1..size(COM_EX)],i; } 
    748       nz=size(STD_EX)-size(STD); 
    749 
    750       //zero rows in the begining 
     747         { COM=COM[1..size(COM)],i; COM_EX=COM_EX[1..size(COM_EX)],i; }
     748      nz=size(STD_EX)-size(STD);
     749
     750      //zero rows in the begining
    751751
    752752       if(size(STD)!=size(STD_EX) )
     
    756756           COM_EX=0,COM_EX[1..size(COM_EX)];
    757757         }
    758        } 
    759 
    760        
    761        
    762      
     758       }
     759
     760
     761
     762
    763763       for(i=nz+1; i<=size(STD_EX); i++ )
    764         {if( leadcoef(STD[i-nz])!=leadcoef(STD_EX[i]) )   {STD[i-nz]=leadcoef(STD_EX[i])*STD[i-nz];}
    765         }
    766 
    767         //assign the zero rows in STD_EX
     764        {if( leadcoef(STD[i-nz])!=leadcoef(STD_EX[i]) )          {STD[i-nz]=leadcoef(STD_EX[i])*STD[i-nz];}
     765        }
     766
     767        //assign the zero rows in STD_EX
    768768
    769769       for (j=2; j<=nz; j++)
    770770       {
    771         p=0;
     771        p=0;
    772772        i=1;
    773773        while(STD_EX[j-1][i]==0){i++;};
     
    780780        if (k==p){ COM_EX[j]=-1; }
    781781       }
    782      
     782
    783783      //assign the zero rows in STD
    784784      for (j=2; j<=size(STD); j++)
    785785       {
    786         i=size(transpose(STD));
     786        i=size(transpose(STD));
    787787        while(STD[j-1][i]==0){i--;}
    788788        p=i;
     
    796796        if(COM[j]<0){COM=delete(COM,j);}
    797797        }
    798      
     798
    799799      for(i=1; i<=size(COM_EX); i++)
    800800        {ff=0;
     
    819819       LT=L[1];
    820820
    821      
     821
    822822       for(i=2; i<=s+st; i++)
    823823        {
     
    838838
    839839      ////////////////////// compute the transformation matrices
    840      
     840
    841841       if (flag mod 2 ==1)
    842         { 
     842        {
    843843         TrafoL=transpose(LT)*TrafoL;
    844844        }
    845        else 
    846         { 
     845       else
     846        {
    847847         TrafoR=TrafoR*involution(LT,inv);
    848848        }
     
    851851      ///////////////////////// check whether the alg termined /////////////////
    852852      if(size(COMPARE)>=3)
    853        {   
     853       {
    854854        if(STD==COMPARE[3]){finish=1;}
    855        }       
     855       }
    856856       ////////////////////////////////// change to the opposite module
    857857       TSTD=transpose(STD);
     
    861861    }
    862862
    863 if (flag mod 2 ==0){ STD = involution(STD,inv);} else { STD = transpose(STD);  } 
    864  
     863if (flag mod 2 ==0){ STD = involution(STD,inv);} else { STD = transpose(STD);  }
     864
    865865    list REVERSE=TrafoL,STD,TrafoR;
    866866    return(REVERSE);
     
    877877    if(leadcoef(M[i])!=0){CON=CON+leadcoef(M[i])*gen(k); k++;}
    878878   }
    879 poly con=content(CON); 
     879poly con=content(CON);
    880880matrix TL=1/con*freemodule(nrows(M));
    881881return(TL);
     
    888888
    889889//static proc Ex_One_wheeled_bicycle()
    890 { 
     890{
    891891ring RA=(0,m), D, lp;
    892892matrix bicycle[2][3]=(1+m)*D^2, D^2, 1, D^2, D^2-1, 0;
     
    897897
    898898
    899 //static proc Ex_RLC-circuit() 
     899//static proc Ex_RLC-circuit()
    900900{
    901901ring RA=(0,m,R1,R2,L,C), D, lp;
     
    946946/*
    947947
    948 //static proc Ex_compare_output_with_maple_package_JanetOre() 
    949 { 
     948//static proc Ex_compare_output_with_maple_package_JanetOre()
     949{
    950950    ring w = 0,(x,d),Dp;
    951951    def W=nc_algebra(1,1);
    952952    setring W;
    953     matrix m[3][3]=[d2,d+1,0],[d+1,0,d3-x2*d],[2d+1, d3+d2, d2]; 
     953    matrix m[3][3]=[d2,d+1,0],[d+1,0,d3-x2*d],[2d+1, d3+d2, d2];
    954954    list J=jacobson(m,0);
    955     print(J[1]*m*J[3]); 
     955    print(J[1]*m*J[3]);
    956956    print(J[2]);
    957957    print(J[1]);
     
    965965    def W=nc_algebra(1,s);
    966966    setring W;
    967     matrix m[3][3]=[s^2,s+1,0],[s+1,0,s^3-x^2*s],[2*s+1, s^3+s^2, s^2]; 
     967    matrix m[3][3]=[s^2,s+1,0],[s+1,0,s^3-x^2*s],[2*s+1, s^3+s^2, s^2];
    968968    list J=jacobson(m,0);
    969     print(J[1]*m*J[3]); 
     969    print(J[1]*m*J[3]);
    970970    print(J[2]);
    971971    print(J[1]);
     
    975975
    976976//static proc Ex_cyclic()
    977 {   
     977{
    978978    ring w = 0,(x,d),Dp;
    979979    def W=nc_algebra(1,1);
     
    981981    matrix m[3][3]=d,0,0,x*d+1,d,0,0,x*d,d;
    982982    list J=jacobson(m,0);
    983     print(J[1]*m*J[3]); 
     983    print(J[1]*m*J[3]);
    984984    print(J[2]);
    985985    print(J[1]);
     
    995995    matrix m[3][3]=s,0,0,x*s+1,s,0,0,x*s,s;
    996996    list J=jacobson(m,0);
    997     print(J[1]*m*J[3]); 
     997    print(J[1]*m*J[3]);
    998998    print(J[2]);
    999999    print(J[1]);
     
    10101010    matrix m[3][3]=s,0,0,x*s+s,s,0,0,x*s,s;
    10111011    list J=jacobson(m,0);
    1012     print(J[1]*m*J[3]); 
     1012    print(J[1]*m*J[3]);
    10131013    print(J[2]);
    10141014    print(J[1]);
  • Singular/LIB/latex.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: latex.lib,v 1.29 2007-06-20 22:30:41 levandov Exp $";
     2version="$Id: latex.lib,v 1.30 2009-01-14 16:07:05 Singular Exp $";
    33category="Visualization";
    44info="
     
    677677 if (size(#)==1)
    678678 { if (typeof(#[1])=="int" or typeof(#[1])=="intvec" or typeof(#[1])=="vector"
    679     or typeof(#[1])=="number" or typeof(#[1])=="bigint" or defined(TeXaligned)) 
    680    { DA = D; DE = D; } 
     679    or typeof(#[1])=="number" or typeof(#[1])=="bigint" or defined(TeXaligned))
     680   { DA = D; DE = D; }
    681681}
    682682
     
    696696    else {s = s + obj + newline;}
    697697   }
    698    if (typeof(obj) == "int" or typeof(#[1])=="bigint") 
     698   if (typeof(obj) == "int" or typeof(#[1])=="bigint")
    699699   { s = s + "  " + string(obj) + "  ";}
    700700
     
    15941594  //if(defined(TeXreplace)){ short =0;}   // hier ueberfluessig 31.5.07
    15951595  if (short)
    1596   { j = 0;  // 31.5.07 
     1596  { j = 0;  // 31.5.07
    15971597    while(s[i]<>"!")
    15981598    { b=i; if (s[i]=="+" or s[i]=="-") {j++;}  // 31.5.07
  • Singular/LIB/matrix.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: matrix.lib,v 1.45 2008-12-08 14:31:46 motsak Exp $";
     2version="$Id: matrix.lib,v 1.46 2009-01-14 16:07:05 Singular Exp $";
    33category="Linear Algebra";
    44info="
     
    3030 rowred(A[,any]);       reduction of matrix A with elementary row-operations
    3131 colred(A[,any]);       reduction of matrix A with elementary col-operations
    32  linear_relations(E);   find linear relations between homogeneous vectors 
     32 linear_relations(E);   find linear relations between homogeneous vectors
    3333 rm_unitrow(A);         remove unit rows and associated columns of A
    3434 rm_unitcol(A);         remove unit columns and associated rows of A
     
    3737 exteriorBasis(n,k[,s]); basis of k-th exterior power of n-dim v.space
    3838 symmetricPower(A,k);   k-th symmetric power of a module/matrix A
    39  exteriorPower(A,k);    k-th exterior power of a module/matrix A 
     39 exteriorPower(A,k);    k-th exterior power of a module/matrix A
    4040          (parameters in square brackets [] are optional)
    4141";
     
    910910"USAGE:   linear_relations(M);
    911911         M: a module
    912 ASSUME:  All non-zero entries of M are homogeneous polynomials of the same 
    913          positife degree. The base field must be an exact field (not real 
     912ASSUME:  All non-zero entries of M are homogeneous polynomials of the same
     913         positife degree. The base field must be an exact field (not real
    914914         or complex).
    915915         It is not checked whether these assumptions hold.
     
    957957  pmat(REL);
    958958  pmat(M*REL);
    959 } 
     959}
    960960
    961961//////////////////////////////////////////////////////////////////////////////
     
    10781078proc symmetricBasis(int n, int k, list #)
    10791079"USAGE:    symmetricBasis(n, k[,s]); n int, k int, s string
    1080 RETURN:   ring, poynomial ring containing the ideal \"symBasis\", 
     1080RETURN:   ring, poynomial ring containing the ideal \"symBasis\",
    10811081          being a basis of the k-th symmetric power of an n-dim vector space.
    1082 NOTE:     The output polynomial ring has characteristics 0 and n variables 
     1082NOTE:     The output polynomial ring has characteristics 0 and n variables
    10831083          named \"S(i)\", where the base variable name S is either given by the
    10841084          optional string argument(which must not contain brackets) or equal to
     
    10991099    if( (find(S, "(") + find(S, ")")) > 0 )
    11001100    {
    1101       ERROR("Wrong optional argument: must be a string without brackets"); 
     1101      ERROR("Wrong optional argument: must be a string without brackets");
    11021102    }
    11031103  }
     
    11171117
    11181118// basis of the 3-rd symmetricPower of a 4-dim vector space:
    1119 def R = symmetricBasis(4, 3, "@e"); setring R; 
     1119def R = symmetricBasis(4, 3, "@e"); setring R;
    11201120R;  // container ring:
    11211121symBasis; // symmetric basis:
     
    11261126proc exteriorBasis(int n, int k, list #)
    11271127"USAGE:    exteriorBasis(n, k[,s]); n int, k int, s string
    1128 RETURN:   qring, an exterior algebra containing the ideal \"extBasis\", 
     1128RETURN:   qring, an exterior algebra containing the ideal \"extBasis\",
    11291129          being a basis of the k-th exterior power of an n-dim vector space.
    1130 NOTE:     The output polynomial ring has characteristics 0 and n variables 
     1130NOTE:     The output polynomial ring has characteristics 0 and n variables
    11311131          named \"S(i)\", where the base variable name S is either given by the
    11321132          optional string argument(which must not contain brackets) or equal to
     
    11471147    if( (find(S, "(") + find(S, ")")) > 0 )
    11481148    {
    1149       ERROR("Wrong optional argument: must be a string without brackets"); 
     1149      ERROR("Wrong optional argument: must be a string without brackets");
    11501150    }
    11511151  }
     
    11651165{ "EXAMPLE:"; echo = 2;
    11661166// basis of the 3-rd symmetricPower of a 4-dim vector space:
    1167 def r = exteriorBasis(4, 3, "@e"); setring r; 
     1167def r = exteriorBasis(4, 3, "@e"); setring r;
    11681168r; // container ring:
    11691169extBasis; // exterior basis:
     
    11941194      rings Tn is source- and Tm is image-ring with bases
    11951195          resp. Ink and Imk.
    1196       M = max dim of Image, N - dim. of source     
     1196      M = max dim of Image, N - dim. of source
    11971197SEE ALSO: symmetricPower, exteriorPower"
    11981198{
     
    12061206
    12071207//------------------------- compute matrix of single images ------------------
    1208   def Rm = save + Tm;  setring Rm; 
     1208  def Rm = save + Tm;  setring Rm;
    12091209  dbprint(p-2, "Temporary Working Ring", Rm);
    12101210
     
    12281228//------------------------- compute image ---------------------
    12291229  // apply S^k(A): Tn -> Rm  to Source basis vectors Ink:
    1230   map TMap = Tn, B; 
    1231 
    1232   ideal C = NF(TMap(Ink), std(0)); 
     1230  map TMap = Tn, B;
     1231
     1232  ideal C = NF(TMap(Ink), std(0));
    12331233  dbprint(p-1, "Image Matrix: ", C);
    12341234
     
    12731273"USAGE:    symmetricPower(A, k); A module, k int
    12741274RETURN:   module: the k-th symmetric power of A
    1275 NOTE:     the chosen bases and most of intermediate data will be shown if 
     1275NOTE:     the chosen bases and most of intermediate data will be shown if
    12761276          printlevel is big enough
    12771277SEE ALSO: exteriorPower
     
    13031303
    13041304//------------------------- compute and return S^k(A) in chosen bases --
    1305   setring save; 
     1305  setring save;
    13061306
    13071307  return(mapPower(p, A, k, Tn, Tm));
     
    13321332"USAGE:    exteriorPower(A, k); A module, k int
    13331333RETURN:   module: the k-th exterior power of A
    1334 NOTE:     the chosen bases and most of intermediate data will be shown if 
     1334NOTE:     the chosen bases and most of intermediate data will be shown if
    13351335          printlevel is big enough. Last rows will be invisible if zero.
    13361336SEE ALSO: symmetricPower
     
    13661366example
    13671367{ "EXAMPLE:"; echo = 2;
    1368   ring r = (0),(a, b, c, d, e, f), dp; 
     1368  ring r = (0),(a, b, c, d, e, f), dp;
    13691369  r; "base ring:";
    13701370
    1371   module B = a*gen(1) + c*gen(2) + e*gen(3), 
    1372              b*gen(1) + d*gen(2) + f*gen(3), 
     1371  module B = a*gen(1) + c*gen(2) + e*gen(3),
     1372             b*gen(1) + d*gen(2) + f*gen(3),
    13731373                        e*gen(1) + f*gen(3);
    13741374
    13751375  print(B);
    1376   print(exteriorPower(B, 2)); 
    1377   print(exteriorPower(B, 3)); 
     1376  print(exteriorPower(B, 2));
     1377  print(exteriorPower(B, 3));
    13781378
    13791379  def g = SuperCommutative(); setring g; g;
     
    13841384  print(exteriorPower(A, 2));
    13851385
    1386   module B = a*gen(1) + c*gen(2) + e*gen(3), 
    1387              b*gen(1) + d*gen(2) + f*gen(3), 
     1386  module B = a*gen(1) + c*gen(2) + e*gen(3),
     1387             b*gen(1) + d*gen(2) + f*gen(3),
    13881388                        e*gen(1) + f*gen(3);
    13891389  print(B);
  • Singular/LIB/nchomolog.lib

    r95edd5 r7f3ad4  
    1 version="$Id: nchomolog.lib,v 1.8 2008-08-07 21:15:02 levandov Exp $";
     1version="$Id: nchomolog.lib,v 1.9 2009-01-14 16:07:05 Singular Exp $";
    22category="Noncommutative";
    33info="
     
    168168  ring A=0,(x,t,dx,dt),dp;
    169169  def W = Weyl(); setring W;
    170   matrix M[2][2] = 
     170  matrix M[2][2] =
    171171    dt,  dx,
    172172    t*dx,x*dt;
     
    226226"{
    227227  if (i==0)
    228   { 
     228  {
    229229    return(ncHom_R(Ps)); // the rest is not needed
    230230  }
     
    512512  // assumed to be basering
    513513  // returns the difference between M and Ext^n_D(Ext^n_D(M,D),D)
    514   def save = basering; 
     514  def save = basering;
    515515  setring save;
    516516  module Md = ncExt_R(n,M); // right module
     
    537537  ring R   = 0,(x,y),dp;
    538538  poly F   = x3-y2;
    539   def A    = annfs(F); 
     539  def A    = annfs(F);
    540540  setring A;
    541541  dmodualtest(LD,2);
     
    544544
    545545proc dmodoublext(module M, list #)
    546 "USAGE:   dmodoublext(M [,i]);  M module, i optional int 
     546"USAGE:   dmodoublext(M [,i]);  M module, i optional int
    547547COMPUTE:  a presentation of Ext^i(Ext^i(M,D),D); for basering D
    548548RETURN:   left module
     
    553553{
    554554  // assume: basering is a Weyl algebra?
    555   def save = basering; 
     555  def save = basering;
    556556  setring save;
    557557  // if a list is nonempty and contains an integer N, n = N; otherwise n = nvars/2
     
    572572    n = nvars(save); n = n div 2;
    573573  }
    574   // returns Ext^i_D(Ext^i_D(M,D),D), that is 
     574  // returns Ext^i_D(Ext^i_D(M,D),D), that is
    575575  // computes the "dual" of the "dual" of a d-mod M (for n = nvars/2)
    576576  module Md = ncExt_R(n,M); // right module
     
    602602  ring R   = 0,(x,y),dp;
    603603  poly F   = x3-y2;
    604   def A    = annfs(F); 
     604  def A    = annfs(F);
    605605  setring A;
    606606  dmodoublext(LD);
  • Singular/LIB/nctools.lib

    r95edd5 r7f3ad4  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: nctools.lib,v 1.39 2008-04-23 14:06:10 motsak Exp $";
     2version="$Id: nctools.lib,v 1.40 2009-01-14 16:07:05 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    156156    execute (newringstring);
    157157    def lnewring=imap(r,lr);
    158     return( nc_algebra(lnewring[1],lnewring[2]) ); 
     158    return( nc_algebra(lnewring[1],lnewring[2]) );
    159159  }
    160160  else
     
    491491  D[1,3]=2*x;
    492492  D[2,3]=-2*y;
    493   def S = nc_algebra(1,D); setring S; 
     493  def S = nc_algebra(1,D); setring S;
    494494  S; // this is U(sl_2)
    495495  poly c = 4*x*y+z^2-2*z;
     
    595595  matrix D[3][3];
    596596  D[1,2]=x; D[1,3]=z;
    597   def S = nc_algebra(C,D); setring S; 
     597  def S = nc_algebra(C,D); setring S;
    598598  S;
    599599  ideal j=ndcond(); // the silent version
     
    664664  "EXAMPLE:";echo=2;
    665665  ring A1=0,(x(1..2),d(1..2)),dp;
    666   def S=Weyl(); 
     666  def S=Weyl();
    667667  setring S;  S;
    668668  kill A1,S;
     
    722722RETURN:  qring
    723723PURPOSE:  create the super-commutative algebra (as a GR-algebra) 'over' a basering,
    724 NOTE: activate this qring with the \"setring\" command. 
     724NOTE: activate this qring with the \"setring\" command.
    725725NOTE: if b==e then the resulting ring is commutative unles 'flag' is given and non-zero.
    726726THEORY: given a basering, this procedure introduces the anticommutative relations x(j)x(i)=-x(i)x(j) for all e>=j>i>=b,
     
    732732// NOTE: as a side effect the basering will be changed (if not in a commutative case) to bo the ground G-algebra (without factor).
    733733  int fprot = (find(option(),"prot") != 0);
    734  
     734
    735735  string rname=nameof(basering);
    736  
     736
    737737  if ( rname == "basering") // i.e. no ring has been set yet
    738738  {
     
    742742
    743743  def saveRing = basering;
    744  
     744
    745745  int N = nvars(saveRing);
    746746  int b = 1;
    747747  int e = N;
    748748  int flag = 0;
    749  
     749
    750750  ideal Q = 0;
    751751
     
    756756      ERROR("The argument 'b' must be an integer!");
    757757      return();
    758     }   
     758    }
    759759    b = #[1];
    760760
     
    763763      ERROR("The argument 'b' must within [1..nvars(basering)]!");
    764764      return();
    765     }   
    766    
     765    }
     766
    767767  }
    768768
     
    781781      return();
    782782    }
    783    
     783
    784784    if(e < b)
    785785    {
     
    798798    Q = #[3];
    799799  }
    800  
     800
    801801  if(size(#)>3)
    802802  {
     
    809809  }
    810810
    811   int iSavedDegBoung = degBound; 
     811  int iSavedDegBoung = degBound;
    812812
    813813  if( (b == e) && (flag == 0) ) // commutative ring!!!
     
    817817      print("Warning: (b==e) means that the resulting ring will be commutative!");
    818818    }
    819    
     819
    820820    degBound=0;
    821821    Q = std(Q + (var(b)^2));
    822822    degBound = iSavedDegBoung;
    823    
     823
    824824    qring @EA = Q; // and it will be internally commutative as well!!!
    825        
    826     return(@EA);   
     825
     826    return(@EA);
    827827  }
    828828
    829829/*
    830   // Singular'(H.S.) politics: no ring copies! 
     830  // Singular'(H.S.) politics: no ring copies!
    831831  // in future nc_algebra() should return a new ring!!!
    832832  list CurrRing = ringlist(basering);
     
    841841      print("Warning: (char == 2) means that the resulting ring will be commutative!");
    842842    }
    843    
     843
    844844    int j = ncols(Q) + 1;
    845    
     845
    846846    for ( int i=e; i>=b; i--, j++ )
    847847    {
    848848      Q[j] = var(i)^2;
    849849    }
    850    
    851     degBound=0;   
     850
     851    degBound=0;
    852852    Q = std(Q);
    853853    degBound = iSavedDegBoung;
    854    
     854
    855855    qring @EA = Q; // and it will be internally commutative as well!!!
    856     return(@EA);     
    857   }
    858  
     856    return(@EA);
     857  }
     858
    859859
    860860  int i, j;
    861  
     861
    862862  if( (b == 1) && (e == N) ) // just an exterior algebra?
    863   { 
     863  {
    864864    def S = nc_algebra(-1, 0); // define ground G-algebra!
    865     setring S; 
     865    setring S;
    866866  } else
    867867  {
    868868    matrix @E = UpOneMatrix(N);
    869  
     869
    870870    for ( i = b; i < e; i++ )
    871871    {
     
    880880
    881881  ideal @Q = fetch(saveRing, Q);
    882  
     882
    883883  j = ncols(@Q) + 1;
    884884
     
    894894  }
    895895
    896   degBound=0;   
     896  degBound=0;
    897897  @Q = twostd(@Q); // must be computed within the ground G-algebra => problems with local orderings!
    898898  degBound = iSavedDegBoung;
    899  
     899
    900900  qring @EA = @Q;
    901901
     
    945945    return("SCA rings are factors by (at least) squares!"); // no squares in the factor ideal!
    946946  }
    947  
     947
    948948  list L = ringlist(saveRing);
    949949
     
    960960      {
    961961        if( (fprot == 1) and (i > 1) )
    962         {         
     962        {
    963963          print("Warning: the SCA representation of the current commutative factor ring may be ambiguous!");
    964964        }
    965                      
     965
    966966        return( list(i, i) ); // this is not unique in this case! there may be other squares in the factor ideal!
    967967      }
    968     }   
     968    }
    969969
    970970    return("The current commutative ring is not SCA! (Wrong quotient ideal)"); // no squares in the factor ideal!
     
    991991        if(i < b)
    992992        {
    993           b = i;       
     993          b = i;
    994994        }
    995995
    996996        if(j > e)
    997997        {
    998           e = j;       
     998          e = j;
    999999        }
    10001000      } else
     
    10201020      {
    10211021        if( (fprot == 1) and (i > 1) )
    1022         {         
     1022        {
    10231023          print("Warning: the SCA representation of the current factor ring may be ambiguous!");
    10241024        }
    1025                      
     1025
    10261026        return( list(i, i) ); // this is not unique in this case! there may be other squares in the factor ideal!
    10271027      }
     
    11831183
    11841184  def S = nc_algebra(E,0); setring S; S;
    1185  
     1185
    11861186  if(IsSCA())
    11871187    { "Alternating variables: [", AltVarStart(), ",", AltVarEnd(), "]."; }
  • Singular/LIB/polymake.lib

    r95edd5 r7f3ad4  
    1 version="$Id: polymake.lib,v 1.9 2008-08-29 15:16:49 keilen Exp $";
     1version="$Id: polymake.lib,v 1.10 2009-01-14 16:07:05 Singular Exp $";
    22category="Tropical Geometry";
    33info="
     
    77WARNING:
    88     Most procedures will not work unless polymake or topcom is installed and
    9      if so, they will only work with the operating system LINUX! 
     9     if so, they will only work with the operating system LINUX!
    1010     For more detailed information see IMPORTANT NOTE respectively consult the
    1111     help string of the procedures.
    1212
    1313IMPORTANT NOTE:
    14      Even though this is a Singular library for computing polytopes and fans such 
    15      as the Newton polytope or the Groebner fan of a polynomial, most of the hard 
    16      computations are NOT done by Singular but by the program 
     14     Even though this is a Singular library for computing polytopes and fans such
     15     as the Newton polytope or the Groebner fan of a polynomial, most of the hard
     16     computations are NOT done by Singular but by the program
    1717@*   -  polymake by Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt
    18 @*      (see http://www.math.tu-berlin.de/polymake/), 
     18@*      (see http://www.math.tu-berlin.de/polymake/),
    1919@*   respectively (only in the procedure triangularions) by the program
    2020@*   -  topcom by Joerg Rambau, Universitaet Bayreuth
    2121@*      (see http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM);
    22 @*   this library should rather be seen as an interface which allows to use a (very limited) 
    23      number of options which polymake respectively topcom offers to compute with polytopes 
    24      and fans and to make the results available in Singular for further computations; 
     22@*   this library should rather be seen as an interface which allows to use a (very limited)
     23     number of options which polymake respectively topcom offers to compute with polytopes
     24     and fans and to make the results available in Singular for further computations;
    2525     moreover, the user familiar with Singular does not have to learn the syntax of polymake
    2626     or topcom, if the options offered here are sufficient for his purposes.
     
    3535     groebnerFan(poly)                 computes the Groebner fan of a polynomial
    3636     intmatToPolymake(intmat,string)   transforms an integer matrix into polymake format
    37      polymakeToIntmat(string,string)   transforms polymake output into an integer matrix 
     37     polymakeToIntmat(string,string)   transforms polymake output into an integer matrix
    3838
    3939PROCEDURES USING TOPCOM:
     
    5959
    6060KEYWORDS:    polytope; fan; secondary fan; secondary polytope; polymake;
    61              Newton polytope; Groebner fan 
     61             Newton polytope; Groebner fan
    6262
    6363";
     
    9999RETURN:  list, L with four entries
    100100@*            L[1] : an integer matrix whose rows are the coordinates of vertices
    101                      of the polytope 
     101                     of the polytope
    102102@*            L[2] : the dimension of the polytope
    103103@*            L[3] : a list whose ith entry explains to which vertices the ith vertex
     
    109109                     i.e. the smallest affine space containing the polytope
    110110NOTE: -  for its computations the procedure calls the program polymake by Ewgenij Gawrilow,
    111          TU Berlin and Michael Joswig, TU Darmstadt; it therefore is necessary that 
     111         TU Berlin and Michael Joswig, TU Darmstadt; it therefore is necessary that
    112112         this program is installed in order to use this procedure;
    113113         see http://www.math.tu-berlin.de/polymake/
     
    117117         in polymake format; if you wish to use this for further computations with polymake,
    118118         you have to use the procedure polymakeKeepTmpFiles in before
    119 @*    -  moreover, the procedure creates the file /tmp/polytope.output which it deletes 
     119@*    -  moreover, the procedure creates the file /tmp/polytope.output which it deletes
    120120         again before ending
    121121@*    -  it is possible to give as an optional second argument as string which then will be
     
    191191      }
    192192    }
    193   } 
     193  }
    194194  newveg=newveg[1,size(newveg)-1];
    195195  execute("list nveg="+newveg+";");
     
    226226   "EXAMPLE:";
    227227   echo=2;
    228    // the lattice points of the unit square in the plane 
     228   // the lattice points of the unit square in the plane
    229229   list points=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1);
    230230   // the secondary polytope of this lattice point configuration is computed
     
    266266@*    -  the procedure creates the file  /tmp/newtonPolytope.polymake which contains the polytope
    267267         in polymake format and which can be used for further computations with polymake
    268 @*    -  moreover, the procedure creates the file /tmp/newtonPolytope.output which it deletes 
     268@*    -  moreover, the procedure creates the file /tmp/newtonPolytope.output which it deletes
    269269         again before ending
    270270@*    -  it is possible to give as an optional second argument as string which then will be
     
    303303   np[2];
    304304   // np[3] contains information how the vertices are connected to each other,
    305    // e.g. the first vertex (number 0) is connected to the second, third and 
     305   // e.g. the first vertex (number 0) is connected to the second, third and
    306306   //      fourth vertex
    307307   np[3][1];
     
    313313   np[1];
    314314   // its dimension is
    315    np[2];   
    316    // the Newton polytope is contained in the affine space given 
     315   np[2];
     316   // the Newton polytope is contained in the affine space given
    317317   //     by the equations
    318318   np[4]*M;
     
    348348"USAGE:  normalFan (vert,aff,graph,rays,[,#]);   vert,aff intmat,  graph list, rays int, # string
    349349ASSUME:  - vert is an integer matrix whose rows are the coordinate of the vertices of
    350            a convex lattice polygon; 
     350           a convex lattice polygon;
    351351@*       - aff describes the affine hull of this polytope, i.e.
    352            the smallest affine space containing it, in the following sense: 
    353            denote by n the number of columns of vert, then multiply aff by (1,x(1),...,x(n)) 
     352           the smallest affine space containing it, in the following sense:
     353           denote by n the number of columns of vert, then multiply aff by (1,x(1),...,x(n))
    354354           and set the resulting terms to zero in order to get the equations for the affine hull;
    355355@*       - the ith entry of graph is an integer vector describing to which vertices
     
    357357           connected to vert[k];
    358358@*       - the integer rays is either one (if the extreme rays should be computed) or zero (otherwise)
    359 RETURN:  list, the ith entry of L[1] contains information about the cone in the normal fan 
    360                dual to the ith vertex of the polytope 
     359RETURN:  list, the ith entry of L[1] contains information about the cone in the normal fan
     360               dual to the ith vertex of the polytope
    361361@*             L[1][i][1] = integer matrix representing the inequalities which describe the
    362362                            cone dual to the ith vertex
     
    370370           TU Berlin and Michael Joswig, so it only works if polymake is installed;
    371371           see http://www.math.tu-berlin.de/polymake/
    372 @*       - in the optional argument # it is possible to hand over other names for the 
     372@*       - in the optional argument # it is possible to hand over other names for the
    373373           variables to be used -- be carful, the format must be correct and that is
    374374           not tested, e.g. if you want the variable names to be u00,u10,u01,u11
     
    378378  list ineq; // stores the inequalities of the cones
    379379  int i,j,k;
    380   // we work over the following ring 
     380  // we work over the following ring
    381381  execute("ring ineqring=0,x(1.."+string(ncols(vertices))+"),lp;");
    382382  string greatersign=">";
     
    403403  for (i=1;i<=nrows(vertices);i++)
    404404  {
    405     // first we produce for each vertex in the polytope 
     405    // first we produce for each vertex in the polytope
    406406    // the inequalities describing the dual cone in the normal fan
    407407    list pp;  // contain strings representing the inequalities describing the normal cone
     
    489489  }
    490490  // get the linearity space
    491   return(list(ineq,linearity)); 
     491  return(list(ineq,linearity));
    492492}
    493493example
     
    516516proc groebnerFan (poly f,list #)
    517517"USAGE:  groebnerFan(f[,#]);  f poly, # string
    518 RETURN:  list, the ith entry of L[1] contains information about the ith cone in the Groebner fan 
     518RETURN:  list, the ith entry of L[1] contains information about the ith cone in the Groebner fan
    519519               dual to the ith vertex in the Newton polytope of the f
    520 @*             L[1][i][1] = integer matrix representing the inequalities which describe the cone         
     520@*             L[1][i][1] = integer matrix representing the inequalities which describe the cone
    521521@*             L[1][i][2] = a list which contains the inequalities represented by L[1][i][1]
    522522                            as a list of strings
    523523@*             L[1][i][3] = an interger matrix whose rows are the extreme rays of the cone
    524524@*             L[2] = is an integer matrix whose rows span the linearity space of the fan,
    525                       i.e. the linear space which is contained in each cone               
     525                      i.e. the linear space which is contained in each cone
    526526@*             L[3] = the Newton polytope of f in the format of the procedure newtonPolytope
    527527@*             L[4] = integer matrix where each row represents the exponet vector of one monomial
     
    533533           TU Berlin and Michael Joswig, so it only works if polymake is installed;
    534534           see http://www.math.tu-berlin.de/polymake/
    535 @*       - the procedure creates the file  /tmp/newtonPolytope.polymake which contains the 
    536            Newton polytope of f in polymake format and which can be used for further 
     535@*       - the procedure creates the file  /tmp/newtonPolytope.polymake which contains the
     536           Newton polytope of f in polymake format and which can be used for further
    537537           computations with polymake
    538538@*       - it is possible to give as an optional second argument as string which then will be
     
    605605ASSUME:  - M is an integer matrix which should be transformed into polymake format;
    606606@*       - art is one of the following strings:
    607 @*         + 'rays'   : indicating that a first column of 0's should be added 
    608 @*         + 'points' : indicating that a first column of 1's should be added 
     607@*         + 'rays'   : indicating that a first column of 0's should be added
     608@*         + 'points' : indicating that a first column of 1's should be added
    609609RETURN:  string, the matrix is transformed in a string and a first column has been added
    610610EXAMPLE: example intmatToPolymake;   shows an example"
     
    614614    string anf="0 ";
    615615  }
    616   else 
     616  else
    617617  {
    618618    string anf="1 ";
     
    654654                 where each row has been multiplied with the lowest common multiple of the
    655655                 denominators of its entries so as to be an integer matrix; moreover,
    656                  if art=='affine', then the first column is omitted since we only want affine 
     656                 if art=='affine', then the first column is omitted since we only want affine
    657657                 coordinates
    658658EXAMPLE: example polymakeToIntmat;   shows an example"
     
    666666    pm=stringdelete(pm,1);
    667667  }
    668   pm=stringdelete(pm,1); 
     668  pm=stringdelete(pm,1);
    669669  // find out how many entries each vector has, namely one more than 'spaces' in a row
    670670  int i=1;
     
    681681  // if we want to have affine coordinates
    682682  if (art=="affine")
    683   {   
     683  {
    684684    s--; // then there is one column less
    685685    // and the entry of the first column (in the first row) has to be removed
     
    720720      if (pm[i]==" ")
    721721      {
    722         pm[i]=",";     
     722        pm[i]=",";
    723723      }
    724724    }
     
    730730  }
    731731  // since the matrix could be over the rationals, we need a ring with rational coefficients
    732   ring zwischering=0,x,lp;   
     732  ring zwischering=0,x,lp;
    733733  // create the matrix with the elements of pm as entries
    734734  execute("matrix mm["+string(z)+"]["+string(s)+"]="+pm+";");
     
    780780"USAGE:  triangulations(polygon); list polygon
    781781ASSUME:  polygon is a list of integer vectors of the same size representing the affine
    782          coordinates of the lattice points 
     782         coordinates of the lattice points
    783783PURPOSE: the procedure considers the marked polytope given as the convex hull of
    784784         the lattice points and with these lattice points as markings; it then
    785          computes all possible triangulations of this marked polytope 
     785         computes all possible triangulations of this marked polytope
    786786RETURN:  list, each entry corresponds to one triangulation and the ith entry is
    787787               itself a list of integer vectors of size three, where each integer
     
    790790NOTE:  - the procedure calls for its computations the program points2triangs
    791791         from the program topcom by Joerg Rambau, Universitaet Bayreuth; it
    792          therefore is necessary that this program is installed in order to use this 
     792         therefore is necessary that this program is installed in order to use this
    793793         procedure; see
    794794@*       http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     
    799799         you have to use the procedure polymakeKeepTmpFiles in before
    800800@*     - note that an integer i in an integer vector representing a triangle refers to
    801          the ith lattice point, i.e. polygon[i]; this convention is different from 
     801         the ith lattice point, i.e. polygon[i]; this convention is different from
    802802         TOPCOM's convention, where i would refer to the i-1st lattice point
    803803EXAMPLE: example triangulations;   shows an example"
    804804{
    805805  int i,j;
    806   // prepare the input for points2triangs by writing the input polygon in the 
     806  // prepare the input for points2triangs by writing the input polygon in the
    807807  // necessary format
    808808  string spi="[";
     
    847847      }
    848848      else
    849       {       
     849      {
    850850        np2t=np2t+p2t[i];
    851851      }
     
    859859  {
    860860    if (np2t[size(np2t)]!=";")
    861     {     
     861    {
    862862      np2t=np2t+p2t[size(p2t)-1]+p2t[size(p2t)];
    863863    }
     
    881881          np2t=np2t+"))";
    882882          i++;
    883         }     
     883        }
    884884        else
    885885        {
     
    919919   "EXAMPLE:";
    920920   echo=2;
    921    // the lattice points of the unit square in the plane 
     921   // the lattice points of the unit square in the plane
    922922   list polygon=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1);
    923923   // the triangulations of this lattice point configuration are computed
     
    935935PURPOSE: the procedure considers the marked polytope given as the convex hull of
    936936         the lattice points and with these lattice points as markings; it then
    937          computes the lattice points of the secondary polytope given by this 
     937         computes the lattice points of the secondary polytope given by this
    938938         marked polytope which correspond to the triangulations computed by
    939939         the procedure triangulations
    940940RETURN:  list, say L, such that:
    941 @*             L[1] = intmat, each row gives the affine coordinates of a lattice point 
     941@*             L[1] = intmat, each row gives the affine coordinates of a lattice point
    942942                      in the secondary polytope given by the marked
    943943                      polytope corresponding to polygon
    944944@*             L[2] = the list of corresponding triangulations
    945 NOTE:    if the triangluations are not handed over as optional argument the procedure calls 
     945NOTE:    if the triangluations are not handed over as optional argument the procedure calls
    946946         for its computation of these triangulations the program points2triangs
    947947         from the program topcom by Joerg Rambau, Universitaet Bayreuth; it
    948          therefore is necessary that this program is installed in order to use this 
     948         therefore is necessary that this program is installed in order to use this
    949949         procedure; see
    950950@*       http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     
    995995    secpoly[i,1..size(polygon)]=vertex;
    996996  }
    997   return(list(secpoly,triangs));         
     997  return(list(secpoly,triangs));
    998998}
    999999example
     
    10241024PURPOSE: the procedure considers the marked polytope given as the convex hull of
    10251025         the lattice points and with these lattice points as markings; it then
    1026          computes the lattice points of the secondary polytope given by this 
     1026         computes the lattice points of the secondary polytope given by this
    10271027         marked polytope which correspond to the triangulations computed by
    10281028         the procedure triangulations
    1029 RETURN:  list, the ith entry of L[1] contains information about the ith cone in the 
     1029RETURN:  list, the ith entry of L[1] contains information about the ith cone in the
    10301030               secondary fan of the polygon, i.e. the cone dual to the ith vertex of the
    10311031               secondary polytope
     
    10391039                      i.e. the linear space which is contained in each cone
    10401040@*             L[3] = the secondary polytope in the format of the procedure polymakePolytope
    1041 @*             L[4] = the list of triangulations corresponding to the vertices 
     1041@*             L[4] = the list of triangulations corresponding to the vertices
    10421042                      of the secondary polytope
    10431043NOTE:    - the procedure calls for its computation polymake by Ewgenij Gawrilow,
    10441044           TU Berlin and Michael Joswig, so it only works if polymake is installed;
    10451045           see http://www.math.tu-berlin.de/polymake/
    1046 @*       - in the optional argument # it is possible to hand over other names for the 
     1046@*       - in the optional argument # it is possible to hand over other names for the
    10471047           variables to be used -- be carful, the format must be correct and that is
    10481048           not tested, e.g. if you want the variable names to be u00,u10,u01,u11
    10491049           then you must hand over the string u11,u10,u01,u11
    1050 @*       - if the triangluations are not handed over as optional argument the procedure calls 
     1050@*       - if the triangluations are not handed over as optional argument the procedure calls
    10511051           for its computation of these triangulations the program points2triangs
    10521052           from the program topcom by Joerg Rambau, Universitaet Bayreuth; it
    1053            therefore is necessary that this program is installed in order to use this 
     1053           therefore is necessary that this program is installed in order to use this
    10541054           procedure; see
    10551055@*         http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     
    11431143   // interior is a lattice point in the interior of this lattice polygon
    11441144   intvec interior=1,1;
    1145    // compute the general cycle length of a cycle of the corresponding cycle 
     1145   // compute the general cycle length of a cycle of the corresponding cycle
    11461146   // in the dual tropical curve, note that (0,1) and (2,1) do not contribute
    11471147   cycleLength(boundary,interior);
     
    11621162@*                       L[2][i][j][1] = intvec, the coordinates of the jth lattice point on that facet
    11631163@*                       L[2][i][j][2] = int, the position of L[2][i][j][1] in markings
    1164 @*             L[3]    : represents the interior lattice points of the polygon 
     1164@*             L[3]    : represents the interior lattice points of the polygon
    11651165@*                       L[3][i][1] = intvec, the coordinates of the ith interior point
    11661166@*                       L[3][i][2] = int, the position of L[3][i][1] in markings
     
    12471247    }
    12481248    vert[3][i]=list(vert[3][i],j);
    1249   } 
     1249  }
    12501250  return(vert);
    12511251}
     
    12541254   "EXAMPLE:";
    12551255   echo=2;
    1256    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1256   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    12571257   // with all integer points as markings
    12581258   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
     
    12721272proc eta (list triang,list polygon)
    12731273"USAGE:  eta(triang,polygon);  triang, polygon list
    1274 ASSUME:  polygon has the format of the output of splitPolygon, i.e. it is a list with three 
     1274ASSUME:  polygon has the format of the output of splitPolygon, i.e. it is a list with three
    12751275         entries describing a convex lattice polygon in the following way:
    12761276@*       polygon[1] : is a list of lists; for each i the entry polygon[1][i][1] is a lattice point which is
     
    12891289         polygon described by polygon; if an entry of triang is the vector (i,j,k) then the triangle
    12901290         is build by the vertices with indices i, j and k
    1291 RETURN:  intvec, the integer vector eta describing that vertex of the Newton polytope discriminant 
    1292                  of the polygone whose dual cone in the Groebner fan contains the cone of the 
     1291RETURN:  intvec, the integer vector eta describing that vertex of the Newton polytope discriminant
     1292                 of the polygone whose dual cone in the Groebner fan contains the cone of the
    12931293                 secondary fan of the polygon corresponding to the given triangulation
    1294 NOTE:    for a better description of eta see either Gelfand, Kapranov, Zelevinski: Discriminants, 
     1294NOTE:    for a better description of eta see either Gelfand, Kapranov, Zelevinski: Discriminants,
    12951295         Resultants and multidimensional Determinants. Chapter 10.
    12961296EXAMPLE: example eta;   shows an example"
     
    13591359      if ((polygon[1][j][2]==triang[k][1]) or (polygon[1][j][2]==triang[k][2]) or (polygon[1][j][2]==triang[k][3]))
    13601360      {
    1361         // ... if so, add the area of the triangle to etaij 
     1361        // ... if so, add the area of the triangle to etaij
    13621362        etaij=etaij+triangarea[k];
    1363         // then check if that triangle has a facet which is contained in one of the 
     1363        // then check if that triangle has a facet which is contained in one of the
    13641364        // two facets of the polygon which are adjecent to the given vertex ...
    13651365        // these two facets are seiten[j] and seiten[j+1]
     
    13931393  {
    13941394    for (j=1;j<=size(polygon[2][i]);j++)
    1395     {     
     1395    {
    13961396      // initialise etaij
    13971397      etaij=0;
     
    14041404        if ((polygon[2][i][j][2]==triang[k][1]) or (polygon[2][i][j][2]==triang[k][2]) or (polygon[2][i][j][2]==triang[k][3]))
    14051405        {
    1406           // ... if so, add the area of the triangle to etaij 
     1406          // ... if so, add the area of the triangle to etaij
    14071407          etaij=etaij+triangarea[k];
    1408           // then check if that triangle has a facet which is contained in the 
     1408          // then check if that triangle has a facet which is contained in the
    14091409          // facet of the polygon which contains the lattice point in question,
    14101410          // this is the facet seiten[i+1];
     
    14141414            // ... and for each lattice point in the triangle ...
    14151415            for (m=1;m<=size(triang[k]);m++)
    1416             {           
     1416            {
    14171417              // ... if they coincide and are not the vertex itself ...
    14181418              if ((seiten[i+1][l][2]==triang[k][m]) and (seiten[i+1][l][2]!=polygon[2][i][j][2]))
     
    14511451      if ((polygon[3][j][2]==triang[k][1]) or (polygon[3][j][2]==triang[k][2]) or (polygon[3][j][2]==triang[k][3]))
    14521452      {
    1453         // ... if so, add the area of the triangle to etaij 
     1453        // ... if so, add the area of the triangle to etaij
    14541454        etaij=etaij+triangarea[k];
    14551455      }
     
    14641464   "EXAMPLE:";
    14651465   echo=2;
    1466    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1466   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    14671467   // with all integer points as markings
    14681468   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
     
    14711471   // split the polygon in its vertices, its facets and its interior points
    14721472   list sp=splitPolygon(polygon);
    1473    // define a triangulation by connecting the only interior point 
     1473   // define a triangulation by connecting the only interior point
    14741474   //        with the vertices
    14751475   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,5,10);
     
    14771477   eta(triang,sp);
    14781478}
    1479  
     1479
    14801480proc findOrientedBoundary (list polygon)
    14811481"USAGE:      findOrientedBoundary(polygon); polygon list
     
    15171517    //   compute their pairwise angles and their lengths
    15181518    for (i=1;i<=size(polygon)-1;i++)
    1519     {     
     1519    {
    15201520      for (j=i+1;j<=size(polygon);j++)
    15211521      {
     
    15411541    polygon=sortlistbyintvec(polygon,abstand);
    15421542    return(list(polygon,endpoints));
    1543   } 
     1543  }
    15441544  ///////////////////////////////////////////////////////////////
    15451545  list orderedvertices;  // stores the vertices in an ordered way
     
    15511551  intvec startvertex=polygon[1]; // keep the starting vertex to test, when the end is reached
    15521552  int endtest;                    // is set to one, when the end is reached
    1553   int startvertexfound;// is 1, once for some testvertex a candidate for the next vertex has been found 
     1553  int startvertexfound;// is 1, once for some testvertex a candidate for the next vertex has been found
    15541554  polygon=delete(polygon,1);    // delete the testvertex
    15551555  intvec v,w;
     
    15771577      // therefore find a vertex in the interior as candidate; but always testing against
    15781578      // the starting vertex, this can not happen
    1579       comparevertices[size(comparevertices)+1]=startvertex; 
     1579      comparevertices[size(comparevertices)+1]=startvertex;
    15801580      for (j=1;(j<=size(comparevertices)) and (d<=0);j++)
    15811581      {
     
    15911591    }
    15921592    if (size(naechste)>0) // then a candidate for the next vertex has been found
    1593     {     
     1593    {
    15941594      startvertexfound=1; // at least once a candidate has been found
    15951595      naechste=sortlist(naechste,3);  //we order the candidates according to their distance from testvertex;
     
    16071607      }
    16081608    }
    1609     else // that means either that the vertex was inside the polygon, 
     1609    else // that means either that the vertex was inside the polygon,
    16101610    {    // or that we have reached the last vertex on the boundary of the polytope
    16111611      if (startvertexfound==0) // the vertex was in the interior; we delete it and start all over again
    1612       {       
    1613         orderedvertices[1]=polygon[1]; 
    1614         minimisedorderedvertices[1]=polygon[1]; 
     1612      {
     1613        orderedvertices[1]=polygon[1];
     1614        minimisedorderedvertices[1]=polygon[1];
    16151615        testvertex=polygon[1];
    16161616        startvertex=polygon[1];
     
    16731673             computes all marked points in points which ly on the boundary of that polygon, ordered
    16741674             clockwise
    1675 RETURN:      list, of integer vectors which are the coordinates of the lattice points on 
     1675RETURN:      list, of integer vectors which are the coordinates of the lattice points on
    16761676                   the boundary of the above mentioned polygon P, if this polygon is not the
    1677                    empty set (that would be the case if points[pt] is not a vertex of any 
     1677                   empty set (that would be the case if points[pt] is not a vertex of any
    16781678                   triangle in the triangulation); otherwise return the empty list
    16791679EXAMPLE:     example cyclePoints;   shows an example"
     
    17231723   "EXAMPLE:";
    17241724   echo=2;
    1725    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
     1725   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
    17261726   // with all integer points as markings
    17271727   list points=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),
    17281728               intvec(0,0),intvec(2,1),intvec(0,1),intvec(1,2),
    17291729               intvec(0,2),intvec(0,3);
    1730    // define a triangulation 
     1730   // define a triangulation
    17311731   list triang=intvec(1,2,5),intvec(1,5,7),intvec(1,7,9),intvec(8,9,10),
    17321732               intvec(1,8,9),intvec(1,2,8);
     
    17651765proc picksFormula (list polygon)
    17661766"USAGE:  picksFormula(polygon);   polygon list
    1767 ASSUME:  polygon is a list of integer vectors in the plane and consider their convex hull C 
    1768 RETURN:  list, L of three integersthe 
     1767ASSUME:  polygon is a list of integer vectors in the plane and consider their convex hull C
     1768RETURN:  list, L of three integersthe
    17691769@*             L[1] : the lattice area of C, i.e. twice the Euclidean area
    17701770@*             L[2] : the number of lattice points on the boundary of C
     
    18151815proc ellipticNF (list polygon)
    18161816"USAGE:  ellipticNF(polygon);   polygon list
    1817 ASSUME:  polygon is a list of integer vectors in the plane such that their convex hull C 
     1817ASSUME:  polygon is a list of integer vectors in the plane such that their convex hull C
    18181818         has precisely one interior lattice point; i.e. C is the Newton polygon of an
    18191819         elliptic curve
    18201820PURPOSE: compute the normal form of the polygon with respect to the unimodular affine
    1821          transformations T=A*x+v; there are sixteen different normal forms 
     1821         transformations T=A*x+v; there are sixteen different normal forms
    18221822         (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons and
    18231823                   the number 12.  Amer. Math. Monthly  107  (2000),  no. 3, 238--250.)
     
    19521952    M=pg[max],1,pg[max+1],1,pg[max+2],1;
    19531953    // the orientation of the polygon matters
    1954     A=pg[max-1]-pg[max],pg[max+1]-pg[max];   
     1954    A=pg[max-1]-pg[max],pg[max+1]-pg[max];
    19551955    if (det(A)==4)
    19561956    {
     
    20012001    {
    20022002      max++;
    2003     }   
     2003    }
    20042004    M=pg[max],1,pg[max+1],1,pg[max+2],1;
    20052005    N=0,1,1,1,2,1,2,1,1;
     
    20642064   // the vertices of the normal form are
    20652065   nf[1];
    2066    // it has been transformed by the unimodular affine transformation A*x+v 
     2066   // it has been transformed by the unimodular affine transformation A*x+v
    20672067   // with matrix A
    20682068   nf[2];
     
    20792079"USAGE:  ellipticNFDB(n[,#]);   n int, # list
    20802080ASSUME:  n is an intger between 1 and 16
    2081 PURPOSE: this is a database storing the 16 normal forms of planar polygons with 
     2081PURPOSE: this is a database storing the 16 normal forms of planar polygons with
    20822082         precisely one interior point up to unimodular affine transformations
    20832083@*       (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons and
    20842084                   the number 12.  Amer. Math. Monthly  107  (2000),  no. 3, 238--250.)
    20852085RETURN:  list, L such that
    2086 @*             L[1] : list whose entries are the vertices of the nth normal form 
    2087 @*             L[2] : list whose entries are all the lattice points of the nth normal form 
     2086@*             L[1] : list whose entries are the vertices of the nth normal form
     2087@*             L[2] : list whose entries are all the lattice points of the nth normal form
    20882088@*             L[3] : only present if the optional parameter # is present, and then
    2089                       it is a polynomial in the variables (x,y) whose Newton polygon 
     2089                      it is a polynomial in the variables (x,y) whose Newton polygon
    20902090                      is the nth normal form
    20912091NOTE:    the optional parameter is only allowed if the basering has the variables x and y
     
    21392139proc polymakeKeepTmpFiles (int i)
    21402140"USAGE:  polymakeKeepTmpFiles(int i);   i int
    2141 PURPOSE: some procedures create files in the directory /tmp which are used for 
     2141PURPOSE: some procedures create files in the directory /tmp which are used for
    21422142         computations with polymake respectively topcom; these will be removed
    21432143         when the corresponding procedure is left; however, it might be desireable
     
    21842184static proc scalarproduct (intvec w,intvec v)
    21852185"USAGE:      scalarproduct(w,v); w,v intvec
    2186 ASSUME:      w and v are integer vectors of the same length 
     2186ASSUME:      w and v are integer vectors of the same length
    21872187RETURN:      int, the scalarproduct of v and w
    21882188NOTE:        the procedure is called by findOrientedBoundary"
     
    22312231  {
    22322232    int m=nrows(M);
    2233    
     2233
    22342234  }
    22352235  else
     
    22892289  {
    22902290    return("");
    2291    
     2291
    22922292  }
    22932293  if (i==1)
     
    23992399        k++;
    24002400      }
    2401       else 
     2401      else
    24022402      {
    24032403        stop=1;
     
    24422442        k++;
    24432443      }
    2444       else 
     2444      else
    24452445      {
    24462446        stop=1;
     
    24912491static proc polygonToCoordinates (list points)
    24922492"USAGE:      polygonToCoordinates(points);   points list
    2493 ASSUME:      points is a list of integer vectors each of size two describing the 
     2493ASSUME:      points is a list of integer vectors each of size two describing the
    24942494             marked points of a convex lattice polygon like the output of polygonDB
    2495 RETURN:      list, the first entry is a string representing the coordinates corresponding 
     2495RETURN:      list, the first entry is a string representing the coordinates corresponding
    24962496                   to the latticpoints seperated by commata
    24972497                   the second entry is a list where the ith entry is a string representing
     
    25282528  }
    25292529  size(etavectors);
    2530  
     2530
    25312531  for (i=size(etavectors);i>=2;i--)
    25322532  {
     
    25632563    }
    25642564    return(list(etavectors,string(ad)));
    2565    
    2566    
    2567   }
    2568  
     2565
     2566
     2567  }
     2568
    25692569  return(etavectors);
    25702570}
     
    25992599}
    26002600
    2601 */ 
     2601*/
  • Singular/LIB/powers.lib

    r95edd5 r7f3ad4  
    11// version string automatically expanded by CVS
    2 version="$Id: powers.lib,v 1.3 2008-06-26 13:17:43 motsak Exp $";
     2version="$Id: powers.lib,v 1.4 2009-01-14 16:07:05 Singular Exp $";
    33category="Linear algebra";
    44
     
    1515    exteriorBasis(int, int)        return a basis of a k-th exterior power
    1616    exteriorPower(module,int)      return k-th exterior power of a matrix
    17        
     17
    1818";
    19    
     19
    2020
    2121LIB "general.lib"; // for sort
     
    8181    p = char(basering);
    8282  }
    83    
     83
    8484  ring S = (p), (e(1..n)), dp;
    8585  def T = SuperCommutative(); setring T;
  • Singular/LIB/ratgb.lib

    r95edd5 r7f3ad4  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: ratgb.lib,v 1.12 2008-02-26 23:36:12 levandov Exp $";
     2version="$Id: ratgb.lib,v 1.13 2009-01-14 16:07:05 Singular Exp $";
    33category="Noncommutative";
    44info="
     
    1414LIB "poly.lib";
    1515
    16 //static 
     16//static