Changeset 11dddeb in git for Singular/LIB/poly.lib


Ignore:
Timestamp:
Feb 23, 2004, 11:19:13 AM (20 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
dd8844f86c84ceb5f72e448153ac7a2d0daf5a00
Parents:
c229324983bbffba788eee2e34c2f5428261bb0f
Message:
*hannes: from V2-0


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/poly.lib

    rc22932 r11dddeb  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: poly.lib,v 1.33 2001-01-16 13:48:36 Singular Exp $";
     2version="$Id: poly.lib,v 1.34 2004-02-23 10:19:13 Singular Exp $";
    33category="General purpose";
    44info="
     
    1313 is_zero(poly/...);     int, =1 resp. =0 if coker(input) is 0 resp. not
    1414 lcm(ideal);            lcm of given generators of ideal
    15  maxcoef(poly/...);     maximal length of coefficient occuring in poly/...
     15 maxcoef(poly/...);     maximal length of coefficient occurring in poly/...
    1616 maxdeg(poly/...);      int/intmat = degree/s of terms of maximal order
    1717 maxdeg1(poly/...);     int = [weighted] maximal degree of input
     
    2525 mod2id(M,iv);          conversion of a module M to an ideal
    2626 id2mod(i,iv);          conversion inverse to mod2id
     27 substitute(I,...)      substitute in I variables by polynomials
    2728 subrInterred(i1,i2,iv);interred w.r.t. a subset of variables
     29 hilbPoly( I)           Hilbert polynomial of basering/I
    2830          (parameters in square brackets [] are optional)
    2931";
     
    3234LIB "ring.lib";
    3335///////////////////////////////////////////////////////////////////////////////
    34 
     36static proc bino(int a, int b)
     37{
     38//computes binomial var(1)+a over b
     39   int i;
     40   if(b==0){return(1);}
     41   poly p=(var(1)+a)/b;
     42   for(i=1;i<=b-1;i++)
     43   {
     44      p=p*(var(1)+a-i)/i;
     45   }
     46   return(p);
     47}
     48
     49proc hilbPoly(ideal I)
     50"USAGE: hilbPoly(I) I a homogeneous ideal
     51RETURN: the Hilbert polynomial of basering/I as an intvec v=v_0,...,v_r
     52        such that the Hilbert polynomial is (v_0+v_1*t+...v_r*t^r)/r!
     53EXAMPLE: example hilbPoly; shows an example
     54"
     55{
     56   def R=basering;
     57   if(!attrib(I,"isSB")){I=std(I);}
     58   intvec v=hilb(I,2);
     59   int s=dim(I);
     60   intvec hp;
     61   if(s==0){return(hp);}
     62   int d=size(v)-2;
     63   ring S=0,t,dp;
     64   poly p=v[1+d]*bino(s-1-d,s-1);
     65   int i;
     66   for(i=1;i<=d;i++)
     67   {
     68      p=p+v[d-i+1]*bino(s-1-d+i,s-1);
     69   }
     70   int n=1;
     71   for(i=2;i<=s-1;i++){n=n*i;}
     72   p=n*p;
     73   for(i=1;i<=s;i++)
     74   {
     75      hp[i]=int(leadcoef(p[s-i+1]));
     76   }
     77   setring R;
     78   return(hp);
     79}
     80example
     81{ "EXAMPLE:"; echo = 2;
     82   ring r = 0,(b,c,t,h),dp;
     83   ideal I=
     84   bct-t2h+2th2+h3,
     85   bt3-ct3-t4+b2th+c2th-2bt2h+2ct2h+2t3h-bch2-2bth2+2cth2+2th3,
     86   b2c2+bt2h-ct2h-t3h+b2h2+2bch2+c2h2-2bth2+2cth2+t2h2-2bh3+2ch3+2th3+3h4,
     87   c2t3+ct4-c3th-2c2t2h-2ct3h-t4h+bc2h2-2c2th2-bt2h2+4t3h2+2bth3-2cth3-t2h3
     88   +bh4-6th4-2h5;
     89   hilbPoly(I);
     90}
     91
     92///////////////////////////////////////////////////////////////////////////////
     93proc substitute (I,list #)
     94"USAGE:  - case 1: typeof(#[1])==poly:
     95           substitute (I,v,f[,v1,f1,v2,f2,...]); I object of basering which
     96           can be mapped, v,v1,v2,.. ring variables, f,f1,f2,... poly
     97@*       - case 2: typeof(#[1])==ideal:
     98           substitute1 (I,v,f); I object of basering which can be mapped,
     99           v ideal of ring variables, f ideal
     100RETURN:  object of same type as I,
     101@*       - case 1: ring variable v,v1,v2,... substituted by polynomials
     102           f,f1,f2,..., in this order
     103@*       - case 2: ring variables in v substituted by polynomials in f:
     104           v[i] is substituted by f[i], i=1,...,i=min(size(v),ncols(f))
     105NOTE:    this procedure extends the built-in command subst which substitutes
     106         ring variables only by monomials
     107EXAMPLE: example substitute; shows an example
     108"
     109
     110{
     111   def bas = basering;
     112   ideal m = maxideal(1);
     113   int i,ii;
     114   if(typeof(#[1])=="poly")
     115   {
     116     poly v = #[1];
     117     poly f = #[2];
     118     map phi = bas,m;
     119     def J = I;
     120     for (ii=1; ii<=size(#) - 1; ii=ii+2)
     121     {
     122        m = maxideal(1);
     123        i=rvar(#[ii]);
     124        m[i] = #[ii+1];
     125        phi = bas,m;
     126        J = phi(J);
     127     }
     128     return(J);
     129   }
     130   if(typeof(#[1])=="ideal")
     131   {
     132     ideal v = #[1];
     133     ideal f = #[2];
     134     int mi = size(v);
     135     if(ncols(f)<mi)
     136     {
     137        mi = ncols(f);
     138     }
     139     m[rvar(v[1])]=f[1];
     140     map phi = bas,m;
     141     def J = phi(I);
     142     for (ii=2; ii<=mi; ii++)
     143     {
     144        m = maxideal(1);
     145        m[rvar(v[ii])]=f[ii];
     146        phi = bas,m;
     147        J = phi(J);
     148     }
     149     return(J);
     150   }
     151}
     152example
     153{ "EXAMPLE:"; echo = 2;
     154   ring r = 0,(b,c,t),dp;
     155   ideal I = -bc+4b2c2t,bc2t-5b2c;
     156   substitute(I,c,b+c,t,0,b,b-1);
     157   ideal v = c,t,b;
     158   ideal f = b+c,0,b-1;
     159   substitute(I,v,f);
     160}
     161///////////////////////////////////////////////////////////////////////////////
    35162proc cyclic (int n)
    36163"USAGE:   cyclic(n);  n integer
     
    278405         (maxdeg of each var is 1).
    279406         Of type int if id is of type poly, of type intmat else
    280 NOTE:    proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has
     407NOTE:    proc maxdeg1 returns 1 integer, the absolute maximum; moreover, it has
    281408         an option for computing weighted degrees
    282409EXAMPLE: example maxdeg; shows examples
     
    317444example
    318445{ "EXAMPLE:"; echo = 2;
    319    ring r = 0,(x,y,z),wp(-1,-2,-3);
     446   ring r = 0,(x,y,z),wp(1,2,3);
    320447   poly f = x+y2+z3;
    321448   deg(f);             //deg; returns weighted degree (in case of 1 block)!
     
    397524example
    398525{ "EXAMPLE:"; echo = 2;
    399    ring r = 0,(x,y,z),wp(-1,-2,-3);
     526   ring r = 0,(x,y,z),wp(1,2,3);
    400527   poly f = x+y2+z3;
    401528   deg(f);            //deg returns weighted degree (in case of 1 block)!
     
    404531   maxdeg1(f,v);                        //weighted maximal degree
    405532   matrix m[2][2]=f+x10,1,0,f^2;
    406    maxdeg1(m,v);                        //absolut weighted maximal degree
     533   maxdeg1(m,v);                        //absolute weighted maximal degree
    407534}
    408535///////////////////////////////////////////////////////////////////////////////
     
    413540         (mindeg of each variable is 1) of type int if id of type poly, else
    414541         of type intmat.
    415 NOTE:    proc mindeg1 returns one integer, the absolut minimum; moreover it
     542NOTE:    proc mindeg1 returns one integer, the absolute minimum; moreover it
    416543         has an option for computing weighted degrees.
    417544EXAMPLE: example mindeg; shows examples
     
    539666   mindeg1(f,v);            // computes minimal weighted degree
    540667   matrix m[2][2]=x10,1,0,f^2;
    541    mindeg1(m,1..3);         // computes absolut minimum of weighted degrees
     668   mindeg1(m,1..3);         // computes absolute minimum of weighted degrees
    542669}
    543670///////////////////////////////////////////////////////////////////////////////
     
    611738
    612739proc lcm (id, list #)
    613 "USAGE:   lcm(p[,q]); p int/intve q a list of integers or
     740"USAGE:   lcm(p[,q]); p int/intvec q a list of integers or
    614741          p poly/ideal q a list of polynomials
    615742RETURN:  the least common multiple of the common entries of p and q:
     
    8971024          l[2]=their coefficients after interreduction
    8981025          l[3]=l[1]*l[2]
    899 PUPOSE:  Do interred only w.r.t. a subset of variables.
     1026PURPOSE:  Do interred only w.r.t. a subset of variables.
    9001027         The procedure returns an interreduced system of generators of
    9011028         sm considered as a k[t_1,..,t_s]-submodule of the free module
Note: See TracChangeset for help on using the changeset viewer.