Changeset b6f755 in git


Ignore:
Timestamp:
Sep 14, 2000, 2:38:55 PM (24 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4188d308699580d975efd0f6cca8dcb41c396f70')
Children:
b4e536263bb0aa911b1f252afe51fd37579eaaa1
Parents:
88f41c23800323735502f1de13789462ad26d128
Message:
*hannes: ip.lib -> intprog.lib


git-svn-id: file:///usr/local/Singular/svn/trunk@4592 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/all.lib

    r88f41c rb6f755  
    1 // $Id: all.lib,v 1.26 2000-08-18 11:58:31 Singular Exp $
     1// $Id: all.lib,v 1.27 2000-09-14 12:37:08 Singular Exp $
    22///////////////////////////////////////////////////////////////////////////////
    33
    4 version="$Id: all.lib,v 1.26 2000-08-18 11:58:31 Singular Exp $";
     4version="$Id: all.lib,v 1.27 2000-09-14 12:37:08 Singular Exp $";
    55info="
    66LIBRARY:  all.lib   Load all libraries
     
    6969LIB "spcurve.lib";
    7070LIB "algebra.lib";
    71 LIB "ip.lib";
     71LIB "intprog.lib";
    7272LIB "toric.lib";
    7373LIB "mregular.lib"
  • Singular/LIB/toric.lib

    r88f41c rb6f755  
    1 // version="$Id: toric.lib,v 1.6 2000-08-14 12:56:58 obachman Exp $";
     1// version="$Id: toric.lib,v 1.7 2000-09-14 12:37:10 Singular Exp $";
    22
    33///////////////////////////////////////////////////////////////////////////////
    44
    55info="
    6 LIBRARY: toric.lib              COMPUTING TORIC IDEALS   
     6LIBRARY: toric.lib                COMPUTING TORIC IDEALS
    77
    88AUTHOR:  Christine Theis, email: ctheis@math.uni-sb.de
     
    1010PROCEDURES:
    1111
    12 toric_ideal(intmat A, string alg [,intvec prsv]);       computes the toric ideal of A
    13 
    14 toric_std(ideal I);     computes the standard basis of I using a specialized Buchberger algorithm
     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
    1515";
    1616
     
    2020
    2121static proc toric_ideal_1(intmat A, string alg)
    22 {       
     22{
    2323  ideal I;
    2424  // to be returned
     
    2929    "ERROR: The number of matrix columns is smaller than the number of ring variables.";
    3030    return(I);
    31   }     
     31  }
    3232
    3333  // check suitability of actual term ordering
     
    118118      "Warning: Block orderings are not supported; Dp used for computation.";
    119119    }
    120   } 
     120  }
    121121
    122122  int pos;
     
    214214    return(I);
    215215  }
    216  
     216
    217217  // check algorithm
    218218  if(alg=="ct" || alg=="pct")
     
    225225  }
    226226
    227   // create temporary file with which the external program is called 
     227  // create temporary file with which the external program is called
    228228
    229229  int dummy;
    230230  int process=system("pid");
    231   string matrixfile="temp_MATRIX"+string(process);     
     231  string matrixfile="temp_MATRIX"+string(process);
    232232  link MATRIX=":w "+matrixfile;
    233233  open(MATRIX);
     
    246246    }
    247247  }
    248  
     248
    249249  // search for positive row space vector, if required by the
    250   // algorithm   
     250  // algorithm
    251251  int found=0;
    252252  if((alg=="blr") || (alg=="hs"))
    253   { 
     253  {
    254254    for(i=1;i<=nrows(A);i++)
    255255    {
     
    269269    if(found==0)
    270270    {
    271       "ERROR: The chosen algorithm needs a 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.";
    272272      close(MATRIX);
    273273      dummy=system("sh","rm -f "+matrixfile);
    274274      return(I);
    275     } 
     275    }
    276276    write(MATRIX,"positive row space vector:");
    277277    for(j=1;j<=ncols(A);j++)
    278     { 
     278    {
    279279      write(MATRIX,A[found,j]);
    280280    }
     
    294294  pos=find(toric_id,":",pos);
    295295  pos++;
    296  
     296
    297297  while(toric_id[pos]==" " || toric_id[pos]==newline)
    298298  {
     
    306306  }
    307307  execute("generators="+number_string+";");
    308  
     308
    309309  intvec v;
    310310  poly head;
     
    339339      if(v[j]>0)
    340340      {
    341         head=head*var(j)^v[j];   
     341        head=head*var(j)^v[j];
    342342      }
    343343    }
    344344    I[i]=head-tail;
    345345  }
    346      
     346
    347347  // delete all created files
    348348  dummy=system("sh","rm -f "+matrixfile);
     
    355355
    356356static proc toric_ideal_2(intmat A, string alg, intvec prsv)
    357 {       
     357{
    358358  ideal I;
    359359  // to be returned
     
    364364    "ERROR: The number of matrix columns does not equal the size of the positive row space vector.";
    365365    return(I);
    366   }     
     366  }
    367367
    368368  // check suitability of actual basering
     
    371371    "ERROR: The number of matrix columns is smaller than the number of ring variables.";
    372372    return(I);
    373   }     
     373  }
    374374
    375375  // check suitability of actual term ordering
     
    460460      "Warning: Block orderings are not supported; Dp used for computation.";
    461461    }
    462   } 
     462  }
    463463
    464464  int pos;
     
    556556    return(I);
    557557  }
    558  
     558
    559559  // check algorithm
    560560  if(alg=="ct" || alg=="pct")
     
    567567  }
    568568
    569   // create temporary file with that the external program is called 
     569  // create temporary file with that the external program is called
    570570
    571571  int dummy;
    572572  int process=system("pid");
    573   string matrixfile="temp_MATRIX"+string(process);     
     573  string matrixfile="temp_MATRIX"+string(process);
    574574  link MATRIX=":w "+matrixfile;
    575575  open(MATRIX);
     
    591591  // enter positive row space vector, if required by the algorithm
    592592  if((alg=="blr") || (alg=="hs"))
    593   { 
     593  {
    594594    write(MATRIX,"positive row space vector:");
    595595    for(j=1;j<=ncols(A);j++)
    596     { 
     596    {
    597597      write(MATRIX,prsv[j]);
    598598    }
     
    611611  pos=find(toric_id,":",pos);
    612612  pos++;
    613  
     613
    614614  while(toric_id[pos]==" " || toric_id[pos]==newline)
    615615  {
     
    623623  }
    624624  execute("generators="+number_string+";");
    625  
     625
    626626  intvec v;
    627627  poly head;
     
    656656      if(v[j]>0)
    657657      {
    658         head=head*var(j)^v[j];   
     658        head=head*var(j)^v[j];
    659659      }
    660660    }
    661661    I[i]=head-tail;
    662662  }
    663      
     663
    664664  // delete all created files
    665665  dummy=system("sh","rm -f "+matrixfile);
     
    674674"USAGE:    toric_ideal(A,alg);      A intmat, alg string
    675675           toric_ideal(A,alg,prsv); A intmat, alg string, prsv intvec
    676 RETURN:   ideal: standard basis of the toric ideal of A 
     676RETURN:   ideal: standard basis of the toric ideal of A
    677677NOTE:     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  
     678
    679679One may call the procedure with several different algorithms:
    680680
     
    689689- the algorithm of DiBiase/Urbanke (du).
    690690
    691 The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du. 
     691The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du.
    692692
    693693If `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.
    694694
    695 For the mathematical background, see 
    696 @texinfo 
    697 @ref{Toric ideals and integer programming}. 
     695For the mathematical background, see
     696@texinfo
     697@ref{Toric ideals and integer programming}.
    698698@end texinfo
    699699EXAMPLE:  example toric_ideal; shows an example
    700 SEE ALSO: toric_std, toric_lib, ip_lib, Toric ideals
     700SEE ALSO: toric_std, toric_lib, intprog_lib, Toric ideals
    701701"
    702702{
     
    717717"EXAMPLE"; echo=2;
    718718
    719 ring r=0,(x,y,z),dp; 
     719ring r=0,(x,y,z),dp;
    720720
    721721// call with two arguments
     
    725725ideal I=toric_ideal(A,"du");
    726726I;
    727  
     727
    728728I=toric_ideal(A,"blr");
    729729I;
    730  
     730
    731731// call with three arguments
    732732intvec prsv=1,2,1;
    733733I=toric_ideal(A,"blr",prsv);
    734734I;
    735  
     735
    736736}
    737737
     
    740740proc toric_std(ideal I)
    741741"USAGE:   toric_std(I);      I ideal
    742 RETURN:   ideal: standard basis of I 
    743 NOTE:     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. 
    744 For the mathematical background, see 
    745 @texinfo 
    746 @ref{Toric ideals and integer programming}. 
     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}.
    747747@end texinfo
    748748EXAMPLE:  example toric_std; shows an example
    749 SEE ALSO: toric_ideal, toric_lib, ip_lib, Toric ideals
     749SEE ALSO: toric_ideal, toric_lib, intprog_lib, Toric ideals
    750750"
    751751{
     
    840840      "Warning: Block orderings are not supported; Dp used for computation.";
    841841    }
    842   } 
     842  }
    843843
    844844  int pos;
     
    866866    }
    867867  }
    868  
     868
    869869  if(external_ord=="" && find(singular_ord,"wp")==3)
    870870  {
     
    937937    return(I);
    938938  }
    939  
     939
    940940  // create first temporary file with which the external program is called
    941  
     941
    942942  int dummy;
    943943  int process=system("pid");
    944   string groebnerfile="temp_GROEBNER"+string(process); 
     944  string groebnerfile="temp_GROEBNER"+string(process);
    945945  link GROEBNER=":w "+groebnerfile;
    946946  open(GROEBNER);
     
    948948  write(GROEBNER,"GROEBNER","computed with algorithm:","pt","term ordering:","elimination block",0,"weighted block",nvars(basering),external_ord);
    949949  // algorithm is totally unimportant, only required by the external program
    950  
     950
    951951  for(i=1;i<=nvars(basering);i++)
    952952  {
    953953    write(GROEBNER,weightvec[i]);
    954954  }
    955  
     955
    956956  write(GROEBNER,"size:",size(I),"Groebner basis:");
    957957  poly head;
     
    962962  for(j=1;j<=size(I);j++)
    963963  {
    964     // test suitability of generator j 
     964    // test suitability of generator j
    965965    rest=I[j];
    966966    head=lead(rest);
     
    968968    tail=lead(rest);
    969969    rest=rest-tail;
    970    
     970
    971971    if(head==0 && tail==0 && rest!=0)
    972972    {
     
    976976      return(J);
    977977    }
    978    
     978
    979979    if(leadcoef(tail)!=-leadcoef(head))
    980980      // generator is no difference of monomials (or a constant multiple)
     
    985985      return(J);
    986986    }
    987        
     987
    988988    if(gcd(head,tail)!=1)
    989989    {
    990990      "Warning: The monomials of generator "+string(j)+" of the input ideal are not relatively prime.";
    991991    }
    992    
     992
    993993    // write vector representation of generator j into the file
    994994    v=leadexp(head)-leadexp(tail);
     
    999999  }
    10001000  close(GROEBNER);
    1001  
     1001
    10021002  // create second temporary file
    10031003
    1004   string newcostfile="temp_NEW_COST"+string(process);   
     1004  string newcostfile="temp_NEW_COST"+string(process);
    10051005  link NEW_COST=":w "+newcostfile;
    10061006  open(NEW_COST);
    10071007
    1008   write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 
     1008  write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:");
    10091009  for(i=1;i<=nvars(basering);i++)
    10101010  {
    10111011    write(NEW_COST,weightvec[i]);
    10121012  }
    1013  
     1013
    10141014  // call external program
    10151015  dummy=system("sh","change_cost "+groebnerfile+" "+newcostfile);
    1016  
     1016
    10171017  // read toric standard basis from created file
    10181018  link TORIC_IDEAL=":r "+newcostfile+".GB.pt";
     
    10231023  pos=find(toric_id,":",pos);
    10241024  pos++;
    1025  
     1025
    10261026  while(toric_id[pos]==" " || toric_id[pos]==newline)
    10271027  {
     
    10641064      if(v[i]>0)
    10651065      {
    1066         head=head*var(i)^v[i];   
     1066        head=head*var(i)^v[i];
    10671067      }
    10681068    }
    10691069    J[j]=head-tail;
    10701070  }
    1071      
     1071
    10721072  // delete all created files
    10731073  dummy=system("sh","rm -f "+groebnerfile);
    10741074  dummy=system("sh","rm -f "+groebnerfile+".GB.pt");
    1075   dummy=system("sh","rm -f "+newcostfile); 
     1075  dummy=system("sh","rm -f "+newcostfile);
    10761076
    10771077  return(J);
     
    10901090ideal J=toric_std(I);
    10911091J;
    1092  
     1092
    10931093// call with the same ideal, but badly chosen generators:
    1094 // 1) not only binomials 
     1094// 1) not only binomials
    10951095I=x-y,2x-y-z;
    10961096J=toric_std(I);
     
    10991099J=toric_std(I);
    11001100J;
    1101  
     1101
    11021102// call with a non-toric ideal that seems to be toric
    11031103I=x-yz,xy-z;
    11041104J=toric_std(I);
    11051105J;
    1106 // comparison with real standard basis and saturation 
     1106// comparison with real standard basis and saturation
    11071107ideal H=std(I);
    11081108H;
     
    11101110sat(H,xyz);
    11111111}
    1112 
    1113 
Note: See TracChangeset for help on using the changeset viewer.