
// Make newform 322.2.g.a in Magma, downloaded from the LMFDB on 17 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_322_g();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_322_g_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_322_2_g_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_322_2_g_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [2401, 0, 8085, 0, 22423, 0, 14406, 0, 6585, 0, 1434, 0, 226, 0, 18, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-650423475226, 0, -992457622834, 0, -598846393691, 0, -206205174673, 0, -39156407581, 0, -4992038792, 0, -357616089, 0, -16016843, 0], [-2481148141444, 0, -3791385151776, 0, -2357725853427, 0, -645698199869, 0, -116812942191, 0, -12366108886, 0, -838784719, 0, -25899908, 0], [362977184262, 0, 679011213031, 0, 629143386508, 0, 266212664966, 0, 58435186409, 0, 8339521600, 0, 647630005, 0, 31483524, 0], [-1235543183245, 0, 1037405997123, 0, 723058716380, 0, 346946458867, 0, 71855612665, 0, 11030105099, 0, 853307341, 0, 46792861, 0], [506321481001, 0, 1404683653213, 0, 841521367050, 0, 416294239206, 0, 91738182609, 0, 14913954672, 0, 1196540914, 0, 68184274, 0], [0, 234153598717, 0, -10188065349, 0, -28154149749, 0, -30826320447, 0, -7411650444, 0, -1368597087, 0, -112789235, 0, -6975738], [-1717473487905, 0, -5576076848873, 0, -3484548118870, 0, -1734524737163, 0, -386835300380, 0, -63539668261, 0, -5129397229, 0, -294128509, 0], [671866451907, 0, -4308366097873, 0, -3786373832724, 0, -2133415874648, 0, -492908101323, 0, -81813898297, 0, -6640569708, 0, -379875222, 0], [0, -2682037157653, 0, 11555957875297, 0, 6496688880199, 0, 3122871260604, 0, 679206852725, 0, 109886589690, 0, 8793640344, 0, 500045446], [0, -421218231742, 0, 2680850200333, 0, 2329068000147, 0, 1081154919617, 0, 239063115702, 0, 36966138724, 0, 2937898622, 0, 159118374], [0, -9325440613244, 0, 17033080757013, 0, 11201140500018, 0, 7363397425490, 0, 1716042596475, 0, 301479751327, 0, 24724308082, 0, 1482542225], [0, 15022740886300, 0, 45480525704329, 0, 28821327863734, 0, 12617397123280, 0, 2705049202442, 0, 418326213629, 0, 33070488812, 0, 1812976145], [0, 14580373128671, 0, 40441071229375, 0, 25745509497624, 0, 11908073199276, 0, 2602270360005, 0, 413665642185, 0, 33041863886, 0, 1849992808], [0, 9891611938649, 0, -37522204462150, 0, -28110655811896, 0, -15140293448971, 0, -3426523980851, 0, -565731629381, 0, -45707452382, 0, -2619126371], [0, 2315919560941, 0, -55464603304326, 0, -39285915639747, 0, -20759601211693, 0, -4673818962915, 0, -769038087803, 0, -62041171232, 0, -3550950679]];
    Rf_basisdens := [1, 409935420069, 409935420069, 409935420069, 409935420069, 409935420069, 58562202867, 409935420069, 409935420069, 2869547940483, 409935420069, 2869547940483, 2869547940483, 2869547940483, 2869547940483, 2869547940483];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_322_g();"
function MakeCharacter_322_g()
    N := 322;
    order := 6;
    char_gens := [185, 281];
    v := [1, 3];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_322_g_Hecke();"
function MakeCharacter_322_g_Hecke(Kf)
    N := 322;
    order := 6;
    char_gens := [185, 281];
    char_values := [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..(prec+1)]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 2;
    raw_aps := [[0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0], [1, 0, -1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, -1, 0, 1, 1, -1], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, -1, 1, 0, 0, 1, 0, -1, 1, 1, 0], [1, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 1, -1], [1, 0, -1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 2, -1, -2, -1, 1], [3, -1, 0, -1, 0, -2, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 1, 0, -1, 2, 0], [1, -2, 0, 0, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 1, 0, -1, -1, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, -1, 0, 0, 0, -1, -3, -1], [-1, 2, 1, 1, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 1, 0, -1, -1, 2], [0, 0, 0, 0, 0, 0, -5, 0, 0, 2, 1, 1, -1, 4, 4, -1], [0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, 0, -2, 2, 2, 0], [0, 0, 0, 0, 0, 0, 3, 0, 0, -2, 0, -1, 1, -1, -4, 0], [2, -3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3, 0, 0, 1, 1, 1, -1, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3, 0, 0, 1, 0, 0, -1, 4, 2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 4, 0, 0, -1, -2, -1, 0, 3, -1, -1], [-6, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-5, -1, 0, 1, -4, 3, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, -1, -1, -1, 0, -1, -2, 0], [-1, 0, 3, 4, 0, -2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 2, 0, -2, 2, 2, 0], [1, -2, 0, -4, 2, -1, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 8, 0, 0, -1, -2, -2, 8, -5, -5, -1], [-1, 0, 0, 1, 0, 6, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -2, 2, 0, -2, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0], [9, -6, 0, -5, -2, -7, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-2, -1, 0, -2, 1, 2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -8, 0, 0, 0, 1, 1, -3, 5, 6, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -3, 1, 0], [2, 0, -1, 0, -3, -2, 0, 3, -2, 0, 0, 0, 0, 0, 0, 0], [2, 7, 0, 3, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -6, 0, 0, 2, 2, 0, -6, -1, 5, -1], [-10, -4, 1, -1, -2, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [-6, 1, 2, 3, -1, 9, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -4, 0, 0, 0, -1, 1, -4, 1, 2, 0], [0, 0, 0, 0, 0, 0, 5, 0, 0, -1, -1, 0, -2, -1, -3, -1], [-3, -7, 0, 3, 0, 3, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0], [2, -3, 1, -4, 5, -4, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, -2, -3, 1, 2, 6, -3, 1], [0, 0, 0, 0, 0, 0, 4, 0, 0, -3, 0, -2, 3, 1, -9, -1], [5, 8, 0, 9, -2, 2, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2, 0, 0, -2, -1, -1, 0, 1, -2, 0], [-8, 0, 0, 0, -1, -8, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [12, -2, 0, -4, 4, -8, 0, -2, 1, 0, 0, 0, 0, 0, 0, 0], [-18, 2, 1, 4, -6, 18, 0, 6, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, -4, -3, 0, 8, -4, -4, 1], [0, 0, 0, 0, 0, 0, 6, 0, 0, -3, -3, 1, 6, -2, -6, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, -3, -1, -1, 0, 0, -3, 2], [-2, -1, -4, 0, 1, 4, 0, -2, -4, 0, 0, 0, 0, 0, 0, 0], [8, 3, 1, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 2, 4, 1, -2, 0, 1], [-5, -4, 4, 5, 0, -4, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0], [1, -3, 2, -1, 0, -12, 0, -4, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 0, 1, 1, 1, -4, 3, 1, 0], [-2, 3, -2, 6, -1, 2, 0, 1, -4, 0, 0, 0, 0, 0, 0, 0], [-9, 0, -2, 3, 0, 15, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0], [-3, 5, 2, 0, 2, -3, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -7, 0, 0, 0, 1, 2, -7, -1, 7, 2], [0, 0, 0, 0, 0, 0, 2, 0, 0, 1, -3, -3, 2, 0, 0, -4], [0, 0, 0, 0, 0, 0, 12, 0, 0, 1, -1, -3, 9, -4, -8, -4], [0, 0, 0, 0, 0, 0, -2, 0, 0, 0, -2, -3, 1, -2, 0, -2], [0, 0, 0, 0, 0, 0, -1, 0, 0, 5, 2, -1, -2, 3, 3, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -2, -2, 0, 0, -4, 0], [-13, 6, 0, 3, 6, 8, 0, -3, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 2, -1, -1, 2, -4, 0, -3], [11, 5, 2, 0, 2, 11, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 1, -3, -6, 6, 0], [0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 2, 3, -1, -5, 0, 2], [0, 0, 0, 0, 0, 0, 14, 0, 0, -2, -2, -2, 0, -7, -4, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, -2, 3, -1, 1, 1, -4, -3], [-5, 1, 0, 1, 0, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [-2, -4, -2, 2, 0, 1, 0, -2, -1, 0, 0, 0, 0, 0, 0, 0], [-5, 4, 1, 0, 4, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 3, 2, -1, -2, -5, 5, -4], [12, -4, -5, -4, 4, -20, 0, -8, -5, 0, 0, 0, 0, 0, 0, 0], [-2, 1, -2, 2, -3, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 2, 4, -2, -2, -2, 0], [0, 0, 0, 0, 0, 0, -2, 0, 0, 3, 1, -3, -2, 2, 4, -4], [9, -7, 2, -14, -1, -9, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0], [4, -7, 2, -5, 3, -5, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0], [5, 7, 0, -5, 0, 8, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -10, 0, 0, -1, 3, 1, -4, 8, 7, 0], [2, 8, 0, 8, 0, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -6, 0, 0, -3, 0, 6, -6, -3, 0, 6], [0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, 5, 0, 0, 0], [4, 7, 0, -4, 0, -4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [2, -9, 3, -4, -1, -4, 0, 0, -3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -18, 0, 0, 2, -2, -2, 0, 9, 5, 3], [0, 0, 0, 0, 0, 0, -6, 0, 0, 3, 3, -1, -6, 10, 6, -2], [0, 0, 0, 0, 0, 0, -5, 0, 0, -5, -1, 3, -3, 0, -2, 8], [0, 0, 0, 0, 0, 0, 8, 0, 0, 4, 2, 2, 0, -4, -5, -3], [-9, -1, 1, 0, 4, -9, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [1, -3, 2, -1, 3, -1, 0, -6, 2, 0, 0, 0, 0, 0, 0, 0], [-8, 5, 0, 8, -6, 8, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [7, -7, -1, -14, 5, -7, 0, -5, -2, 0, 0, 0, 0, 0, 0, 0], [12, 0, 5, -4, 0, -20, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [-10, 13, 0, 12, 2, 11, 0, -1, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -8, 0, 0, 3, -1, -1, 0, 4, -5, -1], [0, 0, 0, 0, 0, 0, -3, 0, 0, -6, -5, 4, -2, -10, -6, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 5, 3, 0, 1, -1, 5], [0, 0, 0, 0, 0, 0, -10, 0, 0, 3, 1, -1, -8, 0, 3, -2], [0, 0, 0, 0, 0, 0, 6, 0, 0, 4, 0, 0, 0, -3, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0, 0, 7, -1, 1, 4, -1, -1, -4], [-9, -3, 2, 0, -4, -9, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -4, 1, 0, 6, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, -2, -3, 0, -2, 0, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, 4, 0, -12, -4, 4], [15, -16, 2, -7, -2, -7, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, -2, -2, -1, -1, -1, -3, -1], [-1, 8, 2, 16, -2, 1, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0], [-10, 0, 0, -2, 4, 4, 0, -2, -3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 0, -6, -6, 1, 3, -11, -6, 0], [0, 0, 0, 0, 0, 0, -3, 0, 0, 0, -6, 1, 3, 5, -3, 1], [-24, -2, 0, -2, 0, 11, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 18, 0, 0, 1, -4, -2, 7, -13, -13, -1], [0, 0, 0, 0, 0, 0, 6, 0, 0, -10, -3, 2, 9, -5, -1, 2], [9, -7, 2, -14, 6, -9, 0, -6, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -6, 0, 0, 8, 8, 0, -8, 10, 8, 0], [0, 0, 0, 0, 0, 0, -4, 0, 0, -3, -7, 2, 4, 7, -7, 5], [0, 0, 0, 0, 0, 0, -1, 0, 0, 7, 7, -3, 2, 7, 7, 0], [-8, -13, 0, -14, 2, -3, 0, -1, -2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 9, 0, 0, 3, 3, 0, 3, -3, -3, -6], [0, 0, 0, 0, 0, 0, -2, 0, 0, -4, -3, 5, -2, -8, -3, 5], [0, 0, 0, 0, 0, 0, -10, 0, 0, -1, -2, 4, -10, 5, 4, 2], [0, 0, 0, 0, 0, 0, -4, 0, 0, -2, 0, -1, 1, 6, -4, 0], [18, -6, 0, -12, -7, -18, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [11, 0, 7, -5, 0, -17, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], [1, 2, 0, -1, 0, 5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-8, 1, -3, 2, 4, 8, 0, -4, -6, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 8, 0, 0, -7, -5, 0, 15, -12, -7, 2], [7, -1, 0, 0, -2, 7, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -16, 0, 0, -2, 0, 1, -5, 10, 8, 4], [-10, 6, -2, 13, -6, 7, 0, 12, -2, 0, 0, 0, 0, 0, 0, 0], [-17, 3, 3, 0, 1, -17, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [14, -16, 0, -16, 0, -15, 0, 0, -6, 0, 0, 0, 0, 0, 0, 0], [1, 4, 2, -1, 0, 16, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0], [4, 3, -10, -4, 0, -1, 0, -1, -5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -16, 0, 0, 3, 3, 3, -6, 10, 15, 0], [-29, 7, -3, 5, -3, 5, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [-21, -8, 0, -9, 2, 6, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 8, 0, 0, 3, -2, -2, 0, -4, -7, -1], [0, 0, 0, 0, 0, 0, 7, 0, 0, 3, 2, -4, 5, 8, 3, -1], [0, 0, 0, 0, 0, 0, -2, 0, 0, 4, 7, -2, -5, 3, 9, -6], [12, 0, 0, 2, -4, -5, 0, 2, -2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -10, 0, 0, 5, -2, 3, -4, 1, 13, 3], [0, 0, 0, 0, 0, 0, -2, 0, 0, 7, 5, -7, -2, 11, 8, -8], [4, 0, 0, -4, 0, -4, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0, 0, -2, -5, -5, 5, -2, -2, -3], [34, 4, -2, 1, 2, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -23, 0, 0, 4, 3, 1, 0, 2, 4, 1], [0, 0, 0, 0, 0, 0, -4, 0, 0, -3, -3, -3, 0, 2, -3, 1], [0, 0, 0, 0, 0, 0, 8, 0, 0, 3, 2, -6, 8, -3, -1, -5], [23, -3, 4, -6, 9, -23, 0, -9, 8, 0, 0, 0, 0, 0, 0, 0], [-7, 5, -3, 0, 1, -7, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_322_g_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_322_2_g_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_322_2_g_a(:prec:=16)
    chi := MakeCharacter_322_g();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_322_2_g_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_322_2_g_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_322_g();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![25, 45, -8, -63, 35, 21, -4, -3, 1]>],Snew);
    return Vf;
end function;