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

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