Changeset 6e118cf in git


Ignore:
Timestamp:
Sep 24, 2008, 3:44:01 PM (15 years ago)
Author:
Stanislav Bulygin <bulygin@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
56fba11a0c7f7e483a766ea6ee166b22f2f7f6ef
Parents:
a1268301053fa4acc4bf30c8f2e760fe2df2bb7f
Message:
adding comments and delimiters


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/decodegb.lib

    ra12683 r6e118cf  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: decodegb.lib,v 1.3 2008-09-23 11:58:38 bulygin Exp $";
     2version="$Id: decodegb.lib,v 1.4 2008-09-24 13:44:01 bulygin Exp $";
    33category="Coding theory";
    44info="
     
    4545
    4646///////////////////////////////////////////////////////////////////////////////
    47 
     47// creates a list result, where result[i]=i, 1<=i<=n
    4848static proc lis (int n)
    4949{
     
    5757}
    5858
     59///////////////////////////////////////////////////////////////////////////////
     60// creates a list of all combinations without repititions of m objects out of n
    5961static proc combinations (int m, int n)
    6062{
     
    7274}
    7375
    74 static proc combinsert (list temp, int i)
    75 {
    76  list result;
    77  list tmp;
    78  int j,k;
    79  for (j=1; j<=size(temp); j++)
    80  {
    81   result[j]=tmp;
    82  }
    83  for (j=1; j<=size(temp); j++)
    84  {
    85   for (k=1; k<=size(temp[j]); k++)
    86   {
    87    if (temp[j][k]<i) {result[j][k]=temp[j][k];}
    88    else {result[j][k]=temp[j][k]+1;}
    89   }
    90  }
    91  return(result);   
    92 }
    93 
     76
     77///////////////////////////////////////////////////////////////////////////////
     78// the poolynomial for Sala's restrictions
    9479static proc p_poly(int n, int a, int b)
    9580{
     
    10186  return(f);
    10287}
     88
     89///////////////////////////////////////////////////////////////////////////////
    10390
    10491proc sysCRHT (int n, list defset, int e, int q, int m, int #)
     
    116103  poly sum;
    117104 
    118   // check equations
     105  //------------ add check equations -----------------
    119106  for (i=1; i<=r; i++)
    120107  {
     
    127114  }
    128115 
    129   // restrictions on syndromes
     116  //------------ field equations on syndromes -----------
    130117  for (i=1; i<=r; i++)
    131118  {
     
    133120  }
    134121 
    135   // n-th roots of unity
     122  //------------ restrictions on error-locations: n-th roots of unity --------------
    136123  for (i=1; i<=e; i++)
    137124  {
     
    144131  } 
    145132 
     133  //------------ add Sala's additional conditions if necessary -----------------
    146134  if (#)
    147135  {
     
    190178}
    191179
     180///////////////////////////////////////////////////////////////////////////////
     181
    192182
    193183proc sysCRHTMindistBinary (int n, list defset, int w)
     
    204194  poly sum;
    205195 
    206   // check equations
     196  //------------ add check equations --------------
    207197  for (i=1; i<=r; i++)
    208198  {
     
    216206 
    217207 
    218   // n-th roots of unity
     208  //----------- locations are n-th roots of unity ------------
    219209  for (i=1; i<=w; i++)
    220210  {
     
    222212  } 
    223213 
    224  
     214  //------------ adding conditions on locations being different ------------
    225215  for (i=1; i<=w; i++)
    226216  {
     
    253243}
    254244
     245///////////////////////////////////////////////////////////////////////////////
     246// slightly modified mod function
    255247static proc mod_ (int n, int m)
    256248{
     
    258250  if (n mod m!=0) {return(n mod m);}
    259251}
     252
     253///////////////////////////////////////////////////////////////////////////////
    260254
    261255proc sysNewton (int n, list defset, int t, int q, int m, int #)
     
    300294 
    301295 
    302  // generate generalized Newton identities
     296 //------------ generate generalized Newton identities ----------
    303297 if (#)
    304298 {
     
    334328 }
    335329 
    336  // field equations on sigma's
     330 //----------- add field equations on sigma's --------------
    337331 for (i=1; i<=t; i++)
    338332 {
     
    340334 }
    341335 
    342  // conjugacy relations
     336 //----------- add conjugacy relations ------------------
    343337 for (i=1; i<=n; i++)
    344338 {
     
    371365}
    372366
     367///////////////////////////////////////////////////////////////////////////////
     368// forms a list of special combinations needed for computation of Waring's function
    373369static proc combinations_sum (int m, int n)
    374370{
     
    404400}
    405401
     402///////////////////////////////////////////////////////////////////////////////
     403//if n=q^e*m, m and n are coprime, then return e
    406404static proc exp_count (int n, int q)
    407405{
     
    415413 return(result);
    416414}
     415
     416///////////////////////////////////////////////////////////////////////////////
    417417
    418418
     
    459459  Q_update=Q;
    460460 }
    461    
     461 
     462 //-------------- form polynomials for the Bin system via Waring's function -------------- 
    462463 for (i=1; i<=size(Q_update); i++)
    463464 {
     
    511512}
    512513
     514///////////////////////////////////////////////////////////////////////////////
     515
    513516proc encode (matrix x, matrix g)
    514517"USAGE:  encode (x, g);  x a row vector (message), and g a generator matrix
     
    532535     print(encode(x,g));
    533536}
     537
     538///////////////////////////////////////////////////////////////////////////////
    534539
    535540proc syndrome (matrix h, matrix c)
     
    564569}
    565570
     571///////////////////////////////////////////////////////////////////////////////
     572// (coordinatewise) star product of two vectors
    566573static proc star(matrix m, int i, int j)
    567574{
     
    573580 return(result);
    574581}
     582
     583///////////////////////////////////////////////////////////////////////////////
    575584
    576585proc sysQE(matrix check, matrix y, int t, int fieldeq, int formal)
     
    623632 matrix transf=inverse(transpose(h_full));
    624633 
     634 //----------- expression matrix of check vectors w.r.t. the MDS basis --------------
    625635 tim=rtimer;
    626636 for (i=1; i<=red ; i++)
     
    630640 }
    631641 
     642 //----------- compute the structure constants ------------------------
    632643 tim=rtimer;
    633644 matrix te[n][1];
     
    694705  }
    695706 }
     707 
     708 //--------- form the quadratic equations according to the theory ---------------
    696709 for (i=1; i<=n; i++)
    697710 {
     
    743756}
    744757
     758///////////////////////////////////////////////////////////////////////////////
     759
    745760proc errorInsert(matrix y, list pos, list val)
    746761"USAGE:  errorInsert(y, pos, val); y is a (code) word, pos = positions where errors occured, val = their corresponding values
     
    775790}
    776791
     792///////////////////////////////////////////////////////////////////////////////
     793
    777794proc errorRand(matrix y, int num, int e)
    778795"USAGE:    errorRand(y, num, e); y is a (code) word, num is the number of errors, e is an extension degree (if one wants values to
     
    835852}
    836853
     854///////////////////////////////////////////////////////////////////////////////
     855
    837856proc randomCheck(int m, int n, int e, int #)
    838857"USAGE:    randomCheck(m, n, e); m x n are dimensions of the matrix, e is an extension degree (if one wants values to
     
    870889     print(g);     
    871890}
     891
     892///////////////////////////////////////////////////////////////////////////////
    872893
    873894proc genMDSMat(int n, number a)
     
    901922}
    902923
     924///////////////////////////////////////////////////////////////////////////////
     925
    903926
    904927proc mindist (matrix check)
     
    925948 option(redSB);
    926949 def A=sysQE(check,z,count,0,0);
     950
     951 //----------- proceed with solving the system w.r.t zero vector until some solutions are found --------------------
    927952 while (flag)
    928953 {
     
    971996}
    972997
     998///////////////////////////////////////////////////////////////////////////////
     999
    9731000proc decode(matrix check, matrix rec)
    9741001"USAGE:    decode(check, rec, t); check is the check matrix of the code
     
    10441071}
    10451072
     1073///////////////////////////////////////////////////////////////////////////////
     1074
    10461075
    10471076proc solveForRandom(int n, int redun, int ncodes, int ntrials, int #)
     
    10661095 matrix z[1][ncols(h_full)];
    10671096 int n=ncols(h_full);
     1097
     1098 //------------------ determine error-correction capacity -------------------
    10681099 for (i=1; i<=ncodes; i++)
    10691100 {
     
    10851116  tim2=rtimer; 
    10861117  tim3=rtimer;
     1118
     1119  //------------- generate the template system ----------------------
    10871120  def A=sysQE(h,z,t,0,0);
    10881121  setring A;
     
    10941127  print("The system is generated");
    10951128  timdec3=timdec3+rtimer-tim3; 
     1129
     1130  //------------- modify the template according to every received word -------------------
    10961131  for (j=1; j<=ntrials; j++)
    10971132  {
     
    11231158}
    11241159
     1160///////////////////////////////////////////////////////////////////////////////
     1161
    11251162
    11261163proc solveForCode(matrix check, int ntrials, int #)
     
    11491186 h=check;
    11501187 print(h);
     1188
     1189 //------------------ determine error-correction capacity -------------------
    11511190 if (#>0)
    11521191 {
     
    11631202 tim2=rtimer; 
    11641203 tim3=rtimer;
     1204
     1205 //------------- generate the template system ----------------------
    11651206 def A=sysQE(h,z,t,0,0);
    11661207 setring A;
     
    11711212 ideal sys=qe;
    11721213 print("The system is generated");
    1173  timdec3=timdec3+rtimer-tim3; 
     1214 timdec3=timdec3+rtimer-tim3;
     1215
     1216 //------------- modify the template according to every received word -------------------
    11741217 for (j=1; j<=ntrials; j++)
    11751218 {
     
    12021245
    12031246
    1204 static proc list2intvec (list l)
    1205 {
    1206  intvec result;
    1207  for (int i=1; i<=size(l); i++)
    1208  {
    1209   result[i]=l[i];
    1210  }
    1211  return(result);
    1212 }
    1213    
    1214 
     1247///////////////////////////////////////////////////////////////////////////////
     1248// adding syndrome values to the template system
    12151249static proc add_synd (matrix rec, matrix check, int redun, ideal sys)
    12161250{
     
    12251259}
    12261260
     1261///////////////////////////////////////////////////////////////////////////////
     1262// evaluate a polynomial at a given point
    12271263static proc ev (poly f, matrix p)
    12281264{
     
    12371273}
    12381274
     1275//////////////////////////////////////////////////////////////////////////////////////
     1276// return index of an element in the ideal where it does not vanish at the given point
    12391277static proc find_index (ideal G, matrix p)
    12401278{
     
    12501288}
    12511289
     1290///////////////////////////////////////////////////////////////////////////////
     1291// convert ideal to list
    12521292static proc ideal2list (ideal id)
    12531293{
     
    12601300}
    12611301
     1302///////////////////////////////////////////////////////////////////////////////
     1303// convert list to ideal
    12621304static proc list2ideal (list l)
    12631305{
     
    12701312}
    12711313
     1314////////////////////////////////////////////////////////////////////////////////////
     1315// checl whether given polynomial is divisible by some leading monomial of the ideal
    12721316static proc divisible (poly m, ideal G)
    12731317{
     
    12781322     return(0);
    12791323}
     1324
     1325///////////////////////////////////////////////////////////////////////////////
    12801326
    12811327proc vanishId (list points)
     
    12921338     list temp;
    12931339     poly h,cur;
     1340
     1341     //------------- proceed according to Farr-Gao algorithm ----------------
    12941342     for (k=1; k<=n; k++)
    12951343     {         
     
    13251373     
    13261374     //generate all 3-vectors over GF(3)
    1327      list points=points_gen(3,1);
    1328      
    1329      list points2=conv_points(points);
     1375     list points=pointsGen(3,1);
     1376     
     1377     list points2=convPoints(points);
    13301378     
    13311379     //grasps the first 11 points
    1332      list p=grasp_list(points2,1,11);
     1380     list p=graspList(points2,1,11);
    13331381     print(p);
    13341382     
     
    13381386}
    13391387
    1340 proc points_gen (int m, int e)
     1388//////////////////////////////////////////////////////////////////////////////////////////////////
     1389// construct the list of all vectors of length m with elements in p^e, where p is characteristics
     1390proc pointsGen (int m, int e)
    13411391{
    13421392     if (e>1)
     
    13641414          return(result);
    13651415     }
    1366      list prev=points_gen(m-1,e);     
     1416     list prev=pointsGen(m-1,e);     
    13671417     for (i=1; i<=size(prev); i++)
    13681418     {
     
    14011451          return(result);
    14021452     }
    1403      list prev=points_gen(m-1,e);     
     1453     list prev=pointsGen(m-1,e);     
    14041454     for (i=1; i<=size(prev); i++)
    14051455     {
     
    14161466}
    14171467
     1468///////////////////////////////////////////////////////////////////////////////
     1469// convert list to a column vector
    14181470static proc list2vec (list l)
    14191471{
     
    14261478}
    14271479
    1428 proc conv_points (list points)
     1480///////////////////////////////////////////////////////////////////////////////
     1481// convert all the point in the list with list2vec
     1482proc convPoints (list points)
    14291483{
    14301484     for (int i=1; i<=size(points); i++)
     
    14351489}
    14361490
    1437 proc grasp_list (list l, int m, int n)
     1491///////////////////////////////////////////////////////////////////////////////
     1492// extracts elements from l in the range m..n
     1493proc graspList (list l, int m, int n)
    14381494{
    14391495     list result;
     
    14471503}
    14481504
     1505///////////////////////////////////////////////////////////////////////////////
     1506// "characteristic" polynomial
    14491507static proc xi_gen (matrix p, int e, int s)
    14501508{
     
    14601518}
    14611519
     1520///////////////////////////////////////////////////////////////////////////////
     1521// generating polynomials in Fitzgerald-Lax construction
    14621522static proc gener_funcs (matrix check, list points, int e, ideal id, int s)
    14631523{
     
    14851545}
    14861546
     1547///////////////////////////////////////////////////////////////////////////////
     1548
    14871549proc sysFL (matrix check, matrix y, int t, int e, int s)
    14881550"USAGE:    sysFL (check,y,t,e,s); check is a check matrix of the code, y is a received word, t the number of errors to correct,
     
    14961558     int n=ncols(check);
    14971559     int m=nrows(check);         
    1498      list points=points_gen(s,e);
    1499      list points2=conv_points(points);
    1500      list p=grasp_list(points2,1,n);     
     1560     list points=pointsGen(s,e);
     1561     list points2=convPoints(points);
     1562     list p=graspList(points2,1,n);     
    15011563     ideal id=vanishId(p,e);     
    15021564     ideal funcs=gener_funcs(check,p,e,id,s);         
     
    15061568     int i,j,k;
    15071569     
    1508      //vanishing realtions     
     1570     //--------------- add vanishing realtions ---------------------
    15091571     for (i=1; i<=t; i++)
    15101572     {         
     
    15201582     }         
    15211583     
    1522      //field equations
     1584     //--------------- add field equations --------------------
    15231585     for (i=1; i<=t; i++)
    15241586     {
     
    15351597     result=simplify(result,8);
    15361598     
    1537      //check realtions
     1599     //--------------- add check realtions --------------------
    15381600     poly sum;
    15391601     matrix syn[m][1]=syndrome(check,y);         
     
    15901652}
    15911653
     1654///////////////////////////////////////////////////////////////////////////////
     1655// preprocessing steps for the Fitzgerald-Lax scheme
    15921656proc FLpreprocess (int p, int e, int n, int t, string minp)
    15931657{
     
    16701734}
    16711735
     1736///////////////////////////////////////////////////////////////////////////////
     1737// imitating two indeces
    16721738static proc x_var (int i, int j, int s)
    16731739{     
     
    16751741}
    16761742
     1743///////////////////////////////////////////////////////////////////////////////
     1744// random vector of length n with entries from p^e, p the characteristic
    16771745static proc randomvector(int n, int e, int #)
    16781746{     
     
    16861754}
    16871755
     1756////////////////////////////////////////////////////////////////////////////////////////////
     1757// "convert" representation of an element from the field extension from vector to an elelemnt
    16881758static proc asElement(list l)
    16891759{
     
    16991769}
    17001770
    1701 proc random_prime_vector (int n, int #)
     1771///////////////////////////////////////////////////////////////////////////////
     1772// random vector of length n with entries from p, p the characteristic
     1773static proc random_prime_vector (int n, int #)
    17021774{
    17031775  if (#==1)
     
    17161788  return(l);
    17171789}
     1790
     1791///////////////////////////////////////////////////////////////////////////////
    17181792
    17191793proc solveForRandomFL(int n, int redun, int p, int e, int t, int ncodes, int ntrials, string minpol)
     
    17481822     g=dual_code(h);
    17491823     tim2=rtimer;       
    1750      tim3=rtimer;               
     1824     tim3=rtimer;
     1825
     1826     //------------ generate the template system ------------------               
    17511827     sys=sysFL(h,z,t,e,s_work);     
    17521828     timdec3=timdec3+rtimer-tim3;
    17531829   
     1830     //------------- modifying the template according to the received word ---------------
    17541831     for (j=1; j<=ntrials; j++)
    17551832     {
     
    17761853}
    17771854
     1855///////////////////////////////////////////////////////////////////////////////
     1856// add syndrome values to the template system in FL
    17781857static proc LF_add_synd (matrix rec, matrix check, ideal sys)
    17791858{
Note: See TracChangeset for help on using the changeset viewer.