source: git/Singular/LIB/gaussman.lib @ 779ee3

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