Changeset 030f16d in git


Ignore:
Timestamp:
Jul 28, 2000, 2:54:45 PM (24 years ago)
Author:
Christine Theis <theis@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
827a49d7d340e1a3812ae8cf7d34fce5c4ea6d54
Parents:
da5475ad68b027eb46bd3128738511f1af10775c
Message:
*** empty log message ***


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/toric.lib

    rda5475 r030f16d  
    1 // $Id: toric.lib,v 1.2 2000-05-16 08:25:01 Singular Exp $
    2 //
    3 // author : Christine Theis
    4 //
    5 //version="$Id: toric.lib,v 1.2 2000-05-16 08:25:01 Singular Exp $";
     1// version="$Id: toric.lib,v 1.3 2000-07-28 12:54:45 theis Exp $";
    62
    73///////////////////////////////////////////////////////////////////////////////
    84
    95info="
    10 LIBRARY: toric.lib                Procedures for computing toric ideals
    11 
    12 
    13 Let A an integral (mxn)-matrix. The toric ideal I_A of A is defined
    14 as the ideal
    15 
    16     I_A:=< x^u - x^v | u,v integral and nonnegative, u-v in the kernel of A >
    17 
    18 in the ring of n variables x:=x1,...,xn.
    19 Toric ideals play an important role in polyhedral geometry and may also be
    20 used for integer programming. They are generated by binomials with
    21 relatively prime monomials. Buchberger's algorithm can be specialized to
    22 these structures in a way that considerably speeds up computation.
    23 
    24 
    25 toric_ideal(intmat A, string alg);
    26 toric_ideal(intmat A, string alg, intvec prsv);
    27 
    28     procedures for computing the toric ideal of A
    29     They return the standard basis of the toric ideal of A with respect
    30     to the term ordering in the actual basering.
    31     When calling this procedure, a ring with n variables should be active.
    32     Not all term orderings are supported: The usual global term orderings
    33     may be used, but no block orderings combining them.
    34     One may call the procedure with several different algorithms:
    35 
    36         - the algorithm of Conti/Traverso using elimination (ect),
    37         - the algorithm of Pottier (pt),
    38         - an algorithm of Bigatti/La Scala/Robbiano (blr),
    39         - the algorithm of Hosten/Sturmfels (hs),
    40         - the algorithm of DiBiase/Urbanke (du).
    41 
    42     The last two seem to be the fastest in the actual implementation.
    43     `alg' should be the abbreviation (in brackets) for an algorithm
    44     as above.
    45     If `alg' is chosen to be `blr' or `hs', the algorithm needs a
    46     vector with positive coefficcients in the row space of A. If
    47     no row of A contains only positive entries, one must use the
    48     second version of toric_ideal which takes such a vector in the
    49     third argument.
    50 
    51 
    52 toric_std(ideal I);
    53 
    54     computes the standard basis of I using the specialized Buchberger
    55     algorithm. The generating system by which I is given has to consist
    56     of binomials of the form x^u-x^v (although there are other generating
    57     systems of toric ideals). There is no real check if I is toric.
    58     If the generator list of I contains a binomial whose monomials are not
    59     relatively prime, the procedure outputs a warning. If I is generated by
    60     binomials of the above form, but not toric, toric_std computes an ideal
    61     `between' I and its saturation with respect to all variables.
    62 
     6LIBRARY: toric.lib              COMPUTING TORIC IDEALS   
     7
     8AUTHOR:  Christine Theis, email: ctheis@math.uni-sb.de
     9
     10PROCEDURES:
     11
     12toric_ideal(intmat A, string alg [,intvec prsv]);       computes the toric ideal of A
     13
     14toric_std(ideal I);     computes the standard basis of I using a specialized Buchberger algorithm
    6315";
    6416
    6517///////////////////////////////////////////////////////////////////////////////
    6618
     19
     20
    6721static proc toric_ideal_1(intmat A, string alg)
    68 {
     22{       
    6923  ideal I;
    7024  // to be returned
     
    7327  if(nvars(basering)<ncols(A))
    7428  {
    75     "ERROR: number of matrix columns must be greater or equal number of ring variables";
     29    "ERROR: The number of matrix columns is smaller than the number of ring variables.";
    7630    return(I);
    77   }
     31  }     
    7832
    7933  // check suitability of actual term ordering
     
    9549    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    9650    {
    97       "Warning: block orderings are not supported; lp used for computation";
     51      "Warning: Block orderings are not supported; lp used for computation.";
    9852    }
    9953  }
     
    10862    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    10963    {
    110       "Warning: block orderings are not supported; lp used for computation";
     64      "Warning: Block orderings are not supported; lp used for computation.";
    11165    }
    11266  }
     
    12276    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    12377    {
    124       "Warning: block orderings are not supported; dp used for computation";
     78      "Warning: Block orderings are not supported; dp used for computation.";
    12579    }
    12680  }
     
    13589    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    13690    {
    137       "Warning: block orderings are not supported; dp used for computation";
     91      "Warning: Block orderings are not supported; dp used for computation.";
    13892    }
    13993  }
     
    149103    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    150104    {
    151       "Warning: block orderings are not supported; Dp used for computation";
     105      "Warning: Block orderings are not supported; Dp used for computation.";
    152106    }
    153107  }
     
    162116    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    163117    {
    164       "Warning: block orderings are not supported; Dp used for computation";
    165     }
    166   }
     118      "Warning: Block orderings are not supported; Dp used for computation.";
     119    }
     120  } 
    167121
    168122  int pos;
     
    187141    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    188142    {
    189       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
     143      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
    190144    }
    191145  }
     
    208162    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    209163    {
    210       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
     164      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
    211165    }
    212166  }
     
    230184    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    231185    {
    232       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     186      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    233187    }
    234188  }
     
    251205    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    252206    {
    253       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     207      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    254208    }
    255209  }
     
    257211  if(external_ord=="")
    258212  {
    259     "ERROR: term ordering of actual basering not supported";
     213    "ERROR: The term ordering of the actual basering is not supported.";
    260214    return(I);
    261215  }
    262 
     216 
    263217  // check algorithm
    264218  if(alg=="ct" || alg=="pct")
     
    267221    // extended matrix
    268222  {
    269     "ERROR: algorithm not suitable";
     223    "ERROR: The chosen algorithm is not suitable.";
    270224    return(I);
    271225  }
    272226
    273   // create temporary file with that the external program is called
     227  // create temporary file with which the external program is called
    274228
    275229  int dummy;
    276230  int process=system("pid");
    277   string matrixfile="temp_MATRIX"+string(process);
     231  string matrixfile="./temp_MATRIX"+string(process);   
    278232  link MATRIX=":w "+matrixfile;
    279233  open(MATRIX);
     
    292246    }
    293247  }
    294 
     248 
    295249  // search for positive row space vector, if required by the
    296   // algorithm
     250  // algorithm   
    297251  int found=0;
    298252  if((alg=="blr") || (alg=="hs"))
    299   {
     253  { 
    300254    for(i=1;i<=nrows(A);i++)
    301255    {
     
    315269    if(found==0)
    316270    {
    317       "ERROR: algorithm needs positive vector in the row space of the matrix";
     271      "ERROR: The chosen algorithm needs a positive vector in the row space of the matrix.";     
    318272      close(MATRIX);
    319273      dummy=system("sh","rm -f "+matrixfile);
    320274      return(I);
    321     }
     275    } 
    322276    write(MATRIX,"positive row space vector:");
    323277    for(j=1;j<=ncols(A);j++)
    324     {
     278    { 
    325279      write(MATRIX,A[found,j]);
    326280    }
     
    334288  // read toric ideal from created file
    335289  link TORIC_IDEAL=":r "+matrixfile+".GB."+alg;
    336   string toric_ideal=read(TORIC_IDEAL);
     290  string toric_id=read(TORIC_IDEAL);
    337291
    338292  int generators;
    339   pos=find(toric_ideal,"size");
    340   pos=find(toric_ideal,":",pos);
     293  pos=find(toric_id,"size");
     294  pos=find(toric_id,":",pos);
    341295  pos++;
    342 
    343   while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
     296 
     297  while(toric_id[pos]==" " || toric_id[pos]==newline)
    344298  {
    345299    pos++;
    346300  }
    347301  number_string="";
    348   while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    349   {
    350     number_string=number_string+toric_ideal[pos];
     302  while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     303  {
     304    number_string=number_string+toric_id[pos];
    351305    pos++;
    352306  }
    353307  execute("generators="+number_string+";");
    354 
     308 
    355309  intvec v;
    356310  poly head;
    357311  poly tail;
    358312
    359   pos=find(toric_ideal,"basis");
    360   pos=find(toric_ideal,":",pos);
     313  pos=find(toric_id,"basis");
     314  pos=find(toric_id,":",pos);
    361315  pos++;
    362316
     
    368322    for(j=1;j<=ncols(A);j++)
    369323    {
    370       while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
    371       {
    372         pos++;
    373       }
    374       number_string="";
    375       while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    376       {
    377         number_string=number_string+toric_ideal[pos];
     324      while(toric_id[pos]==" " || toric_id[pos]==newline)
     325      {
     326        pos++;
     327      }
     328      number_string="";
     329      while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     330      {
     331        number_string=number_string+toric_id[pos];
    378332        pos++;
    379333      }
     
    385339      if(v[j]>0)
    386340      {
    387         head=head*var(j)^v[j];
     341        head=head*var(j)^v[j];   
    388342      }
    389343    }
    390344    I[i]=head-tail;
    391345  }
    392 
     346     
    393347  // delete all created files
    394348  dummy=system("sh","rm -f "+matrixfile);
     
    398352}
    399353
     354
     355
    400356static proc toric_ideal_2(intmat A, string alg, intvec prsv)
    401 {
     357{       
    402358  ideal I;
    403359  // to be returned
     
    406362  if(size(prsv)<ncols(A))
    407363  {
    408     "ERROR: number of matrix columns must equal size of positive row space vector";
     364    "ERROR: The number of matrix columns does not equal the size of the positive row space vector.";
    409365    return(I);
    410   }
     366  }     
    411367
    412368  // check suitability of actual basering
    413369  if(nvars(basering)!=ncols(A))
    414370  {
    415     "ERROR: number of matrix columns must be greater or equal number of ring variables";
     371    "ERROR: The number of matrix columns is smaller than the number of ring variables.";
    416372    return(I);
    417   }
     373  }     
    418374
    419375  // check suitability of actual term ordering
     
    435391    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    436392    {
    437       "Warning: block orderings are not supported; lp used for computation";
     393      "Warning: Block orderings are not supported; lp used for computation.";
    438394    }
    439395  }
     
    448404    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    449405    {
    450       "Warning: block orderings are not supported; lp used for computation";
     406      "Warning: Block orderings are not supported; lp used for computation.";
    451407    }
    452408  }
     
    462418    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    463419    {
    464       "Warning: block orderings are not supported; dp used for computation";
     420      "Warning: Block orderings are not supported; dp used for computation.";
    465421    }
    466422  }
     
    475431    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    476432    {
    477       "Warning: block orderings are not supported; dp used for computation";
     433      "Warning: Block orderings are not supported; dp used for computation.";
    478434    }
    479435  }
     
    489445    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    490446    {
    491       "Warning: block orderings are not supported; Dp used for computation";
     447      "Warning: Block orderings are not supported; Dp used for computation.";
    492448    }
    493449  }
     
    502458    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    503459    {
    504       "Warning: block orderings are not supported; Dp used for computation";
    505     }
    506   }
     460      "Warning: Block orderings are not supported; Dp used for computation.";
     461    }
     462  } 
    507463
    508464  int pos;
     
    527483    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    528484    {
    529       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
     485      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
    530486    }
    531487  }
     
    548504    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    549505    {
    550       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
     506      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
    551507    }
    552508  }
     
    570526    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    571527    {
    572       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     528      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    573529    }
    574530  }
     
    591547    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    592548    {
    593       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     549      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    594550    }
    595551  }
     
    597553  if(external_ord=="")
    598554  {
    599     "ERROR: term ordering of actual basering not supported";
     555    "ERROR: The term ordering of the actual basering is not supported.";
    600556    return(I);
    601557  }
    602 
     558 
    603559  // check algorithm
    604560  if(alg=="ct" || alg=="pct")
     
    607563    // extended matrix
    608564  {
    609     "ERROR: algorithm not suitable";
     565    "ERROR: The chosen algorithm is not suitable.";
    610566    return(I);
    611567  }
    612568
    613   // create temporary file with that the external program is called
     569  // create temporary file with that the external program is called 
    614570
    615571  int dummy;
    616572  int process=system("pid");
    617   string matrixfile="temp_MATRIX"+string(process);
     573  string matrixfile="./temp_MATRIX"+string(process);   
    618574  link MATRIX=":w "+matrixfile;
    619575  open(MATRIX);
     
    635591  // enter positive row space vector, if required by the algorithm
    636592  if((alg=="blr") || (alg=="hs"))
    637   {
     593  { 
    638594    write(MATRIX,"positive row space vector:");
    639595    for(j=1;j<=ncols(A);j++)
    640     {
     596    { 
    641597      write(MATRIX,prsv[j]);
    642598    }
     
    649605  // read toric ideal from created file
    650606  link TORIC_IDEAL=":r "+matrixfile+".GB."+alg;
    651   string toric_ideal=read(TORIC_IDEAL);
     607  string toric_id=read(TORIC_IDEAL);
    652608
    653609  int generators;
    654   pos=find(toric_ideal,"size");
    655   pos=find(toric_ideal,":",pos);
     610  pos=find(toric_id,"size");
     611  pos=find(toric_id,":",pos);
    656612  pos++;
    657 
    658   while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
     613 
     614  while(toric_id[pos]==" " || toric_id[pos]==newline)
    659615  {
    660616    pos++;
    661617  }
    662618  number_string="";
    663   while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    664   {
    665     number_string=number_string+toric_ideal[pos];
     619  while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     620  {
     621    number_string=number_string+toric_id[pos];
    666622    pos++;
    667623  }
    668624  execute("generators="+number_string+";");
    669 
     625 
    670626  intvec v;
    671627  poly head;
    672628  poly tail;
    673629
    674   pos=find(toric_ideal,"basis");
    675   pos=find(toric_ideal,":",pos);
     630  pos=find(toric_id,"basis");
     631  pos=find(toric_id,":",pos);
    676632  pos++;
    677633
     
    683639    for(j=1;j<=ncols(A);j++)
    684640    {
    685       while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
    686       {
    687         pos++;
    688       }
    689       number_string="";
    690       while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    691       {
    692         number_string=number_string+toric_ideal[pos];
     641      while(toric_id[pos]==" " || toric_id[pos]==newline)
     642      {
     643        pos++;
     644      }
     645      number_string="";
     646      while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     647      {
     648        number_string=number_string+toric_id[pos];
    693649        pos++;
    694650      }
     
    700656      if(v[j]>0)
    701657      {
    702         head=head*var(j)^v[j];
     658        head=head*var(j)^v[j];   
    703659      }
    704660    }
    705661    I[i]=head-tail;
    706662  }
    707 
     663     
    708664  // delete all created files
    709665  dummy=system("sh","rm -f "+matrixfile);
     
    713669}
    714670
     671
     672
    715673proc toric_ideal
    716 "USAGE:
    717 toric_ideal(A,alg);            A intmat, alg string
    718 toric_ideal(A,alg,prsv);       A intmat, alg string, prsv intvec
    719 RETURN:  toric ideal of A as explained in toric.lib
    720          return type = ideal
    721 EXAMPLE: example toric_ideal;  shows an example"
     674"USAGE:    toric_ideal(A,alg);      A intmat, alg string
     675           toric_ideal(A,alg,prsv); A intmat, alg string, prsv intvec
     676RETURN:   ideal: standard basis of the toric ideal of A
     677NOTE:     These procedures return the standard basis of the toric ideal of A with respect to the term ordering in the actual basering. Not all term orderings are supported: The usual global term orderings may be used, but no block orderings combining them.
     678 
     679One may call the procedure with several different algorithms:
     680
     681- the algorithm of Conti/Traverso using elimination (ect),
     682
     683- the algorithm of Pottier (pt),
     684
     685- an algorithm of Bigatti/La Scala/Robbiano (blr),
     686
     687- the algorithm of Hosten/Sturmfels (hs),
     688
     689- the algorithm of DiBiase/Urbanke (du).
     690
     691The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du.
     692
     693If `alg' is chosen to be `blr' or `hs', the algorithm needs a vector with positive coefficcients in the row space of A. If no row of A contains only positive entries, one has to use the second version of toric_ideal which takes such a vector as its third argument.
     694
     695For the mathematical background, see
     696@texinfo
     697@ref{Toric ideals and integer programming}.
     698@end texinfo
     699EXAMPLE:  example toric_ideal; shows an example
     700SEE ALSO: toric_std, toric_lib, IP_lib, toric ideals
     701"
    722702{
    723703  if(size(#)==2)
     
    730710  }
    731711}
     712
     713
     714
    732715example
    733716{
    734   "EXAMPLE"; echo=2;
    735  
    736   ring r=0,(x,y,z),dp;
    737  
    738   // call with two arguments
    739   intmat A[2][3]=1,1,0,0,1,1;
    740   A;
    741  
    742   ideal I=toric_ideal(A,"du");
    743   I;
    744   
    745   I=toric_ideal(A,"blr");
    746   I;
    747   
    748   // call with three arguments
    749   intvec prsv=1,2,1;
    750   I=toric_ideal(A,"blr",prsv);
    751   I;
    752 
     717"EXAMPLE"; echo=2;
     718
     719ring r=0,(x,y,z),dp;
     720
     721// call with two arguments
     722intmat A[2][3]=1,1,0,0,1,1;
     723A;
     724
     725// ideal I=toric_ideal(A,"du");
     726// I;
     727 
     728// I=toric_ideal(A,"blr");
     729// I;
     730 
     731// call with three arguments
     732intvec prsv=1,2,1;
     733// I=toric_ideal(A,"blr",prsv);
     734// I;
     735 
    753736}
    754737
     738
     739
    755740proc toric_std(ideal I)
    756 "USAGE:   toric_std(I);        I ideal
    757 RETURN:  standard basis of I as explained in toric.lib
    758          return type = ideal
    759 EXAMPLE: example toric_std;   shows an example"
     741"USAGE:   toric_std(I);      I ideal
     742RETURN:   ideal: standard basis of I
     743NOTE:     This procedure computes the standard basis of I using a specialized Buchberger algorithm. The generating system by which I is given has to consist of binomials of the form x^u-x^v. There is no real check if I is toric. If I is generated by binomials of the above form, but not toric, toric_std computes an ideal `between' I and its saturation with respect to all variables.
     744For the mathematical background, see
     745@texinfo
     746@ref{Toric ideals and integer programming}.
     747@end texinfo
     748EXAMPLE:  example toric_std; shows an example
     749SEE ALSO: toric_ideal, toric_lib, IP_lib, toric ideals
     750"
    760751{
    761752  ideal J;
     
    780771    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    781772    {
    782       "Warning: block orderings are not supported; lp used for computation";
     773      "Warning: Block orderings are not supported; lp used for computation.";
    783774    }
    784775  }
     
    793784    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    794785    {
    795       "Warning: block orderings are not supported; lp used for computation";
     786      "Warning: Block orderings are not supported; lp used for computation.";
    796787    }
    797788  }
     
    807798    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    808799    {
    809       "Warning: block orderings are not supported; dp used for computation";
     800      "Warning: Block orderings are not supported; dp used for computation.";
    810801    }
    811802  }
     
    820811    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    821812    {
    822       "Warning: block orderings are not supported; dp used for computation";
     813      "Warning: Block orderings are not supported; dp used for computation.";
    823814    }
    824815  }
     
    834825    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    835826    {
    836       "Warning: block orderings are not supported; Dp used for computation";
     827      "Warning: Block orderings are not supported; Dp used for computation.";
    837828    }
    838829  }
     
    847838    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    848839    {
    849       "Warning: block orderings are not supported; Dp used for computation";
    850     }
    851   }
     840      "Warning: Block orderings are not supported; Dp used for computation.";
     841    }
     842  } 
    852843
    853844  int pos;
     
    872863    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    873864    {
    874       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
    875     }
    876   }
    877 
     865      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
     866    }
     867  }
     868 
    878869  if(external_ord=="" && find(singular_ord,"wp")==3)
    879870  {
     
    894885    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    895886    {
    896       "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";
     887      "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation.";
    897888    }
    898889  }
     
    916907    if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c"))
    917908    {
    918       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     909      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    919910    }
    920911  }
     
    937928    if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord))
    938929    {
    939       "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";
     930      "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation.";
    940931    }
    941932  }
     
    943934  if(external_ord=="")
    944935  {
    945     "ERROR: term ordering of actual basering not supported";
     936    "ERROR: The term ordering of the actual basering is not supported.";
    946937    return(I);
    947938  }
    948 
     939 
    949940  // create first temporary file with which the external program is called
    950 
     941 
    951942  int dummy;
    952943  int process=system("pid");
    953   string groebnerfile="temp_GROEBNER"+string(process);
     944  string groebnerfile="./temp_GROEBNER"+string(process);       
    954945  link GROEBNER=":w "+groebnerfile;
    955946  open(GROEBNER);
     
    957948  write(GROEBNER,"GROEBNER","computed with algorithm:","pt","term ordering:","elimination block",0,"weighted block",nvars(basering),external_ord);
    958949  // algorithm is totally unimportant, only required by the external program
    959 
     950 
    960951  for(i=1;i<=nvars(basering);i++)
    961952  {
    962953    write(GROEBNER,weightvec[i]);
    963954  }
    964 
     955 
    965956  write(GROEBNER,"size:",size(I),"Groebner basis:");
    966957  poly head;
     
    971962  for(j=1;j<=size(I);j++)
    972963  {
    973     // test suitability of generator j
     964    // test suitability of generator j 
    974965    rest=I[j];
    975966    head=lead(rest);
     
    977968    tail=lead(rest);
    978969    rest=rest-tail;
    979 
     970   
    980971    if(head==0 && tail==0 && rest!=0)
    981972    {
    982       "ERROR: generator "+string(j)+" of input ideal is no binomial";
     973      "ERROR: Generator "+string(j)+" of the input ideal is no binomial.";
    983974      close(GROEBNER);
    984975      dummy=system("sh","rm -f "+groebnerfile);
    985976      return(J);
    986977    }
    987 
     978   
    988979    if(leadcoef(tail)!=-leadcoef(head))
    989       // generator no difference of monomials (or a constant multiple)
    990     {
    991       "ERROR: generator "+string(j)+" of input ideal is no difference of monomials";
     980      // generator is no difference of monomials (or a constant multiple)
     981    {
     982      "ERROR: Generator "+string(j)+" of the input ideal is no difference of monomials.";
    992983      close(GROEBNER);
    993984      dummy=system("sh","rm -f "+groebnerfile);
    994985      return(J);
    995986    }
    996 
     987       
    997988    if(gcd(head,tail)!=1)
    998989    {
    999       "Warning: monomials of generator "+string(j)+" of input ideal are not relatively prime";
    1000     }
    1001 
     990      "Warning: The monomials of generator "+string(j)+" of the input ideal are not relatively prime.";
     991    }
     992   
    1002993    // write vector representation of generator j into the file
    1003994    v=leadexp(head)-leadexp(tail);
     
    1008999  }
    10091000  close(GROEBNER);
    1010 
     1001 
    10111002  // create second temporary file
    10121003
    1013   string newcostfile="temp_NEW_COST"+string(process);
     1004  string newcostfile="./temp_NEW_COST"+string(process);
    10141005  link NEW_COST=":w "+newcostfile;
    10151006  open(NEW_COST);
    10161007
    1017   write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:");
     1008  write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 
    10181009  for(i=1;i<=nvars(basering);i++)
    10191010  {
    10201011    write(NEW_COST,weightvec[i]);
    10211012  }
    1022 
     1013 
    10231014  // call external program
    10241015  dummy=system("sh","change_cost "+groebnerfile+" "+newcostfile);
    1025 
     1016 
    10261017  // read toric standard basis from created file
    10271018  link TORIC_IDEAL=":r "+newcostfile+".GB.pt";
    1028   string toric_ideal=read(TORIC_IDEAL);
     1019  string toric_id=read(TORIC_IDEAL);
    10291020
    10301021  int generators;
    1031   pos=find(toric_ideal,"size");
    1032   pos=find(toric_ideal,":",pos);
     1022  pos=find(toric_id,"size");
     1023  pos=find(toric_id,":",pos);
    10331024  pos++;
    1034 
    1035   while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
     1025 
     1026  while(toric_id[pos]==" " || toric_id[pos]==newline)
    10361027  {
    10371028    pos++;
    10381029  }
    10391030  number_string="";
    1040   while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    1041   {
    1042     number_string=number_string+toric_ideal[pos];
     1031  while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     1032  {
     1033    number_string=number_string+toric_id[pos];
    10431034    pos++;
    10441035  }
    10451036  execute("generators="+number_string+";");
    10461037
    1047   pos=find(toric_ideal,"basis");
    1048   pos=find(toric_ideal,":",pos);
     1038  pos=find(toric_id,"basis");
     1039  pos=find(toric_id,":",pos);
    10491040  pos++;
    10501041
     
    10561047    for(i=1;i<=nvars(basering);i++)
    10571048    {
    1058       while(toric_ideal[pos]==" " || toric_ideal[pos]==newline)
    1059       {
    1060         pos++;
    1061       }
    1062       number_string="";
    1063       while(toric_ideal[pos]!=" " && toric_ideal[pos]!=newline)
    1064       {
    1065         number_string=number_string+toric_ideal[pos];
     1049      while(toric_id[pos]==" " || toric_id[pos]==newline)
     1050      {
     1051        pos++;
     1052      }
     1053      number_string="";
     1054      while(toric_id[pos]!=" " && toric_id[pos]!=newline)
     1055      {
     1056        number_string=number_string+toric_id[pos];
    10661057        pos++;
    10671058      }
     
    10731064      if(v[i]>0)
    10741065      {
    1075         head=head*var(i)^v[i];
     1066        head=head*var(i)^v[i];   
    10761067      }
    10771068    }
    10781069    J[j]=head-tail;
    10791070  }
    1080 
     1071     
    10811072  // delete all created files
    10821073  dummy=system("sh","rm -f "+groebnerfile);
    10831074  dummy=system("sh","rm -f "+groebnerfile+".GB.pt");
    1084   dummy=system("sh","rm -f "+newcostfile);
     1075  dummy=system("sh","rm -f "+newcostfile); 
    10851076
    10861077  return(J);
    10871078}
     1079
     1080
     1081
    10881082example
    10891083{
    1090   "EXAMPLE"; echo=2;
    1091  
    1092   ring r=0,(x,y,z),wp(3,2,1);
    1093  
    1094   // call with toric ideal (of the matrix A=(1,1,1))
    1095   ideal I=x-y,x-z;
    1096   ideal J=toric_std(I);
    1097   J;
    1098   
    1099   // call with the same ideal, but badly chosen generators:
    1100   // not only binomials
    1101   I=x-y,2x-y-z;
    1102   J=toric_std(I);
    1103   // binomials whose monomials are not relatively prime
    1104   I=x-y,xy-yz,y-z;
    1105   J=toric_std(I);
    1106   J;
    1107   
    1108   // call with a non-toric ideal that seems to be toric
    1109   I=x-yz,xy-z;
    1110   J=toric_std(I);
    1111   J;
    1112   // comparison with real standard basis and saturation
    1113   ideal H=std(I);
    1114   H;
    1115   LIB "elim.lib";
    1116   sat(H,xyz);
     1084"EXAMPLE"; echo=2;
     1085
     1086ring r=0,(x,y,z),wp(3,2,1);
     1087
     1088// call with toric ideal (of the matrix A=(1,1,1))
     1089ideal I=x-y,x-z;
     1090//ideal J=toric_std(I);
     1091//J;
     1092 
     1093// call with the same ideal, but badly chosen generators:
     1094// 1) not only binomials
     1095I=x-y,2x-y-z;
     1096//J=toric_std(I);
     1097// 2) binomials whose monomials are not relatively prime
     1098I=x-y,xy-yz,y-z;
     1099//J=toric_std(I);
     1100//J;
     1101 
     1102// call with a non-toric ideal that seems to be toric
     1103I=x-yz,xy-z;
     1104//J=toric_std(I);
     1105//J;
     1106// comparison with real standard basis and saturation
     1107ideal H=std(I);
     1108H;
     1109LIB "elim.lib";
     1110sat(H,xyz);
    11171111}
    11181112
    1119 //////////////////////////////////////////////////////////////////////////////
     1113
Note: See TracChangeset for help on using the changeset viewer.