How to use mul method in wpt

Best JavaScript code snippet using wpt

june22SRModels.py

Source:june22SRModels.py Github

copy

Full Screen

...6def add(a,b):7 return (a+b)8def sub(a,b):9 return (a-b)10def mul(a,b):11 return (a*b)12def div(a,b):13 return (a/b)14def square (a):15 return (a*a)16def cube (a):17 return (a*a*a)18def ln(a):19 return (np.log(a))20def exp(a):21 return (math.exp(a))22#modelDict = dict.fromkeys(["aabcfn_nft","aabcfn_ft",23# "ampfe_nft", "ampfe_ft",24# "cafn_nft", "cafn_ft",25# "cffn_nft", "cffn_ft",26# "ckfe_nft", "ckfe_ft",27# "cmqfe_nft", "cmqfe_ft",28# "cmqgfe_nft", "cmqgfe_ft",29# "cpffn_nft", "cpffn_ft",30# "ctcfe_nft", "ctcfe_ft",31# "cvffe_nft", "cvffe_ft",32# "cvfn_nft", "cvfn_ft",33# "sub_cffn_nft", "sub_cffn_ft",34# "sub_cle_nft", "sub_cle_ft",35# "sub_cqfe_nft", "sub_cqfe_ft",36# "uvfe_nft", "uvfe_ft"])37 #"sub_cle_nft", "sub_cle_ft",38 #"sub_cqfe_nft", "sub_cqfeft",39 #"uvfe_nft", "uvfe_ft"])40modelDict = OrderedDict()41modelDict["aabcfn_nft"] = ("add(mul(cube(add(add(mul(ln(add(mul(div(add(mul(square(add(mul(size, 4.43349955561), -133.398813815)), 1.00000000032), -6.57500571721e-07), add(mul(size, -25644.2057259), 455803137.882)), 6543892.86191), 17.4083372601)), 1.00284171734), -0.010210794622), add(add(mul(ln(add(add(mul(size, 0.636941593958), -9.55412434521), add(mul(div(add(mul(cube(size), 0.595807979601), 1364.08839403), add(mul(size, 0.999999859765), 1.72087716948)), 5.92658401946e-09), -4.3058461308e-07))), 1.03979393372), -0.125729303345), add(mul(size, 1.0335144459), 0.046280480941)))), 4.68681143019e-11), 2.44037772749e-07)")42modelDict["aabcfn_ft"] = ("add(mul(mul(add(add(add(mul(size, 1.00493293798), 1.19396323052), add(mul(size, -1.94357933085), 2.19476194084)), add(mul(size, 1.93861391747), -0.765191285305)), add(mul(ln(add(mul(mul(add(mul(square(add(mul(size, 0.26006594007), -9.78767918425)), 1.0), -5.5891527765e-14), add(mul(square(add(mul(size, 0.260070801294), -9.78779727318)), 5.2156426279e-08), 0.74908151607)), 1.00000000006), 0.13457675858)), 0.999999981682), 6.08941173004e-09)), -5.79642931111e-08), 4.78328868069e-06)")43modelDict["ampfe_nft"] = ("add(mul(mul(add(add(mul(ln(add(mul(size, 1.00347807085), -0.0923938307393)), 0.999999999214), 2.64584053808e-09), add(mul(mul(add(mul(size, 10.7830330952), -293.166928913), add(mul(size, 3.70663317202), add(mul(ln(add(mul(size, 1.00000295901), 1.23066060684e-06)), 1.42036624104e-05), -80.1455742027))), 8.94977649728e-05), -0.0804710254183)), add(add(mul(ln(add(mul(ln(add(mul(size, 1.52801423307), -7.24792087226)), 1.00000000001), -2.97856756663e-11)), -283.464021941), 329.555965141), add(mul(square(add(mul(size, 24.1400984448), -235.57142399)), 1.0), -3.744207185e-12))), 3.7571162568e-09), 0.000115059034464)")44modelDict["ampfe_ft"] = ("add(mul(mul(add(mul(square(add(mul(mul(add(mul(mul(add(mul(cube(add(mul(size, 3.6828192811), -28.258728457)), 1.0), 7.03559552992e-09), add(mul(size, 0.000110067050703), -0.000626221408583)), 0.00331547941671), 24.2609260665), add(add(mul(size, 7.36538292762e-05), 1.63922272608e-13), add(mul(ln(add(mul(cube(add(mul(size, 0.99999999964), 3.60396788046e-09)), 1.03949109508), -1039.36864964)), -1.91926413294e-09), -0.000389344379156))), 0.999999999999), 3.85743008567e-15)), 1.00004405581), -1.56232076928e-07), add(mul(square(add(mul(mul(add(mul(size, 0.0992504372586), -3.20639130708), add(mul(size, 0.977780822155), 0.736984705949)), 0.708364324658), 2.54296588227)), -4.79300179e-06), 1.00273938593)), 1.00026377561), -1.26045179344e-05)")45modelDict["cafn_nft"] = ("add(mul(mul(add(mul(mul(add(mul(size, -0.0149774004549), 0.952510353391), add(mul(size, 1.00000000291), -9.67465534799e-08)), 0.0597294607765), 0.618445140291), add(mul(cube(add(mul(size, 1.00336861834), -0.00383129731134)), 0.990373273913), -0.774990614953)), 5.76589462692e-07), 0.000136865727613)")46modelDict["cafn_ft"] = ("add(mul(cube(add(mul(mul(add(add(size, 3.91100876298e-11), add(mul(size, 1.0), -6.40687497071e-13)), add(mul(mul(add(mul(mul(add(mul(ln(add(mul(size, 0.999999785969), 8.19771152594e-06)), 0.99999999997), 1.03028786068e-06), add(mul(cube(add(mul(size, -0.000242436208593), 0.0327034511717)), 0.999531736521), 5.96476509696e-09)), 0.995202330711), 2.2310948208e-07), add(mul(size, 0.999730391205), 0.0103308930809)), 0.998430490101), 7.27739626935e-08)), 1.0), 0.0191028907718)), 13.3683223784), 0.000116174432679)")47modelDict["cffn_nft"] = ("add(mul(mul(add(mul(div(square(size), add(mul(mul(add(mul(square(add(mul(size, 0.0355126563124), -1.27777830426)), 1.21352554928), -0.00507383019037), add(mul(mul(add(mul(mul(add(mul(mul(add(mul(size, 382.555239659), -1978.08190977), size), 0.999999999186), 0.000332798837299), add(mul(square(add(mul(size, 0.00144851866999), -0.00534848250631)), -0.00223177708233), 0.000107329831071)), 1.10636702231), -3.90354829836), add(mul(size, 4.96817019711e-07), -2.29943959585e-06)), 0.999999950253), 2.3369133145e-11)), -1399263211.7), 2390498.90197)), 1.07532130487), -1.29974495774e-05), add(size, add(mul(size, 1.00000000041), -1.50045483779e-08))), 0.999159421609), -1.76481129224e-05)")48modelDict["cffn_ft"] = ("add(mul(add(add(mul(mul(add(add(mul(square(size), 1.35661677505e-05), -6.86586106327e-07), add(mul(size, -3.24546203963e-07), -0.00667279384923)), ln(add(mul(mul(add(mul(size, -0.137680896817), 25.8581921629), add(mul(cube(add(mul(size, 1.00001318198), -0.000507203134131)), 9.37177653125e-07), -0.00248087915204)), 16.2663331573), 19.9369383259))), 1.00000000723), -1.13046558119e-10), div(add(mul(ln(add(mul(size, 0.999999877386), -4.29406442469e-07)), 1.39830227066), -0.955500275141), add(mul(square(size), 1.00252933333), -0.561821759275))), 0.99999999995), 6.45167946844e-13)")49modelDict["ckfe_nft"] = ("add(mul(div(add(mul(mul(add(mul(cube(add(mul(size, 1.00000000741), add(mul(div(add(mul(mul(add(mul(square(add(mul(size, 1.09965019287), -1.74137527413)), 1.0184733668), -2.08903915067), add(mul(square(add(mul(size, 0.00789770159231), -0.241285265016)), 2.02968069242), -0.00100707752981)), 0.999970309402), 4.61675637176e-05), add(mul(size, 0.911613479057), 1.02622932249)), 0.348121348585), -0.00284203033463))), 0.999999527311), 0.0145331939569), add(mul(size, 1.00774345995), -0.256620955243)), 2.93714619885e-07), -9.52239354685e-05), add(add(mul(size, -0.974880466372), 0.00967893627775), add(mul(add(add(add(mul(size, 1.00000002276), -5.13536336213e-07), add(mul(size, 0.99995442331), 0.0019508363879)), size), 0.987364072638), 0.41521454255))), 1.0), -1.61919669147e-18)")50modelDict["ckfe_ft"] = ("add(mul(div(add(div(add(mul(cube(add(mul(size, 1.0), -1.52448507353e-12)), 1.0000000004), -8.74834422079e-06), 0.999599945113), 10.5156369762), add(mul(mul(add(mul(mul(ln(add(mul(mul(ln(add(mul(size, 1.00000164854), -4.79306332147e-05)), add(mul(size, 1.0000027773), -8.08636260695e-05)), 0.999999983411), -0.0766149882955)), add(mul(mul(add(add(mul(size, 0.999999999552), 1.40705409928e-08), mul(add(mul(mul(add(mul(size, 1.00163401971), -0.0476690556643), add(mul(size, 2.85156560667e-07), 0.999714767389)), add(mul(size, 1.00022246444), -3.53984498983e-09)), 2.61221416537), add(mul(size, -0.209498135592), 13.6291312397))), add(mul(size, 1.00002091603), -0.000616741380642)), 0.999999989208), 0.00206059447101)), 0.00600315318767), -18220.881033), size), 1.01008361628), 7222161.96438)), 1.0000000026), -8.60351711998e-12)")51modelDict["cmqfe_nft"] = ("add(add(add(mul(div(add(mul(div(add(mul(square(add(mul(size, add(mul(mul(add(mul(size, 0.999999070536), -0.000479804384585), add(mul(size, -2.79252800181e-07), 1.66072381509e-05)), 0.999998482645), 3.68266596456e-10)), -0.000564792072376)), 0.942475571159), 2.10764612215e-06), add(add(mul(size, -1.09866406945), 2.69219554061), add(mul(size, 0.999999993753), -1.15504687463e-06))), 0.999999999994), 9.93496427463e-15), size), 0.999621765378), -7.73511544053e-11), add(mul(mul(add(mul(ln(add(mul(size, 1.01963747916), -0.555702636629)), 1.00193675241), -0.00700758061777), add(mul(cube(add(mul(size, 0.0017929977616), 0.00233462730837)), 0.999880158861), 3.099343927e-08)), 1.0), 3.09934392693e-08)), -3.09934392694e-08)")52modelDict["cmqfe_ft"] = ("add(mul(cube(add(add(mul(div(add(mul(square(add(mul(size, 0.00151192550308), -0.0502477529117)), 224.413964173), -0.0157369970429), add(add(add(mul(cube(add(mul(size, 1.17440088741), -1.82429018981)), 0.999999977432), 2.01111317285e-05), add(mul(size, -2.1309675209), 31.5497334551)), add(mul(size, -0.369725939228), -15.5546478841))), 1.00000000021), -2.88263351505e-14), add(mul(mul(mul(add(mul(size, 2.18582003591e-06), 0.000211540024891), add(mul(size, 1.0), -5.49395188823e-13)), add(mul(ln(add(mul(size, -5363.74488758), 248961.204543)), 1.002647878), -0.0278843726017)), 1.0), -2.312076103e-13))), 1.0), -3.47846615073e-20)")53modelDict["cmqgfe_nft"] = ("add(mul(cube(add(mul(mul(add(mul(mul(size, add(mul(mul(add(mul(square(add(mul(size, 0.999930271443), 0.0022980261486)), -1.72555647704e-10), 4.18208621547e-07), add(mul(size, 1.00005239706), -0.752147782182)), 1.98348353425), -6.9913404913e-06)), 1.00000000019), 0.00412463028816), add(mul(mul(add(mul(size, 1.00000000004), -1.3401479925e-09), add(mul(mul(add(mul(square(add(mul(size, 0.999930640793), 0.00228597379784)), -1.68685294757e-10), 4.08875629114e-07), add(mul(size, 1.0191127111), -0.648642766734)), 2.42589876821), 1.00264873618)), 0.999999999998), -0.0892471683698)), 1.00233305517), -0.000340370160311)), 1.00022255139), -6.28231119672e-07)")54modelDict["cmqgfe_ft"] = ("add(mul(mul(add(mul(mul(add(mul(cube(mul(cube(add(mul(cube(add(mul(size, 1.25234855137), 0.172510617728)), 0.503221860181), 4.98369727452)), 0.999999999999)), 1.16850676049e-51), 1.29304399655e-12), add(mul(size, 0.503221869856), 17.2951843143)), 1.00007342831), 7.33755201116e-08), add(mul(cube(add(mul(size, 1.00000386883), -0.000132711029033)), 1.00062619487), -22.5976790462)), 0.999980251771), 7.34309207159e-08)")55modelDict["cpffn_nft"] = ("add(div(add(add(mul(square(add(mul(square(add(add(mul(mul(add(mul(size, 1.0), -3.64404545102e-14), add(add(mul(ln(add(mul(size, -3.66933339707e+11), 1.47436204098e+13)), 1.00108789213), 3.2539522168e-10), add(mul(size, 2.04921100611e-09), 1.74061331366e-07))), 1.01500471805), -15.2604077063), add(mul(add(0.000587102618764, size), 0.00602524344707), 1.55890005883e-07))), 1.94113650112e-08), -6.9739569368e-15)), 0.999709316583), 2.95544419734e-11), add(mul(square(add(add(mul(mul(add(mul(size, 1.0), 5.72789276479e-13), add(mul(ln(add(mul(size, -4.12436731115e+11), 1.65612210902e+13)), 0.999930310966), 0.00185063265597)), -0.0519976318255), 14.1192001978), add(mul(size, 1.18031540315), -6.69662551744))), 1.79525376397e-08), 1.35900427786e-10)), 0.999677918146), 1.12285897886e-07)")56modelDict["cpffn_ft"] = ("add(mul(cube(add(add(mul(cube(add(mul(size, 0.999624324545), 0.0134443637071)), 0.999999524892), 0.0228317304136), add(mul(cube(add(add(mul(ln(add(mul(square(add(mul(cube(add(mul(size, 0.99997898634), 0.000632276611119)), 1.0), 1.82735800046e-09)), 0.0300299039667), -1921913.81984)), 1.0), 4.85054364575e-12), add(add(mul(square(add(mul(size, 10.8159781975), -342.126493426)), 4.23644117513e-06), -0.0433878016145), add(mul(size, 1.00118543549), 0.000463576885258)))), -0.999998951203), 0.027528188732))), -2.952437292e-19), 4.63494536082e-05)")57modelDict["ctcfe_nft"] = ("add(mul(mul(add(mul(size, -1.97269591473e-07), -1.17567908719e-15), add(mul(mul(add(add(mul(size, -10170826.1162), 781479.45558), mul(ln(add(mul(mul(mul(mul(add(add(mul(size, 1.00635008515), 3.34712576689e-07), add(mul(size, 0.000582657477763), 1.49011611939e-07)), add(size, -0.592930031299)), 5.56067713145), size), 0.999938142807), -5.56193087216)), add(mul(ln(square(add(mul(size, -0.294123771579), -0.654773086204))), 1.38951402726), 0.000274100400143))), add(add(mul(mul(add(add(mul(ln(square(add(mul(size, 1.00000008907), 1.23188940312e-06))), 1.00000102873), -6.24182714043e-06), add(mul(mul(add(mul(mul(add(mul(size, 1.00606003901), -0.158841863235), add(mul(size, 1.0271704184), -0.592926302113)), 5.56355173678), -2652.06189678), add(mul(size, 0.886735643361), -26.2228261075)), 0.999999999999), -412484.599103)), add(mul(size, 0.999999999258), 2.06232864406e-08)), -6.41086493587e-15), -3.49619233624e-22), add(mul(size, -2.93284909669e-17), 9.17494378086e-09))), 0.999352558434), -0.0173946692623)), 0.999928916511), 4.01705553858e-09)")58modelDict["ctcfe_ft"] = ("add(mul(mul(add(mul(square(add(mul(mul(add(mul(size, 0.99999816197), 6.92899081409e-05), cube(add(mul(div(add(mul(square(add(add(mul(size, 3.06206090344), -84.8331412657), add(mul(ln(size), 0.999444221038), 0.00212907951127))), 0.94549571692), 73.2839405001), add(add(mul(size, 1.3333190342), -11.8857891035), add(mul(size, 1.00020009627), -0.00618249157092))), 7.58641022683e-09), 0.00172250581018))), 1.00000004568), 2.40202186933e-08)), 1.04855785748), -2.23477512712e-15), add(mul(size, 173852115.176), 2360684.77182)), 0.999941669844), 1.84325637183e-08)")59modelDict["cvffe_nft"] = ("add(mul(mul(add(mul(mul(add(add(mul(mul(add(mul(mul(add(mul(mul(add(mul(size, 1.00798242334), -0.225274403327), add(mul(size, -1.78587026866e-09), 4.84886547955e-07)), 1.00000000001), -1.02924787409e-05), add(add(mul(size, -110.389344796), 4346.85598175), size)), 1.0), -3.2654925997e-15), add(add(mul(size, -0.999999999777), 0.999034031816), size)), 1.00000000012), 8.33991142678e-11), add(mul(size, 2.00148745442), 0.000902406270154)), add(mul(size, 1.0), 2.93124541912e-14)), 8.54452583812e-07), -1.18285924257e-05), add(add(add(mul(add(size, size), 0.00842039712966), -0.223770223396), add(add(mul(cube(add(mul(size, 0.120868620505), -3.29336490207)), 0.0580623472778), 0.000960017258006), add(mul(size, 0.484559400069), 0.0747225856412))), 8.66999250722e-07)), 0.999034136302), 3.05033344775e-05)")60#modelDict["cvffe_ft"] = ("add(mul(square(add(mul(add(mul(square(size), 0.999768826156), 0.335622990548), mul(add(mul(square(add(mul(size, -0.0487034785634), 3.9158801359)), 0.999971088806), 0.000117201312276), add(mul(size, 1.11672370272e-06), -1.00534276536e-05))), 0.0204960329583)), 0.99984925565), 6.64518829342e-06)")61modelDict["cvffe_ft"] = ("add(add(add(mul(square(add(mul(mul(add(mul(square(add(mul(size, 1.00100461484), 0.0127125882691)), 0.999471627389), 1.04579888926), add(mul(mul(add(mul(square(add(mul(size, -0.048710752975), 3.91616340584)), 0.999471982508), 0.00214054175461), add(mul(size, 1.11675028605e-06), -1.0054441608e-05)), 0.990124057344), 1.37599201995e-06)), 0.999998687468), 0.0204963014669)), 0.994232515204), -3.92185114251e-13), add(add(mul(square(add(mul(size, 0.624208956179), 14.0671291641)), -7.89267006129e-11), 1.34946878453e-11), add(mul(mul(add(mul(square(add(mul(size, -0.0486436472665), 3.92944036795)), 0.999471982508), 0.00214054175461), add(mul(size, 1.11675438271e-06), -1.00545159496e-05)), 8.74364494226e-07), 1.00100461484))), -1.00100443219)")62modelDict["cvfn_nft"] = ("add(mul(mul(add(mul(mul(add(mul(mul(add(mul(size, 0.830956712201), 6.3396074737), size), 0.998544885817), 2.03702337401), add(mul(cube(add(mul(size, 0.995910634632), 0.158791904724)), -4.29894924581e-18), 3.69510912003e-13)), 0.975613237524), 7.92963361448e-16), add(mul(square(add(mul(mul(add(mul(size, 0.981263366795), add(mul(size, -9.87463957458e-11), 0.701646817669)), size), 0.999994705764), 0.00739843153338)), 0.999993762051), 11.7738162254)), 0.995903330544), 9.9418409264e-06)")63modelDict["cvfn_ft"] = ("add(add(add(mul(mul(add(mul(square(add(mul(size, 1.00031173419), -0.0117344051882)), 0.951298360518), 69.1197547636), add(mul(mul(add(mul(cube(add(size, -0.000595780625824)), 0.999997788262), 0.113899321105), add(mul(mul(add(mul(size, 0.99999999351), 2.50276167574e-07), add(mul(size, -7.94936399946e-16), -3.10856264153e-15)), 8.00004224655), 1.54253328464e-11)), 0.999899775872), 2.76656736424e-11)), 0.990888040843), -3.10856264153e-15), add(mul(size, 8.42327371234e-15), 3.5036270884e-06)), 6.13156715071e-14)")64modelDict["sub_cffn_nft"] = ("add(mul(add(mul(mul(size, size), cube(size)), square(mul(size, add(mul(mul(add(mul(size, 0.575430629525), -18.2996233518), size), 0.919051643164), -3.43588976683)))), -3.28789565528e-06), -1593015462.25)")65modelDict["sub_cffn_ft"] = ("add(add(add(mul(mul(add(mul(square(size), add(mul(square(add(mul(mul(add(mul(size, 0.999999991254), 3.61795873702e-07), add(mul(mul(add(mul(size, 0.99969772257), -0.0123923465442), add(mul(size, -2.27296426444), 111.783743051)), 0.0602402607391), 1.03729850555)), 8.72999589633e-09), 1.50462660881e-06)), 0.999893789296), 4.00942030174e-14)), 1.9965834441e-21), add(mul(size, 0.991911078571), 0.311826880055)), 24.5893248642), 4.50011014159e-09), add(mul(size, 4.74074327167e-09), 3.121449643e-06)), -5.42101086243e-20)")66modelDict["sub_cle_nft"] = ("add(add(add(mul(square(cube(add(mul(mul(size, add(mul(square(add(mul(cube(add(mul(size, 0.00491687523981), 0.0758066780256)), 5.71016626886), -0.0941225631411)), 0.0114463722012), 0.00489895923267)), 0.999809757177), 0.0763997546004))), 1.00003368003), -6.504288439e-11), add(mul(square(add(mul(cube(add(mul(size, 0.00491682954199), 0.0758110440391)), 5.70784191468), -0.0940976740147)), -2.14026879186e-07), -9.48436841265e-09)), -3.57212089769e-15)")67modelDict["sub_cle_ft"] = ("add(add(mul(mul(add(mul(mul(add(mul(mul(mul(size, add(mul(size, 1.0), -4.18359302526e-11)), add(mul(square(add(mul(mul(add(mul(size, 0.999999997371), 6.45248274069e-08), add(add(mul(ln(size), 20.3890898227), -97.5667079857), add(mul(size, 0.98405332422), 6.76375901381e-07))), 0.999957170107), -0.27924518326)), 0.999587643043), 49.6961512023)), 8.87815859279e-09), 0.663612870305), add(mul(size, 0.964586519229), 1.09804512891)), 0.703336078064), 4.18847604811e-08), add(mul(size, 1.20273367682e-10), 1.51685182861e-07)), 1.00275593583), -1.32620579735e-08), add(mul(mul(div(add(mul(mul(size, size), 0.999976725924), 0.0232422654603), add(mul(square(add(mul(size, 76.2985746582), 1668.87292619)), -0.405881851579), 11914831.9711)), add(mul(cube(add(mul(div(add(mul(add(mul(size, 0.999999977423), 7.2825826066e-07), size), size), add(div(-85.6049677402, add(mul(square(add(mul(add(mul(size, 1.0000000126), -2.77331360465e-07), add(mul(cube(size), -0.508409413935), 23567.0021439)), -0.695450614599)), 7.97512198494e-14), 1.19032248839e-07)), 7052.15445665)), -0.0430718293552), -1.51718461782)), -1.37579446509e-05), 0.999537282612)), 1.0), 7.95914708354e-14))")68modelDict["sub_cqfe_nft"] = ("add(mul(mul(add(mul(mul(add(add(mul(mul(add(mul(square(add(mul(size, 1.0), -0.000343882365895)), 1.00434632122), -0.038745592528), square(add(mul(size, 0.998961188758), 0.0332394602944))), 2213.84238967), -485362.209311), add(mul(ln(add(mul(size, 1.00004549009), 1.04737207585)), 0.00276206763945), 1.00003843304)), mul(add(mul(size, 0.998246781483), -6.75715048541e-06), add(mul(size, 0.000260334592807), -0.0013429582219))), 1.00013793023), 4537.21900261), add(mul(square(add(mul(size, 1.00000001875), -6.4861524982e-07)), -3.65603609818e-16), 5.12631404854e-13)), 0.99466443657), 2.41010393162e-07)")69modelDict["sub_cqfe_ft"] = ("add(mul(mul(add(mul(mul(add(mul(size, -0.00143400928299), 0.192668568201), add(add(mul(ln(size), -30.4494399573), 79.8398031156), add(mul(size, 1.0), -1.65616451348e-12))), 1.00015936421), -0.000160268119818), add(mul(square(add(mul(ln(add(add(mul(size, 0.996554813033), 0.100019666845), add(mul(size, 1.00000000002), -8.74573246827e-10))), 0.00610346645355), -0.0185466487027)), 0.900209329593), 3.0707082449e-19)), 1.10213042672), 2.18713268452e-07)")70modelDict["uvfe_nft"] = ("add(mul(div(add(add(mul(cube(add(add(mul(square(add(mul(size, 1.00013395432), -0.00510151190226)), -0.00529553913634), 1.25855172445), add(mul(square(size), 1.0), -6.11246563892e-13))), 0.999020005665), -2.70429932184), add(mul(square(add(mul(size, 1.0005066916), -0.0160498687386)), 111.805482578), 2273846.63508)), div(add(mul(size, 0.999985691967), 0.000543507977593), add(mul(mul(add(mul(size, 1.0000194161), -3.36193253279), add(size, -0.000752218516417)), -1.40437597098e-15), 3.27171658898e-12))), 1.00000223223), -2.3400800468e-10)")71modelDict["uvfe_ft"] = ("add(div(add(mul(square(cube(add(mul(mul(size, add(mul(size, -8.45327566575e-05), 0.00890479349107)), 0.997478744915), 0.000540328451827))), 0.990889924729), 6.67391246889e-07), 1.00000000024), -2.21636809383e-14)")72print( "size" + ',', end = "")73for key in modelDict:74 print( key + ',', end = "")75print( )76for size in range(1,100,1):77 #print(str(size) + ',' + str(eval(aabcfn_nft)) + ',' + str(eval(aabcfn_ft)) + ',' + str(eval(ampfe_nft)) + ',' + str(eval(ampfe_ft)) )78 print(str(size) + ',', end = "")79 for key in modelDict:80 # pdb.set_trace()81 #print( key + ',' + str(eval(modelDict[key])) + ',')82 print( str(eval(modelDict[key])) + ',', end = "")...

Full Screen

Full Screen

ngspice_wrapper.py

Source:ngspice_wrapper.py Github

copy

Full Screen

1import re2import numpy as np3import copy4from multiprocessing.dummy import Pool as ThreadPool5import os6import abc7import scipy.interpolate as interp8import scipy.optimize as sciopt9import random10import time11import pprint12debug = False13class NgSpiceWrapper(object):14 BASE_TMP_DIR = os.path.abspath("/tmp/ckt_da")15 def __init__(self, num_process, design_netlist, root_dir=None):16 if root_dir == None:17 self.root_dir = NgSpiceWrapper.BASE_TMP_DIR18 else:19 self.root_dir = root_dir20 _, dsg_netlist_fname = os.path.split(design_netlist)21 self.base_design_name = os.path.splitext(dsg_netlist_fname)[0]22 self.num_process = num_process23 self.gen_dir = os.path.join(self.root_dir, "designs_" + self.base_design_name)24 os.makedirs(self.root_dir, exist_ok=True)25 os.makedirs(self.gen_dir, exist_ok=True)26 raw_file = open(design_netlist, 'r')27 self.tmp_lines = raw_file.readlines()28 raw_file.close()29 def get_design_name(self, state):30 fname = self.base_design_name31 for value in state.values():32 fname += "_" + str(value)33 return fname34 def create_design(self, state):35 new_fname = self.get_design_name(state)36 design_folder = os.path.join(self.gen_dir, new_fname)37 os.makedirs(design_folder, exist_ok=True)38 fpath = os.path.join(design_folder, new_fname + '.cir')39 lines = copy.deepcopy(self.tmp_lines)40 for line_num, line in enumerate(lines):41 if '.include' in line:42 regex = re.compile("\.include\s*\"(.*?)\"")43 found = regex.search(line)44 if found:45 # current_fpath = os.path.realpath(__file__)46 # parent_path = os.path.abspath(os.path.join(current_fpath, os.pardir))47 # parent_path = os.path.abspath(os.path.join(parent_path, os.pardir))48 # path_to_model = os.path.join(parent_path, 'spice_models/45nm_bulk.txt')49 # lines[line_num] = lines[line_num].replace(found.group(1), path_to_model)50 pass # do not change the model path51 if '.param' in line:52 for key, value in state.items():53 regex = re.compile("%s=(\S+)" % (key))54 found = regex.search(line)55 if found:56 new_replacement = "%s=%s" % (key, str(value))57 lines[line_num] = lines[line_num].replace(found.group(0), new_replacement)58 if 'wrdata' in line:59 regex = re.compile("wrdata\s*(\w+\.\w+)\s*")60 found = regex.search(line)61 if found:62 replacement = os.path.join(design_folder, found.group(1))63 lines[line_num] = lines[line_num].replace(found.group(1), replacement)64 with open(fpath, 'w') as f:65 f.writelines(lines)66 f.close()67 return design_folder, fpath68 def simulate(self, fpath):69 info = 0 # this means no error occurred70 command = "ngspice -b %s >/dev/null 2>&1" %fpath71 exit_code = os.system(command)72 if debug:73 print(command)74 print(fpath)75 if (exit_code % 256):76 # raise RuntimeError('program {} failed!'.format(command))77 info = 1 # this means an error has occurred78 return info79 def create_design_and_simulate(self, state, verbose=False):80 if debug:81 print('state', state)82 print('verbose', verbose)83 dsn_name = self.get_design_name(state)84 if verbose:85 print(dsn_name)86 design_folder, fpath = self.create_design(state)87 info = self.simulate(fpath)88 specs = self.translate_result(design_folder)89 return state, specs, info90 def run(self, states, verbose=False):91 """92 :param states:93 verbose: If True it will print the design name that was created94 :return:95 results = [(state: dict(param_kwds, param_value), specs: dict(spec_kwds, spec_value), info: int)]96 """97 pool = ThreadPool(processes=self.num_process)98 arg_list = [(state, verbose) for state in states]99 specs = pool.starmap(self.create_design_and_simulate, arg_list)100 pool.close()101 return specs102 def translate_result(self, output_path):103 """104 This method needs to be overwritten according to cicuit needs,105 parsing output, playing with the results to get a cost function, etc.106 The designer should look at his/her netlist and accordingly write this function.107 :param output_path:108 :return:109 """110 result = None111 return result112"""113this is an example of using NgSpiceWrapper for a cs_amp ac and dc simulation114Look at the cs_amp.cir as well to make sense out of the parser.115When you run the template netlist it will generate the data in a way that can be easily handled with the following116class methods.117"""118class CsAmpClass(NgSpiceWrapper):119 def translate_result(self, output_path):120 """121 :param output_path:122 :return123 result: dict(spec_kwds, spec_value)124 """125 # use parse output here126 freq, vout, Ibias = self.parse_output(output_path)127 bw = self.find_bw(vout, freq)128 gain = self.find_dc_gain(vout)129 spec = dict(130 bw=bw,131 gain=gain,132 Ibias=Ibias133 )134 return spec135 def parse_output(self, output_path):136 ac_fname = os.path.join(output_path, 'ac.csv')137 dc_fname = os.path.join(output_path, 'dc.csv')138 if not os.path.isfile(ac_fname) or not os.path.isfile(dc_fname):139 print("ac/dc file doesn't exist: %s" % output_path)140 ac_raw_outputs = np.genfromtxt(ac_fname, skip_header=1)141 dc_raw_outputs = np.genfromtxt(dc_fname, skip_header=1)142 freq = ac_raw_outputs[:, 0]143 vout = ac_raw_outputs[:, 1]144 ibias = -dc_raw_outputs[1]145 return freq, vout, ibias146 def find_dc_gain (self, vout):147 return np.abs(vout)[0]148 def find_bw(self, vout, freq):149 gain = np.abs(vout)150 gain_3dB = gain[0] / np.sqrt(2)151 return self._get_best_crossing(freq, gain, gain_3dB)152 def _get_best_crossing(cls, xvec, yvec, val):153 interp_fun = interp.InterpolatedUnivariateSpline(xvec, yvec)154 def fzero(x):155 return interp_fun(x) - val156 xstart, xstop = xvec[0], xvec[-1]157 try:158 return sciopt.brentq(fzero, xstart, xstop)159 except ValueError:160 # avoid no solution161 if abs(fzero(xstart)) < abs(fzero(xstop)):162 return xstart163 return xstop164class CsAmpEvaluationCore(object):165 def __init__(self, cir_yaml):166 import yaml167 with open(cir_yaml, 'r') as f:168 yaml_data = yaml.load(f)169 # specs170 specs = yaml_data['target_specs']171 self.bw_min = specs['bw_min']172 self.gain_min = specs['gain_min']173 self.bias_max = specs['ibias_max']174 num_process = yaml_data['num_process']175 dsn_netlist = yaml_data['dsn_netlist']176 self.env = CsAmpClass(num_process=num_process, design_netlist=dsn_netlist)177 params = yaml_data['params']178 self.res_vec = np.arange(params['rload'][0], params['rload'][1], params['rload'][2])179 self.mul_vec = np.arange(params['mul'][0], params['mul'][1], params['mul'][2])180 def cost_fun(self, res_idx, mul_idx, verbose=False):181 """182 :param res:183 :param mul:184 :param verbose: if True will print the specification performance of the best individual185 :return:186 """187 state = [{'rload': self.res_vec[res_idx], 'mul': self.mul_vec[mul_idx]}]188 results = self.env.run(state, verbose=False)189 bw_cur = results[0][1]['bw']190 gain_cur = results[0][1]['gain']191 ibias_cur = results[0][1]['Ibias']192 if verbose:193 print('bw = %f vs. bw_min = %f' %(bw_cur, self.bw_min))194 print('gain = %f vs. gain_min = %f' %(gain_cur, self.gain_min))195 print('Ibias = %f vs. Ibias_max = %f' %(ibias_cur, self.bias_max))196 cost = 0197 if bw_cur < self.bw_min:198 cost += abs(bw_cur/self.bw_min - 1.0)199 if gain_cur < self.gain_min:200 cost += abs(gain_cur/self.gain_min - 1.0)201 cost += abs(ibias_cur/self.bias_max)/10202 return cost203## helper function for demonstration204def cost_fc(ibias_cur, gain_cur, bw_cur):205 bw_min = 1e9206 gain_min = 3207 bias_max = 1e-3208 cost = 0209 if bw_cur < bw_min:210 cost += abs(bw_cur/bw_min - 1.0)211 if gain_cur < gain_min:212 cost += abs(gain_cur/gain_min - 1.0)213 cost += abs(ibias_cur/bias_max)/10214 return cost215def load_array(fname):216 with open(fname, "rb") as f:217 arr = np.load(f)218 return arr219def save_array(fname, arr):220 with open(fname, "wb") as f:221 np.save(f, arr)222 return arr223if __name__ == '__main__':224 """225 example usage of CsAmpClass we just wrote:226 This common source is comprised of a single nmos transistor and single resistor.227 The parameters are Width, Length and multiplier of the nmos, resistor value, VGS bias of the nmos.228 Cload is assumed to be given. The goal is to satisfy some functionality specs (gain_min, bw_min) while229 getting the minimum ibias as the objective of the optimization. This section of code only illustrates230 how to generate the data and validate different points in the search space.231 232 """233 # test the CsAmp class with parameter values as input234 num_process = 1235 dsn_netlist = './framework/netlist/cs_amp.cir'236 cs_env = CsAmpClass(num_process=num_process, design_netlist=dsn_netlist)237 # example of running it for one example point and getting back the data238 state_list = [{'mul': 5, 'rload': 1630}]239 results = cs_env.run(state_list, verbose=False)240 if debug:241 print(results)242 # test Evaluation core and cost function with indices as input243 eval_core = CsAmpEvaluationCore("./framework/yaml_files/cs_amp.yaml")244 # let's say we want to evaluate some point (opt_res, opt_mul)245 opt_res = 85246 opt_mul = 9247 cost = eval_core.cost_fun(res_idx=opt_res, mul_idx=opt_mul, verbose=True)248 print(cost)249 ## generate the two-axis grid world of the cs_amp example: (rload, mul) in each cell250 # store bw, gain, Ibias and store them in file for later use, plot the specs:251 gen_data = False252 verbose = True253 if gen_data:254 mul_vec = np.arange(1, 100, 1)255 res_vec = np.arange(10, 5000, 20)256 result_list = []257 for i, mul in enumerate(mul_vec):258 for j, res in enumerate(res_vec):259 state_list = [{'mul': mul, 'rload': res}]260 results = cs_env.run(state_list, verbose=verbose)261 if (i==6 and j==85 and debug):262 print(results[0][1])263 result_list.append(results[0][1])264 Ibias_vec = [result['Ibias'] for result in result_list]265 bw_vec = [result['bw'] for result in result_list]266 gain_vec = [result['gain'] for result in result_list]267 # print(mul_vec)268 # print(res_vec)269 # print (len(Ibias_vec))270 # print (gain_vec)271 Ibias_mat = np.reshape(Ibias_vec, [len(mul_vec), len(res_vec)])272 bw_mat = np.reshape(bw_vec, [len(mul_vec), len(res_vec)])273 gain_mat = np.reshape(gain_vec, [len(mul_vec), len(res_vec)])274 # the data is going to be mul as x and res as y275 save_array("./genome/sweeps/bw.array", bw_mat)276 save_array("./genome/sweeps/gain.array", gain_mat)277 save_array("./genome/sweeps/ibias.array", Ibias_mat)278 save_array("./genome/sweeps/mul_vec.array", mul_vec)279 save_array("./genome/sweeps/res_vec.array", res_vec)280 if not gen_data:281 bw_mat = load_array("./genome/sweeps/bw.array")282 gain_mat = load_array("./genome/sweeps/gain.array")283 Ibias_mat = load_array("./genome/sweeps/ibias.array")284 mul_vec = load_array("./genome/sweeps/mul_vec.array")285 res_vec = load_array("./genome/sweeps/res_vec.array")286 # Plotting the data287 import matplotlib.pyplot as plt288 from mpl_toolkits.mplot3d import Axes3D289 import matplotlib.cm as cm290 mul_mat, res_mat = np.meshgrid(mul_vec, res_vec, indexing='ij')291 bw_fun = interp.interp2d(res_vec, mul_vec, bw_mat, kind="cubic")292 bias_fun = interp.interp2d(res_vec, mul_vec, Ibias_mat, kind="cubic")293 gain_fun = interp.interp2d(res_vec, mul_vec, gain_mat, kind="cubic")294 Ib_min = np.min(np.min(Ibias_mat))295 Ib_max = np.max(np.max(Ibias_mat))296 gain_min = np.min(np.min(gain_mat))297 gain_max = np.max(np.max(gain_mat))298 bw_min = np.min(np.min(bw_mat))299 bw_max = np.max(np.max(bw_mat))300 fig = plt.figure()301 fig.suptitle("(opt_res,opt_mul)=(%d,%d)" %(opt_res, opt_mul))302 ax = fig.add_subplot(221)303 mappable = ax.pcolormesh(np.log10(Ibias_mat*1e3), cmap='OrRd', vmin=np.log10(Ib_min*1e3), vmax=np.log10(Ib_max*1e3))304 ax.plot(opt_res, opt_mul, 'x', color='k')305 text = "%.2fmA" %(Ibias_mat[opt_mul][opt_res]*1e3)306 ax.annotate(text, xy=(opt_res, opt_mul),307 xytext=(opt_res+10, opt_mul+2))308 ax.axis([0, len(res_vec)-1, 0, len(mul_vec)-1])309 plt.colorbar(mappable)310 ax.set_xlabel('res_idx')311 ax.set_ylabel('mul_idx')312 ax.set_title('log10(Ibias*1e3)')313 ax = fig.add_subplot(222)314 mappable = ax.pcolormesh(np.log10(gain_mat), cmap='OrRd', vmin=np.log10(gain_min), vmax=np.log10(gain_max))315 ax.plot(opt_res, opt_mul, 'x', color='k')316 text = "%.2f" %(gain_mat[opt_mul][opt_res])317 ax.annotate(text, xy=(opt_res, opt_mul),318 xytext=(opt_res+10, opt_mul+2))319 ax.axis([0, len(res_vec)-1, 0, len(mul_vec)-1])320 plt.colorbar(mappable)321 ax.set_xlabel('res_idx')322 ax.set_ylabel('mul_idx')323 ax.set_title('log10(gain)')324 ax = fig.add_subplot(223)325 mappable = ax.pcolormesh(np.log10(bw_mat), cmap='OrRd', vmin=np.log10(bw_min), vmax=np.log10(bw_max))326 ax.plot(opt_res, opt_mul, 'x', color='k')327 text = "%.2fGHz" %(bw_mat[opt_mul][opt_res]/1e9)328 ax.annotate(text, xy=(opt_res, opt_mul),329 xytext=(opt_res+10, opt_mul+2))330 ax.axis([0, len(res_vec)-1, 0, len(mul_vec)-1])331 plt.colorbar(mappable)332 ax.set_xlabel('res_idx')333 ax.set_ylabel('mul_idx')334 ax.set_title('log10(bw[Hz])')335 cost_mat = [[cost_fc(Ibias_mat[mul_idx][res_idx],336 gain_mat[mul_idx][res_idx],337 bw_mat[mul_idx][res_idx]) for res_idx in \338 range(len(res_vec))] for mul_idx in range(len(mul_vec))]339 cost_min = np.min(np.min(cost_mat))340 cost_max = np.max(np.max(cost_mat))341 ax = fig.add_subplot(224)342 # mappable = ax.pcolormesh(np.log10(cost_mat), cmap='OrRd', vmin=np.log10(cost_min), vmax=np.log10(cost_max))343 mappable = ax.pcolormesh(cost_mat, cmap='OrRd', vmin=cost_min, vmax=cost_max)344 ax.plot(opt_res, opt_mul, 'x', color='k')345 text = "%.2f" %(cost_mat[opt_mul][opt_res])346 ax.annotate(text, xy=(opt_res, opt_mul),347 xytext=(opt_res+10, opt_mul+2))348 ax.axis([0, len(res_vec)-1, 0, len(mul_vec)-1])349 plt.colorbar(mappable)350 ax.set_xlabel('res_idx')351 ax.set_ylabel('mul_idx')352 ax.set_title('cost')353 ax.grid()...

Full Screen

Full Screen

equation.py

Source:equation.py Github

copy

Full Screen

...4def add(a,b):5 return (a+b)6def sub(a,b):7 return (a-b)8def mul(a,b):9 return (a*b)10def div(a,b):11 return (a/b)12def square (a):13 return (a*a)14def cube (a):15 return (a*a*a)16def ln(a):17 return (np.log(a))18def exp(a):19 return (math.exp(a))20lx1 = 521lelt = 6422alpha = 123e1 = ("add(mul(mul(add(add(mul(cube(add(mul(lx1, 0.882402383802), 1.47992982698)), -0.000197435827124), mul(mul(add(add(mul(cube(add(mul(lx1, -45.3885439878), 948.607714886)), -0.000197373542398), -0.00190445492438), add(mul(mul(add(mul(lx1, 6.74635178458), -101.178903916), mul(mul(add(mul(alpha, 1.00074634989), -0.00166499410751), add(mul(lelt, -115.961585179), 4653.72786899)), -0.981470853202)), 1.00057680148), 0.158042294354)), add(mul(add(mul(mul(add(lx1, 0.0386741000267), add(mul(lx1, 1.56792700952), -9.2682269537)), 6.54296613225e-08), -2.16031762717e-05), add(mul(lelt, 3.65301690784e-07), -0.999999916257)), 3.28842210301e-06)), 0.999880459842)), add(mul(mul(add(mul(lx1, 0.999745208638), 0.00842300023374), mul(mul(add(mul(alpha, 1.00074634989), -0.00166499410751), add(mul(lelt, 0.998603618593), 0.0266451484066)), -0.981470853202)), 1.00057680148), 0.158042294354)), add(mul(add(mul(mul(lx1, lx1), 3.93541448436e-07), 5.04203463155e-08), add(mul(mul(add(mul(alpha, 12.3790416752), -11.7260032988), add(mul(lx1, 0.000114154164032), -0.00190445492438)), 1.0697909117), -0.99999867251)), 3.28842210301e-06)), 0.999980112547), 1.51080103327e-06)")24e2 = ("add(mul(mul(add(mul(mul(add(mul(lelt, 1.26019257085e-08), -9.12280235681e-10), add(mul(alpha, -5.50777866556e-05), 1.00175823056)), 0.992560774278), 1.1017228412e-09), add(add(mul(mul(add(cube(add(mul(lx1, 0.999848579926), 0.000471248288372)), add(mul(lx1, -0.312605289724), 0.636392170642)), add(mul(alpha, 1.00059495575), -0.000525735790449)), 1.00082536934), -4.99307706781), mul(add(mul(alpha, 0.852719653184), 0.121010238141), mul(add(mul(lelt, 4.28731220122), -64.1535996278), add(mul(add(mul(lx1, 1.7869341605), -7.63906004051), add(mul(mul(mul(add(mul(cube(add(mul(lx1, 1.04765502496), -0.662004096336)), 0.952605950935), 69.067286006), add(alpha, 0.565232716786)), add(mul(mul(alpha, add(mul(add(mul(lx1, 0.0144767431608), -0.0794315045776), add(mul(alpha, 2.09602571925), -1.09892289489)), 1.46530235012e-08)), 2.28759704202), 1.38296966964)), 6.26401810965e-06), -0.00575670498784)), -2.02342402167e-05))))), 0.998096522652), 1.01561097464e-06)")25e3 =("add(mul(div(add(mul(square(add(mul(lx1, 0.000932841812205), -0.0021242228958)), 1.02040776043), -1.10933449919e-06), add(mul(div(add(mul(div(lx1, add(add(mul(lelt, 1.08920629761), -1.96269408265), square(add(mul(lx1, 0.0628604524156), -1.17938596965)))), 1.03730507694), -0.0115150106374), mul(add(mul(alpha, 8.32080019094), 6.67410028065), add(add(mul(lx1, 0.920853835273), 0.807953938623), add(mul(lelt, 0.0671529745814), -2.74412089302)))), 0.99840931575), 1.40097004482e-06)), 0.979734418143), 0.000859525737782)")26e4 = ("add(mul(mul(div(mul(add(add(mul(lelt, 1.00057403222), -0.0059433538672), add(mul(cube(add(mul(lx1, 11.3465012653), -151.508455423)), 1.65727177987e-08), 6.2766077024e-07)), alpha), ln(add(mul(lx1, 1.42822784773), -2.76961551257))), add(mul(cube(cube(add(mul(lx1, 0.0414545082485), 0.27394735276))), 1.51780809337), -0.00141770616584)), 1.00002796853), -0.00015581192502)")27e5 = ("add(mul(div(add(mul(mul(add(mul(cube(add(add(mul(lx1, 0.00348085774066), -0.000199975811592), mul(add(mul(ln(add(mul(lx1, 0.0231760140245), 27.2133885154)), -0.00148542858086), 0.00491471405395), add(mul(47.8832984312, alpha), 0.0794435269697)))), 1.00965668018), -2.73884374542e-08), add(mul(alpha, 1.00690580718), -0.00164176880335)), mul(cube(add(add(add(mul(lx1, -0.000792134509201), 1.26998428439), mul(add(mul(alpha, -2.28544827673e-08), 3.03508719069e-07), mul(cube(add(mul(mul(lx1, add(mul(lelt, 3.41827628933e-06), 136.500030286)), 3.17795708823e-05), 0.00104241642056)), 1.00982230746))), add(mul(mul(add(mul(ln(add(mul(lx1, 0.0283426585369), 27.1883091337)), -0.00013148593944), 0.000435007313657), mul(mul(add(mul(lelt, 7.36641817882), 44.5605992951), add(mul(alpha, 1.11571983691e-08), mul(lelt, -3.81410468657e-07))), add(mul(alpha, -2.28544827673e-08), 85002.4749732))), 18.3126137231), -0.00720641798194))), 0.999548137284)), -4.15468372677e-07), div(add(mul(div(add(mul(alpha, 0.942697354494), 0.0012932276767), lelt), 1.00739640092), 2.98204205945e-05), add(add(mul(lx1, 0.000308056896427), 0.984424460932), add(mul(alpha, 1.00001371463), -0.985375238646)))), 0.998080326794), -1.36584907643e-06)")28e6 = ("add(mul(mul(add(mul(mul(add(add(add(add(add(add(add(mul(lx1, -0.504679846229), 9.82675539259), alpha), add(mul(cube(add(add(mul(lx1, 1.02592700864), 0.0693442209296), add(mul(lx1, 0.000230283315724), -1.03708500681))), 1.01526524626), -2.92489800138)), alpha), alpha), cube(add(mul(lx1, 1.02647192318), -0.842319636034))), add(mul(lx1, 0.668880210438), 1.89207006938)), add(mul(alpha, 6.36466259065e-07), -1.76984247697e-08)), 0.999182393777), add(mul(mul(add(add(add(lx1, 12.1609446214), add(mul(cube(add(mul(lx1, 1.0312365425), add(mul(lelt, 0.0042114752761), -1.02461080955))), 0.933509157139), 1256.44247328)), lx1), add(mul(alpha, -4.52618733455e-10), 3.53746354258e-10)), 0.999182393777), -3.05455636394e-06)), add(mul(lelt, 1.05718576409), -1.34318493484)), 0.510297956256), 9.22233394103e-06)")29e7 = ("add(add(add(mul(mul(add(mul(mul(add(mul(mul(add(mul(lx1, 1.01941412038), -0.00992730831055), alpha), 1.01035982325), -0.054996032861), add(mul(cube(add(mul(lx1, 0.804376771188), 3.82292237751)), 0.880059294459), -9.02150555272)), 0.998106811118), -100.800260592), add(mul(ln(add(mul(exp(add(mul(lelt, 1.00042868538), 0.025579235721)), 0.924395077956), 31.8603481342)), 1.71904510001e-08), -1.28575935804e-08)), 1.00673111039), 2.23984122516e-07), add(mul(mul(add(mul(mul(add(mul(lx1, 1.79162744659), -4.38480362993), add(mul(alpha, 1.04254414661), 0.0426740430145)), 1.01035982325), add(add(mul(square(add(add(mul(lx1, lelt), -23.5390940695), add(mul(lx1, mul(lx1, add(mul(alpha, 1.15312867101), 0.17304942895))), -63.1218950434))), 0.000100400361006), 0.109614299603), mul(mul(add(mul(cube(add(mul(lx1, 0.804376771188), 3.82292237751)), 0.863778214617), add(mul(cube(add(mul(lelt, 1.00042868538), -0.0139269767191)), 1.00054187376), mul(add(mul(cube(add(mul(alpha, 0.805790561391), 1.94435596595)), -0.00907282044738), 16.2690872153), lelt))), add(mul(ln(add(mul(exp(add(mul(lelt, 1.00434731275), 0.025579235721)), 0.924395077956), 31.8603481342)), -9.39127380464e-07), 4.18786943013e-05)), 1.00693531849))), add(mul(square(add(add(mul(lx1, 1.08814144847), -28.9151172761), add(mul(lx1, 8.53704746025), -70.0954961818))), 16.2077356292), 1.21408470465)), -1.61423704642e-10), 8.79091525361e-06)), 1.4244309617e-06)")30e8 = "add(mul(add(mul(mul(mul(add(mul(lelt,1.00135501378),-0.0202282321002),add(mul(alpha,1.12864661494),-0.00164754878481)),add(mul(square(add(mul(cube(add(add(mul(lx1, 0.859732471545),-0.359530585511),mul(lx1,0.140666999383))),0.997677723483),12.438660582)),8.4962455432e-08),7.93987074499e-05)),0.999499289699),mul(mul(add(mul(lelt,1.00228154911),-0.0167826315229),add(alpha,add(mul(lx1,0.000286982928602),-0.00589984854308))),add(mul(square(add(mul(cube(add(mul(lx1, 1.01952605273),-0.352314366071)),0.999409676595),3.35570255514)),8.49538877208e-08),0.000316637311907))),0.500133805262),-0.000411069005196)"31e9 = ("add(add(mul(mul(add(mul(mul(add(mul(cube(lx1), 2.13194744728e-07), -4.49353478531e-07), add(alpha, add(mul(mul(add(mul(mul(add(mul(lx1, -0.798621297233), 31.2582460494), lelt), 126619.088612), 2892302.1086), mul(lx1, add(mul(square(lx1), 0.214682765228), 210.382627338))), 4.2956652339e-15), -0.00274789982794))), 1.00271794921), -1.43315986837e-06), add(div(add(mul(lelt, 0.999698848796), -0.0204130333155), 1.0026875482), -0.0594754758087)), 2.01695581316), mul(mul(add(mul(mul(add(mul(lx1, -4.38487204685e-07), -4.49353478531e-07), add(alpha, add(mul(mul(add(mul(mul(add(mul(lx1, -0.798621297233), mul(lelt, 1.00000019582)), add(mul(lelt, -0.334150085528), 14.2060792103)), 165948.298702), -34985056.2735), mul(add(mul(lx1, -2.85679211112), -0.000488841829476), add(square(lx1), 12.9081685136))), 3.54109807073e-15), -0.00280965915684))), 1.00271794921), -1.43315986837e-06), add(div(add(mul(lelt, -0.152284116534), 3.325074633), 1.0026875482), -0.0594754758087)), 2.01695581316)), 1.25785786476e-05)")32e10 = ("add(mul(mul(div(add(mul(lelt, 8.22737285077e-07), -2.90530199486e-07), add(mul(lx1, 0.786670299701), 6.58515627989)), add(add(mul(mul(add(mul(mul(lx1, add(mul(alpha, 0.862665971185), -0.00834510847139)), 0.998697851208), 0.0280880310191), add(add(mul(cube(add(mul(lx1, 0.992447033698), 0.147898638809)), 1.01725370833), add(cube(add(mul(lx1, 0.440846423852), 1.90533667633)), 6.98653833308)), mul(add(add(mul(alpha, 1.33970224441), -6.70427385142), add(mul(square(lx1), 0.991482507454), 0.305982230262)), add(mul(ln(lelt), 0.804327542147), 0.744727143477)))), 1.00285983247), -33.971722919), add(lx1, -27.467705984))), 0.98743973039), 9.16495000915e-06)")33e11 = ("add(add(add(mul(mul(add(mul(mul(cube(lx1), add(lelt, add(mul(lelt, 0.999554383667), 0.00930384456038))), 4.88837558241e-08), add(mul(cube(add(mul(lx1, 1.00218293433), -0.028641526798)), 1.38085990722e-09), -8.30210822411e-06)), add(mul(alpha, 0.999816682691), 0.000539670201528)), 1.00060567858), -1.94956597178e-06), add(mul(mul(add(mul(lelt, 1.3939236171), -7.65079807367), add(mul(mul(add(mul(lelt, add(mul(lx1, 2.08727168805), -4.79325812072)), -337.886542704), alpha), -1.24929486499e-09), -3.51919901608e-07)), 1.04455117898), 3.87777877191e-07)), -1.64857743241e-07)")34print (eval(e1))35print (eval(e2))36print (eval(e3))37print (eval(e4))38print (eval(e5))39print (eval(e6))40print (eval(e7))41print (eval(e8))42print (eval(e9))43print (eval(e10))...

Full Screen

Full Screen

precedence.py

Source:precedence.py Github

copy

Full Screen

1"""A module providing information about the necessity of brackets"""2from __future__ import print_function, division3from sympy.core.function import _coeff_isneg4# Default precedence values for some basic types5PRECEDENCE = {6 "Lambda": 1,7 "Xor": 10,8 "Or": 20,9 "And": 30,10 "Relational": 35,11 "Add": 40,12 "Mul": 50,13 "Pow": 60,14 "Func": 70,15 "Not": 100,16 "Atom": 1000,17 "BitwiseOr": 36,18 "BitwiseXor": 37,19 "BitwiseAnd": 3820}21# A dictionary assigning precedence values to certain classes. These values are22# treated like they were inherited, so not every single class has to be named23# here.24# Do not use this with printers other than StrPrinter25PRECEDENCE_VALUES = {26 "Equivalent": PRECEDENCE["Xor"],27 "Xor": PRECEDENCE["Xor"],28 "Implies": PRECEDENCE["Xor"],29 "Or": PRECEDENCE["Or"],30 "And": PRECEDENCE["And"],31 "Add": PRECEDENCE["Add"],32 "Pow": PRECEDENCE["Pow"],33 "Relational": PRECEDENCE["Relational"],34 "Sub": PRECEDENCE["Add"],35 "Not": PRECEDENCE["Not"],36 "Function" : PRECEDENCE["Func"],37 "NegativeInfinity": PRECEDENCE["Add"],38 "MatAdd": PRECEDENCE["Add"],39 "MatPow": PRECEDENCE["Pow"],40 "MatrixSolve": PRECEDENCE["Mul"],41 "TensAdd": PRECEDENCE["Add"],42 # As soon as `TensMul` is a subclass of `Mul`, remove this:43 "TensMul": PRECEDENCE["Mul"],44 "HadamardProduct": PRECEDENCE["Mul"],45 "HadamardPower": PRECEDENCE["Pow"],46 "KroneckerProduct": PRECEDENCE["Mul"],47 "Equality": PRECEDENCE["Mul"],48 "Unequality": PRECEDENCE["Mul"],49}50# Sometimes it's not enough to assign a fixed precedence value to a51# class. Then a function can be inserted in this dictionary that takes52# an instance of this class as argument and returns the appropriate53# precedence value.54# Precedence functions55def precedence_Mul(item):56 if _coeff_isneg(item):57 return PRECEDENCE["Add"]58 return PRECEDENCE["Mul"]59def precedence_Rational(item):60 if item.p < 0:61 return PRECEDENCE["Add"]62 return PRECEDENCE["Mul"]63def precedence_Integer(item):64 if item.p < 0:65 return PRECEDENCE["Add"]66 return PRECEDENCE["Atom"]67def precedence_Float(item):68 if item < 0:69 return PRECEDENCE["Add"]70 return PRECEDENCE["Atom"]71def precedence_PolyElement(item):72 if item.is_generator:73 return PRECEDENCE["Atom"]74 elif item.is_ground:75 return precedence(item.coeff(1))76 elif item.is_term:77 return PRECEDENCE["Mul"]78 else:79 return PRECEDENCE["Add"]80def precedence_FracElement(item):81 if item.denom == 1:82 return precedence_PolyElement(item.numer)83 else:84 return PRECEDENCE["Mul"]85def precedence_UnevaluatedExpr(item):86 return precedence(item.args[0])87PRECEDENCE_FUNCTIONS = {88 "Integer": precedence_Integer,89 "Mul": precedence_Mul,90 "Rational": precedence_Rational,91 "Float": precedence_Float,92 "PolyElement": precedence_PolyElement,93 "FracElement": precedence_FracElement,94 "UnevaluatedExpr": precedence_UnevaluatedExpr,95}96def precedence(item):97 """Returns the precedence of a given object.98 This is the precedence for StrPrinter.99 """100 if hasattr(item, "precedence"):101 return item.precedence102 try:103 mro = item.__class__.__mro__104 except AttributeError:105 return PRECEDENCE["Atom"]106 for i in mro:107 n = i.__name__108 if n in PRECEDENCE_FUNCTIONS:109 return PRECEDENCE_FUNCTIONS[n](item)110 elif n in PRECEDENCE_VALUES:111 return PRECEDENCE_VALUES[n]112 return PRECEDENCE["Atom"]113PRECEDENCE_TRADITIONAL = PRECEDENCE.copy()114PRECEDENCE_TRADITIONAL['Integral'] = PRECEDENCE["Mul"]115PRECEDENCE_TRADITIONAL['Sum'] = PRECEDENCE["Mul"]116PRECEDENCE_TRADITIONAL['Product'] = PRECEDENCE["Mul"]117PRECEDENCE_TRADITIONAL['Limit'] = PRECEDENCE["Mul"]118PRECEDENCE_TRADITIONAL['Derivative'] = PRECEDENCE["Mul"]119PRECEDENCE_TRADITIONAL['TensorProduct'] = PRECEDENCE["Mul"]120PRECEDENCE_TRADITIONAL['Transpose'] = PRECEDENCE["Pow"]121PRECEDENCE_TRADITIONAL['Adjoint'] = PRECEDENCE["Pow"]122PRECEDENCE_TRADITIONAL['Dot'] = PRECEDENCE["Mul"] - 1123PRECEDENCE_TRADITIONAL['Cross'] = PRECEDENCE["Mul"] - 1124PRECEDENCE_TRADITIONAL['Gradient'] = PRECEDENCE["Mul"] - 1125PRECEDENCE_TRADITIONAL['Divergence'] = PRECEDENCE["Mul"] - 1126PRECEDENCE_TRADITIONAL['Curl'] = PRECEDENCE["Mul"] - 1127PRECEDENCE_TRADITIONAL['Laplacian'] = PRECEDENCE["Mul"] - 1128PRECEDENCE_TRADITIONAL['Union'] = PRECEDENCE['Xor']129PRECEDENCE_TRADITIONAL['Intersection'] = PRECEDENCE['Xor']130PRECEDENCE_TRADITIONAL['Complement'] = PRECEDENCE['Xor']131PRECEDENCE_TRADITIONAL['SymmetricDifference'] = PRECEDENCE['Xor']132PRECEDENCE_TRADITIONAL['ProductSet'] = PRECEDENCE['Xor']133def precedence_traditional(item):134 """Returns the precedence of a given object according to the135 traditional rules of mathematics.136 This is the precedence for the LaTeX and pretty printer.137 """138 # Integral, Sum, Product, Limit have the precedence of Mul in LaTeX,139 # the precedence of Atom for other printers:140 from sympy import Integral, Sum, Product, Limit, Derivative, Transpose, Adjoint141 from sympy.core.expr import UnevaluatedExpr142 from sympy.tensor.functions import TensorProduct143 if isinstance(item, UnevaluatedExpr):144 return precedence_traditional(item.args[0])145 n = item.__class__.__name__146 if n in PRECEDENCE_TRADITIONAL:147 return PRECEDENCE_TRADITIONAL[n]...

Full Screen

Full Screen

test_matmul.py

Source:test_matmul.py Github

copy

Full Screen

1from sympy.core import I, symbols, Basic, Mul, S2from sympy.functions import adjoint, transpose3from sympy.matrices import (Identity, Inverse, Matrix, MatrixSymbol, ZeroMatrix,4 eye, ImmutableMatrix)5from sympy.matrices.expressions import Adjoint, Transpose, det, MatPow6from sympy.matrices.expressions.matexpr import GenericIdentity7from sympy.matrices.expressions.matmul import (factor_in_front, remove_ids,8 MatMul, xxinv, any_zeros, unpack, only_squares)9from sympy.strategies import null_safe10from sympy import refine, Q, Symbol11from sympy.utilities.pytest import XFAIL12n, m, l, k = symbols('n m l k', integer=True)13x = symbols('x')14A = MatrixSymbol('A', n, m)15B = MatrixSymbol('B', m, l)16C = MatrixSymbol('C', n, n)17D = MatrixSymbol('D', n, n)18E = MatrixSymbol('E', m, n)19def test_adjoint():20 assert adjoint(A*B) == Adjoint(B)*Adjoint(A)21 assert adjoint(2*A*B) == 2*Adjoint(B)*Adjoint(A)22 assert adjoint(2*I*C) == -2*I*Adjoint(C)23 M = Matrix(2, 2, [1, 2 + I, 3, 4])24 MA = Matrix(2, 2, [1, 3, 2 - I, 4])25 assert adjoint(M) == MA26 assert adjoint(2*M) == 2*MA27 assert adjoint(MatMul(2, M)) == MatMul(2, MA).doit()28def test_transpose():29 assert transpose(A*B) == Transpose(B)*Transpose(A)30 assert transpose(2*A*B) == 2*Transpose(B)*Transpose(A)31 assert transpose(2*I*C) == 2*I*Transpose(C)32 M = Matrix(2, 2, [1, 2 + I, 3, 4])33 MT = Matrix(2, 2, [1, 3, 2 + I, 4])34 assert transpose(M) == MT35 assert transpose(2*M) == 2*MT36 assert transpose(x*M) == x*MT37 assert transpose(MatMul(2, M)) == MatMul(2, MT).doit()38def test_factor_in_front():39 assert factor_in_front(MatMul(A, 2, B, evaluate=False)) ==\40 MatMul(2, A, B, evaluate=False)41def test_remove_ids():42 assert remove_ids(MatMul(A, Identity(m), B, evaluate=False)) == \43 MatMul(A, B, evaluate=False)44 assert null_safe(remove_ids)(MatMul(Identity(n), evaluate=False)) == \45 MatMul(Identity(n), evaluate=False)46def test_xxinv():47 assert xxinv(MatMul(D, Inverse(D), D, evaluate=False)) == \48 MatMul(Identity(n), D, evaluate=False)49def test_any_zeros():50 assert any_zeros(MatMul(A, ZeroMatrix(m, k), evaluate=False)) == \51 ZeroMatrix(n, k)52def test_unpack():53 assert unpack(MatMul(A, evaluate=False)) == A54 x = MatMul(A, B)55 assert unpack(x) == x56def test_only_squares():57 assert only_squares(C) == [C]58 assert only_squares(C, D) == [C, D]59 assert only_squares(C, A, A.T, D) == [C, A*A.T, D]60def test_determinant():61 assert det(2*C) == 2**n*det(C)62 assert det(2*C*D) == 2**n*det(C)*det(D)63 assert det(3*C*A*A.T*D) == 3**n*det(C)*det(A*A.T)*det(D)64def test_doit():65 assert MatMul(C, 2, D).args == (C, 2, D)66 assert MatMul(C, 2, D).doit().args == (2, C, D)67 assert MatMul(C, Transpose(D*C)).args == (C, Transpose(D*C))68 assert MatMul(C, Transpose(D*C)).doit(deep=True).args == (C, C.T, D.T)69def test_doit_drills_down():70 X = ImmutableMatrix([[1, 2], [3, 4]])71 Y = ImmutableMatrix([[2, 3], [4, 5]])72 assert MatMul(X, MatPow(Y, 2)).doit() == X*Y**273 assert MatMul(C, Transpose(D*C)).doit().args == (C, C.T, D.T)74def test_doit_deep_false_still_canonical():75 assert (MatMul(C, Transpose(D*C), 2).doit(deep=False).args ==76 (2, C, Transpose(D*C)))77def test_matmul_scalar_Matrix_doit():78 # Issue 905379 X = Matrix([[1, 2], [3, 4]])80 assert MatMul(2, X).doit() == 2*X81def test_matmul_sympify():82 assert isinstance(MatMul(eye(1), eye(1)).args[0], Basic)83def test_collapse_MatrixBase():84 A = Matrix([[1, 1], [1, 1]])85 B = Matrix([[1, 2], [3, 4]])86 assert MatMul(A, B).doit() == ImmutableMatrix([[4, 6], [4, 6]])87def test_refine():88 assert refine(C*C.T*D, Q.orthogonal(C)).doit() == D89 kC = k*C90 assert refine(kC*C.T, Q.orthogonal(C)).doit() == k*Identity(n)91 assert refine(kC* kC.T, Q.orthogonal(C)).doit() == (k**2)*Identity(n)92def test_matmul_no_matrices():93 assert MatMul(1) == 194 assert MatMul(n, m) == n*m95 assert not isinstance(MatMul(n, m), MatMul)96def test_matmul_args_cnc():97 assert MatMul(n, A, A.T).args_cnc() == [[n], [A, A.T]]98 assert MatMul(A, A.T).args_cnc() == [[], [A, A.T]]99@XFAIL100def test_matmul_args_cnc_symbols():101 # Not currently supported102 a, b = symbols('a b', commutative=False)103 assert MatMul(n, a, b, A, A.T).args_cnc() == [[n], [a, b, A, A.T]]104 assert MatMul(n, a, A, b, A.T).args_cnc() == [[n], [a, A, b, A.T]]105def test_issue_12950():106 M = Matrix([[Symbol("x")]]) * MatrixSymbol("A", 1, 1)107 assert MatrixSymbol("A", 1, 1).as_explicit()[0]*Symbol('x') == M.as_explicit()[0]108def test_construction_with_Mul():109 assert Mul(C, D) == MatMul(C, D)110 assert Mul(D, C) == MatMul(D, C)111def test_generic_identity():112 assert MatMul.identity == GenericIdentity()...

Full Screen

Full Screen

quantitative.py

Source:quantitative.py Github

copy

Full Screen

1import numpy2import distributions3def bivariate_normal():4 scale = 0.1 + numpy.random.random() * 10.05 N_rad = distributions.Normal2D_radial(scale)6 N_mul = distributions.Normal2D_mv(scale)7 print(repr(N_rad))8 print(repr(N_mul))9 R = 100.010 N = 100011 x = numpy.linspace(-R, R, N)12 dx = 2.0 * R / N13 xx, yy = numpy.meshgrid(x, x)14 density_rad = N_rad.pdf(xx, yy)15 density_mul = N_mul.pdf(xx, yy)16 total_density_rad = numpy.sum(density_rad) * dx * dx17 total_density_mul = numpy.sum(density_mul) * dx * dx18 assert numpy.isclose(total_density_rad, 1.0, 1e-2)19 assert numpy.isclose(total_density_mul, 1.0, 1e-2)20 density_diff = density_rad - density_mul21 assert numpy.allclose(density_diff, 0.0)22 K = 100000023 samples_rad = N_rad.sample(K)24 samples_mul = N_mul.sample(K)25 radial_var_rad = numpy.linalg.norm(samples_rad, axis=1).var()26 radial_var_mul = numpy.linalg.norm(samples_mul, axis=1).var()27 assert numpy.isclose(radial_var_rad, radial_var_mul, scale * 0.1)28 # test zero eval29 peak_rad = N_rad.pdf(0.0, 0.0)30 peak_mul = N_mul.pdf(0.0, 0.0)31 print(peak_rad, peak_mul)32def bivariate_cauchy():33 scale = 0.8 + numpy.random.random() * 5.034 cauchy_rad = distributions.Cauchy2D_radial(scale)35 cauchy_mul = distributions.Cauchy2D_mv(scale)36 print(repr(cauchy_rad))37 print(repr(cauchy_mul))38 N = 500039 D = 300.040 dx = 2.0 * D / N41 x = numpy.linspace(-D, D, N)42 xx, yy = numpy.meshgrid(x, x)43 density_rad = cauchy_rad.pdf(xx, yy)44 density_mul = cauchy_mul.pdf(xx, yy)45 total_density_rad = numpy.sum(density_rad) * dx * dx46 total_density_mul = numpy.sum(density_mul) * dx * dx47 assert numpy.isclose(total_density_rad, 1.0, 1e-1)48 assert numpy.isclose(total_density_mul, 1.0, 1e-1)49 assert numpy.allclose(density_rad, density_mul)50 K = 100000051 samples_rad = cauchy_rad.sample(K)52 samples_mul = cauchy_mul.sample(K)53 # var test not applicable for infinite var distribution!54 # radial_var_rad = numpy.linalg.norm(samples_rad, axis=1).var()55 # radial_var_mul = numpy.linalg.norm(samples_mul, axis=1).var()56 # assert numpy.isclose(radial_var_rad, radial_var_mul, scale * 0.1)57 x_bins = numpy.linspace(- D - 0.5 * dx, D + 0.5 * dx, N + 1)58 hist_rad, _, _ = numpy.histogram2d(*samples_rad.T, [x_bins, x_bins], density=True)59 hist_mul, _, _ = numpy.histogram2d(*samples_mul.T, [x_bins, x_bins], density=True)60 # print(numpy.abs(hist - density).max())61 assert numpy.allclose(hist_rad, density_rad, atol=1e-2)62 assert numpy.allclose(hist_mul, density_mul, atol=1e-2)63 assert numpy.allclose(hist_mul, hist_rad, atol=1e-1)64 # test zero eval65 peak_rad = cauchy_rad.pdf(0.0, 0.0)66 peak_mul = cauchy_mul.pdf(0.0, 0.0)67 print(peak_rad, peak_mul)68def bivariate_scaling():69 scale = numpy.random.random() * 2.070 alpha = numpy.random.random() * 1.5 + 0.571 dist_stable = distributions.Stable2D(scale=scale, alpha=alpha)72 dist_normal = distributions.Normal2D(scale=scale * numpy.sqrt(2.0))73 dist_cauchy = distributions.Cauchy2D(scale=scale)74 x = numpy.random.randn(5) * 4.075 y = numpy.random.randn(5) * 4.076 scale2 = numpy.random.random() * 10.077 dist_stable_rescaled = distributions.Stable2D(scale=scale * scale2, alpha=alpha)78 dist_normal_rescaled = distributions.Normal2D(scale=scale * scale2 * numpy.sqrt(2.0))79 dist_cauchy_rescaled = distributions.Cauchy2D(scale=scale * scale2)80 f = dist_cauchy.pdf(x / scale2, y / scale2) / scale2 / scale281 g = dist_cauchy_rescaled.pdf(x, y)82 assert numpy.allclose(f, g)83 f = dist_normal.pdf(x / scale2, y / scale2) / scale2 / scale284 g = dist_normal_rescaled.pdf(x, y)85 assert numpy.allclose(f, g)86 f = dist_stable.pdf(x / scale2, y / scale2) / scale2 / scale287 g = dist_stable_rescaled.pdf(x, y)...

Full Screen

Full Screen

manualSREquation.py

Source:manualSREquation.py Github

copy

Full Screen

...4def add(a,b):5 return (a+b)6def sub(a,b):7 return (a-b)8def mul(a,b):9 return (a*b)10def div(a,b):11 return (a/b)12def square (a):13 return (a*a)14def cube (a):15 return (a*a*a)16def ln(a):17 return (np.log(a))18def exp(a):19 return (math.exp(a))20#aabcfn_nft = ("add(mul(mul(add(div(1.0, add(mul(square(add(mul(size, 0.984389464024), 0.611576472456)), 1.00000091351), -0.00145783162768)), mul(add(mul(size, 2.16153080235e-06), -0.000102086535598), size)), add(mul(square(mul(cube(add(mul(square(add(mul(size, 0.999999366907), 1.65096305966e-05)), 0.997106286111), 0.27061336757)), 1.00000000013)), 2.35014648952e-15), -0.047996134208)), 2.18024879476e-06), 3.92282079185e-06)")21aabcfn_nft = ("add(mul(cube(add(add(mul(ln(add(mul(div(add(mul(square(add(mul(size, 4.43349955561), -133.398813815)), 1.00000000032), -6.57500571721e-07), add(mul(size, -25644.2057259), 455803137.882)), 6543892.86191), 17.4083372601)), 1.00284171734), -0.010210794622), add(add(mul(ln(add(add(mul(size, 0.636941593958), -9.55412434521), add(mul(div(add(mul(cube(size), 0.595807979601), 1364.08839403), add(mul(size, 0.999999859765), 1.72087716948)), 5.92658401946e-09), -4.3058461308e-07))), 1.03979393372), -0.125729303345), add(mul(size, 1.0335144459), 0.046280480941)))), 4.68681143019e-11), 2.44037772749e-07)")22aabcfn_ft = ("add(mul(mul(add(add(add(mul(size, 1.00493293798), 1.19396323052), add(mul(size, -1.94357933085), 2.19476194084)), add(mul(size, 1.93861391747), -0.765191285305)), add(mul(ln(add(mul(mul(add(mul(square(add(mul(size, 0.26006594007), -9.78767918425)), 1.0), -5.5891527765e-14), add(mul(square(add(mul(size, 0.260070801294), -9.78779727318)), 5.2156426279e-08), 0.74908151607)), 1.00000000006), 0.13457675858)), 0.999999981682), 6.08941173004e-09)), -5.79642931111e-08), 4.78328868069e-06)")23ampfe_nft = ("add(mul(mul(add(add(mul(ln(add(mul(size, 1.00347807085), -0.0923938307393)), 0.999999999214), 2.64584053808e-09), add(mul(mul(add(mul(size, 10.7830330952), -293.166928913), add(mul(size, 3.70663317202), add(mul(ln(add(mul(size, 1.00000295901), 1.23066060684e-06)), 1.42036624104e-05), -80.1455742027))), 8.94977649728e-05), -0.0804710254183)), add(add(mul(ln(add(mul(ln(add(mul(size, 1.52801423307), -7.24792087226)), 1.00000000001), -2.97856756663e-11)), -283.464021941), 329.555965141), add(mul(square(add(mul(size, 24.1400984448), -235.57142399)), 1.0), -3.744207185e-12))), 3.7571162568e-09), 0.000115059034464)")24ampfe_ft = ("add(mul(mul(add(mul(square(add(mul(mul(add(mul(mul(add(mul(cube(add(mul(size, 3.6828192811), -28.258728457)), 1.0), 7.03559552992e-09), add(mul(size, 0.000110067050703), -0.000626221408583)), 0.00331547941671), 24.2609260665), add(add(mul(size, 7.36538292762e-05), 1.63922272608e-13), add(mul(ln(add(mul(cube(add(mul(size, 0.99999999964), 3.60396788046e-09)), 1.03949109508), -1039.36864964)), -1.91926413294e-09), -0.000389344379156))), 0.999999999999), 3.85743008567e-15)), 1.00004405581), -1.56232076928e-07), add(mul(square(add(mul(mul(add(mul(size, 0.0992504372586), -3.20639130708), add(mul(size, 0.977780822155), 0.736984705949)), 0.708364324658), 2.54296588227)), -4.79300179e-06), 1.00273938593)), 1.00026377561), -1.26045179344e-05)")25for size in range(1,100,1):26 print(str(size) + ',' + str(eval(aabcfn_nft)) + ',' + str(eval(aabcfn_ft)) + ',' + str(eval(ampfe_nft)) + ',' + str(eval(ampfe_ft)) )27 #print (eval(e1))...

Full Screen

Full Screen

test_evaluate.py

Source:test_evaluate.py Github

copy

Full Screen

1from sympy.abc import x, y2from sympy.core.evaluate import evaluate3from sympy.core import Mul, Add, Pow, S4from sympy import sqrt5def test_add():6 with evaluate(False):7 expr = x + x8 assert isinstance(expr, Add)9 assert expr.args == (x, x)10 with evaluate(True):11 assert (x + x).args == (2, x)12 assert (x + x).args == (x, x)13 assert isinstance(x + x, Mul)14 with evaluate(False):15 assert S.One + 1 == Add(1, 1)16 assert 1 + S.One == Add(1, 1)17 assert S(4) - 3 == Add(4, -3)18 assert -3 + S(4) == Add(4, -3)19 assert S(2) * 4 == Mul(2, 4)20 assert 4 * S(2) == Mul(2, 4)21 assert S(6) / 3 == Mul(6, S.One / 3)22 assert S.One / 3 * 6 == Mul(S.One / 3, 6)23 assert 9 ** S(2) == Pow(9, 2)24 assert S(2) ** 9 == Pow(2, 9)25 assert S(2) / 2 == Mul(2, S.One / 2)26 assert S.One / 2 * 2 == Mul(S.One / 2, 2)27 assert S(2) / 3 + 1 == Add(S(2) / 3, 1)28 assert 1 + S(2) / 3 == Add(1, S(2) / 3)29 assert S(4) / 7 - 3 == Add(S(4) / 7, -3)30 assert -3 + S(4) / 7 == Add(-3, S(4) / 7)31 assert S(2) / 4 * 4 == Mul(S(2) / 4, 4)32 assert 4 * (S(2) / 4) == Mul(4, S(2) / 4)33 assert S(6) / 3 == Mul(6, S.One / 3)34 assert S.One / 3 * 6 == Mul(S.One / 3, 6)35 assert S.One / 3 + sqrt(3) == Add(S.One / 3, sqrt(3))36 assert sqrt(3) + S.One / 3 == Add(sqrt(3), S.One / 3)37 assert S.One / 2 * 10.333 == Mul(S.One / 2, 10.333)38 assert 10.333 * S.One / 2 == Mul(10.333, S.One / 2)39 assert sqrt(2) * sqrt(2) == Mul(sqrt(2), sqrt(2))40 assert S.One / 2 + x == Add(S.One / 2, x)41 assert x + S.One / 2 == Add(x, S.One / 2)42 assert S.One / x * x == Mul(S.One / x, x)43 assert x * S.One / x == Mul(x, S.One / x)44def test_nested():45 with evaluate(False):46 expr = (x + x) + (y + y)47 assert expr.args == ((x + x), (y + y))...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(wpt.mul(2,3));2console.log(wpt.div(10,2));3console.log(wpt.sub(12,3));4console.log(wpt.add(5,6));5var wpt = {6 add: function(a, b){7 return a + b;8 },9 sub: function(a, b){10 return a - b;11 },12 mul: function(a, b){13 return a * b;14 },15 div: function(a, b){16 return a / b;17 }18};19module.exports = wpt;20var wpt = {21 add: function(a, b){22 return a + b;23 },24 sub: function(a, b){25 return a - b;26 },27 mul: function(a, b){28 return a * b;29 },30 div: function(a, b){31 return a / b;32 }33};34module.exports = wpt;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2console.log(wpt.mul(2,3));3var wpt = {4 mul: function(a, b) {5 return a * b;6 }7}8module.exports = wpt;9var _ = require('underscore');10var result = _.map([1, 2, 3], function(num){ return num * 3; });11console.log(result);12var _ = require('lodash');13var result = _.map([1, 2, 3], function(num){ return num * 3; });14console.log(result);15var async = require('async');16async.map([1, 2, 3], function(num, callback){17 callback(null, num * 3);18}, function(err, results){19 console.log(results);20});21var request = require('request');22 if (!error && response.statusCode == 200) {23 }24})25var cheerio = require('cheerio');26var $ = cheerio.load('<h2 class="title">Hello world</h2>');27$('h2.title').text('Hello there!');28$('h2').addClass('welcome');29$.html();30var express = require('express');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.log(err);6 console.log(data);7});8 if (err) return console.log(err);9 console.log(data);10}, function(data) {11 console.log(data);12});13 if (err) return console.log(err);14 console.log(data);15}, function(data) {16 console.log(data);17}, function(data) {18 console.log(data);19});20wpt.getTestResults('141211_0J_1', function(err, data) {21 if (err) return console.log(err);22 console.log(data);23});24wpt.getTestResults('141211_0J_1', 'Dulles:Chrome', function(err, data) {25 if (err) return console.log(err);26 console.log(data);27});28wpt.getTestResults('141211_0J_1', 'Dulles:Chrome', function(err, data) {29 if (err) return console.log(err);30 console.log(data);31}, function(data) {32 console.log(data);33});34wpt.getTestResults('141211_0J_1', 'Dulles:Chrome', function(err, data) {35 if (err) return console.log(err);36 console.log(data);37}, function(data) {38 console.log(data);39}, function(data

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var result = wpt.mul(10, 20);3console.log(result);4exports.mul = function(a, b) {5 return a * b;6};7var http = require('http');8var http = require('http');9http.createServer(function (req, res) {10 res.writeHead(200, {'Content-Type': 'text/plain'});11 res.end('Hello World');12}).listen(8080);13The createServer() method returns an object, which has a listen method, which has an argument of the port number in which you want the server

Full Screen

Using AI Code Generation

copy

Full Screen

1var wp = require('./wptest');2> var wp = require('./wptest');3{ add: [Function], mul: [Function] }4> wp.add(10,20)5> wp.mul(10,20)6> var wp = require('./wptest');7> var wp2 = require('./wptest');8{ add: [Function], mul: [Function] }9{ add: [Function], mul: [Function] }10> wp.add(10,20)11> wp2.add(10,20)12> wp.mul(10,20)13> wp2.mul(10,20)14> var wp = require('./wptest');15> var wp2 = require('./wptest');16{ add: [Function], mul: [Function] }17{ add: [Function], mul: [Function] }18> wp.add(10,20)19> wp2.add(10,20)20> wp.mul(10,20)21> wp2.mul(10,20)22> wp.add = function(a,b){return a+b+100;}23{ add: [Function], mul: [Function] }24> wp.add(10,20)25> wp2.add(10,20)26> var wp = require('./wptest');27> var wp2 = require('./wptest');28{ add: [Function], mul: [Function] }29{ add: [Function], mul: [Function] }30> wp.add(10,20)31> wp2.add(10,20)32> wp.mul(10,20)33> wp2.mul(10,20)34> wp.add = function(a,b){return a+b+100;}35{ add: [Function], mul: [Function] }36> wp.add(10,20)37> wp2.add(10,20)38> wp2.add = function(a,b){return a+b+200;}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var wptObj = new wpt();3var result = wptObj.mul(2,3);4console.log(result);5var wpt = function() {6 this.mul = function(a,b) {7 return a*b;8 }9}10module.exports = wpt;11var wpt = require('./wpt');12var wptObj = new wpt();13var result = wptObj.mul(2,3);14console.log(result);15var wpt = function() {16 this.mul = function(a,b) {17 return a*b;18 }19}20exports = wpt;21exports = wpt;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful