
// Make newform 320.6.c.l in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_320_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_320_c_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_320_6_c_l();".
// 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_320_6_c_l();".
// 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 := [1072562500, 438522500, 89646050, -59798850, 27827225, 2113880, 205428, -87824, 21226, 348, 18, -6, 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], [-8464373013786978826329925, -603348316903702480110000, -92941749509420247948800, 122142306781141996930480, -64281851585677873437336, 2720507879582880380992, -141248900500608409604, 17130235630071728642, -3535072440302249852, 192091663960648556, -8634349133755400, 307234436488338], [5056183094605590776086552532500, 5147183325728664616715123982200, -4327556220803483078670456761150, 421040030395298219604019986400, 40547627105984292925075437245, 16235640217562460443603413417, -5904338358432590439392932161, 553816801053669539036573989, 8095179206972280621725247, 1330069159872813637571727, -336349955350644341398009, 29012648376852651029539], [-7386979791568949031077717570000, -7864227539297539707847320823200, 6869631364598617368781441411400, -734502633247871175095721996400, -55267579553504090608740814220, -15996453114193488563332995852, 5936843624052729300018114516, -708929235973517859664455884, -10558192013211749347811332, -1288624321388489938316212, 342032820193123746040004, -35487438352839306343684], [3771591191044499990531642035000, 966696128591457978513444957600, -182485468868851969384468116700, 84857668491313643941069525250, 9494693305781491970010858360, 1457441126009688154572641096, -353513087409331781691943918, 79467691751665476070252957, 1341251957154278515508486, 101907647401723816832326, -24390480814556742053692, 3819436876559129065107], [-2036534985088695391886390890000, 907437818417872766148745707600, -191592319632745966239138376700, 96884199386560477688191616050, 3160430599955282470390733760, 1729370103611386916078494216, -367304707707933383880065978, 81019587808431128378848547, 1029602505511852694880106, 120057440476131252867146, -25231493151480755942132, 3849709870770421728297], [61438249275599206351748887432500, 64471944995097890103304967031200, -55648572657113628809418715936150, 5784303746828694991625105258900, 470432232219088190304321996145, 154094809792834460407542013507, -56714669716932961581143325756, 6171754608673057072697438769, 91243948800234727227622687, 12443769663051544989248017, -3239381530897085209268814, 313677025240705610068319], [-1885362490222329991007790081965000, 646279583481233129360666314679600, 185730841052364162746840086645800, -140480076118818394288020475332800, -1519157197284422402677430336840, -1617031699424633555739083918144, 267836139336459886618191422552, -62659217463110980019254375248, -642612896986899411655680704, -104273244821536198851494064, 18300133453687299879499888, -2827084074291580965128848], [6633573388185658237146481110800, -2360453584231989109516797320000, -417822243601734527667600236100, 405832246012641969136425210680, 31174837622563674885812742458, 264731673056464903910310842, -796267271369866131175206782, 277867258573519992440636490, 4831533237809968297831574, 94358023410900278385750, -60559280090711923940446, 12786843029867194402942], [314645192407482428284256072500, 341531046229990296123113512600, -69247673344582608488167548700, 33537718366826554483626329450, 2276022108763635022823599460, 539937291429219360503765336, -127457878720636111217731788, 28586049715341475715859912, 423985868687745515382976, 37623336599970765419816, -8732287291322962879072, 1359694548862667227062], [-18805046405068574273020085934800, 6455560390324419119268423320000, 1165078204978013309001819908100, -1080067789772402685377392336760, -111961871411699812034142689978, 3597301278365766222912816646, 2277415417449224518013982398, -849725811911438899185204234, -16287254467035875384325206, -43514089925929985152662, 176470660700834971420510, -39481333059848761968766], [-368330390114519124189420498405000, -390477593838046001533139635172800, 83183849708845419343480937771100, -39878523044853549731715328046850, -2504491796754790920407588779880, -461098401547767991077060769608, 130371814028530750368743915414, -30083810747371655673807140561, -455572105548067210950465278, -33968730326415030686260798, 8880905548636125402851916, -1418494773144224753357511]];
    Rf_basisdens := [1, 913072868511280052779575, 4389780429941681109748362727500, 1097445107485420277437090681875, 68179151091737281541050865250, 68179151091737281541050865250, 3292335322456260832311272045625, 20851457042222985271304722955625, 19100571336387467424095929425, 1301128837628574075210894375, 19100571336387467424095929425, 340895755458686407705254326250];
    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_320_c();"
function MakeCharacter_320_c()
    N := 320;
    order := 2;
    char_gens := [191, 261, 257];
    v := [2, 2, 1];
    // 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_320_c_Hecke();"
function MakeCharacter_320_c_Hecke(Kf)
    N := 320;
    order := 2;
    char_gens := [191, 261, 257];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 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]];
    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 := 6;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [5, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0], [0, 0, -5, -3, 0, 0, -1, 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, -2, -1, 0, 0, 0, -1, 0, -1], [0, 0, 0, -1, 0, 0, 0, 2, 2, 0, -1, 0], [0, 0, -61, 8, 0, 0, 57, 0, 0, 0, 0, 0], [676, 62, 0, 0, 12, -12, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0, 0, 2, -2, 0, 4, 0], [0, 0, 0, 0, 31, 33, 0, 0, 0, -6, 0, -2], [5495, 95, 0, 0, -113, 113, 0, 0, 0, 0, 0, 0], [0, 0, -77, 54, 0, 0, -146, 0, 0, 0, 0, 0], [0, 0, -393, -338, 0, 0, 135, 0, 0, 0, 0, 0], [0, 0, 0, 0, 154, 152, 0, 0, 0, 11, 0, 2], [0, 0, 0, 5, 0, 0, 0, -10, 10, 0, -15, 0], [9764, -266, 0, 0, -87, 87, 0, 0, 0, 0, 0, 0], [0, 0, -617, -354, 0, 0, -622, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, -2, 34, 0, 6, 0], [0, 0, 0, 0, 418, 429, 0, 0, 0, -29, 0, -11], [0, 0, 0, 35, 0, 0, 0, -70, -32, 0, 10, 0], [0, 0, -1473, 286, 0, 0, 594, 0, 0, 0, 0, 0], [29280, -894, 0, 0, 756, -756, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 576, 603, 0, 0, 0, 67, 0, -27], [40992, 234, 0, 0, 1284, -1284, 0, 0, 0, 0, 0, 0], [0, 0, -5621, 1638, 0, 0, 169, 0, 0, 0, 0, 0], [0, 0, 2651, 2308, 0, 0, 1308, 0, 0, 0, 0, 0], [-8222, 1568, 0, 0, 717, -717, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 916, 868, 0, 0, 0, -24, 0, 48], [0, 0, 5791, -2817, 0, 0, -527, 0, 0, 0, 0, 0], [0, 0, 0, -111, 0, 0, 0, 222, -50, 0, 99, 0], [0, 0, 0, 0, 1508, 1494, 0, 0, 0, -256, 0, 14], [0, 0, 0, -24, 0, 0, 0, 48, -35, 0, 46, 0], [-16520, -3270, 0, 0, -1403, 1403, 0, 0, 0, 0, 0, 0], [0, 0, 0, -176, 0, 0, 0, 352, 284, 0, -46, 0], [0, 0, 0, 0, -1361, -1353, 0, 0, 0, 218, 0, -8], [0, 0, -20241, -3102, 0, 0, 1772, 0, 0, 0, 0, 0], [0, 0, 9467, -9410, 0, 0, 3405, 0, 0, 0, 0, 0], [0, 0, 0, 0, -2935, -2785, 0, 0, 0, 66, 0, -150], [0, 0, 0, -94, 0, 0, 0, 188, 651, 0, -114, 0], [-19140, 2318, 0, 0, 1068, -1068, 0, 0, 0, 0, 0, 0], [0, 0, 0, 146, 0, 0, 0, -292, -568, 0, 156, 0], [0, 0, 0, 0, -5088, -5139, 0, 0, 0, -19, 0, 51], [0, 0, 0, 0, 686, 438, 0, 0, 0, -355, 0, 248], [0, 0, 0, 85, 0, 0, 0, -170, 646, 0, 370, 0], [0, 0, 0, 165, 0, 0, 0, -330, -1734, 0, -285, 0], [0, 0, -33057, -465, 0, 0, 3797, 0, 0, 0, 0, 0], [0, 0, -14897, 23882, 0, 0, -588, 0, 0, 0, 0, 0], [-131952, -4838, 0, 0, -8988, 8988, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 666, 493, 0, 0, 0, -421, 0, 173], [0, 0, 0, -377, 0, 0, 0, 754, 546, 0, -372, 0], [157811, -3509, 0, 0, -13965, 13965, 0, 0, 0, 0, 0, 0], [0, 0, 0, -102, 0, 0, 0, 204, 1393, 0, 378, 0], [0, 0, 0, 0, -9966, -9948, 0, 0, 0, -648, 0, -18], [0, 0, 34539, 39635, 0, 0, -405, 0, 0, 0, 0, 0], [-1210716, -2746, 0, 0, -4111, 4111, 0, 0, 0, 0, 0, 0], [0, 0, 0, -643, 0, 0, 0, 1286, -1060, 0, -118, 0], [0, 0, 0, 0, -997, -411, 0, 0, 0, 394, 0, -586], [508145, 2445, 0, 0, 1811, -1811, 0, 0, 0, 0, 0, 0], [0, 0, -38189, -34122, 0, 0, 3596, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6427, 7091, 0, 0, 0, -124, 0, -664], [0, 0, -94705, 9534, 0, 0, -11186, 0, 0, 0, 0, 0], [0, 0, 0, -548, 0, 0, 0, 1096, 450, 0, -1848, 0], [0, 0, 0, 0, 8988, 8334, 0, 0, 0, 1620, 0, 654], [0, 0, 0, 0, -6102, -6406, 0, 0, 0, -2477, 0, 304], [0, 0, 0, -1413, 0, 0, 0, 2826, -2112, 0, -33, 0], [0, 0, 0, 0, -16378, -16494, 0, 0, 0, -222, 0, 116], [0, 0, 23275, 19844, 0, 0, 22974, 0, 0, 0, 0, 0], [-791288, 37546, 0, 0, -39804, 39804, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1208, -654, 0, 0, 0, 2074, 0, -554], [0, 0, 0, -68, 0, 0, 0, 136, 2326, 0, -1848, 0], [0, 0, -107145, 1209, 0, 0, 32249, 0, 0, 0, 0, 0], [0, 0, 0, 0, 23511, 23193, 0, 0, 0, 222, 0, 318], [0, 0, 0, 482, 0, 0, 0, -964, 3791, 0, -1288, 0], [0, 0, 161375, 4849, 0, 0, -16359, 0, 0, 0, 0, 0], [-2871232, 258, 0, 0, 42029, -42029, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -14082, -13986, 0, 0, 0, -773, 0, -96], [-178052, -44530, 0, 0, 21420, -21420, 0, 0, 0, 0, 0, 0], [-2777597, -20557, 0, 0, 8511, -8511, 0, 0, 0, 0, 0, 0], [0, 0, 0, -84, 0, 0, 0, 168, 1141, 0, 576, 0], [2901220, 39470, 0, 0, 1653, -1653, 0, 0, 0, 0, 0, 0], [0, 0, 0, -559, 0, 0, 0, 1118, 5046, 0, -924, 0], [0, 0, 0, 0, -24298, -25539, 0, 0, 0, -1163, 0, 1241], [0, 0, 0, -320, 0, 0, 0, 640, 6606, 0, 2460, 0], [0, 0, 157891, 52136, 0, 0, -1992, 0, 0, 0, 0, 0], [-4622301, 31019, 0, 0, 23579, -23579, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 19236, 19728, 0, 0, 0, 4938, 0, -492], [-238912, 45346, 0, 0, 28596, -28596, 0, 0, 0, 0, 0, 0], [0, 0, 56679, -66408, 0, 0, 33911, 0, 0, 0, 0, 0], [0, 0, -265657, -97916, 0, 0, 20712, 0, 0, 0, 0, 0], [0, 0, 0, 744, 0, 0, 0, -1488, -15370, 0, -306, 0], [0, 0, 137627, 144075, 0, 0, 81259, 0, 0, 0, 0, 0], [0, 0, 0, -2643, 0, 0, 0, 5286, 2992, 0, 1467, 0], [0, 0, 0, -448, 0, 0, 0, 896, -8543, 0, -608, 0], [0, 0, -58189, -17126, 0, 0, -9951, 0, 0, 0, 0, 0], [-3108012, -67506, 0, 0, -41556, 41556, 0, 0, 0, 0, 0, 0], [2666658, -47544, 0, 0, 31056, -31056, 0, 0, 0, 0, 0, 0], [0, 0, -169653, 53286, 0, 0, 62536, 0, 0, 0, 0, 0], [-2860244, -906, 0, 0, -76356, 76356, 0, 0, 0, 0, 0, 0], [0, 0, -325713, -111954, 0, 0, 99208, 0, 0, 0, 0, 0], [0, 0, 0, 0, -12761, -16653, 0, 0, 0, 6322, 0, 3892], [0, 0, 148183, 144358, 0, 0, 88908, 0, 0, 0, 0, 0], [-3783541, 95979, 0, 0, -69985, 69985, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6144, 0, 0, 0, -12288, -2085, 0, 2784, 0], [0, 0, 0, 0, -57448, -59874, 0, 0, 0, 2142, 0, 2426], [0, 0, 37219, -427996, 0, 0, 8574, 0, 0, 0, 0, 0], [0, 0, 0, 0, -58014, -57732, 0, 0, 0, 420, 0, -282], [0, 0, 0, 3681, 0, 0, 0, -7362, -21760, 0, -2664, 0], [-3419283, -125823, 0, 0, -17685, 17685, 0, 0, 0, 0, 0, 0], [0, 0, -353073, 105666, 0, 0, -122993, 0, 0, 0, 0, 0], [0, 0, 0, 0, -105876, -102798, 0, 0, 0, 1165, 0, -3078], [0, 0, 0, 0, 4808, 3199, 0, 0, 0, -2279, 0, 1609], [0, 0, 0, -507, 0, 0, 0, 1014, 8646, 0, 33, 0], [0, 0, 0, 564, 0, 0, 0, -1128, 9460, 0, -2006, 0], [2969711, -15409, 0, 0, 128179, -128179, 0, 0, 0, 0, 0, 0], [0, 0, -297737, -186876, 0, 0, -154274, 0, 0, 0, 0, 0], [0, 0, 286587, 119231, 0, 0, -131913, 0, 0, 0, 0, 0], [0, 0, 0, 0, 19252, 14746, 0, 0, 0, -4701, 0, 4506], [0, 0, 0, 2188, 0, 0, 0, -4376, 19927, 0, 438, 0], [2171870, 128620, 0, 0, -42207, 42207, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -62176, -55833, 0, 0, 0, -4097, 0, -6343], [0, 0, 0, 0, -29296, -27608, 0, 0, 0, 2299, 0, -1688], [0, 0, -175501, 398060, 0, 0, 109578, 0, 0, 0, 0, 0], [0, 0, 0, 3695, 0, 0, 0, -7390, -15842, 0, -2525, 0], [3552706, 78736, 0, 0, -107179, 107179, 0, 0, 0, 0, 0, 0], [-12885508, 27678, 0, 0, -81972, 81972, 0, 0, 0, 0, 0, 0], [0, 0, 0, -4769, 0, 0, 0, 9538, 49576, 0, 2346, 0], [0, 0, 919635, 171915, 0, 0, 5323, 0, 0, 0, 0, 0], [0, 0, 0, 0, -48125, -51555, 0, 0, 0, 1976, 0, 3430], [0, 0, 0, 1450, 0, 0, 0, -2900, 4851, 0, -4470, 0], [0, 0, -250037, -102473, 0, 0, 66543, 0, 0, 0, 0, 0], [0, 0, 0, -7674, 0, 0, 0, 15348, -13350, 0, 1266, 0], [0, 0, 0, 0, -92399, -100677, 0, 0, 0, 6932, 0, 8278], [8209876, -11026, 0, 0, -240276, 240276, 0, 0, 0, 0, 0, 0], [9082658, 194192, 0, 0, -45408, 45408, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 7238, 14624, 0, 0, 0, -12921, 0, -7386], [0, 0, -471073, 4530, 0, 0, -286790, 0, 0, 0, 0, 0], [0, 0, 0, 0, 208318, 205904, 0, 0, 0, 281, 0, 2414], [1666866, -155880, 0, 0, 171120, -171120, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1838, 0, 0, 0, 3676, 9217, 0, 2542, 0], [6076114, 195784, 0, 0, 132905, -132905, 0, 0, 0, 0, 0, 0], [0, 0, -291581, 168822, 0, 0, -157091, 0, 0, 0, 0, 0], [0, 0, 361211, 464536, 0, 0, 185826, 0, 0, 0, 0, 0], [-3380644, 33886, 0, 0, 442425, -442425, 0, 0, 0, 0, 0, 0], [0, 0, 0, 9212, 0, 0, 0, -18424, 9168, 0, 3882, 0], [0, 0, 0, 0, -100284, -99432, 0, 0, 0, -1833, 0, -852], [0, 0, 0, 0, 10552, 4796, 0, 0, 0, 28706, 0, 5756], [0, 0, 0, -5579, 0, 0, 0, 11158, 4920, 0, 711, 0], [0, 0, 540639, -24932, 0, 0, 21987, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9117, 19161, 0, 0, 0, -21996, 0, -10044], [13868257, -13083, 0, 0, 2023, -2023, 0, 0, 0, 0, 0, 0], [0, 0, 731479, -427296, 0, 0, 129032, 0, 0, 0, 0, 0], [0, 0, 634675, -198289, 0, 0, 45591, 0, 0, 0, 0, 0], [0, 0, -65013, 416658, 0, 0, 11948, 0, 0, 0, 0, 0], [0, 0, 0, 5031, 0, 0, 0, -10062, -51562, 0, 3816, 0], [0, 0, 0, 2889, 0, 0, 0, -5778, -14332, 0, -21316, 0], [14753507, 344267, 0, 0, 385675, -385675, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -126668, -111999, 0, 0, 0, 4355, 0, -14669], [-9926188, 179710, 0, 0, 478860, -478860, 0, 0, 0, 0, 0, 0], [0, 0, -2027313, -191980, 0, 0, -261846, 0, 0, 0, 0, 0], [0, 0, 0, 0, -68740, -67960, 0, 0, 0, -26322, 0, -780], [0, 0, -812885, -750540, 0, 0, -149923, 0, 0, 0, 0, 0], [0, 0, 0, -1799, 0, 0, 0, 3598, -18880, 0, -7509, 0], [0, 0, 0, 0, -26474, -14187, 0, 0, 0, -15275, 0, -12287], [0, 0, 665075, 89713, 0, 0, 73515, 0, 0, 0, 0, 0], [0, 0, 0, -7852, 0, 0, 0, 15704, 62344, 0, -16472, 0], [0, 0, 0, 0, -233234, -226632, 0, 0, 0, -25865, 0, -6602]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_320_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_320_6_c_l();".
// 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_320_6_c_l(:prec:=12)
    chi := MakeCharacter_320_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_320_6_c_l();".
// 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_320_6_c_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_320_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![3504384, 0, 158544, 0, 796, 0, 1]>,<11,R![-4638399528960000, 0, 121093324800, 0, -654656, 0, 1]>],Snew);
    return Vf;
end function;