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

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