Changeset ff8d25 in git


Ignore:
Timestamp:
Dec 31, 2000, 2:55:11 AM (22 years ago)
Author:
Gert-Martin Greuel <greuel@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
bb7da752a854cf4b094e8dde30a8a98f0c5bb32f
Parents:
2b4e7066de6a1ca22687a95c7411269e78fe38d8
Message:
* GMG: lcm fuer integers erweitert, Funktionalitaet auf Listen ausgedehnt.
*      Kosmetik


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/poly.lib

    r2b4e70 rff8d25  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: poly.lib,v 1.29 2000-12-22 14:22:23 greuel Exp $";
     2version="$Id: poly.lib,v 1.30 2000-12-31 01:55:11 greuel Exp $";
    33category="General purpose";
    44info="
     
    133133proc freerank
    134134"USAGE:   freerank(M[,any]);  M=poly/ideal/vector/module/matrix
    135 COMPUTE: rank of module presented by M in case it is free. By definition this
    136          is vdim(coker(M)/m*coker(M)) if coker(M) is free, where m = maximal
    137          ideal of basering and M is considered as matrix (the 0-module is
    138          free of rank 0)
     135COMPUTE: rank of module presented by M in case it is free.
     136         By definition this is vdim(coker(M)/m*coker(M)) if coker(M)
     137         is free, where m = maximal ideal of the variables of the
     138         basering and M is considered as matrix.
     139         (the 0-module is free of rank 0)
    139140RETURN:  rank of coker(M) if coker(M) is free and -1 else;
    140141         in case of a second argument return a list:
     
    159160  ideal i=x;
    160161  module M=[x,0,1],[-x,0,-1];
    161   freerank(M);           // should be 2, coker(M) is not free
    162   freerank(syz (M),"");  // [1] should be 1, coker(syz(M))=M is free of rank 1
    163                          // [2] should be gen(2)+gen(1) (minimal relation of M)
     162  freerank(M);          // should be 2, coker(M) is not free
     163  freerank(syz (M),"");
     164  // [1] should be 1, coker(syz(M))=M is free of rank 1
     165  // [2] should be gen(2)+gen(1) (minimal relation of M)
    164166  freerank(i);
    165   freerank(syz(i));      // should be 1, coker(syz(i))=i is free of rank 1
     167  freerank(syz(i));     // should be 1, coker(syz(i))=i is free of rank 1
    166168}
    167169///////////////////////////////////////////////////////////////////////////////
     
    208210proc is_zero
    209211"USAGE:   is_zero(M[,any]); M=poly/ideal/vector/module/matrix
    210 RETURN:  integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is considered
    211          as matrix
    212          if a second argument is given, return a list:
     212RETURN:  integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is
     213         considered as matrix.
     214         If a second argument is given, return a list:
    213215                L[1] = 1 if coker(M)=0 resp. 0 if coker(M)!=0
    214216                L[2] = dim(M)
     
    230232  is_zero(j);
    231233}
    232 ////////////////////////////////////////////////////////////////////////////////
     234///////////////////////////////////////////////////////////////////////////////
    233235
    234236proc maxcoef (f)
     
    273275RETURN:  int/intmat, each component equals maximal degree of monomials in the
    274276         corresponding component of id, independent of ring ordering
    275          (maxdeg of each var is 1)
    276          of type int if id is of type poly, of type intmat else
     277         (maxdeg of each var is 1).
     278         Of type int if id is of type poly, of type intmat else
    277279NOTE:    proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has
    278280         an option for computing weighted degrees
     
    316318   ring r = 0,(x,y,z),wp(-1,-2,-3);
    317319   poly f = x+y2+z3;
    318    deg(f);               //deg; returns weighted degree (in case of 1 block)!
     320   deg(f);             //deg; returns weighted degree (in case of 1 block)!
    319321   maxdeg(f);
    320322   matrix m[2][2]=f+x10,1,0,f^2;
     
    396398   ring r = 0,(x,y,z),wp(-1,-2,-3);
    397399   poly f = x+y2+z3;
    398    deg(f);                  //deg returns weighted degree (in case of 1 block)!
     400   deg(f);            //deg returns weighted degree (in case of 1 block)!
    399401   maxdeg1(f);
    400402   intvec v = ringweights(r);
    401    maxdeg1(f,v);                             //weighted maximal degree
     403   maxdeg1(f,v);                        //weighted maximal degree
    402404   matrix m[2][2]=f+x10,1,0,f^2;
    403    maxdeg1(m,v);                             //absolut weighted maximal degree
     405   maxdeg1(m,v);                        //absolut weighted maximal degree
    404406}
    405407///////////////////////////////////////////////////////////////////////////////
     
    452454   ring r = 0,(x,y,z),ls;
    453455   poly f = x5+y2+z3;
    454    ord(f);                      // ord returns weighted order of leading term!
    455    mindeg(f);                   // computes minimal degree
     456   ord(f);                  // ord returns weighted order of leading term!
     457   mindeg(f);               // computes minimal degree
    456458   matrix m[2][2]=x10,1,0,f^2;
    457    mindeg(m);                   // computes matrix of minimum degrees
     459   mindeg(m);               // computes matrix of minimum degrees
    458460}
    459461///////////////////////////////////////////////////////////////////////////////
     
    532534   ring r = 0,(x,y,z),ls;
    533535   poly f = x5+y2+z3;
    534    ord(f);                      // ord returns weighted order of leading term!
     536   ord(f);                  // ord returns weighted order of leading term!
    535537   intvec v = 1,-3,2;
    536    mindeg1(f,v);                // computes minimal weighted degree
     538   mindeg1(f,v);            // computes minimal weighted degree
    537539   matrix m[2][2]=x10,1,0,f^2;
    538    mindeg1(m,1..3);             // computes absolut minimum of weighted degrees
     540   mindeg1(m,1..3);         // computes absolut minimum of weighted degrees
    539541}
    540542///////////////////////////////////////////////////////////////////////////////
     
    550552//-------------------------------- examples -----------------------------------
    551553example
    552 {  "EXAMPLE:"; echo = 2;
     554{ "EXAMPLE:"; echo = 2;
    553555   ring r = 0,(x,y,z),ls;
    554556   poly f = 2x5+3y2+4z3;
     
    559561   module m=[9xy,0,3z3],[4z,6y,2x];
    560562   normalize(m);
    561    normalize(matrix(m));             // by automatic type conversion to module!
    562 }
    563 ///////////////////////////////////////////////////////////////////////////////
    564 
    565 ////////////////////////////////////////////////////////////////////////////////
     563}
     564///////////////////////////////////////////////////////////////////////////////
     565
     566///////////////////////////////////////////////////////////////////////////////
    566567// Input: <ideal>=<f1,f2,...,fm> and <polynomial> g
    567568// Question: Does g lie in the radical of <ideal>?
    568 // Solution: Compute a standard basis G for <f1,f2,...,fm,gz-1> where z is a new
    569 //           variable. Then g is contained in the radical of <ideal> <=> 1 is
    570 //           generator in G.
    571 ////////////////////////////////////////////////////////////////////////////////
     569// Solution: Compute a standard basis G for <f1,f2,...,fm,gz-1> where z is a
     570//           new variable. Then g is contained in the radical of <ideal> <=>
     571//           1 is generator in G.
     572///////////////////////////////////////////////////////////////////////////////
    572573proc rad_con (poly g,ideal I)
    573 "  USAGE:   rad_con(<poly>,<ideal>);
    574   RETURNS: 1 (TRUE) (type <int>) if <poly> is contained in the radical of
    575            <ideal>, 0 (FALSE) (type <int>) otherwise
    576   EXAMPLE: example rad_con; shows an example
     574"USAGE:   rad_con(g,I); g polynomial, I ideal
     575RETURN:  1 (TRUE) (type int) if g is contained in the radical of I
     576@*       0 (FALSE) (type int) otherwise
     577EXAMPLE: example rad_con; shows an example
    577578"
    578579{ def br=basering;
     
    597598}
    598599example
    599 { "  EXAMPLE: Sturmfels: Algorithms in Invariant Theory 2.3.7.";
    600   echo=2;
    601            ring R=0,(x,y,z),dp;
    602            ideal I=x2+y2,z2;
    603            poly f=x4+y4;
    604            rad_con(f,I);
    605            ideal J=x2+y2,z2,x4+y4;
    606            poly g=z;
    607            rad_con(g,I);
    608 }
    609 
    610 ///////////////////////////////////////////////////////////////////////////////
    611 
    612 proc lcm (ideal i)
    613 "USAGE:   lcm(i); i ideal
    614 RETURN:  poly = lcm(i[1],...,i[size(i)])
    615 NOTE:
     600{ "EXAMPLE:"; echo=2;
     601   ring R=0,(x,y,z),dp;
     602   ideal I=x2+y2,z2;
     603   poly f=x4+y4;
     604   rad_con(f,I);
     605   ideal J=x2+y2,z2,x4+y4;
     606   poly g=z;
     607   rad_con(g,I);
     608}
     609///////////////////////////////////////////////////////////////////////////////
     610
     611proc lcm (id, list #)
     612"USAGE:   lcm(p[,q]); p int/intve q a list of integers or
     613          p poly/ideal q a list of polynomials
     614RETURN:  the least common multiple of the common entries of p and q:
     615@*         - of type int if p is an int/intvec
     616@*         - of type poly if p is a poly/ideal
    616617EXAMPLE: example lcm; shows an example
    617618"
    618619{
    619620  int k,j;
    620    poly p,q;
    621   i=simplify(i,10);
    622   for(j=1;j<=size(i);j++)
    623   {
    624     if(deg(i[j])>0)
    625     {
    626       p=i[j];
    627       break;
    628     }
    629   }
    630   if(deg(p)==-1)
    631   {
    632     return(1);
    633   }
    634   for (k=j+1;k<=size(i);k++)
    635   {
    636      if(deg(i[k])!=0)
     621//------------------------------ integer case --------------------------------
     622  if( typeof(id) == "int" or typeof(id) == "intvec" )
     623  {
     624     intvec i = id;
     625     if (size(#)!=0)
    637626     {
    638         q=gcd(p,i[k]);
    639         if(deg(q)==0)
     627        for (j = 1; j<=size(#); j++)
    640628        {
    641            p=p*i[k];
     629           if (typeof(#[j]) !="int" and typeof(#[j]) !="intvec")
     630           { ERROR("// ** list element must be an integer");}
     631           else
     632           { i = i,#[j]; }
    642633        }
    643         else
     634     }
     635     int p,q;
     636     if( i == 0 )
     637     {
     638        return(0);
     639     }
     640     for(j=1;j<=size(i);j++)
     641     {
     642       if( i[j] != 0 )
     643       {
     644         p=i[j];
     645         break;
     646       }
     647     }
     648     for (k=j+1;k<=size(i);k++)
     649     {
     650        if( i[k] !=0)
    644651        {
     652           q=gcd(p,i[k]);
    645653           p=p/q;
    646654           p=p*i[k];
    647655        }
    648656     }
    649    }
    650   return(p);
     657     if(p <0 )
     658     {return(-p);}
     659     return(p);
     660   }   
     661
     662//----------------------------- polynomial case ------------------------------
     663  if( typeof(id) == "poly" or typeof(id) == "ideal" )
     664  {
     665     ideal i = id;
     666     if (size(#)!=0)
     667     {
     668        for (j = 1; j<=size(#); j++)
     669        {
     670           if (typeof(#[j]) !="poly" and typeof(#[j]) !="ideal"
     671              and typeof(#[j]) !="int" and typeof(#[j]) !="intvec")
     672           { ERROR("// ** list element must be a polynomial");}
     673           else
     674           { i = i,#[j]; }
     675        }
     676     }
     677     poly p,q;
     678     i=simplify(i,10);
     679     if(size(i) == 0)
     680     {
     681        return(0);
     682     }
     683     for(j=1;j<=size(i);j++)
     684     {
     685       if(maxdeg(i[j])!= 0)
     686       {
     687         p=i[j];
     688         break;
     689       }
     690     }
     691     if(deg(p)==-1)
     692     {
     693       return(1);
     694     }
     695     for (k=j+1;k<=size(i);k++)
     696     {
     697        if(maxdeg(i[k])!=0)
     698        {
     699           q=gcd(p,i[k]);
     700           if(maxdeg(q)==0)
     701           {
     702                 p=p*i[k];
     703           }
     704           else
     705           {
     706              p=p/q;
     707              p=p*i[k];
     708           }
     709        }
     710     }
     711     return(p);
     712   }
    651713}
    652714example
     
    655717   poly  p = (x+y)*(y+z);
    656718   poly  q = (z4+2)*(y+z);
    657    ideal l=p,q;
    658    poly  pr= lcm(l);
    659    pr;
    660    l=1,-1,p,1,-1,q,1;
    661    pr=lcm(l);
    662    pr;
     719   lcm(p,q);
     720   ideal i=p,q,y+z;
     721   lcm(i,p);
     722   lcm(2,3,6);
     723   lcm(2..6);
    663724}
    664725
     
    683744///////////////////////////////////////////////////////////////////////////////
    684745
    685 
    686746proc numerator(number n)
    687747"USAGE:    numerator(n); n number
     
    701761  numerator(n);
    702762}
     763///////////////////////////////////////////////////////////////////////////////
    703764
    704765proc denominator(number n)
     
    721782////////////////////////////////////////////////////////////////////////
    722783
     784////////////////////////////////////////////////////////////////////////
     785// The idea of the procedures mod2id, id2mod and subrInterred is, to
     786// perform standard basis computation or interreduction of a submodule
     787// of a free module with generators gen(1),...,gen(n) over a ring R
     788// in a ring R[t1,...,tn]/<ti*tj> with gen(i) maped to ti
     789////////////////////////////////////////////////////////////////////////
     790
    723791proc mod2id(matrix M,intvec vpos)
    724 "USAGE:     mod2id(M,vpos); M matrix, vpos intvec
    725 ASSUME:    vpos is an integer vector such that gen(i) corresponds
    726            to var(vpos[i])
    727            the basering contains variables var(vpos[i]) which do not occur
    728            in M
    729 NOTE:      this procedure should be used in the following situation:
    730            one wants to pass to a ring with new variables, say e(1),..,e(s),
    731            which correspond to the components gen(1),..,gen(s) of the
    732            module M such that e(i)*e(j)=0 for all i,j
    733            the new ring should already exist and be the current ring
    734 RETURN:    ideal i in which each gen(i) from the module is replaced by
    735            var(vpos[i]) and all monomials var(vpos[i])*var(vpos[j]) have
    736            been added to the generating set of i
    737 EXAMPLE:   example mod2id; shows an example"
     792"USAGE:   mod2id(M,vpos); M matrix, vpos intvec
     793ASSUME:  vpos is an integer vector such that gen(i) corresponds
     794         to var(vpos[i]).
     795         The basering contains variables var(vpos[i]) which do not occur
     796         in M.
     797RETURN:  ideal I in which each gen(i) from the module is replaced by
     798         var(vpos[i]) and all monomials var(vpos[i])*var(vpos[j]) have
     799         been added to the generating set of I.
     800NOTE:    This procedure should be used in the following situation:
     801         one wants to pass to a ring with new variables, say e(1),..,e(s),
     802         which correspond to the components gen(1),..,gen(s) of the
     803         module M such that e(i)*e(j)=0 for all i,j.
     804         The new ring should already exist and be the current ring
     805EXAMPLE: example mod2id; shows an example"
    738806{
    739807  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
     
    771839
    772840proc id2mod(ideal i,intvec vpos)
    773 "USAGE:     id2mod(I,vpos); I ideal, vpos intvec
    774 NOTE:      * use this procedure only makes sense if the ideal contains
    775              all var(vpos[i])*var(vpos[j]) as monomial generators and
    776              all other generators are linear combinations of the
    777              var(vpos[i]) over the ring in the other variables
    778            * this is the inverse procedure to mod2id and should be applied
    779              only to ideals created by mod2id using the same intvec vpos
    780              (possibly after a standard basis computation)
    781 RETURN:    module corresponding to the ideal by replacing var(vpos[i]) by
    782            gen(i) and omitting all generators var(vpos[i])*var(vpos[j])
    783 EXAMPLE:   example id2mod; shows an example"
     841"USAGE:   id2mod(I,vpos); I ideal, vpos intvec
     842RETURN:  module corresponding to the ideal by replacing var(vpos[i]) by
     843         gen(i) and omitting all generators var(vpos[i])*var(vpos[j])
     844NOTE:    * This procedure only makes sense if the ideal contains
     845           all var(vpos[i])*var(vpos[j]) as monomial generators and
     846           all other generators of I are linear combinations of the
     847           var(vpos[i]) over the ring in the other variables.
     848         * This is the inverse procedure to mod2id and should be applied
     849           only to ideals created by mod2id using the same intvec vpos
     850           (possibly after a standard basis computation)
     851EXAMPLE: example id2mod; shows an example"
    784852{
    785853  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
     
    820888               e.g. x_1,..,x_n and t_1,..,t_s
    821889         mon:  ideal with monomial generators (not divisible by
    822                one of the t_i) such that sm is contained in the module
     890               any of the t_i) such that sm is contained in the module
    823891               k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)]
    824892         iv:   intvec listing the variables which are supposed to be used
     
    828896          l[2]=their coefficients after interreduction
    829897          l[3]=l[1]*l[2]
    830           (interreduced system of generators of sm seen as a submodule
    831           of k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)])
    832 EXAMPLE: example subrInterred; shows an example"
     898PUPOSE:  Do interred only w.r.t. a subset of variables. 
     899         The procedure returns an interreduced system of generators of
     900         sm considered as a k[t_1,..,t_s]-submodule of the free module
     901         k[t_1,..,t_s]*mon[1]+..+k[t_1,..,t_s]*mon[size(mon)]).
     902EXAMPLE: example subrInterred; shows an example
     903"
    833904{
    834905  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
Note: See TracChangeset for help on using the changeset viewer.