Changeset 29c4ee in git for Singular/LIB/general.lib


Ignore:
Timestamp:
Feb 3, 2011, 2:31:47 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
c7b57f22ef0dbc32c7a7cd866e9c64d75e5f9f64
Parents:
ba490a26293bfdb10c1245e8aa0a20a4f29cd236
Message:
fix tr. 309

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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/general.lib

    rba490a2 r29c4ee  
    654654
    655655proc sort (id, list #)
    656 "USAGE:   sort(id[,v,o,n]); id = ideal/module/intvec/list(of intvec's or int's)
     656"USAGE:   sort(id[,v,o,n]); id = ideal/module/intvec/list
    657657@*       sort may be called with 1, 2 or 3 arguments in the following way:
    658658@*       sort(id[,v,n]); v=intvec of positive integers, n=integer,
     
    667667             NOTE: generators with SMALLER(!) leading term come FIRST
    668668             (e.g. sort(id); sorts backwards to actual monomial ordering)
    669            - if id=list of intvec's or int's: consider a list element, say
    670              id[1]=3,2,5, as exponent vector of the monomial x^3*y^2*z^5;
    671              the corresponding monomials are ordered w.r.t. intvec v (s.a.).
    672              If no v is present, the monomials are sorted w.r.t. ordering o
    673              (if o is given) or w.r.t. lexicographical ordering (if no o is
    674              given). The corresponding ordered list of exponent vectors is
    675              returned.
    676              (e.g. sort(id); sorts lexicographically, smaller int's come first)
    677              WARNING: Since negative exponents create the 0 polynomial in
    678              Singular, id should not contain negative integers: the result
    679              might not be as expected
    680            - if id=intvec: id is treated as list of integers
     669           - if id=list or intvec: sorted w.r.t. < (indep. of other arguments)
    681670           - if n!=0 the ordering is inverse, i.e. w.r.t. v(size(v)..1)
    682671             default: n=0
     
    718707      }
    719708   }
    720    if ( typeof(id)=="intvec" or typeof(id)=="list" and n==0 )
    721    {
    722       string o;
    723       if ( size(#)==0 ) { o = "lp"; n=1; }
    724       if ( size(#)>=1 )
    725       {
    726          if ( typeof(#[1])=="string" ) { o = #[1]; n=1; }
    727       }
    728    }
    729    if ( typeof(id)=="intvec" or typeof(id)=="list" and n==1 )
    730    {
    731       if ( typeof(id)=="list" )
    732       {
    733          for (ii=1; ii<=size(id); ii++)
    734          {
    735             if (typeof(id[ii]) != "intvec" and typeof(id[ii]) != "int")
    736                { ERROR("// list elements must be intvec/int"); }
    737             else
    738                { s=size(id[ii])*(s < size(id[ii])) + s*(s >= size(id[ii])); }
    739          }
    740       }
    741       execute("ring r=0,x(1..s),("+o+");");
    742       ideal i;
    743       poly f;
    744       for (ii=1; ii<=size(id); ii++)
    745       {
    746          f=1;
    747          for (jj=1; jj<=size(id[ii]); jj++)
    748          {
    749             f=f*x(jj)^(id[ii])[jj];
    750          }
    751          i[ii]=f;
    752       }
    753       v = sort(i)[2];
     709   if ( typeof(id)=="intvec" or typeof(id)=="list" )
     710   {
     711      int Bn,Bi,Bj,Bb;
     712      intvec pivot;
     713      for(Bi=size(id);Bi>0;Bi--) { pivot[Bi]=Bi; }
     714      while(Bj==0)
     715      {
     716        Bi++;
     717        Bj=1;
     718        for(Bn=1;Bn<=size(id)-Bi;Bn++)
     719        {
     720          if(id[pivot[Bn]]>id[pivot[Bn+1]])
     721          {
     722            Bb=pivot[Bn];
     723            pivot[Bn]=pivot[Bn+1];
     724            pivot[Bn+1]=Bb;
     725            Bj=0;
     726          }
     727        }
     728      }
     729      def Br=id;
     730      for(Bi=size(id);Bi>0;Bi--) { Br[Bi]=id[pivot[Bi]]; }
     731      return(list(Br,pivot));
    754732   }
    755733   if ( size(#)!=0 and n==0 ) { v = #[1]; }
     
    798776   sort( M, sort(lead(M), "c,dp")[2] )[1];
    799777
    800    // BUG: Please, don't use this sort for integer vectors or lists 
     778   // BUG: Please, don't use this sort for integer vectors or lists
    801779   // with them if there can be negative integers!
    802780   // TODO: for some HiWi
    803    sort(3..-3)[1]; 
    804    sort(list(-v, v))[1]; 
     781   sort(3..-3)[1];
     782   sort(list(-v, v))[1];
    805783
    806784}
Note: See TracChangeset for help on using the changeset viewer.