source: git/Singular/LIB/gaussman.lib @ fee17e

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