
// Make newform 370.2.g.e in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_370_g();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_370_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_370_2_g_e();".
// 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_370_2_g_e();".
// 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 := [256, -5632, 61952, -61952, 28432, 24512, 76384, -44248, 13544, 4848, 13826, -7362, 2009, 278, 760, -394, 103, 4, 8, -4, 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, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2780131920531890535246494294656, 14401782890505048046582010304, -165391697792224818875997047104, 305482225879943223308228263344, 931876817379099048873589099456, 157415255898134013007951756848, -165030687632668403603285449208, 105372179869081409512877561604, 133559490223096577245216999658, 31062992751010546982387785706, -29175408561133510819234239833, 13182068741183440504070962720, 7044362608370133737895169704, 1745574471448265825046051302, -1593584551933006605971772423, 620522616202978404413005718, 79399887171604448836402476, 19269839637431983087912600, -16487377417880247286093917, 5800353585176790349222994], [385587653571791129143305009152, -30616587340564366693942063654752, 54859181054684452815048155689312, -11927341769725448503300944833712, -20905422720389314548231275891248, -45083387390745716754584846548704, 45380917281208923291364221569864, 9485890082039520584652664893828, 753649384157312038683471343576, -8087546108522413698378500879228, 5872622937469098540944532262484, 1099492457155905520089054009065, 282798913786012314078712237218, -429843866589899571362470845146, 220590436692757290553281702684, 13694130617013893070551932891, 4058419180518852331298810652, -4462579968291835172305293250, 1860562921401592242213947286, -30775524341942221760039387], [-274486764186518951421943667456, 2991466062065031304187000606976, -2431103949714157686458075742016, 5404015373906038406266796245296, 2075024228952655279326898668544, 3843900710558888520774043252032, -2187618293854881752995863078392, 1332867173253574902913828229856, 410116886946676734842353210232, 698555859118268193855159035714, -381375997141222412565409387622, 146639211186111063983721634555, 23374716745539846312098185146, 38439468746971409148251848268, -20750330509073814823693689702, 6391049701758067616306544917, 312941500416588119573434284, 405774774062199385299192100, -212660727526153025824891908, 58965535466715046805445971], [-407377493554315161342566440960, 4532898255698113979669152399872, -5569922443009033818754630410368, -201410447929852860690911950704, 750171236110010090998087209920, 5175004472392345696328444294592, -4166681755218838677755870586040, -567657370146433961267620096776, -270410622149643175304753948624, 930142943161423582420074998578, -566147245317696689897771281522, -41714002773446007923742335575, -35452356312683959263948005610, 51038527329400230457439727688, -23697486223827497214960946650, 731670231343349085649238839, -439281985215117765019522716, 532403137436334512570649560, -213650269245471113610567540, 18154565221821476922021601], [-9113615277610461812557473664, 1986197896548149554339067330640, -2083891127748416396152701158528, 778022383087486863225954617952, 2220632939865827546424610225736, 4500577108966250925160329873144, -331340134586639017517734793728, 299419834964243548726704813906, 237772381330604896594751262646, 649141437496138814753958695245, -74852243579806058576659567594, 39942197503083663320975844710, 4111314114575758254096898794, 25365085728566592151926026911, -6233193243387346550059866228, 1944075675793343386838946370, 20398710211289303626949508, 225654985339877215089427265, -72113549127850094650249452, 18534789732040946004155782], [5909068406683621289610257323744, -42653961110487070374221153664, 169480020590083690981979476544, 5859846252100225331988121082976, 24801361228134131914660677192544, 11262932169038299903129472035392, 1548296420876556292725712247308, -3370840625248871700397363025124, 2662719482944415622419928933362, 1127887580432424549734931603854, 306481675688630310570221343568, -503393164878863900117652283145, 43841175613040913947773866996, 8887646598908923350876165308, 17243331706865020128549789948, -14842746392872344694515214063, -142509557388575588274195246, -106151413960923047407313000, 186568521536668945043365242, -104721642704376918236449849], [-15484116356697965221169018509184, 71059703127144060337603973748864, -95796105220095201444942302297824, 6977266989122133410098095189744, 15015776918520422803350709258816, 83623887518615979919320855619248, -85144006061317966734863112767288, -8603081468255876060709395976216, -376836709861984784367277126252, 16862096684225482744574215202546, -12499749727999445551130068114508, -348030723104072060945598199505, -192217912464673776846241314606, 1018030060853944707568301264852, -565384779445988216210937542328, 51647845636237614942708291413, -2134861375190894140431236724, 11029639238955330413530664800, -5279993314562049312221864562, 747527247206630316708622619], [3439239847664078432049633684736, 5069835740118388431842954250624, -17532068427828111069243232021024, 8876476968012808646240138363664, 4242679883150413710570536590336, -1247800819830162230286661846512, -21108893223847476053079316002248, 1651205308719393779871281914824, 1725795779948603374805425434548, 892832004772497027346952331086, -2982162217366331168375483018648, 288660568639796321839927606345, 146694545972205503383500819774, 108548287293584861238909071612, -122673036106349147795073892788, 21807987487694422898909352683, 1980881204545561136364079956, 1414665193604538859829053000, -1109053524533563691628140802, 237502635151889443195395989], [-3047242750038385627095760077056, 63994692983423428557652291782336, -61021781559231547837843571279056, 32560210476417916321626517235376, 30126008381418078119425149410944, 79712369970297710377526578698792, -46110454474110060106922747541992, 14932182254689695008509560366576, 5896648955900470836408217238162, 14443053696776008143527532589904, -7746999687021515968705142739707, 2177452487256151461181960794205, 336514939230769332958018799646, 794132250669654322210201573058, -416061235804056256056528630777, 110750975528586322480746081737, 4694630464476558001267061904, 8365050653302564206110847700, -4229890154947643569162423833, 1072213922603589653991967451], [-4276675357577767908161324353088, -37236993415355846812769581843872, 67110145253705555795249327293712, -31401613128851972213891842024752, -28271347502270190932929221410288, -45789450614570429608728396428184, 63374190022336396460640529822384, -12446951516508428468900808260052, -7172307029879338853237180962474, -10778580943645999940646824146858, 9966695482412695645925883808639, -1986842105609379324609303608735, -495948935949549470401527043842, -715894388728310504531203706116, 486314150318308597802166894129, -114208314740632749299721608599, -6806834814825664756063056108, -8062181969742112173592618250, 4755377072911068972933553941, -1150201174983150433663008877], [-5242098660710589737355120402688, 65101673405651764926075088480128, -151581938642270846547322029529088, 51805428419789712808186426912848, 16574021133276381480062830440512, 40173828272742756115395773063616, -143878971297938890247688590279416, 31166246498879096066885066447448, 12922621017459190157290975356976, 13940083258229213783530790934442, -21402663594507880762794890881186, 4891500117178324170811908541565, 1219379031977996588898024188958, 1122402061108856995072173206584, -972758229431358175865361617946, 249617246826004498397887129651, 17470569534470052945016546692, 13451011858587072046050147800, -9293195052479812056724191084, 2416504293012447523611560773], [16216601907471084252272079139712, -278225527707336658499579616607872, 265019010848938824952127149407712, -91143408071345811279037198221552, -120616217167488612456039163626688, -340536451669165891181840408658384, 189806921436809528094488549992184, -28973670157446321492895713114552, -16460486764757997320480521053524, -59819682669604960110277382217458, 30495203412888067495336854788564, -5065025306502496384298235450835, -586381788066327226686995313642, -3195844546929979463404095546716, 1575416078457534914521938497904, -325401394000686701387064635249, -8106343681147596935999848908, -33231057970177047939546184600, 15715494292874776663271490066, -3392827119547412823372563327], [150376255902832735990583377216, -35662174653261684741971201399520, 34742682330408584756873690332592, -17304318637533407106365692664208, -21568567003098000339082599764144, -47970187795107895020151289163096, 21634857160665125771597842028152, -7726292571873633543180510805524, -3485386785039344935243153466434, -8303382357686075829678307505950, 3705168975122773737667107543781, -1113066732231008191939124317505, -161840387923241652242648038506, -435211349883333258193793540044, 207722197000716142429193663067, -56293146301588723068815442505, -2142474929113406847262975512, -4488888947613089857762034270, 2143667670242344379996904303, -543955237053333783513966163], [5293784686985805781315182863296, -142344931178433662518346714234016, 168872067670230443405084920071056, -98162411332652082640935020441136, -72495815839124522650258246345904, -176871321593491392783437782412712, 134228242091989793635746040881472, -47116717490081809700096967012396, -17757423178188701018213434956562, -34528126434040184900327888279074, 22273752507772986326537729266027, -6712068498119353284877382460005, -1190462027587230515981805363486, -2021691892946686153648735155688, 1172630029639692617052986437557, -328629881295179425841163976897, -16710793396253370597714823044, -21826543284049793815418582150, 11854570682874520782390018453, -3135969293497370487644828611], [-3139785312995627535085921917728, 63333304136385908474015784944208, -59231922086835664964409677766688, 27725552169750670915167002071008, 28860210975724144469936691188872, 80259893777311370067743708464536, -43341763264075689319190535125396, 8756971494638215174095520033818, 3658229364584330386342432949726, 14117586561015609122019987400937, -7026495565763495073626395227581, 1339555523294650082237742653665, 111131998074380248634390715798, 753738306957882548885859734789, -365010149309211501403733543901, 78491357448203855456355189161, 1604433236325041571375440682, 7825873051315937126527429825, -3651877679166395840635936329, 800719765753327410019907183], [793433364810148880423586246784, -8732958891716413443314162012544, 8838417735353116557227646726944, -4203693475909164583784665069584, -3032641428838508735254578449216, -10791278175371554711387850719728, 5799328888861109836940928343288, -2444920596487580752753635919944, -772924007345244857192365003588, -1953360410630372140115292955966, 999810901883614231005129479788, -352461780297814564533296782745, -53117920878752338108150851894, -107372908285649088804780718972, 55970700256229057158530737328, -16778796384184757567425172323, -767018175874080076647250236, -1131191104544162746331590400, 578766627559173954356632662, -157945728781378625753630509], [3047242750038385627095760077056, -63994692983423428557652291782336, 61717757987931987912404081988256, -32560210476417916321626517235376, -30126008381418078119425149410944, -79712369970297710377526578698792, 46110454474110060106922747541992, -14932182254689695008509560366576, -5896648955900470836408217238162, -14443053696776008143527532589904, 7746999687021515968705142739707, -2177452487256151461181960794205, -336514939230769332958018799646, -794132250669654322210201573058, 416061235804056256056528630777, -110750975528586322480746081737, -4694630464476558001267061904, -8365050653302564206110847700, 4229890154947643569162423833, -1072213922603589653991967451], [13059794177039396047856054651648, -274223313400554911461251198915648, 287085575922714051420640039829488, -129741803953088307841587827943888, -131069906326486688825045327037952, -358391297519470350061120527841896, 181213629678143431020401121423536, -69266857926391755446124058745328, -25648417626535072515737286865826, -62998828225906631115304881128972, 30579747173808548824553535981941, -9974898477751493263555396635415, -1463080344490419565692861899718, -3355963093892768685407451842354, 1685900811988810683227713632591, -482371193964732193692801654491, -20372304332514286000829189052, -34928336249580838223598736600, 17343937658579306826117333639, -4578953037327424540733270513]];
    Rf_basisdens := [1, 1, 695976428700440074560510709200, 2783905714801760298242042836800, 2783905714801760298242042836800, 371187428640234706432272378240, 278390571480176029824204283680, 1391952857400880149121021418400, 5567811429603520596484085673600, 927968571600586766080680945600, 2783905714801760298242042836800, 2783905714801760298242042836800, 5567811429603520596484085673600, 5567811429603520596484085673600, 556781142960352059648408567360, 2783905714801760298242042836800, 695976428700440074560510709200, 135800278770817575524002089600, 695976428700440074560510709200, 2783905714801760298242042836800];
    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_370_g();"
function MakeCharacter_370_g()
    N := 370;
    order := 4;
    char_gens := [297, 261];
    v := [3, 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_370_g_Hecke();"
function MakeCharacter_370_g_Hecke(Kf)
    N := 370;
    order := 4;
    char_gens := [297, 261];
    char_values := [[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, 1, 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, 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, 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, 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, 0, 0, 0, -1], [0, 0, 1, 0, 0, 1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0], [2, 0, 1, 1, -1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, -1, 1, 0], [-1, 0, 0, -1, 1, 0, 0, -1, 0, 0, -1, 1, 0, 0, -1, 1, -1, 0, -1, 1], [0, 0, -1, -1, 1, 0, -1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [-1, 1, 1, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1, -1, 0, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0, 0, -1, 0, 0, 0, 0], [-1, 0, -1, 0, 1, -1, -1, -1, -1, 0, -2, 0, 0, -1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0, 1, 0, 1, -1, 2, -1, 0, 1, 0, 1, 0, 0, 0, -1], [0, 1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, -1, -1], [-1, 0, 1, 1, -1, 0, 0, 0, -1, 0, -1, 0, 0, -1, 1, 0, 1, 0, 0, 0], [0, 1, 2, 1, -1, 0, 1, 1, 1, -1, 0, 0, 1, -1, 0, 0, -1, 0, 0, 1], [1, 0, -1, 0, 0, -1, 0, 1, 0, 1, 1, -1, 1, 0, 0, -1, 0, 0, 0, -1], [1, 1, 0, 0, 0, -1, -1, 0, 2, 1, 1, 0, 1, 2, 0, 0, 0, 0, -1, 0], [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 1], [0, 0, -1, 0, 1, 0, -1, 0, -2, -1, 0, -2, 1, 0, -1, 0, 0, 1, 0, 0], [0, 2, 1, 0, 0, 0, 0, 0, -1, 0, 0, -2, 0, -1, 0, -2, 0, 0, -1, 0], [0, -2, 0, 1, -1, -1, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [1, 2, 3, 1, 0, 0, 1, 1, 0, -2, -1, 1, 2, 0, 0, -1, -1, 0, 0, 1], [1, 2, 1, 0, -2, 0, 0, -1, 0, -2, -1, 0, 2, 0, 0, 0, 0, 0, -1, -1], [-4, 1, 1, -1, -1, 1, -1, 1, -1, -1, 0, -1, -1, 0, -1, 0, 1, 1, 1, 0], [0, 0, 1, 0, -1, 0, 1, 0, -2, -1, 6, 2, 1, 1, 1, 1, 0, 1, -1, 0], [2, 0, -1, -1, 0, -1, 1, 0, 2, 1, 0, 2, -1, 1, 0, -1, -1, 0, -1, 0], [-2, -2, 0, 0, 0, 0, 1, 1, 1, 0, -2, -1, 0, 1, 1, -1, 0, 0, 0, -1], [0, -1, 2, 0, 0, 1, 1, -1, 1, -1, 0, 0, -1, 1, 0, 0, 0, 0, -1, 1], [2, 3, 2, 0, -2, 0, -1, -1, 0, -1, 0, 0, 1, 0, 1, 0, 0, -1, 0, 0], [-1, 4, 0, 0, 0, -1, 0, -1, -1, 1, -1, 0, 1, -1, 0, 0, 0, 0, -1, 1], [-1, 0, -2, -1, 1, 0, -2, -1, -1, 0, -1, 0, 0, -1, -3, 0, -1, 0, 1, 1], [2, 2, 1, 2, -2, 0, 0, 1, -2, 0, 2, 1, 0, -2, -2, 1, 2, 0, 1, -1], [-2, 0, -2, -2, 1, -1, 0, -1, 1, 0, 0, 1, -1, -1, 0, 1, -1, 0, -1, 0], [0, 0, -1, 0, -1, -2, -1, 0, -1, 1, 4, 1, 1, -2, 1, -2, 2, 1, 1, -2], [0, -1, -1, 0, 0, 0, -1, 0, -1, 1, -2, 1, -1, 1, -1, 1, 0, -1, -2, 0], [-2, -4, -2, -1, 1, -2, -2, -1, 0, 2, -2, 1, 2, 0, -2, 1, -1, 0, -1, 1], [-2, -4, -2, -3, 5, -1, 0, -1, 2, 0, 0, 2, -2, -1, 0, 1, -1, 0, -1, 0], [4, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, -2, 3, 2, 0, -3, 0, 0], [-2, -1, 0, 0, 0, -1, 1, -1, 1, 1, -2, 2, 1, 1, 2, 2, 0, 0, -1, 1], [1, -1, 1, 1, 3, 0, 1, 0, 1, 1, -1, -2, -1, -1, 0, 2, -1, 1, 1, 0], [2, 0, 0, 1, 0, -1, 1, 0, 0, 1, 0, 0, 1, 1, -1, -1, -1, 1, -1, 0], [-1, -1, 1, 0, -1, 2, 0, 0, -2, 1, 1, 1, -1, 2, 0, -1, 0, 0, 2, 0], [0, 2, -1, 0, 3, 0, -1, 0, -2, 1, -2, 2, -1, 2, -1, 2, 0, -1, 0, 0], [-1, 2, 0, -2, 2, 2, 2, -3, -2, -2, -1, 0, -2, -2, 0, 0, -2, 0, 0, 3], [1, -2, -4, -2, 0, -1, -2, 0, -1, 2, -1, 0, -2, 1, 0, 0, 2, 1, 0, 0], [-4, 2, 0, 3, -3, 1, 0, 3, 2, 0, 0, 2, 2, -2, 3, 2, 1, -3, 1, 0], [2, 1, 3, 0, 1, 0, 0, 1, 2, -1, -2, 0, 1, -2, 0, 0, 0, 2, 2, 1], [-4, 1, -1, -2, 2, -2, -1, -1, 1, -1, 0, 1, 1, 2, 0, -2, -2, 0, -2, 0], [0, 1, 0, -2, 1, 0, 0, 0, -1, 0, -2, 1, 2, 1, -1, 1, 0, -1, 0, 2], [0, -1, 0, -2, 2, 1, 0, -1, -1, -1, 0, 2, -1, -1, 0, 2, -2, 0, -1, 1], [-3, 3, 1, 1, -1, 1, -1, 1, -2, -1, -3, -3, -1, -2, -1, -3, 1, 0, 1, -1], [3, 0, 0, 0, -2, -2, 0, 2, 1, 0, -3, 3, 0, -1, 0, -3, 0, 2, 0, 2], [1, -2, 0, -1, 1, 2, 0, -2, -1, -2, 1, 2, -2, -1, -1, 2, -1, 0, 1, 2], [0, 1, 0, 2, -2, 2, -1, 2, 0, -1, 0, 0, 1, 3, 0, -3, 2, 0, 2, 0], [2, -2, 1, 3, -3, 1, -2, 1, -2, -1, 2, -4, -1, -2, 2, -4, 3, 0, 3, -1], [0, 0, -1, -1, 0, -1, -1, 0, 1, 1, 4, -1, 1, 2, -1, 2, 1, -1, -2, -2], [-6, -3, 3, 2, 0, 2, 1, 0, -3, 1, 0, -3, -1, -3, 0, 3, 2, 0, 2, 0], [0, -2, 1, 2, -3, 0, 1, 0, 2, -1, 4, -2, -1, -2, -1, -2, 0, -1, 1, -2], [-1, 3, 5, 1, -1, 1, 1, 1, 1, -3, 1, -1, 3, -1, 0, 1, -1, -2, 1, 1], [8, -4, -3, -1, 4, -1, 1, 0, -2, 1, 0, -2, -1, 2, 0, -2, -1, 0, -1, 0], [-4, -3, -1, -1, -5, 2, -1, 1, 0, 3, 4, 1, -3, 0, 0, -1, 1, -2, 3, 1], [-4, 1, -1, 0, 2, 2, 0, -1, -1, -1, 4, -1, 1, 1, 0, 1, 0, -1, -2, -1], [-3, 0, 1, 0, 0, -1, -1, -2, -1, 1, -3, 2, 1, -1, 4, 2, 0, 0, -2, 2], [0, 2, 2, 0, 2, 2, 2, 0, 3, -2, 4, -3, 0, -3, 0, -3, -2, 0, -2, 0], [4, 0, 0, 0, 0, 1, 0, 1, -6, 0, -4, 1, 0, 6, 0, -1, 0, 0, 0, 1], [-1, -3, -1, -1, -1, 2, -1, 2, -4, 3, 1, 3, -3, 4, 0, -3, 1, 1, 3, 2], [-6, 0, -1, 0, -4, 0, 0, -2, 3, 0, 6, -2, 0, -3, 0, 2, 0, 2, -1, -2], [0, 1, -3, -3, 5, 1, -3, 0, 0, 3, -4, 0, -1, 0, -4, 0, -1, -4, -1, 2], [0, -1, 2, 2, -3, 0, 2, 0, 1, -2, 4, -1, 0, -4, -1, -4, 0, -1, 1, -2], [-6, -2, -1, -2, 1, 0, 1, -3, 0, 1, 0, 0, -3, 1, 0, -1, 0, 0, 0, 0], [0, 1, 0, 1, 0, -1, 0, 0, -2, 0, -4, 2, 0, -2, 2, -2, 1, 2, 3, 4], [4, -4, 1, -5, 5, 1, 2, -3, 1, -1, 4, 1, -1, 1, -2, 1, -5, 0, -5, 3], [3, -3, 0, 1, -1, 1, -1, 1, 4, -1, 3, 2, -1, 4, 2, 2, 1, 0, 2, -1], [0, -2, -1, 1, -3, -2, -1, 0, 2, 1, 8, -2, 0, -1, 1, -1, 2, 1, 0, -2], [0, 0, -1, -1, 0, -1, -1, 0, -3, 1, -6, 3, 1, 3, -1, 3, 1, -1, -3, 0], [-7, -1, -1, -3, 3, -1, 2, -2, -3, 1, -7, -1, 1, -3, -6, -1, -3, 0, -3, 2], [-5, 2, 2, 0, -2, -2, 0, -1, 1, -2, 5, 1, 2, -1, 0, -1, 0, -2, 0, -1], [3, -4, 0, 2, -2, 0, 0, 1, 1, 0, 3, -5, 0, 1, -2, -5, 2, 0, 2, -1], [-1, -1, -2, -1, 1, 1, -1, 3, -1, 1, 1, -3, -1, 1, 0, 3, 1, 2, 0, 3], [0, 2, -1, -1, 1, -2, -1, 0, 0, 1, 4, 0, 2, 1, -1, 1, 2, -1, -4, -2], [8, 6, 3, 3, -3, 0, -3, 2, 1, 0, 8, -2, 0, 1, 2, -2, 3, 0, 0, -2], [0, -1, 1, 0, 0, 2, 3, -1, -4, -2, 0, -4, -2, -4, -2, -4, 0, 0, 1, 1], [-2, 2, 2, 1, 5, 2, 1, 1, 3, -2, 2, 2, 2, -3, 0, -2, -1, -2, -1, 1], [-3, 3, 7, 2, -10, 3, 2, 1, 0, -3, 3, -3, 3, 0, 0, 3, -2, -1, 2, 1], [2, 10, 0, 3, -3, -2, -2, 0, -2, 2, 2, -4, 2, -2, 3, -4, 3, 0, 1, 0], [5, -9, -2, -1, 1, 1, 1, 0, 5, -1, 5, 1, -1, 5, 0, 1, -1, 0, 2, 0], [8, -1, -3, -3, 3, -1, -1, -7, -3, -1, 0, -3, -1, -2, -3, 2, -1, 3, -1, 0], [-4, 1, -1, -1, -3, 2, -1, 1, -1, -1, 4, -4, 1, 1, 0, 4, 1, 0, -1, 1], [0, 2, -2, -2, 3, -1, -2, 0, -1, 2, 6, 1, 1, 4, 1, 4, 1, 1, -1, -2], [-10, 5, 1, 0, -2, -4, 1, -1, 2, 1, 0, 2, 3, -1, -2, 1, -4, 2, -4, 0], [0, -5, -2, -1, 1, -1, -4, 1, 3, 1, 0, 3, 1, 3, 1, 3, -1, 0, 0, -1], [2, -2, -2, -1, 3, 1, -2, -2, -5, -2, 0, -5, 0, 5, -1, -5, 1, 1, 1, 0], [-2, -1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, -3, 1, 3, 0, -1, 0, 0], [5, 3, 3, 0, -1, -1, 0, 1, -1, -3, -5, 0, 3, 1, 0, 0, 0, 0, 0, 1], [0, -2, 1, 0, -1, 2, 1, 0, 1, -1, -14, -1, -1, -2, -3, -2, -2, -3, 4, 2], [-8, 2, -2, 1, -3, 1, 0, 4, -1, 0, 0, -1, 0, -1, 2, 1, 1, -2, 1, 0], [0, 2, 1, -1, 2, 1, 1, 0, -1, -1, 0, 1, 1, 1, -2, 1, -1, -2, -4, 1], [0, 5, -1, -3, 7, 1, -1, 0, -1, 1, -6, 1, 1, 1, 0, 1, -1, 0, -1, 0], [8, -2, -3, 0, 2, -2, 0, 0, -3, 2, -8, 0, -2, 3, 0, 0, 0, 2, -1, 0], [0, 1, -1, 1, 3, 1, -1, 0, -1, 1, -2, 1, -3, 2, -3, 2, -1, -3, 1, -1], [0, 2, 3, 5, -2, -1, 3, 0, 0, -3, 8, 0, -1, 0, 1, 0, 1, 1, 2, 2], [0, 4, 2, -2, 4, 2, 2, 0, 0, -2, -8, 0, 2, -3, -3, -3, -2, -3, -2, -1], [-3, 2, 4, 2, -2, 2, 2, -2, 4, -2, 3, -2, 2, -4, 0, 2, -2, 4, 0, -2], [-6, -4, -4, -2, 3, 3, -2, -1, -1, -2, 0, -1, -3, 1, 2, -1, 3, -2, 3, 0], [-10, 1, -2, -2, 0, 0, -1, 0, -1, -1, 0, -1, -1, -2, -2, 2, 0, 2, 0, 0], [0, -3, -4, -1, -2, -3, -4, 0, 0, 4, 0, 0, 0, 3, 2, 3, 3, 2, 1, -3], [8, 0, 0, 0, 2, 2, 0, 2, 3, 0, -8, 4, 0, -3, 0, -4, 0, -4, 0, 2], [0, 1, -2, 3, 2, -1, -2, 0, 2, 2, 4, -2, -4, 0, 0, 0, 1, 0, 1, -4], [-8, 0, -1, 0, -2, -2, 4, -3, 1, 4, 0, 1, -2, 0, -1, 0, -2, 1, -2, 0], [0, 2, -1, 1, -1, -4, -1, 0, -4, 1, 16, 4, 2, 3, 0, 3, 4, 0, 0, -4], [2, 0, 0, -5, 5, 0, -2, -3, 3, 0, 2, 2, 0, 3, -4, 2, -5, 0, -5, 3], [4, -5, -4, -2, 0, -5, -2, -1, 5, 5, -4, 6, -5, -5, 0, -6, 2, -2, 3, -1], [12, -2, 0, 1, 1, 1, 0, -1, -2, 0, 0, -2, 0, -2, 1, 2, 1, -1, 1, 0], [-7, 6, 0, 3, -3, -4, -3, 3, 3, 4, -7, -2, 4, 3, -1, -2, 3, 0, -1, -3], [0, 3, -2, -2, 1, -3, -1, 1, 5, -1, 0, 5, 2, 4, -2, -4, -3, 2, -3, 0], [-10, -4, 1, -3, 2, -1, 3, -3, 4, 3, 0, 4, -5, -1, 1, 1, -1, -1, -1, 0], [0, -1, -1, -3, 0, 0, -1, 0, 2, 1, -4, -2, 2, 1, -1, 1, 0, -1, 2, 4], [-2, 1, -3, 1, 2, -2, -1, -4, -2, -1, 0, -2, 4, -1, -3, 1, -2, 3, -2, 0], [12, 2, 1, 2, -8, 5, 1, 4, -5, 1, 0, -5, -4, 0, 2, 0, 5, -2, 5, 0], [-11, 1, 0, -3, 3, 3, 2, -2, -6, -3, -11, -4, -3, -6, 0, -4, -3, 0, 0, 2], [-4, 3, 0, 2, 0, -3, 2, -3, 1, -3, 4, 0, 3, -1, 0, 0, -2, 2, -5, -3], [3, -7, -6, -1, -1, -1, -1, 1, 3, 7, -3, 5, -7, -3, 0, -5, 1, -2, 2, 1], [0, 1, -3, -1, 3, -1, -3, 0, 4, 3, 0, -4, -1, -3, 1, -3, 1, 1, -1, 1], [0, 0, -3, -3, 4, 1, -3, 0, -2, 3, -4, 2, -1, -3, -1, -3, -1, -1, 1, 3], [-2, 2, -1, 0, 8, -4, 0, -2, -1, -2, 2, 0, 2, 1, 0, 0, 0, 0, -3, -2], [-13, 1, 0, -2, 2, 1, -1, -4, 3, -1, -13, -3, -1, 3, -2, -3, -2, 0, -1, 4], [0, 1, -1, -2, 4, 2, -1, 0, -3, 1, 2, 3, -1, 1, -3, 1, -2, -3, -4, 2], [0, 4, 4, 5, -1, -1, 4, 0, 3, -4, -2, -3, 0, 2, 2, 2, 1, 2, -3, -4], [10, -6, 4, 1, -1, 2, 2, 3, 4, -2, 10, -1, -2, 4, 0, -1, 1, 0, -1, -3], [-6, -4, 2, 5, 1, 1, 2, 3, -3, 2, 0, -3, 2, -3, 1, 3, 1, -1, 1, 0], [0, -8, 2, 0, 0, 2, 4, 0, 0, -2, 0, 0, -2, 0, -3, 0, 0, 0, 0, 0], [0, -3, -2, -1, 2, 3, -2, 0, -2, 2, -20, 2, -4, -2, -2, -2, -3, -2, 3, 2], [6, 0, -2, -3, 3, -3, 0, -2, 0, 0, 0, 0, 0, -1, -2, 1, -3, 2, -3, 0], [0, -4, -3, -4, 0, 1, -3, 0, -2, 3, -8, 2, 0, 6, -1, 6, -1, -1, -1, 5], [-9, -1, -5, -5, 1, -3, -5, -3, 1, 1, 9, 1, -1, -1, 0, -1, 5, 2, 1, -3], [2, -4, -3, 2, -2, 1, 2, -1, 3, 4, -2, 0, -4, -3, 0, 0, -2, 0, -1, -1], [-5, -8, -5, -5, 5, 4, 0, -2, -3, -4, -5, 2, -4, -3, -5, 2, -5, 0, 4, 2], [0, 5, 0, -2, 10, 5, 0, 0, -4, 0, -16, 4, -3, 2, -4, 2, -5, -4, -2, 6], [-1, -7, -11, -5, -1, -3, -5, 0, 0, 7, 1, 4, -7, 0, 0, -4, 5, -2, 1, 0], [-8, 2, 0, -3, 3, -1, -4, 2, 3, -4, 0, 3, 2, 2, 0, -2, -1, 0, -1, 0], [-8, -5, -1, 2, 4, 0, 1, 0, -7, 1, 0, -7, 1, -1, -2, 1, 0, 2, 0, 0], [5, 1, 2, 1, 15, 4, 1, 2, -4, -1, -5, 1, 1, 4, 0, -1, -1, 1, 0, 2], [14, 2, 2, 5, -3, -1, 2, 5, 4, 2, 0, 4, 4, 3, 2, -3, -1, -2, -1, 0], [1, -1, 4, 2, -6, 2, 2, 0, -1, 1, -1, 3, -1, 1, 0, -3, -2, -4, 3, 0], [-4, -7, 3, 2, 2, 4, 1, 0, -6, 1, 0, -6, -3, -2, 2, 2, 4, -2, 4, 0], [6, 0, -3, 3, -2, -1, 3, 0, -4, 3, 0, -4, 1, 1, -1, -1, -1, 1, -1, 0], [2, -6, 2, 0, 6, 0, 0, 5, 2, 0, 0, 2, 0, 3, 1, -3, 0, -1, 0, 0], [7, -3, -4, -3, 3, 0, -3, 0, -3, 0, 7, -2, 0, -3, -4, -2, -3, 0, 1, 0], [-6, 4, 2, 1, -10, -1, 1, -1, -4, -4, 6, 2, 4, 4, 0, -2, -1, 4, -3, -1], [16, -1, 3, 2, -2, -3, 3, 1, -1, 3, 16, 2, 3, -1, 4, 2, 2, 0, -4, -1], [0, -2, -2, -2, -2, -2, -2, 0, 1, 2, 4, -1, 2, 0, 1, 0, 2, 1, -1, -7], [6, -8, 0, -1, 9, -1, 0, -5, 0, 0, 0, 0, 0, -1, 0, 1, -1, 0, -1, 0], [0, 2, 2, 4, 8, 0, 4, 2, 5, -2, 0, 1, 2, -5, 0, -1, -4, 3, -4, 2], [10, 7, 4, -2, -3, -2, -2, -4, 3, -2, 0, 3, 2, -1, -2, 1, -2, 2, -2, 0], [5, 4, 6, 1, 0, 4, 1, 3, -1, -4, -5, 0, 4, 1, 0, 0, -1, -6, 1, 3], [5, 6, 6, 1, 2, 4, 1, 3, 1, -6, -5, -2, 6, -1, 0, 2, -1, -6, -1, 3], [-4, 2, 0, 1, -1, -1, 0, -5, -1, 0, 0, -1, 2, -3, -3, 3, -1, 3, -1, 0], [4, 6, 2, 3, -3, -2, -7, 0, 0, 2, 4, -1, 2, 0, 6, -1, 3, 0, -1, 0], [8, -8, 0, 2, 5, 0, 3, 2, 3, 3, 0, 3, -1, 0, 3, 0, 0, -3, 0, 0], [-10, 1, 6, 4, -5, 4, 0, 1, -2, 0, 0, -2, 0, 3, 1, -3, 4, -1, 4, 0], [2, -8, 1, -2, 2, 2, 0, 0, -2, -2, 2, 3, -2, -2, -4, 3, -2, 0, -1, 0], [18, -2, 0, 4, -4, 4, 2, 10, -2, 2, 0, -2, -2, 5, 5, -5, 4, -5, 4, 0], [-12, 12, -1, 1, -8, -1, -3, -3, -2, -3, 0, -2, 5, 2, -2, -2, -1, 2, -1, 0], [0, 2, 2, 0, 0, 0, 2, 0, -2, -2, 14, 2, 2, 5, 3, 5, 0, 3, -2, 1], [14, 0, 3, 1, -1, 5, 2, 3, 5, -5, 14, 3, -5, 5, 4, 3, 1, 0, 3, -3], [3, -6, 6, 3, -3, 0, 3, 3, 1, 0, 3, 2, 0, 1, 7, 2, 3, 0, -3, -3], [-16, -4, -3, -4, 7, -6, 3, -2, 6, 3, 0, 6, -1, 0, 1, 0, -6, -1, -6, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_370_g_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_370_2_g_e();".
// 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_370_2_g_e(:prec:=20)
    chi := MakeCharacter_370_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_370_2_g_e();".
// 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_370_2_g_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_370_g();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![256, 5632, 61952, 61952, 28432, -24512, 76384, 44248, 13544, -4848, 13826, 7362, 2009, -278, 760, 394, 103, -4, 8, 4, 1]>],Snew);
    return Vf;
end function;