source: git/Singular/LIB/gmssing.lib @ 5c5638

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