source: git/Singular/LIB/gmssing.lib

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