Ignore:
Timestamp:
Jul 30, 2019, 4:14:32 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
f835e7ef57d0065a19c0d736e27fbf9149ddf87a
Parents:
ce45c3875a5144c82068f119b9783eeb7adcfcea
Message:
format: ellipticcovers.lib
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ellipticcovers.lib

    rce45c3 r30bd62  
    6767
    6868
    69 proc mod_init()
    70 {
    71 newstruct("graph","list vertices, list edges");
    72 newstruct("Net","list rows");
    73 
    74 system("install","graph","print",printGraph,1);
    75 system("install","Net","print",printNet,1);
    76 system("install","Net","+",catNet,2);
    77 
    78 }
    79 
     69static proc mod_init()
     70{
     71  newstruct("graph","list vertices, list edges");
     72  newstruct("Net","list rows");
     73
     74  system("install","graph","print",printGraph,1);
     75  system("install","Net","print",printNet,1);
     76  system("install","Net","+",catNet,2);
     77}
    8078
    8179static proc catNet(Net N, Net M)
    8280{
    83 list L;
    84 list LN=N.rows;
    85 list LM=M.rows;
    86 int widthN=size(LN[1]);
    87 int widthM=size(LM[1]);
    88 int nm=max(size(LN),size(LM));
    89 for (int j=1; j<=nm; j++)
    90 {
     81  list L;
     82  list LN=N.rows;
     83  list LM=M.rows;
     84  int widthN=size(LN[1]);
     85  int widthM=size(LM[1]);
     86  int nm=max(size(LN),size(LM));
     87  for (int j=1; j<=nm; j++)
     88  {
    9189    if (j>size(LN)){LN[j]=emptyString(widthN);}
    9290    if (j>size(LM)){LM[j]=emptyString(widthM);}
    9391    L[j]=LN[j]+LM[j];
    94 }
    95 Net NM;
    96 NM.rows=L;
    97 return(NM);}
     92  }
     93  Net NM;
     94  NM.rows=L;
     95  return(NM);
     96}
    9897
    9998
     
    111110static proc printNet(Net N)
    112111{
    113 list L = N.rows;
    114 for (int j=1; j<=size(L); j++)
    115 {
    116    print(L[j]);
    117 }
    118 }
    119 
    120 static proc net(def M){
    121   if (typeof(M)=="list"){
     112  list L = N.rows;
     113  for (int j=1; j<=size(L); j++)
     114  {
     115    print(L[j]);
     116  }
     117}
     118
     119static proc net(def M)
     120{
     121  if (typeof(M)=="list")
     122  {
    122123    return(netList(M));
    123124  }
     
    126127  L[1]=string(M);
    127128  N.rows=L;
    128 return(N);}
     129  return(N);
     130}
    129131
    130132
     
    147149  G;
    148150}
    149 
    150 
    151151
    152152proc makeGraph(list v, list e)
     
    170170  G;
    171171}
    172 
    173172
    174173proc propagator(def xy, def d)
     
    195194"
    196195{
    197   if ((typeof(xy)=="list")||(typeof(d)=="int")) {
     196  if ((typeof(xy)=="list")||(typeof(d)=="int"))
     197  {
    198198    number x = xy[1];
    199199    number y = xy[2];
     
    201201    if (d==0) {return(x^2*y^2/(x^2-y^2)^2);}
    202202    number p=0;
    203     for (int j=1; j<=d; j++){
     203    for (int j=1; j<=d; j++)
     204    {
    204205       if (d%j==0){p=p+(j*x^(4*j)+j*y^(4*j))/(x*y)^(2*j);}
    205206    }
    206207    return(p);
    207208  }
    208   if ((typeof(xy)=="graph")||(typeof(d)=="list"))  {
     209  if ((typeof(xy)=="graph")||(typeof(d)=="list"))
     210  {
    209211    list xl = ringlist(basering)[1][2];
    210212    list ed = xy.edges;
    211213    number f=1;
    212     for (int j=1; j<=size(ed); j++){
     214    for (int j=1; j<=size(ed); j++)
     215    {
    213216       execute("number xx1 = "+xl[ed[j][1]]);
    214217       execute("number xx2 = "+xl[ed[j][2]]);
     
    219222    return(f);
    220223  }
    221   if ((typeof(xy)=="graph")||(typeof(d)=="int"))  {
    222   }
    223 ERROR("wrong input type");}
     224  if ((typeof(xy)=="graph")||(typeof(d)=="int"))
     225  {
     226  }
     227  ERROR("wrong input type");
     228}
    224229example
    225230{ "EXAMPLE:"; echo=2;
     
    230235  propagator(G,list(1,1,1,0,0,0));
    231236}
    232 
    233 
    234 
    235 
    236237
    237238proc computeConstant(number f,number xx)
     
    240241RETURN:  number, the constant coefficient of the Laurent series of f in the variable x.
    241242THEORY:  Computes the constant coefficient of the Laurent series by iterative differentiation.
    242 
    243243KEYWORDS: Laurent series
    244244EXAMPLE:  example computeConstant; shows an example
     
    250250  int j;
    251251  poly de;
    252   while (tst==0){
    253      ff=f*xx^k;
    254      for (j=1; j<=k; j++){
    255         ff=diff(ff,xx)/j;
    256      }
    257   de = subst(denominator(ff),xx,0);
    258   if (de!=0){
    259      poly nu = subst(numerator(ff),xx,0);
    260      return(number(nu/de));
    261   }
    262   k=k+1;
    263   }
    264 ERROR("error in computeConstant");}
     252  while (tst==0)
     253  {
     254    ff=f*xx^k;
     255    for (j=1; j<=k; j++)i
     256    {
     257      ff=diff(ff,xx)/j;
     258    }
     259    de = subst(denominator(ff),xx,0);
     260    if (de!=0)
     261    {
     262      poly nu = subst(numerator(ff),xx,0);
     263      return(number(nu/de));
     264    }
     265    k++;
     266  }
     267  ERROR("error in computeConstant");
     268}
    265269example
    266270{ "EXAMPLE:"; echo=2;
     
    270274  computeConstant(P,x2);
    271275}
    272 
    273 
    274 
    275276
    276277proc evaluateIntegral(number P, list xL)
     
    289290{
    290291  number p = P;
    291   for(int j=1; j<=size(xL); j++){
     292  for(int j=1; j<=size(xL); j++)
     293  {
    292294     p=computeConstant(p,xL[j]);
    293295  }
    294 return(p);}
     296  return(p);
     297}
    295298example
    296299{ "EXAMPLE:"; echo=2;
     
    300303  evaluateIntegral(p,list(x1,x3,x4,x2));
    301304}
    302 
    303305
    304306proc permute (list N)
     
    314316"
    315317{
    316    int i,j,k;
    317    list L,L1;
    318    if (size(N)==1){
    319      return(list(N));
    320    } else {
    321      k=1;
    322      for (i=1; i<=size(N); i++){
    323        L=permute(delete(N,i));
    324        for (j=1; j<=size(L); j++){
    325           L1[k]=L[j]+list(N[i]);
    326           k=k+1;
    327        }
    328      }
    329    }
    330 return(L1);}
     318  int i,j,k;
     319  list L,L1;
     320  if (size(N)==1)
     321  {
     322    return(list(N));
     323  }
     324  else
     325  {
     326    k=1;
     327    for (i=1; i<=size(N); i++)
     328    {
     329      L=permute(delete(N,i));
     330      for (j=1; j<=size(L); j++)
     331      {
     332        L1[k]=L[j]+list(N[i]);
     333        k=k+1;
     334      }
     335    }
     336  }
     337  return(L1);
     338}
    331339example
    332340{ "EXAMPLE:"; echo=2;
     
    349357"
    350358{
    351 ring R = 2,(x(1..n)),dp;
    352 ideal I = maxideal(a);
    353 list L;
    354 for (int j=1;j<=size(I);j++){
    355   L[j]=leadexp(I[j]);
    356 }
    357 return(L);}
     359  ring R = 2,(x(1..n)),dp;
     360  ideal I = maxideal(a);
     361  list L;
     362  for (int j=1;j<=size(I);j++)i
     363  {
     364    L[j]=leadexp(I[j]);
     365  }
     366  return(L);
     367}
    358368example
    359369{ "EXAMPLE:"; echo=2;
    360370  partitions(3,7);
    361371}
    362 
    363 
    364372
    365373proc gromovWitten(def P,list #)
     
    385393"
    386394{
    387   if (typeof(P)=="number") {
    388   list xl = ringlist(basering)[1][2];
    389   int j;
    390   for(j=1; j<=size(xl); j++){
    391      execute("number n= "+xl[j]);
    392      xl[j]=n;
    393      kill n;
    394   }
    395   list pxl = permute(xl);
    396   number p = 0;
    397   for(j=1; j<=size(pxl); j++){
    398      p=p+evaluateIntegral(P,pxl[j]);
    399   }
    400   return(p);
    401   }
    402   if (typeof(P)=="graph"){
    403      if (size(#)>1){
    404        return(gromovWitten(propagator(P,#)));
    405      } else {
     395  if (typeof(P)=="number")
     396  {
     397    list xl = ringlist(basering)[1][2];
     398    int j;
     399    for(j=1; j<=size(xl); j++)
     400    {
     401      execute("number n= "+xl[j]);
     402      xl[j]=n;
     403      kill n;
     404    }
     405    list pxl = permute(xl);
     406    number p = 0;
     407    for(j=1; j<=size(pxl); j++)
     408    {
     409      p=p+evaluateIntegral(P,pxl[j]);
     410    }
     411    return(p);
     412  }
     413  if (typeof(P)=="graph")
     414  {
     415    if (size(#)>1)
     416    {
     417      return(gromovWitten(propagator(P,#)));
     418    }
     419    else
     420    {
    406421      int d =#[1];
    407422      list pa = partitions(size(P.edges),d);
    408423      list re;
    409424      int ti;
    410       for (int j=1; j<=size(pa); j++) {
    411        ti=timer;
    412        re[j]=gromovWitten(propagator(P,pa[j]));
    413        ti=timer-ti;
    414        //print(string(j)+" / "+string(size(pa))+"    "+string(pa[j])+"     "+string(re[j])+"      "+string(sum(re))+"     "+string(ti));
     425      for (int j=1; j<=size(pa); j++)
     426      {
     427        ti=timer;
     428        re[j]=gromovWitten(propagator(P,pa[j]));
     429        ti=timer-ti;
     430        //print(string(j)+" / "+string(size(pa))+"    "+string(pa[j])+"     "+string(re[j])+"      "+string(sum(re))+"     "+string(ti));
    415431      }
    416      return(lsum(re));
    417      }
     432      return(lsum(re));
     433    }
    418434  }
    419435}
     
    427443  gromovWitten(G,2);
    428444}
    429 
    430 
    431445
    432446proc computeGromovWitten(graph P,int d, int st, int en, list #)
     
    443457"
    444458{
    445      number s =0;
    446      list pararg;
    447      list re;
    448      list pa = partitions(size(P.edges),d);
    449      int vb=0;
    450      if (size(#)>0){vb=#[1];}
    451      int ti;
    452      if (vb>0){print(size(pa));}
    453      for (int j=1; j<=size(pa); j++) {
    454       if ((j>=st)&(j<=en)){
    455        ti=timer;
    456        //pararg[j]=list(propagator(G,pa[j]));
    457        re[j]=gromovWitten(propagator(P,pa[j]));
    458        ti=timer-ti;
    459        if (vb>0){print(string(j)+" / "+string(size(pa))+"    "+string(pa[j])+"     "+string(re[j])+"      "+string(lsum(re))+"     "+string(ti));}
    460       } else {re[j]=s;}
    461      }
    462      //list re = parallelWaitAll("gromovWitten", pararg, list(list(list(2))));
    463      return(re);
     459  number s =0;
     460  list pararg;
     461  list re;
     462  list pa = partitions(size(P.edges),d);
     463  int vb=0;
     464  if (size(#)>0){vb=#[1];}
     465  int ti;
     466  if (vb>0){print(size(pa));}
     467  for (int j=1; j<=size(pa); j++)
     468  {
     469    if ((j>=st)&(j<=en))
     470    {
     471      ti=timer;
     472      //pararg[j]=list(propagator(G,pa[j]));
     473      re[j]=gromovWitten(propagator(P,pa[j]));
     474      ti=timer-ti;
     475      if (vb>0){print(string(j)+" / "+string(size(pa))+"    "+string(pa[j])+"     "+string(re[j])+"      "+string(lsum(re))+"     "+string(ti));}
     476    }
     477    else
     478    {re[j]=s;}
     479  }
     480  //list re = parallelWaitAll("gromovWitten", pararg, list(list(list(2))));
     481  return(re);
    464482}
    465483example
     
    471489  computeGromovWitten(G,2,3,7,1);
    472490}
    473 
    474491
    475492proc lsum(list L)
     
    485502{
    486503  execute(typeof(L[1])+" s");
    487   for(int j=1; j<=size(L); j++){
    488      s=s+L[j];
    489   }
    490 return(s);}
     504  for(int j=1; j<=size(L); j++)
     505  {
     506    s=s+L[j];
     507  }
     508  return(s);
     509}
    491510example
    492511{ "EXAMPLE:"; echo=2;
     
    494513  lsum(L);
    495514}
    496 
    497 
    498515
    499516proc generatingFunction(graph G, int d)
     
    512529  int j,jj;
    513530  list pa,L;
    514   for (j=1; j<=d; j++){
     531  for (j=1; j<=d; j++)
     532  {
    515533    pa = partitions(size(G.edges),j);
    516534    L = computeGromovWitten(G,j,1,size(pa));
    517     for (jj=1; jj<=size(pa); jj++) {
    518        s=s+L[jj]*monomial(pa[jj]);
    519     }
    520   }
    521 return(s);}
     535    for (jj=1; jj<=size(pa); jj++)
     536    {
     537      s=s+L[jj]*monomial(pa[jj]);
     538    }
     539  }
     540  return(s);
     541}
    522542example
    523543{ "EXAMPLE:"; echo=2;
Note: See TracChangeset for help on using the changeset viewer.