source: git/Singular/LIB/gmssing.lib @ faed79

spielwiese
Last change on this file since faed79 was 7d56875, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: typos reported by gorzelc git-svn-id: file:///usr/local/Singular/svn/trunk@11114 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 36.9 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: gmssing.lib,v 1.12 2008-10-09 09:31:57 Singular Exp $";
3category="Singularities";
4
5info="
6LIBRARY:  gmssing.lib  Gauss-Manin System of Isolated Singularities
7
8AUTHOR:   Mathias Schulze, email: mschulze@mathematik.uni-kl.de
9
10OVERVIEW: A library to compute invariants related to the Gauss-Manin system
11          of an isolated hypersurface singularity
12
13PROCEDURES:
14 gmsring(t,s);              Gauss-Manin system of t with variable s
15 gmsnf(p,K);                Gauss-Manin normal form of p
16 gmscoeffs(p,K);            Gauss-Manin basis representation of p
17 bernstein(t);              roots of the Bernstein polynomial of t
18 monodromy(t);              Jordan data of complex monodromy of t
19 spectrum(t);               singularity spectrum of t
20 sppairs(t);                spectral pairs of t
21 vfilt(t);                  V-filtration of t on Brieskorn lattice
22 vwfilt(t);                 weighted V-filtration of t on Brieskorn lattice
23 tmatrix(t);                matrix of t w.r.t. good basis of Brieskorn lattice
24 endvfilt(V);               endomorphism V-filtration on Jacobian algebra
25 sppnf(a,w[,m]);            spectral pairs normal form of (a,w[,m])
26 sppprint(spp);             print spectral pairs spp
27 spadd(sp1,sp2);            sum of spectra sp1 and sp2
28 spsub(sp1,sp2);            difference of spectra sp1 and sp2
29 spmul(sp0,k);              linear combination of spectra sp
30 spissemicont(sp[,opt]);    semicontinuity test of spectrum sp
31 spsemicont(sp0,sp[,opt]);  semicontinuous combinations of spectra sp0 in sp
32 spmilnor(sp);              Milnor number of spectrum sp
33 spgeomgenus(sp);           geometrical genus of spectrum sp
34 spgamma(sp);               gamma invariant of spectrum sp
35
36SEE ALSO: mondromy_lib, spectrum_lib, gmspoly_lib
37
38KEYWORDS: singularities; Gauss-Manin system; Brieskorn lattice;
39          mixed Hodge structure; V-filtration; weight filtration
40          Bernstein polynomial; monodromy; spectrum; spectral pairs;
41          good basis
42";
43
44LIB "linalg.lib";
45
46///////////////////////////////////////////////////////////////////////////////
47
48static proc stdtrans(ideal I)
49{
50  def @R=basering;
51
52  string os=ordstr(@R);
53  int j=find(os,",C");
54  if(j==0)
55  {
56    j=find(os,"C,");
57  }
58  if(j==0)
59  {
60    j=find(os,",c");
61  }
62  if(j==0)
63  {
64    j=find(os,"c,");
65  }
66  if(j>0)
67  {
68    os[j..j+1]="  ";
69  }
70
71  execute("ring @S="+charstr(@R)+",(gmspoly,"+varstr(@R)+"),(c,dp,"+os+");");
72
73  ideal I=homog(imap(@R,I),gmspoly);
74  module M=transpose(transpose(I)+freemodule(ncols(I)));
75  M=std(M);
76
77  setring(@R);
78  execute("map h=@S,1,"+varstr(@R)+";");
79  module M=h(M);
80
81  for(int i=ncols(M);i>=1;i--)
82  {
83    for(j=ncols(M);j>=1;j--)
84    {
85      if(M[i][1]==0)
86      {
87        M[i]=0;
88      }
89      if(i!=j&&M[j][1]!=0)
90      {
91        if(lead(M[i][1])/lead(M[j][1])!=0)
92        {
93          M[i]=0;
94        }
95      }
96    }
97  }
98
99  M=transpose(simplify(M,2));
100  I=M[1];
101  attrib(I,"isSB",1);
102  M=M[2..ncols(M)];
103  module U=transpose(M);
104
105  return(list(I,U));
106}
107///////////////////////////////////////////////////////////////////////////////
108
109proc gmsring(poly t,string s)
110"USAGE:    gmsring(t,s); poly t, string s
111ASSUME:   characteristic 0; local degree ordering;
112          isolated critical point 0 of t
113RETURN:
114@format
115ring G;  Gauss-Manin system of t with variable s
116  poly gmspoly=t;
117  ideal gmsjacob;  Jacobian ideal of t
118  ideal gmsstd;  standard basis of Jacobian ideal
119  matrix gmsmatrix;  matrix(gmsjacob)*gmsmatrix==matrix(gmsstd)
120  ideal gmsbasis;  monomial vector space basis of Jacobian algebra
121  int gmsmaxdeg;  maximal weight of variables
122@end format
123NOTE:     gmsbasis is a C[[s]]-basis of H'' and [t,s]=s^2
124KEYWORDS: Gauss-Manin system; Brieskorn lattice
125EXAMPLE:  example gmsring; shows examples
126"
127{
128  def @R=basering;
129  if(charstr(@R)!="0")
130  {
131    ERROR("characteristic 0 expected");
132  }
133  for(int i=nvars(@R);i>=1;i--)
134  {
135    if(var(i)>1)
136    {
137      ERROR("local ordering expected");
138    }
139  }
140
141  ideal dt=jacob(t);
142  list l=stdtrans(dt);
143  ideal g=l[1];
144  if(vdim(g)<=0)
145  {
146    if(vdim(g)==0)
147    {
148      ERROR("singularity at 0 expected");
149    }
150    else
151    {
152      ERROR("isolated critical point 0 expected");
153    }
154  }
155  matrix B=l[2];
156  ideal m=kbase(g);
157
158  int gmsmaxdeg;
159  for(i=nvars(@R);i>=1;i--)
160  {
161    if(deg(var(i))>gmsmaxdeg)
162    {
163      gmsmaxdeg=deg(var(i));
164    }
165  }
166
167  string os=ordstr(@R);
168  int j=find(os,",C");
169  if(j==0)
170  {
171    j=find(os,"C,");
172  }
173  if(j==0)
174  {
175    j=find(os,",c");
176  }
177  if(j==0)
178  {
179    j=find(os,"c,");
180  }
181  if(j>0)
182  {
183    os[j..j+1]="  ";
184  }
185
186  execute("ring G="+string(charstr(@R))+",("+s+","+varstr(@R)+"),(ws("+
187    string(deg(highcorner(g))+2*gmsmaxdeg)+"),"+os+",c);");
188
189  poly gmspoly=imap(@R,t);
190  ideal gmsjacob=imap(@R,dt);
191  ideal gmsstd=imap(@R,g);
192  matrix gmsmatrix=imap(@R,B);
193  ideal gmsbasis=imap(@R,m);
194
195  attrib(gmsstd,"isSB",1);
196  export gmspoly, gmsjacob, gmsstd, gmsmatrix, gmsbasis;
197  if (system("with","Namespaces")) { exportto(Top, gmsmaxdeg);}
198  else { export(gmsmaxdeg);}
199
200  return(G);
201}
202example
203{ "EXAMPLE:"; echo=2;
204  ring @R=0,(x,y),ds;
205  poly t=x5+x2y2+y5;
206  def G=gmsring(t,"s");
207  setring(G);
208  gmspoly;
209  print(gmsjacob);
210  print(gmsstd);
211  print(gmsmatrix);
212  print(gmsbasis);
213  gmsmaxdeg;
214}
215///////////////////////////////////////////////////////////////////////////////
216
217proc gmsnf(ideal p,int K)
218"USAGE:    gmsnf(p,K); poly p, int K
219ASSUME:   basering returned by gmsring
220RETURN:
221  list nf;
222  ideal nf[1];  projection of p to <gmsbasis>C{{s}} mod s^(K+1) @*
223  ideal nf[2];  p==nf[1]+nf[2]
224NOTE:     computation can be continued by setting p to nf[2][1]
225EXAMPLE:  example gmsnf; shows examples
226"
227{
228  if(system("with","gms"))
229  {
230    return(system("gmsnf",p,gmsstd,gmsmatrix,(K+1)*deg(var(1))-2*gmsmaxdeg,K));
231  }
232
233  intvec v=1;
234  v[nvars(basering)]=0;
235
236  int k;
237  ideal r,q;
238  r[ncols(p)]=0;
239  q[ncols(p)]=0;
240
241  poly s;
242  int i,j;
243  for(k=ncols(p);k>=1;k--)
244  {
245    while(p[k]!=0&&deg(lead(p[k]),v)<=K)
246    {
247      i=1;
248      s=lead(p[k])/lead(gmsstd[i]);
249      while(i<ncols(gmsstd)&&s==0)
250      {
251        i++;
252        s=lead(p[k])/lead(gmsstd[i]);
253      }
254      if(s!=0)
255      {
256        p[k]=p[k]-s*gmsstd[i];
257        for(j=1;j<=nrows(gmsmatrix);j++)
258        {
259          p[k]=p[k]+diff(s*gmsmatrix[j,i],var(j+1))*var(1);
260        }
261      }
262      else
263      {
264        r[k]=r[k]+lead(p[k]);
265        p[k]=p[k]-lead(p[k]);
266      }
267      while(deg(lead(p[k]))>(K+1)*deg(var(1))-2*gmsmaxdeg&&
268        deg(lead(p[k]),v)<=K)
269      {
270        q[k]=q[k]+lead(p[k]);
271        p[k]=p[k]-lead(p[k]);
272      }
273    }
274    q[k]=q[k]+p[k];
275  }
276
277  return(list(r,q));
278}
279example
280{ "EXAMPLE:"; echo=2;
281  ring R=0,(x,y),ds;
282  poly t=x5+x2y2+y5;
283  def G=gmsring(t,"s");
284  setring(G);
285  list l0=gmsnf(gmspoly,0);
286  print(l0[1]);
287  list l1=gmsnf(gmspoly,1);
288  print(l1[1]);
289  list l=gmsnf(l0[2],1);
290  print(l[1]);
291}
292///////////////////////////////////////////////////////////////////////////////
293
294proc gmscoeffs(ideal p,int K)
295"USAGE:    gmscoeffs(p,K); poly p, int K
296ASSUME:   basering constructed by gmsring
297RETURN:
298@format
299list l;
300  matrix l[1];  C@{@{s@}@}-basis representation of p mod s^(K+1)
301  ideal l[2];  p==matrix(gmsbasis)*l[1]+l[2]
302@end format
303NOTE:     computation can be continued by setting p to l[2]
304EXAMPLE:  example gmscoeffs; shows examples
305"
306{
307  list l=gmsnf(p,K);
308  ideal r,q=l[1..2];
309  poly v=1;
310  for(int i=2;i<=nvars(basering);i++)
311  {
312    v=v*var(i);
313  }
314  matrix C=coeffs(r,gmsbasis,v);
315  return(list(C,q));
316}
317example
318{ "EXAMPLE:"; echo=2;
319  ring R=0,(x,y),ds;
320  poly t=x5+x2y2+y5;
321  def G=gmsring(t,"s");
322  setring(G);
323  list l0=gmscoeffs(gmspoly,0);
324  print(l0[1]);
325  list l1=gmscoeffs(gmspoly,1);
326  print(l1[1]);
327  list l=gmscoeffs(l0[2],1);
328  print(l[1]);
329}
330///////////////////////////////////////////////////////////////////////////////
331
332static proc mindegree(matrix A)
333{
334  int d=-1;
335
336  int i,j;
337  for(i=nrows(A);i>=1;i--)
338  {
339    for(j=ncols(A);j>=1;j--)
340    {
341      if(d==-1||(ord(A[i,j])<d&&ord(A[i,j])>-1))
342      {
343        d=ord(A[i,j]);
344      }
345    }
346  }
347
348  return(d);
349}
350///////////////////////////////////////////////////////////////////////////////
351
352static proc maxdegree(matrix A)
353{
354  int d=-1;
355
356  int i,j;
357  for(i=nrows(A);i>=1;i--)
358  {
359    for(j=ncols(A);j>=1;j--)
360    {
361      if(deg(A[i,j])>d)
362      {
363        d=deg(A[i,j]);
364      }
365    }
366  }
367
368  return(d);
369}
370///////////////////////////////////////////////////////////////////////////////
371
372static proc saturate()
373{
374  int mu=ncols(gmsbasis);
375  ideal r=gmspoly*gmsbasis;
376  matrix A0[mu][mu],C;
377  module H0;
378  module H,H1=freemodule(mu),freemodule(mu);
379  int k=-1;
380  list l;
381
382  dbprint(printlevel-voice+2,"// compute saturation of H''");
383  while(size(reduce(H,std(H0*var(1))))>0)
384  {
385    dbprint(printlevel-voice+2,"// compute matrix A of t");
386    k++;
387    dbprint(printlevel-voice+2,"// k="+string(k));
388    l=gmscoeffs(r,k);
389    C,r=l[1..2];
390    A0=A0+C;
391
392    dbprint(printlevel-voice+2,"// compute saturation step");
393    H0=H;
394    H1=jet(module(A0*H1+var(1)^2*diff(matrix(H1),var(1))),k);
395    H=H*var(1)+H1;
396  }
397
398  A0=A0-k*var(1);
399  dbprint(printlevel-voice+2,"// compute basis of saturation of H''");
400  H=std(H0);
401
402  dbprint(printlevel-voice+2,"// transform H'' to saturation of H''");
403  H0=division(freemodule(mu)*var(1)^k,H,k*deg(var(1)))[1];
404
405  return(A0,r,H,H0,k);
406}
407///////////////////////////////////////////////////////////////////////////////
408
409static proc tjet(matrix A0,ideal r,module H,int K0,int K)
410{
411  dbprint(printlevel-voice+2,"// compute matrix A of t");
412  dbprint(printlevel-voice+2,"// k="+string(K0+K+1));
413  list l=gmscoeffs(r,K0+K+1);
414  matrix C;
415  C,r=l[1..2];
416  A0=A0+C;
417  dbprint(printlevel-voice+2,"// transform A to saturation of H''");
418  matrix A=division(A0*H+var(1)^2*diff(matrix(H),var(1)),H,
419    (K+1)*deg(var(1)))[1]/var(1);
420  return(A,A0,r);
421}
422///////////////////////////////////////////////////////////////////////////////
423
424static proc eigenval(matrix A0,ideal r,module H,int K0)
425{
426  dbprint(printlevel-voice+2,
427    "// compute eigenvalues e with multiplicities m of A1");
428  matrix A;
429  A,A0,r=tjet(A0,r,H,K0,0);
430  list l=eigenvals(A);
431  def e,m=l[1..2];
432  dbprint(printlevel-voice+2,"// e="+string(e));
433  dbprint(printlevel-voice+2,"// m="+string(m));
434  return(e,m,A0,r);
435}
436///////////////////////////////////////////////////////////////////////////////
437
438static proc transform(matrix A,matrix A0,ideal r,module H,module H0,ideal e,
439  intvec m,int K0,int K,int opt)
440{
441  int mu=ncols(gmsbasis);
442
443  int i,j,k;
444  intvec d;
445  d[ncols(e)]=0;
446  if(opt)
447  {
448    dbprint(printlevel-voice+2,
449      "// compute rounded maximal differences d of e");
450    for(i=1;i<=ncols(e);i++)
451    {
452      d[i]=int(e[ncols(e)]-e[i]);
453    }
454  }
455  else
456  {
457    dbprint(printlevel-voice+2,
458      "// compute maximal integer differences d of e");
459    for(i=1;i<ncols(e);i++)
460    {
461      for(j=i+1;j<=ncols(e);j++)
462      {
463        k=int(e[j]-e[i]);
464        if(number(e[j]-e[i])==k)
465        {
466          if(k>d[i])
467          {
468            d[i]=k;
469          }
470          if(-k>d[j])
471          {
472            d[j]=-k;
473          }
474        }
475      }
476    }
477  }
478  dbprint(printlevel-voice+2,"// d="+string(d));
479
480  for(i,k=1,0;i<=size(d);i++)
481  {
482    if(k<d[i])
483    {
484      k=d[i];
485    }
486  }
487  A,A0,r=tjet(A0,r,H,K0,K+k);
488
489  module U,V;
490  if(k>0)
491  {
492    int i0,j0,i1,j1;
493    list l;
494
495    while(k>0)
496    {
497      dbprint(printlevel-voice+2,"// transform to separate eigenvalues");
498      U=0;
499      for(i=1;i<=ncols(e);i++)
500      {
501        U=U+syz(power(jet(A,0)-e[i],m[i]));
502      }
503      V=inverse(U);
504      A=V*A*U;
505      H=H*U;
506      H0=V*H0;
507
508      dbprint(printlevel-voice+2,"// transform to reduce maximum of d by 1");
509      for(i0,i=1,1;i0<=ncols(e);i0++)
510      {
511        for(i1=1;i1<=m[i0];i1,i=i1+1,i+1)
512        {
513          for(j0,j=1,1;j0<=ncols(e);j0++)
514          {
515            for(j1=1;j1<=m[j0];j1,j=j1+1,j+1)
516            {
517              if(d[i0]==0&&d[j0]>=1)
518              {
519                A[i,j]=A[i,j]*var(1);
520              }
521              if(d[i0]>=1&&d[j0]==0)
522              {
523                A[i,j]=A[i,j]/var(1);
524              }
525            }
526          }
527        }
528      }
529
530      H0=transpose(H0);
531      for(i0,i=1,1;i0<=ncols(e);i0++)
532      {
533        if(d[i0]>=1)
534        {
535          for(i1=1;i1<=m[i0];i1,i=i1+1,i+1)
536          {
537            H[i]=H[i]*var(1);
538          }
539          d[i0]=d[i0]-1;
540        }
541        else
542        {
543          for(i1=1;i1<=m[i0];i1,i=i1+1,i+1)
544          {
545            A[i,i]=A[i,i]-1;
546            H0[i]=H0[i]*var(1);
547          }
548          e[i0]=e[i0]-1;
549        }
550      }
551      H0=transpose(H0);
552
553      l=sppnf(list(e,d,m));
554      e,d,m=l[1..3];
555
556      k--;
557      K0++;
558    }
559
560    A=jet(A,K);
561  }
562
563  dbprint(printlevel-voice+2,"// transform to separate eigenvalues");
564  U=0;
565  for(i=1;i<=ncols(e);i++)
566  {
567    U=U+syz(power(jet(A,0)-e[i],m[i]));
568  }
569  V=inverse(U);
570  A=V*A*U;
571  H=H*U;
572  H0=V*H0;
573
574  return(A,A0,r,H,H0,e,m,K0);
575}
576///////////////////////////////////////////////////////////////////////////////
577
578proc bernstein(poly t)
579"USAGE:    bernstein(t); poly t
580ASSUME:   characteristic 0; local degree ordering;
581          isolated critical point 0 of t
582RETURN:   list:
583          roots of the Bernstein polynomial b (ideal) and its multiplicies
584NOTE:     the roots of b are negative rational numbers and -1 is a root of b
585KEYWORDS: Bernstein polynomial
586EXAMPLE:  example bernstein; shows examples
587"
588{
589  def @R=basering;
590  int n=nvars(@R)-1;
591  def @G=gmsring(t,"s");
592  setring(@G);
593
594  matrix A;
595  module U0;
596  ideal e;
597  intvec m;
598
599  def A0,r,H,H0,K0=saturate();
600  A,A0,r=tjet(A0,r,H,K0,0);
601  list l=minipoly(A);
602  e,m=l[1..2];
603
604  for(int i=1;i<=ncols(e);i++)
605  {
606    e[i]=-e[i];
607    if(e[i]==-1)
608    {
609      m[i]=m[i]+1;
610    }
611  }
612
613  setring(@R);
614  ideal e=imap(@G,e);
615  kill @G,gmsmaxdeg;
616
617  return(list(e,m));
618}
619example
620{ "EXAMPLE:"; echo=2;
621  ring R=0,(x,y),ds;
622  poly t=x5+x2y2+y5;
623  bernstein(t);
624}
625///////////////////////////////////////////////////////////////////////////////
626
627proc monodromy(poly t)
628"USAGE:    monodromy(t); poly t
629ASSUME:   characteristic 0; local degree ordering;
630          isolated critical point 0 of t
631RETURN:
632@format
633list l;  Jordan data jordan(M) of monodromy matrix exp(-2*pi*i*M)
634  ideal l[1];
635    number l[1][i];  eigenvalue of i-th Jordan block of M
636  intvec l[2];
637    int l[2][i];  size of i-th Jordan block of M
638  intvec l[3];
639    int l[3][i];  multiplicity of i-th Jordan block of M
640@end format
641SEE ALSO: mondromy_lib, linalg_lib
642KEYWORDS: monodromy
643EXAMPLE:  example monodromy; shows examples
644"
645{
646  def @R=basering;
647  int n=nvars(@R)-1;
648  def @G=gmsring(t,"s");
649  setring(@G);
650
651  matrix A;
652  module U0;
653  ideal e;
654  intvec m;
655
656  def A0,r,H,H0,K0=saturate();
657  e,m,A0,r=eigenval(A0,r,H,K0);
658  A,A0,r,H,H0,e,m,K0=transform(A,A0,r,H,H0,e,m,K0,0,0);
659
660  list l=jordan(A,e,m);
661  setring(@R);
662  list l=imap(@G,l);
663  kill @G,gmsmaxdeg;
664
665  return(l);
666}
667example
668{ "EXAMPLE:"; echo=2;
669  ring R=0,(x,y),ds;
670  poly t=x5+x2y2+y5;
671  monodromy(t);
672}
673///////////////////////////////////////////////////////////////////////////////
674
675proc spectrum(poly t)
676"USAGE:    spectrum(t); poly t
677ASSUME:   characteristic 0; local degree ordering;
678          isolated critical point 0 of t
679RETURN:
680@format
681list sp;  singularity spectrum of t
682  ideal sp[1];
683    number sp[1][i];  i-th spectral number
684  intvec sp[2];
685    int sp[2][i];  multiplicity of i-th spectral number
686@end format
687SEE ALSO: spectrum_lib
688KEYWORDS: mixed Hodge structure; V-filtration; spectrum
689EXAMPLE:  example spectrum; shows examples
690"
691{
692  list l=vwfilt(t);
693  return(spnf(list(l[1],l[3])));
694}
695example
696{ "EXAMPLE:"; echo=2;
697  ring R=0,(x,y),ds;
698  poly t=x5+x2y2+y5;
699  spprint(spectrum(t));
700}
701///////////////////////////////////////////////////////////////////////////////
702
703proc sppairs(poly t)
704"USAGE:    sppairs(t); poly t
705ASSUME:   characteristic 0; local degree ordering;
706          isolated critical point 0 of t
707RETURN:
708@format
709list spp;  spectral pairs of t
710  ideal spp[1];
711    number spp[1][i];  V-filtration index of i-th spectral pair
712  intvec spp[2];
713    int spp[2][i];  weight filtration index of i-th spectral pair
714  intvec spp[3];
715    int spp[3][i];  multiplicity of i-th spectral pair
716@end format
717SEE ALSO: spectrum_lib
718KEYWORDS: mixed Hodge structure; V-filtration; weight filtration;
719          spectrum; spectral pairs
720EXAMPLE:  example sppairs; shows examples
721"
722{
723  list l=vwfilt(t);
724  return(list(l[1],l[2],l[3]));
725}
726example
727{ "EXAMPLE:"; echo=2;
728  ring R=0,(x,y),ds;
729  poly t=x5+x2y2+y5;
730  sppprint(sppairs(t));
731}
732///////////////////////////////////////////////////////////////////////////////
733
734proc vfilt(poly t)
735"USAGE:    vfilt(t); poly t
736ASSUME:   characteristic 0; local degree ordering;
737          isolated critical point 0 of t
738RETURN:
739@format
740list v;  V-filtration on H''/s*H''
741  ideal v[1];
742    number v[1][i];  V-filtration index of i-th spectral number
743  intvec v[2];
744    int v[2][i];  multiplicity of i-th spectral number
745  list v[3];
746    module v[3][i];  vector space of i-th graded part in terms of v[4]
747  ideal v[4];  monomial vector space basis of H''/s*H''
748  ideal v[5];  standard basis of Jacobian ideal
749@end format
750SEE ALSO: spectrum_lib
751KEYWORDS: mixed Hodge structure; V-filtration; spectrum
752EXAMPLE:  example vfilt; shows examples
753"
754{
755  list l=vwfilt(t);
756  return(spnf(list(l[1],l[3],l[4]))+list(l[5],l[6]));
757}
758example
759{ "EXAMPLE:"; echo=2;
760  ring R=0,(x,y),ds;
761  poly t=x5+x2y2+y5;
762  vfilt(t);
763}
764///////////////////////////////////////////////////////////////////////////////
765
766proc vwfilt(poly t)
767"USAGE:    vwfilt(t); poly t
768ASSUME:   characteristic 0; local degree ordering;
769          isolated critical point 0 of t
770RETURN:
771@format
772list vw;  weighted V-filtration on H''/s*H''
773  ideal vw[1];
774    number vw[1][i];  V-filtration index of i-th spectral pair
775  intvec vw[2];
776    int vw[2][i];  weight filtration index of i-th spectral pair
777  intvec vw[3];
778    int vw[3][i];  multiplicity of i-th spectral pair
779  list vw[4];
780    module vw[4][i];  vector space of i-th graded part in terms of vw[5]
781  ideal vw[5];  monomial vector space basis of H''/s*H''
782  ideal vw[6];  standard basis of Jacobian ideal
783@end format
784SEE ALSO: spectrum_lib
785KEYWORDS: mixed Hodge structure; V-filtration; weight filtration;
786          spectrum; spectral pairs
787EXAMPLE:  example vwfilt; shows examples
788"
789{
790  def @R=basering;
791  int n=nvars(@R)-1;
792  def @G=gmsring(t,"s");
793  setring(@G);
794
795  int mu=ncols(gmsbasis);
796  matrix A;
797  ideal e;
798  intvec m;
799
800  def A0,r,H,H0,K0=saturate();
801  e,m,A0,r=eigenval(A0,r,H,K0);
802  A,A0,r,H,H0,e,m,K0=transform(A,A0,r,H,H0,e,m,K0,0,1);
803
804  dbprint(printlevel-voice+2,"// compute weight filtration basis");
805  list l=jordanbasis(A,e,m);
806  def U,v=l[1..2];
807  kill l;
808  vector u0;
809  int v0;
810  int i,j,k,l;
811  for(k,l=1,1;l<=ncols(e);k,l=k+m[l],l+1)
812  {
813    for(i=k+m[l]-1;i>=k+1;i--)
814    {
815      for(j=i-1;j>=k;j--)
816      {
817        if(v[i]>v[j])
818        {
819          v0=v[i];v[i]=v[j];v[j]=v0;
820          u0=U[i];U[i]=U[j];U[j]=u0;
821        }
822      }
823    }
824  }
825
826  dbprint(printlevel-voice+2,"// transform to weight filtration basis");
827  matrix V=inverse(U);
828  A=V*A*U;
829  dbprint(printlevel-voice+2,"// compute standard basis of H''");
830  H=H*U;
831  H0=std(V*H0);
832
833  dbprint(printlevel-voice+2,"// compute spectral pairs");
834  ideal a;
835  intvec w;
836  for(i=1;i<=mu;i++)
837  {
838    j=leadexp(H0[i])[nvars(basering)+1];
839    a[i]=A[j,j]+ord(H0[i])/deg(var(1))-1;
840    w[i]=v[j]+n;
841  }
842  H=H*H0;
843  H=simplify(jet(H/var(1)^(mindegree(H)/deg(var(1))),0),1);
844
845  kill l;
846  list l=sppnf(list(a,w,H))+list(gmsbasis,gmsstd);
847  setring(@R);
848  list l=imap(@G,l);
849  kill @G,gmsmaxdeg;
850  attrib(l[5],"isSB",1);
851
852  return(l);
853}
854example
855{ "EXAMPLE:"; echo=2;
856  ring R=0,(x,y),ds;
857  poly t=x5+x2y2+y5;
858  vwfilt(t);
859}
860///////////////////////////////////////////////////////////////////////////////
861
862static proc fsplit(ideal e0,intvec m0,matrix A,module H,module H0)
863{
864  int mu=ncols(gmsbasis);
865
866  dbprint(printlevel-voice+2,"// compute standard basis of H''");
867  H0=std(H0);
868  H0=simplify(H0,1);
869
870  dbprint(printlevel-voice+2,"// compute Hodge filtration");
871  int i,j,k;
872  ideal e;
873  intvec m;
874  e[mu]=0;
875  for(i=1;i<=ncols(e0);i++)
876  {
877    for(j=m0[i];j>=1;j--)
878    {
879      k++;
880      e[k]=e0[i];
881      m[k]=i;
882    }
883  }
884
885  number n,n0;
886  vector v,v0;
887  list F;
888  for(i=ncols(e0);i>=1;i--)
889  {
890    F[i]=module(matrix(0,mu,1));
891  }
892  for(i=mu;i>=1;i--)
893  {
894    v=H0[i];
895    v0=lead(v);
896    n0=leadcoef(e[leadexp(v0)[nvars(basering)+1]])+leadexp(v0)[1];
897    v=v-lead(v);
898    while(v!=0)
899    {
900      n=leadcoef(e[leadexp(v)[nvars(basering)+1]])+leadexp(v)[1];
901      if(n==n0)
902      {
903        v0=v0+lead(v);
904        v=v-lead(v);
905      }
906      else
907      {
908        v=0;
909      }
910    }
911    j=m[leadexp(v0)[nvars(basering)+1]];
912    F[j]=F[j]+v0;
913  }
914
915  dbprint(printlevel-voice+2,"// compute splitting of Hodge filtration");
916  matrix A0=jet(A,0);
917  module U,U0,U1,U2;
918  matrix N;
919  s=0;
920  for(i=size(F);i>=1;i--)
921  {
922    N=A0-e0[i];
923    U0=0;
924    while(size(F[i])>0)
925    {
926      U1=jet(F[i],0);
927      k=0;
928      while(size(U1)>0)
929      {
930        for(j=ncols(U1);j>=1;j--)
931        {
932          if(size(reduce(U1[j],std(U0)))>0)
933          {
934            U0=U0+U1[j];
935          }
936        }
937        U1=N*U1;
938        k++;
939      }
940      F[i]=module(F[i]/var(1));
941    }
942    U=U0+U;
943  }
944
945  dbprint(printlevel-voice+2,"// transform to Hodge splitting basis");
946  H=H*U;
947  H0=lift(U,H0);
948  A=lift(U,A*U);
949
950  return(e,A,H,H0);
951}
952///////////////////////////////////////////////////////////////////////////////
953
954static proc glift(ideal e,matrix A,module H,module H0,int K)
955{
956  poly s=var(1);
957  int mu=ncols(gmsbasis);
958
959  dbprint(printlevel-voice+2,"// compute standard basis of H''");
960  H0=std(H0);
961  H0=simplify(H0,1);
962
963  int i,j,k;
964  ideal v;
965  for(i=mu;i>=1;i--)
966  {
967    v[i]=e[leadexp(H0[i])[nvars(basering)+1]]+leadexp(H0[i])[1];
968  }
969
970  dbprint(printlevel-voice+2,
971    "// compute matrix A0 of t w.r.t. good basis H0 of H''");
972  number c;
973  matrix h0[mu][1];
974  matrix m[mu][1];
975  matrix a0[mu][1];
976  matrix A0[mu][mu];
977  module M=H0;
978  module N=jet(s*A*matrix(H0)+s^2*diff(matrix(H0),s),K+1);
979  while(size(N)>0)
980  {
981    j=mu;
982    for(k=mu-1;k>=1;k--)
983    {
984      if(N[k]>N[j])
985      {
986        j=k;
987      }
988    }
989    i=mu;
990    while(leadexp(M[i])[nvars(basering)+1]!=leadexp(N[j])[nvars(basering)+1])
991    {
992      i--;
993    }
994    k=leadexp(N[j])[1]-leadexp(M[i])[1];
995    if(k==0||i==j)
996    {
997      dbprint(printlevel-voice+3,"// compute A0["+string(i)+","+string(j)+"]");
998      c=leadcoef(N[j])/leadcoef(M[i]);
999      A0[i,j]=A0[i,j]+c*s^k;
1000      N[j]=jet(N[j]-c*s^k*M[i],K+1);
1001    }
1002    else
1003    {
1004      dbprint(printlevel-voice+3,
1005        "// reduce H0["+string(j)+"] with H0["+string(i)+"]");
1006      c=leadcoef(N[j])/leadcoef(M[i])/(1-k-leadcoef(v[i])+leadcoef(v[j]));
1007      H0[j]=H0[j]+c*s^(k-1)*H0[i];
1008      M[j]=M[j]+c*s^(k-1)*M[i];
1009      h0=c*s^(k-1)*H0[i];
1010      N[j]=N[j]+jet(s*A*h0+s^2*diff(h0,s),K+1)[1];
1011      m=M[i];
1012      a0=transpose(A0)[j];
1013      N=N-jet(c*s^(k-1)*m*transpose(a0),K+1);
1014    }
1015  }
1016
1017  H0=H*H0;
1018  H0=H0/var(1)^(mindegree(H0)/deg(var(1)));
1019
1020  return(A0,H0);
1021}
1022///////////////////////////////////////////////////////////////////////////////
1023
1024proc tmatrix(poly t)
1025"USAGE:    tmatrix(t); poly t
1026ASSUME:   characteristic 0; local degree ordering;
1027          isolated critical point 0 of t
1028RETURN:
1029@format
1030list l=A0,A1,T,M;
1031  matrix A0,A1;  t=A0+s*A1+s^2*(d/ds) on H'' w.r.t. C[[s]]-basis M*T
1032  module T;  C-basis of C^mu
1033  ideal M;  monomial C-basis of H''/sH''
1034@end format
1035KEYWORDS: good basis
1036EXAMPLE:  example tmatrix; shows examples
1037"
1038{
1039  def @R=basering;
1040  int n=nvars(@R)-1;
1041  def @G=gmsring(t,"s");
1042  setring(@G);
1043
1044  int mu=ncols(gmsbasis);
1045  matrix A;
1046  module U0;
1047  ideal e;
1048  intvec m;
1049
1050  def A0,r,H,H0,K0=saturate();
1051  e,m,A0,r=eigenval(A0,r,H,K0);
1052  A,A0,r,H,H0,e,m,K0=transform(A,A0,r,H,H0,e,m,K0,K0+int(e[ncols(e)]-e[1]),1);
1053  A,H0=glift(fsplit(e,m,A,H,H0),K0);
1054
1055  A0=jet(A,0);
1056  A=jet(A/var(1),0);
1057
1058  list l=A0,A,H0,gmsbasis;
1059  setring(@R);
1060  list l=imap(@G,l);
1061  kill @G,gmsmaxdeg;
1062
1063  return(l);
1064}
1065example
1066{ "EXAMPLE:"; echo=2;
1067  ring R=0,(x,y),ds;
1068  poly t=x5+x2y2+y5;
1069  list l=tmatrix(t);
1070  print(l[1]);
1071  print(l[2]);
1072  print(l[3]);
1073  print(l[4]);
1074}
1075///////////////////////////////////////////////////////////////////////////////
1076
1077proc endvfilt(list v)
1078"USAGE:   endvfilt(v); list v
1079ASSUME:  v returned by vfilt
1080RETURN:
1081@format
1082list ev;  V-filtration on Jacobian algebra
1083  ideal ev[1];
1084    number ev[1][i];  i-th V-filtration index
1085  intvec ev[2];
1086    int ev[2][i];  i-th multiplicity
1087  list ev[3];
1088    module ev[3][i];  vector space of i-th graded part in terms of ev[4]
1089  ideal ev[4];  monomial vector space basis of Jacobian algebra
1090  ideal ev[5];  standard basis of Jacobian ideal
1091@end format
1092KEYWORDS: V-filtration; endomorphism filtration
1093EXAMPLE:  example endvfilt; shows examples
1094"
1095{
1096  def a,d,V,m,g=v[1..5];
1097  attrib(g,"isSB",1);
1098  int mu=ncols(m);
1099
1100  module V0=V[1];
1101  for(int i=2;i<=size(V);i++)
1102  {
1103    V0=V0,V[i];
1104  }
1105
1106  dbprint(printlevel-voice+2,"// compute multiplication in Jacobian algebra");
1107  list M;
1108  module U=freemodule(ncols(m));
1109  for(i=ncols(m);i>=1;i--)
1110  {
1111    M[i]=division(coeffs(reduce(m[i]*m,g,U),m)*V0,V0)[1];
1112  }
1113
1114  int j,k,i0,j0,i1,j1;
1115  number b0=number(a[1]-a[ncols(a)]);
1116  number b1,b2;
1117  matrix M0;
1118  module L;
1119  list v0=freemodule(ncols(m));
1120  ideal a0=b0;
1121  list l;
1122
1123  while(b0<number(a[ncols(a)]-a[1]))
1124  {
1125    dbprint(printlevel-voice+2,"// find next possible index");
1126    b1=number(a[ncols(a)]-a[1]);
1127    for(j=ncols(a);j>=1;j--)
1128    {
1129      for(i=ncols(a);i>=1;i--)
1130      {
1131        b2=number(a[i]-a[j]);
1132        if(b2>b0&&b2<b1)
1133        {
1134          b1=b2;
1135        }
1136        else
1137        {
1138          if(b2<=b0)
1139          {
1140            i=0;
1141          }
1142        }
1143      }
1144    }
1145    b0=b1;
1146
1147    l=ideal();
1148    for(k=ncols(m);k>=2;k--)
1149    {
1150      l=l+list(ideal());
1151    }
1152
1153    dbprint(printlevel-voice+2,"// collect conditions for EV["+string(b0)+"]");
1154    j=ncols(a);
1155    j0=mu;
1156    while(j>=1)
1157    {
1158      i0=1;
1159      i=1;
1160      while(i<ncols(a)&&a[i]<a[j]+b0)
1161      {
1162        i0=i0+d[i];
1163        i++;
1164      }
1165      if(a[i]<a[j]+b0)
1166      {
1167        i0=i0+d[i];
1168        i++;
1169      }
1170      for(k=1;k<=ncols(m);k++)
1171      {
1172        M0=M[k];
1173        if(i0>1)
1174        {
1175          l[k]=l[k],M0[1..i0-1,j0-d[j]+1..j0];
1176        }
1177      }
1178      j0=j0-d[j];
1179      j--;
1180    }
1181
1182    dbprint(printlevel-voice+2,"// compose condition matrix");
1183    L=transpose(module(l[1]));
1184    for(k=2;k<=ncols(m);k++)
1185    {
1186      L=L,transpose(module(l[k]));
1187    }
1188
1189    dbprint(printlevel-voice+2,"// compute kernel of condition matrix");
1190    v0=v0+list(syz(L));
1191    a0=a0,b0;
1192  }
1193
1194  dbprint(printlevel-voice+2,"// compute graded parts");
1195  option(redSB);
1196  for(i=1;i<size(v0);i++)
1197  {
1198    v0[i+1]=std(v0[i+1]);
1199    v0[i]=std(reduce(v0[i],v0[i+1]));
1200  }
1201  option(noredSB);
1202
1203  dbprint(printlevel-voice+2,"// remove trivial graded parts");
1204  i=1;
1205  while(size(v0[i])==0)
1206  {
1207    i++;
1208  }
1209  list v1=v0[i];
1210  intvec d1=size(v0[i]);
1211  ideal a1=a0[i];
1212  i++;
1213  while(i<=size(v0))
1214  {
1215    if(size(v0[i])>0)
1216    {
1217      v1=v1+list(v0[i]);
1218      d1=d1,size(v0[i]);
1219      a1=a1,a0[i];
1220    }
1221    i++;
1222  }
1223  return(list(a1,d1,v1,m,g));
1224}
1225example
1226{ "EXAMPLE:"; echo=2;
1227  ring R=0,(x,y),ds;
1228  poly t=x5+x2y2+y5;
1229  endvfilt(vfilt(t));
1230}
1231///////////////////////////////////////////////////////////////////////////////
1232
1233proc sppnf(list sp)
1234"USAGE:   sppnf(list(a,w[,m])); ideal a, intvec w, intvec m
1235ASSUME:  ncols(a)==size(w)==size(m)
1236RETURN:  order (a[i][,w[i]]) with multiplicity m[i] lexicographically
1237EXAMPLE: example sppnf; shows examples
1238"
1239{
1240  ideal a=sp[1];
1241  intvec w=sp[2];
1242  int n=ncols(a);
1243  intvec m;
1244  list V;
1245  module v;
1246  int i,j;
1247  for(i=3;i<=size(sp);i++)
1248  {
1249    if(typeof(sp[i])=="intvec")
1250    {
1251      m=sp[i];
1252    }
1253    if(typeof(sp[i])=="module")
1254    {
1255      v=sp[i];
1256      for(j=n;j>=1;j--)
1257      {
1258        V[j]=module(v[j]);
1259      }
1260    }
1261    if(typeof(sp[i])=="list")
1262    {
1263      V=sp[i];
1264    }
1265  }
1266  if(m==0)
1267  {
1268    for(i=n;i>=1;i--)
1269    {
1270      m[i]=1;
1271    }
1272  }
1273
1274  int k;
1275  ideal a0;
1276  intvec w0,m0;
1277  list V0;
1278  number a1;
1279  int w1,m1;
1280  for(i=n;i>=1;i--)
1281  {
1282    if(m[i]!=0)
1283    {
1284      for(j=i-1;j>=1;j--)
1285      {
1286        if(m[j]!=0)
1287        {
1288          if(number(a[i])>number(a[j])||
1289            (number(a[i])==number(a[j])&&w[i]<w[j]))
1290          {
1291            a1=number(a[i]);
1292            a[i]=a[j];
1293            a[j]=a1;
1294            w1=w[i];
1295            w[i]=w[j];
1296            w[j]=w1;
1297            m1=m[i];
1298            m[i]=m[j];
1299            m[j]=m1;
1300            if(size(V)>0)
1301            {
1302              v=V[i];
1303              V[i]=V[j];
1304              V[j]=v;
1305            }
1306          }
1307          if(number(a[i])==number(a[j])&&w[i]==w[j])
1308          {
1309            m[i]=m[i]+m[j];
1310            m[j]=0;
1311            if(size(V)>0)
1312            {
1313              V[i]=V[i]+V[j];
1314            }
1315          }
1316        }
1317      }
1318      k++;
1319      a0[k]=a[i];
1320      w0[k]=w[i];
1321      m0[k]=m[i];
1322      if(size(V)>0)
1323      {
1324        V0[k]=V[i];
1325      }
1326    }
1327  }
1328
1329  if(size(V0)>0)
1330  {
1331    n=size(V0);
1332    module U=std(V0[n]);
1333    for(i=n-1;i>=1;i--)
1334    {
1335      V0[i]=simplify(reduce(V0[i],U),1);
1336      if(i>=2)
1337      {
1338        U=std(U+V0[i]);
1339      }
1340    }
1341  }
1342
1343  if(k>0)
1344  {
1345    sp=a0,w0,m0;
1346    if(size(V0)>0)
1347    {
1348      sp[4]=V0;
1349    }
1350  }
1351  return(sp);
1352}
1353example
1354{ "EXAMPLE:"; echo=2;
1355  ring R=0,(x,y),ds;
1356  list sp=list(ideal(-1/2,-3/10,-3/10,-1/10,-1/10,0,1/10,1/10,3/10,3/10,1/2),
1357    intvec(2,1,1,1,1,1,1,1,1,1,0));
1358  sppprint(sppnf(sp));
1359}
1360///////////////////////////////////////////////////////////////////////////////
1361
1362proc sppprint(list spp)
1363"USAGE:   sppprint(spp); list spp
1364RETURN:  string s;  spectral pairs spp
1365EXAMPLE: example sppprint; shows examples
1366"
1367{
1368  string s;
1369  for(int i=1;i<size(spp[3]);i++)
1370  {
1371    s=s+"(("+string(spp[1][i])+","+string(spp[2][i])+"),"
1372      +string(spp[3][i])+"),";
1373  }
1374  s=s+"(("+string(spp[1][i])+","+string(spp[2][i])+"),"+string(spp[3][i])+")";
1375  return(s);
1376}
1377example
1378{ "EXAMPLE:"; echo=2;
1379  ring R=0,(x,y),ds;
1380  list spp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(2,1,1,1,1,1,0),
1381    intvec(1,2,2,1,2,2,1));
1382  sppprint(spp);
1383}
1384///////////////////////////////////////////////////////////////////////////////
1385
1386proc spadd(list sp1,list sp2)
1387"USAGE:   spadd(sp1,sp2); list sp1, list sp2
1388RETURN:  list sp;  sum of spectra sp1 and sp2
1389EXAMPLE: example spadd; shows examples
1390"
1391{
1392  ideal s;
1393  intvec m;
1394  int i,i1,i2=1,1,1;
1395  while(i1<=size(sp1[2])||i2<=size(sp2[2]))
1396  {
1397    if(i1<=size(sp1[2]))
1398    {
1399      if(i2<=size(sp2[2]))
1400      {
1401        if(number(sp1[1][i1])<number(sp2[1][i2]))
1402        {
1403          s[i]=sp1[1][i1];
1404          m[i]=sp1[2][i1];
1405          i++;
1406          i1++;
1407        }
1408        else
1409        {
1410          if(number(sp1[1][i1])>number(sp2[1][i2]))
1411          {
1412            s[i]=sp2[1][i2];
1413            m[i]=sp2[2][i2];
1414            i++;
1415            i2++;
1416          }
1417          else
1418          {
1419            if(sp1[2][i1]+sp2[2][i2]!=0)
1420            {
1421              s[i]=sp1[1][i1];
1422              m[i]=sp1[2][i1]+sp2[2][i2];
1423              i++;
1424            }
1425            i1++;
1426            i2++;
1427          }
1428        }
1429      }
1430      else
1431      {
1432        s[i]=sp1[1][i1];
1433        m[i]=sp1[2][i1];
1434        i++;
1435        i1++;
1436      }
1437    }
1438    else
1439    {
1440      s[i]=sp2[1][i2];
1441      m[i]=sp2[2][i2];
1442      i++;
1443      i2++;
1444    }
1445  }
1446  return(list(s,m));
1447}
1448example
1449{ "EXAMPLE:"; echo=2;
1450  ring R=0,(x,y),ds;
1451  list sp1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1452  spprint(sp1);
1453  list sp2=list(ideal(-1/6,1/6),intvec(1,1));
1454  spprint(sp2);
1455  spprint(spadd(sp1,sp2));
1456}
1457///////////////////////////////////////////////////////////////////////////////
1458
1459proc spsub(list sp1,list sp2)
1460"USAGE:   spsub(sp1,sp2); list sp1, list sp2
1461RETURN:  list sp;  difference of spectra sp1 and sp2
1462EXAMPLE: example spsub; shows examples
1463"
1464{
1465  return(spadd(sp1,spmul(sp2,-1)));
1466}
1467example
1468{ "EXAMPLE:"; echo=2;
1469  ring R=0,(x,y),ds;
1470  list sp1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1471  spprint(sp1);
1472  list sp2=list(ideal(-1/6,1/6),intvec(1,1));
1473  spprint(sp2);
1474  spprint(spsub(sp1,sp2));
1475}
1476///////////////////////////////////////////////////////////////////////////////
1477
1478proc spmul(list #)
1479"USAGE:   spmul(sp0,k); list sp0, int[vec] k
1480RETURN:  list sp;  linear combination of spectra sp0 with coefficients k
1481EXAMPLE: example spmul; shows examples
1482"
1483{
1484  if(size(#)==2)
1485  {
1486    if(typeof(#[1])=="list")
1487    {
1488      if(typeof(#[2])=="int")
1489      {
1490        return(list(#[1][1],#[1][2]*#[2]));
1491      }
1492      if(typeof(#[2])=="intvec")
1493      {
1494        list sp0=list(ideal(),intvec(0));
1495        for(int i=size(#[2]);i>=1;i--)
1496        {
1497          sp0=spadd(sp0,spmul(#[1][i],#[2][i]));
1498        }
1499        return(sp0);
1500      }
1501    }
1502  }
1503  return(list(ideal(),intvec(0)));
1504}
1505example
1506{ "EXAMPLE:"; echo=2;
1507  ring R=0,(x,y),ds;
1508  list sp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1509  spprint(sp);
1510  spprint(spmul(sp,2));
1511  list sp1=list(ideal(-1/6,1/6),intvec(1,1));
1512  spprint(sp1);
1513  list sp2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1514  spprint(sp2);
1515  spprint(spmul(list(sp1,sp2),intvec(1,2)));
1516}
1517///////////////////////////////////////////////////////////////////////////////
1518
1519proc spissemicont(list sp,list #)
1520"USAGE:   spissemicont(sp[,1]); list sp, int opt
1521RETURN:
1522@format
1523int k=
1524  1;  if sum of sp is positive on all intervals [a,a+1) [and (a,a+1)]
1525  0;  if sum of sp is negative on some interval [a,a+1) [or (a,a+1)]
1526@end format
1527EXAMPLE: example spissemicont; shows examples
1528"
1529{
1530  int opt=0;
1531  if(size(#)>0)
1532  {
1533    if(typeof(#[1])=="int")
1534    {
1535      opt=1;
1536    }
1537  }
1538  int i,j,k;
1539  i=1;
1540  while(i<=size(sp[2])-1)
1541  {
1542    j=i+1;
1543    k=0;
1544    while(j+1<=size(sp[2])&&number(sp[1][j])<=number(sp[1][i])+1)
1545    {
1546      if(opt==0||number(sp[1][j])<number(sp[1][i])+1)
1547      {
1548        k=k+sp[2][j];
1549      }
1550      j++;
1551    }
1552    if(j==size(sp[2])&&number(sp[1][j])<=number(sp[1][i])+1)
1553    {
1554      if(opt==0||number(sp[1][j])<number(sp[1][i])+1)
1555      {
1556        k=k+sp[2][j];
1557      }
1558    }
1559    if(k<0)
1560    {
1561      return(0);
1562    }
1563    i++;
1564  }
1565  return(1);
1566}
1567example
1568{ "EXAMPLE:"; echo=2;
1569  ring R=0,(x,y),ds;
1570  list sp1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1571  spprint(sp1);
1572  list sp2=list(ideal(-1/6,1/6),intvec(1,1));
1573  spprint(sp2);
1574  spissemicont(spsub(sp1,spmul(sp2,3)));
1575  spissemicont(spsub(sp1,spmul(sp2,4)));
1576}
1577///////////////////////////////////////////////////////////////////////////////
1578
1579proc spsemicont(list sp0,list sp,list #)
1580"USAGE:   spsemicont(sp0,sp,k[,1]); list sp0, list sp
1581RETURN:
1582@format
1583list l;
1584  intvec l[i];  if the spectra sp0 occur with multiplicities k
1585                in a deformation of a [quasihomogeneous] singularity
1586                with spectrum sp then k<=l[i]
1587@end format
1588EXAMPLE: example spsemicont; shows examples
1589"
1590{
1591  list l,l0;
1592  int i,j,k;
1593  while(spissemicont(sp0,#))
1594  {
1595    if(size(sp)>1)
1596    {
1597      l0=spsemicont(sp0,list(sp[1..size(sp)-1]));
1598      for(i=1;i<=size(l0);i++)
1599      {
1600        if(size(l)>0)
1601        {
1602          j=1;
1603          while(j<size(l)&&l[j]!=l0[i])
1604          {
1605            j++;
1606          }
1607          if(l[j]==l0[i])
1608          {
1609            l[j][size(sp)]=k;
1610          }
1611          else
1612          {
1613            l0[i][size(sp)]=k;
1614            l=l+list(l0[i]);
1615          }
1616        }
1617        else
1618        {
1619          l=l0;
1620        }
1621      }
1622    }
1623    sp0=spsub(sp0,sp[size(sp)]);
1624    k++;
1625  }
1626  if(size(sp)>1)
1627  {
1628    return(l);
1629  }
1630  else
1631  {
1632    return(list(intvec(k-1)));
1633  }
1634}
1635example
1636{ "EXAMPLE:"; echo=2;
1637  ring R=0,(x,y),ds;
1638  list sp0=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1639  spprint(sp0);
1640  list sp1=list(ideal(-1/6,1/6),intvec(1,1));
1641  spprint(sp1);
1642  list sp2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1643  spprint(sp2);
1644  list sp=sp1,sp2;
1645  list l=spsemicont(sp0,sp);
1646  l;
1647  spissemicont(spsub(sp0,spmul(sp,l[1])));
1648  spissemicont(spsub(sp0,spmul(sp,l[1]-1)));
1649  spissemicont(spsub(sp0,spmul(sp,l[1]+1)));
1650}
1651///////////////////////////////////////////////////////////////////////////////
1652
1653proc spmilnor(list sp)
1654"USAGE:   spmilnor(sp); list sp
1655RETURN:  int mu;  Milnor number of spectrum sp
1656EXAMPLE: example spmilnor; shows examples
1657"
1658{
1659  return(sum(sp[2]));
1660}
1661example
1662{ "EXAMPLE:"; echo=2;
1663  ring R=0,(x,y),ds;
1664  list sp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1665  spprint(sp);
1666  spmilnor(sp);
1667}
1668///////////////////////////////////////////////////////////////////////////////
1669
1670proc spgeomgenus(list sp)
1671"USAGE:   spgeomgenus(sp); list sp
1672RETURN:  int g;  geometrical genus of spectrum sp
1673EXAMPLE: example spgeomgenus; shows examples
1674"
1675{
1676  int g=0;
1677  int i=1;
1678  while(i+1<=size(sp[2])&&number(sp[1][i])<=number(0))
1679  {
1680    g=g+sp[2][i];
1681    i++;
1682  }
1683  if(i==size(sp[2])&&number(sp[1][i])<=number(0))
1684  {
1685    g=g+sp[2][i];
1686  }
1687  return(g);
1688}
1689example
1690{ "EXAMPLE:"; echo=2;
1691  ring R=0,(x,y),ds;
1692  list sp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1693  spprint(sp);
1694  spgeomgenus(sp);
1695}
1696///////////////////////////////////////////////////////////////////////////////
1697
1698proc spgamma(list sp)
1699"USAGE:   spgamma(sp); list sp
1700RETURN:  number gamma;  gamma invariant of spectrum sp
1701EXAMPLE: example spgamma; shows examples
1702"
1703{
1704  int i,j;
1705  number g=0;
1706  for(i=1;i<=ncols(sp[1]);i++)
1707  {
1708    for(j=1;j<=sp[2][i];j++)
1709    {
1710      g=g+(number(sp[1][i])-number(nvars(basering)-2)/2)^2;
1711    }
1712  }
1713  g=-g/4+sum(sp[2])*number(sp[1][ncols(sp[1])]-sp[1][1])/48;
1714  return(g);
1715}
1716example
1717{ "EXAMPLE:"; echo=2;
1718  ring R=0,(x,y),ds;
1719  list sp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1720  spprint(sp);
1721  spgamma(sp);
1722}
1723///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.