source: git/Singular/LIB/gaussman.lib @ 744dd08

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