default(parisize,"32M");
zet=1;
Z(a)=lfuncreate([(p,n)->1/(1-p^a*x),0,[-a],2*a+1,1,1,[[a+1,1/x+O(1)]]]);
N=nfinit(x^10-2*x^8-9*x^6+57*x^4-69*x^2+47);
G=galoisinit(N);
E=ellinit([0,-1,1,-10,-20]); \\ 11a1
VALL={
[zet,
lfuncreate([n->vector(n,i,kronecker(i,857)),0,[0],1,857,1]),
lfunthetainit(zet),
lfuninit(zet,[1,1,2],2),
\\5
lfuninit(x^3-x-1,[1,1,2],2),
lfuninit(x^4-2,[1,1,2],2),
lfuninit(x^6+108,[1,1,2],2),
lfuninit(polsubcyclo(11,5),[1,1,2],2),
x^3-x-1,
\\10
x^4-2,
polsubcyclo(11,5),
17,
-4,
857,
\\15
[znstar(5,1),2],
E,
ellinit([1,1]),
ellinit([-7,3]),
lfunetaquo([1,1;3,1;5,1;15,1]),
\\20
lfunmul(-4,-3),
lfundiv(x^3-x-1,1),
bnfinit(x^4+2*x^2+5),
[bnrinit(bnfinit(x^3+x^2+2*x+1),4),[1]],
Z(2),
\\25
lfunqf(matid(4)),
lfunqf(matdiagonal([1,2,3,4])),
lfunartin(N,G,[2,0,-y^3-y^2-1,y^3+y^2],5),
lfunartin(N,G,[['a,0;0,'a^4],[0,1;1,0]],5),
  if(1,my(E1=ellinit([0,0,1,-1,0]),E2=ellinit([0,1,1,-23,-50]));
lfuncreate([n->lfunan(E1,n)+lfunan(E2,n),n->-lfunan(E1,n)+lfunan(E2,n),[0,1],2,37,1])),
\\30
  if(1,my(K3=nfinit(a^2-a-9));
ellinit([0,2,1,-19-8*a,28+11*a],K3)),
  if(1,my(E=ellinit([0,-1,1,-10,-20])); \\11a1
lfuncreate([n->my(V=ellan(E,n));vector(n,i,V[i]/sqrt(i)),0,[1/2,3/2],1,11,1])),
lfuntwist(E, Mod(2,5)),
lfunsympow(E,2),
lfunsympow(E,3),
\\35
  if(1,localprec(19);
lfuncreate(()->[n->lfunan(Mod(2,7),n),1,[0],1,7,((-13-3*sqrt(-3))/14)^(1/6)])),
  if(1,my(bnf=bnfinit('a^2+47),bnr=bnrinit(bnf,1));
lfuncreate([bnr,[[1],[2]]])),
if(1,my(G=znstar(44,1)); lfuncreate([G,[[3,0],[9,0]]])),
lfunshift(x^2+1,1),
lfunshift(x^2+1,-1/2),
\\40
lfunshift(x^2+1,1,1),
lfunhgm(hgminit([5]),1),
if(1,my(bnf=bnfinit(x^2-x+2), gc=gcharinit(bnf,idealprimedec(bnf,11)[1]),chi=[1,-1,-1/2]~);
  lfuncreate([gc,chi])),
if(1,my(bnf=bnfinit(a^2-a-9), bnr=bnrinit(bnf,[2,[0,0]]));
  lfuncreate([bnr,matdiagonal(bnr.cyc)])),
  lfuninit(1, []),
\\45
  lfuninit(x^2+1, [])
];
}
\p36
chk(s,i,a,b, laxist = 0) =
{ my (v, cvt = 0, B = getlocalbitprec());
  if (type(a)!="t_VEC", a=[a]; b=[b]; cvt=1);
  v = vector(#a,i, my(e); round((a[i]-b[i]) / b[i], &e); e);
  if (type(a[1])=="t_COMPLEX" && exponent(imag(a)) < -B, a = real(a));
  if (cvt, a = a[1]);
  if (vecmax(v) > if (laxist, laxist, 15 - B),
    error("bug in lfuntype:", s, ":", i, ":", v)
  , print(i," (",s,"): ",a));
}

{
for(i=1,#VALL,
  ldata=VALL[i];
  L=lfuninit(ldata,[1,1,2],2);
  a=lfun(L,2+2*I);
  b=lfun(ldata,2+2*I);
  chk("lfun(2+2*I)",i,a,b);
  iferr(
    a=lfun(L,2);
    b=lfun(ldata,2);
    chk("lfun",i,a,b);
    b=lfun(lfuncreate(ldata),2);
    chk("lfuncreate",i,a,b), E, print(E));
  iferr(
    a=lfun(L,2,2);
    b=lfun(ldata,2,2);
    chk("lfunderiv",i,a,b), E, print(E));
  iferr(
    a=lfunlambda(L,2);
    b=lfunlambda(ldata,2);
    chk("lfunlambda",i,a,b), E, print(E));
  iferr(
    a=lfunlambda(L,2,2);
    b=lfunlambda(ldata,2,2);
    chk("lfunderivlambda",i,a,b), E, print(E));
  a=lfuncheckfeq(L);
  b=lfuncheckfeq(ldata);
  chk("lfuncheckfeq",i,a,b, 1); \\ we may have a != b
  a=lfuncheckfeq(lfundual(L));
  b=lfuncheckfeq(lfundual(ldata));
  chk("lfuncheckfeq(lfundual)",i,a,b, 1); \\ we may have a != b
  a=lfunhardy(L,2);
  b=lfunhardy(ldata,2);
  chk("lfunhardy",i,a,b);
  print(i," (lfunorderzero): ",iferr(lfunorderzero(L),E,E));
  L=lfunthetainit(ldata);
  a=lfuntheta(L,2);
  b=lfuntheta(ldata,2);
  chk("lfuntheta",i,a,b);
  print(i," (lfunan): ",lfunan(ldata,10));
  print(i," (lfuneuler): ",iferr(lfuneuler(ldata,3),E,E));
  print(i," (lfuneuler): ",iferr(lfuneuler(ldata,7),E,E));
)
}
