Changeset 88b91c in git


Ignore:
Timestamp:
Nov 18, 2016, 12:20:28 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
e47b0bf4bb6fba5369dca501612dbf300bf645d4
Parents:
520e40713e3c9c8fb0487733dbd451f4420111ae
Message:
new lib goettsche.lib, updated chern.lib
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/chern.lib

    r520e407 r88b91c  
    11////////////////////////////////////////////////////////////////
    2 version = "version chern.lib 0.615 Feb_2015 ";      //$Id$
     2version = "version chern.lib 0.7 Nov_2016";      //$Id$
    33category = "Chern classes";
    44info="
    5 LIBRARY:  chern.lib    Symbolic Computations with Chern classes
    6 
    7 AUTHOR:  Oleksandr Iena,      oleksandr.iena@uni.lu,  yena@mathematik.uni-kl.de
     5LIBRARY:  chern.lib    Symbolic Computations with Chern classes,
     6                       Computation of Chern classes
     7
     8AUTHOR:  Oleksandr Iena,      o.g.yena@gmail.com,  yena@mathematik.uni-kl.de
     9
     10OVERVIEW:
     11  A toolbox for symbolic computations with Chern classes.
     12  The Aluffi's algorithms for computation of characteristic classes of algebraic varieties
     13  (Segre, Fulton, Chern-Schwartz-MacPherson classes) are implemented as well.
     14
    815
    916REFERENCES:
    10   [1] Iena, Oleksandr,  On symbolic computations with Chern classes:
     17  [1] Aluffi, Paolo     Computing characteristic classes of projective schemes.
     18                        Journal of Symbolic Computation, 35 (2003), 3-19.
     19  [2] Iena, Oleksandr,  On symbolic computations with Chern classes:
    1120                        remarks on the library chern.lib for Singular,
    1221                        http://hdl.handle.net/10993/22395, 2015.
    13   [2] Lascoux, Alain,   Classes de Chern d'un produit tensoriel.
     22  [3] Lascoux, Alain,   Classes de Chern d'un produit tensoriel.
    1423                        C. R. Acad. Sci., Paris, Ser. A 286, 385-387 (1978).
    15   [3] Manivel, Laurent  Chern classes of tensor products, arXiv 1012.0014, 2010.
     24  [4] Manivel, Laurent  Chern classes of tensor products, arXiv 1012.0014, 2010.
    1625
    1726PROCEDURES:
     
    95104  partOver(n, J);           partitions over a given partition J with summands not exceeding n
    96105  partUnder(J);             partitions under a given partition J
     106  SegreA(I);                Segre class of the projective subscheme defined by I
     107  FultonA(I);               Fulton class of the projective subscheme defined by I
     108  CSMA(I);                  Chern-Schwartz-MacPherson class of the
     109                            projective subscheme defined by I
     110  EulerAff(I);              Euler characteristic of the affine subvariety defined by I
     111  EulerProj(I);             Euler characteristic of the projective subvariety defined by I
    97112";
    98113
    99114LIB "general.lib";
    100 LIB "lrcalc.lib"; // needed for chProdM(..) and chProdMP(..)
     115//LIB "lrcalc.lib"; // needed for chProdM(..) and chProdMP(..)
    101116//----------------------------------------------------------
    102117
     
    13621377          c, C lists of polynomials, N integer
    13631378RETURN:   list of polynomials
    1364 PURPOSE:  computes [up to degree N] the list of Chern classe of the vector bundle Hom(E, F)
    1365           in terms of the ranks and the Chern clases of E and F
     1379PURPOSE:  computes [up to degree N] the list of Chern classes of the vector bundle Hom(E, F)
     1380          in terms of the ranks and the Chern classes of E and F
    13661381EXAMPLE:  example chHom; shows an example
    13671382NOTE:
     
    21512166  print( todd(l, 2) );
    21522167
    2153   // compute the first 5 terms corresponding to the Chern clases c(1), c(2)
     2168  // compute the first 5 terms corresponding to the Chern classes c(1), c(2)
    21542169  l=c(1..2);
    21552170  print( todd(l, 5) );
     
    30273042  list I = 0, 1, 1;
    30283043  print( partUnder(I) );
     3044}
     3045//-------------------------------------------------------------------------------------------
     3046
     3047proc SegreA(ideal I)
     3048"USAGE:   SegreA(I);  I an ideal
     3049RETURN:   list of integers
     3050PURPOSE:  computes the Segre classes of the subscheme defined by I
     3051EXAMPLE:  example SegreA; shows an example
     3052NOTE:
     3053"
     3054{
     3055  if( !homog(I) ) // if the ideal is not homogeneous
     3056  {
     3057    print("You are trying to compute the Segre class of a non-homogeneous ideal!");
     3058    print("The ideal must be homogeneous, an empty list is returned.");
     3059    return( list() );
     3060  }
     3061  // modify the generators of the ideal so that all of them are of the same degree
     3062  I=equal_deg(I);
     3063  int d=deg(I[1]); // this degree is stored in this variable
     3064  int i;
     3065  list rez; // define the variable for the result
     3066  int n=nvars(basering)-1; // the dimension of the projective space
     3067  if(d==-1) // if the ideal is zero
     3068  {
     3069    for(i=0;i<=n;i++)
     3070    {
     3071      rez=rez+ list( int((-1)^i*binomial(n+i, i)) );
     3072    }
     3073    return(rez);
     3074  }
     3075  int sz=ncols(I); // the number of new generators is stored here
     3076  def br@=basering; // remember the base ring
     3077  // add additional variables t@(1), ... , t@(sz) and u@ to the base ring
     3078  execute("ring r@=("+ charstr(basering) +"),("+varstr(basering)+",t@(1..sz),u@), dp;");
     3079  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
     3080  ideal I=F(I); // the ideal generated by I in the new ring
     3081  ideal J(0..n); // define n+1 ideals J(0), ... , J(n)
     3082  // compute the ideal of the Rees algebra of the ideal I:
     3083  for(i=1; i<=sz; i++) // consider the ideal generated by t@(i)-u@*I[i]
     3084  {
     3085    J(0)=J(0) + ideal( t@(i)-u@*I[i] );
     3086  }
     3087  J(0)=eliminate(J(0), u@); // and eliminate the variable u@
     3088  ideal T=t@(1..sz); // define the ideal generated by the additional variables t@(1), ... , t@(sz)
     3089  for(i=1;i<=n;i++)// for all i=1, ... n define J(j) as in 3.6 of the Aluffi's paper
     3090  {
     3091    // add a random general linear form in variables t@(1), ... , t@(n) to J(i-1)
     3092    J(i)=sat( random_hypersurf(J(i-1), T)   , T)[1]; // and saturate with respect to T
     3093  }
     3094  poly prd=product(T); // compute the product of t@(i)
     3095  poly cl;
     3096  poly mlt;
     3097  for(i=0;i<=n;i++)
     3098  {
     3099    // eliminate all t@(i) from J(i)
     3100    // compute the degree of the scheme defined by this ideal
     3101    // and use it to compute the class corresponding to c(O(d))^n * G\otimes O(d)
     3102    cl=cl+mult(std(eliminate(J(i), prd)))*u@^i*(1+d*u@)^(n-i);
     3103    // the (n+1)-st power of the inverse of the Chern class of O(d)
     3104    mlt=mlt+binomial(n+i, i)*(-d*u@)^i;
     3105  }
     3106  poly resPoly;
     3107  // compute the Segre class by the Aluffi's formula from Proposition 3.1 as polynomial in u@
     3108  resPoly= NF( 1-cl*mlt, u@^(n+1));
     3109  matrix cf=coeffs(resPoly, u@); // coefficients of the Segre class
     3110  rez=list(); // empty the list
     3111  for(i=0;i<=n;i++) // fill the list with the the Segre classes in positive degrees
     3112  {
     3113    if( i < nrows(cf) ) // if i is not bigger than the maximal degree of non-zero Segre classes
     3114    {
     3115      rez=rez+list(int(cf[i+1,1]));
     3116    }
     3117    else // otherwise fill the list with zeroes
     3118    {
     3119      rez=rez+list( int(0) );
     3120    }
     3121  }
     3122  return(rez);
     3123}
     3124example
     3125{
     3126  "EXAMPLE:";echo =2;
     3127  // Consider a 3-dimensional projective space
     3128  ring r = 0, (x, y, z, w), dp;
     3129  // Consider 3 non-coplanar lines trough one point and compute the Segre class
     3130  ideal I=xy, xz, yz;
     3131  I;
     3132  SegreA(I);
     3133  // Now consider 3 coplanar lines trough one point and its Segre class
     3134  ideal J=w, x*y*(x+y);
     3135  J;
     3136  SegreA(J);
     3137}
     3138//-------------------------------------------------------------------------------------------
     3139
     3140proc FultonA(ideal I)
     3141"USAGE:   FultonA(I);  I an ideal
     3142RETURN:   list of integers
     3143PURPOSE:  computes the Fulton classes of the subscheme defined by I
     3144EXAMPLE:  example FultonA; shows an example
     3145NOTE:
     3146"
     3147{
     3148  if( !homog(I) ) // if the ideal is not homogeneous
     3149  {
     3150    print("You are trying to compute the Segre class of a non-homogeneous ideal!");
     3151    print("The ideal must be homogeneous, an empty list is returned.");
     3152    return( list() );
     3153  }
     3154  // modify the generators of the ideal so that all of them are of the same degree
     3155  I=equal_deg(I);
     3156  int d=deg(I[1]); // this degree is stored in this variable
     3157  int i;
     3158  list rez; // define the variable for the result
     3159  int n=nvars(basering)-1; // the dimension of the projective space
     3160  if(d==-1) // if the ideal is zero
     3161  {
     3162    rez=rez+list(int(1));
     3163    for(i=1;i<=n;i++)
     3164    {
     3165      rez=rez+ list( int(0) );
     3166    }
     3167    return(rez);
     3168  }
     3169  int sz=ncols(I); // the number of new generators is stored here
     3170  def br@=basering; // remember the base ring
     3171  // add additional variables t@(1), ... , t@(sz) and u@ to the base ring
     3172  execute("ring r@=("+ charstr(basering) +"),("+varstr(basering)+",t@(1..sz),u@), dp;");
     3173  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
     3174  ideal I=F(I); // the ideal generated by I in the new ring
     3175  ideal J(0..n); // define n+1 ideals J(0), ... , J(n)
     3176  // compute the ideal of the Rees algebra of the ideal I:
     3177  for(i=1; i<=sz; i++) // consider the ideal generated by t@(i)-u@*I[i]
     3178  {
     3179    J(0)=J(0) + ideal( t@(i)-u@*I[i] );
     3180  }
     3181  J(0)=eliminate(J(0), u@); // and eliminate the variable u@
     3182  ideal T=t@(1..sz); // define the ideal generated by the additional variables t@(1), ... , t@(sz)
     3183  for(i=1;i<=n;i++)// for all i=1, ... n define J(j) as in 3.6 of the Aluffi's paper
     3184  {
     3185    // add a random general linear form in variables t@(1), ... , t@(n) to J(i-1)
     3186    J(i)=sat(   random_hypersurf(J(i-1), T)  , T)[1]; // and saturate with respect to T
     3187  }
     3188  poly prd=product(T); // compute the product of t@(i)
     3189  poly cl;
     3190  poly mlt;
     3191  for(i=0;i<=n;i++)
     3192  {
     3193    // eliminate all t@(i) from J(i)
     3194    // compute the degree of the scheme defined by this ideal
     3195    // the class corresponding to c(O(d))^n * G\otimes O(d)
     3196    cl=cl+ mult(std( eliminate( J(i),  prd) ))*u@^i*(1+d*u@)^(n-i);
     3197    // the (n+1)-st power of the inverse of the Chern class of O(d)
     3198    mlt=mlt+binomial(n+i, i)*(-d*u@)^i;
     3199  }
     3200  poly resPoly;
     3201  // compute the Fulton class using the Aluffi's formula for the Segre class and
     3202  // multiplying it by the Chern class of the projective space (1+u@)^(n+1)
     3203  resPoly= NF( (1+u@)^(n+1)*(1-cl*mlt), u@^(n+1) );
     3204  matrix cf=coeffs(resPoly, u@); // coefficients of the Fulton class
     3205  rez=list(); // empty the list
     3206  for(i=0;i<=n;i++) // fill the list with the the Fulton classes in positive degrees
     3207  {
     3208    if( i < nrows(cf) ) // if i is not bigger than the maximal degree of non-zero Fulton classes
     3209    {
     3210      rez=rez+list(int(cf[i+1,1]));
     3211    }
     3212    else // otherwise fill the list with zeroes
     3213    {
     3214      rez=rez+list( int(0) );
     3215    }
     3216  }
     3217  return(rez);
     3218}
     3219example
     3220{
     3221  "EXAMPLE:";echo =2;
     3222  // Consider a 3-dimensional projective space
     3223  ring r = 0, (x, y, z, w), dp;
     3224  // Consider 3 non-coplanar lines trough one point and compute the Fulton class
     3225  ideal I=xy, xz, yz;
     3226  I;
     3227  FultonA(I);
     3228  // Now consider 3 coplanar lines trough one point and its Fulton class
     3229  ideal J=w, x*y*(x+y);
     3230  J;
     3231  FultonA(J);
     3232}
     3233//-------------------------------------------------------------------------------------------
     3234
     3235proc CSMA(ideal I)
     3236"USAGE:   CSMA(I);  I an ideal
     3237RETURN:   list of integers
     3238PURPOSE:  computes the Chern-Schwartz-MacPherson classes of the variety defined by I
     3239EXAMPLE:  example CSMA; shows an example
     3240NOTE:
     3241"
     3242{
     3243  if( !homog(I) ) // if the ideal is not homogeneous
     3244  {
     3245    print("You are trying to compute the Chern-Schwartz-MacPherson class.");
     3246    print("However the input ideal is not homogeneous!");
     3247    print("The ideal must be homogeneous, an empty list is returned.");
     3248    return( list() );
     3249  }
     3250  int sz=ncols(I);
     3251  int i;
     3252  int n=nvars(basering)-1;
     3253  bigintmat REZ[1][n+1];
     3254  int j;
     3255  int szpr;
     3256  list pr;
     3257  int sgn=-1;
     3258  for(i=1;i<=sz;i++)
     3259  {
     3260    sgn=-sgn;
     3261    pr=prds(i,I);
     3262    szpr=size(pr);
     3263    for(j=1;j<=szpr;j++)
     3264    {
     3265      REZ=REZ+sgn*CSM_hypersurf(pr[j]);
     3266    }
     3267  }
     3268  list rez;
     3269  for(i=0;i<=n;i++)
     3270  {
     3271    rez=rez+list(REZ[1,i+1]);
     3272  }
     3273  return(rez);
     3274}
     3275example
     3276{
     3277  "EXAMPLE:";echo =2;
     3278  // consider the projective plane with homogeneous coordinates x, y, z
     3279  ring r = 0, (x, y, z), dp;
     3280  // the Chern-Schwartz-MacPherson class of a smooth cubic:
     3281  ideal I=x3+y3+z3;
     3282  I;
     3283  CSMA(I);
     3284  // the Chern-Schwartz-MacPherson class of singular cubic
     3285  // that is a union of 3 non-collinear lines:
     3286  ideal J=x*y*z;
     3287  J;
     3288  CSMA(J);
     3289  // the Chern-Schwartz-MacPherson class of singular cubic
     3290  // that is a union of 3 lines passing through one point
     3291  ideal K=x*y*(x+y);
     3292  K;
     3293  CSMA(K);
     3294}
     3295//-------------------------------------------------------------------------------------------
     3296
     3297proc EulerAff(ideal I)
     3298"USAGE:   EulerAff(I);  I an ideal
     3299RETURN:   integer
     3300PURPOSE:  computes the Euler characteristic of the affine variety defined by I
     3301EXAMPLE:  example EulerAff; shows an example
     3302NOTE:
     3303"
     3304{
     3305  int n=nvars(basering);
     3306  def br@=basering; // remember the base ring
     3307  execute("ring r@=("+ charstr(basering) +"),("+varstr(basering)+",homvar@), dp;");
     3308  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
     3309  ideal I=F(I);
     3310  ideal J=homog(I, homvar@);
     3311  ideal JJ=J, homvar@;
     3312  return( CSMA(J)[n]-CSMA(JJ)[n] );
     3313}
     3314example
     3315{
     3316  "EXAMPLE:";echo =2;
     3317  ring r = 0, (x, y), dp;
     3318  // compute the Euler characteristic of the affine ellipric curve y^2=x^3+x+1;
     3319  ideal I=y2-x3-x-1;
     3320  EulerAff(I);
     3321}
     3322//-------------------------------------------------------------------------------------------
     3323
     3324proc EulerProj(ideal I)
     3325"USAGE:   EulerProj(I);  I an ideal
     3326RETURN:   integer
     3327PURPOSE:  computes the highest degree term of the Chern-Schwartz-MacPherson class
     3328          of the variety defined by I, which equals the Euler characteristic
     3329EXAMPLE:  example EulerProj; shows an example
     3330NOTE:     uses CSMA(...)
     3331"
     3332{
     3333  if( !homog(I) ) // if the ideal is not homogeneous
     3334  {
     3335    print("The ideal must be homogeneous, zero is returned.");
     3336    return( int(0) );
     3337  }
     3338  int n=nvars(basering)-1;
     3339  return( CSMA(I)[n] );
     3340}
     3341example
     3342{
     3343  "EXAMPLE:";echo =2;
     3344  // consider the projective plane with homogeneous coordinates x, y, z
     3345  ring r = 0, (x, y, z), dp;
     3346  // Euler characteristic of a smooth cubic:
     3347  ideal I=x3+y3+z3;
     3348  I;
     3349  EulerProj(I);
     3350  // Euler characteritic of 3 non-collinear lines:
     3351  ideal J=x*y*z;
     3352  J;
     3353  EulerProj(J);
     3354  // Euler characteristic of 3 lines passing through one point
     3355  ideal K=x*y*(x+y);
     3356  K;
     3357  EulerProj(K);
    30293358}
    30303359//----------------------------------------------------------------------------------------
     
    34313760//---------------------------------------------------------------------------------------
    34323761
     3762static proc max_deg(ideal I)
     3763"USAGE:   max_deg(I);  I an ideal
     3764RETURN:   integer
     3765PURPOSE:  computes the maximal degree of the generators of I
     3766EXAMPLE:  example max_deg; shows an example
     3767NOTE:
     3768"
     3769{
     3770  int rez=0;
     3771  int i;
     3772  int sz = ncols(I);
     3773  for(i=1;i<=sz;i++)
     3774  {
     3775    rez=max(rez, deg(I[i]) );
     3776  }
     3777  return(rez);
     3778}
     3779example
     3780{
     3781  "EXAMPLE:";echo =2;
     3782  // the maximal degree of the ideal in k[x, y]:
     3783  ring r = 0, (x, y), dp;
     3784  ideal I= x4, y7, x2y3;
     3785  print(max_deg(I));
     3786}
     3787//-------------------------------------------------------------------------------------------
     3788
     3789static proc var_pow(int n)
     3790"USAGE:   var_pow(n);  n an integer
     3791RETURN:   ideal
     3792PURPOSE:  computes the ideal generated by the n-th powers of the variables of the base ring
     3793EXAMPLE:  example var_pow; shows an example
     3794NOTE:
     3795"
     3796{
     3797  ideal I=maxideal(1);
     3798  int sz=ncols(I);
     3799  int i;
     3800  ideal J;
     3801  for(i=1; i<=sz; i++)
     3802  {
     3803    J=J+ideal(I[i]^n);
     3804  }
     3805  return(J);
     3806}
     3807example
     3808{
     3809  "EXAMPLE:";echo =2;
     3810  // the 3-rd powers of the variables in k[x, y]:
     3811  ring r = 0, (x, y), dp;
     3812  print(var_pow(3));
     3813}
     3814//-------------------------------------------------------------------------------------------
     3815
     3816static proc equal_deg(ideal I)
     3817"USAGE:   equal_deg(I);  I an ideal
     3818RETURN:   ideal
     3819PURPOSE:  computes an ideal generated by elements of the same degree
     3820          that defines the same projective subscheme as I
     3821EXAMPLE:  example equal_deg; shows an example
     3822NOTE:
     3823"
     3824{
     3825  I=simplify(I, 8+2);
     3826  int sz=ncols(I);
     3827  int mxd=max_deg(I);
     3828  int i;
     3829  ideal J;
     3830  for(i=1;i<=sz;i++)
     3831  {
     3832    J=J+I[i]*var_pow( mxd-deg(I[i]) );
     3833  }
     3834
     3835  return(sort( simplify(J, 8+2) )[1]);
     3836}
     3837example
     3838{
     3839  "EXAMPLE:"; echo=2;
     3840  // change the ideal (x, y^2) in k[x, y, z]:
     3841  ring r = 0, (x, y, z), dp;
     3842  ideal I=x, y*z;
     3843  // the ideal defines a two points subscheme in the projective plane
     3844  // and is generated by elements of different degrees
     3845  print(I);
     3846  ideal J=equal_deg(I);
     3847  // now the ideal is generated by elemets of degree 2
     3848  // and defines the same subscheme in the projective plane
     3849  J;
     3850  // notice that both ideals have the same saturation
     3851  // with respect to the irrelevant ideal (x, y, z)
     3852  // the saturation of the initial ideal coincides with the ideal itself
     3853  sat(I, maxideal(1))[1];
     3854  // the saturation of the modified ideal
     3855  sat(J, maxideal(1))[1];
     3856}
     3857//-------------------------------------------------------------------------------------------
     3858
     3859static proc CSM_hypersurf(poly f)
     3860"USAGE:   CSM_hypersurf(f);  f a polynomial
     3861RETURN:   list of integers
     3862PURPOSE:  computes the Chern-Schwartz-MacPherson classes of the hypersurface defined by f
     3863EXAMPLE:  example CSM_hypersurf; shows an example
     3864NOTE:
     3865"
     3866{
     3867  ideal I=jacob(f);
     3868  I=simplify(I, 8+2); // ignore repetitions and zero generators
     3869  I=sort(I)[1]; // sort the generators, it speeds up the computations
     3870  int d=deg(I[1]); // the degree of the generators of the Jacobian ideal
     3871  int i;
     3872  int n=nvars(basering)-1; // the dimension of the projective space
     3873  bigintmat REZ[1][n+1];
     3874  if(d==-1) // if the Jacobian ideal is zero
     3875  {
     3876    for(i=0;i<=n;i++)
     3877    {
     3878      REZ[1,i+1]=binomial(n+1,i);
     3879    }
     3880    return(REZ);
     3881  }
     3882  //TODO need to check the zero ideal and I==1;
     3883  int sz=ncols(I);
     3884  def br@=basering; // remember the base ring
     3885  execute("ring r@=("+ charstr(basering) +"),("+varstr(basering)+",t@(1..sz),u@), dp;");
     3886  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
     3887  ideal I=F(I);
     3888  ideal J(0..n);
     3889  for(i=1; i<=sz; i++)
     3890  {
     3891    J(0)=J(0) + ideal( t@(i)-u@*I[i] );
     3892  }
     3893  J(0)=eliminate(J(0), u@);
     3894  ideal T=t@(1..sz);
     3895  for(i=1;i<=n;i++)
     3896  {
     3897    J(i) = sat( random_hypersurf(J(i-1), T), T )[1];
     3898  }
     3899  poly prd=product(T);
     3900  poly cl;
     3901  poly mlt;
     3902  for(i=0;i<=n;i++)
     3903  {
     3904    cl=cl+  mult( std(eliminate( J(i),  prd)) ) *(-u@)^i*(1+u@)^(n-i);
     3905  }
     3906  cl=(1+u@)^(n+1)-cl;
     3907  poly resPoly=NF( cl, u@^(n+1) );
     3908  matrix cf=coeffs(resPoly, u@);
     3909  for(i=0;i<=n;i++)
     3910  {
     3911    if( i < nrows(cf) )
     3912    {
     3913      REZ[1,i+1]=int(cf[i+1,1]);
     3914    }
     3915    else
     3916    {
     3917      REZ[1,i+1]=int(0);
     3918    }
     3919  }
     3920  return(REZ);
     3921}
     3922example
     3923{
     3924  "EXAMPLE:";echo =2;
     3925  // consider the projective plane with homogeneous coordinates x, y, z
     3926  ring r = 0, (x, y, z), dp;
     3927  // the Chern-Schwartz-MacPherson class of a smooth cubic:
     3928  poly f=x3+y3+z3;
     3929  f;
     3930  CSM_hypersurf(f);
     3931  // the Chern-Schwartz-MacPherson class of singular cubic
     3932  // that is a union of 3 non-collinear lines:
     3933  poly g=x*y*z;
     3934  g;
     3935  CSM_hypersurf(g);
     3936  // the Chern-Schwartz-MacPherson class of singular cubic
     3937  // that is a union of 3 lines passing through one point
     3938  poly h=x*y*(x+y);
     3939  h;
     3940  CSM_hypersurf(h);
     3941}
     3942//-------------------------------------------------------------------------------------------
     3943
     3944static proc random_hypersurf(ideal I, ideal V)
     3945"USAGE:   random_hypersurf(I, V);  I, V ideals
     3946RETURN:   ideal
     3947PURPOSE:  computes the sum of I with the ideal generated by a random
     3948          linear combination of the generators of V such that the dimension decreases
     3949EXAMPLE:  example random_hypersurf; shows an example
     3950NOTE:     if the ideal I=1 (the whole ring), then I is returned
     3951"
     3952{
     3953  ideal H;
     3954  ideal J;
     3955 // if(isSubModule(ideal(1), I)) // if I equals 1 (the whole ring);
     3956  if( is_zero(I) )
     3957  {
     3958    return(I);
     3959  }
     3960  // otherwise
     3961  int ok=0;
     3962  int ntries; // number of tries
     3963  while( !ok ) // give two tries for every b in randomid(V, 1, b)
     3964  {
     3965    H=randomid(V, 1, ntries div 2 +1);
     3966    ntries++; // increase by 1
     3967    if( isSubModule( quotient(I, ideal(H) ), I) )
     3968    {
     3969      J=I + H;
     3970      ok=1;
     3971    }
     3972  }
     3973  return(J);
     3974}
     3975example
     3976{
     3977  "EXAMPLE:";echo =2;
     3978  // Consider an ideal in  k[x, y, z, s, t] and find its intersection with a general hyperplane
     3979  // given by as+bt=0
     3980  ring r = 0, (x, y, z, s, t), dp;
     3981  ideal I=x2, yz, s+t;
     3982  I;
     3983  ideal V= s, t;
     3984  V;
     3985  // the ideal of the intersection with the random general hyperplane
     3986  random_hypersurf(I, V);
     3987}
     3988//-------------------------------------------------------------------------------------------
     3989
     3990static proc prds(int n, def l)
     3991"USAGE:   prds(n, l);  n an integer, l list of polynomials or ideal
     3992RETURN:   list of polynomials
     3993PURPOSE:  computes all possible products of length n (without repetitions) of the entries of l
     3994EXAMPLE:  example prds; shows an example
     3995NOTE:
     3996"
     3997{
     3998  int sz;
     3999  if(typeof(l)=="ideal")
     4000  {
     4001    sz=ncols(l);
     4002  }
     4003  else
     4004  {
     4005    sz=size(l);
     4006  }
     4007  if( (n>sz)||(sz==0)||(n<0) )
     4008  {
     4009    return( list() );
     4010  }
     4011  // otherwise
     4012  if(n==0)
     4013  {
     4014    return( list(int(1)) );
     4015  }
     4016  if(sz==n)
     4017  {
     4018    return(product(l));
     4019  }
     4020  list L, LL, ll;
     4021  ll=l[2..sz];
     4022  poly f=l[1];
     4023  L=prds(n, ll );
     4024  LL=prds(n-1,ll);
     4025  int i;
     4026  sz=size(LL);
     4027  for(i=1;i<=sz;i++)
     4028  {
     4029    LL[i]=f*LL[i];
     4030  }
     4031  return(L+LL);
     4032}
     4033example
     4034{
     4035  "EXAMPLE:";echo =2;
     4036  ring r = 0, (x, y, z, w), dp;
     4037  // compute all possible 2-products between the variables x,y,z,w
     4038  list l=x,y,z,w;
     4039  prds(2, l);
     4040  // compute all possible 3-products between the variables x,y,z,w
     4041  ideal I=x,y,z,w;
     4042  prds(3, l);
     4043}
     4044//-------------------------------------------------------------------------------------------
  • doc/NEWS.texi

    r520e407 r88b91c  
    2121
    2222@heading News for version @value{VERSION}
     23
     24New libraries:
     25@itemize
     26@item goettsche.lia:b Goettsche's formula for the Betti numbers of the Hilbert scheme
     27of points on a surface, Macdonald's formula for the symmetric product (@nref{goettsche_lib})
     28@end itemize
     29
     30Changed libraries:
     31@itemize
     32@item chern.lib:  new version (@nref{chern_lib})
     33@end itemize
     34
     35@heading News for version 4-0-3
    2336
    2437Syntax changes:
Note: See TracChangeset for help on using the changeset viewer.