#The table of elliptic curves was taken from:
#
# - https://lmfdb.org
# - http://www2.math.uu.se/~astrombe/emaass/emaass.html
#

import yaml
import os
import mpmath
from utils.utils import numbers_to_yaml
from utils.utils import real_interval_to_sage_string
from utils.utils import blur_real_interval

path = 'data/Number_theory/Spectral_parameters_of_Maass_forms_of_level_1/'

prec10 = 100 #relative precision in base 10

RIFprec = RealIntervalField(prec10 * 3.4 * 2)

#loads global variable 'data':
#load(os.path.join(path,'maass_newforms_level_1.sage')) 

Rs = []

#Data from LMFDB:
with open(os.path.join(path,'maass_newforms_level_1.sage'),'r') as f:
	for line in f.readlines():
		if line.startswith('['):
			level, weight, conrey_index, R, symmetry, fricke_eigenvalue = line.strip('[]').split(', ')
			Rs.append(R.strip())
		
#print("Rs:",Rs)

#Data from http://www2.math.uu.se/~astrombe/emaass/emaass.html:
Rs[0] = '9.5336952613535575543442352359287703238212563951072519823757904641353489912983477817692555099754353664930447678582858545070606684438141868197806345007851003097788057757671669696423050885797142015768815935050701451547502559739566719000743313709274267349296605800972091052856305888136582622667109683761586794914917460293896700320835477858034157046862997871498614745363318521200089234322574479539883140600449156860306645071551311701119944888917488393891108286792402303054832149058548235003257130318083783608565210751456881267194214603007027640334195578226229118537680493994517252345202639328313233656511787057153488536010148769505862484018056152530170186610930153652729227434751205894580112587775104763684918913225700255338336954768552453549840792022673757208320181558524923193699289367581772269902856643633445753642064559809807505636133543338782349591525548320089604377224026583033544565844377646222676081439293760029646298441111152081467139294731507541320134650681429646627198632396161937629689674179305706375297879659676178399483907791134176190776024'
Rs[1] = '12.173008324679677849527951176395548123982471673099947900413598940859445360826608874026076101199140832638759595404699524333249193551311375431211296188831489043801548343390481240675732008474760057151025932295098323172331776467075309159231313136191022499612963790045338225382595760532204026679627200392570588153090018433984354696227713030812156512443444676987521472510992920642389712027201517801189495520423571106043849905255488894328388995364990333304622304810463644210972571574390294965607424794228427901751201099649904081631994932974712600341461726243755149399828018752019886305754006414153982650702536109384973947635921037446078113413001784404594114128283822146731951632434208231882807751420363423429909134971941254901536001853089334338633055830964035444861728681104567416289068956067934539626281497652329373439704048805250442013622753095045197880839341374133303405356310551176950754821764924040933662476316974112831481635466615377186273996019384169424466982570719737804217002862920283243306182071978335641488534576781779699222945838749785257982188'
Rs[2] = '13.779751351890738944243673281517712597155132568793487069252388221614450333539970094157831609557427576719389697516128744399928311090623728418274852217424475694646388038712220756501172641654742174506259957609635449533699631602174671551329842386409475066077338613482123435406587831810742009269782000845636739704644144420410097429528240630760510484740112435363844601357338214659375359631473694383503315514410662774309843655774213445252208805038812410029297526025385729100270109762806089680372810996416336146403667103609242100820406768244558810617354721200370291890228802337608104537751837874642432784247950048309185035652757361274403656248442309496312654585416076724041550200003590274908802431431614495987037924140227935111968290403979329435630334880483599257543497910005672056032327420199526886666140530236198595304671289473129131863031432246165725470308070596327790428842565371520749945458977653549025346734169754984024584979760956671879825255899936607429048444698517338800344833696233960997913571085893326361974508188102577448743772412197211279432061'
Rs[3] = '14.358509518259812779866942569037165495614385899196766247815202266632011206792885819013195493581924093302984035923177862336241745063986728203164204172971427566695608273558032695392939185641321797417080282832609224289026542467215224239240048237093315063558944428975733794816238609484520684560499827726912236778504023803692136388354599304586947171603692027379064102935175194328760232984676481965471246445874803298729760902863407391536162462158137840639335734193413119336190801661479909896626266977214580249911887996094489418112101593873600495435045241385571212082855499377774940980317301609917558043437560368741624955004951062056480935343913837105858620909477693418793807602517210593945843908527229296150849479659908698759765717932134595686944008740591147004871118507485541038742800900602599532665646147744923953189441444499358549596278010994579999349052429010965562337321594368370060419355510961153861512624461484053896642328826964149445281426495583490652265384987250821742165258661602644878932390891731809489417100142686893496813955525349823989629412'
Rs[4] = '16.138073171521030580198294285986003945631442885413786958273827121759470305427552793555566427238370348127926093891809983788029782768556061457169580705845726742534918600209105482732853874878400508142343341087313755301490858271419591574630627005601302567862294463957047382013605974139763189457309298880778142217098784661146139510133273762182776265060741989629499539023450110289661080882811556845725827439129934459952113208918254029161908573876499533819929384036800159510012988923179969764901582381277020476196229323233494862906919198591007765382351740518409133594091016228607700521820151757370101162302534198958492527924749250390085312147383824677739628582705825296506671141111848577901110737922265035905729183583717134627151729441258268641660525200081426134146649475785940592281033583060179089895464083183446114010616146128275999890195943095845556708549670201248377460611385788428237702805832645405541013411593092569674962350317024401031884859415349844907078868779989604599892733828857488216344109263896532800467042487657341253797621849740213581161298'
Rs[5] = '16.644259201899819943526274559368655701431681459972319289076514550018290176189704244091022468276701795972577359987648701528808426480525594986291726623729538696536024775141911311161184302811237408044772969486050397286575666735621713790333207215208250839391338727922616611037041942140620231028941055923066562274604869271300425748703740466932985750194706486161680996381917069945398047309139974293475024075247291171727318243421808776561620629187699815423009022013613944959524358113304128471171448434304203645060209325178231222912032728613565653955218733864962803711112669331810532370248909102491049411620500834567200129945022485214950192643881039924616376524182576823908924907205311440919744025899152406028579266863758487006028525426096274170651829386598881812264796963798749849487444555923499933473362388076946367275884194911497630099436774430361281824212326732361867354646802885337265461710348983377998008716905928876564106953179631949845227652534160389434474986043430706330206326983645441170062858499128714814121954374791076785026716692239952167960670'
Rs[6] = '17.7385633810573778932173263615465461720054800532512918807962468981021415775998037727919764023386065314690351298535892370958074592057242703215375901813651585011706065843351765867768316203622470075869659727953567267939699984550690909072381813316003567884654106449629192754826171368666177792396221349420260290054698705436253956925492693327008520848808481960363685910335129517841087416082212590229631874948009048361234983585898342147386237147513936064608008633875305180047490519924444853616432574091695375053828971311157523019632910530240976764195159195630828681263844133155731216602213017950735556147402586369712290417198481974499224217081818520377336240292905656893302027111544858102099463801429067960094094973298815105632296691187089961230520071074340114940096183588373211769007294367323430094757822243368148655926974420680922547135635499646726979990342057566494249583873842789487193582724802859025759382277324717632383862419505868824411386795413968559787192351313448497734760305484298633694957009166589709615716057178847533467896114441687058400633'
Rs[7] = '18.1809178345307038603183082681933139382499245654178178710679250877452686291067049008924782055775086893981722948794048171667186950425325639802230347769624951654882700206785799402699099433275420561756567545832439529413416686942521871623066647830189489720219870847783724880386635665466322066215278594256896777922363740284120230440183960688053664600571657526699015786630490448397075387970044509290827474420307976992946414784167245977520659280909874682945279903797251243502780405470533784123334676955936241337598458703064024606070311237600241235960741099794803232429178859820860174514726799627023412224911784184323343689552591908576826444701760175360987295387725632516633884858600616044411183396294084887037718292271026949393161119872639749646095715176917320579670015295540739469872431543511117696819616316038775603244870902415322958683094971152430488049155841332727832858574094047000424040098097788580269936357867392250819491238359066973653734327482706279843381443594832875970774934015192777763660922240971739843902978241846496532735948398023426897464'
Rs[8] = '19.4234814708282551916337803572085244415855256007633319757794759378626261134705961296947480791604794137570847184098353190608072058942312424373252224274689225660906808540753041537564113223579809029417938972322262309125513332321695300125819118581736099639863212319042496132029921929816152684176043181109690979163810116498653103629820900033243488863302156522341493913685120303794864244315646412077358205105981147381212557686948108951788911985768534688836540153829679832532408594187924775120995096436307934515479043226552435991973694794043436190785202820920792413930747523708626700482644338817657364056010478501728920693468228604431492127050204458936838353593441710197527851671687598147045048754030209670526469996194839629861861750993568477724746045135794103508384715351410135682130482114354912859512265261291997357386986781144588067731849041836114189690959221880631688999704995811408536989542207554837449721512458562397101141329466678983615325798827059373687472130655636151664006282288376459523493563288850799073644309662941340539372127695214264660575'
Rs[9] = '19.4847138547410133641285264278728762187740623853452066130858075155722603965932065799164215265317800107383876595639081413465578901910236979523684082167242436786822665629880137120487688940044482270407544026311388982132704761455742999218454032441450690903182600309217996283574998091893610524735569783543641228301045892669160864249145680849411294536945777448049210580239379515764821600601942895996130866257920717898002755698426611548363483374915827590273519469395982136081180214653695492262157461286340023046660241177658001235507342060436936805351112533164232989962401480082600630946369148889636472293992588235154100980667956571697235319437735606479309460445813682570355326620046539946926487422372817987598933592362861780734374216956037631501373350330566414576116159497037240932202288339574383787530268586440167950579209363508942552023649593792873714079501120137326189627345536606638974070790393366401119287652484164037111070718603848689771504911744994793989959813322385757787843812390524194900764409012938641929283870619505272244336340983622700566078'


numbers = {R[:5]: R[:101] for R in Rs}

filename = os.path.join(path, 'numbers.yaml')
yaml.dump(numbers, stream = open(filename, 'w'), sort_keys = False)
