source: git/Singular/LIB/gaussman.lib @ 7b55a0

fieker-DuValspielwiese
Last change on this file since 7b55a0 was 7b55a0, checked in by Mathias Schulze <mschulze@…>, 22 years ago
gaussman.lib git-svn-id: file:///usr/local/Singular/svn/trunk@6216 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 39.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: gaussman.lib,v 1.87 2002-07-23 16:39:15 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  dbprint(printlevel-voice+2,"// compute saturation of H''");
376  while(size(reduce(H,std(H0*var(1))))>0)
377  {
378    dbprint(printlevel-voice+2,"// compute matrix A of t");
379    k++;
380    dbprint(printlevel-voice+2,"// k="+string(k));
381    l=gmscoeffs(r,k);
382    C,r=l[1..2];
383    A0=A0+C;
384
385    dbprint(printlevel-voice+2,"// compute saturation step");
386    H0=H;
387    H1=jet(module(A0*H1+var(1)^2*diff(matrix(H1),var(1))),k);
388    H=H*var(1)+H1;
389  }
390
391  A0=A0-k*var(1);
392  dbprint(printlevel-voice+2,"// compute basis of saturation of H''");
393  H=std(H0);
394
395  dbprint(printlevel-voice+2,"// transform H'' to saturation of H''");
396  H0=division(freemodule(mu)*var(1)^k,H,k*deg(var(1)))[1];
397
398  return(A0,r,H,H0,k);
399}
400///////////////////////////////////////////////////////////////////////////////
401
402static proc tjet(matrix A0,ideal r,module H,int k0,int K)
403{
404  dbprint(printlevel-voice+2,"// compute matrix A of t");
405  dbprint(printlevel-voice+2,"// k="+string(K+k0+1));
406  list l=gmscoeffs(r,K+k0+1);
407  matrix C;
408  C,r=l[1..2];
409  A0=A0+C;
410  dbprint(printlevel-voice+2,"// transform A to saturation of H''");
411  matrix A=division(A0*H+var(1)^2*diff(matrix(H),var(1)),H,
412    (K+1)*deg(var(1)))[1]/var(1);
413  return(A,A0,r);
414}
415///////////////////////////////////////////////////////////////////////////////
416
417static proc eigenval(matrix A0,ideal r,module H,int k0)
418{
419  dbprint(printlevel-voice+2,
420    "// compute eigenvalues e with multiplicities m of A1");
421  matrix A;
422  A,A0,r=tjet(A0,r,H,k0,0);
423  list l=eigenvals(A);
424  def e,m=l[1..2];
425  dbprint(printlevel-voice+2,"// e="+string(e));
426  dbprint(printlevel-voice+2,"// m="+string(m));
427  return(e,m,A0,r);
428}
429///////////////////////////////////////////////////////////////////////////////
430
431static proc transform(matrix A,matrix A0,ideal r,module H,module H0,ideal e,
432  intvec m,int k0,int K,int opt)
433{
434  int mu=ncols(gmsbasis);
435
436  number e0,e1=nmin(e),nmax(e);
437
438  int i,j,k;
439  intvec d;
440  d[ncols(e)]=0;
441  if(opt)
442  {
443    dbprint(printlevel-voice+2,
444      "// compute rounded 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+k);
484  module U0=var(1)^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 maximum of d by 1");
507      for(i0,i=1,1;i0<=ncols(e);i0++)
508      {
509        for(i1=1;i1<=m[i0];i1,i=i1+1,i+1)
510        {
511          for(j0,j=1,1;j0<=ncols(e);j0++)
512          {
513            for(j1=1;j1<=m[j0];j1,j=j1+1,j+1)
514            {
515              if(d[i0]==0&&d[j0]>0)
516              {
517                A[i,j]=A[i,j]/var(1);
518              }
519              if(d[i0]>0&&d[j0]==0)
520              {
521                A[i,j]=A[i,j]*var(1);
522              }
523            }
524          }
525        }
526      }
527
528      H0=transpose(H0);
529      for(i0,i=1,1;i0<=ncols(e);i0++)
530      {
531        if(d[i0]>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]*var(1);
537            U0[i]=U0[i]/var(1);
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  kill r;
587  ideal r;
588  for(int i,j=1,1;i<=ncols(e);i++)
589  {
590    if(e[i]!=1)
591    {
592      r[j]=-e[i];
593      j++;
594    }
595  }
596
597  setring(R);
598  ideal r=imap(G,r);
599  kill G,gmsmaxdeg;
600
601  return(r);
602}
603example
604{ "EXAMPLE:"; echo=2;
605  ring R=0,(x,y),ds;
606  poly t=x5+x2y2+y5;
607  bernstein(t);
608}
609///////////////////////////////////////////////////////////////////////////////
610
611proc monodromy(poly t)
612"USAGE:    monodromy(t); poly t
613ASSUME:   characteristic 0; local degree ordering;
614          isolated critical point 0 of t
615RETURN:
616@format
617list l;  Jordan data jordan(M) of monodromy matrix exp(-2*pi*i*M)
618  ideal l[1];
619    number l[1][i];  eigenvalue of i-th Jordan block of M
620  intvec l[2];
621    int l[2][i];  size of i-th Jordan block of M
622  intvec l[3];
623    int l[3][i];  multiplicity of i-th Jordan block of M
624@end format
625SEE ALSO: mondromy_lib, linalg_lib
626KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice; monodromy
627EXAMPLE:  example monodromy; shows examples
628"
629{
630  def R=basering;
631  int n=nvars(R)-1;
632  def G=gmsring(t,"s");
633  setring(G);
634
635  matrix A;
636  module U0;
637  ideal e;
638  intvec m;
639
640  def A0,r,H,H0,k0=saturate();
641  e,m,A0,r=eigenval(A0,r,H,k0);
642  A,A0,r,H0,U0,e,m=transform(A,A0,r,H,H0,e,m,k0,0,0);
643
644  list l=jordan(A,e,m);
645  setring(R);
646  list l=imap(G,l);
647  kill G,gmsmaxdeg;
648
649  return(l);
650}
651example
652{ "EXAMPLE:"; echo=2;
653  ring R=0,(x,y),ds;
654  poly t=x5+x2y2+y5;
655  monodromy(t);
656}
657///////////////////////////////////////////////////////////////////////////////
658
659proc spectrum(poly t)
660"USAGE:    spectrum(t); poly t
661ASSUME:   characteristic 0; local degree ordering;
662          isolated critical point 0 of t
663RETURN:
664@format
665list sp;  singularity spectrum of t
666  ideal sp[1];
667    number sp[1][i];  i-th spectral number
668  intvec sp[2];
669    int sp[2][i];  multiplicity of i-th spectral number
670@end format
671SEE ALSO: spectrum_lib
672KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
673          mixed Hodge structure; V-filtration; spectrum
674EXAMPLE:  example spectrum; shows examples
675"
676{
677  list l=vwfilt(t);
678  return(spnf(l[1],l[3]));
679}
680example
681{ "EXAMPLE:"; echo=2;
682  ring R=0,(x,y),ds;
683  poly t=x5+x2y2+y5;
684  spprint(spectrum(t));
685}
686///////////////////////////////////////////////////////////////////////////////
687
688proc sppairs(poly t)
689"USAGE:    sppairs(t); poly t
690ASSUME:   characteristic 0; local degree ordering;
691          isolated critical point 0 of t
692RETURN:
693@format
694list spp;  spectral pairs of t
695  ideal spp[1];
696    number spp[1][i];  V-filtration index of i-th spectral pair
697  intvec spp[2];
698    int spp[2][i];  weight filtration index of i-th spectral pair
699  intvec spp[3];
700    int spp[3][i];  multiplicity of i-th spectral pair
701@end format
702SEE ALSO: spectrum_lib
703KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
704          mixed Hodge structure; V-filtration; weight filtration;
705          spectrum; spectral pairs
706EXAMPLE:  example sppairs; shows examples
707"
708{
709  list l=vwfilt(t);
710  return(list(l[1],l[2],l[3]));
711}
712example
713{ "EXAMPLE:"; echo=2;
714  ring R=0,(x,y),ds;
715  poly t=x5+x2y2+y5;
716  sppprint(sppairs(t));
717}
718///////////////////////////////////////////////////////////////////////////////
719
720proc spnf(ideal a,list #)
721"USAGE:   spnf(a[,m][,V]); ideal a, intvec m, list V
722ASSUME:  ncols(a)==size(m)==size(V); typeof(V[i])=="int"
723RETURN:  order (a[i][,V[i]]) with multiplicity m[i] lexicographically
724EXAMPLE: example spnf; shows examples
725"
726{
727  int n=ncols(a);
728  intvec m;
729  module v;
730  list V;
731  int i,j;
732  while(i<size(#))
733  {
734    i++;
735    if(typeof(#[i])=="intvec")
736    {
737      m=#[i];
738    }
739    if(typeof(#[i])=="module")
740    {
741      v=#[i];
742      for(j=n;j>=1;j--)
743      {
744        V[j]=module(v[j]);
745      }
746    }
747    if(typeof(#[i])=="list")
748    {
749      V=#[i];
750    }
751  }
752  if(m==0)
753  {
754    for(i=n;i>=1;i--)
755    {
756      m[i]=1;
757    }
758  }
759
760  int k;
761  ideal a0;
762  intvec m0;
763  list V0;
764  number a1;
765  int m1;
766  for(i=n;i>=1;i--)
767  {
768    if(m[i]!=0)
769    {
770      for(j=i-1;j>=1;j--)
771      {
772        if(m[j]!=0)
773        {
774          if(number(a[i])>number(a[j]))
775          {
776            a1=number(a[i]);
777            a[i]=a[j];
778            a[j]=a1;
779            m1=m[i];
780            m[i]=m[j];
781            m[j]=m1;
782            if(size(V)>0)
783            {
784              v=V[i];
785              V[i]=V[j];
786              V[j]=v;
787            }
788          }
789          if(number(a[i])==number(a[j]))
790          {
791            m[i]=m[i]+m[j];
792            m[j]=0;
793            if(size(V)>0)
794            {
795              V[i]=V[i]+V[j];
796            }
797          }
798        }
799      }
800      k++;
801      a0[k]=a[i];
802      m0[k]=m[i];
803      if(size(V)>0)
804      {
805        V0[k]=V[i];
806      }
807    }
808  }
809
810  if(size(V0)>0)
811  {
812    n=size(V0);
813    module U=std(V0[n]);
814    for(i=n-1;i>=1;i--)
815    {
816      V0[i]=simplify(reduce(V0[i],U),1);
817      if(i>=2)
818      {
819        U=std(U+V0[i]);
820      }
821    }
822  }
823
824  list l;
825  if(k>0)
826  {
827    l=a0,m0;
828    if(size(V0)>0)
829    {
830      l[3]=V0;
831    }
832  }
833  return(l);
834}
835example
836{ "EXAMPLE:"; echo=2;
837}
838///////////////////////////////////////////////////////////////////////////////
839
840proc sppnf(ideal a,intvec w,list #)
841"USAGE:   sppnf(a,w[,m][,V]); ideal a, intvec w, intvec m, list V
842ASSUME:  ncols(e)=size(w)=size(m)=size(V); typeof(V[i])=="module"
843RETURN:  order (a[i][,w[i]][,V[i]]) with multiplicity m[i] lexicographically
844EXAMPLE: example sppnorm; shows examples
845"
846{
847  int n=ncols(a);
848  intvec m;
849  module v;
850  list V;
851  int i,j;
852  while(i<size(#))
853  {
854    i++;
855    if(typeof(#[i])=="intvec")
856    {
857      m=#[i];
858    }
859    if(typeof(#[i])=="module")
860    {
861      v=#[i];
862      for(j=n;j>=1;j--)
863      {
864        V[j]=module(v[j]);
865      }
866    }
867    if(typeof(#[i])=="list")
868    {
869      V=#[i];
870    }
871  }
872  if(m==0)
873  {
874    for(i=n;i>=1;i--)
875    {
876      m[i]=1;
877    }
878  }
879
880  int k;
881  ideal a0;
882  intvec w0,m0;
883  list V0;
884  number a1;
885  int w1,m1;
886  for(i=n;i>=1;i--)
887  {
888    if(m[i]!=0)
889    {
890      for(j=i-1;j>=1;j--)
891      {
892        if(m[j]!=0)
893        {
894          if(number(a[i])>number(a[j])||
895            (number(a[i])==number(a[j])&&w[i]<w[j]))
896          {
897            a1=number(a[i]);
898            a[i]=a[j];
899            a[j]=a1;
900            w1=w[i];
901            w[i]=w[j];
902            w[j]=w1;
903            m1=m[i];
904            m[i]=m[j];
905            m[j]=m1;
906            if(size(V)>0)
907            {
908              v=V[i];
909              V[i]=V[j];
910              V[j]=v;
911            }
912          }
913          if(number(a[i])==number(a[j])&&w[i]==w[j])
914          {
915            m[i]=m[i]+m[j];
916            m[j]=0;
917            if(size(V)>0)
918            {
919              V[i]=V[i]+V[j];
920            }
921          }
922        }
923      }
924      k++;
925      a0[k]=a[i];
926      w0[k]=w[i];
927      m0[k]=m[i];
928      if(size(V)>0)
929      {
930        V0[k]=V[i];
931      }
932    }
933  }
934
935  if(size(V0)>0)
936  {
937    n=size(V0);
938    module U=std(V0[n]);
939    for(i=n-1;i>=1;i--)
940    {
941      V0[i]=simplify(reduce(V0[i],U),1);
942      if(i>=2)
943      {
944        U=std(U+V0[i]);
945      }
946    }
947  }
948
949  list l;
950  if(k>0)
951  {
952    l=a0,w0,m0;
953    if(size(V0)>0)
954    {
955      l[4]=V0;
956    }
957  }
958  return(l);
959}
960example
961{ "EXAMPLE:"; echo=2;
962}
963///////////////////////////////////////////////////////////////////////////////
964
965proc vfilt(poly t)
966"USAGE:    vfilt(t); poly t
967ASSUME:   characteristic 0; local degree ordering;
968          isolated critical point 0 of t
969RETURN:
970@format
971list v;  V-filtration on H''/s*H''
972  ideal v[1];
973    number v[1][i];  V-filtration index of i-th spectral number
974  intvec v[2];
975    int v[2][i];  multiplicity of i-th spectral number
976  list v[3];
977    module v[3][i];  vector space of i-th graded part in terms of v[4]
978  ideal v[4];  monomial vector space basis of H''/s*H''
979  ideal v[5];  standard basis of Jacobian ideal
980@end format
981SEE ALSO: spectrum_lib
982KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
983          mixed Hodge structure; V-filtration; spectrum
984EXAMPLE:  example vfilt; shows examples
985"
986{
987  list l=vwfilt(t);
988  return(spnf(l[1],l[3],l[4])+list(l[5],l[6]));
989}
990example
991{ "EXAMPLE:"; echo=2;
992  ring R=0,(x,y),ds;
993  poly t=x5+x2y2+y5;
994  vfilt(t);
995}
996///////////////////////////////////////////////////////////////////////////////
997
998proc vwfilt(poly t)
999"USAGE:    vwfilt(t); poly t
1000ASSUME:   characteristic 0; local degree ordering;
1001          isolated critical point 0 of t
1002RETURN:
1003@format
1004list vw;  weighted V-filtration on H''/s*H''
1005  ideal vw[1];
1006    number vw[1][i];  V-filtration index of i-th spectral pair
1007  intvec vw[2];
1008    int vw[2][i];  weight filtration index of i-th spectral pair
1009  intvec vw[3];
1010    int vw[3][i];  multiplicity of i-th spectral pair
1011  list vw[4];
1012    module vw[4][i];  vector space of i-th graded part in terms of vw[5]
1013  ideal vw[5];  monomial vector space basis of H''/s*H''
1014  ideal vw[6];  standard basis of Jacobian ideal
1015@end format
1016SEE ALSO: spectrum_lib
1017KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
1018          mixed Hodge structure; V-filtration; weight filtration;
1019          spectrum; spectral pairs
1020EXAMPLE:  example vwfilt; shows examples
1021"
1022{
1023  def R=basering;
1024  int n=nvars(R)-1;
1025  def G=gmsring(t,"s");
1026  setring(G);
1027
1028  int mu=ncols(gmsbasis);
1029  matrix A;
1030  module U0;
1031  ideal e;
1032  intvec m;
1033
1034  def A0,r,H,H0,k0=saturate();
1035  e,m,A0,r=eigenval(A0,r,H,k0);
1036  A,A0,r,H0,U0,e,m=transform(A,A0,r,H,H0,e,m,k0,0,1);
1037
1038  dbprint(printlevel-voice+2,"// compute weight filtration basis");
1039  list l=jordanbasis(A,e,m);
1040  def U,v=l[1..2];
1041  kill l;
1042  vector u0;
1043  int v0;
1044  int i,j,k,l;
1045  for(k,l=1,1;l<=ncols(e);k,l=k+m[l],l+1)
1046  {
1047    for(i=k+m[l]-1;i>=k+1;i--)
1048    {
1049      for(j=i-1;j>=k;j--)
1050      {
1051        if(v[i]>v[j])
1052        {
1053          v0=v[i];v[i]=v[j];v[j]=v0;
1054          u0=U[i];U[i]=U[j];U[j]=u0;
1055        }
1056      }
1057    }
1058  }
1059
1060  dbprint(printlevel-voice+2,"// transform to weight filtration basis");
1061  matrix V=inverse(U);
1062  A=V*A*U;
1063  dbprint(printlevel-voice+2,"// compute standard basis of H''");
1064  H0=std(V*H0);
1065  U0=U0*U;
1066
1067  dbprint(printlevel-voice+2,"// compute spectral pairs");
1068  ideal a;
1069  intvec w;
1070  for(i=1;i<=mu;i++)
1071  {
1072    j=leadexp(H0[i])[nvars(basering)+1];
1073    a[i]=A[j,j]+ord(H0[i])/deg(var(1))-1;
1074    w[i]=v[j]+n;
1075  }
1076  kill v;
1077  module v=simplify(jet(H*U0*H0,2*k0)/var(1)^(2*k0),1);
1078
1079  kill l;
1080  list l=sppnf(a,w,v)+list(gmsbasis,gmsstd);
1081  setring(R);
1082  list l=imap(G,l);
1083  kill G,gmsmaxdeg;
1084  attrib(l[5],"isSB",1);
1085
1086  return(l);
1087}
1088example
1089{ "EXAMPLE:"; echo=2;
1090  ring R=0,(x,y),ds;
1091  poly t=x5+x2y2+y5;
1092  vwfilt(t);
1093}
1094///////////////////////////////////////////////////////////////////////////////
1095
1096static proc commutator(matrix A)
1097{
1098  int n=ncols(A);
1099  int i,j,k;
1100  matrix C[n^2][n^2];
1101  for(i=0;i<n;i++)
1102  {
1103    for(j=0;j<n;j++)
1104    {
1105      for(k=0;k<n;k++)
1106      {
1107        C[i*n+j+1,k*n+j+1]=C[i*n+j+1,k*n+j+1]+A[i+1,k+1];
1108        C[i*n+j+1,i*n+k+1]=C[i*n+j+1,i*n+k+1]-A[k+1,j+1];
1109      }
1110    }
1111  }
1112  return(C);
1113}
1114
1115///////////////////////////////////////////////////////////////////////////////
1116
1117proc tmatrix(poly t,list #)
1118"USAGE:    tmatrix(t); poly t
1119ASSUME:   characteristic 0; local degree ordering;
1120          isolated critical point 0 of t
1121RETURN:
1122@format
1123list l=A0,A1,T,M;
1124  matrix A0,A1;  t=A0+s*A1+s^2*(d/ds) on H'' w.r.t. C[[s]]-basis M*T
1125  module T;  C-basis of C^mu
1126  ideal M;  monomial C-basis of H''/sH''
1127@end format
1128KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
1129          mixed Hodge structure; opposite Hodge filtration; V-filtration
1130EXAMPLE:  example tmatrix; shows examples
1131"
1132{
1133  def R=basering;
1134  int n=nvars(R)-1;
1135  def G=gmsring(t,"s");
1136  setring(G);
1137
1138  int mu=ncols(gmsbasis);
1139  matrix A;
1140  module U0;
1141  ideal e;
1142  intvec m;
1143
1144  def A0,r,H,H0,k0=saturate();
1145  e,m,A0,r=eigenval(A0,r,H,k0);
1146  int k1=int(nmax(e)-nmin(e));
1147  A,A0,r,H0,U0,e,m=transform(A,A0,r,H,H0,e,m,k0,k0+k1,1);
1148  module T=H*U0;
1149
1150  ring S=0,s,(ds,c);
1151  matrix A=imap(G,A);
1152  module H0=imap(G,H0);
1153  module T=imap(G,T);
1154  ideal e=imap(G,e);
1155
1156  dbprint(printlevel-voice+2,"// transform to Jordan basis");
1157  module U=jordanbasis(A,e,m)[1];
1158  matrix V=inverse(U);
1159  A=V*A*U;
1160  module H=V*H0;
1161  T=T*U;
1162
1163  dbprint(printlevel-voice+2,"// compute splitting of V-filtration");
1164  int i,j,k;
1165  U=freemodule(mu);
1166  V=matrix(0,mu,mu);
1167  matrix v[mu^2][1];
1168  matrix A0=commutator(jet(A,0));
1169  for(k=1;k<=k0+k1;k++)
1170  {
1171    for(j=0;j<k;j++)
1172    {
1173      V=matrix(V)-(jet(A,k-j)/var(1)^(k-j))*(jet(U,j)/var(1)^j);
1174    }
1175    v=V[1..mu,1..mu];
1176    v=inverse(A0+k)*v;
1177    V=v[1..mu^2,1];
1178    U=matrix(U)+var(1)^k*V;
1179  }
1180  attrib(U,"isSB",1);
1181
1182  dbprint(printlevel-voice+2,"// transform to V-splitting basis");
1183  A=jet(A,0);
1184  H=std(division(H,U,(k0+k1)*deg(var(1)))[1]);
1185  T=T*U;
1186
1187  dbprint(printlevel-voice+2,"// compute V-leading terms of H''");
1188  int i0,j0;
1189  module H1=H;
1190  for(k=ncols(H1);k>=1;k--)
1191  {
1192    i0=leadexp(H1[k])[nvars(basering)+1];
1193    j0=ord(H1[k]);
1194    H0[k]=lead(H1[k]);
1195    H1[k]=H1[k]-lead(H1[k]);
1196    if(H1[k]!=0)
1197    {
1198      i=leadexp(H1[k])[nvars(basering)+1];
1199      j=ord(H1[k]);
1200      while(A[i,i]+j==A[i0,i0]+j0)
1201      {
1202        H0[k]=H0[k]+lead(H1[k]);
1203        H1[k]=H1[k]-lead(H1[k]);
1204        i=leadexp(H1[k])[nvars(basering)+1];
1205        j=ord(H1[k]);
1206      }
1207    }
1208  }
1209  H0=simplify(H0,1);
1210
1211  dbprint(printlevel-voice+2,"// compute N");
1212  matrix N=A;
1213  for(i=1;i<=ncols(N);i++)
1214  {
1215    N[i,i]=0;
1216  }
1217
1218  dbprint(printlevel-voice+2,"// compute splitting of Hodge filtration");
1219  U=0;
1220  module U1;
1221  module C;
1222  list F,I;
1223  module F0,I0,U0;
1224  for(i0,j0=1,1;i0<=ncols(e);i0++)
1225  {
1226    C=matrix(0,mu,1);
1227    for(j=m[i0];j>=1;j,j0=j-1,j0+1)
1228    {
1229      C=C+gen(j0);
1230    }
1231    F0=intersect(C,H0);
1232
1233    F=list();
1234    j=0;
1235    while(size(F0)>0)
1236    {
1237      j++;
1238      F[j]=matrix(0,mu,1);
1239      if(size(jet(F0,0))>0)
1240      {
1241        for(i=ncols(F0);i>=1;i--)
1242        {
1243          if(ord(F0[i])==0)
1244          {
1245            F[j]=F[j]+F0[i];
1246          }
1247        }
1248      }
1249      for(i=ncols(F0);i>=1;i--)
1250      {
1251        F0[i]=F0[i]/var(1);
1252      }
1253    }
1254
1255    I=list();
1256    I0=module();
1257    U0=std(module());
1258    for(i=size(F);i>=1;i--)
1259    {
1260      I[i]=module();
1261    }
1262    for(i=1;i<=size(F);i++)
1263    {
1264      I0=reduce(F[i],U0);
1265      j=i;
1266      while(size(I0)>0)
1267      {
1268        U0=std(U0+I0);
1269        I[j]=I[j]+I0;
1270        I0=reduce(N*I0,U0);
1271        j++;
1272      }
1273    }
1274
1275    for(i=1;i<=size(I);i++)
1276    {
1277      U=U+I[i];
1278    }
1279  }
1280
1281  dbprint(printlevel-voice+2,"// transform to Hodge splitting basis");
1282  V=inverse(U);
1283  A=V*A*U;
1284  H=V*H;
1285  T=T*U;
1286
1287  dbprint(printlevel-voice+2,"// compute reduced standard basis of H''");
1288  degBound=k0+k1+2;
1289  option(redSB);
1290  H=std(H);
1291  option(noredSB);
1292  degBound=0;
1293  H=simplify(jet(H,k0+k1),1);
1294  attrib(H,"isSB",1);
1295  dbprint(printlevel-voice+2,"// compute matrix A0+sA1 of t");
1296  A=division(var(1)*A*H+var(1)^2*diff(matrix(H),var(1)),H,deg(var(1)))[1];
1297  A0=jet(A,0);
1298  A=jet(A,1)/var(1);
1299  T=jet(T*H,2*k0)/var(1)^(2*k0);
1300
1301  setring(R);
1302  matrix A0=imap(S,A0);
1303  matrix A1=imap(S,A);
1304  module T=imap(S,T);
1305  ideal M=imap(G,gmsbasis);
1306  kill G,gmsmaxdeg;
1307  kill S;
1308  return(list(A0,A1,T,M));
1309}
1310example
1311{ "EXAMPLE:"; echo=2;
1312  ring R=0,(x,y),ds;
1313  poly t=x5+x2y2+y5;
1314  list A=tmatrix(t);
1315  print(A[1]);
1316  print(A[2]);
1317  print(A[3]);
1318  print(A[4]);
1319}
1320///////////////////////////////////////////////////////////////////////////////
1321
1322proc endvfilt(list v)
1323"USAGE:   endvfilt(v); list v
1324ASSUME:  v returned by vfilt
1325RETURN:
1326@format
1327list ev;  V-filtration on Jacobian algebra
1328  ideal ev[1];
1329    number ev[1][i];  i-th V-filtration index
1330  intvec ev[2];
1331    int ev[2][i];  i-th multiplicity
1332  list ev[3];
1333    module ev[3][i];  vector space of i-th graded part in terms of ev[4]
1334  ideal ev[4];  monomial vector space basis of Jacobian algebra
1335  ideal ev[5];  standard basis of Jacobian ideal
1336@end format
1337KEYWORDS: singularities; Gauss-Manin connection; Brieskorn lattice;
1338          mixed Hodge structure; V-filtration; endomorphism filtration
1339EXAMPLE:  example endvfilt; shows examples
1340"
1341{
1342  def a,d,V,m,g=v[1..5];
1343  attrib(g,"isSB",1);
1344  int mu=ncols(m);
1345
1346  module V0=V[1];
1347  for(int i=2;i<=size(V);i++)
1348  {
1349    V0=V0,V[i];
1350  }
1351
1352  dbprint(printlevel-voice+2,"// compute multiplication in Jacobian algebra");
1353  list M;
1354  module U=freemodule(ncols(m));
1355  for(i=ncols(m);i>=1;i--)
1356  {
1357    M[i]=division(coeffs(reduce(m[i]*m,g,U),m)*V0,V0)[1];
1358  }
1359
1360  int j,k,i0,j0,i1,j1;
1361  number b0=number(a[1]-a[ncols(a)]);
1362  number b1,b2;
1363  matrix M0;
1364  module L;
1365  list v0=freemodule(ncols(m));
1366  ideal a0=b0;
1367  list l;
1368
1369  while(b0<number(a[ncols(a)]-a[1]))
1370  {
1371    dbprint(printlevel-voice+2,"// find next possible index");
1372    b1=number(a[ncols(a)]-a[1]);
1373    for(j=ncols(a);j>=1;j--)
1374    {
1375      for(i=ncols(a);i>=1;i--)
1376      {
1377        b2=number(a[i]-a[j]);
1378        if(b2>b0&&b2<b1)
1379        {
1380          b1=b2;
1381        }
1382        else
1383        {
1384          if(b2<=b0)
1385          {
1386            i=0;
1387          }
1388        }
1389      }
1390    }
1391    b0=b1;
1392
1393    l=ideal();
1394    for(k=ncols(m);k>=2;k--)
1395    {
1396      l=l+list(ideal());
1397    }
1398
1399    dbprint(printlevel-voice+2,"// collect conditions for EV["+string(b0)+"]");
1400    j=ncols(a);
1401    j0=mu;
1402    while(j>=1)
1403    {
1404      i0=1;
1405      i=1;
1406      while(i<ncols(a)&&a[i]<a[j]+b0)
1407      {
1408        i0=i0+d[i];
1409        i++;
1410      }
1411      if(a[i]<a[j]+b0)
1412      {
1413        i0=i0+d[i];
1414        i++;
1415      }
1416      for(k=1;k<=ncols(m);k++)
1417      {
1418        M0=M[k];
1419        if(i0>1)
1420        {
1421          l[k]=l[k],M0[1..i0-1,j0-d[j]+1..j0];
1422        }
1423      }
1424      j0=j0-d[j];
1425      j--;
1426    }
1427
1428    dbprint(printlevel-voice+2,"// compose condition matrix");
1429    L=transpose(module(l[1]));
1430    for(k=2;k<=ncols(m);k++)
1431    {
1432      L=L,transpose(module(l[k]));
1433    }
1434
1435    dbprint(printlevel-voice+2,"// compute kernel of condition matrix");
1436    v0=v0+list(syz(L));
1437    a0=a0,b0;
1438  }
1439
1440  dbprint(printlevel-voice+2,"// compute graded parts");
1441  option(redSB);
1442  for(i=1;i<size(v0);i++)
1443  {
1444    v0[i+1]=std(v0[i+1]);
1445    v0[i]=std(reduce(v0[i],v0[i+1]));
1446  }
1447  option(noredSB);
1448
1449  dbprint(printlevel-voice+2,"// remove trivial graded parts");
1450  i=1;
1451  while(size(v0[i])==0)
1452  {
1453    i++;
1454  }
1455  list v1=v0[i];
1456  intvec d1=size(v0[i]);
1457  ideal a1=a0[i];
1458  i++;
1459  while(i<=size(v0))
1460  {
1461    if(size(v0[i])>0)
1462    {
1463      v1=v1+list(v0[i]);
1464      d1=d1,size(v0[i]);
1465      a1=a1,a0[i];
1466    }
1467    i++;
1468  }
1469  return(list(a1,d1,v1,m,g));
1470}
1471example
1472{ "EXAMPLE:"; echo=2;
1473  ring R=0,(x,y),ds;
1474  poly t=x5+x2y2+y5;
1475  endvfilt(vfilt(t));
1476}
1477///////////////////////////////////////////////////////////////////////////////
1478
1479proc spprint(list sp)
1480"USAGE:   spprint(sp); list sp
1481RETURN:  string s;  spectrum sp
1482EXAMPLE: example spprint; shows examples
1483"
1484{
1485  string s;
1486  for(int i=1;i<size(sp[2]);i++)
1487  {
1488    s=s+"("+string(sp[1][i])+","+string(sp[2][i])+"),";
1489  }
1490  s=s+"("+string(sp[1][i])+","+string(sp[2][i])+")";
1491  return(s);
1492}
1493example
1494{ "EXAMPLE:"; echo=2;
1495  ring R=0,(x,y),ds;
1496  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));
1497  spprint(sp);
1498}
1499///////////////////////////////////////////////////////////////////////////////
1500
1501proc sppprint(list spp)
1502"USAGE:   sppprint(spp); list spp
1503RETURN:  string s;  spectral pairs spp
1504EXAMPLE: example sppprint; shows examples
1505"
1506{
1507  string s;
1508  for(int i=1;i<size(spp[3]);i++)
1509  {
1510    s=s+"(("+string(spp[1][i])+","+string(spp[2][i])+"),"+string(spp[3][i])+"),";
1511  }
1512  s=s+"(("+string(spp[1][i])+","+string(spp[2][i])+"),"+string(spp[3][i])+")";
1513  return(s);
1514}
1515example
1516{ "EXAMPLE:"; echo=2;
1517  ring R=0,(x,y),ds;
1518  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));
1519  sppprint(spp);
1520}
1521///////////////////////////////////////////////////////////////////////////////
1522
1523proc spadd(list sp1,list sp2)
1524"USAGE:   spadd(sp1,sp2); list sp1, list sp2
1525RETURN:  list sp;  sum of spectra sp1 and sp2
1526EXAMPLE: example spadd; shows examples
1527"
1528{
1529  ideal s;
1530  intvec m;
1531  int i,i1,i2=1,1,1;
1532  while(i1<=size(sp1[2])||i2<=size(sp2[2]))
1533  {
1534    if(i1<=size(sp1[2]))
1535    {
1536      if(i2<=size(sp2[2]))
1537      {
1538        if(number(sp1[1][i1])<number(sp2[1][i2]))
1539        {
1540          s[i]=sp1[1][i1];
1541          m[i]=sp1[2][i1];
1542          i++;
1543          i1++;
1544        }
1545        else
1546        {
1547          if(number(sp1[1][i1])>number(sp2[1][i2]))
1548          {
1549            s[i]=sp2[1][i2];
1550            m[i]=sp2[2][i2];
1551            i++;
1552            i2++;
1553          }
1554          else
1555          {
1556            if(sp1[2][i1]+sp2[2][i2]!=0)
1557            {
1558              s[i]=sp1[1][i1];
1559              m[i]=sp1[2][i1]+sp2[2][i2];
1560              i++;
1561            }
1562            i1++;
1563            i2++;
1564          }
1565        }
1566      }
1567      else
1568      {
1569        s[i]=sp1[1][i1];
1570        m[i]=sp1[2][i1];
1571        i++;
1572        i1++;
1573      }
1574    }
1575    else
1576    {
1577      s[i]=sp2[1][i2];
1578      m[i]=sp2[2][i2];
1579      i++;
1580      i2++;
1581    }
1582  }
1583  return(list(s,m));
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  spprint(spadd(sp1,sp2));
1593}
1594///////////////////////////////////////////////////////////////////////////////
1595
1596proc spsub(list sp1,list sp2)
1597"USAGE:   spsub(sp1,sp2); list sp1, list sp2
1598RETURN:  list sp;  difference of spectra sp1 and sp2
1599EXAMPLE: example spsub; shows examples
1600"
1601{
1602  return(spadd(sp1,spmul(sp2,-1)));
1603}
1604example
1605{ "EXAMPLE:"; echo=2;
1606  ring R=0,(x,y),ds;
1607  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));
1608  spprint(sp1);
1609  list sp2=list(ideal(-1/6,1/6),intvec(1,1));
1610  spprint(sp2);
1611  spprint(spsub(sp1,sp2));
1612}
1613///////////////////////////////////////////////////////////////////////////////
1614
1615proc spmul(list #)
1616"USAGE:   spmul(sp0,k); list sp0, int[vec] k
1617RETURN:  list sp;  linear combination of spectra sp0 with coefficients k
1618EXAMPLE: example spmul; shows examples
1619"
1620{
1621  if(size(#)==2)
1622  {
1623    if(typeof(#[1])=="list")
1624    {
1625      if(typeof(#[2])=="int")
1626      {
1627        return(list(#[1][1],#[1][2]*#[2]));
1628      }
1629      if(typeof(#[2])=="intvec")
1630      {
1631        list sp0=list(ideal(),intvec(0));
1632        for(int i=size(#[2]);i>=1;i--)
1633        {
1634          sp0=spadd(sp0,spmul(#[1][i],#[2][i]));
1635        }
1636        return(sp0);
1637      }
1638    }
1639  }
1640  return(list(ideal(),intvec(0)));
1641}
1642example
1643{ "EXAMPLE:"; echo=2;
1644  ring R=0,(x,y),ds;
1645  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));
1646  spprint(sp);
1647  spprint(spmul(sp,2));
1648  list sp1=list(ideal(-1/6,1/6),intvec(1,1));
1649  spprint(sp1);
1650  list sp2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1651  spprint(sp2);
1652  spprint(spmul(list(sp1,sp2),intvec(1,2)));
1653}
1654///////////////////////////////////////////////////////////////////////////////
1655
1656proc spissemicont(list sp,list #)
1657"USAGE:   spissemicont(sp[,1]); list sp, int opt
1658RETURN:
1659@format
1660int k=
1661  1;  if sum of sp is positive on all intervals [a,a+1) [and (a,a+1)]
1662  0;  if sum of sp is negative on some interval [a,a+1) [or (a,a+1)]
1663@end format
1664EXAMPLE: example spissemicont; shows examples
1665"
1666{
1667  int opt=0;
1668  if(size(#)>0)
1669  {
1670    if(typeof(#[1])=="int")
1671    {
1672      opt=1;
1673    }
1674  }
1675  int i,j,k;
1676  i=1;
1677  while(i<=size(sp[2])-1)
1678  {
1679    j=i+1;
1680    k=0;
1681    while(j+1<=size(sp[2])&&number(sp[1][j])<=number(sp[1][i])+1)
1682    {
1683      if(opt==0||number(sp[1][j])<number(sp[1][i])+1)
1684      {
1685        k=k+sp[2][j];
1686      }
1687      j++;
1688    }
1689    if(j==size(sp[2])&&number(sp[1][j])<=number(sp[1][i])+1)
1690    {
1691      if(opt==0||number(sp[1][j])<number(sp[1][i])+1)
1692      {
1693        k=k+sp[2][j];
1694      }
1695    }
1696    if(k<0)
1697    {
1698      return(0);
1699    }
1700    i++;
1701  }
1702  return(1);
1703}
1704example
1705{ "EXAMPLE:"; echo=2;
1706  ring R=0,(x,y),ds;
1707  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));
1708  spprint(sp1);
1709  list sp2=list(ideal(-1/6,1/6),intvec(1,1));
1710  spprint(sp2);
1711  spissemicont(spsub(sp1,spmul(sp2,3)));
1712  spissemicont(spsub(sp1,spmul(sp2,4)));
1713}
1714///////////////////////////////////////////////////////////////////////////////
1715
1716proc spsemicont(list sp0,list sp,list #)
1717"USAGE:   spsemicont(sp0,sp,k[,1]); list sp0, list sp
1718RETURN:
1719@format
1720list l;
1721  intvec l[i];  if the spectra sp0 occur with multiplicities k
1722                in a deformation of a [quasihomogeneous] singularity
1723                with spectrum sp then k<=l[i]
1724@end format
1725EXAMPLE: example spsemicont; shows examples
1726"
1727{
1728  list l,l0;
1729  int i,j,k;
1730  while(spissemicont(sp0,#))
1731  {
1732    if(size(sp)>1)
1733    {
1734      l0=spsemicont(sp0,list(sp[1..size(sp)-1]));
1735      for(i=1;i<=size(l0);i++)
1736      {
1737        if(size(l)>0)
1738        {
1739          j=1;
1740          while(j<size(l)&&l[j]!=l0[i])
1741          {
1742            j++;
1743          }
1744          if(l[j]==l0[i])
1745          {
1746            l[j][size(sp)]=k;
1747          }
1748          else
1749          {
1750            l0[i][size(sp)]=k;
1751            l=l+list(l0[i]);
1752          }
1753        }
1754        else
1755        {
1756          l=l0;
1757        }
1758      }
1759    }
1760    sp0=spsub(sp0,sp[size(sp)]);
1761    k++;
1762  }
1763  if(size(sp)>1)
1764  {
1765    return(l);
1766  }
1767  else
1768  {
1769    return(list(intvec(k-1)));
1770  }
1771}
1772example
1773{ "EXAMPLE:"; echo=2;
1774  ring R=0,(x,y),ds;
1775  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));
1776  spprint(sp0);
1777  list sp1=list(ideal(-1/6,1/6),intvec(1,1));
1778  spprint(sp1);
1779  list sp2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1780  spprint(sp2);
1781  list sp=sp1,sp2;
1782  list l=spsemicont(sp0,sp);
1783  l;
1784  spissemicont(spsub(sp0,spmul(sp,l[1])));
1785  spissemicont(spsub(sp0,spmul(sp,l[1]-1)));
1786  spissemicont(spsub(sp0,spmul(sp,l[1]+1)));
1787}
1788///////////////////////////////////////////////////////////////////////////////
1789
1790proc spmilnor(list sp)
1791"USAGE:   spmilnor(sp); list sp
1792RETURN:  int mu;  Milnor number of spectrum sp
1793EXAMPLE: example spmilnor; shows examples
1794"
1795{
1796  return(sum(sp[2]));
1797}
1798example
1799{ "EXAMPLE:"; echo=2;
1800  ring R=0,(x,y),ds;
1801  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));
1802  spprint(sp);
1803  spmilnor(sp);
1804}
1805///////////////////////////////////////////////////////////////////////////////
1806
1807proc spgeomgenus(list sp)
1808"USAGE:   spgeomgenus(sp); list sp
1809RETURN:  int g;  geometrical genus of spectrum sp
1810EXAMPLE: example spgeomgenus; shows examples
1811"
1812{
1813  int g=0;
1814  int i=1;
1815  while(i+1<=size(sp[2])&&number(sp[1][i])<=number(0))
1816  {
1817    g=g+sp[2][i];
1818    i++;
1819  }
1820  if(i==size(sp[2])&&number(sp[1][i])<=number(0))
1821  {
1822    g=g+sp[2][i];
1823  }
1824  return(g);
1825}
1826example
1827{ "EXAMPLE:"; echo=2;
1828  ring R=0,(x,y),ds;
1829  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));
1830  spprint(sp);
1831  spgeomgenus(sp);
1832}
1833///////////////////////////////////////////////////////////////////////////////
1834
1835proc spgamma(list sp)
1836"USAGE:   spgamma(sp); list sp
1837RETURN:  number gamma;  gamma invariant of spectrum sp
1838EXAMPLE: example spgamma; shows examples
1839"
1840{
1841  int i,j;
1842  number g=0;
1843  for(i=1;i<=ncols(sp[1]);i++)
1844  {
1845    for(j=1;j<=sp[2][i];j++)
1846    {
1847      g=g+(number(sp[1][i])-number(nvars(basering)-2)/2)^2;
1848    }
1849  }
1850  g=-g/4+sum(sp[2])*number(sp[1][ncols(sp[1])]-sp[1][1])/48;
1851  return(g);
1852}
1853example
1854{ "EXAMPLE:"; echo=2;
1855  ring R=0,(x,y),ds;
1856  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));
1857  spprint(sp);
1858  spgamma(sp);
1859}
1860///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.