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

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