Function: gcharalgebraic
Section: number_fields
C-Name: gcharalgebraic
Prototype: GDG
Help: gcharalgebraic(gc,{type}): returns a matrix whose columns form a basis of
 the algebraic Grossencharacters in gc. If type is specified as a vector of
 integer exponents [p,q] for each complex place, returns a vector containing
 an algebraic character of that infinity type (or the empty vector if such a
 character does not exist).
Doc: \var{gc} being the structure returned by \kbd{gcharinit}, returns a \typ{MAT}
 whose columns form a basis of the subgroup of algebraic Grossencharacters in
 \var{gc} (Weil type A0). The last component is interpreted as a power of the
 norm.

 If \var{type} is a \typ{VEC} of length $\var{gc}\kbd{.r1}+\var{gc}\kbd{.r2}$,
 containing a pair of integers $[p_{\tau},q_{\tau}]$ for each complex
 embedding~$\tau$, returns a \typ{VEC} containing a character whose infinity type
 at~$\tau$ is
 $$ z \mapsto z^{-p_{\tau}}\bar{z}^{-q_{\tau}} $$
 if such a character exists, or empty otherwise.
 The full set of characters of that infinity type is obtained by multiplying by
 the group of finite order characters.

 \bprog
 ? bnf = bnfinit(x^4-2*x^3+23*x^2-22*x+6,1);
 ? gc = gcharinit(bnf,1);
 ? gc.cyc
 % = [6, 0, 0, 0, 0.E-57]
 ? gcharalgebraic(gc)
 % =
 [1 0    0  0]
 [0 1    0  0]
 [0 0    1  0]
 [0 0    0  0]
 [0 0 -1/2 -1]
 ? gcharalgebraic(gc,[[1,1],[0,1]])
 % = [] \\ @com $p_{\tau}+q_{\tau}$ must be constant for an algebraic character to exist
 ? chi = gcharalgebraic(gc,[[1,1],[0,2]])[1]
 % = [0, 1, 2, 0, -1]~
 ? for(i=0,5,print(lfuneuler([gc,chi+[i,0,0,0,0]~],3)));
 \\@com all characters with this infinity type: multiply by finite order characters
 @eprog

 When the torsion subgroup is not cyclic, we can enumerate the characters of a
 given type with \kbd{forvec}.
 \bprog
 ? bnf = bnfinit(x^4+15*x^2+45,1);
 ? gc = gcharinit(bnf,1);
 ? gc.cyc
 % = [2, 2, 0, 0, 0, 0.E-57]
 ? [chi] = gcharalgebraic(gc,[[2,0],[2,0]]);
 ? {forvec(v=vectorv(2,i,[0,gc.cyc[i]-1]),
      print(round(lfunan([gc,chi+concat(v,[0,0,0,0]~)],20)));
    )};
   [1, 0, 0, 4, -5, 0, 0, 0, -9, 0, 16, 0, 0, 0, 0, 16, 0, 0, 16, -20]
   [1, 0, 0, -4, 5, 0, 0, 0, 9, 0, 16, 0, 0, 0, 0, 16, 0, 0, -16, -20]
   [1, 0, 0, 4, 5, 0, 0, 0, 9, 0, -16, 0, 0, 0, 0, 16, 0, 0, 16, 20]
   [1, 0, 0, -4, -5, 0, 0, 0, -9, 0, -16, 0, 0, 0, 0, 16, 0, 0, -16, 20]
 @eprog

 Some algebraic Hecke characters are related to CM Abelian varieties. We first
 show an example with an elliptic curve.
 \bprog
 ? E = ellinit([0, 0, 1, -270, -1708]); \\@com elliptic curve with potential CM by $\Q(\sqrt{-3})$
 ? bnf = bnfinit(x^2+3,1);
 ? p3 = idealprimedec(bnf,3)[1];
 ? gc = gcharinit(bnf,Mat([p3,2]));
 ? gc.cyc
 % = [0, 0.E-57]
 ? [chi] = gcharalgebraic(gc,[[1,0]])
 % = [[-1, -1/2]~]
 ? LE = lfuncreate(E);
 ? lfunan(LE,20)
 % = [1, 0, 0, -2, 0, 0, -1, 0, 0, 0, 0, 0, 5, 0, 0, 4, 0, 0, -7, 0]
 ? Lchi = lfuncreate([gc,chi]);
 ? round(lfunan(Lchi,20))
 % = [1, 0, 0, -2, 0, 0, -1, 0, 0, 0, 0, 0, 5, 0, 0, 4, 0, 0, -7, 0]
 @eprog

 Here is an example with a CM Abelian surface.
 \bprog
 ? L = lfungenus2([-2*x^4 - 2*x^3 + 2*x^2 + 3*x - 2, x^3]);
 ? bnf = bnfinit(a^4 - a^3 + 2*a^2 + 4*a + 3, 1);
 ? pr = idealprimedec(bnf,13)[1];
 ? gc = gcharinit(bnf,pr);
 ? gc.cyc
 % = [3, 0, 0, 0, 0.E-57]
 ? chitors = [1,0,0,0,0]~;
 ? typ = [[1,0],[1,0]];
 ? [chi0] = gcharalgebraic(gc,typ);
 ? igood = oo; nbgood = 0;
 ? {for(i=0,gc.cyc[1]-1,
      chi = chi0 + i*chitors;
      Lchi = lfuncreate([gc,chi]);
      if(lfunparams(L) == lfunparams(Lchi)
        && exponent(lfunan(L,10) - lfunan(Lchi,10)) < -50,
        igood=i; nbgood++
      );
   )};
 ? nbgood
 % = 1
 ? chi = chi0 + igood*chitors;
 ? Lchi = lfuncreate([gc,chi]);
 ? lfunan(L,30)
 % = [1, 0, -3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, -4, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, -6, 0, -3, 0]
 ? round(lfunan(Lchi,30))
 % = [1, 0, -3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, -4, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, -6, 0, -3, 0]
 @eprog
