source: git/Singular/LIB/gaussman.lib @ 6f56ca

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