From nobody at rubyforge.org Thu May 10 08:15:20 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Thu, 10 May 2007 08:15:20 -0400 (EDT) Subject: [Archipelago-submits] [264] trunk/archipelago/lib/archipelago/disco.rb: made an extra necessary require in disco Message-ID: <20070510121520.E35C1524097E@rubyforge.org> Revision: 264 Author: zond Date: 2007-05-10 08:15:20 -0400 (Thu, 10 May 2007) Log Message: ----------- made an extra necessary require in disco Modified Paths: -------------- trunk/archipelago/lib/archipelago/disco.rb Modified: trunk/archipelago/lib/archipelago/disco.rb =================================================================== --- trunk/archipelago/lib/archipelago/disco.rb 2007-04-19 10:34:29 UTC (rev 263) +++ trunk/archipelago/lib/archipelago/disco.rb 2007-05-10 12:15:20 UTC (rev 264) @@ -20,6 +20,7 @@ require 'ipaddr' require 'pp' require 'archipelago/current' +require 'archipelago/hashish' require 'drb' require 'set' require 'digest/sha1' From nobody at rubyforge.org Mon May 14 08:25:40 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 08:25:40 -0400 (EDT) Subject: [Archipelago-submits] [265] trunk/archipelago/Rakefile: bumped version number Message-ID: <20070514122541.0369A5240AD7@rubyforge.org> Revision: 265 Author: zond Date: 2007-05-14 08:25:40 -0400 (Mon, 14 May 2007) Log Message: ----------- bumped version number Modified Paths: -------------- trunk/archipelago/Rakefile Modified: trunk/archipelago/Rakefile =================================================================== --- trunk/archipelago/Rakefile 2007-05-10 12:15:20 UTC (rev 264) +++ trunk/archipelago/Rakefile 2007-05-14 12:25:40 UTC (rev 265) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "archipelago" - s.version = "0.2.5" + s.version = "0.2.6" s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "A set of tools for distributed computing in ruby." From nobody at rubyforge.org Mon May 14 08:27:30 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 08:27:30 -0400 (EDT) Subject: [Archipelago-submits] [266] trunk/oneliner: reverted to r261 Message-ID: <20070514122731.0FD5E5240AD7@rubyforge.org> Revision: 266 Author: zond Date: 2007-05-14 08:27:30 -0400 (Mon, 14 May 2007) Log Message: ----------- reverted to r261 Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/lib/oneliner/superstring.rb Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-14 12:25:40 UTC (rev 265) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-14 12:27:30 UTC (rev 266) @@ -22,7 +22,7 @@ // // The distribution of degrees. // -static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; +double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; // // Encrypt the context again @@ -216,9 +216,51 @@ return INT2NUM(tmp); } -static VALUE rb_superstring; -static VALUE rb_context; +// +// Use context to check if the degree blocks adjacent to block +// can lead to anything good. +// +static VALUE +superstring_decode_multiple(VALUE self, VALUE block_data, VALUE blocks, VALUE nr_of_blocks) +{ + VALUE get_func = rb_intern("[]"); + VALUE set_func = rb_intern("[]="); + VALUE this_block; + VALUE block = rb_funcall(block_data, get_func, 1, INT2NUM(0)); + VALUE block_numbers = rb_funcall(block_data, get_func, 1, INT2NUM(1)); + int degree = RARRAY(block_numbers)->len; + int tmp; + int got_new_block = 0; + int missing_blocks = degree; + int _nr_of_blocks = NUM2INT(nr_of_blocks); + int missing_block_nr; + for (tmp = 0; tmp < degree; tmp++) { + int block_nr = NUM2INT(rb_funcall(block_numbers, get_func, 1, INT2NUM(tmp))); + if ((this_block = rb_funcall(blocks, get_func, 1, INT2NUM(block_nr))) != Qnil) { + rb_str_modify(block); + _string_xor2(RSTRING(block)->ptr, RSTRING(this_block)->ptr, RSTRING(this_block)->len); + rb_funcall(block_numbers, set_func, 2, INT2NUM(tmp), Qnil); + missing_blocks--; + } else { + missing_block_nr = block_nr; + } + } + + rb_funcall(block_numbers, rb_intern("compact!"), 0); + + if (missing_blocks == 1) { + rb_funcall(blocks, set_func, 2, INT2NUM(missing_block_nr), block); + got_new_block = 1; + } + + return got_new_block ? Qtrue : Qfalse; +} + + +VALUE rb_superstring; +VALUE rb_context; + #ifdef __cplusplus extern "C" { #endif @@ -239,6 +281,7 @@ rb_define_method(string, "^=", string_xor2, 1); rb_define_method(string, "hack", string_hack, 1); rb_define_method(rb_superstring, "get_degree", superstring_get_degree, 1); + rb_define_method(rb_superstring, "decode_multiple", superstring_decode_multiple, 3); } #ifdef __cplusplus } Modified: trunk/oneliner/lib/oneliner/superstring.rb =================================================================== --- trunk/oneliner/lib/oneliner/superstring.rb 2007-05-14 12:25:40 UTC (rev 265) +++ trunk/oneliner/lib/oneliner/superstring.rb 2007-05-14 12:27:30 UTC (rev 266) @@ -19,7 +19,7 @@ require 'digest/sha2' module Oneliner - + # # A String subclass providing Online Code functionality. # @@ -28,81 +28,12 @@ E = 0.01 Q = 3 F = (Math.log((E ** 2) / 4) / Math.log(1 - (E / 2))).abs.to_i - - # - # A class that represents a block created from xoring other blocks. - # - class XORBlock - attr_accessor :xor_sum, :source_blocks - # - # Initialize the XORBlock with the given +xor_sum+ and an empty hash of source blocks. - # - def initialize(xor_sum) - @xor_sum = xor_sum - @source_blocks = {} - end - # - # Record that the given +source_block_nr+ is a part of this check block (one more time, - # if necessary). - # - def <<(source_block_nr) - @source_blocks[source_block_nr] ||= 0 - @source_blocks[source_block_nr] += 1 - end - # - # Return whether we are - # :finished (our xor_sum represents the value of the sole remaining source block) - # :empty (we can just as well be deleted, we can not be of any good) - # or :running (we need more data to reach a conclusion) - # - def state - case @source_blocks.size - when 1 - if @source_blocks.values.first % 2 == 1 - :finished - else - :empty - end - when 0 - :empty - else - :running - end - end - # - # Record that the +found_block_nr+ has +value+ and delete it from our set of source blocks. - # - def apply(found_block_nr, value) - #puts "#{self.inspect}.apply(#{found_block_nr}, #{value.inspect})" - while @source_blocks[found_block_nr] > 0 - @xor_sum ^= value - @source_blocks[found_block_nr] -= 1 - end - @source_blocks.delete(found_block_nr) - #puts "and now we have #{@source_blocks.size} blocks left, and our state is #{state}" - end + P = [0, (1 - ((1 + (1 / F)) / (1 + E)))] + 2.upto(F) do |i| + P << (((1 - P[1]) * F) / ((F - 1) * i * (i - 1))) end # - # AuxBlocks are just like XORBlocks but they need to be - # accounted for even if we dont know their xor_sum yet... - # - class AuxBlock < XORBlock - attr_accessor :block_nr - def initialize(block_nr) - @xor_sum = nil - @source_blocks = {} - @block_nr = block_nr - end - def apply(found_block_nr, value) - if @xor_sum.nil? - @xor_sum = "\000" * value.size - end - super - end - end - - # # Will return a String containing +requested_size+ nr of bytes # as an online coded chunk of blocks for this SuperString. # @@ -136,6 +67,8 @@ def decode!(chunk) raise "#{chunk.inspect} is too small for metadata (8 bytes)" unless chunk.size > 7 + @decode_done = nil + context = Context.new requested_size = chunk[0..3].unpack("i").first @@ -144,10 +77,15 @@ the_seed = chunk[4..7].unpack("i").first - add_to_graph(chunk, context, the_seed) + chunk_data = build_chunk_data(chunk, context, the_seed) + + @known_nr_of_blocks += chunk_data.size + @known_chunks.unshift(chunk_data) if @known_nr_of_blocks > @nr_of_blocks - + + nil while do_decode(context) + if decode_done? self.replace(compact(@blocks[0... at nr_of_data_blocks])[0...requested_size]) return true @@ -180,6 +118,29 @@ # # + # Builds a Hash with index of each block in the +chunk+ + # paired with the block itself and the source blocks for + # that block determined using +context+ and +the_seed+. + # + def build_chunk_data(chunk, context, the_seed) + blocks_to_return = {} + + context.seed(the_seed) + + expand(chunk[8..-1]).each_with_index do |block, index| + this_degree = get_degree(context) + these_blocks = [] + this_degree.times do |m| + these_blocks << context.random(@nr_of_blocks) + end + + blocks_to_return[index] = [block, these_blocks] + end + + return blocks_to_return + end + + # # Split +s+ up into @block_size (in bits if less than 8, otherwise closed matching nr of bytes) pieces # and return them in an array. # @@ -246,337 +207,99 @@ # Decoding stuff # - # - # Initial decoding and graph building. ARGH!!!1111eleven - # - def add_to_graph(chunk, context, the_seed) - - # - # Initialize the context so that we get the same rand numbers as when we built the chunk. - # - context.seed(the_seed) - - # - # Everything except the first 8 chars of the chunk are check blocks. - # - chunk_blocks = expand(chunk[8..-1]) - @known_nr_of_blocks += chunk_blocks.size - - # - # Go through the chunk... - # - class << chunk_blocks - alias :add_to_graph_each :each + def do_decode(context) + found_new_block = false + @known_chunks.clone.each_with_index do |chunk_data, i| + this_chunk_found_new_block, this_chunk_informative = decode_chunk(chunk_data) + found_new_block = found_new_block || this_chunk_found_new_block + @known_chunks.delete(i) unless this_chunk_informative end - chunk_blocks.add_to_graph_each do |block| + return aux_decode || found_new_block + end - # - # Get the degree from the context. - # - degree_for_this_block = get_degree(context) + def aux_decode + got_new_block = false - # - # If we have the nice case of a single-source-block check block - # we just set the block and remember to see if it leads somewhere. - # - # Else we have a merry go round of fucking forks... - # - if degree_for_this_block == 1 - found_block_nr = context.random(@nr_of_blocks) - @blocks[found_block_nr] = block - #puts "single source: \##{found_block_nr} = #{block.inspect}" - analyze(found_block_nr, block) - else - # - # Build a graph component with the block. - # - check_block = XORBlock.new(block) + @nr_of_data_blocks.upto(@nr_of_blocks - 1) do |i| - # - # Remember where this check block is supposed to be inserted. - # - inserts = [] - - # - # For each wanted source block... - # - degree_for_this_block.times do |m| - # - # Find it from the context. - # - this_source_block_nr = context.random(@nr_of_blocks) + aux_block = @blocks[i] + if aux_block - # - # If we already have this block, just modify the xor_sum accordingly, otherwise... - # - if (known_block = @blocks[this_source_block_nr]) - check_block.xor_sum ^= known_block - #puts "#{degree_for_this_block} known source: \##{this_source_block_nr} = #{known_block.inspect}" - else - # - # Add this source source block nr to our known source blocks. - # - check_block << this_source_block_nr + source_blocks = @aux_hash[i] + if source_blocks.size == 1 + block_nr = source_blocks.first - # - # Get (and possibly set) the check block array for this source block - # and add our data to it. - # - inserts << { - :set => check_blocks_for_this_source_block = (@graph[this_source_block_nr] ||= Set.new), - :value => check_block - } - #puts "#{degree_for_this_block} unknown source: \##{this_source_block_nr}" + if @blocks[block_nr].nil? + @blocks[block_nr] = aux_block + got_new_block = true + @blocks[i] = nil end - end - - # - # If we only had one missing block, then we can remember it and see if it leads someplace. - # - # Otherwise insert it wherever it was supposed to be inserted. - # - case check_block.state - when :finished - @blocks[new_block = check_block.source_blocks.keys.first] = check_block.xor_sum - #puts "#{degree_for_this_block} source: \##{new_block} = #{check_block.xor_sum.inspect}" - analyze(new_block, check_block.xor_sum) - when :running - inserts.each do |insert| - s = insert[:set] - s << insert[:value] + else + missing_blocks = source_blocks.size + missing_block = nil + xor_sum = aux_block + source_blocks.each do |block| + source_block = @blocks[block] + if source_block + missing_blocks -= 1 + xor_sum ^= source_block + else + missing_block = block + end end - end - end - end - end - - # - # Analyze what we can conclude from a known block. - # - def analyze_block(block_nr, block_value) - # - # Remember what we want to analyze when this is done. - # - to_analyze = [] - - # - # If we have any unresolved check blocks for this block. - # - if unresolved_check_blocks_for_this_block = @graph[block_nr] - # - # For each such block... - # - unresolved_check_blocks_for_this_block.clone.each do |check_block| - # - # Apply our newly found knowledge. - # - check_block.apply(block_nr, block_value) - - # - # Remove this check block from the list of check blocks for this block. - # - unresolved_check_blocks_for_this_block.delete(check_block) - - # - # If the check block has finished its career and contains useful data. - # - if check_block.state == :finished - # - # Record the found block. - # - @blocks[new_block = check_block.source_blocks.keys.first] = check_block.xor_sum - - # - # Remove this check block from the found block, and if empty remove the - # check block list for it. - # - unresolved_check_blocks_for_found_block = @graph[new_block] - unresolved_check_blocks_for_found_block.delete(check_block) - @graph.delete(new_block) if unresolved_check_blocks_for_found_block.empty? - - #puts "\##{block_nr} = #{block_value.inspect} => \##{new_block} = #{check_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, check_block.xor_sum] - else - #puts "nah, still #{check_block.source_blocks.size} unknowns" + if missing_blocks == 1 + @blocks[missing_block] = xor_sum + got_new_block = true + @blocks[i] = nil + end end end - - # - # Delete this block from the graph after we have done all we can for it. - # - @graph.delete(block_nr) end - # - # Analyze what we found out earlier. - # - to_analyze.each do |new_block, sum| - analyze(new_block, sum) - end + return got_new_block end - - # - # Analyze the results of new known blocks. - # - def analyze(block_nr, block_value) - #puts "analyzing \##{block_nr} = #{block_value.inspect}" - # - # Do analyze_block on the block nr to see if we can resolve any check block - # relations from this block. - # - analyze_block(block_nr, block_value) - # - # Do aux_analyze_block on the block to see if we can resolve any aux block - # relations from this block. - # - analyze_aux_block(block_nr, block_value) - end - # - # Analyze what we can conclude from the aux block relations and a new block. - # - def analyze_aux_block(block_nr, block_value) - # - # Remember what we want to analyze when done. - # - to_analyze = [] + def decode_chunk(blocks) + got_new_block = false + got_informative_block = false - # - # If this block is a data block, check to see if it is the next to last - # remaining block for a known aux block. - # - # Else, check to see if we have all data blocks except one for this aux block. - # - if block_nr < @nr_of_data_blocks - # - # If we have unresolved aux data for this block. - # - if unresolved_aux_blocks_for_this_block = @aux_graph[block_nr] - # - # For each such block... - # - unresolved_aux_blocks_for_this_block.clone.each do |aux_block| - # - # If it is known. - # - if known_block = @blocks[aux_block.block_nr] - # - # Apply our new knowledge to it. - # - aux_block.apply(block_nr, block_value) - # - # Delete it from our list of unresolved blocks. - # - unresolved_aux_blocks_for_this_block.delete(aux_block) - # - # If the aux block is :finished (ie it has all but one of its data blocks - # accounted for). - # - if aux_block.state == :finished - # - # Record the found block to be the xor of the component blocks of the aux_block and the aux_block itself. - # - @blocks[new_block = aux_block.source_blocks.keys.first] = aux_block.xor_sum ^ known_block + blocks.clone.each do |index, block_data| - # - # Remove the aux block from the aux graph. - # - @aux_graph.delete(aux_block.block_nr) + block, block_numbers = block_data - # - # Remove this aux block from the found block, and if empty remove the - # check block list for it. - # - unresolved_aux_blocks_for_found_block = @aux_graph[new_block] - unresolved_aux_blocks_for_found_block.delete(aux_block) - @aux_graph.delete(new_block) if unresolved_aux_blocks_for_found_block.empty? - - #puts "aux: \##{block_nr} = #{block_value.inspect} => \##{new_block} = #{aux_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, aux_block.xor_sum] - else - #puts "aux: nah, still #{aux_block.source_blocks.size} unknowns" - end - end - end - # - # Delete this block from the aux graph after we have done all we can for it. - # - @aux_graph.delete(block_nr) if unresolved_aux_blocks_for_this_block.empty? - end - else - aux_block = @aux_graph[block_nr] + got_informative_block = true - # - # If the aux block is :finished (ie it has all but one of its data blocks - # accounted for). - # - if aux_block && aux_block.state == :finished - # - # Record the found block to be the xor of the component blocks of the aux_block and itself. - # - @blocks[new_block = aux_block.source_blocks.keys.first] = aux_block.xor_sum ^ block_value - - # - # Remove the aux block from the aux_graph. - # - @aux_graph.delete(block_nr) + if block_numbers.size == 1 + block_nr = block_numbers.first - # - # Remove this aux block from the found block, and if empty remove the - # check block list for it. - # - unresolved_aux_blocks_for_found_block = @aux_graph[new_block] - unresolved_aux_blocks_for_found_block.delete(aux_block) - @aux_graph.delete(new_block) if unresolved_aux_blocks_for_found_block.empty? - - #puts "aux: \##{block_nr} = #{block_value.inspect} => \##{new_block} = #{check_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, check_block.xor_sum] + if @blocks[block_nr].nil? + @blocks[block_nr] = block + got_new_block = true + blocks.delete(index) + end + else + if decode_multiple(block_data, @blocks, @nr_of_blocks) + got_new_block = true + blocks.delete(index) + end end + end - - # - # Analyze what we found out earlier. - # - to_analyze.each do |new_block, sum| - analyze(new_block, sum) - end + + return [got_new_block, got_informative_block] end - - # - # Generate the graph containing the relations between the data blocks - # and the aux blocks. - # - # {block nr in composite data => [data block 0, ..., data block n]} - # - def generate_aux_graph - rval = {} + + def generate_aux_hash + rval = Array.new(@nr_of_blocks) context = Context.new context.seed(@nr_of_data_blocks) - 0.upto(@nr_of_data_blocks - 1) do |data_block_nr| - - aux_blocks_for_this_data_block = Set.new - rval[data_block_nr] = aux_blocks_for_this_data_block - + 0.upto(@nr_of_data_blocks - 1) do |i| 1.upto(Q) do aux_block_nr = @nr_of_data_blocks + context.random(@nr_of_aux_blocks) - aux_block = (rval[aux_block_nr] ||= AuxBlock.new(aux_block_nr)) - aux_block << data_block_nr - aux_blocks_for_this_data_block << aux_block + (rval[aux_block_nr] ||= []) << i end end @@ -585,8 +308,6 @@ def ensure_decode_format(requested_size) unless defined?(@blocks) - @graph = {} - @decode_done = nil self.concat("\000" * requested_size) set_block_size @nr_of_data_blocks = expand(self).size @@ -594,8 +315,10 @@ @blocks = Array.new(@nr_of_data_blocks) @blocks += Array.new(@nr_of_aux_blocks) set_nr_of_blocks - @aux_graph = generate_aux_graph + @aux_hash = generate_aux_hash + @known_chunks = [] @known_nr_of_blocks = 0 + @known_block_nrs_by_seed = {} end end From nobody at rubyforge.org Mon May 14 08:27:56 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 08:27:56 -0400 (EDT) Subject: [Archipelago-submits] [267] trunk/oneliner/Rakefile: bumped version number Message-ID: <20070514122756.8C87D5240B50@rubyforge.org> Revision: 267 Author: zond Date: 2007-05-14 08:27:56 -0400 (Mon, 14 May 2007) Log Message: ----------- bumped version number Modified Paths: -------------- trunk/oneliner/Rakefile Modified: trunk/oneliner/Rakefile =================================================================== --- trunk/oneliner/Rakefile 2007-05-14 12:27:30 UTC (rev 266) +++ trunk/oneliner/Rakefile 2007-05-14 12:27:56 UTC (rev 267) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "oneliner" - s.version = "0.2.5" + s.version = "0.2.6" s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "An online code implementation for ruby." From nobody at rubyforge.org Mon May 14 08:29:47 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 08:29:47 -0400 (EDT) Subject: [Archipelago-submits] [268] made release_0_2_6 Message-ID: <20070514122948.05C635240B61@rubyforge.org> Revision: 268 Author: zond Date: 2007-05-14 08:29:47 -0400 (Mon, 14 May 2007) Log Message: ----------- made release_0_2_6 Modified Paths: -------------- trunk/hyperactive/Rakefile Added Paths: ----------- tags/release_0_2_6/ tags/release_0_2_6/archipelago/ tags/release_0_2_6/archipelago/Rakefile tags/release_0_2_6/oneliner/ tags/release_0_2_6/oneliner/Rakefile tags/release_0_2_6/oneliner/ext/oneliner_ext.c tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb Removed Paths: ------------- tags/release_0_2_6/archipelago/Rakefile tags/release_0_2_6/oneliner/Rakefile tags/release_0_2_6/oneliner/ext/oneliner_ext.c tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb Copied: tags/release_0_2_6/archipelago (from rev 264, trunk/archipelago) Deleted: tags/release_0_2_6/archipelago/Rakefile =================================================================== --- trunk/archipelago/Rakefile 2007-05-10 12:15:20 UTC (rev 264) +++ tags/release_0_2_6/archipelago/Rakefile 2007-05-14 12:29:47 UTC (rev 268) @@ -1,59 +0,0 @@ - -require 'rake' -require 'rake/testtask' -require 'rubygems' -Gem::manage_gems -require 'rake/gempackagetask' - - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = "archipelago" - s.version = "0.2.5" - s.author = "Martin Kihlgren" - s.email = "zond at troja dot ath dot cx" - s.summary = "A set of tools for distributed computing in ruby." - s.files = FileList['lib/**/*.rb', 'tests/*', 'script/*', 'GPL-2', 'TODO'].to_a - s.require_path = "lib" - s.autorequire = "archipelago" - s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') - s.has_rdoc = true - s.rdoc_options << '--line-numbers' - s.rdoc_options << '--inline-source' - s.extra_rdoc_files = ["README"] -end - - -SOURCE_FILES = FileList.new do |fl| - [ "lib", "tests" ].each do |dir| - fl.include "#{dir}/**/*" - end - fl.include "Rakefile" -end - -Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar = true -end - -task :default => [:units] do -end - -desc "Run all tests" -Rake::TestTask.new(:units) do |t| - t.pattern = 'tests/*_test.rb' - t.verbose = true - t.warning = true -end - -desc "Run all benchmarks" -Rake::TestTask.new(:bench) do |t| - t.pattern = 'tests/*_benchmark.rb' - t.verbose = true - t.warning = true -end - -desc "Package a gem from the source" -task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do - puts "generated latest version" -end - Copied: tags/release_0_2_6/archipelago/Rakefile (from rev 265, trunk/archipelago/Rakefile) =================================================================== --- tags/release_0_2_6/archipelago/Rakefile (rev 0) +++ tags/release_0_2_6/archipelago/Rakefile 2007-05-14 12:29:47 UTC (rev 268) @@ -0,0 +1,59 @@ + +require 'rake' +require 'rake/testtask' +require 'rubygems' +Gem::manage_gems +require 'rake/gempackagetask' + + +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.name = "archipelago" + s.version = "0.2.6" + s.author = "Martin Kihlgren" + s.email = "zond at troja dot ath dot cx" + s.summary = "A set of tools for distributed computing in ruby." + s.files = FileList['lib/**/*.rb', 'tests/*', 'script/*', 'GPL-2', 'TODO'].to_a + s.require_path = "lib" + s.autorequire = "archipelago" + s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') + s.has_rdoc = true + s.rdoc_options << '--line-numbers' + s.rdoc_options << '--inline-source' + s.extra_rdoc_files = ["README"] +end + + +SOURCE_FILES = FileList.new do |fl| + [ "lib", "tests" ].each do |dir| + fl.include "#{dir}/**/*" + end + fl.include "Rakefile" +end + +Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_tar = true +end + +task :default => [:units] do +end + +desc "Run all tests" +Rake::TestTask.new(:units) do |t| + t.pattern = 'tests/*_test.rb' + t.verbose = true + t.warning = true +end + +desc "Run all benchmarks" +Rake::TestTask.new(:bench) do |t| + t.pattern = 'tests/*_benchmark.rb' + t.verbose = true + t.warning = true +end + +desc "Package a gem from the source" +task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do + puts "generated latest version" +end + Copied: tags/release_0_2_6/oneliner (from rev 265, trunk/oneliner) Deleted: tags/release_0_2_6/oneliner/Rakefile =================================================================== --- trunk/oneliner/Rakefile 2007-05-14 12:25:40 UTC (rev 265) +++ tags/release_0_2_6/oneliner/Rakefile 2007-05-14 12:29:47 UTC (rev 268) @@ -1,60 +0,0 @@ - -require 'rake' -require 'rake/testtask' -require 'rubygems' -Gem::manage_gems -require 'rake/gempackagetask' - - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = "oneliner" - s.version = "0.2.5" - s.author = "Martin Kihlgren" - s.email = "zond at troja dot ath dot cx" - s.summary = "An online code implementation for ruby." - s.files = FileList['lib/**/*.rb', 'tests/*', 'ext/*', 'GPL-2'].to_a - s.require_path = "lib" - s.extensions << 'ext/extconf.rb' - s.autorequire = "oneliner" - s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') - s.has_rdoc = true - s.rdoc_options << '--line-numbers' - s.rdoc_options << '--inline-source' - s.extra_rdoc_files = ["README"] -end - - -SOURCE_FILES = FileList.new do |fl| - [ "lib", "tests" ].each do |dir| - fl.include "#{dir}/**/*" - end - fl.include "Rakefile" -end - -Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar = true -end - -task :default => [:units] do -end - -desc "Run all tests" -Rake::TestTask.new(:units) do |t| - t.pattern = 'tests/*_test.rb' - t.verbose = true - t.warning = true -end - -desc "Run all benchmarks" -Rake::TestTask.new(:bench) do |t| - t.pattern = 'tests/*_benchmark.rb' - t.verbose = true - t.warning = true -end - -desc "Package a gem from the source" -task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do - puts "generated latest version" -end - Copied: tags/release_0_2_6/oneliner/Rakefile (from rev 267, trunk/oneliner/Rakefile) =================================================================== --- tags/release_0_2_6/oneliner/Rakefile (rev 0) +++ tags/release_0_2_6/oneliner/Rakefile 2007-05-14 12:29:47 UTC (rev 268) @@ -0,0 +1,60 @@ + +require 'rake' +require 'rake/testtask' +require 'rubygems' +Gem::manage_gems +require 'rake/gempackagetask' + + +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.name = "oneliner" + s.version = "0.2.6" + s.author = "Martin Kihlgren" + s.email = "zond at troja dot ath dot cx" + s.summary = "An online code implementation for ruby." + s.files = FileList['lib/**/*.rb', 'tests/*', 'ext/*', 'GPL-2'].to_a + s.require_path = "lib" + s.extensions << 'ext/extconf.rb' + s.autorequire = "oneliner" + s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') + s.has_rdoc = true + s.rdoc_options << '--line-numbers' + s.rdoc_options << '--inline-source' + s.extra_rdoc_files = ["README"] +end + + +SOURCE_FILES = FileList.new do |fl| + [ "lib", "tests" ].each do |dir| + fl.include "#{dir}/**/*" + end + fl.include "Rakefile" +end + +Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_tar = true +end + +task :default => [:units] do +end + +desc "Run all tests" +Rake::TestTask.new(:units) do |t| + t.pattern = 'tests/*_test.rb' + t.verbose = true + t.warning = true +end + +desc "Run all benchmarks" +Rake::TestTask.new(:bench) do |t| + t.pattern = 'tests/*_benchmark.rb' + t.verbose = true + t.warning = true +end + +desc "Package a gem from the source" +task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do + puts "generated latest version" +end + Deleted: tags/release_0_2_6/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-14 12:25:40 UTC (rev 265) +++ tags/release_0_2_6/oneliner/ext/oneliner_ext.c 2007-05-14 12:29:47 UTC (rev 268) @@ -1,246 +0,0 @@ -// Archipelago - a distributed computing toolkit for ruby -// Copyright (C) 2006 Martin Kihlgren -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -#include "ruby.h" -#include -#include - -// -// The distribution of degrees. -// -static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; - -// -// Encrypt the context again -// -static void -_aes_randomize_context(char *context) -{ - AES_KEY key; - - AES_set_encrypt_key((unsigned char *) "0123456789012345", 128, &key); - - AES_encrypt((unsigned char *) context + 4, - (unsigned char *) context + 4, - &key); - ( (int *) context )[0] = 1; -} - -// -// Encrypt the buffer of ctx and set its counter to 0 -// -static void -aes_randomize_context(VALUE self) -{ - rb_str_modify(self); - _aes_randomize_context(RSTRING(self)->ptr); -} - -// -// Fill the buffer of context with seed and randomize it. -// -static VALUE -aes_seed_context(VALUE self, VALUE seed) -{ - int tmp; - - if (RSTRING(self)->len < 17) - rb_str_concat(self, rb_str_new(0, 17)); - - rb_str_modify(self); - for (tmp = 1; tmp < 5; tmp++) - ( (int *) RSTRING(self)->ptr )[tmp] = NUM2INT(seed); - - aes_randomize_context(self); - - return seed; -} - -// -// Return an int that is the next random in the context -// -static int -_aes_random(char *context) -{ - int *int_context = (int *) context; - if (int_context[0] < 5) { - int return_value = int_context[int_context[0]]; - int_context[0]++; - return return_value; - } else { - _aes_randomize_context(context); - return _aes_random(context); - } -} - -// -// Get the int at the counter of context in the buffer of context. -// -static VALUE -aes_random(int argc, VALUE *argv, VALUE self) -{ - int return_value; - - rb_str_modify(self); - return_value = _aes_random(RSTRING(self)->ptr); - - if (argc == 0) { - return rb_float_new( ( (double) ( (unsigned int) return_value ) ) / ( (double) UINT_MAX )); - } else { - VALUE max = argv[0]; - return INT2NUM(( (unsigned int) return_value ) % NUM2INT(max)); - } -} - -// -// Initialize a context. -// -static VALUE -context_initialize(int argc, VALUE *argv, VALUE self) -{ - rb_str_concat(self, rb_str_new(0, 17)); - return self; -} - -// -// Return self ^ subject -// -static VALUE -string_xor(VALUE self, VALUE subject) -{ - int tmp; - int len = RSTRING(self)->len; - VALUE return_value = rb_str_new(0, len); - - Check_Type(subject, T_STRING); - - if (len != RSTRING(subject)->len) - rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); - - rb_str_modify(return_value); - for (tmp = 0; tmp < len / 4; tmp++) { - ( (int *) RSTRING(return_value)->ptr )[tmp] = ( (int *) RSTRING(self)->ptr )[tmp] ^ ( (int *) RSTRING(subject)->ptr )[tmp]; - } - for (tmp = 0; tmp < (len % 4); tmp++) { - RSTRING(return_value)->ptr[len - tmp - 1] = RSTRING(self)->ptr[len - tmp - 1] ^ RSTRING(subject)->ptr[len - tmp - 1]; - } - - return return_value; -} - -// -// Make str into str ^ subject -// -static void -_string_xor2(char *str, char *subject, int len) -{ - int tmp; - - for (tmp = 0; tmp < len / 4; tmp++) { - ( (int *) str )[tmp] = ( (int *) str )[tmp] ^ ( (int *) subject )[tmp]; - } - for (tmp = 0; tmp < (len % 4); tmp++) { - str[len - tmp - 1] = str[len - tmp - 1] ^ subject[len - tmp - 1]; - } -} - -// -// Return an Array with bite size chunks of us -// -static VALUE -string_hack(VALUE self, VALUE size_value) -{ - if (NUM2INT(size_value) < 1) - rb_raise(rb_eTypeError, "argument to hack must be a positive integer > 0"); - - int size = NUM2INT(size_value); - VALUE rval = rb_ary_new(); - int tmp; - - for (tmp = 0; tmp < RSTRING(self)->len; tmp += size) { - rb_ary_push(rval, rb_str_new(RSTRING(self)->ptr + tmp, tmp + size < RSTRING(self)->len ? size : RSTRING(self)->len - tmp)); - } - - return rval; -} - -// -// Make self into self ^ subject -// -static VALUE -string_xor2(VALUE self, VALUE subject) -{ - int tmp; - int len = RSTRING(self)->len; - - Check_Type(subject, T_STRING); - - if (len != RSTRING(subject)->len) - rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); - - rb_str_modify(self); - _string_xor2(RSTRING(self)->ptr, RSTRING(subject)->ptr, len); - - return self; -} - -// -// Get a random degree -// -static VALUE -superstring_get_degree(VALUE self, VALUE context) -{ - double f; - int tmp = 0; - - rb_str_modify(context); - f = ( (double) ( (unsigned int) _aes_random(RSTRING(context)->ptr) ) ) / ( (double) UINT_MAX ); - while (f > 0) { - tmp++; - f = f - P[tmp]; - } - return INT2NUM(tmp); -} - -static VALUE rb_superstring; -static VALUE rb_context; - -#ifdef __cplusplus -extern "C" { -#endif - void Init_oneliner_ext() { - VALUE string = rb_const_get(rb_cObject, rb_intern("String")); - rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), - "SuperString", - string); - rb_context = rb_define_class_under(rb_superstring, - "Context", - string); - - rb_define_const(rb_context, "INT_MAX", INT2NUM(INT_MAX)); - rb_define_method(rb_context, "initialize", context_initialize, -1); - rb_define_method(rb_context, "random", aes_random, -1); - rb_define_method(rb_context, "seed", aes_seed_context, 1); - rb_define_method(string, "^", string_xor, 1); - rb_define_method(string, "^=", string_xor2, 1); - rb_define_method(string, "hack", string_hack, 1); - rb_define_method(rb_superstring, "get_degree", superstring_get_degree, 1); - } -#ifdef __cplusplus -} -#endif - Copied: tags/release_0_2_6/oneliner/ext/oneliner_ext.c (from rev 266, trunk/oneliner/ext/oneliner_ext.c) =================================================================== --- tags/release_0_2_6/oneliner/ext/oneliner_ext.c (rev 0) +++ tags/release_0_2_6/oneliner/ext/oneliner_ext.c 2007-05-14 12:29:47 UTC (rev 268) @@ -0,0 +1,289 @@ +// Archipelago - a distributed computing toolkit for ruby +// Copyright (C) 2006 Martin Kihlgren +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#include "ruby.h" +#include +#include + +// +// The distribution of degrees. +// +double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; + +// +// Encrypt the context again +// +static void +_aes_randomize_context(char *context) +{ + AES_KEY key; + + AES_set_encrypt_key((unsigned char *) "0123456789012345", 128, &key); + + AES_encrypt((unsigned char *) context + 4, + (unsigned char *) context + 4, + &key); + ( (int *) context )[0] = 1; +} + +// +// Encrypt the buffer of ctx and set its counter to 0 +// +static void +aes_randomize_context(VALUE self) +{ + rb_str_modify(self); + _aes_randomize_context(RSTRING(self)->ptr); +} + +// +// Fill the buffer of context with seed and randomize it. +// +static VALUE +aes_seed_context(VALUE self, VALUE seed) +{ + int tmp; + + if (RSTRING(self)->len < 17) + rb_str_concat(self, rb_str_new(0, 17)); + + rb_str_modify(self); + for (tmp = 1; tmp < 5; tmp++) + ( (int *) RSTRING(self)->ptr )[tmp] = NUM2INT(seed); + + aes_randomize_context(self); + + return seed; +} + +// +// Return an int that is the next random in the context +// +static int +_aes_random(char *context) +{ + int *int_context = (int *) context; + if (int_context[0] < 5) { + int return_value = int_context[int_context[0]]; + int_context[0]++; + return return_value; + } else { + _aes_randomize_context(context); + return _aes_random(context); + } +} + +// +// Get the int at the counter of context in the buffer of context. +// +static VALUE +aes_random(int argc, VALUE *argv, VALUE self) +{ + int return_value; + + rb_str_modify(self); + return_value = _aes_random(RSTRING(self)->ptr); + + if (argc == 0) { + return rb_float_new( ( (double) ( (unsigned int) return_value ) ) / ( (double) UINT_MAX )); + } else { + VALUE max = argv[0]; + return INT2NUM(( (unsigned int) return_value ) % NUM2INT(max)); + } +} + +// +// Initialize a context. +// +static VALUE +context_initialize(int argc, VALUE *argv, VALUE self) +{ + rb_str_concat(self, rb_str_new(0, 17)); + return self; +} + +// +// Return self ^ subject +// +static VALUE +string_xor(VALUE self, VALUE subject) +{ + int tmp; + int len = RSTRING(self)->len; + VALUE return_value = rb_str_new(0, len); + + Check_Type(subject, T_STRING); + + if (len != RSTRING(subject)->len) + rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); + + rb_str_modify(return_value); + for (tmp = 0; tmp < len / 4; tmp++) { + ( (int *) RSTRING(return_value)->ptr )[tmp] = ( (int *) RSTRING(self)->ptr )[tmp] ^ ( (int *) RSTRING(subject)->ptr )[tmp]; + } + for (tmp = 0; tmp < (len % 4); tmp++) { + RSTRING(return_value)->ptr[len - tmp - 1] = RSTRING(self)->ptr[len - tmp - 1] ^ RSTRING(subject)->ptr[len - tmp - 1]; + } + + return return_value; +} + +// +// Make str into str ^ subject +// +static void +_string_xor2(char *str, char *subject, int len) +{ + int tmp; + + for (tmp = 0; tmp < len / 4; tmp++) { + ( (int *) str )[tmp] = ( (int *) str )[tmp] ^ ( (int *) subject )[tmp]; + } + for (tmp = 0; tmp < (len % 4); tmp++) { + str[len - tmp - 1] = str[len - tmp - 1] ^ subject[len - tmp - 1]; + } +} + +// +// Return an Array with bite size chunks of us +// +static VALUE +string_hack(VALUE self, VALUE size_value) +{ + if (NUM2INT(size_value) < 1) + rb_raise(rb_eTypeError, "argument to hack must be a positive integer > 0"); + + int size = NUM2INT(size_value); + VALUE rval = rb_ary_new(); + int tmp; + + for (tmp = 0; tmp < RSTRING(self)->len; tmp += size) { + rb_ary_push(rval, rb_str_new(RSTRING(self)->ptr + tmp, tmp + size < RSTRING(self)->len ? size : RSTRING(self)->len - tmp)); + } + + return rval; +} + +// +// Make self into self ^ subject +// +static VALUE +string_xor2(VALUE self, VALUE subject) +{ + int tmp; + int len = RSTRING(self)->len; + + Check_Type(subject, T_STRING); + + if (len != RSTRING(subject)->len) + rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); + + rb_str_modify(self); + _string_xor2(RSTRING(self)->ptr, RSTRING(subject)->ptr, len); + + return self; +} + +// +// Get a random degree +// +static VALUE +superstring_get_degree(VALUE self, VALUE context) +{ + double f; + int tmp = 0; + + rb_str_modify(context); + f = ( (double) ( (unsigned int) _aes_random(RSTRING(context)->ptr) ) ) / ( (double) UINT_MAX ); + while (f > 0) { + tmp++; + f = f - P[tmp]; + } + return INT2NUM(tmp); +} + +// +// Use context to check if the degree blocks adjacent to block +// can lead to anything good. +// +static VALUE +superstring_decode_multiple(VALUE self, VALUE block_data, VALUE blocks, VALUE nr_of_blocks) +{ + VALUE get_func = rb_intern("[]"); + VALUE set_func = rb_intern("[]="); + VALUE this_block; + VALUE block = rb_funcall(block_data, get_func, 1, INT2NUM(0)); + VALUE block_numbers = rb_funcall(block_data, get_func, 1, INT2NUM(1)); + int degree = RARRAY(block_numbers)->len; + int tmp; + int got_new_block = 0; + int missing_blocks = degree; + int _nr_of_blocks = NUM2INT(nr_of_blocks); + int missing_block_nr; + + for (tmp = 0; tmp < degree; tmp++) { + int block_nr = NUM2INT(rb_funcall(block_numbers, get_func, 1, INT2NUM(tmp))); + if ((this_block = rb_funcall(blocks, get_func, 1, INT2NUM(block_nr))) != Qnil) { + rb_str_modify(block); + _string_xor2(RSTRING(block)->ptr, RSTRING(this_block)->ptr, RSTRING(this_block)->len); + rb_funcall(block_numbers, set_func, 2, INT2NUM(tmp), Qnil); + missing_blocks--; + } else { + missing_block_nr = block_nr; + } + } + + rb_funcall(block_numbers, rb_intern("compact!"), 0); + + if (missing_blocks == 1) { + rb_funcall(blocks, set_func, 2, INT2NUM(missing_block_nr), block); + got_new_block = 1; + } + + return got_new_block ? Qtrue : Qfalse; +} + + +VALUE rb_superstring; +VALUE rb_context; + +#ifdef __cplusplus +extern "C" { +#endif + void Init_oneliner_ext() { + VALUE string = rb_const_get(rb_cObject, rb_intern("String")); + rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), + "SuperString", + string); + rb_context = rb_define_class_under(rb_superstring, + "Context", + string); + + rb_define_const(rb_context, "INT_MAX", INT2NUM(INT_MAX)); + rb_define_method(rb_context, "initialize", context_initialize, -1); + rb_define_method(rb_context, "random", aes_random, -1); + rb_define_method(rb_context, "seed", aes_seed_context, 1); + rb_define_method(string, "^", string_xor, 1); + rb_define_method(string, "^=", string_xor2, 1); + rb_define_method(string, "hack", string_hack, 1); + rb_define_method(rb_superstring, "get_degree", superstring_get_degree, 1); + rb_define_method(rb_superstring, "decode_multiple", superstring_decode_multiple, 3); + } +#ifdef __cplusplus +} +#endif + Deleted: tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb =================================================================== --- trunk/oneliner/lib/oneliner/superstring.rb 2007-05-14 12:25:40 UTC (rev 265) +++ tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb 2007-05-14 12:29:47 UTC (rev 268) @@ -1,662 +0,0 @@ -# Archipelago - a distributed computing toolkit for ruby -# Copyright (C) 2006 Martin Kihlgren -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require 'set' -require 'digest/sha2' - -module Oneliner - - # - # A String subclass providing Online Code functionality. - # - class SuperString < String - - E = 0.01 - Q = 3 - F = (Math.log((E ** 2) / 4) / Math.log(1 - (E / 2))).abs.to_i - - # - # A class that represents a block created from xoring other blocks. - # - class XORBlock - attr_accessor :xor_sum, :source_blocks - # - # Initialize the XORBlock with the given +xor_sum+ and an empty hash of source blocks. - # - def initialize(xor_sum) - @xor_sum = xor_sum - @source_blocks = {} - end - # - # Record that the given +source_block_nr+ is a part of this check block (one more time, - # if necessary). - # - def <<(source_block_nr) - @source_blocks[source_block_nr] ||= 0 - @source_blocks[source_block_nr] += 1 - end - # - # Return whether we are - # :finished (our xor_sum represents the value of the sole remaining source block) - # :empty (we can just as well be deleted, we can not be of any good) - # or :running (we need more data to reach a conclusion) - # - def state - case @source_blocks.size - when 1 - if @source_blocks.values.first % 2 == 1 - :finished - else - :empty - end - when 0 - :empty - else - :running - end - end - # - # Record that the +found_block_nr+ has +value+ and delete it from our set of source blocks. - # - def apply(found_block_nr, value) - #puts "#{self.inspect}.apply(#{found_block_nr}, #{value.inspect})" - while @source_blocks[found_block_nr] > 0 - @xor_sum ^= value - @source_blocks[found_block_nr] -= 1 - end - @source_blocks.delete(found_block_nr) - #puts "and now we have #{@source_blocks.size} blocks left, and our state is #{state}" - end - end - - # - # AuxBlocks are just like XORBlocks but they need to be - # accounted for even if we dont know their xor_sum yet... - # - class AuxBlock < XORBlock - attr_accessor :block_nr - def initialize(block_nr) - @xor_sum = nil - @source_blocks = {} - @block_nr = block_nr - end - def apply(found_block_nr, value) - if @xor_sum.nil? - @xor_sum = "\000" * value.size - end - super - end - end - - # - # Will return a String containing +requested_size+ nr of bytes - # as an online coded chunk of blocks for this SuperString. - # - def encode(requested_size) - raise "requested size is too small for metadata (8 bytes)" unless requested_size > 7 - - ensure_encode_format - srand - seed = rand(Context::INT_MAX) - context = Context.new - context.seed(seed) - - rval = [self.size].pack("i") - rval << [seed].pack("i") - - blocks = [] - wanted_blocks = ((requested_size - 8) * 8) / @block_size - 1.upto(wanted_blocks) do |n| - blocks << generate_check_block(context, n - 1) - end - - return rval + compact(blocks) - end - - # - # Will try to decode this SuperString using the given +chunk+ and all - # formerly given chunks. - # - # Returns whether decoding is done. - # - def decode!(chunk) - raise "#{chunk.inspect} is too small for metadata (8 bytes)" unless chunk.size > 7 - - context = Context.new - - requested_size = chunk[0..3].unpack("i").first - - ensure_decode_format(requested_size) - - the_seed = chunk[4..7].unpack("i").first - - add_to_graph(chunk, context, the_seed) - - if @known_nr_of_blocks > @nr_of_blocks - - if decode_done? - self.replace(compact(@blocks[0... at nr_of_data_blocks])[0...requested_size]) - return true - else - return false - end - - else - return false - end - end - - # - # Returns whether decoding is done. - # - def decode_done? - return false unless defined?(@decode_done) && defined?(@nr_of_data_blocks) - - unless @decode_done - data = @blocks[0... at nr_of_data_blocks] - @decode_done = data.compact.size == data.size - end - return @decode_done - end - - private - - # - # Misc stuff - # - - # - # Split +s+ up into @block_size (in bits if less than 8, otherwise closed matching nr of bytes) pieces - # and return them in an array. - # - def expand(s) - if @block_size < 8 - rval = s.unpack("b*").first - rval = rval.gsub(/(.{#{@block_size},#{@block_size}})/, "\\1#{"0" * (8 - @block_size)}") - rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 - rval = [rval].pack("b*") - return rval.split(//) - else - bytes_per_block = @block_size / 8 - rval = s - rval += "\000" * (bytes_per_block - (rval.size % bytes_per_block)) if (rval.size % bytes_per_block) > 0 - return rval.hack(bytes_per_block) - end - end - - # - # Glue +blocks+ together into a String. - # - def compact(blocks) - if @block_size < 8 - rval = blocks.join - rval = rval.unpack("b*") - rval = rval.first.gsub(/(.{#{@block_size},#{@block_size}}).{#{8 - @block_size},#{8 - @block_size}}/, - "\\1") - rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 - return [rval].pack("b*") - else - return blocks.join - end - end - - # - # Determine and save the nr of aux_blocks we want for this SuperString. - # - def set_nr_of_aux_blocks - @nr_of_aux_blocks ||= (0.55 * Q * E * @nr_of_data_blocks).ceil - end - - # - # Determine and save the block_size we want for this SuperString. - # - def set_block_size - unless defined?(@block_size) - if size < (256 + 128) - @block_size = 1 - else - @block_size = size / 256 - end - end - return @block_size - end - - # - # Determine and save the nr_of_blocks we want for this SuperString. - # - def set_nr_of_blocks - @nr_of_blocks ||= @blocks.size - end - - # - # Decoding stuff - # - - # - # Initial decoding and graph building. ARGH!!!1111eleven - # - def add_to_graph(chunk, context, the_seed) - - # - # Initialize the context so that we get the same rand numbers as when we built the chunk. - # - context.seed(the_seed) - - # - # Everything except the first 8 chars of the chunk are check blocks. - # - chunk_blocks = expand(chunk[8..-1]) - @known_nr_of_blocks += chunk_blocks.size - - # - # Go through the chunk... - # - class << chunk_blocks - alias :add_to_graph_each :each - end - chunk_blocks.add_to_graph_each do |block| - - # - # Get the degree from the context. - # - degree_for_this_block = get_degree(context) - - # - # If we have the nice case of a single-source-block check block - # we just set the block and remember to see if it leads somewhere. - # - # Else we have a merry go round of fucking forks... - # - if degree_for_this_block == 1 - found_block_nr = context.random(@nr_of_blocks) - @blocks[found_block_nr] = block - #puts "single source: \##{found_block_nr} = #{block.inspect}" - analyze(found_block_nr, block) - else - # - # Build a graph component with the block. - # - check_block = XORBlock.new(block) - - # - # Remember where this check block is supposed to be inserted. - # - inserts = [] - - # - # For each wanted source block... - # - degree_for_this_block.times do |m| - # - # Find it from the context. - # - this_source_block_nr = context.random(@nr_of_blocks) - - # - # If we already have this block, just modify the xor_sum accordingly, otherwise... - # - if (known_block = @blocks[this_source_block_nr]) - check_block.xor_sum ^= known_block - #puts "#{degree_for_this_block} known source: \##{this_source_block_nr} = #{known_block.inspect}" - else - # - # Add this source source block nr to our known source blocks. - # - check_block << this_source_block_nr - - # - # Get (and possibly set) the check block array for this source block - # and add our data to it. - # - inserts << { - :set => check_blocks_for_this_source_block = (@graph[this_source_block_nr] ||= Set.new), - :value => check_block - } - #puts "#{degree_for_this_block} unknown source: \##{this_source_block_nr}" - end - end - - # - # If we only had one missing block, then we can remember it and see if it leads someplace. - # - # Otherwise insert it wherever it was supposed to be inserted. - # - case check_block.state - when :finished - @blocks[new_block = check_block.source_blocks.keys.first] = check_block.xor_sum - #puts "#{degree_for_this_block} source: \##{new_block} = #{check_block.xor_sum.inspect}" - analyze(new_block, check_block.xor_sum) - when :running - inserts.each do |insert| - s = insert[:set] - s << insert[:value] - end - end - end - end - - end - - # - # Analyze what we can conclude from a known block. - # - def analyze_block(block_nr, block_value) - # - # Remember what we want to analyze when this is done. - # - to_analyze = [] - - # - # If we have any unresolved check blocks for this block. - # - if unresolved_check_blocks_for_this_block = @graph[block_nr] - # - # For each such block... - # - unresolved_check_blocks_for_this_block.clone.each do |check_block| - # - # Apply our newly found knowledge. - # - check_block.apply(block_nr, block_value) - - # - # Remove this check block from the list of check blocks for this block. - # - unresolved_check_blocks_for_this_block.delete(check_block) - - # - # If the check block has finished its career and contains useful data. - # - if check_block.state == :finished - # - # Record the found block. - # - @blocks[new_block = check_block.source_blocks.keys.first] = check_block.xor_sum - - # - # Remove this check block from the found block, and if empty remove the - # check block list for it. - # - unresolved_check_blocks_for_found_block = @graph[new_block] - unresolved_check_blocks_for_found_block.delete(check_block) - @graph.delete(new_block) if unresolved_check_blocks_for_found_block.empty? - - #puts "\##{block_nr} = #{block_value.inspect} => \##{new_block} = #{check_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, check_block.xor_sum] - else - #puts "nah, still #{check_block.source_blocks.size} unknowns" - end - end - - # - # Delete this block from the graph after we have done all we can for it. - # - @graph.delete(block_nr) - end - - # - # Analyze what we found out earlier. - # - to_analyze.each do |new_block, sum| - analyze(new_block, sum) - end - end - - # - # Analyze the results of new known blocks. - # - def analyze(block_nr, block_value) - #puts "analyzing \##{block_nr} = #{block_value.inspect}" - # - # Do analyze_block on the block nr to see if we can resolve any check block - # relations from this block. - # - analyze_block(block_nr, block_value) - # - # Do aux_analyze_block on the block to see if we can resolve any aux block - # relations from this block. - # - analyze_aux_block(block_nr, block_value) - end - - # - # Analyze what we can conclude from the aux block relations and a new block. - # - def analyze_aux_block(block_nr, block_value) - # - # Remember what we want to analyze when done. - # - to_analyze = [] - - # - # If this block is a data block, check to see if it is the next to last - # remaining block for a known aux block. - # - # Else, check to see if we have all data blocks except one for this aux block. - # - if block_nr < @nr_of_data_blocks - # - # If we have unresolved aux data for this block. - # - if unresolved_aux_blocks_for_this_block = @aux_graph[block_nr] - # - # For each such block... - # - unresolved_aux_blocks_for_this_block.clone.each do |aux_block| - # - # If it is known. - # - if known_block = @blocks[aux_block.block_nr] - # - # Apply our new knowledge to it. - # - aux_block.apply(block_nr, block_value) - # - # Delete it from our list of unresolved blocks. - # - unresolved_aux_blocks_for_this_block.delete(aux_block) - # - # If the aux block is :finished (ie it has all but one of its data blocks - # accounted for). - # - if aux_block.state == :finished - # - # Record the found block to be the xor of the component blocks of the aux_block and the aux_block itself. - # - @blocks[new_block = aux_block.source_blocks.keys.first] = aux_block.xor_sum ^ known_block - - # - # Remove the aux block from the aux graph. - # - @aux_graph.delete(aux_block.block_nr) - - # - # Remove this aux block from the found block, and if empty remove the - # check block list for it. - # - unresolved_aux_blocks_for_found_block = @aux_graph[new_block] - unresolved_aux_blocks_for_found_block.delete(aux_block) - @aux_graph.delete(new_block) if unresolved_aux_blocks_for_found_block.empty? - - #puts "aux: \##{block_nr} = #{block_value.inspect} => \##{new_block} = #{aux_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, aux_block.xor_sum] - else - #puts "aux: nah, still #{aux_block.source_blocks.size} unknowns" - end - end - end - # - # Delete this block from the aux graph after we have done all we can for it. - # - @aux_graph.delete(block_nr) if unresolved_aux_blocks_for_this_block.empty? - end - else - aux_block = @aux_graph[block_nr] - - # - # If the aux block is :finished (ie it has all but one of its data blocks - # accounted for). - # - if aux_block && aux_block.state == :finished - # - # Record the found block to be the xor of the component blocks of the aux_block and itself. - # - @blocks[new_block = aux_block.source_blocks.keys.first] = aux_block.xor_sum ^ block_value - - # - # Remove the aux block from the aux_graph. - # - @aux_graph.delete(block_nr) - - # - # Remove this aux block from the found block, and if empty remove the - # check block list for it. - # - unresolved_aux_blocks_for_found_block = @aux_graph[new_block] - unresolved_aux_blocks_for_found_block.delete(aux_block) - @aux_graph.delete(new_block) if unresolved_aux_blocks_for_found_block.empty? - - #puts "aux: \##{block_nr} = #{block_value.inspect} => \##{new_block} = #{check_block.xor_sum.inspect}" - - # - # Remember to analyze the results of this. - # - to_analyze << [new_block, check_block.xor_sum] - end - end - - # - # Analyze what we found out earlier. - # - to_analyze.each do |new_block, sum| - analyze(new_block, sum) - end - end - - # - # Generate the graph containing the relations between the data blocks - # and the aux blocks. - # - # {block nr in composite data => [data block 0, ..., data block n]} - # - def generate_aux_graph - rval = {} - - context = Context.new - context.seed(@nr_of_data_blocks) - - 0.upto(@nr_of_data_blocks - 1) do |data_block_nr| - - aux_blocks_for_this_data_block = Set.new - rval[data_block_nr] = aux_blocks_for_this_data_block - - 1.upto(Q) do - aux_block_nr = @nr_of_data_blocks + context.random(@nr_of_aux_blocks) - aux_block = (rval[aux_block_nr] ||= AuxBlock.new(aux_block_nr)) - aux_block << data_block_nr - aux_blocks_for_this_data_block << aux_block - end - end - - return rval - end - - def ensure_decode_format(requested_size) - unless defined?(@blocks) - @graph = {} - @decode_done = nil - self.concat("\000" * requested_size) - set_block_size - @nr_of_data_blocks = expand(self).size - set_nr_of_aux_blocks - @blocks = Array.new(@nr_of_data_blocks) - @blocks += Array.new(@nr_of_aux_blocks) - set_nr_of_blocks - @aux_graph = generate_aux_graph - @known_nr_of_blocks = 0 - end - end - - def ensure_size(requested_size) - if size == 0 - concat("\000" * requested_size) - @decoded_blocks = Set.new - elsif size != requested_size - raise "size of #{self} (#{size}) is wrong, should be #{requested_size}" - end - end - - # - # Encoding stuff - # - - def generate_check_block(context, n) - degree = get_degree(context) - - block_nr = context.random(@nr_of_blocks) - rval = @blocks[block_nr] - - 2.upto(degree) do - block_nr = context.random(@nr_of_blocks) - rval ^= @blocks[block_nr] - end - return rval - end - - def generate_aux_blocks - rval = Array.new(@nr_of_aux_blocks) - - context = Context.new - context.seed(@nr_of_data_blocks) - - b_size = nil - @blocks.each_with_index do |b, i| - 1.upto(Q) do - aux_block_nr = context.random(@nr_of_aux_blocks) - if rval[aux_block_nr].nil? - rval[aux_block_nr] = b - else - rval[aux_block_nr] ^= b - end - end - end - - return rval - end - - def ensure_encode_format - unless defined?(@blocks) - set_block_size - @blocks = expand(self) - @nr_of_data_blocks = @blocks.size - set_nr_of_aux_blocks - @blocks += generate_aux_blocks - @nr_of_blocks = @blocks.size - end - end - - end - -end Copied: tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb (from rev 266, trunk/oneliner/lib/oneliner/superstring.rb) =================================================================== --- tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb (rev 0) +++ tags/release_0_2_6/oneliner/lib/oneliner/superstring.rb 2007-05-14 12:29:47 UTC (rev 268) @@ -0,0 +1,385 @@ +# Archipelago - a distributed computing toolkit for ruby +# Copyright (C) 2006 Martin Kihlgren +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require 'set' +require 'digest/sha2' + +module Oneliner + + # + # A String subclass providing Online Code functionality. + # + class SuperString < String + + E = 0.01 + Q = 3 + F = (Math.log((E ** 2) / 4) / Math.log(1 - (E / 2))).abs.to_i + P = [0, (1 - ((1 + (1 / F)) / (1 + E)))] + 2.upto(F) do |i| + P << (((1 - P[1]) * F) / ((F - 1) * i * (i - 1))) + end + + # + # Will return a String containing +requested_size+ nr of bytes + # as an online coded chunk of blocks for this SuperString. + # + def encode(requested_size) + raise "requested size is too small for metadata (8 bytes)" unless requested_size > 7 + + ensure_encode_format + srand + seed = rand(Context::INT_MAX) + context = Context.new + context.seed(seed) + + rval = [self.size].pack("i") + rval << [seed].pack("i") + + blocks = [] + wanted_blocks = ((requested_size - 8) * 8) / @block_size + 1.upto(wanted_blocks) do |n| + blocks << generate_check_block(context, n - 1) + end + + return rval + compact(blocks) + end + + # + # Will try to decode this SuperString using the given +chunk+ and all + # formerly given chunks. + # + # Returns whether decoding is done. + # + def decode!(chunk) + raise "#{chunk.inspect} is too small for metadata (8 bytes)" unless chunk.size > 7 + + @decode_done = nil + + context = Context.new + + requested_size = chunk[0..3].unpack("i").first + + ensure_decode_format(requested_size) + + the_seed = chunk[4..7].unpack("i").first + + chunk_data = build_chunk_data(chunk, context, the_seed) + + @known_nr_of_blocks += chunk_data.size + @known_chunks.unshift(chunk_data) + + if @known_nr_of_blocks > @nr_of_blocks + + nil while do_decode(context) + + if decode_done? + self.replace(compact(@blocks[0... at nr_of_data_blocks])[0...requested_size]) + return true + else + return false + end + + else + return false + end + end + + # + # Returns whether decoding is done. + # + def decode_done? + return false unless defined?(@decode_done) && defined?(@nr_of_data_blocks) + + unless @decode_done + data = @blocks[0... at nr_of_data_blocks] + @decode_done = data.compact.size == data.size + end + return @decode_done + end + + private + + # + # Misc stuff + # + + # + # Builds a Hash with index of each block in the +chunk+ + # paired with the block itself and the source blocks for + # that block determined using +context+ and +the_seed+. + # + def build_chunk_data(chunk, context, the_seed) + blocks_to_return = {} + + context.seed(the_seed) + + expand(chunk[8..-1]).each_with_index do |block, index| + this_degree = get_degree(context) + these_blocks = [] + this_degree.times do |m| + these_blocks << context.random(@nr_of_blocks) + end + + blocks_to_return[index] = [block, these_blocks] + end + + return blocks_to_return + end + + # + # Split +s+ up into @block_size (in bits if less than 8, otherwise closed matching nr of bytes) pieces + # and return them in an array. + # + def expand(s) + if @block_size < 8 + rval = s.unpack("b*").first + rval = rval.gsub(/(.{#{@block_size},#{@block_size}})/, "\\1#{"0" * (8 - @block_size)}") + rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 + rval = [rval].pack("b*") + return rval.split(//) + else + bytes_per_block = @block_size / 8 + rval = s + rval += "\000" * (bytes_per_block - (rval.size % bytes_per_block)) if (rval.size % bytes_per_block) > 0 + return rval.hack(bytes_per_block) + end + end + + # + # Glue +blocks+ together into a String. + # + def compact(blocks) + if @block_size < 8 + rval = blocks.join + rval = rval.unpack("b*") + rval = rval.first.gsub(/(.{#{@block_size},#{@block_size}}).{#{8 - @block_size},#{8 - @block_size}}/, + "\\1") + rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 + return [rval].pack("b*") + else + return blocks.join + end + end + + # + # Determine and save the nr of aux_blocks we want for this SuperString. + # + def set_nr_of_aux_blocks + @nr_of_aux_blocks ||= (0.55 * Q * E * @nr_of_data_blocks).ceil + end + + # + # Determine and save the block_size we want for this SuperString. + # + def set_block_size + unless defined?(@block_size) + if size < (256 + 128) + @block_size = 1 + else + @block_size = size / 256 + end + end + return @block_size + end + + # + # Determine and save the nr_of_blocks we want for this SuperString. + # + def set_nr_of_blocks + @nr_of_blocks ||= @blocks.size + end + + # + # Decoding stuff + # + + def do_decode(context) + found_new_block = false + @known_chunks.clone.each_with_index do |chunk_data, i| + this_chunk_found_new_block, this_chunk_informative = decode_chunk(chunk_data) + found_new_block = found_new_block || this_chunk_found_new_block + @known_chunks.delete(i) unless this_chunk_informative + end + return aux_decode || found_new_block + end + + def aux_decode + got_new_block = false + + @nr_of_data_blocks.upto(@nr_of_blocks - 1) do |i| + + aux_block = @blocks[i] + if aux_block + + source_blocks = @aux_hash[i] + if source_blocks.size == 1 + block_nr = source_blocks.first + + if @blocks[block_nr].nil? + @blocks[block_nr] = aux_block + got_new_block = true + @blocks[i] = nil + end + else + missing_blocks = source_blocks.size + missing_block = nil + xor_sum = aux_block + source_blocks.each do |block| + source_block = @blocks[block] + if source_block + missing_blocks -= 1 + xor_sum ^= source_block + else + missing_block = block + end + end + + if missing_blocks == 1 + @blocks[missing_block] = xor_sum + got_new_block = true + @blocks[i] = nil + end + end + end + end + + return got_new_block + end + + def decode_chunk(blocks) + got_new_block = false + got_informative_block = false + + blocks.clone.each do |index, block_data| + + block, block_numbers = block_data + + got_informative_block = true + + if block_numbers.size == 1 + block_nr = block_numbers.first + + if @blocks[block_nr].nil? + @blocks[block_nr] = block + got_new_block = true + blocks.delete(index) + end + else + if decode_multiple(block_data, @blocks, @nr_of_blocks) + got_new_block = true + blocks.delete(index) + end + end + + end + + return [got_new_block, got_informative_block] + end + + def generate_aux_hash + rval = Array.new(@nr_of_blocks) + + context = Context.new + context.seed(@nr_of_data_blocks) + + 0.upto(@nr_of_data_blocks - 1) do |i| + 1.upto(Q) do + aux_block_nr = @nr_of_data_blocks + context.random(@nr_of_aux_blocks) + (rval[aux_block_nr] ||= []) << i + end + end + + return rval + end + + def ensure_decode_format(requested_size) + unless defined?(@blocks) + self.concat("\000" * requested_size) + set_block_size + @nr_of_data_blocks = expand(self).size + set_nr_of_aux_blocks + @blocks = Array.new(@nr_of_data_blocks) + @blocks += Array.new(@nr_of_aux_blocks) + set_nr_of_blocks + @aux_hash = generate_aux_hash + @known_chunks = [] + @known_nr_of_blocks = 0 + @known_block_nrs_by_seed = {} + end + end + + def ensure_size(requested_size) + if size == 0 + concat("\000" * requested_size) + @decoded_blocks = Set.new + elsif size != requested_size + raise "size of #{self} (#{size}) is wrong, should be #{requested_size}" + end + end + + # + # Encoding stuff + # + + def generate_check_block(context, n) + degree = get_degree(context) + + block_nr = context.random(@nr_of_blocks) + rval = @blocks[block_nr] + + 2.upto(degree) do + block_nr = context.random(@nr_of_blocks) + rval ^= @blocks[block_nr] + end + return rval + end + + def generate_aux_blocks + rval = Array.new(@nr_of_aux_blocks) + + context = Context.new + context.seed(@nr_of_data_blocks) + + b_size = nil + @blocks.each_with_index do |b, i| + 1.upto(Q) do + aux_block_nr = context.random(@nr_of_aux_blocks) + if rval[aux_block_nr].nil? + rval[aux_block_nr] = b + else + rval[aux_block_nr] ^= b + end + end + end + + return rval + end + + def ensure_encode_format + unless defined?(@blocks) + set_block_size + @blocks = expand(self) + @nr_of_data_blocks = @blocks.size + set_nr_of_aux_blocks + @blocks += generate_aux_blocks + @nr_of_blocks = @blocks.size + end + end + + end + +end Modified: trunk/hyperactive/Rakefile =================================================================== --- trunk/hyperactive/Rakefile 2007-05-14 12:27:56 UTC (rev 267) +++ trunk/hyperactive/Rakefile 2007-05-14 12:29:47 UTC (rev 268) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "hyperactive" - s.version = "0.2.5" + s.version = "0.2.6" s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "A base class for persistent objects that uses archipelago for persistence. Useful for Ruby on Rails models for example." From nobody at rubyforge.org Mon May 14 13:00:31 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 13:00:31 -0400 (EDT) Subject: [Archipelago-submits] [269] trunk/rbtree-0.2.0: made a gem out of rbtree, added some info in the readme. Message-ID: <20070514170031.7ED935240B93@rubyforge.org> Revision: 269 Author: zond Date: 2007-05-14 13:00:30 -0400 (Mon, 14 May 2007) Log Message: ----------- made a gem out of rbtree, added some info in the readme. added a version number. moved stuff around. deleted the MANIFEST. Modified Paths: -------------- trunk/rbtree-0.2.0/README Added Paths: ----------- trunk/rbtree-0.2.0/Rakefile trunk/rbtree-0.2.0/ext/ trunk/rbtree-0.2.0/ext/archipelago_rbtree.c trunk/rbtree-0.2.0/ext/dict.c trunk/rbtree-0.2.0/ext/dict.h trunk/rbtree-0.2.0/ext/extconf.rb trunk/rbtree-0.2.0/tests/ trunk/rbtree-0.2.0/tests/rbtree_test.rb Removed Paths: ------------- trunk/rbtree-0.2.0/MANIFEST trunk/rbtree-0.2.0/dict.c trunk/rbtree-0.2.0/dict.h trunk/rbtree-0.2.0/extconf.rb trunk/rbtree-0.2.0/rbtree.c trunk/rbtree-0.2.0/test.rb Property Changed: ---------------- trunk/rbtree-0.2.0/ Property changes on: trunk/rbtree-0.2.0 ___________________________________________________________________ Name: svn:ignore - rbtree.bundle mkmf.log Makefile + archipelago_rbtree.bundle mkmf.log Makefile pkg Deleted: trunk/rbtree-0.2.0/MANIFEST =================================================================== --- trunk/rbtree-0.2.0/MANIFEST 2007-05-14 12:29:47 UTC (rev 268) +++ trunk/rbtree-0.2.0/MANIFEST 2007-05-14 17:00:30 UTC (rev 269) @@ -1,10 +0,0 @@ -ChangeLog -LICENSE -MANIFEST -README -depend -dict.c -dict.h -extconf.rb -rbtree.c -test.rb Modified: trunk/rbtree-0.2.0/README =================================================================== --- trunk/rbtree-0.2.0/README 2007-05-14 12:29:47 UTC (rev 268) +++ trunk/rbtree-0.2.0/README 2007-05-14 17:00:30 UTC (rev 269) @@ -1,5 +1,13 @@ =begin += Gemification + +To simplify my usage of this nice package, and managing my patches to +it, I have added it to this repository and added a Rakefile to create +a gem for it. Install it like any gem, basically. + +//Martin Kihlgren + = Ruby/RBTree RBTree is a sorted associative collection using Red-Black Tree as Added: trunk/rbtree-0.2.0/Rakefile =================================================================== --- trunk/rbtree-0.2.0/Rakefile (rev 0) +++ trunk/rbtree-0.2.0/Rakefile 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,47 @@ + +require 'rake' +require 'rake/testtask' +require 'rubygems' +Gem::manage_gems +require 'rake/gempackagetask' + + +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.name = "archipelago_rbtree" + s.version = "0.2.6" + s.author = "OZAWA Takuma, Kaz Kylheku, Martin Kihlgren" + s.email = "zond at troja dot ath dot cx" + s.summary = "A patched version of the rbtree code that accepts each and reverse_each with offsets." + s.files = FileList["**/*"].to_a + s.extensions << 'ext/extconf.rb' + s.autorequire = "archipelago_rbtree" + s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') +end + +Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_tar = true +end + +task :default => [:units] do +end + +desc "Run all tests" +Rake::TestTask.new(:units) do |t| + t.pattern = 'tests/*_test.rb' + t.verbose = true + t.warning = true +end + +desc "Run all benchmarks" +Rake::TestTask.new(:bench) do |t| + t.pattern = 'tests/*_benchmark.rb' + t.verbose = true + t.warning = true +end + +desc "Package a gem from the source" +task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do + puts "generated latest version" +end + Deleted: trunk/rbtree-0.2.0/dict.c =================================================================== --- trunk/rbtree-0.2.0/dict.c 2007-05-14 12:29:47 UTC (rev 268) +++ trunk/rbtree-0.2.0/dict.c 2007-05-14 17:00:30 UTC (rev 269) @@ -1,1216 +0,0 @@ -/* - * Dictionary Abstract Data Type - * Copyright (C) 1997 Kaz Kylheku - * - * Free Software License: - * - * All rights are reserved by the author, with the following exceptions: - * Permission is granted to freely reproduce and distribute this software, - * possibly in exchange for a fee, provided that this copyright notice appears - * intact. Permission is also granted to adapt this software to produce - * derivative works, as long as the modified versions carry this copyright - * notice and additional notices stating that the work has been modified. - * This source code may be translated into executable form and incorporated - * into proprietary software; there is no requirement for such software to - * contain a copyright notice related to this source. - * - * $Id: dict.c,v 1.15 2005/10/06 05:16:35 kuma Exp $ - * $Name: $ - */ - -/* - * Modified for Ruby/RBTree by OZAWA Takuma. - */ - -#include -#include -#include -#include "dict.h" - -#include - -#ifdef KAZLIB_RCSID -static const char rcsid[] = "$Id: dict.c,v 1.15 2005/10/06 05:16:35 kuma Exp $"; -#endif - -/* - * These macros provide short convenient names for structure members, - * which are embellished with dict_ prefixes so that they are - * properly confined to the documented namespace. It's legal for a - * program which uses dict to define, for instance, a macro called ``parent''. - * Such a macro would interfere with the dnode_t struct definition. - * In general, highly portable and reusable C modules which expose their - * structures need to confine structure member names to well-defined spaces. - * The resulting identifiers aren't necessarily convenient to use, nor - * readable, in the implementation, however! - */ - -#define left dict_left -#define right dict_right -#define parent dict_parent -#define color dict_color -#define key dict_key -#define data dict_data - -#define nilnode dict_nilnode -#define nodecount dict_nodecount -#define compare dict_compare -#define allocnode dict_allocnode -#define freenode dict_freenode -#define context dict_context -#define dupes dict_dupes - -#define dictptr dict_dictptr - -#define dict_root(D) ((D)->nilnode.left) -#define dict_nil(D) (&(D)->nilnode) -#define DICT_DEPTH_MAX 64 - -#define COMPARE(dict, key1, key2) dict->compare(key1, key2, dict->context) - -static dnode_t *dnode_alloc(void *context); -static void dnode_free(dnode_t *node, void *context); - -/* - * Perform a ``left rotation'' adjustment on the tree. The given node P and - * its right child C are rearranged so that the P instead becomes the left - * child of C. The left subtree of C is inherited as the new right subtree - * for P. The ordering of the keys within the tree is thus preserved. - */ - -static void rotate_left(dnode_t *upper) -{ - dnode_t *lower, *lowleft, *upparent; - - lower = upper->right; - upper->right = lowleft = lower->left; - lowleft->parent = upper; - - lower->parent = upparent = upper->parent; - - /* don't need to check for root node here because root->parent is - the sentinel nil node, and root->parent->left points back to root */ - - if (upper == upparent->left) { - upparent->left = lower; - } else { - assert (upper == upparent->right); - upparent->right = lower; - } - - lower->left = upper; - upper->parent = lower; -} - -/* - * This operation is the ``mirror'' image of rotate_left. It is - * the same procedure, but with left and right interchanged. - */ - -static void rotate_right(dnode_t *upper) -{ - dnode_t *lower, *lowright, *upparent; - - lower = upper->left; - upper->left = lowright = lower->right; - lowright->parent = upper; - - lower->parent = upparent = upper->parent; - - if (upper == upparent->right) { - upparent->right = lower; - } else { - assert (upper == upparent->left); - upparent->left = lower; - } - - lower->right = upper; - upper->parent = lower; -} - -/* - * Do a postorder traversal of the tree rooted at the specified - * node and free everything under it. Used by dict_free(). - */ - -static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil) -{ - if (node == nil) - return; - free_nodes(dict, node->left, nil); - free_nodes(dict, node->right, nil); - dict->freenode(node, dict->context); -} - -/* - * This procedure performs a verification that the given subtree is a binary - * search tree. It performs an inorder traversal of the tree using the - * dict_next() successor function, verifying that the key of each node is - * strictly lower than that of its successor, if duplicates are not allowed, - * or lower or equal if duplicates are allowed. This function is used for - * debugging purposes. - */ - -static int verify_bintree(dict_t *dict) -{ - dnode_t *first, *next; - - first = dict_first(dict); - - if (dict->dupes) { - while (first && (next = dict_next(dict, first))) { - if (COMPARE(dict, first->key, next->key) > 0) - return 0; - first = next; - } - } else { - while (first && (next = dict_next(dict, first))) { - if (COMPARE(dict, first->key, next->key) >= 0) - return 0; - first = next; - } - } - return 1; -} - - -/* - * This function recursively verifies that the given binary subtree satisfies - * three of the red black properties. It checks that every red node has only - * black children. It makes sure that each node is either red or black. And it - * checks that every path has the same count of black nodes from root to leaf. - * It returns the blackheight of the given subtree; this allows blackheights to - * be computed recursively and compared for left and right siblings for - * mismatches. It does not check for every nil node being black, because there - * is only one sentinel nil node. The return value of this function is the - * black height of the subtree rooted at the node ``root'', or zero if the - * subtree is not red-black. - */ - -static unsigned int verify_redblack(dnode_t *nil, dnode_t *root) -{ - unsigned height_left, height_right; - - if (root != nil) { - height_left = verify_redblack(nil, root->left); - height_right = verify_redblack(nil, root->right); - if (height_left == 0 || height_right == 0) - return 0; - if (height_left != height_right) - return 0; - if (root->color == dnode_red) { - if (root->left->color != dnode_black) - return 0; - if (root->right->color != dnode_black) - return 0; - return height_left; - } - if (root->color != dnode_black) - return 0; - return height_left + 1; - } - return 1; -} - -/* - * Compute the actual count of nodes by traversing the tree and - * return it. This could be compared against the stored count to - * detect a mismatch. - */ - -static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root) -{ - if (root == nil) - return 0; - else - return 1 + verify_node_count(nil, root->left) - + verify_node_count(nil, root->right); -} - -/* - * Verify that the tree contains the given node. This is done by - * traversing all of the nodes and comparing their pointers to the - * given pointer. Returns 1 if the node is found, otherwise - * returns zero. It is intended for debugging purposes. - */ - -static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node) -{ - if (root != nil) { - return root == node - || verify_dict_has_node(nil, root->left, node) - || verify_dict_has_node(nil, root->right, node); - } - return 0; -} - - -/* - * Dynamically allocate and initialize a dictionary object. - */ - -dict_t *dict_create(dict_comp_t comp) -{ - dict_t* new = ALLOC(dict_t); - - if (new) { - new->compare = comp; - new->allocnode = dnode_alloc; - new->freenode = dnode_free; - new->context = NULL; - new->nodecount = 0; - new->nilnode.left = &new->nilnode; - new->nilnode.right = &new->nilnode; - new->nilnode.parent = &new->nilnode; - new->nilnode.color = dnode_black; - new->dupes = 0; - } - return new; -} - -/* - * Select a different set of node allocator routines. - */ - -void dict_set_allocator(dict_t *dict, dnode_alloc_t al, - dnode_free_t fr, void *context) -{ - assert (dict_count(dict) == 0); - assert ((al == NULL && fr == NULL) || (al != NULL && fr != NULL)); - - dict->allocnode = al ? al : dnode_alloc; - dict->freenode = fr ? fr : dnode_free; - dict->context = context; -} - -/* - * Free a dynamically allocated dictionary object. Removing the nodes - * from the tree before deleting it is required. - */ - -void dict_destroy(dict_t *dict) -{ - assert (dict_isempty(dict)); - xfree(dict); -} - -/* - * Free all the nodes in the dictionary by using the dictionary's - * installed free routine. The dictionary is emptied. - */ - -void dict_free_nodes(dict_t *dict) -{ - dnode_t *nil = dict_nil(dict), *root = dict_root(dict); - free_nodes(dict, root, nil); - dict->nodecount = 0; - dict->nilnode.left = &dict->nilnode; - dict->nilnode.right = &dict->nilnode; - dict->nilnode.parent = &dict->nilnode; -} - -/* - * Obsolescent function, equivalent to dict_free_nodes - */ - -void dict_free(dict_t *dict) -{ -#ifdef KAZLIB_OBSOLESCENT_DEBUG - assert ("call to obsolescent function dict_free()" && 0); -#endif - dict_free_nodes(dict); -} - -/* - * Initialize a user-supplied dictionary object. - */ - -dict_t *dict_init(dict_t *dict, dict_comp_t comp) -{ - dict->compare = comp; - dict->allocnode = dnode_alloc; - dict->freenode = dnode_free; - dict->context = NULL; - dict->nodecount = 0; - dict->nilnode.left = &dict->nilnode; - dict->nilnode.right = &dict->nilnode; - dict->nilnode.parent = &dict->nilnode; - dict->nilnode.color = dnode_black; - dict->dupes = 0; - return dict; -} - -/* - * Initialize a dictionary in the likeness of another dictionary - */ - -void dict_init_like(dict_t *dict, const dict_t *template) -{ - dict->compare = template->compare; - dict->allocnode = template->allocnode; - dict->freenode = template->freenode; - dict->context = template->context; - dict->nodecount = 0; - dict->nilnode.left = &dict->nilnode; - dict->nilnode.right = &dict->nilnode; - dict->nilnode.parent = &dict->nilnode; - dict->nilnode.color = dnode_black; - dict->dupes = template->dupes; - - assert (dict_similar(dict, template)); -} - -/* - * Remove all nodes from the dictionary (without freeing them in any way). - */ - -static void dict_clear(dict_t *dict) -{ - dict->nodecount = 0; - dict->nilnode.left = &dict->nilnode; - dict->nilnode.right = &dict->nilnode; - dict->nilnode.parent = &dict->nilnode; - assert (dict->nilnode.color == dnode_black); -} - -/* - * Verify the integrity of the dictionary structure. This is provided for - * debugging purposes, and should be placed in assert statements. Just because - * this function succeeds doesn't mean that the tree is not corrupt. Certain - * corruptions in the tree may simply cause undefined behavior. - */ - -int dict_verify(dict_t *dict) -{ - dnode_t *nil = dict_nil(dict), *root = dict_root(dict); - - /* check that the sentinel node and root node are black */ - if (root->color != dnode_black) - return 0; - if (nil->color != dnode_black) - return 0; - if (nil->right != nil) - return 0; - /* nil->left is the root node; check that its parent pointer is nil */ - if (nil->left->parent != nil) - return 0; - /* perform a weak test that the tree is a binary search tree */ - if (!verify_bintree(dict)) - return 0; - /* verify that the tree is a red-black tree */ - if (!verify_redblack(nil, root)) - return 0; - if (verify_node_count(nil, root) != dict_count(dict)) - return 0; - return 1; -} - -/* - * Determine whether two dictionaries are similar: have the same comparison and - * allocator functions, and same status as to whether duplicates are allowed. - */ - -int dict_similar(const dict_t *left, const dict_t *right) -{ - if (left->compare != right->compare) - return 0; - - if (left->allocnode != right->allocnode) - return 0; - - if (left->freenode != right->freenode) - return 0; - - if (left->context != right->context) - return 0; - -/* if (left->dupes != right->dupes) */ -/* return 0; */ - - return 1; -} - -/* - * Locate a node in the dictionary having the given key. - * If the node is not found, a null a pointer is returned (rather than - * a pointer that dictionary's nil sentinel node), otherwise a pointer to the - * located node is returned. - */ - -dnode_t *dict_lookup(dict_t *dict, const void *key) -{ - dnode_t *root = dict_root(dict); - dnode_t *nil = dict_nil(dict); - dnode_t *saved; - int result; - - /* simple binary search adapted for trees that contain duplicate keys */ - - while (root != nil) { - result = COMPARE(dict, key, root->key); - if (result < 0) - root = root->left; - else if (result > 0) - root = root->right; - else { - if (!dict->dupes) { /* no duplicates, return match */ - return root; - } else { /* could be dupes, find leftmost one */ - do { - saved = root; - root = root->left; - while (root != nil && COMPARE(dict, key, root->key)) - root = root->right; - } while (root != nil); - return saved; - } - } - } - - return NULL; -} - -/* - * Look for the node corresponding to the lowest key that is equal to or - * greater than the given key. If there is no such node, return null. - */ - -dnode_t *dict_lower_bound(dict_t *dict, const void *key) -{ - dnode_t *root = dict_root(dict); - dnode_t *nil = dict_nil(dict); - dnode_t *tentative = 0; - - while (root != nil) { - int result = COMPARE(dict, key, root->key); - - if (result > 0) { - root = root->right; - } else if (result < 0) { - tentative = root; - root = root->left; - } else { - if (!dict->dupes) { - return root; - } else { - tentative = root; - root = root->left; - } - } - } - - return tentative; -} - -/* - * Look for the node corresponding to the greatest key that is equal to or - * lower than the given key. If there is no such node, return null. - */ - -dnode_t *dict_upper_bound(dict_t *dict, const void *key) -{ - dnode_t *root = dict_root(dict); - dnode_t *nil = dict_nil(dict); - dnode_t *tentative = 0; - - while (root != nil) { - int result = COMPARE(dict, key, root->key); - - if (result < 0) { - root = root->left; - } else if (result > 0) { - tentative = root; - root = root->right; - } else { - if (!dict->dupes) { - return root; - } else { - tentative = root; - root = root->right; - } - } - } - - return tentative; -} - -/* - * Insert a node into the dictionary. The node should have been - * initialized with a data field. All other fields are ignored. - * The behavior is undefined if the user attempts to insert into - * a dictionary that is already full (for which the dict_isfull() - * function returns true). - */ - -int dict_insert(dict_t *dict, dnode_t *node, const void *key) -{ - dnode_t *where = dict_root(dict), *nil = dict_nil(dict); - dnode_t *parent = nil, *uncle, *grandpa; - int result = -1; - - node->key = key; - - assert (!dict_isfull(dict)); - assert (!dict_contains(dict, node)); - assert (!dnode_is_in_a_dict(node)); - - /* basic binary tree insert */ - - while (where != nil) { - parent = where; - result = COMPARE(dict, key, where->key); - /* trap attempts at duplicate key insertion unless it's explicitly allowed */ - - if (!dict->dupes && result == 0) { - where->data = node->data; - return 0; - } else if (result < 0) { - where = where->left; - } else { - where = where->right; - } - } - - assert (where == nil); - - if (result < 0) - parent->left = node; - else - parent->right = node; - - node->parent = parent; - node->left = nil; - node->right = nil; - - dict->nodecount++; - - /* red black adjustments */ - - node->color = dnode_red; - - while (parent->color == dnode_red) { - grandpa = parent->parent; - if (parent == grandpa->left) { - uncle = grandpa->right; - if (uncle->color == dnode_red) { /* red parent, red uncle */ - parent->color = dnode_black; - uncle->color = dnode_black; - grandpa->color = dnode_red; - node = grandpa; - parent = grandpa->parent; - } else { /* red parent, black uncle */ - if (node == parent->right) { - rotate_left(parent); - parent = node; - assert (grandpa == parent->parent); - /* rotation between parent and child preserves grandpa */ - } - parent->color = dnode_black; - grandpa->color = dnode_red; - rotate_right(grandpa); - break; - } - } else { /* symmetric cases: parent == parent->parent->right */ - uncle = grandpa->left; - if (uncle->color == dnode_red) { - parent->color = dnode_black; - uncle->color = dnode_black; - grandpa->color = dnode_red; - node = grandpa; - parent = grandpa->parent; - } else { - if (node == parent->left) { - rotate_right(parent); - parent = node; - assert (grandpa == parent->parent); - } - parent->color = dnode_black; - grandpa->color = dnode_red; - rotate_left(grandpa); - break; - } - } - } - - dict_root(dict)->color = dnode_black; - - assert (dict_verify(dict)); - return 1; -} - -/* - * Delete the given node from the dictionary. If the given node does not belong - * to the given dictionary, undefined behavior results. A pointer to the - * deleted node is returned. - */ - -dnode_t *dict_delete(dict_t *dict, dnode_t *delete) -{ - dnode_t *nil = dict_nil(dict), *child, *delparent = delete->parent; - - /* basic deletion */ - - assert (!dict_isempty(dict)); - assert (dict_contains(dict, delete)); - - /* - * If the node being deleted has two children, then we replace it with its - * successor (i.e. the leftmost node in the right subtree.) By doing this, - * we avoid the traditional algorithm under which the successor's key and - * value *only* move to the deleted node and the successor is spliced out - * from the tree. We cannot use this approach because the user may hold - * pointers to the successor, or nodes may be inextricably tied to some - * other structures by way of embedding, etc. So we must splice out the - * node we are given, not some other node, and must not move contents from - * one node to another behind the user's back. - */ - - if (delete->left != nil && delete->right != nil) { - dnode_t *next = dict_next(dict, delete); - dnode_t *nextparent = next->parent; - dnode_color_t nextcolor = next->color; - - assert (next != nil); - assert (next->parent != nil); - assert (next->left == nil); - - /* - * First, splice out the successor from the tree completely, by - * moving up its right child into its place. - */ - - child = next->right; - child->parent = nextparent; - - if (nextparent->left == next) { - nextparent->left = child; - } else { - assert (nextparent->right == next); - nextparent->right = child; - } - - /* - * Now that the successor has been extricated from the tree, install it - * in place of the node that we want deleted. - */ - - next->parent = delparent; - next->left = delete->left; - next->right = delete->right; - next->left->parent = next; - next->right->parent = next; - next->color = delete->color; - delete->color = nextcolor; - - if (delparent->left == delete) { - delparent->left = next; - } else { - assert (delparent->right == delete); - delparent->right = next; - } - - } else { - assert (delete != nil); - assert (delete->left == nil || delete->right == nil); - - child = (delete->left != nil) ? delete->left : delete->right; - - child->parent = delparent = delete->parent; - - if (delete == delparent->left) { - delparent->left = child; - } else { - assert (delete == delparent->right); - delparent->right = child; - } - } - - delete->parent = NULL; - delete->right = NULL; - delete->left = NULL; - - dict->nodecount--; - - assert (verify_bintree(dict)); - - /* red-black adjustments */ - - if (delete->color == dnode_black) { - dnode_t *parent, *sister; - - dict_root(dict)->color = dnode_red; - - while (child->color == dnode_black) { - parent = child->parent; - if (child == parent->left) { - sister = parent->right; - assert (sister != nil); - if (sister->color == dnode_red) { - sister->color = dnode_black; - parent->color = dnode_red; - rotate_left(parent); - sister = parent->right; - assert (sister != nil); - } - if (sister->left->color == dnode_black - && sister->right->color == dnode_black) { - sister->color = dnode_red; - child = parent; - } else { - if (sister->right->color == dnode_black) { - assert (sister->left->color == dnode_red); - sister->left->color = dnode_black; - sister->color = dnode_red; - rotate_right(sister); - sister = parent->right; - assert (sister != nil); - } - sister->color = parent->color; - sister->right->color = dnode_black; - parent->color = dnode_black; - rotate_left(parent); - break; - } - } else { /* symmetric case: child == child->parent->right */ - assert (child == parent->right); - sister = parent->left; - assert (sister != nil); - if (sister->color == dnode_red) { - sister->color = dnode_black; - parent->color = dnode_red; - rotate_right(parent); - sister = parent->left; - assert (sister != nil); - } - if (sister->right->color == dnode_black - && sister->left->color == dnode_black) { - sister->color = dnode_red; - child = parent; - } else { - if (sister->left->color == dnode_black) { - assert (sister->right->color == dnode_red); - sister->right->color = dnode_black; - sister->color = dnode_red; - rotate_left(sister); - sister = parent->left; - assert (sister != nil); - } - sister->color = parent->color; - sister->left->color = dnode_black; - parent->color = dnode_black; - rotate_right(parent); - break; - } - } - } - - child->color = dnode_black; - dict_root(dict)->color = dnode_black; - } - - assert (dict_verify(dict)); - - return delete; -} - -/* - * Allocate a node using the dictionary's allocator routine, give it - * the data item. - */ - -int dict_alloc_insert(dict_t *dict, const void *key, void *data) -{ - dnode_t *node = dict->allocnode(dict->context); - - if (node) { - dnode_init(node, data); - if (!dict_insert(dict, node, key)) - dict->freenode(node, dict->context); - return 1; - } - return 0; -} - -void dict_delete_free(dict_t *dict, dnode_t *node) -{ - dict_delete(dict, node); - dict->freenode(node, dict->context); -} - -/* - * Return the node with the lowest (leftmost) key. If the dictionary is empty - * (that is, dict_isempty(dict) returns 1) a null pointer is returned. - */ - -dnode_t *dict_first(dict_t *dict) -{ - dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left; - - if (root != nil) - while ((left = root->left) != nil) - root = left; - - return (root == nil) ? NULL : root; -} - -/* - * Return the node with the highest (rightmost) key. If the dictionary is empty - * (that is, dict_isempty(dict) returns 1) a null pointer is returned. - */ - -dnode_t *dict_last(dict_t *dict) -{ - dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *right; - - if (root != nil) - while ((right = root->right) != nil) - root = right; - - return (root == nil) ? NULL : root; -} - -/* - * Return the given node's successor node---the node which has the - * next key in the the left to right ordering. If the node has - * no successor, a null pointer is returned rather than a pointer to - * the nil node. - */ - -dnode_t *dict_next(dict_t *dict, dnode_t *curr) -{ - dnode_t *nil = dict_nil(dict), *parent, *left; - - if (curr->right != nil) { - curr = curr->right; - while ((left = curr->left) != nil) - curr = left; - return curr; - } - - parent = curr->parent; - - while (parent != nil && curr == parent->right) { - curr = parent; - parent = curr->parent; - } - - return (parent == nil) ? NULL : parent; -} - -/* - * Return the given node's predecessor, in the key order. - * The nil sentinel node is returned if there is no predecessor. - */ - -dnode_t *dict_prev(dict_t *dict, dnode_t *curr) -{ - dnode_t *nil = dict_nil(dict), *parent, *right; - - if (curr->left != nil) { - curr = curr->left; - while ((right = curr->right) != nil) - curr = right; - return curr; - } - - parent = curr->parent; - - while (parent != nil && curr == parent->left) { - curr = parent; - parent = curr->parent; - } - - return (parent == nil) ? NULL : parent; -} - -void dict_allow_dupes(dict_t *dict) -{ - dict->dupes = 1; -} - -dictcount_t dict_count(dict_t *dict) -{ - return dict->nodecount; -} - -int dict_isempty(dict_t *dict) -{ - return dict->nodecount == 0; -} - -int dict_isfull(dict_t *dict) -{ - return dict->nodecount == DICTCOUNT_T_MAX; -} - -int dict_contains(dict_t *dict, dnode_t *node) -{ - return verify_dict_has_node(dict_nil(dict), dict_root(dict), node); -} - -static dnode_t *dnode_alloc(void *context) -{ - return malloc(sizeof *dnode_alloc(NULL)); -} - -static void dnode_free(dnode_t *node, void *context) -{ - free(node); -} - -dnode_t *dnode_create(void *data) -{ - dnode_t *new = malloc(sizeof *new); - if (new) { - new->data = data; - new->parent = NULL; - new->left = NULL; - new->right = NULL; - } - return new; -} - -dnode_t *dnode_init(dnode_t *dnode, void *data) -{ - dnode->data = data; - dnode->parent = NULL; - dnode->left = NULL; - dnode->right = NULL; - return dnode; -} - -void dnode_destroy(dnode_t *dnode) -{ - assert (!dnode_is_in_a_dict(dnode)); - free(dnode); -} - -void *dnode_get(dnode_t *dnode) -{ - return dnode->data; -} - -const void *dnode_getkey(dnode_t *dnode) -{ - return dnode->key; -} - -void dnode_put(dnode_t *dnode, void *data) -{ - dnode->data = data; -} - -int dnode_is_in_a_dict(dnode_t *dnode) -{ - return (dnode->parent && dnode->left && dnode->right); -} - -void dict_process(dict_t *dict, void *context, dnode_process_t function) -{ - dnode_t *node = dict_first(dict), *next; - - while (node != NULL) { - /* check for callback function deleting */ - /* the next node from under us */ - assert (dict_contains(dict, node)); - next = dict_next(dict, node); - function(dict, node, context); - node = next; - } -} - -static void load_begin_internal(dict_load_t *load, dict_t *dict) -{ - load->dictptr = dict; - load->nilnode.left = &load->nilnode; - load->nilnode.right = &load->nilnode; -} - -void dict_load_begin(dict_load_t *load, dict_t *dict) -{ - assert (dict_isempty(dict)); - load_begin_internal(load, dict); -} - -void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key) -{ - dict_t *dict = load->dictptr; - dnode_t *nil = &load->nilnode; - - assert (!dnode_is_in_a_dict(newnode)); - assert (dict->nodecount < DICTCOUNT_T_MAX); - - #ifndef NDEBUG - if (dict->nodecount > 0) { - if (dict->dupes) - assert (COMPARE(dict, nil->left->key, key) <= 0); - else - assert (COMPARE(dict, nil->left->key, key) < 0); - } - #endif - - newnode->key = key; - nil->right->left = newnode; - nil->right = newnode; - newnode->left = nil; - dict->nodecount++; -} - -void dict_load_end(dict_load_t *load) -{ - dict_t *dict = load->dictptr; - dnode_t *tree[DICT_DEPTH_MAX] = { 0 }; - dnode_t *curr, *dictnil = dict_nil(dict), *loadnil = &load->nilnode, *next; - dnode_t *complete = 0; - dictcount_t fullcount = DICTCOUNT_T_MAX, nodecount = dict->nodecount; - dictcount_t botrowcount; - unsigned baselevel = 0, level = 0, i; - - assert (dnode_red == 0 && dnode_black == 1); - - while (fullcount >= nodecount && fullcount) - fullcount >>= 1; - - botrowcount = nodecount - fullcount; - - for (curr = loadnil->left; curr != loadnil; curr = next) { - next = curr->left; - - if (complete == NULL && botrowcount-- == 0) { - assert (baselevel == 0); - assert (level == 0); - baselevel = level = 1; - complete = tree[0]; - - if (complete != 0) { - tree[0] = 0; - complete->right = dictnil; - while (tree[level] != 0) { - tree[level]->right = complete; - complete->parent = tree[level]; - complete = tree[level]; - tree[level++] = 0; - } - } - } - - if (complete == NULL) { - curr->left = dictnil; - curr->right = dictnil; - curr->color = level % 2; - complete = curr; - - assert (level == baselevel); - while (tree[level] != 0) { - tree[level]->right = complete; - complete->parent = tree[level]; - complete = tree[level]; - tree[level++] = 0; - } - } else { - curr->left = complete; - curr->color = (level + 1) % 2; - complete->parent = curr; - tree[level] = curr; - complete = 0; - level = baselevel; - } - } - - if (complete == NULL) - complete = dictnil; - - for (i = 0; i < DICT_DEPTH_MAX; i++) { - if (tree[i] != 0) { - tree[i]->right = complete; - complete->parent = tree[i]; - complete = tree[i]; - } - } - - dictnil->color = dnode_black; - dictnil->right = dictnil; - complete->parent = dictnil; - complete->color = dnode_black; - dict_root(dict) = complete; - - assert (dict_verify(dict)); -} - -void dict_merge(dict_t *dest, dict_t *source) -{ - dict_load_t load; - dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source); - - assert (dict_similar(dest, source)); - - if (source == dest) - return; - - dest->nodecount = 0; - load_begin_internal(&load, dest); - - for (;;) { - if (leftnode != NULL && rightnode != NULL) { - if (COMPARE(dest, leftnode->key, rightnode->key) < 0) - goto copyleft; - else - goto copyright; - } else if (leftnode != NULL) { - goto copyleft; - } else if (rightnode != NULL) { - goto copyright; - } else { - assert (leftnode == NULL && rightnode == NULL); - break; - } - - copyleft: - { - dnode_t *next = dict_next(dest, leftnode); - #ifndef NDEBUG - leftnode->left = NULL; /* suppress assertion in dict_load_next */ - #endif - dict_load_next(&load, leftnode, leftnode->key); - leftnode = next; - continue; - } - - copyright: - { - dnode_t *next = dict_next(source, rightnode); - #ifndef NDEBUG - rightnode->left = NULL; - #endif - dict_load_next(&load, rightnode, rightnode->key); - rightnode = next; - continue; - } - } - - dict_clear(source); - dict_load_end(&load); -} - -int dict_equal(dict_t* dict1, dict_t* dict2, - dict_value_eql_t value_eql) -{ - dnode_t* node1; - dnode_t* node2; - - if (dict_count(dict1) != dict_count(dict2)) - return 0; - if (!dict_similar(dict1, dict2)) - return 0; - - for (node1 = dict_first(dict1), node2 = dict_first(dict2); - node1 != NULL && node2 != NULL; - node1 = dict_next(dict1, node1), node2 = dict_next(dict2, node2)) { - - if (COMPARE(dict1, node1->key, node2->key) != 0) - return 0; - if (!value_eql(node1->data, node2->data)) - return 0; - } - return 1; -} Deleted: trunk/rbtree-0.2.0/dict.h =================================================================== --- trunk/rbtree-0.2.0/dict.h 2007-05-14 12:29:47 UTC (rev 268) +++ trunk/rbtree-0.2.0/dict.h 2007-05-14 17:00:30 UTC (rev 269) @@ -1,123 +0,0 @@ -/* - * Dictionary Abstract Data Type - * Copyright (C) 1997 Kaz Kylheku - * - * Free Software License: - * - * All rights are reserved by the author, with the following exceptions: - * Permission is granted to freely reproduce and distribute this software, - * possibly in exchange for a fee, provided that this copyright notice appears - * intact. Permission is also granted to adapt this software to produce - * derivative works, as long as the modified versions carry this copyright - * notice and additional notices stating that the work has been modified. - * This source code may be translated into executable form and incorporated - * into proprietary software; there is no requirement for such software to - * contain a copyright notice related to this source. - * - * $Id: dict.h,v 1.9 2005/10/06 05:16:35 kuma Exp $ - * $Name: $ - */ - -/* - * Modified for Ruby/RBTree by OZAWA Takuma. - */ - -#ifndef DICT_H -#define DICT_H - -#include - -/* - * Blurb for inclusion into C++ translation units - */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned long dictcount_t; -#define DICTCOUNT_T_MAX ULONG_MAX - -/* - * The dictionary is implemented as a red-black tree - */ - -typedef enum { dnode_red, dnode_black } dnode_color_t; - -typedef struct dnode_t { - struct dnode_t *dict_left; - struct dnode_t *dict_right; - struct dnode_t *dict_parent; - dnode_color_t dict_color; - const void *dict_key; - void *dict_data; -} dnode_t; - -typedef int (*dict_comp_t)(const void *, const void *, void *); -typedef dnode_t *(*dnode_alloc_t)(void *); -typedef void (*dnode_free_t)(dnode_t *, void *); - -typedef int (*dict_value_eql_t)(const void *, const void *); - -typedef struct dict_t { - dnode_t dict_nilnode; - dictcount_t dict_nodecount; - dict_comp_t dict_compare; - dnode_alloc_t dict_allocnode; - dnode_free_t dict_freenode; - void *dict_context; - int dict_dupes; -} dict_t; - -typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *); - -typedef struct dict_load_t { - dict_t *dict_dictptr; - dnode_t dict_nilnode; -} dict_load_t; - -extern dict_t *dict_create(dict_comp_t); -extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *); -extern void dict_destroy(dict_t *); -extern void dict_free_nodes(dict_t *); -extern void dict_free(dict_t *); -extern dict_t *dict_init(dict_t *, dict_comp_t); -extern void dict_init_like(dict_t *, const dict_t *); -extern int dict_verify(dict_t *); -extern int dict_similar(const dict_t *, const dict_t *); -extern dnode_t *dict_lookup(dict_t *, const void *); -extern dnode_t *dict_lower_bound(dict_t *, const void *); -extern dnode_t *dict_upper_bound(dict_t *, const void *); -extern int dict_insert(dict_t *, dnode_t *, const void *); -extern dnode_t *dict_delete(dict_t *, dnode_t *); -extern int dict_alloc_insert(dict_t *, const void *, void *); -extern void dict_delete_free(dict_t *, dnode_t *); -extern dnode_t *dict_first(dict_t *); -extern dnode_t *dict_last(dict_t *); -extern dnode_t *dict_next(dict_t *, dnode_t *); -extern dnode_t *dict_prev(dict_t *, dnode_t *); -extern dictcount_t dict_count(dict_t *); -extern int dict_isempty(dict_t *); -extern int dict_isfull(dict_t *); -extern int dict_contains(dict_t *, dnode_t *); -extern void dict_allow_dupes(dict_t *); -extern int dnode_is_in_a_dict(dnode_t *); -extern dnode_t *dnode_create(void *); -extern dnode_t *dnode_init(dnode_t *, void *); -extern void dnode_destroy(dnode_t *); -extern void *dnode_get(dnode_t *); -extern const void *dnode_getkey(dnode_t *); -extern void dnode_put(dnode_t *, void *); -extern void dict_process(dict_t *, void *, dnode_process_t); -extern void dict_load_begin(dict_load_t *, dict_t *); -extern void dict_load_next(dict_load_t *, dnode_t *, const void *); -extern void dict_load_end(dict_load_t *); -extern void dict_merge(dict_t *, dict_t *); - -int dict_equal(dict_t*, dict_t*, dict_value_eql_t); - -#ifdef __cplusplus -} -#endif - -#endif Added: trunk/rbtree-0.2.0/ext/archipelago_rbtree.c =================================================================== --- trunk/rbtree-0.2.0/ext/archipelago_rbtree.c (rev 0) +++ trunk/rbtree-0.2.0/ext/archipelago_rbtree.c 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,1715 @@ +/* + * MIT License + * Copyright (c) 2002-2004, 2007 OZAWA Takuma + * $Id: rbtree.c,v 1.80 2007/02/01 02:50:56 kuma Exp $ + */ +#include +#include +#include +#include +#include "dict.h" + +#define RBTREE_IN_ITERATION FL_USER1 +#define RBTREE_PROC_DEFAULT FL_USER2 +#define HASH_PROC_DEFAULT FL_USER2 + +#ifndef ULONG2NUM +#define ULONG2NUM UINT2NUM +#endif + +VALUE RBTree; +VALUE MultiRBTree; + +static ID id_bound; +static ID id_cmp; +static ID id_call; +static ID id_default; + +#ifndef HAVE_RB_MARSHAL_DUMP +static VALUE rb_mMarshal; +static ID id_dump; +static ID id_load; +#endif + +typedef struct { + dict_t* dict; + VALUE ifnone; + int iter_lev; +} rbtree_t; + +#define RBTREE(rbtree) DATA_PTR(rbtree) +#define DICT(rbtree) ((rbtree_t*)RBTREE(rbtree))->dict +#define IFNONE(rbtree) ((rbtree_t*)RBTREE(rbtree))->ifnone +#define ITER_LEV(rbtree) ((rbtree_t*)RBTREE(rbtree))->iter_lev +#define COMPARE(rbtree) DICT(rbtree)->dict_compare +#define CONTEXT(rbtree) DICT(rbtree)->dict_context + +#define TO_KEY(arg) ((const void*)arg) +#define TO_VAL(arg) ((void*)arg) +#define GET_KEY(dnode) ((VALUE)dnode_getkey(dnode)) +#define GET_VAL(dnode) ((VALUE)dnode_get(dnode)) +#define ASSOC(dnode) rb_assoc_new(GET_KEY(dnode), GET_VAL(dnode)) + +/*********************************************************************/ + +#ifndef HAVE_RB_BLOCK_PROC +static VALUE +rb_block_proc() +{ + return rb_f_lambda(); +} +#endif + +#ifndef HAVE_RB_YIELD_VALUES +static VALUE +rb_yield_values(int n, ...) +{ + int i; + va_list ap; + VALUE ary = rb_ary_new2(n); + + va_start(ap, n); + for (i = 0; i < n; i++) + rb_ary_push(ary, va_arg(ap, VALUE)); + va_end(ap); + return rb_yield(ary); +} +#endif + +static int +cmpint(VALUE i, VALUE a, VALUE b) +{ +#if RUBY_VERSION_CODE >= 180 + return rb_cmpint(i, a, b); +#else + return rb_cmpint(i); +#endif +} + + +static void +rbtree_free(rbtree_t* rbtree) +{ + dict_free_nodes(rbtree->dict); + dict_destroy(rbtree->dict); + xfree(rbtree); +} + +static void +rbtree_mark(rbtree_t* rbtree) +{ + if (rbtree == NULL) return; + + if (rbtree->dict != NULL) { + dict_t* dict = rbtree->dict; + dnode_t* node; + for (node = dict_first(dict); + node != NULL; + node = dict_next(dict, node)) { + + rb_gc_mark(GET_KEY(node)); + rb_gc_mark(GET_VAL(node)); + } + rb_gc_mark((VALUE)dict->dict_context); + } + rb_gc_mark(rbtree->ifnone); +} + +static dnode_t* +rbtree_alloc_node(void* context) +{ + return ALLOC(dnode_t); +} + +static void +rbtree_free_node(dnode_t* node, void* context) +{ + xfree(node); +} + +static void +rbtree_argc_error() +{ + rb_raise(rb_eArgError, "wrong number of arguments"); +} + +static int +rbtree_cmp(const void* key1, const void* key2, void* context) +{ + VALUE ret; + if (TYPE(key1) == T_STRING && TYPE(key2) == T_STRING) + return rb_str_cmp((VALUE)key1, (VALUE)key2); + ret = rb_funcall((VALUE)key1, id_cmp, 1, (VALUE)key2); + return cmpint(ret, (VALUE)key1, (VALUE)key2); +} + +static int +rbtree_user_cmp(const void* key1, const void* key2, void* cmp_proc) +{ + VALUE ret = rb_funcall((VALUE)cmp_proc, id_call, 2, + (VALUE)key1, (VALUE)key2); + return cmpint(ret, (VALUE)key1, (VALUE)key2); +} + +static void +rbtree_modify(VALUE self) +{ + if (ITER_LEV(self) > 0) + rb_raise(rb_eTypeError, "can't modify rbtree in iteration"); + if (OBJ_FROZEN(self)) + rb_error_frozen("rbtree"); + if (!OBJ_TAINTED(self) && rb_safe_level() >= 4) + rb_raise(rb_eSecurityError, "Insecure: can't modify rbtree"); +} + +static VALUE +rbtree_alloc(VALUE klass) +{ + dict_t* dict; + VALUE rbtree = Data_Wrap_Struct(klass, rbtree_mark, rbtree_free, 0); + RBTREE(rbtree) = ALLOC(rbtree_t); + MEMZERO(RBTREE(rbtree), rbtree_t, 1); + + dict = dict_create(rbtree_cmp); + dict_set_allocator(dict, rbtree_alloc_node, rbtree_free_node, + (void*)Qnil); + if (klass == MultiRBTree) + dict_allow_dupes(dict); + + DICT(rbtree) = dict; + IFNONE(rbtree) = Qnil; + return rbtree; +} + +VALUE rbtree_aset(VALUE, VALUE, VALUE); +VALUE rbtree_clear(VALUE); +VALUE rbtree_has_key(VALUE, VALUE); +VALUE rbtree_update(VALUE, VALUE); + +/*********************************************************************/ + +#ifndef HAVE_OBJECT_ALLOCATE +/* + * + */ +VALUE +rbtree_s_new(int argc, VALUE* argv, VALUE klass) +{ + VALUE rbtree = rbtree_alloc(klass); + rb_obj_call_init(rbtree, argc, argv); + return rbtree; +} +#endif + +static int +hash_to_rbtree_i(VALUE key, VALUE value, VALUE rbtree) +{ + if (key != Qundef) + rbtree_aset(rbtree, key, value); + return ST_CONTINUE; +} + +/* + * + */ +VALUE +rbtree_s_create(int argc, VALUE* argv, VALUE klass) +{ + int i; + VALUE rbtree; + + if (argc == 1) { + if (rb_obj_is_kind_of(argv[0], klass)) { + rbtree = rbtree_alloc(klass); + rbtree_update(rbtree, argv[0]); + return rbtree; + } else if (TYPE(argv[0]) == T_HASH) { + rbtree = rbtree_alloc(klass); + st_foreach(RHASH(argv[0])->tbl, hash_to_rbtree_i, rbtree); + return rbtree; + } + } + + if (argc % 2 != 0) + rb_raise(rb_eArgError, "odd number of arguments for RBTree"); + + rbtree = rbtree_alloc(klass); + for (i = 0; i < argc; i += 2) + rbtree_aset(rbtree, argv[i], argv[i + 1]); + return rbtree; +} + +/* + * + */ +VALUE +rbtree_initialize(int argc, VALUE* argv, VALUE self) +{ + rbtree_modify(self); + + if (rb_block_given_p()) { + if (argc > 0) + rbtree_argc_error(); + IFNONE(self) = rb_block_proc(); + FL_SET(self, RBTREE_PROC_DEFAULT); + } else { + if (argc > 1) + rbtree_argc_error(); + else if (argc == 1) + IFNONE(self) = argv[0]; + } + return self; +} + +/*********************************************************************/ + +typedef enum { + INITIAL_VALUE, NODE_NOT_FOUND, NODE_FOUND +} insert_node_ret_t; + +typedef struct { + dict_t* dict; + dnode_t* node; + const void* key; + insert_node_ret_t ret; +} insert_node_t; + +static VALUE +insert_node_body(insert_node_t* arg) +{ + if (dict_insert(arg->dict, arg->node, arg->key)) + arg->ret = NODE_NOT_FOUND; + else + arg->ret = NODE_FOUND; + return Qnil; +} + +static VALUE +insert_node_ensure(insert_node_t* arg) +{ + dict_t* dict = arg->dict; + dnode_t* node = arg->node; + switch (arg->ret) { + case INITIAL_VALUE: + dict->dict_freenode(node, dict->dict_context); + break; + case NODE_NOT_FOUND: + if (TYPE(arg->key) == T_STRING) + node->dict_key = TO_KEY(rb_str_new4(GET_KEY(node))); + break; + case NODE_FOUND: + dict->dict_freenode(node, dict->dict_context); + break; + } + return Qnil; +} + +static void +rbtree_insert(VALUE self, VALUE key, VALUE value) +{ + insert_node_t arg; + dict_t* dict = DICT(self); + dnode_t* node = dict->dict_allocnode(dict->dict_context); + + dnode_init(node, TO_VAL(value)); + + arg.dict = dict; + arg.node = node; + arg.key = TO_KEY(key); + arg.ret = INITIAL_VALUE; + + rb_ensure(insert_node_body, (VALUE)&arg, + insert_node_ensure, (VALUE)&arg); +} + +/*********************************************************************/ + +/* + * + */ +VALUE +rbtree_aset(VALUE self, VALUE key, VALUE value) +{ + rbtree_modify(self); + + if (dict_isfull(DICT(self))) { + dnode_t* node = dict_lookup(DICT(self), TO_KEY(key)); + if (node == NULL) + rb_raise(rb_eIndexError, "rbtree full"); + else + dnode_put(node, TO_VAL(value)); + return value; + } + rbtree_insert(self, key, value); + return value; +} + +/* + * + */ +VALUE +rbtree_aref(VALUE self, VALUE key) +{ + dnode_t* node = dict_lookup(DICT(self), TO_KEY(key)); + if (node == NULL) + return rb_funcall(self, id_default, 1, key); + else + return GET_VAL(node); +} + +/* + * + */ +VALUE +rbtree_fetch(int argc, VALUE* argv, VALUE self) +{ + dnode_t* node; + int block_given; + + if (argc == 0 || argc > 2) + rbtree_argc_error(); + block_given = rb_block_given_p(); + if (block_given && argc == 2) + rb_warn("block supersedes default value argument"); + + node = dict_lookup(DICT(self), TO_KEY(argv[0])); + if (node != NULL) + return GET_VAL(node); + + if (block_given) + return rb_yield(argv[0]); + if (argc == 1) + rb_raise(rb_eIndexError, "key not found"); + return argv[1]; +} + +/* + * + */ +VALUE +rbtree_size(VALUE self) +{ + return ULONG2NUM(dict_count(DICT(self))); +} + +/* + * + */ +VALUE +rbtree_empty_p(VALUE self) +{ + return dict_isempty(DICT(self)) ? Qtrue : Qfalse; +} + +/* + * + */ +VALUE +rbtree_default(int argc, VALUE* argv, VALUE self) +{ + VALUE key = Qnil; + if (argc == 1) + key = argv[0]; + else if (argc > 1) + rbtree_argc_error(); + + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { + if (argc == 0) return Qnil; + return rb_funcall(IFNONE(self), id_call, 2, self, key); + } + return IFNONE(self); +} + +/* + * + */ +VALUE +rbtree_set_default(VALUE self, VALUE ifnone) +{ + rbtree_modify(self); + IFNONE(self) = ifnone; + FL_UNSET(self, RBTREE_PROC_DEFAULT); + return ifnone; +} + +/* + * + */ +VALUE +rbtree_default_proc(VALUE self) +{ + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) + return IFNONE(self); + return Qnil; +} + +static int +value_eq(const void* key1, const void* key2) +{ + return rb_equal((VALUE)key1, (VALUE)key2); +} + +/* + * + */ +VALUE +rbtree_equal(VALUE self, VALUE other) +{ + int ret; + if (self == other) + return Qtrue; + if (!rb_obj_is_kind_of(other, MultiRBTree)) + return Qfalse; + ret = dict_equal(DICT(self), DICT(other), value_eq); + return ret ? Qtrue : Qfalse; +} + +/*********************************************************************/ + +typedef enum { + EACH_NEXT, EACH_STOP +} each_return_t; + +typedef each_return_t (*each_callback_func)(dnode_t*, void*); + +typedef struct { + VALUE self; + each_callback_func func; + void* arg; + int reverse; + void* start; +} rbtree_each_arg_t; + +static VALUE +rbtree_each_ensure(VALUE self) +{ + ITER_LEV(self)--; + return Qnil; +} + +static VALUE +rbtree_each_body(rbtree_each_arg_t* arg) +{ + VALUE self = arg->self; + dict_t* dict = DICT(self); + dnode_t* node; + dnode_t* first_node = NULL; + dnode_t* (*next_func)(dict_t*, dnode_t*); + + if (arg->reverse) { + if (arg->start != NULL) + first_node = dict_upper_bound(dict, TO_KEY(arg->start)); + if (first_node == NULL) + first_node = dict_last(dict); + next_func = dict_prev; + } else { + if (arg->start != NULL) + first_node = dict_lower_bound(dict, TO_KEY(arg->start)); + if (first_node == NULL) + first_node = dict_first(dict); + next_func = dict_next; + } + + ITER_LEV(self)++; + for (node = first_node; + node != NULL; + node = next_func(dict, node)) { + + if (arg->func(node, arg->arg) == EACH_STOP) + break; + } + return self; +} + +static VALUE +rbtree_for_each(VALUE self, each_callback_func func, void* arg, void* start) +{ + rbtree_each_arg_t each_arg; + each_arg.self = self; + each_arg.func = func; + each_arg.arg = arg; + each_arg.reverse = 0; + each_arg.start = start; + return rb_ensure(rbtree_each_body, (VALUE)&each_arg, + rbtree_each_ensure, self); +} + +static VALUE +rbtree_reverse_for_each(VALUE self, each_callback_func func, void* arg, void *start) +{ + rbtree_each_arg_t each_arg; + each_arg.self = self; + each_arg.func = func; + each_arg.arg = arg; + each_arg.reverse = 1; + each_arg.start = start; + return rb_ensure(rbtree_each_body, (VALUE)&each_arg, + rbtree_each_ensure, self); +} + +/*********************************************************************/ + +static each_return_t +each_i(dnode_t* node, void* arg) +{ + rb_yield(ASSOC(node)); + return EACH_NEXT; +} + +/* + * call-seq: + * rbtree.each(start = nil) {|key, value| block} => rbtree + * + * Calls block once for each key in order, passing the key and value + * as a two-element array parameters. Starts at +start+ if given. + */ +VALUE +rbtree_each(int argc, VALUE *argv, VALUE self) +{ + if (argc > 1) + rbtree_argc_error(); + + if (argc == 0) + return rbtree_for_each(self, each_i, NULL, NULL); + else if (argc == 1) + return rbtree_for_each(self, each_i, NULL, argv[0]); +} + +static each_return_t +each_pair_i(dnode_t* node, void* arg) +{ + rb_yield_values(2, GET_KEY(node), GET_VAL(node)); + return EACH_NEXT; +} + +/* + * call-seq: + * rbtree.each_pair {|key, value| block} => rbtree + * + * Calls block once for each key in order, passing the key and value + * as parameters. + */ +VALUE +rbtree_each_pair(VALUE self) +{ + return rbtree_for_each(self, each_pair_i, NULL, NULL); +} + +static each_return_t +each_key_i(dnode_t* node, void* arg) +{ + rb_yield(GET_KEY(node)); + return EACH_NEXT; +} + +/* + * call-seq: + * rbtree.each_key {|key| block} => rbtree + * + * Calls block once for each key in order, passing the key as + * parameters. + */ +VALUE +rbtree_each_key(VALUE self) +{ + return rbtree_for_each(self, each_key_i, NULL, NULL); +} + +static each_return_t +each_value_i(dnode_t* node, void* arg) +{ + rb_yield(GET_VAL(node)); + return EACH_NEXT; +} + +/* + * call-seq: + * rbtree.each_value {|value| block} => rbtree + * + * Calls block once for each key in order, passing the value as + * parameters. + */ +VALUE +rbtree_each_value(VALUE self) +{ + return rbtree_for_each(self, each_value_i, NULL, NULL); +} + +/* + * call-seq: + * rbtree.reverse_each(start = nil) {|key, value| block} => rbtree + * + * Calls block once for each key in reverse order, passing the key and + * value as parameters. Starts at +start+ if given. + */ +VALUE +rbtree_reverse_each(int argc, VALUE *argv, VALUE self) +{ + if (argc > 1) + rbtree_argc_error(); + + if (argc == 0) + return rbtree_reverse_for_each(self, each_i, NULL, NULL); + else if (argc == 1) + return rbtree_reverse_for_each(self, each_i, NULL, argv[0]); +} + +static each_return_t +aset_i(dnode_t* node, void* self) +{ + rbtree_aset((VALUE)self, GET_KEY(node), GET_VAL(node)); + return EACH_NEXT; +} + +static void +copy_dict(VALUE src, VALUE dest, dict_comp_t cmp, void* context) +{ + VALUE temp = rbtree_alloc(CLASS_OF(dest)); + COMPARE(temp) = cmp; + CONTEXT(temp) = context; + rbtree_for_each(src, aset_i, (void*)temp, NULL); + { + dict_t* t = DICT(temp); + DICT(temp) = DICT(dest); + DICT(dest) = t; + } + rbtree_free(RBTREE(temp)); + rb_gc_force_recycle(temp); +} + +/* + * + */ +VALUE +rbtree_initialize_copy(VALUE self, VALUE other) +{ + if (self == other) + return self; + if (!rb_obj_is_kind_of(other, CLASS_OF(self))) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)", + rb_class2name(CLASS_OF(other)), + rb_class2name(CLASS_OF(self))); + } + + copy_dict(other, self, COMPARE(other), CONTEXT(other)); + + IFNONE(self) = IFNONE(other); + if (FL_TEST(other, RBTREE_PROC_DEFAULT)) + FL_SET(self, RBTREE_PROC_DEFAULT); + else + FL_UNSET(self, RBTREE_PROC_DEFAULT); + return self; +} + +#ifndef HAVE_RB_OBJ_INIT_COPY +/* + * + */ +VALUE +rbtree_clone(VALUE self) +{ + VALUE clone = rbtree_alloc(CLASS_OF(self)); + rbtree_initialize_copy(clone, self); + return clone; +} +#endif + +/* + * + */ +VALUE +rbtree_values_at(int argc, VALUE* argv, VALUE self) +{ + int i; + VALUE ary = rb_ary_new(); + + for (i = 0; i < argc; i++) + rb_ary_push(ary, rbtree_aref(self, argv[i])); + return ary; +} + +static each_return_t +select_i(dnode_t* node, void* ary) +{ + if (RTEST(rb_yield_values(2, GET_KEY(node), GET_VAL(node)))) + rb_ary_push((VALUE)ary, ASSOC(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_select(VALUE self) +{ + VALUE ary = rb_ary_new(); + rbtree_for_each(self, select_i, (void*)ary, NULL); + return ary; +} + +static each_return_t +index_i(dnode_t* node, void* arg_) +{ + VALUE* arg = (VALUE*)arg_; + if (rb_equal(GET_VAL(node), arg[1])) { + arg[0] = GET_KEY(node); + return EACH_STOP; + } + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_index(VALUE self, VALUE value) +{ + VALUE arg[2]; + arg[0] = Qnil; + arg[1] = value; + rbtree_for_each(self, index_i, (void*)&arg, NULL); + return arg[0]; +} + +/* + * + */ +VALUE +rbtree_clear(VALUE self) +{ + rbtree_modify(self); + dict_free_nodes(DICT(self)); + return self; +} + +/* + * + */ +VALUE +rbtree_delete(VALUE self, VALUE key) +{ + dict_t* dict = DICT(self); + dnode_t* node; + VALUE value; + + rbtree_modify(self); + node = dict_lookup(dict, TO_KEY(key)); + if (node == NULL) + return rb_block_given_p() ? rb_yield(key) : Qnil; + value = GET_VAL(node); + dict_delete_free(dict, node); + return value; +} + +/*********************************************************************/ + +typedef struct dnode_list_t_ { + struct dnode_list_t_* prev; + dnode_t* node; +} dnode_list_t; + +typedef struct { + VALUE self; + dnode_list_t* list; + int raised; +} rbtree_delete_if_arg_t; + +static VALUE +rbtree_delete_if_ensure(rbtree_delete_if_arg_t* arg) +{ + dict_t* dict = DICT(arg->self); + dnode_list_t* list = arg->list; + + if (--ITER_LEV(arg->self) == 0) { + while (list != NULL) { + dnode_list_t* l = list; + if (!arg->raised) + dict_delete_free(dict, l->node); + list = l->prev; + xfree(l); + } + } + return Qnil; +} + +static VALUE +rbtree_delete_if_body(rbtree_delete_if_arg_t* arg) +{ + VALUE self = arg->self; + dict_t* dict = DICT(self); + dnode_t* node; + + arg->raised = 1; + ITER_LEV(self)++; + for (node = dict_first(dict); + node != NULL; + node = dict_next(dict, node)) { + + if (RTEST(rb_yield_values(2, GET_KEY(node), GET_VAL(node)))) { + dnode_list_t* l = ALLOC(dnode_list_t); + l->node = node; + l->prev = arg->list; + arg->list = l; + } + } + arg->raised = 0; + return self; +} + +/*********************************************************************/ + +/* + * + */ +VALUE +rbtree_delete_if(VALUE self) +{ + rbtree_delete_if_arg_t arg; + + rbtree_modify(self); + arg.self = self; + arg.list = NULL; + return rb_ensure(rbtree_delete_if_body, (VALUE)&arg, + rbtree_delete_if_ensure, (VALUE)&arg); +} + +/* + * + */ +VALUE +rbtree_reject_bang(VALUE self) +{ + const dictcount_t count = dict_count(DICT(self)); + rbtree_delete_if(self); + if (count == dict_count(DICT(self))) + return Qnil; + return self; +} + +/* + * + */ +VALUE +rbtree_reject(VALUE self) +{ + return rbtree_reject_bang(rb_obj_dup(self)); +} + +static VALUE +rbtree_shift_pop(VALUE self, const int mode) +{ + dict_t* dict = DICT(self); + dnode_t* node; + VALUE ret; + + rbtree_modify(self); + + if (dict_isempty(dict)) { + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { + return rb_funcall(IFNONE(self), id_call, 2, self, Qnil); + } + return IFNONE(self); + } + + if (mode == 0) + node = dict_first(dict); + else + node = dict_last(dict); + ret = ASSOC(node); + dict_delete_free(dict, node); + return ret; +} + +/* + * call-seq: + * rbtree.shift => array or object + * + * Removes the first(that is, the smallest) key-value pair and returns + * it as a two-item array. + */ +VALUE +rbtree_shift(VALUE self) +{ + return rbtree_shift_pop(self, 0); +} + +/* + * call-seq: + * rbtree.pop => array or object + * + * Removes the last(that is, the biggest) key-value pair and returns + * it as a two-item array. + */ +VALUE +rbtree_pop(VALUE self) +{ + return rbtree_shift_pop(self, 1); +} + +static each_return_t +invert_i(dnode_t* node, void* rbtree) +{ + rbtree_aset((VALUE)rbtree, GET_VAL(node), GET_KEY(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_invert(VALUE self) +{ + VALUE rbtree = rbtree_alloc(CLASS_OF(self)); + rbtree_for_each(self, invert_i, (void*)rbtree, NULL); + return rbtree; +} + +static each_return_t +update_block_i(dnode_t* node, void* self_) +{ + VALUE self = (VALUE)self_; + VALUE key = GET_KEY(node); + VALUE value = GET_VAL(node); + + if (rbtree_has_key(self, key)) + value = rb_yield_values(3, key, rbtree_aref(self, key), value); + rbtree_aset(self, key, value); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_update(VALUE self, VALUE other) +{ + rbtree_modify(self); + + if (self == other) + return self; + if (!rb_obj_is_kind_of(other, CLASS_OF(self))) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)", + rb_class2name(CLASS_OF(other)), + rb_class2name(CLASS_OF(self))); + } + + if (rb_block_given_p()) + rbtree_for_each(other, update_block_i, (void*)self, NULL); + else + rbtree_for_each(other, aset_i, (void*)self, NULL); + return self; +} + +/* + * + */ +VALUE +rbtree_merge(VALUE self, VALUE other) +{ + return rbtree_update(rb_obj_dup(self), other); +} + +/* + * + */ +VALUE +rbtree_has_key(VALUE self, VALUE key) +{ + return dict_lookup(DICT(self), TO_KEY(key)) == NULL ? Qfalse : Qtrue; +} + +static each_return_t +has_value_i(dnode_t* node, void* arg_) +{ + VALUE* arg = (VALUE*)arg_; + if (rb_equal(GET_VAL(node), arg[1])) { + arg[0] = Qtrue; + return EACH_STOP; + } + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_has_value(VALUE self, VALUE value) +{ + VALUE arg[2]; + arg[0] = Qfalse; + arg[1] = value; + rbtree_for_each(self, has_value_i, (void*)&arg, NULL); + return arg[0]; +} + +static each_return_t +keys_i(dnode_t* node, void* ary) +{ + rb_ary_push((VALUE)ary, GET_KEY(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_keys(VALUE self) +{ + VALUE ary = rb_ary_new(); + rbtree_for_each(self, keys_i, (void*)ary, NULL); + return ary; +} + +static each_return_t +values_i(dnode_t* node, void* ary) +{ + rb_ary_push((VALUE)ary, GET_VAL(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_values(VALUE self) +{ + VALUE ret = rb_ary_new(); + rbtree_for_each(self, values_i, (void*)ret, NULL); + return ret; +} + +static each_return_t +to_a_i(dnode_t* node, void* ary) +{ + rb_ary_push((VALUE)ary, ASSOC(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_to_a(VALUE self) +{ + VALUE ary = rb_ary_new(); + rbtree_for_each(self, to_a_i, (void*)ary, NULL); + OBJ_INFECT(ary, self); + return ary; +} + +static each_return_t +to_hash_i(dnode_t* node, void* hash) +{ + st_insert(RHASH(hash)->tbl, GET_KEY(node), GET_VAL(node)); + return EACH_NEXT; +} + +/* + * + */ +VALUE +rbtree_to_hash(VALUE self) +{ + VALUE hash = rb_hash_new(); + rbtree_for_each(self, to_hash_i, (void*)hash, NULL); + RHASH(hash)->ifnone = IFNONE(self); + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) + FL_SET(hash, HASH_PROC_DEFAULT); + OBJ_INFECT(hash, self); + return hash; +} + +/* + * + */ +VALUE +rbtree_to_rbtree(VALUE self) +{ + return self; +} + +static VALUE +rbtree_begin_inspect(VALUE self) +{ + const char* c = rb_class2name(CLASS_OF(self)); + VALUE str = rb_str_new(0, strlen(c) + 5); + const size_t len = sprintf(RSTRING(str)->ptr, "#<%s: ", c); + RSTRING(str)->len = len; + return str; +} + +static VALUE +to_s_rbtree(VALUE self, VALUE nil) +{ + return rb_ary_to_s(rbtree_to_a(self)); +} + +/* + * + */ +VALUE +rbtree_to_s(VALUE self) +{ + if (rb_inspecting_p(self)) + return rb_str_cat2(rbtree_begin_inspect(self), "...>"); + return rb_protect_inspect(to_s_rbtree, self, Qnil); +} + +static each_return_t +inspect_i(dnode_t* node, void* ret_) +{ + VALUE ret = (VALUE)ret_; + VALUE str; + + if (RSTRING(ret)->ptr[0] == '-') + RSTRING(ret)->ptr[0] = '#'; + else + rb_str_cat2(ret, ", "); + + str = rb_inspect(GET_KEY(node)); + rb_str_append(ret, str); + OBJ_INFECT(ret, str); + + rb_str_cat2(ret, "=>"); + + str = rb_inspect(GET_VAL(node)); + rb_str_append(ret, str); + OBJ_INFECT(ret, str); + + return EACH_NEXT; +} + +static VALUE +inspect_rbtree(VALUE self, VALUE ret) +{ + VALUE str; + + rb_str_cat2(ret, "{"); + RSTRING(ret)->ptr[0] = '-'; + rbtree_for_each(self, inspect_i, (void*)ret, NULL); + RSTRING(ret)->ptr[0] = '#'; + rb_str_cat2(ret, "}"); + + str = rb_inspect(IFNONE(self)); + rb_str_cat2(ret, ", default="); + rb_str_append(ret, str); + OBJ_INFECT(ret, str); + + str = rb_inspect((VALUE)CONTEXT(self)); + rb_str_cat2(ret, ", cmp_proc="); + rb_str_append(ret, str); + OBJ_INFECT(ret, str); + + rb_str_cat2(ret, ">"); + OBJ_INFECT(ret, self); + return ret; +} + +/* + * + */ +VALUE +rbtree_inspect(VALUE self) +{ + VALUE str = rbtree_begin_inspect(self); + if (rb_inspecting_p(self)) + return rb_str_cat2(str, "...>"); + return rb_protect_inspect(inspect_rbtree, self, str); +} + +/* + * call-seq: + * rbtree.lower_bound(key) => array + * + * Retruns key-value pair corresponding to the lowest key that is + * equal to or greater than the given key(inside of lower + * boundary). If there is no such key, returns nil. + */ +VALUE +rbtree_lower_bound(VALUE self, VALUE key) +{ + dnode_t* node = dict_lower_bound(DICT(self), TO_KEY(key)); + if (node == NULL) + return Qnil; + return ASSOC(node); +} + +/* + * call-seq: + * rbtree.upper_bound(key) => array + * + * Retruns key-value pair corresponding to the greatest key that is + * equal to or lower than the given key(inside of upper boundary). If + * there is no such key, returns nil. + */ +VALUE +rbtree_upper_bound(VALUE self, VALUE key) +{ + dnode_t* node = dict_upper_bound(DICT(self), TO_KEY(key)); + if (node == NULL) + return Qnil; + return ASSOC(node); +} + +/*********************************************************************/ + +typedef struct { + VALUE self; + dnode_t* lower_node; + dnode_t* upper_node; + VALUE ret; +} rbtree_bound_arg_t; + +static VALUE +rbtree_bound_body(rbtree_bound_arg_t* arg) +{ + VALUE self = arg->self; + dict_t* dict = DICT(self); + dnode_t* lower_node = arg->lower_node; + dnode_t* upper_node = arg->upper_node; + const int block_given = rb_block_given_p(); + VALUE ret = arg->ret; + dnode_t* node; + + ITER_LEV(self)++; + for (node = lower_node;; + node = dict_next(dict, node)) { + + if (block_given) + rb_yield_values(2, GET_KEY(node), GET_VAL(node)); + else + rb_ary_push(ret, ASSOC(node)); + if (node == upper_node) + break; + } + return ret; +} + +/*********************************************************************/ + +/* + * call-seq: + * rbtree.bound(key1, key2 = key1) => array + * rbtree.bound(key1, key2 = key1) {|key, value| block} => rbtree + * + * Returns an array containing key-value pairs between the result of + * RBTree#lower_bound and RBTree#upper_bound. If a block is given it + * calls the block once for each pair. + */ +VALUE +rbtree_bound(int argc, VALUE* argv, VALUE self) +{ + dict_t* dict = DICT(self); + dnode_t* lower_node; + dnode_t* upper_node; + VALUE ret; + + if (argc == 0 || argc > 2) + rbtree_argc_error(); + + lower_node = dict_lower_bound(dict, TO_KEY(argv[0])); + upper_node = dict_upper_bound(dict, TO_KEY(argv[argc - 1])); + ret = rb_block_given_p() ? self : rb_ary_new(); + + if (lower_node == NULL || upper_node == NULL || + COMPARE(self)(dnode_getkey(lower_node), + dnode_getkey(upper_node), + CONTEXT(self)) > 0) { + return ret; + } else { + rbtree_bound_arg_t arg; + arg.self = self; + arg.lower_node = lower_node; + arg.upper_node = upper_node; + arg.ret = ret; + + return rb_ensure(rbtree_bound_body, (VALUE)&arg, + rbtree_each_ensure, self); + } +} + +static VALUE +rbtree_first_last(VALUE self, const int mode) +{ + dict_t* dict = DICT(self); + dnode_t* node; + + if (dict_isempty(dict)) { + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { + return rb_funcall(IFNONE(self), id_call, 2, self, Qnil); + } + return IFNONE(self); + } + + if (mode == 0) + node = dict_first(dict); + else + node = dict_last(dict); + return ASSOC(node); +} + +/* + * call-seq: + * rbtree.first => array or object + * + * Returns the first(that is, the smallest) key-value pair. + */ +VALUE +rbtree_first(VALUE self) +{ + return rbtree_first_last(self, 0); +} + +/* + * call-seq: + * rbtree.last => array of object + * + * Returns the last(that is, the biggest) key-value pair. + */ +VALUE +rbtree_last(VALUE self) +{ + return rbtree_first_last(self, 1); +} + +/* + * call-seq: + * rbtree.readjust => rbtree + * rbtree.readjust(nil) => rbtree + * rbtree.readjust(proc) => rbtree + * rbtree.readjust {|key1, key2| block} => rbtree + * + * Sets a proc to compare keys and readjusts elements using the given + * block or a Proc object given as the argument. The block takes two + * key arguments and returns negative, 0, or positive depending on the + * first argument is less than, equal to, or greater than the second + * one. If no block is given it just readjusts elements using current + * comparison block. If nil is given as the argument it sets default + * comparison block. + */ +VALUE +rbtree_readjust(int argc, VALUE* argv, VALUE self) +{ + dict_comp_t cmp = NULL; + void* context = NULL; + + rbtree_modify(self); + + if (argc == 0) { + if (rb_block_given_p()) { + cmp = rbtree_user_cmp; + context = (void*)rb_block_proc(); + } else { + cmp = COMPARE(self); + context = CONTEXT(self); + } + } else if (argc == 1 && !rb_block_given_p()) { + if (argv[0] == Qnil) { + cmp = rbtree_cmp; + context = (void*)Qnil; + } else { + if (CLASS_OF(argv[0]) != rb_cProc) + rb_raise(rb_eTypeError, + "wrong argument type %s (expected Proc)", + rb_class2name(CLASS_OF(argv[0]))); + cmp = rbtree_user_cmp; + context = (void*)argv[0]; + } + } else { + rbtree_argc_error(); + } + + if (dict_isempty(DICT(self))) { + COMPARE(self) = cmp; + CONTEXT(self) = context; + return self; + } + copy_dict(self, self, cmp, context); + return self; +} + +/* + * call-seq: + * rbtree.cmp_proc => proc + * + * Returns the comparison block that is given by RBTree#readjust. + */ +VALUE +rbtree_cmp_proc(VALUE self) +{ + return (VALUE)(CONTEXT(self)); +} + +/*********************************************************************/ + +static ID id_comma_breakable; +static ID id_object_group; +static ID id_pp; +static ID id_pp_hash; +static ID id_text; + +typedef struct { + VALUE rbtree; + VALUE pp; +} pp_arg_t; + +static VALUE +pp_object_group(VALUE arg_) +{ + pp_arg_t* arg = (pp_arg_t*)arg_; + return rb_funcall(arg->pp, id_object_group, 1, arg->rbtree); +} + +static VALUE +pp_block(VALUE nil, pp_arg_t* arg) +{ + VALUE pp = arg->pp; + VALUE rbtree = arg->rbtree; + + rb_funcall(pp, id_text, 1, rb_str_new2(": ")); + rb_funcall(pp, id_pp_hash, 1, rbtree); + rb_funcall(pp, id_comma_breakable, 0); + rb_funcall(pp, id_text, 1, rb_str_new2("default=")); + rb_funcall(pp, id_pp, 1, IFNONE(rbtree)); + rb_funcall(pp, id_comma_breakable, 0); + rb_funcall(pp, id_text, 1, rb_str_new2("cmp_proc=")); + rb_funcall(pp, id_pp, 1, CONTEXT(rbtree)); + return pp; +} + +/*********************************************************************/ + +/* + * Called by pretty printing function pp. + */ +VALUE +rbtree_pretty_print(VALUE self, VALUE pp) +{ + pp_arg_t pp_arg; + pp_arg.rbtree = self; + pp_arg.pp = pp; + + return rb_iterate(pp_object_group, (VALUE)&pp_arg, + pp_block, (VALUE)&pp_arg); +} + +/* + * Called by pretty printing function pp. + */ +VALUE +rbtree_pretty_print_cycle(VALUE self, VALUE pp) +{ + return rb_funcall(pp, id_pp, 1, rbtree_inspect(self)); +} + +/*********************************************************************/ + +#ifndef HAVE_RB_MARSHAL_DUMP +static VALUE +rb_marshal_dump(VALUE obj, VALUE port) +{ + return rb_funcall(rb_mMarshal, id_dump, 2, obj, port); +} + +static VALUE +rb_marshal_load(VALUE port) +{ + return rb_funcall(rb_mMarshal, id_load, 1, port); +} +#endif + +static each_return_t +to_flatten_ary_i(dnode_t* node, void* ary) +{ + rb_ary_push((VALUE)ary, GET_KEY(node)); + rb_ary_push((VALUE)ary, GET_VAL(node)); + return EACH_NEXT; +} + +/*********************************************************************/ + +/* + * Called by Marshal.dump. + */ +VALUE +rbtree_dump(VALUE self, VALUE limit) +{ + VALUE ary; + VALUE ret; + + if (FL_TEST(self, RBTREE_PROC_DEFAULT)) + rb_raise(rb_eTypeError, "cannot dump rbtree with default proc"); + if ((VALUE)CONTEXT(self) != Qnil) + rb_raise(rb_eTypeError, "cannot dump rbtree with compare proc"); + + ary = rb_ary_new2(dict_count(DICT(self)) * 2 + 1); + rbtree_for_each(self, to_flatten_ary_i, (void*)ary, NULL); + rb_ary_push(ary, IFNONE(self)); + + ret = rb_marshal_dump(ary, limit); + rb_ary_clear(ary); + rb_gc_force_recycle(ary); + return ret; +} + +/* + * Called by Marshal.load. + */ +VALUE +rbtree_s_load(VALUE klass, VALUE str) +{ + VALUE rbtree = rbtree_alloc(klass); + VALUE ary = rb_marshal_load(str); + VALUE* ptr = RARRAY(ary)->ptr; + long len = RARRAY(ary)->len - 1; + long i; + + for (i = 0; i < len; i += 2) + rbtree_aset(rbtree, ptr[i], ptr[i + 1]); + IFNONE(rbtree) = ptr[len]; + + rb_ary_clear(ary); + rb_gc_force_recycle(ary); + return rbtree; +} + +/*********************************************************************/ + +/* + * Document-class: RBTree + * + * RBTree is a sorted associative collection using Red-Black Tree as + * the internal data structure. The elements of RBTree are ordered and + * the interface is the almost same as Hash, so simply you can + * consider RBTree sorted Hash. + * + * Red-Black Tree is a kind of binary tree that automatically balances + * by itself when a node is inserted or deleted. Thus the complexity + * for insert, search and delete is O(log N) in expected and worst + * case. On the other hand the complexity of Hash is O(1). Because + * Hash is unordered the data structure is more effective than + * Red-Black Tree as an associative collection. + * + * The interface of RBTree is the almost same as Hash although there + * are some limitations. + * + * * While iterating (e.g. in RBTree#each block), RBTree is + * unmodifiable. + * + * * Comparison is done using <=> method of key objects. So all types + * of keys in RBTree should be comparable each other or an arbitrary + * Proc might be set by RBTree#readjust. + * + * RBTree has a few searching methods that Hash doesn't have. They are + * RBTree#lower_bound, RBTree#upper_bound and RBTree#bound. See + * document of each method for details. + * + * Pretty printing is available for RBTree by using pp.rb. The output + * of pp is easier than p to read. Just call Kernel#pp for the object. + * + * MultiRBTree that allows duplicates of keys is also available. + */ +void Init_archipelago_rbtree() +{ + MultiRBTree = rb_define_class("MultiRBTree", rb_cData); + RBTree = rb_define_class("RBTree", MultiRBTree); + + rb_include_module(MultiRBTree, rb_mEnumerable); + +#ifdef HAVE_OBJECT_ALLOCATE + rb_define_alloc_func(MultiRBTree, rbtree_alloc); +#else + rb_define_singleton_method(MultiRBTree, "new", rbtree_s_new, -1); +#endif + rb_define_singleton_method(MultiRBTree, "[]", rbtree_s_create, -1); + + rb_define_method(MultiRBTree, "initialize", rbtree_initialize, -1); + +#ifdef HAVE_RB_OBJ_INIT_COPY + rb_define_method(MultiRBTree, "initialize_copy", rbtree_initialize_copy, 1); +#else + rb_define_method(MultiRBTree, "clone", rbtree_clone, 0); +#endif + + rb_define_method(MultiRBTree, "to_a", rbtree_to_a, 0); + rb_define_method(MultiRBTree, "to_s", rbtree_to_s, 0); + rb_define_method(MultiRBTree, "to_hash", rbtree_to_hash, 0); + rb_define_method(MultiRBTree, "to_rbtree", rbtree_to_rbtree, 0); + rb_define_method(MultiRBTree, "inspect", rbtree_inspect, 0); + + rb_define_method(MultiRBTree, "==", rbtree_equal, 1); + rb_define_method(MultiRBTree, "[]", rbtree_aref, 1); + rb_define_method(MultiRBTree, "fetch", rbtree_fetch, -1); + rb_define_method(MultiRBTree, "lower_bound", rbtree_lower_bound, 1); + rb_define_method(MultiRBTree, "upper_bound", rbtree_upper_bound, 1); + rb_define_method(MultiRBTree, "bound", rbtree_bound, -1); + rb_define_method(MultiRBTree, "first", rbtree_first, 0); + rb_define_method(MultiRBTree, "last", rbtree_last, 0); + rb_define_method(MultiRBTree, "[]=", rbtree_aset, 2); + rb_define_method(MultiRBTree, "store", rbtree_aset, 2); + rb_define_method(MultiRBTree, "default", rbtree_default, -1); + rb_define_method(MultiRBTree, "default=", rbtree_set_default, 1); + rb_define_method(MultiRBTree, "default_proc", rbtree_default_proc, 0); + rb_define_method(MultiRBTree, "index", rbtree_index, 1); + rb_define_method(MultiRBTree, "empty?", rbtree_empty_p, 0); + rb_define_method(MultiRBTree, "size", rbtree_size, 0); + rb_define_method(MultiRBTree, "length", rbtree_size, 0); + + rb_define_method(MultiRBTree, "each", rbtree_each, -1); + rb_define_method(MultiRBTree, "each_value", rbtree_each_value, 0); + rb_define_method(MultiRBTree, "each_key", rbtree_each_key, 0); + rb_define_method(MultiRBTree, "each_pair", rbtree_each_pair, 0); + rb_define_method(MultiRBTree, "reverse_each", rbtree_reverse_each, -1); + + rb_define_method(MultiRBTree, "keys", rbtree_keys, 0); + rb_define_method(MultiRBTree, "values", rbtree_values, 0); + rb_define_method(MultiRBTree, "values_at", rbtree_values_at, -1); + + rb_define_method(MultiRBTree, "shift", rbtree_shift, 0); + rb_define_method(MultiRBTree, "pop", rbtree_pop, 0); + rb_define_method(MultiRBTree, "delete", rbtree_delete, 1); + rb_define_method(MultiRBTree, "delete_if", rbtree_delete_if, 0); + rb_define_method(MultiRBTree, "select", rbtree_select, 0); + rb_define_method(MultiRBTree, "reject", rbtree_reject, 0); + rb_define_method(MultiRBTree, "reject!", rbtree_reject_bang, 0); + rb_define_method(MultiRBTree, "clear", rbtree_clear, 0); + rb_define_method(MultiRBTree, "invert", rbtree_invert, 0); + rb_define_method(MultiRBTree, "update", rbtree_update, 1); + rb_define_method(MultiRBTree, "merge!", rbtree_update, 1); + rb_define_method(MultiRBTree, "merge", rbtree_merge, 1); + rb_define_method(MultiRBTree, "replace", rbtree_initialize_copy, 1); + + rb_define_method(MultiRBTree, "include?", rbtree_has_key, 1); + rb_define_method(MultiRBTree, "member?", rbtree_has_key, 1); + rb_define_method(MultiRBTree, "has_key?", rbtree_has_key, 1); + rb_define_method(MultiRBTree, "has_value?", rbtree_has_value, 1); + rb_define_method(MultiRBTree, "key?", rbtree_has_key, 1); + rb_define_method(MultiRBTree, "value?", rbtree_has_value, 1); + + rb_define_method(MultiRBTree, "readjust", rbtree_readjust, -1); + rb_define_method(MultiRBTree, "cmp_proc", rbtree_cmp_proc, 0); + + rb_define_method(MultiRBTree, "_dump", rbtree_dump, 1); + rb_define_singleton_method(MultiRBTree, "_load", rbtree_s_load, 1); +#ifndef HAVE_RB_MARSHAL_DUMP + rb_mMarshal = rb_path2class("Marshal"); + id_dump = rb_intern("dump"); + id_load = rb_intern("load"); +#endif + + id_bound = rb_intern("bound"); + id_cmp = rb_intern("<=>"); + id_call = rb_intern("call"); + id_default = rb_intern("default"); + + + rb_define_method(MultiRBTree, "pretty_print", rbtree_pretty_print, 1); + rb_define_method(MultiRBTree, + "pretty_print_cycle", rbtree_pretty_print_cycle, 1); + + id_comma_breakable = rb_intern("comma_breakable"); + id_object_group = rb_intern("object_group"); + id_pp_hash = rb_intern("pp_hash"); + id_text = rb_intern("text"); + id_pp = rb_intern("pp"); +} Added: trunk/rbtree-0.2.0/ext/dict.c =================================================================== --- trunk/rbtree-0.2.0/ext/dict.c (rev 0) +++ trunk/rbtree-0.2.0/ext/dict.c 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,1216 @@ +/* + * Dictionary Abstract Data Type + * Copyright (C) 1997 Kaz Kylheku + * + * Free Software License: + * + * All rights are reserved by the author, with the following exceptions: + * Permission is granted to freely reproduce and distribute this software, + * possibly in exchange for a fee, provided that this copyright notice appears + * intact. Permission is also granted to adapt this software to produce + * derivative works, as long as the modified versions carry this copyright + * notice and additional notices stating that the work has been modified. + * This source code may be translated into executable form and incorporated + * into proprietary software; there is no requirement for such software to + * contain a copyright notice related to this source. + * + * $Id: dict.c,v 1.15 2005/10/06 05:16:35 kuma Exp $ + * $Name: $ + */ + +/* + * Modified for Ruby/RBTree by OZAWA Takuma. + */ + +#include +#include +#include +#include "dict.h" + +#include + +#ifdef KAZLIB_RCSID +static const char rcsid[] = "$Id: dict.c,v 1.15 2005/10/06 05:16:35 kuma Exp $"; +#endif + +/* + * These macros provide short convenient names for structure members, + * which are embellished with dict_ prefixes so that they are + * properly confined to the documented namespace. It's legal for a + * program which uses dict to define, for instance, a macro called ``parent''. + * Such a macro would interfere with the dnode_t struct definition. + * In general, highly portable and reusable C modules which expose their + * structures need to confine structure member names to well-defined spaces. + * The resulting identifiers aren't necessarily convenient to use, nor + * readable, in the implementation, however! + */ + +#define left dict_left +#define right dict_right +#define parent dict_parent +#define color dict_color +#define key dict_key +#define data dict_data + +#define nilnode dict_nilnode +#define nodecount dict_nodecount +#define compare dict_compare +#define allocnode dict_allocnode +#define freenode dict_freenode +#define context dict_context +#define dupes dict_dupes + +#define dictptr dict_dictptr + +#define dict_root(D) ((D)->nilnode.left) +#define dict_nil(D) (&(D)->nilnode) +#define DICT_DEPTH_MAX 64 + +#define COMPARE(dict, key1, key2) dict->compare(key1, key2, dict->context) + +static dnode_t *dnode_alloc(void *context); +static void dnode_free(dnode_t *node, void *context); + +/* + * Perform a ``left rotation'' adjustment on the tree. The given node P and + * its right child C are rearranged so that the P instead becomes the left + * child of C. The left subtree of C is inherited as the new right subtree + * for P. The ordering of the keys within the tree is thus preserved. + */ + +static void rotate_left(dnode_t *upper) +{ + dnode_t *lower, *lowleft, *upparent; + + lower = upper->right; + upper->right = lowleft = lower->left; + lowleft->parent = upper; + + lower->parent = upparent = upper->parent; + + /* don't need to check for root node here because root->parent is + the sentinel nil node, and root->parent->left points back to root */ + + if (upper == upparent->left) { + upparent->left = lower; + } else { + assert (upper == upparent->right); + upparent->right = lower; + } + + lower->left = upper; + upper->parent = lower; +} + +/* + * This operation is the ``mirror'' image of rotate_left. It is + * the same procedure, but with left and right interchanged. + */ + +static void rotate_right(dnode_t *upper) +{ + dnode_t *lower, *lowright, *upparent; + + lower = upper->left; + upper->left = lowright = lower->right; + lowright->parent = upper; + + lower->parent = upparent = upper->parent; + + if (upper == upparent->right) { + upparent->right = lower; + } else { + assert (upper == upparent->left); + upparent->left = lower; + } + + lower->right = upper; + upper->parent = lower; +} + +/* + * Do a postorder traversal of the tree rooted at the specified + * node and free everything under it. Used by dict_free(). + */ + +static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil) +{ + if (node == nil) + return; + free_nodes(dict, node->left, nil); + free_nodes(dict, node->right, nil); + dict->freenode(node, dict->context); +} + +/* + * This procedure performs a verification that the given subtree is a binary + * search tree. It performs an inorder traversal of the tree using the + * dict_next() successor function, verifying that the key of each node is + * strictly lower than that of its successor, if duplicates are not allowed, + * or lower or equal if duplicates are allowed. This function is used for + * debugging purposes. + */ + +static int verify_bintree(dict_t *dict) +{ + dnode_t *first, *next; + + first = dict_first(dict); + + if (dict->dupes) { + while (first && (next = dict_next(dict, first))) { + if (COMPARE(dict, first->key, next->key) > 0) + return 0; + first = next; + } + } else { + while (first && (next = dict_next(dict, first))) { + if (COMPARE(dict, first->key, next->key) >= 0) + return 0; + first = next; + } + } + return 1; +} + + +/* + * This function recursively verifies that the given binary subtree satisfies + * three of the red black properties. It checks that every red node has only + * black children. It makes sure that each node is either red or black. And it + * checks that every path has the same count of black nodes from root to leaf. + * It returns the blackheight of the given subtree; this allows blackheights to + * be computed recursively and compared for left and right siblings for + * mismatches. It does not check for every nil node being black, because there + * is only one sentinel nil node. The return value of this function is the + * black height of the subtree rooted at the node ``root'', or zero if the + * subtree is not red-black. + */ + +static unsigned int verify_redblack(dnode_t *nil, dnode_t *root) +{ + unsigned height_left, height_right; + + if (root != nil) { + height_left = verify_redblack(nil, root->left); + height_right = verify_redblack(nil, root->right); + if (height_left == 0 || height_right == 0) + return 0; + if (height_left != height_right) + return 0; + if (root->color == dnode_red) { + if (root->left->color != dnode_black) + return 0; + if (root->right->color != dnode_black) + return 0; + return height_left; + } + if (root->color != dnode_black) + return 0; + return height_left + 1; + } + return 1; +} + +/* + * Compute the actual count of nodes by traversing the tree and + * return it. This could be compared against the stored count to + * detect a mismatch. + */ + +static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root) +{ + if (root == nil) + return 0; + else + return 1 + verify_node_count(nil, root->left) + + verify_node_count(nil, root->right); +} + +/* + * Verify that the tree contains the given node. This is done by + * traversing all of the nodes and comparing their pointers to the + * given pointer. Returns 1 if the node is found, otherwise + * returns zero. It is intended for debugging purposes. + */ + +static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node) +{ + if (root != nil) { + return root == node + || verify_dict_has_node(nil, root->left, node) + || verify_dict_has_node(nil, root->right, node); + } + return 0; +} + + +/* + * Dynamically allocate and initialize a dictionary object. + */ + +dict_t *dict_create(dict_comp_t comp) +{ + dict_t* new = ALLOC(dict_t); + + if (new) { + new->compare = comp; + new->allocnode = dnode_alloc; + new->freenode = dnode_free; + new->context = NULL; + new->nodecount = 0; + new->nilnode.left = &new->nilnode; + new->nilnode.right = &new->nilnode; + new->nilnode.parent = &new->nilnode; + new->nilnode.color = dnode_black; + new->dupes = 0; + } + return new; +} + +/* + * Select a different set of node allocator routines. + */ + +void dict_set_allocator(dict_t *dict, dnode_alloc_t al, + dnode_free_t fr, void *context) +{ + assert (dict_count(dict) == 0); + assert ((al == NULL && fr == NULL) || (al != NULL && fr != NULL)); + + dict->allocnode = al ? al : dnode_alloc; + dict->freenode = fr ? fr : dnode_free; + dict->context = context; +} + +/* + * Free a dynamically allocated dictionary object. Removing the nodes + * from the tree before deleting it is required. + */ + +void dict_destroy(dict_t *dict) +{ + assert (dict_isempty(dict)); + xfree(dict); +} + +/* + * Free all the nodes in the dictionary by using the dictionary's + * installed free routine. The dictionary is emptied. + */ + +void dict_free_nodes(dict_t *dict) +{ + dnode_t *nil = dict_nil(dict), *root = dict_root(dict); + free_nodes(dict, root, nil); + dict->nodecount = 0; + dict->nilnode.left = &dict->nilnode; + dict->nilnode.right = &dict->nilnode; + dict->nilnode.parent = &dict->nilnode; +} + +/* + * Obsolescent function, equivalent to dict_free_nodes + */ + +void dict_free(dict_t *dict) +{ +#ifdef KAZLIB_OBSOLESCENT_DEBUG + assert ("call to obsolescent function dict_free()" && 0); +#endif + dict_free_nodes(dict); +} + +/* + * Initialize a user-supplied dictionary object. + */ + +dict_t *dict_init(dict_t *dict, dict_comp_t comp) +{ + dict->compare = comp; + dict->allocnode = dnode_alloc; + dict->freenode = dnode_free; + dict->context = NULL; + dict->nodecount = 0; + dict->nilnode.left = &dict->nilnode; + dict->nilnode.right = &dict->nilnode; + dict->nilnode.parent = &dict->nilnode; + dict->nilnode.color = dnode_black; + dict->dupes = 0; + return dict; +} + +/* + * Initialize a dictionary in the likeness of another dictionary + */ + +void dict_init_like(dict_t *dict, const dict_t *template) +{ + dict->compare = template->compare; + dict->allocnode = template->allocnode; + dict->freenode = template->freenode; + dict->context = template->context; + dict->nodecount = 0; + dict->nilnode.left = &dict->nilnode; + dict->nilnode.right = &dict->nilnode; + dict->nilnode.parent = &dict->nilnode; + dict->nilnode.color = dnode_black; + dict->dupes = template->dupes; + + assert (dict_similar(dict, template)); +} + +/* + * Remove all nodes from the dictionary (without freeing them in any way). + */ + +static void dict_clear(dict_t *dict) +{ + dict->nodecount = 0; + dict->nilnode.left = &dict->nilnode; + dict->nilnode.right = &dict->nilnode; + dict->nilnode.parent = &dict->nilnode; + assert (dict->nilnode.color == dnode_black); +} + +/* + * Verify the integrity of the dictionary structure. This is provided for + * debugging purposes, and should be placed in assert statements. Just because + * this function succeeds doesn't mean that the tree is not corrupt. Certain + * corruptions in the tree may simply cause undefined behavior. + */ + +int dict_verify(dict_t *dict) +{ + dnode_t *nil = dict_nil(dict), *root = dict_root(dict); + + /* check that the sentinel node and root node are black */ + if (root->color != dnode_black) + return 0; + if (nil->color != dnode_black) + return 0; + if (nil->right != nil) + return 0; + /* nil->left is the root node; check that its parent pointer is nil */ + if (nil->left->parent != nil) + return 0; + /* perform a weak test that the tree is a binary search tree */ + if (!verify_bintree(dict)) + return 0; + /* verify that the tree is a red-black tree */ + if (!verify_redblack(nil, root)) + return 0; + if (verify_node_count(nil, root) != dict_count(dict)) + return 0; + return 1; +} + +/* + * Determine whether two dictionaries are similar: have the same comparison and + * allocator functions, and same status as to whether duplicates are allowed. + */ + +int dict_similar(const dict_t *left, const dict_t *right) +{ + if (left->compare != right->compare) + return 0; + + if (left->allocnode != right->allocnode) + return 0; + + if (left->freenode != right->freenode) + return 0; + + if (left->context != right->context) + return 0; + +/* if (left->dupes != right->dupes) */ +/* return 0; */ + + return 1; +} + +/* + * Locate a node in the dictionary having the given key. + * If the node is not found, a null a pointer is returned (rather than + * a pointer that dictionary's nil sentinel node), otherwise a pointer to the + * located node is returned. + */ + +dnode_t *dict_lookup(dict_t *dict, const void *key) +{ + dnode_t *root = dict_root(dict); + dnode_t *nil = dict_nil(dict); + dnode_t *saved; + int result; + + /* simple binary search adapted for trees that contain duplicate keys */ + + while (root != nil) { + result = COMPARE(dict, key, root->key); + if (result < 0) + root = root->left; + else if (result > 0) + root = root->right; + else { + if (!dict->dupes) { /* no duplicates, return match */ + return root; + } else { /* could be dupes, find leftmost one */ + do { + saved = root; + root = root->left; + while (root != nil && COMPARE(dict, key, root->key)) + root = root->right; + } while (root != nil); + return saved; + } + } + } + + return NULL; +} + +/* + * Look for the node corresponding to the lowest key that is equal to or + * greater than the given key. If there is no such node, return null. + */ + +dnode_t *dict_lower_bound(dict_t *dict, const void *key) +{ + dnode_t *root = dict_root(dict); + dnode_t *nil = dict_nil(dict); + dnode_t *tentative = 0; + + while (root != nil) { + int result = COMPARE(dict, key, root->key); + + if (result > 0) { + root = root->right; + } else if (result < 0) { + tentative = root; + root = root->left; + } else { + if (!dict->dupes) { + return root; + } else { + tentative = root; + root = root->left; + } + } + } + + return tentative; +} + +/* + * Look for the node corresponding to the greatest key that is equal to or + * lower than the given key. If there is no such node, return null. + */ + +dnode_t *dict_upper_bound(dict_t *dict, const void *key) +{ + dnode_t *root = dict_root(dict); + dnode_t *nil = dict_nil(dict); + dnode_t *tentative = 0; + + while (root != nil) { + int result = COMPARE(dict, key, root->key); + + if (result < 0) { + root = root->left; + } else if (result > 0) { + tentative = root; + root = root->right; + } else { + if (!dict->dupes) { + return root; + } else { + tentative = root; + root = root->right; + } + } + } + + return tentative; +} + +/* + * Insert a node into the dictionary. The node should have been + * initialized with a data field. All other fields are ignored. + * The behavior is undefined if the user attempts to insert into + * a dictionary that is already full (for which the dict_isfull() + * function returns true). + */ + +int dict_insert(dict_t *dict, dnode_t *node, const void *key) +{ + dnode_t *where = dict_root(dict), *nil = dict_nil(dict); + dnode_t *parent = nil, *uncle, *grandpa; + int result = -1; + + node->key = key; + + assert (!dict_isfull(dict)); + assert (!dict_contains(dict, node)); + assert (!dnode_is_in_a_dict(node)); + + /* basic binary tree insert */ + + while (where != nil) { + parent = where; + result = COMPARE(dict, key, where->key); + /* trap attempts at duplicate key insertion unless it's explicitly allowed */ + + if (!dict->dupes && result == 0) { + where->data = node->data; + return 0; + } else if (result < 0) { + where = where->left; + } else { + where = where->right; + } + } + + assert (where == nil); + + if (result < 0) + parent->left = node; + else + parent->right = node; + + node->parent = parent; + node->left = nil; + node->right = nil; + + dict->nodecount++; + + /* red black adjustments */ + + node->color = dnode_red; + + while (parent->color == dnode_red) { + grandpa = parent->parent; + if (parent == grandpa->left) { + uncle = grandpa->right; + if (uncle->color == dnode_red) { /* red parent, red uncle */ + parent->color = dnode_black; + uncle->color = dnode_black; + grandpa->color = dnode_red; + node = grandpa; + parent = grandpa->parent; + } else { /* red parent, black uncle */ + if (node == parent->right) { + rotate_left(parent); + parent = node; + assert (grandpa == parent->parent); + /* rotation between parent and child preserves grandpa */ + } + parent->color = dnode_black; + grandpa->color = dnode_red; + rotate_right(grandpa); + break; + } + } else { /* symmetric cases: parent == parent->parent->right */ + uncle = grandpa->left; + if (uncle->color == dnode_red) { + parent->color = dnode_black; + uncle->color = dnode_black; + grandpa->color = dnode_red; + node = grandpa; + parent = grandpa->parent; + } else { + if (node == parent->left) { + rotate_right(parent); + parent = node; + assert (grandpa == parent->parent); + } + parent->color = dnode_black; + grandpa->color = dnode_red; + rotate_left(grandpa); + break; + } + } + } + + dict_root(dict)->color = dnode_black; + + assert (dict_verify(dict)); + return 1; +} + +/* + * Delete the given node from the dictionary. If the given node does not belong + * to the given dictionary, undefined behavior results. A pointer to the + * deleted node is returned. + */ + +dnode_t *dict_delete(dict_t *dict, dnode_t *delete) +{ + dnode_t *nil = dict_nil(dict), *child, *delparent = delete->parent; + + /* basic deletion */ + + assert (!dict_isempty(dict)); + assert (dict_contains(dict, delete)); + + /* + * If the node being deleted has two children, then we replace it with its + * successor (i.e. the leftmost node in the right subtree.) By doing this, + * we avoid the traditional algorithm under which the successor's key and + * value *only* move to the deleted node and the successor is spliced out + * from the tree. We cannot use this approach because the user may hold + * pointers to the successor, or nodes may be inextricably tied to some + * other structures by way of embedding, etc. So we must splice out the + * node we are given, not some other node, and must not move contents from + * one node to another behind the user's back. + */ + + if (delete->left != nil && delete->right != nil) { + dnode_t *next = dict_next(dict, delete); + dnode_t *nextparent = next->parent; + dnode_color_t nextcolor = next->color; + + assert (next != nil); + assert (next->parent != nil); + assert (next->left == nil); + + /* + * First, splice out the successor from the tree completely, by + * moving up its right child into its place. + */ + + child = next->right; + child->parent = nextparent; + + if (nextparent->left == next) { + nextparent->left = child; + } else { + assert (nextparent->right == next); + nextparent->right = child; + } + + /* + * Now that the successor has been extricated from the tree, install it + * in place of the node that we want deleted. + */ + + next->parent = delparent; + next->left = delete->left; + next->right = delete->right; + next->left->parent = next; + next->right->parent = next; + next->color = delete->color; + delete->color = nextcolor; + + if (delparent->left == delete) { + delparent->left = next; + } else { + assert (delparent->right == delete); + delparent->right = next; + } + + } else { + assert (delete != nil); + assert (delete->left == nil || delete->right == nil); + + child = (delete->left != nil) ? delete->left : delete->right; + + child->parent = delparent = delete->parent; + + if (delete == delparent->left) { + delparent->left = child; + } else { + assert (delete == delparent->right); + delparent->right = child; + } + } + + delete->parent = NULL; + delete->right = NULL; + delete->left = NULL; + + dict->nodecount--; + + assert (verify_bintree(dict)); + + /* red-black adjustments */ + + if (delete->color == dnode_black) { + dnode_t *parent, *sister; + + dict_root(dict)->color = dnode_red; + + while (child->color == dnode_black) { + parent = child->parent; + if (child == parent->left) { + sister = parent->right; + assert (sister != nil); + if (sister->color == dnode_red) { + sister->color = dnode_black; + parent->color = dnode_red; + rotate_left(parent); + sister = parent->right; + assert (sister != nil); + } + if (sister->left->color == dnode_black + && sister->right->color == dnode_black) { + sister->color = dnode_red; + child = parent; + } else { + if (sister->right->color == dnode_black) { + assert (sister->left->color == dnode_red); + sister->left->color = dnode_black; + sister->color = dnode_red; + rotate_right(sister); + sister = parent->right; + assert (sister != nil); + } + sister->color = parent->color; + sister->right->color = dnode_black; + parent->color = dnode_black; + rotate_left(parent); + break; + } + } else { /* symmetric case: child == child->parent->right */ + assert (child == parent->right); + sister = parent->left; + assert (sister != nil); + if (sister->color == dnode_red) { + sister->color = dnode_black; + parent->color = dnode_red; + rotate_right(parent); + sister = parent->left; + assert (sister != nil); + } + if (sister->right->color == dnode_black + && sister->left->color == dnode_black) { + sister->color = dnode_red; + child = parent; + } else { + if (sister->left->color == dnode_black) { + assert (sister->right->color == dnode_red); + sister->right->color = dnode_black; + sister->color = dnode_red; + rotate_left(sister); + sister = parent->left; + assert (sister != nil); + } + sister->color = parent->color; + sister->left->color = dnode_black; + parent->color = dnode_black; + rotate_right(parent); + break; + } + } + } + + child->color = dnode_black; + dict_root(dict)->color = dnode_black; + } + + assert (dict_verify(dict)); + + return delete; +} + +/* + * Allocate a node using the dictionary's allocator routine, give it + * the data item. + */ + +int dict_alloc_insert(dict_t *dict, const void *key, void *data) +{ + dnode_t *node = dict->allocnode(dict->context); + + if (node) { + dnode_init(node, data); + if (!dict_insert(dict, node, key)) + dict->freenode(node, dict->context); + return 1; + } + return 0; +} + +void dict_delete_free(dict_t *dict, dnode_t *node) +{ + dict_delete(dict, node); + dict->freenode(node, dict->context); +} + +/* + * Return the node with the lowest (leftmost) key. If the dictionary is empty + * (that is, dict_isempty(dict) returns 1) a null pointer is returned. + */ + +dnode_t *dict_first(dict_t *dict) +{ + dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left; + + if (root != nil) + while ((left = root->left) != nil) + root = left; + + return (root == nil) ? NULL : root; +} + +/* + * Return the node with the highest (rightmost) key. If the dictionary is empty + * (that is, dict_isempty(dict) returns 1) a null pointer is returned. + */ + +dnode_t *dict_last(dict_t *dict) +{ + dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *right; + + if (root != nil) + while ((right = root->right) != nil) + root = right; + + return (root == nil) ? NULL : root; +} + +/* + * Return the given node's successor node---the node which has the + * next key in the the left to right ordering. If the node has + * no successor, a null pointer is returned rather than a pointer to + * the nil node. + */ + +dnode_t *dict_next(dict_t *dict, dnode_t *curr) +{ + dnode_t *nil = dict_nil(dict), *parent, *left; + + if (curr->right != nil) { + curr = curr->right; + while ((left = curr->left) != nil) + curr = left; + return curr; + } + + parent = curr->parent; + + while (parent != nil && curr == parent->right) { + curr = parent; + parent = curr->parent; + } + + return (parent == nil) ? NULL : parent; +} + +/* + * Return the given node's predecessor, in the key order. + * The nil sentinel node is returned if there is no predecessor. + */ + +dnode_t *dict_prev(dict_t *dict, dnode_t *curr) +{ + dnode_t *nil = dict_nil(dict), *parent, *right; + + if (curr->left != nil) { + curr = curr->left; + while ((right = curr->right) != nil) + curr = right; + return curr; + } + + parent = curr->parent; + + while (parent != nil && curr == parent->left) { + curr = parent; + parent = curr->parent; + } + + return (parent == nil) ? NULL : parent; +} + +void dict_allow_dupes(dict_t *dict) +{ + dict->dupes = 1; +} + +dictcount_t dict_count(dict_t *dict) +{ + return dict->nodecount; +} + +int dict_isempty(dict_t *dict) +{ + return dict->nodecount == 0; +} + +int dict_isfull(dict_t *dict) +{ + return dict->nodecount == DICTCOUNT_T_MAX; +} + +int dict_contains(dict_t *dict, dnode_t *node) +{ + return verify_dict_has_node(dict_nil(dict), dict_root(dict), node); +} + +static dnode_t *dnode_alloc(void *context) +{ + return malloc(sizeof *dnode_alloc(NULL)); +} + +static void dnode_free(dnode_t *node, void *context) +{ + free(node); +} + +dnode_t *dnode_create(void *data) +{ + dnode_t *new = malloc(sizeof *new); + if (new) { + new->data = data; + new->parent = NULL; + new->left = NULL; + new->right = NULL; + } + return new; +} + +dnode_t *dnode_init(dnode_t *dnode, void *data) +{ + dnode->data = data; + dnode->parent = NULL; + dnode->left = NULL; + dnode->right = NULL; + return dnode; +} + +void dnode_destroy(dnode_t *dnode) +{ + assert (!dnode_is_in_a_dict(dnode)); + free(dnode); +} + +void *dnode_get(dnode_t *dnode) +{ + return dnode->data; +} + +const void *dnode_getkey(dnode_t *dnode) +{ + return dnode->key; +} + +void dnode_put(dnode_t *dnode, void *data) +{ + dnode->data = data; +} + +int dnode_is_in_a_dict(dnode_t *dnode) +{ + return (dnode->parent && dnode->left && dnode->right); +} + +void dict_process(dict_t *dict, void *context, dnode_process_t function) +{ + dnode_t *node = dict_first(dict), *next; + + while (node != NULL) { + /* check for callback function deleting */ + /* the next node from under us */ + assert (dict_contains(dict, node)); + next = dict_next(dict, node); + function(dict, node, context); + node = next; + } +} + +static void load_begin_internal(dict_load_t *load, dict_t *dict) +{ + load->dictptr = dict; + load->nilnode.left = &load->nilnode; + load->nilnode.right = &load->nilnode; +} + +void dict_load_begin(dict_load_t *load, dict_t *dict) +{ + assert (dict_isempty(dict)); + load_begin_internal(load, dict); +} + +void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key) +{ + dict_t *dict = load->dictptr; + dnode_t *nil = &load->nilnode; + + assert (!dnode_is_in_a_dict(newnode)); + assert (dict->nodecount < DICTCOUNT_T_MAX); + + #ifndef NDEBUG + if (dict->nodecount > 0) { + if (dict->dupes) + assert (COMPARE(dict, nil->left->key, key) <= 0); + else + assert (COMPARE(dict, nil->left->key, key) < 0); + } + #endif + + newnode->key = key; + nil->right->left = newnode; + nil->right = newnode; + newnode->left = nil; + dict->nodecount++; +} + +void dict_load_end(dict_load_t *load) +{ + dict_t *dict = load->dictptr; + dnode_t *tree[DICT_DEPTH_MAX] = { 0 }; + dnode_t *curr, *dictnil = dict_nil(dict), *loadnil = &load->nilnode, *next; + dnode_t *complete = 0; + dictcount_t fullcount = DICTCOUNT_T_MAX, nodecount = dict->nodecount; + dictcount_t botrowcount; + unsigned baselevel = 0, level = 0, i; + + assert (dnode_red == 0 && dnode_black == 1); + + while (fullcount >= nodecount && fullcount) + fullcount >>= 1; + + botrowcount = nodecount - fullcount; + + for (curr = loadnil->left; curr != loadnil; curr = next) { + next = curr->left; + + if (complete == NULL && botrowcount-- == 0) { + assert (baselevel == 0); + assert (level == 0); + baselevel = level = 1; + complete = tree[0]; + + if (complete != 0) { + tree[0] = 0; + complete->right = dictnil; + while (tree[level] != 0) { + tree[level]->right = complete; + complete->parent = tree[level]; + complete = tree[level]; + tree[level++] = 0; + } + } + } + + if (complete == NULL) { + curr->left = dictnil; + curr->right = dictnil; + curr->color = level % 2; + complete = curr; + + assert (level == baselevel); + while (tree[level] != 0) { + tree[level]->right = complete; + complete->parent = tree[level]; + complete = tree[level]; + tree[level++] = 0; + } + } else { + curr->left = complete; + curr->color = (level + 1) % 2; + complete->parent = curr; + tree[level] = curr; + complete = 0; + level = baselevel; + } + } + + if (complete == NULL) + complete = dictnil; + + for (i = 0; i < DICT_DEPTH_MAX; i++) { + if (tree[i] != 0) { + tree[i]->right = complete; + complete->parent = tree[i]; + complete = tree[i]; + } + } + + dictnil->color = dnode_black; + dictnil->right = dictnil; + complete->parent = dictnil; + complete->color = dnode_black; + dict_root(dict) = complete; + + assert (dict_verify(dict)); +} + +void dict_merge(dict_t *dest, dict_t *source) +{ + dict_load_t load; + dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source); + + assert (dict_similar(dest, source)); + + if (source == dest) + return; + + dest->nodecount = 0; + load_begin_internal(&load, dest); + + for (;;) { + if (leftnode != NULL && rightnode != NULL) { + if (COMPARE(dest, leftnode->key, rightnode->key) < 0) + goto copyleft; + else + goto copyright; + } else if (leftnode != NULL) { + goto copyleft; + } else if (rightnode != NULL) { + goto copyright; + } else { + assert (leftnode == NULL && rightnode == NULL); + break; + } + + copyleft: + { + dnode_t *next = dict_next(dest, leftnode); + #ifndef NDEBUG + leftnode->left = NULL; /* suppress assertion in dict_load_next */ + #endif + dict_load_next(&load, leftnode, leftnode->key); + leftnode = next; + continue; + } + + copyright: + { + dnode_t *next = dict_next(source, rightnode); + #ifndef NDEBUG + rightnode->left = NULL; + #endif + dict_load_next(&load, rightnode, rightnode->key); + rightnode = next; + continue; + } + } + + dict_clear(source); + dict_load_end(&load); +} + +int dict_equal(dict_t* dict1, dict_t* dict2, + dict_value_eql_t value_eql) +{ + dnode_t* node1; + dnode_t* node2; + + if (dict_count(dict1) != dict_count(dict2)) + return 0; + if (!dict_similar(dict1, dict2)) + return 0; + + for (node1 = dict_first(dict1), node2 = dict_first(dict2); + node1 != NULL && node2 != NULL; + node1 = dict_next(dict1, node1), node2 = dict_next(dict2, node2)) { + + if (COMPARE(dict1, node1->key, node2->key) != 0) + return 0; + if (!value_eql(node1->data, node2->data)) + return 0; + } + return 1; +} Added: trunk/rbtree-0.2.0/ext/dict.h =================================================================== --- trunk/rbtree-0.2.0/ext/dict.h (rev 0) +++ trunk/rbtree-0.2.0/ext/dict.h 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,123 @@ +/* + * Dictionary Abstract Data Type + * Copyright (C) 1997 Kaz Kylheku + * + * Free Software License: + * + * All rights are reserved by the author, with the following exceptions: + * Permission is granted to freely reproduce and distribute this software, + * possibly in exchange for a fee, provided that this copyright notice appears + * intact. Permission is also granted to adapt this software to produce + * derivative works, as long as the modified versions carry this copyright + * notice and additional notices stating that the work has been modified. + * This source code may be translated into executable form and incorporated + * into proprietary software; there is no requirement for such software to + * contain a copyright notice related to this source. + * + * $Id: dict.h,v 1.9 2005/10/06 05:16:35 kuma Exp $ + * $Name: $ + */ + +/* + * Modified for Ruby/RBTree by OZAWA Takuma. + */ + +#ifndef DICT_H +#define DICT_H + +#include + +/* + * Blurb for inclusion into C++ translation units + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long dictcount_t; +#define DICTCOUNT_T_MAX ULONG_MAX + +/* + * The dictionary is implemented as a red-black tree + */ + +typedef enum { dnode_red, dnode_black } dnode_color_t; + +typedef struct dnode_t { + struct dnode_t *dict_left; + struct dnode_t *dict_right; + struct dnode_t *dict_parent; + dnode_color_t dict_color; + const void *dict_key; + void *dict_data; +} dnode_t; + +typedef int (*dict_comp_t)(const void *, const void *, void *); +typedef dnode_t *(*dnode_alloc_t)(void *); +typedef void (*dnode_free_t)(dnode_t *, void *); + +typedef int (*dict_value_eql_t)(const void *, const void *); + +typedef struct dict_t { + dnode_t dict_nilnode; + dictcount_t dict_nodecount; + dict_comp_t dict_compare; + dnode_alloc_t dict_allocnode; + dnode_free_t dict_freenode; + void *dict_context; + int dict_dupes; +} dict_t; + +typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *); + +typedef struct dict_load_t { + dict_t *dict_dictptr; + dnode_t dict_nilnode; +} dict_load_t; + +extern dict_t *dict_create(dict_comp_t); +extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *); +extern void dict_destroy(dict_t *); +extern void dict_free_nodes(dict_t *); +extern void dict_free(dict_t *); +extern dict_t *dict_init(dict_t *, dict_comp_t); +extern void dict_init_like(dict_t *, const dict_t *); +extern int dict_verify(dict_t *); +extern int dict_similar(const dict_t *, const dict_t *); +extern dnode_t *dict_lookup(dict_t *, const void *); +extern dnode_t *dict_lower_bound(dict_t *, const void *); +extern dnode_t *dict_upper_bound(dict_t *, const void *); +extern int dict_insert(dict_t *, dnode_t *, const void *); +extern dnode_t *dict_delete(dict_t *, dnode_t *); +extern int dict_alloc_insert(dict_t *, const void *, void *); +extern void dict_delete_free(dict_t *, dnode_t *); +extern dnode_t *dict_first(dict_t *); +extern dnode_t *dict_last(dict_t *); +extern dnode_t *dict_next(dict_t *, dnode_t *); +extern dnode_t *dict_prev(dict_t *, dnode_t *); +extern dictcount_t dict_count(dict_t *); +extern int dict_isempty(dict_t *); +extern int dict_isfull(dict_t *); +extern int dict_contains(dict_t *, dnode_t *); +extern void dict_allow_dupes(dict_t *); +extern int dnode_is_in_a_dict(dnode_t *); +extern dnode_t *dnode_create(void *); +extern dnode_t *dnode_init(dnode_t *, void *); +extern void dnode_destroy(dnode_t *); +extern void *dnode_get(dnode_t *); +extern const void *dnode_getkey(dnode_t *); +extern void dnode_put(dnode_t *, void *); +extern void dict_process(dict_t *, void *, dnode_process_t); +extern void dict_load_begin(dict_load_t *, dict_t *); +extern void dict_load_next(dict_load_t *, dnode_t *, const void *); +extern void dict_load_end(dict_load_t *); +extern void dict_merge(dict_t *, dict_t *); + +int dict_equal(dict_t*, dict_t*, dict_value_eql_t); + +#ifdef __cplusplus +} +#endif + +#endif Added: trunk/rbtree-0.2.0/ext/extconf.rb =================================================================== --- trunk/rbtree-0.2.0/ext/extconf.rb (rev 0) +++ trunk/rbtree-0.2.0/ext/extconf.rb 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,38 @@ +require 'mkmf' + +def print(*args) + STDOUT.print *args + STDOUT.flush +end + + +$CFLAGS << ' -std=c89 -pedantic -Wall -Wno-long-long' +$defs << ' -DNDEBUG' + + +print 'checking for allocation framework... ' +if Object.respond_to?(:allocate) + print "yes\n" + $defs << '-DHAVE_OBJECT_ALLOCATE' +else + print "no\n" +end + +have_func('rb_obj_init_copy') +have_func('rb_block_proc') +have_func('rb_yield_values') +have_func('rb_marshal_dump') +have_func('rb_marshal_load') + +print 'checking for inline keyword... ' +inline = ['inline', '__inline', '__inline__', ''].find {|e| + try_link(< -#include -#include -#include -#include "dict.h" - -#define RBTREE_IN_ITERATION FL_USER1 -#define RBTREE_PROC_DEFAULT FL_USER2 -#define HASH_PROC_DEFAULT FL_USER2 - -#ifndef ULONG2NUM -#define ULONG2NUM UINT2NUM -#endif - -VALUE RBTree; -VALUE MultiRBTree; - -static ID id_bound; -static ID id_cmp; -static ID id_call; -static ID id_default; - -#ifndef HAVE_RB_MARSHAL_DUMP -static VALUE rb_mMarshal; -static ID id_dump; -static ID id_load; -#endif - -typedef struct { - dict_t* dict; - VALUE ifnone; - int iter_lev; -} rbtree_t; - -#define RBTREE(rbtree) DATA_PTR(rbtree) -#define DICT(rbtree) ((rbtree_t*)RBTREE(rbtree))->dict -#define IFNONE(rbtree) ((rbtree_t*)RBTREE(rbtree))->ifnone -#define ITER_LEV(rbtree) ((rbtree_t*)RBTREE(rbtree))->iter_lev -#define COMPARE(rbtree) DICT(rbtree)->dict_compare -#define CONTEXT(rbtree) DICT(rbtree)->dict_context - -#define TO_KEY(arg) ((const void*)arg) -#define TO_VAL(arg) ((void*)arg) -#define GET_KEY(dnode) ((VALUE)dnode_getkey(dnode)) -#define GET_VAL(dnode) ((VALUE)dnode_get(dnode)) -#define ASSOC(dnode) rb_assoc_new(GET_KEY(dnode), GET_VAL(dnode)) - -/*********************************************************************/ - -#ifndef HAVE_RB_BLOCK_PROC -static VALUE -rb_block_proc() -{ - return rb_f_lambda(); -} -#endif - -#ifndef HAVE_RB_YIELD_VALUES -static VALUE -rb_yield_values(int n, ...) -{ - int i; - va_list ap; - VALUE ary = rb_ary_new2(n); - - va_start(ap, n); - for (i = 0; i < n; i++) - rb_ary_push(ary, va_arg(ap, VALUE)); - va_end(ap); - return rb_yield(ary); -} -#endif - -static int -cmpint(VALUE i, VALUE a, VALUE b) -{ -#if RUBY_VERSION_CODE >= 180 - return rb_cmpint(i, a, b); -#else - return rb_cmpint(i); -#endif -} - - -static void -rbtree_free(rbtree_t* rbtree) -{ - dict_free_nodes(rbtree->dict); - dict_destroy(rbtree->dict); - xfree(rbtree); -} - -static void -rbtree_mark(rbtree_t* rbtree) -{ - if (rbtree == NULL) return; - - if (rbtree->dict != NULL) { - dict_t* dict = rbtree->dict; - dnode_t* node; - for (node = dict_first(dict); - node != NULL; - node = dict_next(dict, node)) { - - rb_gc_mark(GET_KEY(node)); - rb_gc_mark(GET_VAL(node)); - } - rb_gc_mark((VALUE)dict->dict_context); - } - rb_gc_mark(rbtree->ifnone); -} - -static dnode_t* -rbtree_alloc_node(void* context) -{ - return ALLOC(dnode_t); -} - -static void -rbtree_free_node(dnode_t* node, void* context) -{ - xfree(node); -} - -static void -rbtree_argc_error() -{ - rb_raise(rb_eArgError, "wrong number of arguments"); -} - -static int -rbtree_cmp(const void* key1, const void* key2, void* context) -{ - VALUE ret; - if (TYPE(key1) == T_STRING && TYPE(key2) == T_STRING) - return rb_str_cmp((VALUE)key1, (VALUE)key2); - ret = rb_funcall((VALUE)key1, id_cmp, 1, (VALUE)key2); - return cmpint(ret, (VALUE)key1, (VALUE)key2); -} - -static int -rbtree_user_cmp(const void* key1, const void* key2, void* cmp_proc) -{ - VALUE ret = rb_funcall((VALUE)cmp_proc, id_call, 2, - (VALUE)key1, (VALUE)key2); - return cmpint(ret, (VALUE)key1, (VALUE)key2); -} - -static void -rbtree_modify(VALUE self) -{ - if (ITER_LEV(self) > 0) - rb_raise(rb_eTypeError, "can't modify rbtree in iteration"); - if (OBJ_FROZEN(self)) - rb_error_frozen("rbtree"); - if (!OBJ_TAINTED(self) && rb_safe_level() >= 4) - rb_raise(rb_eSecurityError, "Insecure: can't modify rbtree"); -} - -static VALUE -rbtree_alloc(VALUE klass) -{ - dict_t* dict; - VALUE rbtree = Data_Wrap_Struct(klass, rbtree_mark, rbtree_free, 0); - RBTREE(rbtree) = ALLOC(rbtree_t); - MEMZERO(RBTREE(rbtree), rbtree_t, 1); - - dict = dict_create(rbtree_cmp); - dict_set_allocator(dict, rbtree_alloc_node, rbtree_free_node, - (void*)Qnil); - if (klass == MultiRBTree) - dict_allow_dupes(dict); - - DICT(rbtree) = dict; - IFNONE(rbtree) = Qnil; - return rbtree; -} - -VALUE rbtree_aset(VALUE, VALUE, VALUE); -VALUE rbtree_clear(VALUE); -VALUE rbtree_has_key(VALUE, VALUE); -VALUE rbtree_update(VALUE, VALUE); - -/*********************************************************************/ - -#ifndef HAVE_OBJECT_ALLOCATE -/* - * - */ -VALUE -rbtree_s_new(int argc, VALUE* argv, VALUE klass) -{ - VALUE rbtree = rbtree_alloc(klass); - rb_obj_call_init(rbtree, argc, argv); - return rbtree; -} -#endif - -static int -hash_to_rbtree_i(VALUE key, VALUE value, VALUE rbtree) -{ - if (key != Qundef) - rbtree_aset(rbtree, key, value); - return ST_CONTINUE; -} - -/* - * - */ -VALUE -rbtree_s_create(int argc, VALUE* argv, VALUE klass) -{ - int i; - VALUE rbtree; - - if (argc == 1) { - if (rb_obj_is_kind_of(argv[0], klass)) { - rbtree = rbtree_alloc(klass); - rbtree_update(rbtree, argv[0]); - return rbtree; - } else if (TYPE(argv[0]) == T_HASH) { - rbtree = rbtree_alloc(klass); - st_foreach(RHASH(argv[0])->tbl, hash_to_rbtree_i, rbtree); - return rbtree; - } - } - - if (argc % 2 != 0) - rb_raise(rb_eArgError, "odd number of arguments for RBTree"); - - rbtree = rbtree_alloc(klass); - for (i = 0; i < argc; i += 2) - rbtree_aset(rbtree, argv[i], argv[i + 1]); - return rbtree; -} - -/* - * - */ -VALUE -rbtree_initialize(int argc, VALUE* argv, VALUE self) -{ - rbtree_modify(self); - - if (rb_block_given_p()) { - if (argc > 0) - rbtree_argc_error(); - IFNONE(self) = rb_block_proc(); - FL_SET(self, RBTREE_PROC_DEFAULT); - } else { - if (argc > 1) - rbtree_argc_error(); - else if (argc == 1) - IFNONE(self) = argv[0]; - } - return self; -} - -/*********************************************************************/ - -typedef enum { - INITIAL_VALUE, NODE_NOT_FOUND, NODE_FOUND -} insert_node_ret_t; - -typedef struct { - dict_t* dict; - dnode_t* node; - const void* key; - insert_node_ret_t ret; -} insert_node_t; - -static VALUE -insert_node_body(insert_node_t* arg) -{ - if (dict_insert(arg->dict, arg->node, arg->key)) - arg->ret = NODE_NOT_FOUND; - else - arg->ret = NODE_FOUND; - return Qnil; -} - -static VALUE -insert_node_ensure(insert_node_t* arg) -{ - dict_t* dict = arg->dict; - dnode_t* node = arg->node; - switch (arg->ret) { - case INITIAL_VALUE: - dict->dict_freenode(node, dict->dict_context); - break; - case NODE_NOT_FOUND: - if (TYPE(arg->key) == T_STRING) - node->dict_key = TO_KEY(rb_str_new4(GET_KEY(node))); - break; - case NODE_FOUND: - dict->dict_freenode(node, dict->dict_context); - break; - } - return Qnil; -} - -static void -rbtree_insert(VALUE self, VALUE key, VALUE value) -{ - insert_node_t arg; - dict_t* dict = DICT(self); - dnode_t* node = dict->dict_allocnode(dict->dict_context); - - dnode_init(node, TO_VAL(value)); - - arg.dict = dict; - arg.node = node; - arg.key = TO_KEY(key); - arg.ret = INITIAL_VALUE; - - rb_ensure(insert_node_body, (VALUE)&arg, - insert_node_ensure, (VALUE)&arg); -} - -/*********************************************************************/ - -/* - * - */ -VALUE -rbtree_aset(VALUE self, VALUE key, VALUE value) -{ - rbtree_modify(self); - - if (dict_isfull(DICT(self))) { - dnode_t* node = dict_lookup(DICT(self), TO_KEY(key)); - if (node == NULL) - rb_raise(rb_eIndexError, "rbtree full"); - else - dnode_put(node, TO_VAL(value)); - return value; - } - rbtree_insert(self, key, value); - return value; -} - -/* - * - */ -VALUE -rbtree_aref(VALUE self, VALUE key) -{ - dnode_t* node = dict_lookup(DICT(self), TO_KEY(key)); - if (node == NULL) - return rb_funcall(self, id_default, 1, key); - else - return GET_VAL(node); -} - -/* - * - */ -VALUE -rbtree_fetch(int argc, VALUE* argv, VALUE self) -{ - dnode_t* node; - int block_given; - - if (argc == 0 || argc > 2) - rbtree_argc_error(); - block_given = rb_block_given_p(); - if (block_given && argc == 2) - rb_warn("block supersedes default value argument"); - - node = dict_lookup(DICT(self), TO_KEY(argv[0])); - if (node != NULL) - return GET_VAL(node); - - if (block_given) - return rb_yield(argv[0]); - if (argc == 1) - rb_raise(rb_eIndexError, "key not found"); - return argv[1]; -} - -/* - * - */ -VALUE -rbtree_size(VALUE self) -{ - return ULONG2NUM(dict_count(DICT(self))); -} - -/* - * - */ -VALUE -rbtree_empty_p(VALUE self) -{ - return dict_isempty(DICT(self)) ? Qtrue : Qfalse; -} - -/* - * - */ -VALUE -rbtree_default(int argc, VALUE* argv, VALUE self) -{ - VALUE key = Qnil; - if (argc == 1) - key = argv[0]; - else if (argc > 1) - rbtree_argc_error(); - - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { - if (argc == 0) return Qnil; - return rb_funcall(IFNONE(self), id_call, 2, self, key); - } - return IFNONE(self); -} - -/* - * - */ -VALUE -rbtree_set_default(VALUE self, VALUE ifnone) -{ - rbtree_modify(self); - IFNONE(self) = ifnone; - FL_UNSET(self, RBTREE_PROC_DEFAULT); - return ifnone; -} - -/* - * - */ -VALUE -rbtree_default_proc(VALUE self) -{ - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) - return IFNONE(self); - return Qnil; -} - -static int -value_eq(const void* key1, const void* key2) -{ - return rb_equal((VALUE)key1, (VALUE)key2); -} - -/* - * - */ -VALUE -rbtree_equal(VALUE self, VALUE other) -{ - int ret; - if (self == other) - return Qtrue; - if (!rb_obj_is_kind_of(other, MultiRBTree)) - return Qfalse; - ret = dict_equal(DICT(self), DICT(other), value_eq); - return ret ? Qtrue : Qfalse; -} - -/*********************************************************************/ - -typedef enum { - EACH_NEXT, EACH_STOP -} each_return_t; - -typedef each_return_t (*each_callback_func)(dnode_t*, void*); - -typedef struct { - VALUE self; - each_callback_func func; - void* arg; - int reverse; - void* start; -} rbtree_each_arg_t; - -static VALUE -rbtree_each_ensure(VALUE self) -{ - ITER_LEV(self)--; - return Qnil; -} - -static VALUE -rbtree_each_body(rbtree_each_arg_t* arg) -{ - VALUE self = arg->self; - dict_t* dict = DICT(self); - dnode_t* node; - dnode_t* first_node = NULL; - dnode_t* (*next_func)(dict_t*, dnode_t*); - - if (arg->reverse) { - if (arg->start != NULL) - first_node = dict_upper_bound(dict, TO_KEY(arg->start)); - if (first_node == NULL) - first_node = dict_last(dict); - next_func = dict_prev; - } else { - if (arg->start != NULL) - first_node = dict_lower_bound(dict, TO_KEY(arg->start)); - if (first_node == NULL) - first_node = dict_first(dict); - next_func = dict_next; - } - - ITER_LEV(self)++; - for (node = first_node; - node != NULL; - node = next_func(dict, node)) { - - if (arg->func(node, arg->arg) == EACH_STOP) - break; - } - return self; -} - -static VALUE -rbtree_for_each(VALUE self, each_callback_func func, void* arg, void* start) -{ - rbtree_each_arg_t each_arg; - each_arg.self = self; - each_arg.func = func; - each_arg.arg = arg; - each_arg.reverse = 0; - each_arg.start = start; - return rb_ensure(rbtree_each_body, (VALUE)&each_arg, - rbtree_each_ensure, self); -} - -static VALUE -rbtree_reverse_for_each(VALUE self, each_callback_func func, void* arg, void *start) -{ - rbtree_each_arg_t each_arg; - each_arg.self = self; - each_arg.func = func; - each_arg.arg = arg; - each_arg.reverse = 1; - each_arg.start = start; - return rb_ensure(rbtree_each_body, (VALUE)&each_arg, - rbtree_each_ensure, self); -} - -/*********************************************************************/ - -static each_return_t -each_i(dnode_t* node, void* arg) -{ - rb_yield(ASSOC(node)); - return EACH_NEXT; -} - -/* - * call-seq: - * rbtree.each(start = nil) {|key, value| block} => rbtree - * - * Calls block once for each key in order, passing the key and value - * as a two-element array parameters. Starts at +start+ if given. - */ -VALUE -rbtree_each(int argc, VALUE *argv, VALUE self) -{ - if (argc > 1) - rbtree_argc_error(); - - if (argc == 0) - return rbtree_for_each(self, each_i, NULL, NULL); - else if (argc == 1) - return rbtree_for_each(self, each_i, NULL, argv[0]); -} - -static each_return_t -each_pair_i(dnode_t* node, void* arg) -{ - rb_yield_values(2, GET_KEY(node), GET_VAL(node)); - return EACH_NEXT; -} - -/* - * call-seq: - * rbtree.each_pair {|key, value| block} => rbtree - * - * Calls block once for each key in order, passing the key and value - * as parameters. - */ -VALUE -rbtree_each_pair(VALUE self) -{ - return rbtree_for_each(self, each_pair_i, NULL, NULL); -} - -static each_return_t -each_key_i(dnode_t* node, void* arg) -{ - rb_yield(GET_KEY(node)); - return EACH_NEXT; -} - -/* - * call-seq: - * rbtree.each_key {|key| block} => rbtree - * - * Calls block once for each key in order, passing the key as - * parameters. - */ -VALUE -rbtree_each_key(VALUE self) -{ - return rbtree_for_each(self, each_key_i, NULL, NULL); -} - -static each_return_t -each_value_i(dnode_t* node, void* arg) -{ - rb_yield(GET_VAL(node)); - return EACH_NEXT; -} - -/* - * call-seq: - * rbtree.each_value {|value| block} => rbtree - * - * Calls block once for each key in order, passing the value as - * parameters. - */ -VALUE -rbtree_each_value(VALUE self) -{ - return rbtree_for_each(self, each_value_i, NULL, NULL); -} - -/* - * call-seq: - * rbtree.reverse_each(start = nil) {|key, value| block} => rbtree - * - * Calls block once for each key in reverse order, passing the key and - * value as parameters. Starts at +start+ if given. - */ -VALUE -rbtree_reverse_each(int argc, VALUE *argv, VALUE self) -{ - if (argc > 1) - rbtree_argc_error(); - - if (argc == 0) - return rbtree_reverse_for_each(self, each_i, NULL, NULL); - else if (argc == 1) - return rbtree_reverse_for_each(self, each_i, NULL, argv[0]); -} - -static each_return_t -aset_i(dnode_t* node, void* self) -{ - rbtree_aset((VALUE)self, GET_KEY(node), GET_VAL(node)); - return EACH_NEXT; -} - -static void -copy_dict(VALUE src, VALUE dest, dict_comp_t cmp, void* context) -{ - VALUE temp = rbtree_alloc(CLASS_OF(dest)); - COMPARE(temp) = cmp; - CONTEXT(temp) = context; - rbtree_for_each(src, aset_i, (void*)temp, NULL); - { - dict_t* t = DICT(temp); - DICT(temp) = DICT(dest); - DICT(dest) = t; - } - rbtree_free(RBTREE(temp)); - rb_gc_force_recycle(temp); -} - -/* - * - */ -VALUE -rbtree_initialize_copy(VALUE self, VALUE other) -{ - if (self == other) - return self; - if (!rb_obj_is_kind_of(other, CLASS_OF(self))) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)", - rb_class2name(CLASS_OF(other)), - rb_class2name(CLASS_OF(self))); - } - - copy_dict(other, self, COMPARE(other), CONTEXT(other)); - - IFNONE(self) = IFNONE(other); - if (FL_TEST(other, RBTREE_PROC_DEFAULT)) - FL_SET(self, RBTREE_PROC_DEFAULT); - else - FL_UNSET(self, RBTREE_PROC_DEFAULT); - return self; -} - -#ifndef HAVE_RB_OBJ_INIT_COPY -/* - * - */ -VALUE -rbtree_clone(VALUE self) -{ - VALUE clone = rbtree_alloc(CLASS_OF(self)); - rbtree_initialize_copy(clone, self); - return clone; -} -#endif - -/* - * - */ -VALUE -rbtree_values_at(int argc, VALUE* argv, VALUE self) -{ - int i; - VALUE ary = rb_ary_new(); - - for (i = 0; i < argc; i++) - rb_ary_push(ary, rbtree_aref(self, argv[i])); - return ary; -} - -static each_return_t -select_i(dnode_t* node, void* ary) -{ - if (RTEST(rb_yield_values(2, GET_KEY(node), GET_VAL(node)))) - rb_ary_push((VALUE)ary, ASSOC(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_select(VALUE self) -{ - VALUE ary = rb_ary_new(); - rbtree_for_each(self, select_i, (void*)ary, NULL); - return ary; -} - -static each_return_t -index_i(dnode_t* node, void* arg_) -{ - VALUE* arg = (VALUE*)arg_; - if (rb_equal(GET_VAL(node), arg[1])) { - arg[0] = GET_KEY(node); - return EACH_STOP; - } - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_index(VALUE self, VALUE value) -{ - VALUE arg[2]; - arg[0] = Qnil; - arg[1] = value; - rbtree_for_each(self, index_i, (void*)&arg, NULL); - return arg[0]; -} - -/* - * - */ -VALUE -rbtree_clear(VALUE self) -{ - rbtree_modify(self); - dict_free_nodes(DICT(self)); - return self; -} - -/* - * - */ -VALUE -rbtree_delete(VALUE self, VALUE key) -{ - dict_t* dict = DICT(self); - dnode_t* node; - VALUE value; - - rbtree_modify(self); - node = dict_lookup(dict, TO_KEY(key)); - if (node == NULL) - return rb_block_given_p() ? rb_yield(key) : Qnil; - value = GET_VAL(node); - dict_delete_free(dict, node); - return value; -} - -/*********************************************************************/ - -typedef struct dnode_list_t_ { - struct dnode_list_t_* prev; - dnode_t* node; -} dnode_list_t; - -typedef struct { - VALUE self; - dnode_list_t* list; - int raised; -} rbtree_delete_if_arg_t; - -static VALUE -rbtree_delete_if_ensure(rbtree_delete_if_arg_t* arg) -{ - dict_t* dict = DICT(arg->self); - dnode_list_t* list = arg->list; - - if (--ITER_LEV(arg->self) == 0) { - while (list != NULL) { - dnode_list_t* l = list; - if (!arg->raised) - dict_delete_free(dict, l->node); - list = l->prev; - xfree(l); - } - } - return Qnil; -} - -static VALUE -rbtree_delete_if_body(rbtree_delete_if_arg_t* arg) -{ - VALUE self = arg->self; - dict_t* dict = DICT(self); - dnode_t* node; - - arg->raised = 1; - ITER_LEV(self)++; - for (node = dict_first(dict); - node != NULL; - node = dict_next(dict, node)) { - - if (RTEST(rb_yield_values(2, GET_KEY(node), GET_VAL(node)))) { - dnode_list_t* l = ALLOC(dnode_list_t); - l->node = node; - l->prev = arg->list; - arg->list = l; - } - } - arg->raised = 0; - return self; -} - -/*********************************************************************/ - -/* - * - */ -VALUE -rbtree_delete_if(VALUE self) -{ - rbtree_delete_if_arg_t arg; - - rbtree_modify(self); - arg.self = self; - arg.list = NULL; - return rb_ensure(rbtree_delete_if_body, (VALUE)&arg, - rbtree_delete_if_ensure, (VALUE)&arg); -} - -/* - * - */ -VALUE -rbtree_reject_bang(VALUE self) -{ - const dictcount_t count = dict_count(DICT(self)); - rbtree_delete_if(self); - if (count == dict_count(DICT(self))) - return Qnil; - return self; -} - -/* - * - */ -VALUE -rbtree_reject(VALUE self) -{ - return rbtree_reject_bang(rb_obj_dup(self)); -} - -static VALUE -rbtree_shift_pop(VALUE self, const int mode) -{ - dict_t* dict = DICT(self); - dnode_t* node; - VALUE ret; - - rbtree_modify(self); - - if (dict_isempty(dict)) { - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { - return rb_funcall(IFNONE(self), id_call, 2, self, Qnil); - } - return IFNONE(self); - } - - if (mode == 0) - node = dict_first(dict); - else - node = dict_last(dict); - ret = ASSOC(node); - dict_delete_free(dict, node); - return ret; -} - -/* - * call-seq: - * rbtree.shift => array or object - * - * Removes the first(that is, the smallest) key-value pair and returns - * it as a two-item array. - */ -VALUE -rbtree_shift(VALUE self) -{ - return rbtree_shift_pop(self, 0); -} - -/* - * call-seq: - * rbtree.pop => array or object - * - * Removes the last(that is, the biggest) key-value pair and returns - * it as a two-item array. - */ -VALUE -rbtree_pop(VALUE self) -{ - return rbtree_shift_pop(self, 1); -} - -static each_return_t -invert_i(dnode_t* node, void* rbtree) -{ - rbtree_aset((VALUE)rbtree, GET_VAL(node), GET_KEY(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_invert(VALUE self) -{ - VALUE rbtree = rbtree_alloc(CLASS_OF(self)); - rbtree_for_each(self, invert_i, (void*)rbtree, NULL); - return rbtree; -} - -static each_return_t -update_block_i(dnode_t* node, void* self_) -{ - VALUE self = (VALUE)self_; - VALUE key = GET_KEY(node); - VALUE value = GET_VAL(node); - - if (rbtree_has_key(self, key)) - value = rb_yield_values(3, key, rbtree_aref(self, key), value); - rbtree_aset(self, key, value); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_update(VALUE self, VALUE other) -{ - rbtree_modify(self); - - if (self == other) - return self; - if (!rb_obj_is_kind_of(other, CLASS_OF(self))) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)", - rb_class2name(CLASS_OF(other)), - rb_class2name(CLASS_OF(self))); - } - - if (rb_block_given_p()) - rbtree_for_each(other, update_block_i, (void*)self, NULL); - else - rbtree_for_each(other, aset_i, (void*)self, NULL); - return self; -} - -/* - * - */ -VALUE -rbtree_merge(VALUE self, VALUE other) -{ - return rbtree_update(rb_obj_dup(self), other); -} - -/* - * - */ -VALUE -rbtree_has_key(VALUE self, VALUE key) -{ - return dict_lookup(DICT(self), TO_KEY(key)) == NULL ? Qfalse : Qtrue; -} - -static each_return_t -has_value_i(dnode_t* node, void* arg_) -{ - VALUE* arg = (VALUE*)arg_; - if (rb_equal(GET_VAL(node), arg[1])) { - arg[0] = Qtrue; - return EACH_STOP; - } - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_has_value(VALUE self, VALUE value) -{ - VALUE arg[2]; - arg[0] = Qfalse; - arg[1] = value; - rbtree_for_each(self, has_value_i, (void*)&arg, NULL); - return arg[0]; -} - -static each_return_t -keys_i(dnode_t* node, void* ary) -{ - rb_ary_push((VALUE)ary, GET_KEY(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_keys(VALUE self) -{ - VALUE ary = rb_ary_new(); - rbtree_for_each(self, keys_i, (void*)ary, NULL); - return ary; -} - -static each_return_t -values_i(dnode_t* node, void* ary) -{ - rb_ary_push((VALUE)ary, GET_VAL(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_values(VALUE self) -{ - VALUE ret = rb_ary_new(); - rbtree_for_each(self, values_i, (void*)ret, NULL); - return ret; -} - -static each_return_t -to_a_i(dnode_t* node, void* ary) -{ - rb_ary_push((VALUE)ary, ASSOC(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_to_a(VALUE self) -{ - VALUE ary = rb_ary_new(); - rbtree_for_each(self, to_a_i, (void*)ary, NULL); - OBJ_INFECT(ary, self); - return ary; -} - -static each_return_t -to_hash_i(dnode_t* node, void* hash) -{ - st_insert(RHASH(hash)->tbl, GET_KEY(node), GET_VAL(node)); - return EACH_NEXT; -} - -/* - * - */ -VALUE -rbtree_to_hash(VALUE self) -{ - VALUE hash = rb_hash_new(); - rbtree_for_each(self, to_hash_i, (void*)hash, NULL); - RHASH(hash)->ifnone = IFNONE(self); - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) - FL_SET(hash, HASH_PROC_DEFAULT); - OBJ_INFECT(hash, self); - return hash; -} - -/* - * - */ -VALUE -rbtree_to_rbtree(VALUE self) -{ - return self; -} - -static VALUE -rbtree_begin_inspect(VALUE self) -{ - const char* c = rb_class2name(CLASS_OF(self)); - VALUE str = rb_str_new(0, strlen(c) + 5); - const size_t len = sprintf(RSTRING(str)->ptr, "#<%s: ", c); - RSTRING(str)->len = len; - return str; -} - -static VALUE -to_s_rbtree(VALUE self, VALUE nil) -{ - return rb_ary_to_s(rbtree_to_a(self)); -} - -/* - * - */ -VALUE -rbtree_to_s(VALUE self) -{ - if (rb_inspecting_p(self)) - return rb_str_cat2(rbtree_begin_inspect(self), "...>"); - return rb_protect_inspect(to_s_rbtree, self, Qnil); -} - -static each_return_t -inspect_i(dnode_t* node, void* ret_) -{ - VALUE ret = (VALUE)ret_; - VALUE str; - - if (RSTRING(ret)->ptr[0] == '-') - RSTRING(ret)->ptr[0] = '#'; - else - rb_str_cat2(ret, ", "); - - str = rb_inspect(GET_KEY(node)); - rb_str_append(ret, str); - OBJ_INFECT(ret, str); - - rb_str_cat2(ret, "=>"); - - str = rb_inspect(GET_VAL(node)); - rb_str_append(ret, str); - OBJ_INFECT(ret, str); - - return EACH_NEXT; -} - -static VALUE -inspect_rbtree(VALUE self, VALUE ret) -{ - VALUE str; - - rb_str_cat2(ret, "{"); - RSTRING(ret)->ptr[0] = '-'; - rbtree_for_each(self, inspect_i, (void*)ret, NULL); - RSTRING(ret)->ptr[0] = '#'; - rb_str_cat2(ret, "}"); - - str = rb_inspect(IFNONE(self)); - rb_str_cat2(ret, ", default="); - rb_str_append(ret, str); - OBJ_INFECT(ret, str); - - str = rb_inspect((VALUE)CONTEXT(self)); - rb_str_cat2(ret, ", cmp_proc="); - rb_str_append(ret, str); - OBJ_INFECT(ret, str); - - rb_str_cat2(ret, ">"); - OBJ_INFECT(ret, self); - return ret; -} - -/* - * - */ -VALUE -rbtree_inspect(VALUE self) -{ - VALUE str = rbtree_begin_inspect(self); - if (rb_inspecting_p(self)) - return rb_str_cat2(str, "...>"); - return rb_protect_inspect(inspect_rbtree, self, str); -} - -/* - * call-seq: - * rbtree.lower_bound(key) => array - * - * Retruns key-value pair corresponding to the lowest key that is - * equal to or greater than the given key(inside of lower - * boundary). If there is no such key, returns nil. - */ -VALUE -rbtree_lower_bound(VALUE self, VALUE key) -{ - dnode_t* node = dict_lower_bound(DICT(self), TO_KEY(key)); - if (node == NULL) - return Qnil; - return ASSOC(node); -} - -/* - * call-seq: - * rbtree.upper_bound(key) => array - * - * Retruns key-value pair corresponding to the greatest key that is - * equal to or lower than the given key(inside of upper boundary). If - * there is no such key, returns nil. - */ -VALUE -rbtree_upper_bound(VALUE self, VALUE key) -{ - dnode_t* node = dict_upper_bound(DICT(self), TO_KEY(key)); - if (node == NULL) - return Qnil; - return ASSOC(node); -} - -/*********************************************************************/ - -typedef struct { - VALUE self; - dnode_t* lower_node; - dnode_t* upper_node; - VALUE ret; -} rbtree_bound_arg_t; - -static VALUE -rbtree_bound_body(rbtree_bound_arg_t* arg) -{ - VALUE self = arg->self; - dict_t* dict = DICT(self); - dnode_t* lower_node = arg->lower_node; - dnode_t* upper_node = arg->upper_node; - const int block_given = rb_block_given_p(); - VALUE ret = arg->ret; - dnode_t* node; - - ITER_LEV(self)++; - for (node = lower_node;; - node = dict_next(dict, node)) { - - if (block_given) - rb_yield_values(2, GET_KEY(node), GET_VAL(node)); - else - rb_ary_push(ret, ASSOC(node)); - if (node == upper_node) - break; - } - return ret; -} - -/*********************************************************************/ - -/* - * call-seq: - * rbtree.bound(key1, key2 = key1) => array - * rbtree.bound(key1, key2 = key1) {|key, value| block} => rbtree - * - * Returns an array containing key-value pairs between the result of - * RBTree#lower_bound and RBTree#upper_bound. If a block is given it - * calls the block once for each pair. - */ -VALUE -rbtree_bound(int argc, VALUE* argv, VALUE self) -{ - dict_t* dict = DICT(self); - dnode_t* lower_node; - dnode_t* upper_node; - VALUE ret; - - if (argc == 0 || argc > 2) - rbtree_argc_error(); - - lower_node = dict_lower_bound(dict, TO_KEY(argv[0])); - upper_node = dict_upper_bound(dict, TO_KEY(argv[argc - 1])); - ret = rb_block_given_p() ? self : rb_ary_new(); - - if (lower_node == NULL || upper_node == NULL || - COMPARE(self)(dnode_getkey(lower_node), - dnode_getkey(upper_node), - CONTEXT(self)) > 0) { - return ret; - } else { - rbtree_bound_arg_t arg; - arg.self = self; - arg.lower_node = lower_node; - arg.upper_node = upper_node; - arg.ret = ret; - - return rb_ensure(rbtree_bound_body, (VALUE)&arg, - rbtree_each_ensure, self); - } -} - -static VALUE -rbtree_first_last(VALUE self, const int mode) -{ - dict_t* dict = DICT(self); - dnode_t* node; - - if (dict_isempty(dict)) { - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) { - return rb_funcall(IFNONE(self), id_call, 2, self, Qnil); - } - return IFNONE(self); - } - - if (mode == 0) - node = dict_first(dict); - else - node = dict_last(dict); - return ASSOC(node); -} - -/* - * call-seq: - * rbtree.first => array or object - * - * Returns the first(that is, the smallest) key-value pair. - */ -VALUE -rbtree_first(VALUE self) -{ - return rbtree_first_last(self, 0); -} - -/* - * call-seq: - * rbtree.last => array of object - * - * Returns the last(that is, the biggest) key-value pair. - */ -VALUE -rbtree_last(VALUE self) -{ - return rbtree_first_last(self, 1); -} - -/* - * call-seq: - * rbtree.readjust => rbtree - * rbtree.readjust(nil) => rbtree - * rbtree.readjust(proc) => rbtree - * rbtree.readjust {|key1, key2| block} => rbtree - * - * Sets a proc to compare keys and readjusts elements using the given - * block or a Proc object given as the argument. The block takes two - * key arguments and returns negative, 0, or positive depending on the - * first argument is less than, equal to, or greater than the second - * one. If no block is given it just readjusts elements using current - * comparison block. If nil is given as the argument it sets default - * comparison block. - */ -VALUE -rbtree_readjust(int argc, VALUE* argv, VALUE self) -{ - dict_comp_t cmp = NULL; - void* context = NULL; - - rbtree_modify(self); - - if (argc == 0) { - if (rb_block_given_p()) { - cmp = rbtree_user_cmp; - context = (void*)rb_block_proc(); - } else { - cmp = COMPARE(self); - context = CONTEXT(self); - } - } else if (argc == 1 && !rb_block_given_p()) { - if (argv[0] == Qnil) { - cmp = rbtree_cmp; - context = (void*)Qnil; - } else { - if (CLASS_OF(argv[0]) != rb_cProc) - rb_raise(rb_eTypeError, - "wrong argument type %s (expected Proc)", - rb_class2name(CLASS_OF(argv[0]))); - cmp = rbtree_user_cmp; - context = (void*)argv[0]; - } - } else { - rbtree_argc_error(); - } - - if (dict_isempty(DICT(self))) { - COMPARE(self) = cmp; - CONTEXT(self) = context; - return self; - } - copy_dict(self, self, cmp, context); - return self; -} - -/* - * call-seq: - * rbtree.cmp_proc => proc - * - * Returns the comparison block that is given by RBTree#readjust. - */ -VALUE -rbtree_cmp_proc(VALUE self) -{ - return (VALUE)(CONTEXT(self)); -} - -/*********************************************************************/ - -static ID id_comma_breakable; -static ID id_object_group; -static ID id_pp; -static ID id_pp_hash; -static ID id_text; - -typedef struct { - VALUE rbtree; - VALUE pp; -} pp_arg_t; - -static VALUE -pp_object_group(VALUE arg_) -{ - pp_arg_t* arg = (pp_arg_t*)arg_; - return rb_funcall(arg->pp, id_object_group, 1, arg->rbtree); -} - -static VALUE -pp_block(VALUE nil, pp_arg_t* arg) -{ - VALUE pp = arg->pp; - VALUE rbtree = arg->rbtree; - - rb_funcall(pp, id_text, 1, rb_str_new2(": ")); - rb_funcall(pp, id_pp_hash, 1, rbtree); - rb_funcall(pp, id_comma_breakable, 0); - rb_funcall(pp, id_text, 1, rb_str_new2("default=")); - rb_funcall(pp, id_pp, 1, IFNONE(rbtree)); - rb_funcall(pp, id_comma_breakable, 0); - rb_funcall(pp, id_text, 1, rb_str_new2("cmp_proc=")); - rb_funcall(pp, id_pp, 1, CONTEXT(rbtree)); - return pp; -} - -/*********************************************************************/ - -/* - * Called by pretty printing function pp. - */ -VALUE -rbtree_pretty_print(VALUE self, VALUE pp) -{ - pp_arg_t pp_arg; - pp_arg.rbtree = self; - pp_arg.pp = pp; - - return rb_iterate(pp_object_group, (VALUE)&pp_arg, - pp_block, (VALUE)&pp_arg); -} - -/* - * Called by pretty printing function pp. - */ -VALUE -rbtree_pretty_print_cycle(VALUE self, VALUE pp) -{ - return rb_funcall(pp, id_pp, 1, rbtree_inspect(self)); -} - -/*********************************************************************/ - -#ifndef HAVE_RB_MARSHAL_DUMP -static VALUE -rb_marshal_dump(VALUE obj, VALUE port) -{ - return rb_funcall(rb_mMarshal, id_dump, 2, obj, port); -} - -static VALUE -rb_marshal_load(VALUE port) -{ - return rb_funcall(rb_mMarshal, id_load, 1, port); -} -#endif - -static each_return_t -to_flatten_ary_i(dnode_t* node, void* ary) -{ - rb_ary_push((VALUE)ary, GET_KEY(node)); - rb_ary_push((VALUE)ary, GET_VAL(node)); - return EACH_NEXT; -} - -/*********************************************************************/ - -/* - * Called by Marshal.dump. - */ -VALUE -rbtree_dump(VALUE self, VALUE limit) -{ - VALUE ary; - VALUE ret; - - if (FL_TEST(self, RBTREE_PROC_DEFAULT)) - rb_raise(rb_eTypeError, "cannot dump rbtree with default proc"); - if ((VALUE)CONTEXT(self) != Qnil) - rb_raise(rb_eTypeError, "cannot dump rbtree with compare proc"); - - ary = rb_ary_new2(dict_count(DICT(self)) * 2 + 1); - rbtree_for_each(self, to_flatten_ary_i, (void*)ary, NULL); - rb_ary_push(ary, IFNONE(self)); - - ret = rb_marshal_dump(ary, limit); - rb_ary_clear(ary); - rb_gc_force_recycle(ary); - return ret; -} - -/* - * Called by Marshal.load. - */ -VALUE -rbtree_s_load(VALUE klass, VALUE str) -{ - VALUE rbtree = rbtree_alloc(klass); - VALUE ary = rb_marshal_load(str); - VALUE* ptr = RARRAY(ary)->ptr; - long len = RARRAY(ary)->len - 1; - long i; - - for (i = 0; i < len; i += 2) - rbtree_aset(rbtree, ptr[i], ptr[i + 1]); - IFNONE(rbtree) = ptr[len]; - - rb_ary_clear(ary); - rb_gc_force_recycle(ary); - return rbtree; -} - -/*********************************************************************/ - -/* - * Document-class: RBTree - * - * RBTree is a sorted associative collection using Red-Black Tree as - * the internal data structure. The elements of RBTree are ordered and - * the interface is the almost same as Hash, so simply you can - * consider RBTree sorted Hash. - * - * Red-Black Tree is a kind of binary tree that automatically balances - * by itself when a node is inserted or deleted. Thus the complexity - * for insert, search and delete is O(log N) in expected and worst - * case. On the other hand the complexity of Hash is O(1). Because - * Hash is unordered the data structure is more effective than - * Red-Black Tree as an associative collection. - * - * The interface of RBTree is the almost same as Hash although there - * are some limitations. - * - * * While iterating (e.g. in RBTree#each block), RBTree is - * unmodifiable. - * - * * Comparison is done using <=> method of key objects. So all types - * of keys in RBTree should be comparable each other or an arbitrary - * Proc might be set by RBTree#readjust. - * - * RBTree has a few searching methods that Hash doesn't have. They are - * RBTree#lower_bound, RBTree#upper_bound and RBTree#bound. See - * document of each method for details. - * - * Pretty printing is available for RBTree by using pp.rb. The output - * of pp is easier than p to read. Just call Kernel#pp for the object. - * - * MultiRBTree that allows duplicates of keys is also available. - */ -void Init_rbtree() -{ - MultiRBTree = rb_define_class("MultiRBTree", rb_cData); - RBTree = rb_define_class("RBTree", MultiRBTree); - - rb_include_module(MultiRBTree, rb_mEnumerable); - -#ifdef HAVE_OBJECT_ALLOCATE - rb_define_alloc_func(MultiRBTree, rbtree_alloc); -#else - rb_define_singleton_method(MultiRBTree, "new", rbtree_s_new, -1); -#endif - rb_define_singleton_method(MultiRBTree, "[]", rbtree_s_create, -1); - - rb_define_method(MultiRBTree, "initialize", rbtree_initialize, -1); - -#ifdef HAVE_RB_OBJ_INIT_COPY - rb_define_method(MultiRBTree, "initialize_copy", rbtree_initialize_copy, 1); -#else - rb_define_method(MultiRBTree, "clone", rbtree_clone, 0); -#endif - - rb_define_method(MultiRBTree, "to_a", rbtree_to_a, 0); - rb_define_method(MultiRBTree, "to_s", rbtree_to_s, 0); - rb_define_method(MultiRBTree, "to_hash", rbtree_to_hash, 0); - rb_define_method(MultiRBTree, "to_rbtree", rbtree_to_rbtree, 0); - rb_define_method(MultiRBTree, "inspect", rbtree_inspect, 0); - - rb_define_method(MultiRBTree, "==", rbtree_equal, 1); - rb_define_method(MultiRBTree, "[]", rbtree_aref, 1); - rb_define_method(MultiRBTree, "fetch", rbtree_fetch, -1); - rb_define_method(MultiRBTree, "lower_bound", rbtree_lower_bound, 1); - rb_define_method(MultiRBTree, "upper_bound", rbtree_upper_bound, 1); - rb_define_method(MultiRBTree, "bound", rbtree_bound, -1); - rb_define_method(MultiRBTree, "first", rbtree_first, 0); - rb_define_method(MultiRBTree, "last", rbtree_last, 0); - rb_define_method(MultiRBTree, "[]=", rbtree_aset, 2); - rb_define_method(MultiRBTree, "store", rbtree_aset, 2); - rb_define_method(MultiRBTree, "default", rbtree_default, -1); - rb_define_method(MultiRBTree, "default=", rbtree_set_default, 1); - rb_define_method(MultiRBTree, "default_proc", rbtree_default_proc, 0); - rb_define_method(MultiRBTree, "index", rbtree_index, 1); - rb_define_method(MultiRBTree, "empty?", rbtree_empty_p, 0); - rb_define_method(MultiRBTree, "size", rbtree_size, 0); - rb_define_method(MultiRBTree, "length", rbtree_size, 0); - - rb_define_method(MultiRBTree, "each", rbtree_each, -1); - rb_define_method(MultiRBTree, "each_value", rbtree_each_value, 0); - rb_define_method(MultiRBTree, "each_key", rbtree_each_key, 0); - rb_define_method(MultiRBTree, "each_pair", rbtree_each_pair, 0); - rb_define_method(MultiRBTree, "reverse_each", rbtree_reverse_each, -1); - - rb_define_method(MultiRBTree, "keys", rbtree_keys, 0); - rb_define_method(MultiRBTree, "values", rbtree_values, 0); - rb_define_method(MultiRBTree, "values_at", rbtree_values_at, -1); - - rb_define_method(MultiRBTree, "shift", rbtree_shift, 0); - rb_define_method(MultiRBTree, "pop", rbtree_pop, 0); - rb_define_method(MultiRBTree, "delete", rbtree_delete, 1); - rb_define_method(MultiRBTree, "delete_if", rbtree_delete_if, 0); - rb_define_method(MultiRBTree, "select", rbtree_select, 0); - rb_define_method(MultiRBTree, "reject", rbtree_reject, 0); - rb_define_method(MultiRBTree, "reject!", rbtree_reject_bang, 0); - rb_define_method(MultiRBTree, "clear", rbtree_clear, 0); - rb_define_method(MultiRBTree, "invert", rbtree_invert, 0); - rb_define_method(MultiRBTree, "update", rbtree_update, 1); - rb_define_method(MultiRBTree, "merge!", rbtree_update, 1); - rb_define_method(MultiRBTree, "merge", rbtree_merge, 1); - rb_define_method(MultiRBTree, "replace", rbtree_initialize_copy, 1); - - rb_define_method(MultiRBTree, "include?", rbtree_has_key, 1); - rb_define_method(MultiRBTree, "member?", rbtree_has_key, 1); - rb_define_method(MultiRBTree, "has_key?", rbtree_has_key, 1); - rb_define_method(MultiRBTree, "has_value?", rbtree_has_value, 1); - rb_define_method(MultiRBTree, "key?", rbtree_has_key, 1); - rb_define_method(MultiRBTree, "value?", rbtree_has_value, 1); - - rb_define_method(MultiRBTree, "readjust", rbtree_readjust, -1); - rb_define_method(MultiRBTree, "cmp_proc", rbtree_cmp_proc, 0); - - rb_define_method(MultiRBTree, "_dump", rbtree_dump, 1); - rb_define_singleton_method(MultiRBTree, "_load", rbtree_s_load, 1); -#ifndef HAVE_RB_MARSHAL_DUMP - rb_mMarshal = rb_path2class("Marshal"); - id_dump = rb_intern("dump"); - id_load = rb_intern("load"); -#endif - - id_bound = rb_intern("bound"); - id_cmp = rb_intern("<=>"); - id_call = rb_intern("call"); - id_default = rb_intern("default"); - - - rb_define_method(MultiRBTree, "pretty_print", rbtree_pretty_print, 1); - rb_define_method(MultiRBTree, - "pretty_print_cycle", rbtree_pretty_print_cycle, 1); - - id_comma_breakable = rb_intern("comma_breakable"); - id_object_group = rb_intern("object_group"); - id_pp_hash = rb_intern("pp_hash"); - id_text = rb_intern("text"); - id_pp = rb_intern("pp"); -} Deleted: trunk/rbtree-0.2.0/test.rb =================================================================== --- trunk/rbtree-0.2.0/test.rb 2007-05-14 12:29:47 UTC (rev 268) +++ trunk/rbtree-0.2.0/test.rb 2007-05-14 17:00:30 UTC (rev 269) @@ -1,895 +0,0 @@ -require "rbtree" -require "test/unit.rb" - -module Test - module Unit - class TestCase - unless method_defined?(:assert_raise) - alias :assert_raise :assert_raises - end - end - end -end - -class RBTreeTest < Test::Unit::TestCase - def setup - @rbtree = RBTree[*%w(b B d D a A c C)] - end - - def test_new - assert_nothing_raised { - RBTree.new - RBTree.new("a") - RBTree.new { "a" } - } - assert_raise(ArgumentError) { RBTree.new("a") {} } - assert_raise(ArgumentError) { RBTree.new("a", "a") } - end - - def test_aref - assert_equal("A", @rbtree["a"]) - assert_equal("B", @rbtree["b"]) - assert_equal("C", @rbtree["c"]) - assert_equal("D", @rbtree["d"]) - - assert_equal(nil, @rbtree["e"]) - @rbtree.default = "E" - assert_equal("E", @rbtree["e"]) - end - - def test_size - assert_equal(4, @rbtree.size) - end - - def test_create - rbtree = RBTree[] - assert_equal(0, rbtree.size) - - rbtree = RBTree[@rbtree] - assert_equal(4, rbtree.size) - assert_equal("A", @rbtree["a"]) - assert_equal("B", @rbtree["b"]) - assert_equal("C", @rbtree["c"]) - assert_equal("D", @rbtree["d"]) - - rbtree = RBTree[RBTree.new("e")] - assert_equal(nil, rbtree.default) - rbtree = RBTree[RBTree.new { "e" }] - assert_equal(nil, rbtree.default_proc) - @rbtree.readjust {|a,b| b <=> a } - assert_equal(nil, RBTree[@rbtree].cmp_proc) - - assert_raise(ArgumentError) { RBTree["e"] } - - rbtree = RBTree[Hash[*%w(b B d D a A c C)]] - assert_equal(4, rbtree.size) - assert_equal("A", @rbtree["a"]) - assert_equal("B", @rbtree["b"]) - assert_equal("C", @rbtree["c"]) - assert_equal("D", @rbtree["d"]) - end - - def test_clear - @rbtree.clear - assert_equal(0, @rbtree.size) - end - - def test_aset - @rbtree["e"] = "E" - assert_equal(5, @rbtree.size) - assert_equal("E", @rbtree["e"]) - - @rbtree["c"] = "E" - assert_equal(5, @rbtree.size) - assert_equal("E", @rbtree["c"]) - - if VERSION >= "1.8.0" - assert_raise(ArgumentError) { @rbtree[100] = 100 } - assert_equal(5, @rbtree.size) - end - - - key = "f" - @rbtree[key] = "F" - cloned_key = @rbtree.last[0] - assert_equal("f", cloned_key) - assert_not_same(key, cloned_key) - assert_equal(true, cloned_key.frozen?) - - @rbtree["f"] = "F" - assert_same(cloned_key, @rbtree.last[0]) - - rbtree = RBTree.new - key = ["g"] - rbtree[key] = "G" - assert_same(key, rbtree.first[0]) - assert_equal(false, key.frozen?) - end - - def test_clone - clone = @rbtree.clone - assert_equal(4, @rbtree.size) - assert_equal("A", @rbtree["a"]) - assert_equal("B", @rbtree["b"]) - assert_equal("C", @rbtree["c"]) - assert_equal("D", @rbtree["d"]) - - rbtree = RBTree.new("e") - clone = rbtree.clone - assert_equal("e", clone.default) - - rbtree = RBTree.new { "e" } - clone = rbtree.clone - assert_equal("e", clone.default(nil)) - - rbtree = RBTree.new - rbtree.readjust {|a, b| a <=> b } - clone = rbtree.clone - assert_equal(rbtree.cmp_proc, clone.cmp_proc) - end - - def test_default - assert_equal(nil, @rbtree.default) - - rbtree = RBTree.new("e") - assert_equal("e", rbtree.default) - assert_equal("e", rbtree.default("f")) - assert_raise(ArgumentError) { rbtree.default("e", "f") } - - rbtree = RBTree.new {|rbtree, key| @rbtree[key || "c"] } - assert_equal("C", rbtree.default(nil)) - assert_equal("B", rbtree.default("b")) - end - - def test_set_default - rbtree = RBTree.new { "e" } - rbtree.default = "f" - assert_equal("f", rbtree.default) - end - - def test_default_proc - rbtree = RBTree.new("e") - assert_equal(nil, rbtree.default_proc) - - rbtree = RBTree.new { "e" } - assert_equal("e", rbtree.default_proc.call) - end - - def test_equal - assert_equal(RBTree.new, RBTree.new) - assert_equal(@rbtree, @rbtree) - assert_not_equal(@rbtree, RBTree.new) - - rbtree = RBTree[*%w(b B d D a A c C)] - assert_equal(@rbtree, rbtree) - rbtree["d"] = "A" - assert_not_equal(@rbtree, rbtree) - rbtree["d"] = "D" - rbtree["e"] = "E" - assert_not_equal(@rbtree, rbtree) - @rbtree["e"] = "E" - assert_equal(@rbtree, rbtree) - - rbtree.default = "e" - assert_equal(@rbtree, rbtree) - @rbtree.default = "f" - assert_equal(@rbtree, rbtree) - - a = RBTree.new("e") - b = RBTree.new { "f" } - assert_equal(a, b) - assert_equal(b, b.clone) - - a = RBTree.new - b = RBTree.new - a.readjust {|a, b| a <=> b } - assert_not_equal(a, b) - b.readjust(a.cmp_proc) - assert_equal(a, b) - end - - def test_fetch - assert_equal("A", @rbtree.fetch("a")) - assert_equal("B", @rbtree.fetch("b")) - assert_equal("C", @rbtree.fetch("c")) - assert_equal("D", @rbtree.fetch("d")) - - assert_raise(IndexError) { @rbtree.fetch("e") } - - assert_equal("E", @rbtree.fetch("e", "E")) - assert_equal("E", @rbtree.fetch("e") { "E" }) - assert_equal("E", @rbtree.fetch("e", "F") { "E" }) - - assert_raise(ArgumentError) { @rbtree.fetch } - assert_raise(ArgumentError) { @rbtree.fetch("e", "E", "E") } - end - - def test_index - assert_equal("a", @rbtree.index("A")) - assert_equal(nil, @rbtree.index("E")) - end - - def test_empty_p - assert_equal(false, @rbtree.empty?) - @rbtree.clear - assert_equal(true, @rbtree.empty?) - end - - def test_each - ret = [] - @rbtree.each {|key, val| ret << key << val } - assert_equal(%w(a A b B c C d D), ret) - - assert_raise(TypeError) { - @rbtree.each { @rbtree["e"] = "E" } - } - assert_equal(4, @rbtree.size) - - @rbtree.each { - @rbtree.each {} - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - break - } - assert_equal(4, @rbtree.size) - end - - def test_each_pair - ret = [] - @rbtree.each_pair {|key, val| ret << key << val } - assert_equal(%w(a A b B c C d D), ret) - - assert_raise(TypeError) { - @rbtree.each_pair { @rbtree["e"] = "E" } - } - assert_equal(4, @rbtree.size) - - @rbtree.each_pair { - @rbtree.each_pair {} - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - break - } - assert_equal(4, @rbtree.size) - end - - def test_each_key - ret = [] - @rbtree.each_key {|val| ret.push(val) } - assert_equal(%w(a b c d), ret) - - assert_raise(TypeError) { - @rbtree.each_key { @rbtree["e"] = "E" } - } - assert_equal(4, @rbtree.size) - - @rbtree.each_key { - @rbtree.each_key {} - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - break - } - assert_equal(4, @rbtree.size) - end - - def test_each_value - ret = [] - @rbtree.each_value {|key| ret.push(key) } - assert_equal(%w(A B C D), ret) - - assert_raise(TypeError) { - @rbtree.each_value { @rbtree["e"] = "E" } - } - assert_equal(4, @rbtree.size) - - @rbtree.each_value { - @rbtree.each_value {} - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - break - } - assert_equal(4, @rbtree.size) - end - - def test_shift - ret = @rbtree.shift - assert_equal(3, @rbtree.size) - assert_equal(["a", "A"], ret) - assert_equal(nil, @rbtree["a"]) - - 3.times { @rbtree.shift } - assert_equal(0, @rbtree.size) - assert_equal(nil, @rbtree.shift) - @rbtree.default = "e" - assert_equal("e", @rbtree.shift) - - rbtree = RBTree.new { "e" } - assert_equal("e", rbtree.shift) - end - - def test_pop - ret = @rbtree.pop - assert_equal(3, @rbtree.size) - assert_equal(["d", "D"], ret) - assert_equal(nil, @rbtree["d"]) - - 3.times { @rbtree.pop } - assert_equal(0, @rbtree.size) - assert_equal(nil, @rbtree.pop) - @rbtree.default = "e" - assert_equal("e", @rbtree.pop) - - rbtree = RBTree.new { "e" } - assert_equal("e", rbtree.pop) - end - - def test_delete - ret = @rbtree.delete("c") - assert_equal("C", ret) - assert_equal(3, @rbtree.size) - assert_equal(nil, @rbtree["c"]) - - assert_equal(nil, @rbtree.delete("e")) - assert_equal("E", @rbtree.delete("e") { "E" }) - end - - def test_delete_if - @rbtree.delete_if {|key, val| val == "A" || val == "B" } - assert_equal(RBTree[*%w(c C d D)], @rbtree) - - assert_raise(ArgumentError) { - @rbtree.delete_if {|key, val| key == "c" or raise ArgumentError } - } - assert_equal(2, @rbtree.size) - - assert_raise(TypeError) { - @rbtree.delete_if { @rbtree["e"] = "E" } - } - assert_equal(2, @rbtree.size) - - @rbtree.delete_if { - @rbtree.each { - assert_equal(2, @rbtree.size) - } - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - true - } - assert_equal(0, @rbtree.size) - end - - def test_reject_bang - ret = @rbtree.reject! { false } - assert_equal(nil, ret) - assert_equal(4, @rbtree.size) - - ret = @rbtree.reject! {|key, val| val == "A" || val == "B" } - assert_same(@rbtree, ret) - assert_equal(RBTree[*%w(c C d D)], ret) - end - - def test_reject - ret = @rbtree.reject { false } - assert_equal(nil, ret) - assert_equal(4, @rbtree.size) - - ret = @rbtree.reject {|key, val| val == "A" || val == "B" } - assert_equal(RBTree[*%w(c C d D)], ret) - assert_equal(4, @rbtree.size) - end - - def test_select - ret = @rbtree.select {|key, val| val == "A" || val == "B" } - assert_equal(%w(a A b B), ret.flatten) - assert_raise(ArgumentError) { @rbtree.select("c") } - end - - def test_values_at - ret = @rbtree.values_at("d", "a", "e") - assert_equal(["D", "A", nil], ret) - end - - def test_invert - assert_equal(RBTree[*%w(A a B b C c D d)], @rbtree.invert) - end - - def test_update - rbtree = RBTree.new - rbtree["e"] = "E" - @rbtree.update(rbtree) - assert_equal(RBTree[*%w(a A b B c C d D e E)], @rbtree) - - @rbtree.clear - @rbtree["d"] = "A" - rbtree.clear - rbtree["d"] = "B" - - @rbtree.update(rbtree) {|key, val1, val2| - val1 + val2 if key == "d" - } - assert_equal(RBTree[*%w(d AB)], @rbtree) - - assert_raise(TypeError) { @rbtree.update("e") } - end - - def test_merge - rbtree = RBTree.new - rbtree["e"] = "E" - - ret = @rbtree.merge(rbtree) - assert_equal(RBTree[*%w(a A b B c C d D e E)], ret) - - assert_equal(4, @rbtree.size) - end - - def test_has_key - assert_equal(true, @rbtree.has_key?("a")) - assert_equal(true, @rbtree.has_key?("b")) - assert_equal(true, @rbtree.has_key?("c")) - assert_equal(true, @rbtree.has_key?("d")) - assert_equal(false, @rbtree.has_key?("e")) - end - - def test_has_value - assert_equal(true, @rbtree.has_value?("A")) - assert_equal(true, @rbtree.has_value?("B")) - assert_equal(true, @rbtree.has_value?("C")) - assert_equal(true, @rbtree.has_value?("D")) - assert_equal(false, @rbtree.has_value?("E")) - end - - def test_keys - assert_equal(%w(a b c d), @rbtree.keys) - end - - def test_values - assert_equal(%w(A B C D), @rbtree.values) - end - - def test_to_a - assert_equal([%w(a A), %w(b B), %w(c C), %w(d D)], @rbtree.to_a) - end - - def test_to_s - assert_equal("aAbBcCdD", @rbtree.to_s) - end - - def test_to_hash - @rbtree.default = "e" - hash = @rbtree.to_hash - assert_equal(@rbtree.to_a.flatten, hash.to_a.flatten) - assert_equal("e", hash.default) - - rbtree = RBTree.new { "e" } - hash = rbtree.to_hash - if (hash.respond_to?(:default_proc)) - assert_equal(rbtree.default_proc, hash.default_proc) - else - assert_equal(rbtree.default_proc, hash.default) - end - end - - def test_to_rbtree - assert_same(@rbtree, @rbtree.to_rbtree) - end - - def test_inspect - @rbtree.default = "e" - @rbtree.readjust {|a, b| a <=> b} - re = /#/ - - assert_match(re, @rbtree.inspect) - match = re.match(@rbtree.inspect) - tree, default, cmp_proc = match.to_a[1..-1] - assert_equal(%({"a"=>"A", "b"=>"B", "c"=>"C", "d"=>"D"}), tree) - assert_equal(%("e"), default) - assert_match(/#/, cmp_proc) - - rbtree = RBTree.new - assert_match(re, rbtree.inspect) - match = re.match(rbtree.inspect) - tree, default, cmp_proc = match.to_a[1..-1] - assert_equal("{}", tree) - assert_equal("nil", default) - assert_equal("nil", cmp_proc) - - rbtree = RBTree.new - rbtree["e"] = rbtree - assert_match(re, rbtree.inspect) - match = re.match(rbtree.inspect) - assert_equal(%({"e"=>#}), match[1]) - end - - def test_lower_bound - rbtree = RBTree[*%w(a A c C e E)] - assert_equal(["c", "C"], rbtree.lower_bound("c")) - assert_equal(["c", "C"], rbtree.lower_bound("b")) - assert_equal(nil, rbtree.lower_bound("f")) - end - - def test_upper_bound - rbtree = RBTree[*%w(a A c C e E)] - assert_equal(["c", "C"], rbtree.upper_bound("c")) - assert_equal(["c", "C"], rbtree.upper_bound("d")) - assert_equal(nil, rbtree.upper_bound("Z")) - end - - def test_bound - rbtree = RBTree[*%w(a A c C e E)] - assert_equal(%w(a A c C), rbtree.bound("a", "c").flatten) - assert_equal(%w(a A), rbtree.bound("a").flatten) - assert_equal(%w(c C e E), rbtree.bound("b", "f").flatten) - - assert_equal([], rbtree.bound("b", "b")) - assert_equal([], rbtree.bound("Y", "Z")) - assert_equal([], rbtree.bound("f", "g")) - assert_equal([], rbtree.bound("f", "Z")) - end - - def test_bound_block - ret = [] - @rbtree.bound("b", "c") {|key, val| - ret.push(key) - } - assert_equal(%w(b c), ret) - - assert_raise(TypeError) { - @rbtree.bound("a", "d") { - @rbtree["e"] = "E" - } - } - assert_equal(4, @rbtree.size) - - @rbtree.bound("b", "c") { - @rbtree.bound("b", "c") {} - assert_raise(TypeError) { - @rbtree["e"] = "E" - } - break - } - assert_equal(4, @rbtree.size) - end - - def test_first - assert_equal(["a", "A"], @rbtree.first) - - rbtree = RBTree.new("e") - assert_equal("e", rbtree.first) - - rbtree = RBTree.new { "e" } - assert_equal("e", rbtree.first) - end - - def test_last - assert_equal(["d", "D"], @rbtree.last) - - rbtree = RBTree.new("e") - assert_equal("e", rbtree.last) - - rbtree = RBTree.new { "e" } - assert_equal("e", rbtree.last) - end - - def test_readjust - assert_equal(nil, @rbtree.cmp_proc) - - @rbtree.readjust {|a, b| b <=> a } - assert_equal(%w(d c b a), @rbtree.keys) - assert_not_equal(nil, @rbtree.cmp_proc) - - proc = Proc.new {|a,b| a.to_s <=> b.to_s } - @rbtree.readjust(proc) - assert_equal(%w(a b c d), @rbtree.keys) - assert_equal(proc, @rbtree.cmp_proc) - - @rbtree[0] = nil - if VERSION >= "1.8.0" - assert_raise(ArgumentError) { @rbtree.readjust(nil) } - assert_equal(5, @rbtree.size) - assert_equal(proc, @rbtree.cmp_proc) - - @rbtree.delete(0) - @rbtree.readjust(nil) - assert_raise(ArgumentError) { @rbtree[0] = nil } - end - - - rbtree = RBTree.new - key = ["a"] - rbtree[key] = nil - rbtree[["e"]] = nil - key[0] = "f" - - assert_equal([["f"], ["e"]], rbtree.keys) - rbtree.readjust - assert_equal([["e"], ["f"]], rbtree.keys) - - if VERSION >= "1.8.0" - assert_raise(ArgumentError) { @rbtree.readjust { "e" } } - end - assert_raise(TypeError) { @rbtree.readjust("e") } - assert_raise(ArgumentError) { - @rbtree.readjust(proc) {|a,b| a <=> b } - } - assert_raise(ArgumentError) { @rbtree.readjust(proc, proc) } - end - - def test_replace - rbtree = RBTree.new { "e" } - rbtree.readjust {|a, b| a <=> b} - rbtree["a"] = "A" - rbtree["e"] = "E" - - @rbtree.replace(rbtree) - assert_equal(%w(a A e E), @rbtree.to_a.flatten) - assert_equal(rbtree.default, @rbtree.default) - assert_equal(rbtree.cmp_proc, @rbtree.cmp_proc) - - assert_raise(TypeError) { @rbtree.replace("e") } - end - - def test_reverse_each - ret = [] - @rbtree.reverse_each { |key, val| ret.push([key, val]) } - assert_equal(%w(d D c C b B a A), ret.flatten) - end - - def test_marshal - assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) - - @rbtree.default = "e" - assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) - - assert_raise(TypeError) { - Marshal.dump(RBTree.new { "e" }) - } - - assert_raise(TypeError) { - @rbtree.readjust {|a, b| a <=> b} - Marshal.dump(@rbtree) - } - end - - begin - require "pp" - - def test_pp - assert_equal(%(#\n), - PP.pp(RBTree[], "")) - assert_equal(%(#"A", "b"=>"B"}, default=nil, cmp_proc=nil>\n), - PP.pp(RBTree[*%w(a A b B)], "")) - - rbtree = RBTree[*("a".."z").to_a] - rbtree.default = "a" - rbtree.readjust {|a, b| a <=> b } - expected = <"b", - "c"=>"d", - "e"=>"f", - "g"=>"h", - "i"=>"j", - "k"=>"l", - "m"=>"n", - "o"=>"p", - "q"=>"r", - "s"=>"t", - "u"=>"v", - "w"=>"x", - "y"=>"z"}, - default="a", - cmp_proc=#{rbtree.cmp_proc}> -EOS - assert_equal(expected, PP.pp(rbtree, "")) - - rbtree = RBTree[] - rbtree[rbtree] = rbtree - rbtree.default = rbtree - expected = <"=>"#"}, - default="#", - cmp_proc=nil> -EOS - assert_equal(expected, PP.pp(rbtree, "")) - end - rescue LoadError - end -end - - -class MultiRBTreeTest < Test::Unit::TestCase - def setup - @rbtree = MultiRBTree[*%w(a A b B b C b D c C)] - end - - def test_create - assert_equal(%w(a A b B b C b D c C), @rbtree.to_a.flatten) - - assert_equal(MultiRBTree[*%w(a A)], MultiRBTree[RBTree[*%w(a A)]]) - assert_raise(ArgumentError) { - RBTree[MultiRBTree[*%w(a A)]] - } - end - - def test_size - assert_equal(5, @rbtree.size) - end - - def test_clear - @rbtree.clear - assert_equal(0, @rbtree.size) - end - - def test_empty - assert_equal(false, @rbtree.empty?) - @rbtree.clear - assert_equal(true, @rbtree.empty?) - end - - def test_to_a - assert_equal([%w(a A), %w(b B), %w(b C), %w(b D), %w(c C)], - @rbtree.to_a) - end - - def test_to_s - assert_equal("aAbBbCbDcC", @rbtree.to_s) - end - - def test_to_hash - assert_equal(Hash[*%w(a A b D c C)], @rbtree.to_hash) - end - - def test_to_rbtree - assert_equal(@rbtree, @rbtree.to_rbtree) - end - - def test_aref - assert_equal("B", @rbtree["b"]) - end - - def test_aset - @rbtree["b"] = "A" - assert_equal("B", @rbtree["b"]) - assert_equal(%w(a A b B b C b D b A c C), @rbtree.to_a.flatten) - end - - def test_equal - assert_equal(true, MultiRBTree[*%w(a A b B b C b D c C)] == @rbtree) - assert_equal(true, RBTree[*%w(a A)] == MultiRBTree[*%w(a A)]) - assert_equal(true, MultiRBTree[*%w(a A)] == RBTree[*%w(a A)]) - end - - def test_replace - assert_equal(RBTree[*%w(a A)], - MultiRBTree[*%w(a A)].replace(RBTree[*%w(a A)])) - assert_raise(TypeError) { - RBTree[*%w(a A)].replace(MultiRBTree[*%w(a A)]) - } - end - - def test_update - assert_equal(MultiRBTree[*%w(a A b B)], - MultiRBTree[*%w(a A)].update(RBTree[*%w(b B)])) - assert_raise(TypeError) { - RBTree[*%w(a A)].update(MultiRBTree[*%w(b B)]) - } - end - - def test_clone - assert_equal(@rbtree, @rbtree.clone) - end - - def test_each - ret = [] - @rbtree.each {|k, v| - ret << k << v - } - assert_equal(%w(a A b B b C b D c C), ret) - end - - def test_delete - @rbtree.delete("b") - assert_equal(4, @rbtree.size) - assert_equal(%w(a A b C b D c C), @rbtree.to_a.flatten) - - @rbtree.delete("b") - assert_equal(3, @rbtree.size) - assert_equal(%w(a A b D c C), @rbtree.to_a.flatten) - - @rbtree.delete("b") - assert_equal(2, @rbtree.size) - assert_equal(%w(a A c C), @rbtree.to_a.flatten) - end - - def test_delete_if - @rbtree.delete_if {|k, v| k == "b" } - assert_equal(%w(a A c C), @rbtree.to_a.flatten) - end - - def test_inspect - assert_equal(%(#"A", "b"=>"B", "b"=>"C", "b"=>"D", "c"=>"C"}, default=nil, cmp_proc=nil>), - @rbtree.inspect) - end - - def test_readjust - @rbtree.readjust {|a, b| b <=> a } - assert_equal(%w(c C b B b C b D a A), @rbtree.to_a.flatten) - end - - def test_marshal - assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) - end - - def test_lower_bound - assert_equal(%w(b B), @rbtree.lower_bound("b")) - end - - def test_upper_bound - assert_equal(%w(b D), @rbtree.upper_bound("b")) - end - - def test_bound - assert_equal(%w(b B b C b D), @rbtree.bound("b").flatten) - end - - def test_first - assert_equal(%w(a A), @rbtree.first) - end - - def test_last - assert_equal(%w(c C), @rbtree.last) - end - - def test_shift - assert_equal(%w(a A), @rbtree.shift) - assert_equal(4, @rbtree.size) - assert_equal(nil, @rbtree["a"]) - end - - def test_pop - assert_equal(%w(c C), @rbtree.pop) - assert_equal(4, @rbtree.size) - assert_equal(nil, @rbtree["c"]) - end - - def test_has_key - assert_equal(true, @rbtree.has_key?("b")) - end - - def test_has_value - assert_equal(true, @rbtree.has_value?("B")) - assert_equal(true, @rbtree.has_value?("C")) - assert_equal(true, @rbtree.has_value?("D")) - end - - def test_select - assert_equal(%w(b B b C b D), @rbtree.select {|k, v| k == "b"}.flatten) - assert_equal(%w(b C c C), @rbtree.select {|k, v| v == "C"}.flatten) - end - - def test_values_at - assert_equal(%w(A B), @rbtree.values_at("a", "b")) - end - - def test_invert - assert_equal(MultiRBTree[*%w(A a B b C b C c D b)], @rbtree.invert) - end - - def test_keys - assert_equal(%w(a b b b c), @rbtree.keys) - end - - def test_values - assert_equal(%w(A B C D C), @rbtree.values) - end - - def test_index - assert_equal("b", @rbtree.index("B")) - assert_equal("b", @rbtree.index("C")) - assert_equal("b", @rbtree.index("D")) - end -end Added: trunk/rbtree-0.2.0/tests/rbtree_test.rb =================================================================== --- trunk/rbtree-0.2.0/tests/rbtree_test.rb (rev 0) +++ trunk/rbtree-0.2.0/tests/rbtree_test.rb 2007-05-14 17:00:30 UTC (rev 269) @@ -0,0 +1,887 @@ +require "rbtree" +require "test/unit.rb" + +module Test + module Unit + class TestCase + unless method_defined?(:assert_raise) + alias :assert_raise :assert_raises + end + end + end +end + +class RBTreeTest < Test::Unit::TestCase + def setup + @rbtree = RBTree[*%w(b B d D a A c C)] + end + + def test_new + assert_nothing_raised { + RBTree.new + RBTree.new("a") + RBTree.new { "a" } + } + assert_raise(ArgumentError) { RBTree.new("a") {} } + assert_raise(ArgumentError) { RBTree.new("a", "a") } + end + + def test_aref + assert_equal("A", @rbtree["a"]) + assert_equal("B", @rbtree["b"]) + assert_equal("C", @rbtree["c"]) + assert_equal("D", @rbtree["d"]) + + assert_equal(nil, @rbtree["e"]) + @rbtree.default = "E" + assert_equal("E", @rbtree["e"]) + end + + def test_size + assert_equal(4, @rbtree.size) + end + + def test_create + rbtree = RBTree[] + assert_equal(0, rbtree.size) + + rbtree = RBTree[@rbtree] + assert_equal(4, rbtree.size) + assert_equal("A", @rbtree["a"]) + assert_equal("B", @rbtree["b"]) + assert_equal("C", @rbtree["c"]) + assert_equal("D", @rbtree["d"]) + + rbtree = RBTree[RBTree.new("e")] + assert_equal(nil, rbtree.default) + rbtree = RBTree[RBTree.new { "e" }] + assert_equal(nil, rbtree.default_proc) + @rbtree.readjust {|a,b| b <=> a } + assert_equal(nil, RBTree[@rbtree].cmp_proc) + + assert_raise(ArgumentError) { RBTree["e"] } + + rbtree = RBTree[Hash[*%w(b B d D a A c C)]] + assert_equal(4, rbtree.size) + assert_equal("A", @rbtree["a"]) + assert_equal("B", @rbtree["b"]) + assert_equal("C", @rbtree["c"]) + assert_equal("D", @rbtree["d"]) + end + + def test_clear + @rbtree.clear + assert_equal(0, @rbtree.size) + end + + def test_aset + @rbtree["e"] = "E" + assert_equal(5, @rbtree.size) + assert_equal("E", @rbtree["e"]) + + @rbtree["c"] = "E" + assert_equal(5, @rbtree.size) + assert_equal("E", @rbtree["c"]) + + if VERSION >= "1.8.0" + assert_raise(ArgumentError) { @rbtree[100] = 100 } + assert_equal(5, @rbtree.size) + end + + + key = "f" + @rbtree[key] = "F" + cloned_key = @rbtree.last[0] + assert_equal("f", cloned_key) + assert_not_same(key, cloned_key) + assert_equal(true, cloned_key.frozen?) + + @rbtree["f"] = "F" + assert_same(cloned_key, @rbtree.last[0]) + + rbtree = RBTree.new + key = ["g"] + rbtree[key] = "G" + assert_same(key, rbtree.first[0]) + assert_equal(false, key.frozen?) + end + + def test_clone + clone = @rbtree.clone + assert_equal(4, @rbtree.size) + assert_equal("A", @rbtree["a"]) + assert_equal("B", @rbtree["b"]) + assert_equal("C", @rbtree["c"]) + assert_equal("D", @rbtree["d"]) + + rbtree = RBTree.new("e") + clone = rbtree.clone + assert_equal("e", clone.default) + + rbtree = RBTree.new { "e" } + clone = rbtree.clone + assert_equal("e", clone.default(nil)) + + rbtree = RBTree.new + rbtree.readjust {|a, b| a <=> b } + clone = rbtree.clone + assert_equal(rbtree.cmp_proc, clone.cmp_proc) + end + + def test_default + assert_equal(nil, @rbtree.default) + + rbtree = RBTree.new("e") + assert_equal("e", rbtree.default) + assert_equal("e", rbtree.default("f")) + assert_raise(ArgumentError) { rbtree.default("e", "f") } + + rbtree = RBTree.new {|rbtree, key| @rbtree[key || "c"] } + assert_equal("C", rbtree.default(nil)) + assert_equal("B", rbtree.default("b")) + end + + def test_set_default + rbtree = RBTree.new { "e" } + rbtree.default = "f" + assert_equal("f", rbtree.default) + end + + def test_default_proc + rbtree = RBTree.new("e") + assert_equal(nil, rbtree.default_proc) + + rbtree = RBTree.new { "e" } + assert_equal("e", rbtree.default_proc.call) + end + + def test_equal + assert_equal(RBTree.new, RBTree.new) + assert_equal(@rbtree, @rbtree) + assert_not_equal(@rbtree, RBTree.new) + + rbtree = RBTree[*%w(b B d D a A c C)] + assert_equal(@rbtree, rbtree) + rbtree["d"] = "A" + assert_not_equal(@rbtree, rbtree) + rbtree["d"] = "D" + rbtree["e"] = "E" + assert_not_equal(@rbtree, rbtree) + @rbtree["e"] = "E" + assert_equal(@rbtree, rbtree) + + rbtree.default = "e" + assert_equal(@rbtree, rbtree) + @rbtree.default = "f" + assert_equal(@rbtree, rbtree) + + a = RBTree.new("e") + b = RBTree.new { "f" } + assert_equal(a, b) + assert_equal(b, b.clone) + + a = RBTree.new + b = RBTree.new + a.readjust {|a, b| a <=> b } + assert_not_equal(a, b) + b.readjust(a.cmp_proc) + assert_equal(a, b) + end + + def test_fetch + assert_equal("A", @rbtree.fetch("a")) + assert_equal("B", @rbtree.fetch("b")) + assert_equal("C", @rbtree.fetch("c")) + assert_equal("D", @rbtree.fetch("d")) + + assert_raise(IndexError) { @rbtree.fetch("e") } + + assert_equal("E", @rbtree.fetch("e", "E")) + assert_equal("E", @rbtree.fetch("e") { "E" }) + + assert_raise(ArgumentError) { @rbtree.fetch } + assert_raise(ArgumentError) { @rbtree.fetch("e", "E", "E") } + end + + def test_index + assert_equal("a", @rbtree.index("A")) + assert_equal(nil, @rbtree.index("E")) + end + + def test_empty_p + assert_equal(false, @rbtree.empty?) + @rbtree.clear + assert_equal(true, @rbtree.empty?) + end + + def test_each + ret = [] + @rbtree.each {|key, val| ret << key << val } + assert_equal(%w(a A b B c C d D), ret) + + assert_raise(TypeError) { + @rbtree.each { @rbtree["e"] = "E" } + } + assert_equal(4, @rbtree.size) + + @rbtree.each { + @rbtree.each {} + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + break + } + assert_equal(4, @rbtree.size) + end + + def test_each_pair + ret = [] + @rbtree.each_pair {|key, val| ret << key << val } + assert_equal(%w(a A b B c C d D), ret) + + assert_raise(TypeError) { + @rbtree.each_pair { @rbtree["e"] = "E" } + } + assert_equal(4, @rbtree.size) + + @rbtree.each_pair { + @rbtree.each_pair {} + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + break + } + assert_equal(4, @rbtree.size) + end + + def test_each_key + ret = [] + @rbtree.each_key {|val| ret.push(val) } + assert_equal(%w(a b c d), ret) + + assert_raise(TypeError) { + @rbtree.each_key { @rbtree["e"] = "E" } + } + assert_equal(4, @rbtree.size) + + @rbtree.each_key { + @rbtree.each_key {} + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + break + } + assert_equal(4, @rbtree.size) + end + + def test_each_value + ret = [] + @rbtree.each_value {|key| ret.push(key) } + assert_equal(%w(A B C D), ret) + + assert_raise(TypeError) { + @rbtree.each_value { @rbtree["e"] = "E" } + } + assert_equal(4, @rbtree.size) + + @rbtree.each_value { + @rbtree.each_value {} + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + break + } + assert_equal(4, @rbtree.size) + end + + def test_shift + ret = @rbtree.shift + assert_equal(3, @rbtree.size) + assert_equal(["a", "A"], ret) + assert_equal(nil, @rbtree["a"]) + + 3.times { @rbtree.shift } + assert_equal(0, @rbtree.size) + assert_equal(nil, @rbtree.shift) + @rbtree.default = "e" + assert_equal("e", @rbtree.shift) + + rbtree = RBTree.new { "e" } + assert_equal("e", rbtree.shift) + end + + def test_pop + ret = @rbtree.pop + assert_equal(3, @rbtree.size) + assert_equal(["d", "D"], ret) + assert_equal(nil, @rbtree["d"]) + + 3.times { @rbtree.pop } + assert_equal(0, @rbtree.size) + assert_equal(nil, @rbtree.pop) + @rbtree.default = "e" + assert_equal("e", @rbtree.pop) + + rbtree = RBTree.new { "e" } + assert_equal("e", rbtree.pop) + end + + def test_delete + ret = @rbtree.delete("c") + assert_equal("C", ret) + assert_equal(3, @rbtree.size) + assert_equal(nil, @rbtree["c"]) + + assert_equal(nil, @rbtree.delete("e")) + assert_equal("E", @rbtree.delete("e") { "E" }) + end + + def test_delete_if + @rbtree.delete_if {|key, val| val == "A" || val == "B" } + assert_equal(RBTree[*%w(c C d D)], @rbtree) + + assert_raise(ArgumentError) { + @rbtree.delete_if {|key, val| key == "c" or raise ArgumentError } + } + assert_equal(2, @rbtree.size) + + assert_raise(TypeError) { + @rbtree.delete_if { @rbtree["e"] = "E" } + } + assert_equal(2, @rbtree.size) + + @rbtree.delete_if { + @rbtree.each { + assert_equal(2, @rbtree.size) + } + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + true + } + assert_equal(0, @rbtree.size) + end + + def test_reject_bang + ret = @rbtree.reject! { false } + assert_equal(nil, ret) + assert_equal(4, @rbtree.size) + + ret = @rbtree.reject! {|key, val| val == "A" || val == "B" } + assert_same(@rbtree, ret) + assert_equal(RBTree[*%w(c C d D)], ret) + end + + def test_reject + ret = @rbtree.reject { false } + assert_equal(nil, ret) + assert_equal(4, @rbtree.size) + + ret = @rbtree.reject {|key, val| val == "A" || val == "B" } + assert_equal(RBTree[*%w(c C d D)], ret) + assert_equal(4, @rbtree.size) + end + + def test_select + ret = @rbtree.select {|key, val| val == "A" || val == "B" } + assert_equal(%w(a A b B), ret.flatten) + assert_raise(ArgumentError) { @rbtree.select("c") } + end + + def test_values_at + ret = @rbtree.values_at("d", "a", "e") + assert_equal(["D", "A", nil], ret) + end + + def test_invert + assert_equal(RBTree[*%w(A a B b C c D d)], @rbtree.invert) + end + + def test_update + rbtree = RBTree.new + rbtree["e"] = "E" + @rbtree.update(rbtree) + assert_equal(RBTree[*%w(a A b B c C d D e E)], @rbtree) + + @rbtree.clear + @rbtree["d"] = "A" + rbtree.clear + rbtree["d"] = "B" + + @rbtree.update(rbtree) {|key, val1, val2| + val1 + val2 if key == "d" + } + assert_equal(RBTree[*%w(d AB)], @rbtree) + + assert_raise(TypeError) { @rbtree.update("e") } + end + + def test_merge + rbtree = RBTree.new + rbtree["e"] = "E" + + ret = @rbtree.merge(rbtree) + assert_equal(RBTree[*%w(a A b B c C d D e E)], ret) + + assert_equal(4, @rbtree.size) + end + + def test_has_key + assert_equal(true, @rbtree.has_key?("a")) + assert_equal(true, @rbtree.has_key?("b")) + assert_equal(true, @rbtree.has_key?("c")) + assert_equal(true, @rbtree.has_key?("d")) + assert_equal(false, @rbtree.has_key?("e")) + end + + def test_has_value + assert_equal(true, @rbtree.has_value?("A")) + assert_equal(true, @rbtree.has_value?("B")) + assert_equal(true, @rbtree.has_value?("C")) + assert_equal(true, @rbtree.has_value?("D")) + assert_equal(false, @rbtree.has_value?("E")) + end + + def test_keys + assert_equal(%w(a b c d), @rbtree.keys) + end + + def test_values + assert_equal(%w(A B C D), @rbtree.values) + end + + def test_to_a + assert_equal([%w(a A), %w(b B), %w(c C), %w(d D)], @rbtree.to_a) + end + + def test_to_s + assert_equal("aAbBcCdD", @rbtree.to_s) + end + + def test_to_hash + @rbtree.default = "e" + hash = @rbtree.to_hash + assert_equal(@rbtree.to_a.flatten, hash.to_a.flatten) + assert_equal("e", hash.default) + + rbtree = RBTree.new { "e" } + hash = rbtree.to_hash + if (hash.respond_to?(:default_proc)) + assert_equal(rbtree.default_proc, hash.default_proc) + else + assert_equal(rbtree.default_proc, hash.default) + end + end + + def test_to_rbtree + assert_same(@rbtree, @rbtree.to_rbtree) + end + + def test_inspect + @rbtree.default = "e" + @rbtree.readjust {|a, b| a <=> b} + re = /#/ + + rbtree = RBTree.new + assert_match(re, rbtree.inspect) + match = re.match(rbtree.inspect) + tree, default, cmp_proc = match.to_a[1..-1] + assert_equal("{}", tree) + assert_equal("nil", default) + assert_equal("nil", cmp_proc) + + rbtree = RBTree.new + rbtree["e"] = rbtree + assert_match(re, rbtree.inspect) + match = re.match(rbtree.inspect) + assert_equal(%({"e"=>#}), match[1]) + end + + def test_lower_bound + rbtree = RBTree[*%w(a A c C e E)] + assert_equal(["c", "C"], rbtree.lower_bound("c")) + assert_equal(["c", "C"], rbtree.lower_bound("b")) + assert_equal(nil, rbtree.lower_bound("f")) + end + + def test_upper_bound + rbtree = RBTree[*%w(a A c C e E)] + assert_equal(["c", "C"], rbtree.upper_bound("c")) + assert_equal(["c", "C"], rbtree.upper_bound("d")) + assert_equal(nil, rbtree.upper_bound("Z")) + end + + def test_bound + rbtree = RBTree[*%w(a A c C e E)] + assert_equal(%w(a A c C), rbtree.bound("a", "c").flatten) + assert_equal(%w(a A), rbtree.bound("a").flatten) + assert_equal(%w(c C e E), rbtree.bound("b", "f").flatten) + + assert_equal([], rbtree.bound("b", "b")) + assert_equal([], rbtree.bound("Y", "Z")) + assert_equal([], rbtree.bound("f", "g")) + assert_equal([], rbtree.bound("f", "Z")) + end + + def test_bound_block + ret = [] + @rbtree.bound("b", "c") {|key, val| + ret.push(key) + } + assert_equal(%w(b c), ret) + + assert_raise(TypeError) { + @rbtree.bound("a", "d") { + @rbtree["e"] = "E" + } + } + assert_equal(4, @rbtree.size) + + @rbtree.bound("b", "c") { + @rbtree.bound("b", "c") {} + assert_raise(TypeError) { + @rbtree["e"] = "E" + } + break + } + assert_equal(4, @rbtree.size) + end + + def test_first + assert_equal(["a", "A"], @rbtree.first) + + rbtree = RBTree.new("e") + assert_equal("e", rbtree.first) + + rbtree = RBTree.new { "e" } + assert_equal("e", rbtree.first) + end + + def test_last + assert_equal(["d", "D"], @rbtree.last) + + rbtree = RBTree.new("e") + assert_equal("e", rbtree.last) + + rbtree = RBTree.new { "e" } + assert_equal("e", rbtree.last) + end + + def test_readjust + assert_equal(nil, @rbtree.cmp_proc) + + @rbtree.readjust {|a, b| b <=> a } + assert_equal(%w(d c b a), @rbtree.keys) + assert_not_equal(nil, @rbtree.cmp_proc) + + proc = Proc.new {|a,b| a.to_s <=> b.to_s } + @rbtree.readjust(proc) + assert_equal(%w(a b c d), @rbtree.keys) + assert_equal(proc, @rbtree.cmp_proc) + + @rbtree[0] = nil + if VERSION >= "1.8.0" + assert_raise(ArgumentError) { @rbtree.readjust(nil) } + assert_equal(5, @rbtree.size) + assert_equal(proc, @rbtree.cmp_proc) + + @rbtree.delete(0) + @rbtree.readjust(nil) + assert_raise(ArgumentError) { @rbtree[0] = nil } + end + + + rbtree = RBTree.new + key = ["a"] + rbtree[key] = nil + rbtree[["e"]] = nil + key[0] = "f" + + assert_equal([["f"], ["e"]], rbtree.keys) + rbtree.readjust + assert_equal([["e"], ["f"]], rbtree.keys) + + if VERSION >= "1.8.0" + assert_raise(ArgumentError) { @rbtree.readjust { "e" } } + end + assert_raise(TypeError) { @rbtree.readjust("e") } + assert_raise(ArgumentError) { + @rbtree.readjust(proc) {|a,b| a <=> b } + } + assert_raise(ArgumentError) { @rbtree.readjust(proc, proc) } + end + + def test_replace + rbtree = RBTree.new { "e" } + rbtree.readjust {|a, b| a <=> b} + rbtree["a"] = "A" + rbtree["e"] = "E" + + @rbtree.replace(rbtree) + assert_equal(%w(a A e E), @rbtree.to_a.flatten) + assert_equal(rbtree.default, @rbtree.default) + assert_equal(rbtree.cmp_proc, @rbtree.cmp_proc) + + assert_raise(TypeError) { @rbtree.replace("e") } + end + + def test_reverse_each + ret = [] + @rbtree.reverse_each { |key, val| ret.push([key, val]) } + assert_equal(%w(d D c C b B a A), ret.flatten) + end + + def test_marshal + assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) + + @rbtree.default = "e" + assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) + + assert_raise(TypeError) { + Marshal.dump(RBTree.new { "e" }) + } + + assert_raise(TypeError) { + @rbtree.readjust {|a, b| a <=> b} + Marshal.dump(@rbtree) + } + end + + begin + require "pp" + + def test_pp + assert_equal(%(#\n), + PP.pp(RBTree[], "")) + assert_equal(%(#"A", "b"=>"B"}, default=nil, cmp_proc=nil>\n), + PP.pp(RBTree[*%w(a A b B)], "")) + + rbtree = RBTree[*("a".."z").to_a] + rbtree.default = "a" + rbtree.readjust {|a, b| a <=> b } + expected = <"b", + "c"=>"d", + "e"=>"f", + "g"=>"h", + "i"=>"j", + "k"=>"l", + "m"=>"n", + "o"=>"p", + "q"=>"r", + "s"=>"t", + "u"=>"v", + "w"=>"x", + "y"=>"z"}, + default="a", + cmp_proc=#{rbtree.cmp_proc}> +EOS + assert_equal(expected, PP.pp(rbtree, "")) + + rbtree = RBTree[] + rbtree[rbtree] = rbtree + rbtree.default = rbtree + expected = <"=>"#"}, + default="#", + cmp_proc=nil> +EOS + assert_equal(expected, PP.pp(rbtree, "")) + end + rescue LoadError + end +end + + +class MultiRBTreeTest < Test::Unit::TestCase + def setup + @rbtree = MultiRBTree[*%w(a A b B b C b D c C)] + end + + def test_create + assert_equal(%w(a A b B b C b D c C), @rbtree.to_a.flatten) + + assert_equal(MultiRBTree[*%w(a A)], MultiRBTree[RBTree[*%w(a A)]]) + assert_raise(ArgumentError) { + RBTree[MultiRBTree[*%w(a A)]] + } + end + + def test_size + assert_equal(5, @rbtree.size) + end + + def test_clear + @rbtree.clear + assert_equal(0, @rbtree.size) + end + + def test_empty + assert_equal(false, @rbtree.empty?) + @rbtree.clear + assert_equal(true, @rbtree.empty?) + end + + def test_to_a + assert_equal([%w(a A), %w(b B), %w(b C), %w(b D), %w(c C)], + @rbtree.to_a) + end + + def test_to_s + assert_equal("aAbBbCbDcC", @rbtree.to_s) + end + + def test_to_hash + assert_equal(Hash[*%w(a A b D c C)], @rbtree.to_hash) + end + + def test_to_rbtree + assert_equal(@rbtree, @rbtree.to_rbtree) + end + + def test_aref + assert_equal("B", @rbtree["b"]) + end + + def test_aset + @rbtree["b"] = "A" + assert_equal("B", @rbtree["b"]) + assert_equal(%w(a A b B b C b D b A c C), @rbtree.to_a.flatten) + end + + def test_equal + assert_equal(true, MultiRBTree[*%w(a A b B b C b D c C)] == @rbtree) + assert_equal(true, RBTree[*%w(a A)] == MultiRBTree[*%w(a A)]) + assert_equal(true, MultiRBTree[*%w(a A)] == RBTree[*%w(a A)]) + end + + def test_replace + assert_equal(RBTree[*%w(a A)], + MultiRBTree[*%w(a A)].replace(RBTree[*%w(a A)])) + assert_raise(TypeError) { + RBTree[*%w(a A)].replace(MultiRBTree[*%w(a A)]) + } + end + + def test_update + assert_equal(MultiRBTree[*%w(a A b B)], + MultiRBTree[*%w(a A)].update(RBTree[*%w(b B)])) + assert_raise(TypeError) { + RBTree[*%w(a A)].update(MultiRBTree[*%w(b B)]) + } + end + + def test_clone + assert_equal(@rbtree, @rbtree.clone) + end + + def test_each + ret = [] + @rbtree.each {|k, v| + ret << k << v + } + assert_equal(%w(a A b B b C b D c C), ret) + end + + def test_delete + @rbtree.delete("b") + assert_equal(4, @rbtree.size) + assert_equal(%w(a A b C b D c C), @rbtree.to_a.flatten) + + @rbtree.delete("b") + assert_equal(3, @rbtree.size) + assert_equal(%w(a A b D c C), @rbtree.to_a.flatten) + + @rbtree.delete("b") + assert_equal(2, @rbtree.size) + assert_equal(%w(a A c C), @rbtree.to_a.flatten) + end + + def test_delete_if + @rbtree.delete_if {|k, v| k == "b" } + assert_equal(%w(a A c C), @rbtree.to_a.flatten) + end + + def test_inspect + assert_equal(%(#"A", "b"=>"B", "b"=>"C", "b"=>"D", "c"=>"C"}, default=nil, cmp_proc=nil>), + @rbtree.inspect) + end + + def test_readjust + @rbtree.readjust {|a, b| b <=> a } + assert_equal(%w(c C b B b C b D a A), @rbtree.to_a.flatten) + end + + def test_marshal + assert_equal(@rbtree, Marshal.load(Marshal.dump(@rbtree))) + end + + def test_lower_bound + assert_equal(%w(b B), @rbtree.lower_bound("b")) + end + + def test_upper_bound + assert_equal(%w(b D), @rbtree.upper_bound("b")) + end + + def test_bound + assert_equal(%w(b B b C b D), @rbtree.bound("b").flatten) + end + + def test_first + assert_equal(%w(a A), @rbtree.first) + end + + def test_last + assert_equal(%w(c C), @rbtree.last) + end + + def test_shift + assert_equal(%w(a A), @rbtree.shift) + assert_equal(4, @rbtree.size) + assert_equal(nil, @rbtree["a"]) + end + + def test_pop + assert_equal(%w(c C), @rbtree.pop) + assert_equal(4, @rbtree.size) + assert_equal(nil, @rbtree["c"]) + end + + def test_has_key + assert_equal(true, @rbtree.has_key?("b")) + end + + def test_has_value + assert_equal(true, @rbtree.has_value?("B")) + assert_equal(true, @rbtree.has_value?("C")) + assert_equal(true, @rbtree.has_value?("D")) + end + + def test_select + assert_equal(%w(b B b C b D), @rbtree.select {|k, v| k == "b"}.flatten) + assert_equal(%w(b C c C), @rbtree.select {|k, v| v == "C"}.flatten) + end + + def test_values_at + assert_equal(%w(A B), @rbtree.values_at("a", "b")) + end + + def test_invert + assert_equal(MultiRBTree[*%w(A a B b C b C c D b)], @rbtree.invert) + end + + def test_keys + assert_equal(%w(a b b b c), @rbtree.keys) + end + + def test_values + assert_equal(%w(A B C D C), @rbtree.values) + end + + def test_index + assert_equal("b", @rbtree.index("B")) + assert_equal("b", @rbtree.index("C")) + assert_equal("b", @rbtree.index("D")) + end +end From nobody at rubyforge.org Mon May 14 13:40:18 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 13:40:18 -0400 (EDT) Subject: [Archipelago-submits] [270] trunk/archipelago: removed using Queue from stdlib in Disco, since it works poorly with ruby 1.8.6. Message-ID: <20070514174019.E8D455240B93@rubyforge.org> Revision: 270 Author: zond Date: 2007-05-14 13:40:18 -0400 (Mon, 14 May 2007) Log Message: ----------- removed using Queue from stdlib in Disco, since it works poorly with ruby 1.8.6. added a new Queue class in Current. made Client (possibly) a bit more threadsafe. Modified Paths: -------------- trunk/archipelago/lib/archipelago/client.rb trunk/archipelago/lib/archipelago/current.rb trunk/archipelago/lib/archipelago/disco.rb trunk/archipelago/tests/current_test.rb Modified: trunk/archipelago/lib/archipelago/client.rb =================================================================== --- trunk/archipelago/lib/archipelago/client.rb 2007-05-14 17:00:30 UTC (rev 269) +++ trunk/archipelago/lib/archipelago/client.rb 2007-05-14 17:40:18 UTC (rev 270) @@ -57,9 +57,8 @@ @initial_lookup_timeout = options[:initial_lookup_timeout] || INITIAL_LOOKUP_TIMEOUT @services = {} @service_descriptions.each do |name, description| - t = RBTree.new - t.extend(Archipelago::Current::ThreadedCollection) - @services[name] = t + @services[name] = Archipelago::Disco::ServiceLocker.new + @services[name].convert_to_tree! end start_service_updater @@ -118,9 +117,10 @@ # more than on average once every MAXIMUM_SERVICE_UPDATE_INTERVAL, so that MAY make it worthwhile to do # the RBTree song and dance in here. Hopefully. # - @services[name] = @jockey.lookup(Archipelago::Disco::Query.new(description), timeout) - @services[name].convert_to_tree! - @services[name].validate! if validate + new_services = @jockey.lookup(Archipelago::Disco::Query.new(description), timeout) + new_services.convert_to_tree! + new_services.validate! if validate + @services[name] = new_services end end end Modified: trunk/archipelago/lib/archipelago/current.rb =================================================================== --- trunk/archipelago/lib/archipelago/current.rb 2007-05-14 17:00:30 UTC (rev 269) +++ trunk/archipelago/lib/archipelago/current.rb 2007-05-14 17:40:18 UTC (rev 270) @@ -33,6 +33,41 @@ module Current + class Queue + def initialize + @lock = Monitor.new + @flag = MonitorMixin::ConditionVariable.new(@lock) + @ary = [] + end + def <<(e) + @lock.synchronize do + @ary << e + @flag.broadcast + end + end + def empty?(wait = false) + @lock.synchronize do + if wait + @flag.wait_until do + @ary.empty? + end unless @ary.empty? + return @ary.empty? + else + return @ary.empty? + end + end + end + def shift + @lock.synchronize do + @flag.wait_while do + @ary.empty? + end if @ary.empty? + @flag.broadcast + return @ary.shift + end + end + end + # # Adds a few threaded methods to the normal ruby collections. # Modified: trunk/archipelago/lib/archipelago/disco.rb =================================================================== --- trunk/archipelago/lib/archipelago/disco.rb 2007-05-14 17:00:30 UTC (rev 269) +++ trunk/archipelago/lib/archipelago/disco.rb 2007-05-14 17:40:18 UTC (rev 270) @@ -485,8 +485,8 @@ @local_services = ServiceLocker.new(:jockey => self) @subscribed_services = Set.new - @incoming = Queue.new - @outgoing = Queue.new + @incoming = Archipelago::Current::Queue.new + @outgoing = Archipelago::Current::Queue.new @new_service_semaphore = MonitorMixin::ConditionVariable.new(Archipelago::Current::Lock.new) @service_change_subscribers_by_event_type = {:found => {}, :lost => {}} @@ -575,7 +575,7 @@ end # - # Stops all the threads and close all sockets in this instance. + # Stops all the threads and closes all sockets in this instance. # def stop! if @valid @@ -586,16 +586,13 @@ @listener_thread.kill @unilistener_thread.kill - until @incoming.empty? - sleep(0.01) - end + + @incoming.empty?(true) + @picker_thread.kill @listener.close @unilistener.close - @picker_thread.kill - until @outgoing.empty? - sleep(0.01) - end + @outgoing.empty?(true) @shouter_thread.kill @sender.close @unisender.close @@ -725,7 +722,7 @@ @shouter_thread = Thread.new do loop do begin - recipient, data = @outgoing.pop + recipient, data = @outgoing.shift if recipient address, port = recipient.split(/:/) @unisender.send(Marshal.dump(data), 0, address, port.to_i) @@ -788,7 +785,7 @@ @picker_thread = Thread.new do loop do begin - data = @incoming.pop + data = @incoming.shift if Archipelago::Disco::Query === data @local_services.get_services(data).each do |service_id, service_data| if @thrifty_replying Modified: trunk/archipelago/tests/current_test.rb =================================================================== --- trunk/archipelago/tests/current_test.rb 2007-05-14 17:00:30 UTC (rev 269) +++ trunk/archipelago/tests/current_test.rb 2007-05-14 17:40:18 UTC (rev 270) @@ -19,6 +19,41 @@ class CurrentTest < Test::Unit::TestCase + def test_queue + q = Archipelago::Current::Queue.new + assert(q.empty?) + t = true + Thread.new do + e = q.shift + t = false + end + Thread.pass + assert(t) + q << "blar" + Thread.pass + sleep(0.1) + assert(!t) + + q << "bunke" + assert(!q.empty?) + q.shift + assert(q.empty?) + + assert(q.empty?) + q << "hehu" + assert(!q.empty?) + Thread.new do + q.empty?(true) + t = true + end + Thread.pass + assert(!t) + q.shift + Thread.pass + assert(t) + assert(q.empty?) + end + def test_synchronized t = true From nobody at rubyforge.org Mon May 14 13:41:05 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 13:41:05 -0400 (EDT) Subject: [Archipelago-submits] [271] trunk: bumbed some version numbers Message-ID: <20070514174105.1803A5240B93@rubyforge.org> Revision: 271 Author: zond Date: 2007-05-14 13:41:04 -0400 (Mon, 14 May 2007) Log Message: ----------- bumbed some version numbers Modified Paths: -------------- trunk/archipelago/Rakefile trunk/oneliner/Rakefile trunk/rbtree-0.2.0/Rakefile Modified: trunk/archipelago/Rakefile =================================================================== --- trunk/archipelago/Rakefile 2007-05-14 17:40:18 UTC (rev 270) +++ trunk/archipelago/Rakefile 2007-05-14 17:41:04 UTC (rev 271) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "archipelago" - s.version = "0.2.6" + s.version = "0.2.7" s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "A set of tools for distributed computing in ruby." Modified: trunk/oneliner/Rakefile =================================================================== --- trunk/oneliner/Rakefile 2007-05-14 17:40:18 UTC (rev 270) +++ trunk/oneliner/Rakefile 2007-05-14 17:41:04 UTC (rev 271) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "oneliner" - s.version = "0.2.6" + s.version = "0.2.7" s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "An online code implementation for ruby." Modified: trunk/rbtree-0.2.0/Rakefile =================================================================== --- trunk/rbtree-0.2.0/Rakefile 2007-05-14 17:40:18 UTC (rev 270) +++ trunk/rbtree-0.2.0/Rakefile 2007-05-14 17:41:04 UTC (rev 271) @@ -9,7 +9,7 @@ spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "archipelago_rbtree" - s.version = "0.2.6" + s.version = "0.2.7" s.author = "OZAWA Takuma, Kaz Kylheku, Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "A patched version of the rbtree code that accepts each and reverse_each with offsets." From nobody at rubyforge.org Mon May 14 13:46:29 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 13:46:29 -0400 (EDT) Subject: [Archipelago-submits] [272] trunk/archipelago: added dependencies, added README info Message-ID: <20070514174629.BC0B15240B93@rubyforge.org> Revision: 272 Author: zond Date: 2007-05-14 13:46:29 -0400 (Mon, 14 May 2007) Log Message: ----------- added dependencies, added README info Modified Paths: -------------- trunk/archipelago/README trunk/archipelago/Rakefile trunk/archipelago/lib/archipelago/client.rb trunk/archipelago/lib/archipelago/disco.rb trunk/archipelago/lib/archipelago/hashish.rb Modified: trunk/archipelago/README =================================================================== --- trunk/archipelago/README 2007-05-14 17:41:04 UTC (rev 271) +++ trunk/archipelago/README 2007-05-14 17:46:29 UTC (rev 272) @@ -4,7 +4,7 @@ == Dependencies: Archipelago::Hashish::BerkeleyHashishProvider:: ruby bdb: http://moulon.inra.fr/ruby/bdb.html -Archipelago::Client::Base:: rbtree: in this same repository is a patched version, original code is at http://www.geocities.co.jp/SiliconValley-PaloAlto/3388/rbtree/README.html +Archipelago::Client::Base:: archipelago_rbtree, a patched and gemified version of the original at http://www.geocities.co.jp/SiliconValley-PaloAlto/3388/rbtree/README.html == Sub packages: Archipelago::Disco:: A UDP multicast discovery service useful to find services in your network with a minimum of configuration. Modified: trunk/archipelago/Rakefile =================================================================== --- trunk/archipelago/Rakefile 2007-05-14 17:41:04 UTC (rev 271) +++ trunk/archipelago/Rakefile 2007-05-14 17:46:29 UTC (rev 272) @@ -21,6 +21,8 @@ s.rdoc_options << '--line-numbers' s.rdoc_options << '--inline-source' s.extra_rdoc_files = ["README"] + s.add_dependency('oneliner', '>= 0.2.7') + s.add_dependency('archipelago_rbtree', '>= 0.2.7') end Modified: trunk/archipelago/lib/archipelago/client.rb =================================================================== --- trunk/archipelago/lib/archipelago/client.rb 2007-05-14 17:41:04 UTC (rev 271) +++ trunk/archipelago/lib/archipelago/client.rb 2007-05-14 17:46:29 UTC (rev 272) @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'archipelago/disco' -require 'rbtree' +require 'archipelago_rbtree' module Archipelago Modified: trunk/archipelago/lib/archipelago/disco.rb =================================================================== --- trunk/archipelago/lib/archipelago/disco.rb 2007-05-14 17:41:04 UTC (rev 271) +++ trunk/archipelago/lib/archipelago/disco.rb 2007-05-14 17:46:29 UTC (rev 272) @@ -25,6 +25,7 @@ require 'set' require 'digest/sha1' require 'forwardable' +require 'archipelago_rbtree' module Archipelago Modified: trunk/archipelago/lib/archipelago/hashish.rb =================================================================== --- trunk/archipelago/lib/archipelago/hashish.rb 2007-05-14 17:41:04 UTC (rev 271) +++ trunk/archipelago/lib/archipelago/hashish.rb 2007-05-14 17:46:29 UTC (rev 272) @@ -17,7 +17,7 @@ require 'archipelago/current' require 'bdb' -require 'rbtree' +require 'archipelago_rbtree' module Archipelago From nobody at rubyforge.org Mon May 14 19:36:17 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 May 2007 19:36:17 -0400 (EDT) Subject: [Archipelago-submits] [273] trunk/rbtree-0.2.0: prettier gem Message-ID: <20070514233617.5AA645240BA7@rubyforge.org> Revision: 273 Author: zond Date: 2007-05-14 19:36:16 -0400 (Mon, 14 May 2007) Log Message: ----------- prettier gem Modified Paths: -------------- trunk/rbtree-0.2.0/Rakefile trunk/rbtree-0.2.0/tests/rbtree_test.rb Removed Paths: ------------- trunk/rbtree-0.2.0/depend Modified: trunk/rbtree-0.2.0/Rakefile =================================================================== --- trunk/rbtree-0.2.0/Rakefile 2007-05-14 17:46:29 UTC (rev 272) +++ trunk/rbtree-0.2.0/Rakefile 2007-05-14 23:36:16 UTC (rev 273) @@ -13,7 +13,7 @@ s.author = "OZAWA Takuma, Kaz Kylheku, Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "A patched version of the rbtree code that accepts each and reverse_each with offsets." - s.files = FileList["**/*"].to_a + s.files = FileList["ext/*", "LICENSE", "README"].to_a s.extensions << 'ext/extconf.rb' s.autorequire = "archipelago_rbtree" s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') Deleted: trunk/rbtree-0.2.0/depend =================================================================== --- trunk/rbtree-0.2.0/depend 2007-05-14 17:46:29 UTC (rev 272) +++ trunk/rbtree-0.2.0/depend 2007-05-14 23:36:16 UTC (rev 273) @@ -1,2 +0,0 @@ -dict.o: dict.c dict.h -rbtree.o: rbtree.c dict.h Modified: trunk/rbtree-0.2.0/tests/rbtree_test.rb =================================================================== --- trunk/rbtree-0.2.0/tests/rbtree_test.rb 2007-05-14 17:46:29 UTC (rev 272) +++ trunk/rbtree-0.2.0/tests/rbtree_test.rb 2007-05-14 23:36:16 UTC (rev 273) @@ -1,4 +1,4 @@ -require "rbtree" +require "archipelago_rbtree" require "test/unit.rb" module Test From nobody at rubyforge.org Fri May 18 08:49:21 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 18 May 2007 08:49:21 -0400 (EDT) Subject: [Archipelago-submits] [274] trunk/oneliner: beginning of new try... Message-ID: <20070518124921.7A43D5240AB4@rubyforge.org> Revision: 274 Author: zond Date: 2007-05-18 08:49:21 -0400 (Fri, 18 May 2007) Log Message: ----------- beginning of new try... nothing works yet Modified Paths: -------------- trunk/oneliner/ext/extconf.rb trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/lib/oneliner/superstring.rb trunk/oneliner/tests/superstring_test.rb Property Changed: ---------------- trunk/oneliner/ Property changes on: trunk/oneliner ___________________________________________________________________ Name: svn:ignore - pkg Makefile oneliner_ext.bundle mkmf.log + pkg Makefile oneliner_ext.bundle mkmf.log .gdb_history tmp.rb Modified: trunk/oneliner/ext/extconf.rb =================================================================== --- trunk/oneliner/ext/extconf.rb 2007-05-14 23:36:16 UTC (rev 273) +++ trunk/oneliner/ext/extconf.rb 2007-05-18 12:49:21 UTC (rev 274) @@ -28,6 +28,16 @@ crash "libssl needed" end -dir_config("oneliner_ext") +unless find_executable("pkg-config") + crash("pkg-config needed") +end +unless have_library('glib-2.0') + crash "libglib-2.0 needed" +end + +$CFLAGS += " -D ONELINER_DEBUG" if ARGV.include?("-d") + +$CFLAGS += " -g -gdwarf-2 -g3 " + `pkg-config --cflags --libs glib-2.0`.strip + create_makefile("oneliner_ext") Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-14 23:36:16 UTC (rev 273) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-18 12:49:21 UTC (rev 274) @@ -18,54 +18,93 @@ #include "ruby.h" #include #include +#include +#include +#include // +// The classes +// +static VALUE rb_superstring; + +// +// Utility macros. +// +#ifdef ONELINER_DEBUG +#define DEBUG(s, ...) fprintf(stderr, "DEBUG: "); fprintf(stderr, s, ## __VA_ARGS__); fprintf(stderr, "\n"); fflush(NULL); +#define IFDEBUG(s) s; +#define BITSTRING_DEBUG(msg,str,len) fprintf(stderr, "DEBUG: %s: ", (msg)); rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("unpack"), 1, rb_str_new2("B*"))); fprintf(stderr, "\n"); fflush(NULL) +#else +#define DEBUG(s, ...) ; +#define IFDEBUG(s) ; +#define BITSTRING_DEBUG(msg,str,len) ; +#endif + +#define GUINT32MAX 0xffffffff +#define RANDOM(context,max) (oneliner_context_random(context) % (max)) +#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) GUINT32MAX ) +#define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) + +#define Q 3 +#define E 0.01 + +// +// The c representation of a superstring. +// +typedef struct { + // The blocks of this superstring. + GArray *blocks; + // The size of each block in bits. + guint32 block_size; + // The number of guint8's needed to contain those bits. + guint32 n_chars_in_block; + // The length of the original data. + guint32 data_len; + // The number of bytes needed to store all blocks. + // (not necessarily the same as the length of the original data) + guint32 n_bytes_for_blocks; + // The aux blocks of this superstrin. + GArray *aux_blocks; +} oneliner_superstring; + +// +// A random context. +// +typedef guint8 oneliner_context; + +// // The distribution of degrees. // -double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; +static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; // // Encrypt the context again // static void -_aes_randomize_context(char *context) +oneliner_context_randomize(oneliner_context *context) { AES_KEY key; - AES_set_encrypt_key((unsigned char *) "0123456789012345", 128, &key); + AES_set_encrypt_key((guint8 *) "0123456789012345", 128, &key); - AES_encrypt((unsigned char *) context + 4, - (unsigned char *) context + 4, + AES_encrypt((guint8 *) context + 4, + (guint8 *) context + 4, &key); - ( (int *) context )[0] = 1; + * (guint32 *) context = 1; } // -// Encrypt the buffer of ctx and set its counter to 0 -// -static void -aes_randomize_context(VALUE self) -{ - rb_str_modify(self); - _aes_randomize_context(RSTRING(self)->ptr); -} - -// // Fill the buffer of context with seed and randomize it. // -static VALUE -aes_seed_context(VALUE self, VALUE seed) +static gint32 +oneliner_context_seed(oneliner_context *context, gint32 seed) { - int tmp; + gint32 tmp; - if (RSTRING(self)->len < 17) - rb_str_concat(self, rb_str_new(0, 17)); - - rb_str_modify(self); for (tmp = 1; tmp < 5; tmp++) - ( (int *) RSTRING(self)->ptr )[tmp] = NUM2INT(seed); + ( (gint32 *) context )[tmp] = seed; - aes_randomize_context(self); + oneliner_context_randomize(context); return seed; } @@ -73,193 +112,344 @@ // // Return an int that is the next random in the context // -static int -_aes_random(char *context) +static gint32 +oneliner_context_random(oneliner_context *context) { - int *int_context = (int *) context; + gint32 *int_context = (gint32 *) context; if (int_context[0] < 5) { - int return_value = int_context[int_context[0]]; + gint32 return_value = int_context[int_context[0]]; int_context[0]++; return return_value; } else { - _aes_randomize_context(context); - return _aes_random(context); + oneliner_context_randomize(context); + return oneliner_context_random(context); } } // -// Get the int at the counter of context in the buffer of context. +// Initialize a context. // -static VALUE -aes_random(int argc, VALUE *argv, VALUE self) +static oneliner_context * +oneliner_context_new() { - int return_value; - - rb_str_modify(self); - return_value = _aes_random(RSTRING(self)->ptr); - - if (argc == 0) { - return rb_float_new( ( (double) ( (unsigned int) return_value ) ) / ( (double) UINT_MAX )); - } else { - VALUE max = argv[0]; - return INT2NUM(( (unsigned int) return_value ) % NUM2INT(max)); - } + return (oneliner_context *) g_new0(guint8, 4 * 5); } // -// Initialize a context. +// Free a context. // -static VALUE -context_initialize(int argc, VALUE *argv, VALUE self) +static void +oneliner_context_free(oneliner_context *context) { - rb_str_concat(self, rb_str_new(0, 17)); - return self; + g_free(context); } // -// Return self ^ subject +// Make object into object ^ subject // -static VALUE -string_xor(VALUE self, VALUE subject) +static void +oneliner_string_xor(guint8 *object, guint8 *subject, guint32 len) { - int tmp; - int len = RSTRING(self)->len; - VALUE return_value = rb_str_new(0, len); + guint32 tmp; - Check_Type(subject, T_STRING); - - if (len != RSTRING(subject)->len) - rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); - - rb_str_modify(return_value); +#ifdef G_HAVE_GINT64 + for (tmp = 0; tmp < len / 8; tmp++) { + ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; + } + for (tmp = 0; tmp < (len % 8) / 4; tmp++) { + object[len - tmp - 1] = object[len - tmp - 1] ^ subject[len - tmp - 1]; + } +#else for (tmp = 0; tmp < len / 4; tmp++) { - ( (int *) RSTRING(return_value)->ptr )[tmp] = ( (int *) RSTRING(self)->ptr )[tmp] ^ ( (int *) RSTRING(subject)->ptr )[tmp]; + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; } for (tmp = 0; tmp < (len % 4); tmp++) { - RSTRING(return_value)->ptr[len - tmp - 1] = RSTRING(self)->ptr[len - tmp - 1] ^ RSTRING(subject)->ptr[len - tmp - 1]; + object[len - tmp - 1] = object[len - tmp - 1] ^ subject[len - tmp - 1]; } +#endif +} - return return_value; +// +// Get a random degree +// +static guint32 +oneliner_context_get_degree(guint8 *context) +{ + gdouble f; + guint32 tmp = 0; + + f = RANDFLOAT(context); + while (f > 0) { + tmp++; + f = f - P[tmp]; + } + return tmp; } // -// Make str into str ^ subject +// Return the block size in bits for a string of the given length. // +static guint32 +oneliner_get_block_size(guint32 len) { + return 2; + if (len < 1024) { + return (guint32) ceil((len / 1024.0) * 8.0); + } else { + return (len * 8) / 1024; + } +} + static void -_string_xor2(char *str, char *subject, int len) +oneliner_superstring_get_block_from_data(guint8 *data, guint32 pos, guint32 block_size, guint8 *block) { - int tmp; - - for (tmp = 0; tmp < len / 4; tmp++) { - ( (int *) str )[tmp] = ( (int *) str )[tmp] ^ ( (int *) subject )[tmp]; + // + // Block sizes 1-7 are tricky, + // but all other sizes are divisible by 8 and therefore ok to do with a simple strncpy. + // + if (block_size < 8) { + // If the whole block fits within one char then we cant assume that we have permission + // to read the char after it, but if it DOESNT then we MUST assume that we have permission + // to read the char after it. Therefore the below fork where we read a char or a short from the data. + if ((pos + block_size - 1) / 8 == pos / 8) { + // Set the block content to whatever is at the char that contains the entire block. + *block = data[pos / 8]; + // Left shift it to get rid of any bits before it in the char. + *block = *block << pos % 8; + // Then right shift if all the way to the right to get the right number. + *block = *block >> 8 - block_size; + } else { + // Set a temporary short to whatever is at the first and second chat that contains the entire block. + guint16 short_containing_block = * (guint16 *) (data + (pos / 8)); + // Left shift it to get rid of any bits before it in the short. + short_containing_block = short_containing_block << pos % 8; + // Then right shift it all the way to the right to get the right number. + short_containing_block = short_containing_block >> 16 - block_size; + // Then set the block content to whatever is at the lower part of the short. + *block = (guint8) short_containing_block; + } + } else { + strncpy((gchar *) block, (gchar *) data + (pos / 8), block_size / 8); } - for (tmp = 0; tmp < (len % 4); tmp++) { - str[len - tmp - 1] = str[len - tmp - 1] ^ subject[len - tmp - 1]; - } } // -// Return an Array with bite size chunks of us +// Ensure that str->blocks contains a GArray with all the blocks of this superstring. // -static VALUE -string_hack(VALUE self, VALUE size_value) +static void +oneliner_superstring_build_blocks(oneliner_superstring *str, guint8 *data) { - if (NUM2INT(size_value) < 1) - rb_raise(rb_eTypeError, "argument to hack must be a positive integer > 0"); - - int size = NUM2INT(size_value); - VALUE rval = rb_ary_new(); - int tmp; + guint32 pos; + guint8 *tmp_block; + guint8 *tmp_data = g_new0(guint8, str->n_bytes_for_blocks); - for (tmp = 0; tmp < RSTRING(self)->len; tmp += size) { - rb_ary_push(rval, rb_str_new(RSTRING(self)->ptr + tmp, tmp + size < RSTRING(self)->len ? size : RSTRING(self)->len - tmp)); + strncpy((gchar *) tmp_data, (gchar *) data, str->n_bytes_for_blocks); + str->blocks = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + for (pos = 0; pos < str->n_bytes_for_blocks * 8; pos += str->block_size) { + tmp_block = g_new0(guint8, str->n_chars_in_block + 1); + oneliner_superstring_get_block_from_data(tmp_data, pos, str->block_size, tmp_block); + g_array_append_val(str->blocks, tmp_block); } - return rval; + g_free(tmp_data); } -// -// Make self into self ^ subject -// -static VALUE -string_xor2(VALUE self, VALUE subject) +static void +oneliner_superstring_set_data_from_block(guint8 *data, guint32 block_nr, guint32 block_size, guint8 *block) { - int tmp; - int len = RSTRING(self)->len; + // + // If the block size is less than 8 then we have some tricky business, otherwise + // we know that it is a multiple of 8, which makes it into a simple strncpy. + // + if (block_size < 8) { + // If the entire block fits within one byte then we can not assume that we can write + // the byte after, but if it doesnt then we MUST assume that we CAN write the byte + // after, therefore the below fork where we write a char or a long depending. + if ((block_nr * block_size) / 8 == (((block_nr + 1) * block_size) - 1) / 8) { + // Set the byte we want to write to the block content. + guint8 byte_to_write = *block; + // Left shift it enough so that it matches the segment of data we want to write. + byte_to_write = byte_to_write << 8 - block_size - ((block_nr * block_size) % 8); + // Then OR the corresponding byte in the data with the byte to write. Since + // the data is supposed to be initialized with zeroes this ought to do the trick. + data[(block_nr * block_size) / 8] = data[(block_nr * block_size) / 8] | byte_to_write; + } else { + // Set the short we want to write to the block content. + guint16 short_to_write = (guint16) *block; + // Left shift it enough so that it matches the segment of data we want to write. + short_to_write = short_to_write << 8 - (((block_nr + 1) * block_size) % 8); + // Then OR the corresponding short in the data with the short to write. Since + // the data is supposed to be initialized with zeroes this ought to do the trick. + * (guint16 *) (data + (block_nr * block_size) / 8) = * (guint16 *) (data + (block_nr * block_size) / 8) | short_to_write; + } + } else { + strncpy((gchar *) data + (block_nr * (block_size / 8)), (gchar *) block, block_size / 8); + } +} - Check_Type(subject, T_STRING); +static guint8 * +oneliner_superstring_build_data_from_blocks(guint32 n_bytes_for_blocks, + guint32 data_len, + guint32 block_size, + GArray *blocks) +{ + guint32 index; + guint8 *tmp_data = g_new0(guint8, n_bytes_for_blocks); + for (index = 0; index < blocks->len; index++) { + oneliner_superstring_set_data_from_block(tmp_data, index, block_size, g_array_index(blocks, guint8 *, index)); + } + return g_realloc(tmp_data, data_len); +} - if (len != RSTRING(subject)->len) - rb_raise(rb_eTypeError, "argument to xor must be of same length as receiver"); +static guint8 * +oneliner_superstring_build_data(oneliner_superstring *str) +{ + return oneliner_superstring_build_data_from_blocks(str->n_bytes_for_blocks, + str->data_len, + str->block_size, + str->bloks); +} - rb_str_modify(self); - _string_xor2(RSTRING(self)->ptr, RSTRING(subject)->ptr, len); +static void +oneliner_superstring_build_aux_blocks(oneliner_superstring *str) +{ + guint32 tmp; + oneliner_context *context = oneliner_context_new(); + guint32 n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->blocks->len); + oneliner_context_seed(context, (gint32) str->data_len); + str->aux_blocks = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + g_array_set_size(str->aux_blocks, n_aux_blocks_needed); + for (tmp = 0; tmp < str->blocks->len; tmp++) { + guint32 aux_block_nr = (guint32) RANDOM(context, n_aux_blocks_needed); + guint8 *data_block = g_array_index(str->blocks, guint8 *, tmp); + if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { + g_array_insert_val(str->aux_blocks, aux_block_nr, data_block); + } else { + guint8 *current_aux_block = g_array_index(str->aux_blocks, guint8 *, aux_block_nr); + oneliner_string_xor(current_aux_block, data_block, str->n_chars_in_block); + } + } - return self; + g_free(context); } // -// Get a random degree +// Encode a SuperString // static VALUE -superstring_get_degree(VALUE self, VALUE context) +oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) { - double f; - int tmp = 0; - - rb_str_modify(context); - f = ( (double) ( (unsigned int) _aes_random(RSTRING(context)->ptr) ) ) / ( (double) UINT_MAX ); - while (f > 0) { - tmp++; - f = f - P[tmp]; + oneliner_superstring *str; + + if (argc > 1) { + rb_raise(rb_eRuntimeError, "Oneliner::SuperString.new(String s = nil) takes at most 1 argument."); + } else if (argc == 1) { + Check_Type(argv[0], T_STRING); + + if (RSTRING(argv[0])->len < 1) + rb_raise(rb_eRuntimeError, "First argument to Oneliner::SuperString.new(String s = nil) must be a String of at least size 1 if given."); + + RB_ONELINER(self, str); + + // Make sure the length of our data (our String superclass content) is set. + if (str->data_len == 0) + str->data_len = (guint32) RSTRING(argv[0])->len; + // Make sure the block size we deem reasonable for this data length is set. + if (str->block_size == 0) + str->block_size = oneliner_get_block_size(str->data_len); + // Make sure the number of chars needed to contain such a block is set. + if (str->n_chars_in_block == 0) + str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); + // The number of bytes needed to create enough blocks to contain the data + // (non trivial since the last block of the data may overlap the end of the data + // and therefore need extra space at the end, but it may not be exactly one extra + // byte) + // is the data length * 8 (nr of bits in data) / block size rounded up (nr of blocks needed) + // multiplied by the block_size (minimum number of bits to contain those blocks) divided by 8 rounded up + // (minimum nr of bytes needed to contain those bits). + if (str->n_bytes_for_blocks == 0) + str->n_bytes_for_blocks = (guint32) ceil(ceil((str->data_len * 8.0) / str->block_size) * str->block_size / 8.0); + // Make sure that we have our blocks calculated properly. + if (str->blocks == NULL) + oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); + if (str->aux_blocks == NULL) + oneliner_superstring_build_aux_blocks(str); } - return INT2NUM(tmp); + return self; } -// -// Use context to check if the degree blocks adjacent to block -// can lead to anything good. -// -static VALUE -superstring_decode_multiple(VALUE self, VALUE block_data, VALUE blocks, VALUE nr_of_blocks) +static guint8 * +oneliner_superstring_encode(oneliner_superstring *str, guint32 len) { - VALUE get_func = rb_intern("[]"); - VALUE set_func = rb_intern("[]="); - VALUE this_block; - VALUE block = rb_funcall(block_data, get_func, 1, INT2NUM(0)); - VALUE block_numbers = rb_funcall(block_data, get_func, 1, INT2NUM(1)); - int degree = RARRAY(block_numbers)->len; - int tmp; - int got_new_block = 0; - int missing_blocks = degree; - int _nr_of_blocks = NUM2INT(nr_of_blocks); - int missing_block_nr; + oneliner_context *context = oneliner_context_new(); + guint8 *rval = g_new(guint8, len); + gint32 tmp; - for (tmp = 0; tmp < degree; tmp++) { - int block_nr = NUM2INT(rb_funcall(block_numbers, get_func, 1, INT2NUM(tmp))); - if ((this_block = rb_funcall(blocks, get_func, 1, INT2NUM(block_nr))) != Qnil) { - rb_str_modify(block); - _string_xor2(RSTRING(block)->ptr, RSTRING(this_block)->ptr, RSTRING(this_block)->len); - rb_funcall(block_numbers, set_func, 2, INT2NUM(tmp), Qnil); - missing_blocks--; - } else { - missing_block_nr = block_nr; - } - } + sranddev(); + tmp = (gint32) rand(); + oneliner_context_seed(context, tmp); - rb_funcall(block_numbers, rb_intern("compact!"), 0); + ( (guint32 *) rval )[0] = str->data_len; + ( (guint32 *) rval )[1] = (guint32) seed; + while ( + + g_free(context); +} - if (missing_blocks == 1) { - rb_funcall(blocks, set_func, 2, INT2NUM(missing_block_nr), block); - got_new_block = 1; +static void +oneliner_superstring_free(oneliner_superstring *str) +{ + guint32 tmp; + g_array_free(str->blocks, TRUE); + g_free(str); +} + +static VALUE +oneliner_superstring_alloc(VALUE klass) +{ + oneliner_superstring *str = g_new0(oneliner_superstring, 1); + return Data_Wrap_Struct(klass, NULL, oneliner_superstring_free, str); +} + +static VALUE +oneliner_superstring_get_blocks(GArray *container, guint32 len) +{ + guint32 tmp; + VALUE rval = rb_ary_new(); + for (tmp = 0; tmp < container->len; tmp++) { + guint8 *tmp_block = g_array_index(container, guint8 *, tmp); + rb_ary_push(rval, rb_str_new((gchar *) tmp_block, len)); } + return rval; +} - return got_new_block ? Qtrue : Qfalse; +static VALUE +oneliner_superstring_blocks(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return oneliner_superstring_get_blocks(str->blocks, str->n_chars_in_block); } +static VALUE +oneliner_superstring_aux_blocks(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return oneliner_superstring_get_blocks(str->aux_blocks, str->n_chars_in_block); +} -VALUE rb_superstring; -VALUE rb_context; +static VALUE +oneliner_superstring_to_s(VALUE self) +{ + oneliner_superstring *str; + VALUE rval; + guint8 *tmp_data; + RB_ONELINER(self, str); + tmp_data = oneliner_superstring_build_data(str); + rval = rb_str_new((gchar *) tmp_data, str->data_len); + g_free(tmp_data); + return rval; +} #ifdef __cplusplus extern "C" { @@ -267,21 +457,13 @@ void Init_oneliner_ext() { VALUE string = rb_const_get(rb_cObject, rb_intern("String")); rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), - "SuperString", - string); - rb_context = rb_define_class_under(rb_superstring, - "Context", - string); - - rb_define_const(rb_context, "INT_MAX", INT2NUM(INT_MAX)); - rb_define_method(rb_context, "initialize", context_initialize, -1); - rb_define_method(rb_context, "random", aes_random, -1); - rb_define_method(rb_context, "seed", aes_seed_context, 1); - rb_define_method(string, "^", string_xor, 1); - rb_define_method(string, "^=", string_xor2, 1); - rb_define_method(string, "hack", string_hack, 1); - rb_define_method(rb_superstring, "get_degree", superstring_get_degree, 1); - rb_define_method(rb_superstring, "decode_multiple", superstring_decode_multiple, 3); + "SuperString", + rb_cObject); + rb_define_alloc_func(rb_superstring, oneliner_superstring_alloc); + rb_define_method(rb_superstring, "initialize", oneliner_superstring_initialize, -1); + rb_define_method(rb_superstring, "blocks", oneliner_superstring_blocks, 0); + rb_define_method(rb_superstring, "aux_blocks", oneliner_superstring_aux_blocks, 0); + rb_define_method(rb_superstring, "to_s", oneliner_superstring_to_s, 0); } #ifdef __cplusplus } Modified: trunk/oneliner/lib/oneliner/superstring.rb =================================================================== --- trunk/oneliner/lib/oneliner/superstring.rb 2007-05-14 23:36:16 UTC (rev 273) +++ trunk/oneliner/lib/oneliner/superstring.rb 2007-05-18 12:49:21 UTC (rev 274) @@ -15,371 +15,3 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'set' -require 'digest/sha2' - -module Oneliner - - # - # A String subclass providing Online Code functionality. - # - class SuperString < String - - E = 0.01 - Q = 3 - F = (Math.log((E ** 2) / 4) / Math.log(1 - (E / 2))).abs.to_i - P = [0, (1 - ((1 + (1 / F)) / (1 + E)))] - 2.upto(F) do |i| - P << (((1 - P[1]) * F) / ((F - 1) * i * (i - 1))) - end - - # - # Will return a String containing +requested_size+ nr of bytes - # as an online coded chunk of blocks for this SuperString. - # - def encode(requested_size) - raise "requested size is too small for metadata (8 bytes)" unless requested_size > 7 - - ensure_encode_format - srand - seed = rand(Context::INT_MAX) - context = Context.new - context.seed(seed) - - rval = [self.size].pack("i") - rval << [seed].pack("i") - - blocks = [] - wanted_blocks = ((requested_size - 8) * 8) / @block_size - 1.upto(wanted_blocks) do |n| - blocks << generate_check_block(context, n - 1) - end - - return rval + compact(blocks) - end - - # - # Will try to decode this SuperString using the given +chunk+ and all - # formerly given chunks. - # - # Returns whether decoding is done. - # - def decode!(chunk) - raise "#{chunk.inspect} is too small for metadata (8 bytes)" unless chunk.size > 7 - - @decode_done = nil - - context = Context.new - - requested_size = chunk[0..3].unpack("i").first - - ensure_decode_format(requested_size) - - the_seed = chunk[4..7].unpack("i").first - - chunk_data = build_chunk_data(chunk, context, the_seed) - - @known_nr_of_blocks += chunk_data.size - @known_chunks.unshift(chunk_data) - - if @known_nr_of_blocks > @nr_of_blocks - - nil while do_decode(context) - - if decode_done? - self.replace(compact(@blocks[0... at nr_of_data_blocks])[0...requested_size]) - return true - else - return false - end - - else - return false - end - end - - # - # Returns whether decoding is done. - # - def decode_done? - return false unless defined?(@decode_done) && defined?(@nr_of_data_blocks) - - unless @decode_done - data = @blocks[0... at nr_of_data_blocks] - @decode_done = data.compact.size == data.size - end - return @decode_done - end - - private - - # - # Misc stuff - # - - # - # Builds a Hash with index of each block in the +chunk+ - # paired with the block itself and the source blocks for - # that block determined using +context+ and +the_seed+. - # - def build_chunk_data(chunk, context, the_seed) - blocks_to_return = {} - - context.seed(the_seed) - - expand(chunk[8..-1]).each_with_index do |block, index| - this_degree = get_degree(context) - these_blocks = [] - this_degree.times do |m| - these_blocks << context.random(@nr_of_blocks) - end - - blocks_to_return[index] = [block, these_blocks] - end - - return blocks_to_return - end - - # - # Split +s+ up into @block_size (in bits if less than 8, otherwise closed matching nr of bytes) pieces - # and return them in an array. - # - def expand(s) - if @block_size < 8 - rval = s.unpack("b*").first - rval = rval.gsub(/(.{#{@block_size},#{@block_size}})/, "\\1#{"0" * (8 - @block_size)}") - rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 - rval = [rval].pack("b*") - return rval.split(//) - else - bytes_per_block = @block_size / 8 - rval = s - rval += "\000" * (bytes_per_block - (rval.size % bytes_per_block)) if (rval.size % bytes_per_block) > 0 - return rval.hack(bytes_per_block) - end - end - - # - # Glue +blocks+ together into a String. - # - def compact(blocks) - if @block_size < 8 - rval = blocks.join - rval = rval.unpack("b*") - rval = rval.first.gsub(/(.{#{@block_size},#{@block_size}}).{#{8 - @block_size},#{8 - @block_size}}/, - "\\1") - rval += "0" * (8 - (rval.size % 8)) if (rval.size % 8) > 0 - return [rval].pack("b*") - else - return blocks.join - end - end - - # - # Determine and save the nr of aux_blocks we want for this SuperString. - # - def set_nr_of_aux_blocks - @nr_of_aux_blocks ||= (0.55 * Q * E * @nr_of_data_blocks).ceil - end - - # - # Determine and save the block_size we want for this SuperString. - # - def set_block_size - unless defined?(@block_size) - if size < (256 + 128) - @block_size = 1 - else - @block_size = size / 256 - end - end - return @block_size - end - - # - # Determine and save the nr_of_blocks we want for this SuperString. - # - def set_nr_of_blocks - @nr_of_blocks ||= @blocks.size - end - - # - # Decoding stuff - # - - def do_decode(context) - found_new_block = false - @known_chunks.clone.each_with_index do |chunk_data, i| - this_chunk_found_new_block, this_chunk_informative = decode_chunk(chunk_data) - found_new_block = found_new_block || this_chunk_found_new_block - @known_chunks.delete(i) unless this_chunk_informative - end - return aux_decode || found_new_block - end - - def aux_decode - got_new_block = false - - @nr_of_data_blocks.upto(@nr_of_blocks - 1) do |i| - - aux_block = @blocks[i] - if aux_block - - source_blocks = @aux_hash[i] - if source_blocks.size == 1 - block_nr = source_blocks.first - - if @blocks[block_nr].nil? - @blocks[block_nr] = aux_block - got_new_block = true - @blocks[i] = nil - end - else - missing_blocks = source_blocks.size - missing_block = nil - xor_sum = aux_block - source_blocks.each do |block| - source_block = @blocks[block] - if source_block - missing_blocks -= 1 - xor_sum ^= source_block - else - missing_block = block - end - end - - if missing_blocks == 1 - @blocks[missing_block] = xor_sum - got_new_block = true - @blocks[i] = nil - end - end - end - end - - return got_new_block - end - - def decode_chunk(blocks) - got_new_block = false - got_informative_block = false - - blocks.clone.each do |index, block_data| - - block, block_numbers = block_data - - got_informative_block = true - - if block_numbers.size == 1 - block_nr = block_numbers.first - - if @blocks[block_nr].nil? - @blocks[block_nr] = block - got_new_block = true - blocks.delete(index) - end - else - if decode_multiple(block_data, @blocks, @nr_of_blocks) - got_new_block = true - blocks.delete(index) - end - end - - end - - return [got_new_block, got_informative_block] - end - - def generate_aux_hash - rval = Array.new(@nr_of_blocks) - - context = Context.new - context.seed(@nr_of_data_blocks) - - 0.upto(@nr_of_data_blocks - 1) do |i| - 1.upto(Q) do - aux_block_nr = @nr_of_data_blocks + context.random(@nr_of_aux_blocks) - (rval[aux_block_nr] ||= []) << i - end - end - - return rval - end - - def ensure_decode_format(requested_size) - unless defined?(@blocks) - self.concat("\000" * requested_size) - set_block_size - @nr_of_data_blocks = expand(self).size - set_nr_of_aux_blocks - @blocks = Array.new(@nr_of_data_blocks) - @blocks += Array.new(@nr_of_aux_blocks) - set_nr_of_blocks - @aux_hash = generate_aux_hash - @known_chunks = [] - @known_nr_of_blocks = 0 - @known_block_nrs_by_seed = {} - end - end - - def ensure_size(requested_size) - if size == 0 - concat("\000" * requested_size) - @decoded_blocks = Set.new - elsif size != requested_size - raise "size of #{self} (#{size}) is wrong, should be #{requested_size}" - end - end - - # - # Encoding stuff - # - - def generate_check_block(context, n) - degree = get_degree(context) - - block_nr = context.random(@nr_of_blocks) - rval = @blocks[block_nr] - - 2.upto(degree) do - block_nr = context.random(@nr_of_blocks) - rval ^= @blocks[block_nr] - end - return rval - end - - def generate_aux_blocks - rval = Array.new(@nr_of_aux_blocks) - - context = Context.new - context.seed(@nr_of_data_blocks) - - b_size = nil - @blocks.each_with_index do |b, i| - 1.upto(Q) do - aux_block_nr = context.random(@nr_of_aux_blocks) - if rval[aux_block_nr].nil? - rval[aux_block_nr] = b - else - rval[aux_block_nr] ^= b - end - end - end - - return rval - end - - def ensure_encode_format - unless defined?(@blocks) - set_block_size - @blocks = expand(self) - @nr_of_data_blocks = @blocks.size - set_nr_of_aux_blocks - @blocks += generate_aux_blocks - @nr_of_blocks = @blocks.size - end - end - - end - -end Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-14 23:36:16 UTC (rev 273) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-18 12:49:21 UTC (rev 274) @@ -3,48 +3,21 @@ class SuperStringTest < Test::Unit::TestCase - def test_decoding - 1.upto(8) do |i| - print "[#{5 ** i}]" - STDOUT.flush - size_test(5 ** i) + def test_blocks + 8.times do |m| + n = 128 * m + 63 + print("(#{n})") + s1 = "x" * n + s2 = Oneliner::SuperString.new(s1) + assert_equal(s1, s2.to_s) end - end - - def test_hack - 20.times do - size = rand(1024) - s = "x" * size - bites = rand(128) + 1 - l = s.hack(bites) - assert_equal((size.to_f / bites).ceil, l.size) - assert_equal(s, l.join) - l.each_with_index do |e, index| - if index == l.size - 1 - assert(e.size <= bites) - else - assert_equal(bites, e.size, "element #{index} of #{l.inspect} should be of size #{bites}") - end - end + 1.upto(4) do |m| + n = 1024 * m + 511 + print("(#{n})") + s1 = "x" * n + s2 = Oneliner::SuperString.new(s1) + assert_equal(s1, s2.to_s) end end - def test_weird_string - s = Oneliner::SuperString.new(open(File.join(File.dirname(__FILE__), 'weird_string')).read) - s.encode(20) - end - - private - - def size_test(size) - s = Oneliner::SuperString.new(" " * size) - s2 = Oneliner::SuperString.new - assert(!s2.decode!(s.encode(s.size + 8))) - while !s2.decode!(s.encode((s.size * (0.1)).ceil + 8)) - print "." - STDOUT.flush - end - assert_equal(s, s2) - end - end From nobody at rubyforge.org Sat May 19 15:32:26 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 19 May 2007 15:32:26 -0400 (EDT) Subject: [Archipelago-submits] [275] trunk/oneliner: a bit further along the road Message-ID: <20070519193226.4E2C95240BB9@rubyforge.org> Revision: 275 Author: zond Date: 2007-05-19 15:32:26 -0400 (Sat, 19 May 2007) Log Message: ----------- a bit further along the road Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/tests/superstring_test.rb Added Paths: ----------- trunk/oneliner/tests/string_test.rb Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-18 12:49:21 UTC (rev 274) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-19 19:32:26 UTC (rev 275) @@ -31,19 +31,39 @@ // Utility macros. // #ifdef ONELINER_DEBUG -#define DEBUG(s, ...) fprintf(stderr, "DEBUG: "); fprintf(stderr, s, ## __VA_ARGS__); fprintf(stderr, "\n"); fflush(NULL); -#define IFDEBUG(s) s; -#define BITSTRING_DEBUG(msg,str,len) fprintf(stderr, "DEBUG: %s: ", (msg)); rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("unpack"), 1, rb_str_new2("B*"))); fprintf(stderr, "\n"); fflush(NULL) +#define DEBUG(s, ...) { fprintf(stderr, "DEBUG: "); fprintf(stderr, s, ## __VA_ARGS__); fprintf(stderr, "\n"); fflush(NULL); } +#define IFDEBUG(s) s +#define BITSTRING_DEBUG(msg,str,len) { \ + fprintf(stderr, "DEBUG: %s: ", (msg)); \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), \ + rb_intern("print"), \ + 1, \ + rb_funcall(rb_funcall(rb_funcall(rb_str_new((gchar *) (str), (len)), \ + rb_intern("unpack"), \ + 1, \ + rb_str_new2("b*")), \ + rb_intern("first"), \ + 0), \ + rb_intern("gsub"), \ + 2, \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Regexp")), \ + rb_intern("new"), \ + 1, \ + rb_str_new2("(.{4,4})")), \ + rb_str_new2("\\1,"))); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } +#define STRING_DEBUG(msg,str,len) { fprintf(stderr, "DEBUG: %s: ", (msg)); rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); fprintf(stderr, "\n"); fflush(NULL); } #else #define DEBUG(s, ...) ; #define IFDEBUG(s) ; #define BITSTRING_DEBUG(msg,str,len) ; #endif -#define GUINT32MAX 0xffffffff #define RANDOM(context,max) (oneliner_context_random(context) % (max)) -#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) GUINT32MAX ) +#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) +#define COMBINE_BLOCK(str,block_no) (block_no < str->blocks->len ? g_array_index((str)->blocks, guint8 *, block_no) : g_array_index((str)->aux_blocks, guint8 *, block_no - str->blocks->len)) #define Q 3 #define E 0.01 @@ -145,6 +165,23 @@ } // +// Get a random degree +// +static guint32 +oneliner_context_get_degree(oneliner_context *context) +{ + gdouble f; + guint32 tmp = 0; + + f = RANDFLOAT(context); + while (f > 0) { + tmp++; + f = f - P[tmp]; + } + return tmp; +} + +// // Make object into object ^ subject // static void @@ -153,37 +190,27 @@ guint32 tmp; #ifdef G_HAVE_GINT64 - for (tmp = 0; tmp < len / 8; tmp++) { + for (tmp = 0; tmp < len / 8; tmp++) ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; - } - for (tmp = 0; tmp < (len % 8) / 4; tmp++) { - object[len - tmp - 1] = object[len - tmp - 1] ^ subject[len - tmp - 1]; - } + for (tmp = tmp * 2; tmp < len / 4; tmp++) + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; #else - for (tmp = 0; tmp < len / 4; tmp++) { + for (tmp = 0; tmp < len / 4; tmp++) ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; - } - for (tmp = 0; tmp < (len % 4); tmp++) { - object[len - tmp - 1] = object[len - tmp - 1] ^ subject[len - tmp - 1]; - } + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; #endif } -// -// Get a random degree -// -static guint32 -oneliner_context_get_degree(guint8 *context) +static VALUE +rb_oneliner_string_xor(VALUE self, VALUE object) { - gdouble f; - guint32 tmp = 0; - - f = RANDFLOAT(context); - while (f > 0) { - tmp++; - f = f - P[tmp]; - } - return tmp; + Check_Type(object, T_STRING); + rb_str_modify(self); + oneliner_string_xor((guint8 *) RSTRING(self)->ptr, (guint8 *) RSTRING(object)->ptr, MIN(RSTRING(self)->len, RSTRING(object)->len)); + return self; } // @@ -191,11 +218,10 @@ // static guint32 oneliner_get_block_size(guint32 len) { - return 2; if (len < 1024) { return (guint32) ceil((len / 1024.0) * 8.0); } else { - return (len * 8) / 1024; + return ((len / 128) / 8) * 8; } } @@ -204,31 +230,24 @@ { // // Block sizes 1-7 are tricky, - // but all other sizes are divisible by 8 and therefore ok to do with a simple strncpy. + // but all other sizes are divisible by 8 and therefore ok to do with a simple memcpy. // if (block_size < 8) { // If the whole block fits within one char then we cant assume that we have permission // to read the char after it, but if it DOESNT then we MUST assume that we have permission // to read the char after it. Therefore the below fork where we read a char or a short from the data. if ((pos + block_size - 1) / 8 == pos / 8) { - // Set the block content to whatever is at the char that contains the entire block. *block = data[pos / 8]; - // Left shift it to get rid of any bits before it in the char. - *block = *block << pos % 8; - // Then right shift if all the way to the right to get the right number. + *block = *block << (8 - ((pos + block_size) % 8)) % 8; *block = *block >> 8 - block_size; } else { - // Set a temporary short to whatever is at the first and second chat that contains the entire block. guint16 short_containing_block = * (guint16 *) (data + (pos / 8)); - // Left shift it to get rid of any bits before it in the short. - short_containing_block = short_containing_block << pos % 8; - // Then right shift it all the way to the right to get the right number. + short_containing_block = short_containing_block << (8 - ((pos + block_size) % 8)) % 8; short_containing_block = short_containing_block >> 16 - block_size; - // Then set the block content to whatever is at the lower part of the short. *block = (guint8) short_containing_block; } } else { - strncpy((gchar *) block, (gchar *) data + (pos / 8), block_size / 8); + memcpy(block, data + (pos / 8), sizeof(guint8) * (block_size / 8)); } } @@ -240,17 +259,15 @@ { guint32 pos; guint8 *tmp_block; - guint8 *tmp_data = g_new0(guint8, str->n_bytes_for_blocks); + guint8 tmp_data[str->n_bytes_for_blocks]; - strncpy((gchar *) tmp_data, (gchar *) data, str->n_bytes_for_blocks); + memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * str->data_len); str->blocks = g_array_new(FALSE, FALSE, sizeof(guint8 *)); for (pos = 0; pos < str->n_bytes_for_blocks * 8; pos += str->block_size) { tmp_block = g_new0(guint8, str->n_chars_in_block + 1); oneliner_superstring_get_block_from_data(tmp_data, pos, str->block_size, tmp_block); g_array_append_val(str->blocks, tmp_block); } - - g_free(tmp_data); } static void @@ -258,7 +275,7 @@ { // // If the block size is less than 8 then we have some tricky business, otherwise - // we know that it is a multiple of 8, which makes it into a simple strncpy. + // we know that it is a multiple of 8, which makes it into a simple memcpy. // if (block_size < 8) { // If the entire block fits within one byte then we can not assume that we can write @@ -268,7 +285,7 @@ // Set the byte we want to write to the block content. guint8 byte_to_write = *block; // Left shift it enough so that it matches the segment of data we want to write. - byte_to_write = byte_to_write << 8 - block_size - ((block_nr * block_size) % 8); + byte_to_write = byte_to_write << (block_nr * block_size) % 8; // Then OR the corresponding byte in the data with the byte to write. Since // the data is supposed to be initialized with zeroes this ought to do the trick. data[(block_nr * block_size) / 8] = data[(block_nr * block_size) / 8] | byte_to_write; @@ -276,27 +293,36 @@ // Set the short we want to write to the block content. guint16 short_to_write = (guint16) *block; // Left shift it enough so that it matches the segment of data we want to write. - short_to_write = short_to_write << 8 - (((block_nr + 1) * block_size) % 8); + short_to_write = short_to_write << (block_nr * block_size) % 8; // Then OR the corresponding short in the data with the short to write. Since // the data is supposed to be initialized with zeroes this ought to do the trick. * (guint16 *) (data + (block_nr * block_size) / 8) = * (guint16 *) (data + (block_nr * block_size) / 8) | short_to_write; } } else { - strncpy((gchar *) data + (block_nr * (block_size / 8)), (gchar *) block, block_size / 8); + memcpy((gchar *) data + (block_nr * (block_size / 8)), (gchar *) block, sizeof(guint8) * (block_size / 8)); } } +// +// Take the given blocks of size block_size needing n_bytes_for_blocks to be stored completely and +// concatenate them into a string, then return the first data_len bytes of the result. +// +// If prepend_size is larger than 0 then the prepend string will be prepended to the result. +// static guint8 * oneliner_superstring_build_data_from_blocks(guint32 n_bytes_for_blocks, guint32 data_len, guint32 block_size, - GArray *blocks) + GArray *blocks, + guint32 prepend_size, + guint8 *prepend) { guint32 index; - guint8 *tmp_data = g_new0(guint8, n_bytes_for_blocks); + guint8 *tmp_data = g_new0(guint8, n_bytes_for_blocks + prepend_size + 1); for (index = 0; index < blocks->len; index++) { - oneliner_superstring_set_data_from_block(tmp_data, index, block_size, g_array_index(blocks, guint8 *, index)); + oneliner_superstring_set_data_from_block(tmp_data + prepend_size, index, block_size, g_array_index(blocks, guint8 *, index)); } + memcpy((gchar *) tmp_data, (gchar *) prepend, sizeof(guint8) * prepend_size); return g_realloc(tmp_data, data_len); } @@ -306,7 +332,9 @@ return oneliner_superstring_build_data_from_blocks(str->n_bytes_for_blocks, str->data_len, str->block_size, - str->bloks); + str->blocks, + 0, + NULL); } static void @@ -315,17 +343,19 @@ guint32 tmp; oneliner_context *context = oneliner_context_new(); guint32 n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->blocks->len); + oneliner_context_seed(context, (gint32) str->data_len); - str->aux_blocks = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, n_aux_blocks_needed); + for (tmp = 0; tmp < str->blocks->len; tmp++) { guint32 aux_block_nr = (guint32) RANDOM(context, n_aux_blocks_needed); - guint8 *data_block = g_array_index(str->blocks, guint8 *, tmp); if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { - g_array_insert_val(str->aux_blocks, aux_block_nr, data_block); + g_array_index(str->aux_blocks, guint8 *, aux_block_nr) = (guint8 *) strdup(g_array_index(str->blocks, gchar *, tmp)); } else { - guint8 *current_aux_block = g_array_index(str->aux_blocks, guint8 *, aux_block_nr); - oneliner_string_xor(current_aux_block, data_block, str->n_chars_in_block); + oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, guint8 *, tmp), + str->n_chars_in_block); } } @@ -336,7 +366,7 @@ // Encode a SuperString // static VALUE -oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) +rb_oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) { oneliner_superstring *str; @@ -378,21 +408,54 @@ } static guint8 * -oneliner_superstring_encode(oneliner_superstring *str, guint32 len) +oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) { + guint32 degree = oneliner_context_get_degree(context); + guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); + guint8 *rval = (guint8 *) strdup((gchar *) COMBINE_BLOCK(str, block_nr)); + guint32 tmp; + + for (tmp = 2; tmp <= degree; tmp++) + oneliner_string_xor(rval, COMBINE_BLOCK(str, RANDOM(context, str->blocks->len + str->aux_blocks->len)), str->n_chars_in_block); + + return rval; +} + +static guint32 +oneliner_superstring_encode(oneliner_superstring *str, guint8 **buffer, guint32 len) +{ oneliner_context *context = oneliner_context_new(); - guint8 *rval = g_new(guint8, len); + GArray *rval_ary = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + guint8 prepend[8]; gint32 tmp; sranddev(); tmp = (gint32) rand(); oneliner_context_seed(context, tmp); - ( (guint32 *) rval )[0] = str->data_len; - ( (guint32 *) rval )[1] = (guint32) seed; - while ( + ( (guint32 *) prepend )[0] = str->data_len; + ( (guint32 *) prepend )[1] = (guint32) tmp; + + while ((rval_ary->len * str->block_size) / 8 < len) { + guint8 *check_block = oneliner_superstring_get_check_block(str, context); + g_array_append_val(rval_ary, check_block); + } + // Here I let tmp describe the number of bytes needed to contain the rval_ary considering the block + // size. And since we cant really truncate it at the end at this stage (like we can in the final build_data_from_blocks) + // the data_len argument is the same as the n_bytes_for_blocks argument. Also, we want to prepend the original data-len + // and seed, so we use the prepend argument. + tmp = (guint32) ceil((rval_ary->len * str->block_size) / 8); + *buffer = oneliner_superstring_build_data_from_blocks(tmp, + tmp, + str->block_size, + rval_ary, + 8, + prepend); g_free(context); + g_array_free(rval_ary, TRUE); + + return tmp; } static void @@ -400,11 +463,12 @@ { guint32 tmp; g_array_free(str->blocks, TRUE); + g_array_free(str->aux_blocks, TRUE); g_free(str); } static VALUE -oneliner_superstring_alloc(VALUE klass) +rb_oneliner_superstring_alloc(VALUE klass) { oneliner_superstring *str = g_new0(oneliner_superstring, 1); return Data_Wrap_Struct(klass, NULL, oneliner_superstring_free, str); @@ -423,7 +487,7 @@ } static VALUE -oneliner_superstring_blocks(VALUE self) +rb_oneliner_superstring_blocks(VALUE self) { oneliner_superstring *str; RB_ONELINER(self, str); @@ -431,7 +495,7 @@ } static VALUE -oneliner_superstring_aux_blocks(VALUE self) +rb_oneliner_superstring_aux_blocks(VALUE self) { oneliner_superstring *str; RB_ONELINER(self, str); @@ -439,7 +503,7 @@ } static VALUE -oneliner_superstring_to_s(VALUE self) +rb_oneliner_superstring_to_s(VALUE self) { oneliner_superstring *str; VALUE rval; @@ -451,19 +515,53 @@ return rval; } +static VALUE +rb_oneliner_superstring_block_size(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return INT2NUM(str->block_size); +} + +static VALUE +rb_oneliner_superstring_encode(VALUE self, VALUE size) +{ + guint8 *chunk; + VALUE rval; + oneliner_superstring *str; + guint32 chunk_size; + + Check_Type(size, T_FIXNUM); + if (NUM2INT(size) < 9) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString#encode(Fixnum size) needs a size larger than 8."); + + RB_ONELINER(self, str); + + chunk_size = oneliner_superstring_encode(str, &chunk, NUM2INT(size)); + rval = rb_str_new((gchar *) chunk, chunk_size); + + g_free(chunk); + + return rval; +} + #ifdef __cplusplus extern "C" { #endif void Init_oneliner_ext() { - VALUE string = rb_const_get(rb_cObject, rb_intern("String")); + VALUE rb_string = rb_define_class("String", rb_cObject); + rb_define_method(rb_string, "xor!", rb_oneliner_string_xor, 1); + rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), "SuperString", rb_cObject); - rb_define_alloc_func(rb_superstring, oneliner_superstring_alloc); - rb_define_method(rb_superstring, "initialize", oneliner_superstring_initialize, -1); - rb_define_method(rb_superstring, "blocks", oneliner_superstring_blocks, 0); - rb_define_method(rb_superstring, "aux_blocks", oneliner_superstring_aux_blocks, 0); - rb_define_method(rb_superstring, "to_s", oneliner_superstring_to_s, 0); + rb_define_alloc_func(rb_superstring, rb_oneliner_superstring_alloc); + rb_define_method(rb_superstring, "initialize", rb_oneliner_superstring_initialize, -1); + rb_define_method(rb_superstring, "blocks", rb_oneliner_superstring_blocks, 0); + rb_define_method(rb_superstring, "aux_blocks", rb_oneliner_superstring_aux_blocks, 0); + rb_define_method(rb_superstring, "to_s", rb_oneliner_superstring_to_s, 0); + rb_define_method(rb_superstring, "encode", rb_oneliner_superstring_encode, 1); + rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); } #ifdef __cplusplus } Added: trunk/oneliner/tests/string_test.rb =================================================================== --- trunk/oneliner/tests/string_test.rb (rev 0) +++ trunk/oneliner/tests/string_test.rb 2007-05-19 19:32:26 UTC (rev 275) @@ -0,0 +1,19 @@ + +require File.join(File.dirname(__FILE__), 'test_helper') + +class StringTest < Test::Unit::TestCase + + def test_xor + 100.times do |n| + print("(#{n})") + s = "x" * n + s2 = s.clone + s2.xor!("x" * n) + s3 = s2.clone + s3.xor!("x" * n) + assert_equal("\000" * n, s2) + assert_equal(s, s3) + end + end + +end Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-18 12:49:21 UTC (rev 274) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-19 19:32:26 UTC (rev 275) @@ -6,16 +6,16 @@ def test_blocks 8.times do |m| n = 128 * m + 63 - print("(#{n})") s1 = "x" * n s2 = Oneliner::SuperString.new(s1) + print("(#{s1.size}:#{s2.block_size})") assert_equal(s1, s2.to_s) end - 1.upto(4) do |m| + 2.upto(10) do |m| n = 1024 * m + 511 - print("(#{n})") s1 = "x" * n s2 = Oneliner::SuperString.new(s1) + print("(#{s1.size}:#{s2.block_size})") assert_equal(s1, s2.to_s) end end From nobody at rubyforge.org Sat May 19 17:05:01 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 19 May 2007 17:05:01 -0400 (EDT) Subject: [Archipelago-submits] [276] trunk/oneliner: beginning of decoder Message-ID: <20070519210501.BBDAD5240BB9@rubyforge.org> Revision: 276 Author: zond Date: 2007-05-19 17:05:01 -0400 (Sat, 19 May 2007) Log Message: ----------- beginning of decoder Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/tests/string_test.rb Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-19 19:32:26 UTC (rev 275) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-19 21:05:01 UTC (rev 276) @@ -31,7 +31,11 @@ // Utility macros. // #ifdef ONELINER_DEBUG -#define DEBUG(s, ...) { fprintf(stderr, "DEBUG: "); fprintf(stderr, s, ## __VA_ARGS__); fprintf(stderr, "\n"); fflush(NULL); } +#define DEBUG(s, ...) { \ + fprintf(stderr, "DEBUG: "); \ + fprintf(stderr, s, ## __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } #define IFDEBUG(s) s #define BITSTRING_DEBUG(msg,str,len) { \ fprintf(stderr, "DEBUG: %s: ", (msg)); \ @@ -53,7 +57,11 @@ rb_str_new2("\\1,"))); \ fprintf(stderr, "\n"); \ fflush(NULL); } -#define STRING_DEBUG(msg,str,len) { fprintf(stderr, "DEBUG: %s: ", (msg)); rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); fprintf(stderr, "\n"); fflush(NULL); } +#define STRING_DEBUG(msg,str,len) { \ + fprintf(stderr, "DEBUG: %s: ", (msg)); \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } #else #define DEBUG(s, ...) ; #define IFDEBUG(s) ; @@ -63,7 +71,6 @@ #define RANDOM(context,max) (oneliner_context_random(context) % (max)) #define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) -#define COMBINE_BLOCK(str,block_no) (block_no < str->blocks->len ? g_array_index((str)->blocks, guint8 *, block_no) : g_array_index((str)->aux_blocks, guint8 *, block_no - str->blocks->len)) #define Q 3 #define E 0.01 @@ -80,11 +87,18 @@ guint32 n_chars_in_block; // The length of the original data. guint32 data_len; - // The number of bytes needed to store all blocks. - // (not necessarily the same as the length of the original data) + // The number of blocks needed to contain that data. + guint32 n_blocks_needed; + // The number of bytes needed to store those blocks. guint32 n_bytes_for_blocks; + // The number of aux blocks needed for those blocks. + guint32 n_aux_blocks_needed; // The aux blocks of this superstrin. GArray *aux_blocks; + // The number of check blocks we have decoded so far. + guint32 n_known_check_blocks; + // Whether we have decided already that we are done decoding. + gboolean decode_done; } oneliner_superstring; // @@ -342,14 +356,13 @@ { guint32 tmp; oneliner_context *context = oneliner_context_new(); - guint32 n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->blocks->len); oneliner_context_seed(context, (gint32) str->data_len); str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->aux_blocks, n_aux_blocks_needed); + g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); for (tmp = 0; tmp < str->blocks->len; tmp++) { - guint32 aux_block_nr = (guint32) RANDOM(context, n_aux_blocks_needed); + guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { g_array_index(str->aux_blocks, guint8 *, aux_block_nr) = (guint8 *) strdup(g_array_index(str->blocks, gchar *, tmp)); } else { @@ -362,6 +375,27 @@ g_free(context); } +static void +oneliner_superstring_initialize(oneliner_superstring *str, guint32 data_len) +{ + // Make sure the length of our data (our String superclass content) is set. + str->data_len = (guint32) data_len; + // Make sure the block size we deem reasonable for this data length is set. + str->block_size = oneliner_get_block_size(str->data_len); + // Make sure the number of chars needed to contain such a block is set. + str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); + // Make sure the number of blocks needed to contain this data is set. + str->n_blocks_needed = (guint32) ceil((str->data_len * 8.0) / str->block_size); + // Make sure the number of bytes needed to contain those blocks is set. + str->n_bytes_for_blocks = (guint32) ceil((str->n_blocks_needed * str->block_size) / 8.0); + // Make sure the number of aux blocks needed for those blocks is set. + str->n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->n_blocks_needed); + // Make sure the number of known check blocks so far is set. + str->n_known_check_blocks = 0; + // Make sure we dont think we have decoded already. + str->decode_done = FALSE; +} + // // Encode a SuperString // @@ -379,44 +413,91 @@ rb_raise(rb_eRuntimeError, "First argument to Oneliner::SuperString.new(String s = nil) must be a String of at least size 1 if given."); RB_ONELINER(self, str); - - // Make sure the length of our data (our String superclass content) is set. - if (str->data_len == 0) - str->data_len = (guint32) RSTRING(argv[0])->len; - // Make sure the block size we deem reasonable for this data length is set. - if (str->block_size == 0) - str->block_size = oneliner_get_block_size(str->data_len); - // Make sure the number of chars needed to contain such a block is set. - if (str->n_chars_in_block == 0) - str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); - // The number of bytes needed to create enough blocks to contain the data - // (non trivial since the last block of the data may overlap the end of the data - // and therefore need extra space at the end, but it may not be exactly one extra - // byte) - // is the data length * 8 (nr of bits in data) / block size rounded up (nr of blocks needed) - // multiplied by the block_size (minimum number of bits to contain those blocks) divided by 8 rounded up - // (minimum nr of bytes needed to contain those bits). - if (str->n_bytes_for_blocks == 0) - str->n_bytes_for_blocks = (guint32) ceil(ceil((str->data_len * 8.0) / str->block_size) * str->block_size / 8.0); + + oneliner_superstring_initialize(str, RSTRING(argv[0])->len); + // Make sure that we have our blocks calculated properly. - if (str->blocks == NULL) - oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); - if (str->aux_blocks == NULL) - oneliner_superstring_build_aux_blocks(str); + oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); + oneliner_superstring_build_aux_blocks(str); } return self; } +static VALUE +oneliner_superstring_decode_done(oneliner_superstring *str) +{ + guint32 tmp; + if (str->decode_done) + return Qtrue; + if (str->blocks == NULL) + return Qfalse; + if (str->n_known_check_blocks < str->blocks->len) + return Qfalse; + for (tmp = 0; tmp < str->blocks->len; tmp++) + if (g_array_index(str->blocks, guint8 *, tmp) == NULL) + return Qfalse; + str->decode_done = TRUE; + return Qtrue; +} + +static VALUE +oneliner_superstring_decode(VALUE self, VALUE chunk) +{ + oneliner_superstring *str; + guint32 data_len; + guint32 seed; + guint32 blocks_needed; + + Check_Type(chunk, T_STRING); + + RB_ONELINER(self, str); + + if (RSTRING(chunk)->len < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString#decode(String chunk) needs an argument that is at least 8 characters long."); + + data_len = ((guint32 *) RSTRING(chunk)->ptr)[0]; + seed = ((guint32 *) RSTRING(chunk)->ptr)[1]; + + if (str->data_len == 0) { + str->data_len = data_len; + } else if (str->data_len != data_len) { + rb_raise(rb_eRuntimeError, "Oneliner::Superstring#decode(String chunk) needs all consecutive calls to be with arguments having the same first four characters. Didn't you use chunks produced using #encode calls from the same instance?"); + } + + if (str->blocks == NULL) { + oneliner_superstring_initialize(str, data_len); + str->blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); + g_array_set_size(str->blocks, str->n_blocks_needed); + str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); + g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); + } + + oneliner_superstring_add_to_graph(str, (guint8 *) RSTRING(chunk)->ptr, (guint32) RSTRING(chunk)->len); + + return oneliner_superstring_decode_done(str); +} + static guint8 * +oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_no) +{ + if (block_no < str->blocks->len) + return g_array_index(str->blocks, guint8 *, block_no); + else + return g_array_index(str->aux_blocks, guint8 *, block_no - str->blocks->len); +} + +static guint8 * oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) { guint32 degree = oneliner_context_get_degree(context); guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); - guint8 *rval = (guint8 *) strdup((gchar *) COMBINE_BLOCK(str, block_nr)); + guint8 *rval = (guint8 *) strdup((gchar *) oneliner_superstring_get_combined_block(str, block_nr)); guint32 tmp; for (tmp = 2; tmp <= degree; tmp++) - oneliner_string_xor(rval, COMBINE_BLOCK(str, RANDOM(context, str->blocks->len + str->aux_blocks->len)), str->n_chars_in_block); + oneliner_string_xor(rval, + oneliner_superstring_get_combined_block(str, RANDOM(context, str->blocks->len + str->aux_blocks->len)), + str->n_chars_in_block); return rval; } @@ -508,7 +589,10 @@ oneliner_superstring *str; VALUE rval; guint8 *tmp_data; + RB_ONELINER(self, str); + if (str->blocks == NULL) + return rb_str_new2(""); tmp_data = oneliner_superstring_build_data(str); rval = rb_str_new((gchar *) tmp_data, str->data_len); g_free(tmp_data); @@ -532,8 +616,8 @@ guint32 chunk_size; Check_Type(size, T_FIXNUM); - if (NUM2INT(size) < 9) - rb_raise(rb_eRuntimeError, "Oneliner::SuperString#encode(Fixnum size) needs a size larger than 8."); + if (NUM2INT(size) < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString#encode(Fixnum size) needs a size of at least 8."); RB_ONELINER(self, str); Modified: trunk/oneliner/tests/string_test.rb =================================================================== --- trunk/oneliner/tests/string_test.rb 2007-05-19 19:32:26 UTC (rev 275) +++ trunk/oneliner/tests/string_test.rb 2007-05-19 21:05:01 UTC (rev 276) @@ -4,7 +4,7 @@ class StringTest < Test::Unit::TestCase def test_xor - 100.times do |n| + [1,4,5,8,9,12,13,16,17,20,21].each do |n| print("(#{n})") s = "x" * n s2 = s.clone From nobody at rubyforge.org Sat May 19 18:04:15 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 19 May 2007 18:04:15 -0400 (EDT) Subject: [Archipelago-submits] [277] trunk/oneliner/ext/oneliner_ext.c: a bit more along the way Message-ID: <20070519220415.237155240BD8@rubyforge.org> Revision: 277 Author: zond Date: 2007-05-19 18:04:14 -0400 (Sat, 19 May 2007) Log Message: ----------- a bit more along the way Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-19 21:05:01 UTC (rev 276) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-19 22:04:14 UTC (rev 277) @@ -265,23 +265,44 @@ } } +static GArray * +oneliner_superstring_build_blocks_from_data(guint32 n_bytes_for_blocks, + guint32 data_len, + guint32 block_size, + guint32 n_chars_in_block, + guint32 n_blocks_needed, + guint8 *data) +{ + guint32 block_no; + guint8 *tmp_block; + guint8 tmp_data[n_bytes_for_blocks]; + GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + + g_array_set_size(rval, n_blocks_needed); + memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * data_len); + for (block_no = 0; block_no < n_blocks_needed; block_no++) { + guint32 pos = block_no * block_size; + tmp_block = g_new0(guint8, n_chars_in_block + 1); + oneliner_superstring_get_block_from_data(tmp_data, pos, block_size, tmp_block); + g_array_index(rval, guint8 *, block_no) = tmp_block; + } + + return rval; +} + + // -// Ensure that str->blocks contains a GArray with all the blocks of this superstring. +// Ensure that str->blocks contains a GArray with all the blocks of this data. // static void oneliner_superstring_build_blocks(oneliner_superstring *str, guint8 *data) { - guint32 pos; - guint8 *tmp_block; - guint8 tmp_data[str->n_bytes_for_blocks]; - - memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * str->data_len); - str->blocks = g_array_new(FALSE, FALSE, sizeof(guint8 *)); - for (pos = 0; pos < str->n_bytes_for_blocks * 8; pos += str->block_size) { - tmp_block = g_new0(guint8, str->n_chars_in_block + 1); - oneliner_superstring_get_block_from_data(tmp_data, pos, str->block_size, tmp_block); - g_array_append_val(str->blocks, tmp_block); - } + str->blocks = oneliner_superstring_build_blocks_from_data(str->n_bytes_for_blocks, + str->data_len, + str->block_size, + str->n_chars_in_block, + str->n_blocks_needed, + data); } static void @@ -440,6 +461,31 @@ return Qtrue; } +static GArray * +oneliner_superstring_get_blocks_from_chunk(oneliner_superstring *str, guint8 *chunk, guint32 chunk_len) +{ + return oneliner_superstring_build_blocks_from_data(chunk_len, + chunk_len, + str->block_size, + str->n_chars_in_block, + (chunk_len * 8) / str->block_size, + chunk); +} + +static void +oneliner_superstring_add_to_graph(oneliner_superstring *str, guint32 seed, guint8 *chunk, guint32 chunk_len) +{ + oneliner_context *context = oneliner_context_new(); + GArray *content_blocks; + + oneliner_context_seed(context, (gint32) seed); + + content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); + + g_free(content_blocks); + g_free(context); +} + static VALUE oneliner_superstring_decode(VALUE self, VALUE chunk) { @@ -472,7 +518,7 @@ g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); } - oneliner_superstring_add_to_graph(str, (guint8 *) RSTRING(chunk)->ptr, (guint32) RSTRING(chunk)->len); + oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); return oneliner_superstring_decode_done(str); } @@ -629,6 +675,28 @@ return rval; } +static VALUE +rb_oneliner_superstring_chunk_blocks(VALUE self, VALUE chunk) +{ + oneliner_superstring *str; + VALUE rval; + GArray *blocks; + + Check_Type(chunk, T_STRING); + + if (RSTRING(chunk)->len < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString.chunk_blocks(String chunk) needs an argument that is at least 8 characters long."); + + RB_ONELINER(self, str); + blocks = oneliner_superstring_get_blocks_from_chunk(str, + (guint8 *) RSTRING(chunk)->ptr + 8, + (guint32) RSTRING(chunk)->len - 8); + rval = oneliner_superstring_get_blocks(blocks, + str->n_chars_in_block); + g_array_free(blocks, TRUE); + return rval; +} + #ifdef __cplusplus extern "C" { #endif @@ -646,6 +714,7 @@ rb_define_method(rb_superstring, "to_s", rb_oneliner_superstring_to_s, 0); rb_define_method(rb_superstring, "encode", rb_oneliner_superstring_encode, 1); rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); + rb_define_method(rb_superstring, "chunk_blocks", rb_oneliner_superstring_chunk_blocks, 1); } #ifdef __cplusplus } From nobody at rubyforge.org Mon May 21 05:46:16 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 05:46:16 -0400 (EDT) Subject: [Archipelago-submits] [278] trunk/oneliner: a bit further still Message-ID: <20070521094616.6DE2D52409D5@rubyforge.org> Revision: 278 Author: zond Date: 2007-05-21 05:46:16 -0400 (Mon, 21 May 2007) Log Message: ----------- a bit further still Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/tests/superstring_test.rb Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-19 22:04:14 UTC (rev 277) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-21 09:46:16 UTC (rev 278) @@ -71,6 +71,9 @@ #define RANDOM(context,max) (oneliner_context_random(context) % (max)) #define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) +#define ALLOC_COPY8(dst,src,len) { \ + dst = g_new0(guint8, len + 1); \ + memcpy(dst, src, sizeof(guint8) * len); } #define Q 3 #define E 0.01 @@ -99,9 +102,27 @@ guint32 n_known_check_blocks; // Whether we have decided already that we are done decoding. gboolean decode_done; + // Our graph of check blocks. + GHashTable *graph; } oneliner_superstring; // +// An as yet mysterious block. +// +typedef struct { + guint8 *sum; + GHashTable *source_blocks; +} oneliner_xor_block; + +// +// An insertion to do into the graph of a superstring. +// +typedef struct { + guint32 source_block_nr; + oneliner_xor_block *check_block; +} oneliner_graph_insertion; + +// // A random context. // typedef guint8 oneliner_context; @@ -273,18 +294,18 @@ guint32 n_blocks_needed, guint8 *data) { - guint32 block_no; + guint32 block_nr; guint8 *tmp_block; guint8 tmp_data[n_bytes_for_blocks]; GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); g_array_set_size(rval, n_blocks_needed); memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * data_len); - for (block_no = 0; block_no < n_blocks_needed; block_no++) { - guint32 pos = block_no * block_size; + for (block_nr = 0; block_nr < n_blocks_needed; block_nr++) { + guint32 pos = block_nr * block_size; tmp_block = g_new0(guint8, n_chars_in_block + 1); oneliner_superstring_get_block_from_data(tmp_data, pos, block_size, tmp_block); - g_array_index(rval, guint8 *, block_no) = tmp_block; + g_array_index(rval, guint8 *, block_nr) = tmp_block; } return rval; @@ -385,7 +406,9 @@ for (tmp = 0; tmp < str->blocks->len; tmp++) { guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { - g_array_index(str->aux_blocks, guint8 *, aux_block_nr) = (guint8 *) strdup(g_array_index(str->blocks, gchar *, tmp)); + ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, gchar *, tmp), + str->n_chars_in_block); } else { oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), g_array_index(str->blocks, guint8 *, tmp), @@ -472,17 +495,190 @@ chunk); } +static guint8 * +oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr) +{ + if (block_nr < str->blocks->len) + return g_array_index(str->blocks, guint8 *, block_nr); + else + return g_array_index(str->aux_blocks, guint8 *, block_nr - str->blocks->len); +} + static void +oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) +{ + if (block_nr < str->blocks->len) + g_array_index(str->blocks, guint8 *, block_nr) = block; + else + g_array_index(str->aux_blocks, guint8 *, block_nr - str->blocks->len) = block; +} + +static oneliner_xor_block * +oneliner_xor_block_new(guint8 *data, guint32 len) +{ + oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); + ALLOC_COPY8(rval->sum, data, len); + rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); +} + +static gboolean +oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) +{ + g_free(key); + g_free(data); + return TRUE; +} + +static void +oneliner_xor_block_free(oneliner_xor_block *xor_block) +{ + g_free(xor_block->sum); + g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); + g_hash_table_destroy(xor_block->source_blocks); + g_free(xor_block); +} + +static void +oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) +{ + guint32 *uses; + guint32 *source; + if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { + (*uses)++; + } else { + uses = g_new(guint32, 1); + source = g_new(guint32, 1); + *uses = 1; + *source = source_block_nr; + g_hash_table_insert(xor_block->source_blocks, source, uses); + } +} + +static void +oneliner_xor_block_last_source_block_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) key; +} + +static guint32 +oneliner_xor_block_last_source_block(oneliner_xor_block *xor_block) +{ + guint32 source_block_nr; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_source_block_iterator, &source_block_nr); + return source_block_nr; +} + +static void +oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) data; +} + +static guint32 +oneliner_xor_block_last_uses(oneliner_xor_block *xor_block) +{ + guint32 uses; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_uses_iterator, &uses); + return uses; +} + +static gboolean +oneliner_xor_block_finished(oneliner_xor_block *xor_block) +{ + if ((g_hash_table_size(xor_block->source_blocks) == 1) && + ((oneliner_xor_block_last_uses(xor_block) % 2) == 1)) + return TRUE; + else + return FALSE; +} + +static oneliner_graph_insertion * +oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) +{ + oneliner_graph_insertion *rval = g_new0(oneliner_graph_insertion, 1); + rval->check_block = check_block; + rval->source_block_nr = source_block_nr; + return rval; +} + +static void +oneliner_graph_insertion_free_with_cb(gpointer insertion, gpointer user_data) +{ + oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); + g_free(insertion); +} + +static void +oneliner_insertion_execute(gpointer insertion, gpointer string) +{ + oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; + oneliner_superstring *str = (oneliner_superstring *) string; + guint32 *source_block_nr = g_new(guint32, 1); + GList *check_blocks = g_hash_table_lookup(str->graph, &(ins->source_block_nr)); + + *source_block_nr = ins->source_block_nr; + check_blocks = g_list_append(check_blocks, ins->check_block); + g_hash_table_insert(str->graph, source_block_nr, check_blocks); + + g_free(insertion); +} + +static void oneliner_superstring_add_to_graph(oneliner_superstring *str, guint32 seed, guint8 *chunk, guint32 chunk_len) { oneliner_context *context = oneliner_context_new(); GArray *content_blocks; + guint32 tmp; oneliner_context_seed(context, (gint32) seed); content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); - g_free(content_blocks); + for (tmp = 0; tmp < content_blocks->len; tmp++) { + guint32 degree = oneliner_context_get_degree(context); + if (degree == 1) { + guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); + oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp)); + oneliner_superstring_analyze(block_nr); + } else { + GList *inserts = NULL; + guint32 unknown_source_blocks = 0; + guint32 unknown_source_block_nr = 0; + guint32 tmp2; + oneliner_xor_block *xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), + str->n_chars_in_block); + + for (tmp2 = 0; tmp2 < degree; tmp2++) { + guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); + guint8 *block_content = oneliner_superstring_get_combined_block(str, block_nr); + if (block_content != NULL) { + oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); + } else { + oneliner_xor_block_add(xor_block, block_nr); + inserts = g_list_append(inserts, oneliner_graph_insertion_new(xor_block, block_nr)); + unknown_source_blocks++; + unknown_source_block_nr = block_nr; + } + } + + if (oneliner_xor_block_finished(xor_block)) { + gboolean free_check_block = TRUE; + + oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum); + + g_list_foreach(inserts, oneliner_graph_insertion_free_with_cb, &free_check_block); + g_list_free(inserts); + + oneliner_superstring_analyze(unknown_source_block_nr); + } else { + g_list_foreach(inserts, oneliner_insertion_execute, str); + g_list_free(inserts); + } + + } + } + + g_array_free(content_blocks, TRUE); g_free(context); } @@ -516,6 +712,7 @@ g_array_set_size(str->blocks, str->n_blocks_needed); str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); + str->graph = g_hash_table_new(g_int_hash, g_int_equal); } oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); @@ -524,22 +721,14 @@ } static guint8 * -oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_no) -{ - if (block_no < str->blocks->len) - return g_array_index(str->blocks, guint8 *, block_no); - else - return g_array_index(str->aux_blocks, guint8 *, block_no - str->blocks->len); -} - -static guint8 * oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) { guint32 degree = oneliner_context_get_degree(context); guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); - guint8 *rval = (guint8 *) strdup((gchar *) oneliner_superstring_get_combined_block(str, block_nr)); + guint8 *rval; guint32 tmp; + ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); for (tmp = 2; tmp <= degree; tmp++) oneliner_string_xor(rval, oneliner_superstring_get_combined_block(str, RANDOM(context, str->blocks->len + str->aux_blocks->len)), @@ -586,11 +775,32 @@ } static void +oneliner_superstring_free_and_remove_check_blocks(gpointer data, gpointer user_data) +{ + oneliner_xor_block_free((oneliner_xor_block *) data); +} + +static gboolean +oneliner_superstring_free_and_remove(gpointer source_block_nr, gpointer check_blocks, gpointer user_data) +{ + g_free(source_block_nr); + g_list_foreach((GList *) check_blocks, oneliner_superstring_free_and_remove_check_blocks, NULL); + g_list_free((GList *) check_blocks); + return TRUE; +} + +static void oneliner_superstring_free(oneliner_superstring *str) { guint32 tmp; - g_array_free(str->blocks, TRUE); - g_array_free(str->aux_blocks, TRUE); + if (str->blocks != NULL) + g_array_free(str->blocks, TRUE); + if (str->aux_blocks != NULL) + g_array_free(str->aux_blocks, TRUE); + if (str->graph != NULL) { + g_hash_table_foreach_remove(str->graph, oneliner_superstring_free_and_remove, NULL); + g_hash_table_destroy(str->graph); + } g_free(str); } Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-19 22:04:14 UTC (rev 277) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-21 09:46:16 UTC (rev 278) @@ -3,6 +3,13 @@ class SuperStringTest < Test::Unit::TestCase + def test_encode_size + s = Oneliner::SuperString.new("hehu") + 8.upto(20) do |n| + assert_equal((n - 8) * 8, s.chunk_blocks(s.encode(n)).size) + end + end + def test_blocks 8.times do |m| n = 128 * m + 63 From nobody at rubyforge.org Mon May 21 14:19:46 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 14:19:46 -0400 (EDT) Subject: [Archipelago-submits] [279] trunk/oneliner/ext: even more finished, now it compiles. Message-ID: <20070521181946.E92685240A4A@rubyforge.org> Revision: 279 Author: zond Date: 2007-05-21 14:19:46 -0400 (Mon, 21 May 2007) Log Message: ----------- even more finished, now it compiles. lets hurt our minds by debugging it... Modified Paths: -------------- trunk/oneliner/ext/extconf.rb trunk/oneliner/ext/oneliner_ext.c Modified: trunk/oneliner/ext/extconf.rb =================================================================== --- trunk/oneliner/ext/extconf.rb 2007-05-21 09:46:16 UTC (rev 278) +++ trunk/oneliner/ext/extconf.rb 2007-05-21 18:19:46 UTC (rev 279) @@ -36,7 +36,10 @@ crash "libglib-2.0 needed" end -$CFLAGS += " -D ONELINER_DEBUG" if ARGV.include?("-d") +if ARGV.include?("-d") + $CFLAGS += " -D ONELINER_DEBUG" + $CFLAGS.gsub!(/-O./, "-O0") +end $CFLAGS += " -g -gdwarf-2 -g3 " + `pkg-config --cflags --libs glib-2.0`.strip Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-21 09:46:16 UTC (rev 278) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-21 18:19:46 UTC (rev 279) @@ -31,7 +31,7 @@ // Utility macros. // #ifdef ONELINER_DEBUG -#define DEBUG(s, ...) { \ +#define DEBUG(s, ...) { \ fprintf(stderr, "DEBUG: "); \ fprintf(stderr, s, ## __VA_ARGS__); \ fprintf(stderr, "\n"); \ @@ -71,9 +71,9 @@ #define RANDOM(context,max) (oneliner_context_random(context) % (max)) #define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) -#define ALLOC_COPY8(dst,src,len) { \ - dst = g_new0(guint8, len + 1); \ - memcpy(dst, src, sizeof(guint8) * len); } +#define ALLOC_COPY8(dst,src,len) { \ + (dst) = g_new0(guint8, (len) + 1); \ + memcpy((dst), (src), sizeof(guint8) * (len)); } #define Q 3 #define E 0.01 @@ -84,6 +84,14 @@ typedef struct { // The blocks of this superstring. GArray *blocks; + // The aux blocks of this superstring. + GArray *aux_blocks; + // Our graph of check blocks. + GArray *graph; + // Our graph of aux blocks for the source blocks. + GArray *aux_graph_for_source_blocks; + // Our graph of aux blocks for the aux blocks themselves. + GArray *aux_graph_for_aux_blocks; // The size of each block in bits. guint32 block_size; // The number of guint8's needed to contain those bits. @@ -96,163 +104,32 @@ guint32 n_bytes_for_blocks; // The number of aux blocks needed for those blocks. guint32 n_aux_blocks_needed; - // The aux blocks of this superstrin. - GArray *aux_blocks; // The number of check blocks we have decoded so far. guint32 n_known_check_blocks; // Whether we have decided already that we are done decoding. gboolean decode_done; - // Our graph of check blocks. - GHashTable *graph; } oneliner_superstring; // -// An as yet mysterious block. -// -typedef struct { - guint8 *sum; - GHashTable *source_blocks; -} oneliner_xor_block; - -// -// An insertion to do into the graph of a superstring. -// -typedef struct { - guint32 source_block_nr; - oneliner_xor_block *check_block; -} oneliner_graph_insertion; - -// // A random context. // typedef guint8 oneliner_context; -// -// The distribution of degrees. -// -static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; - -// -// Encrypt the context again -// +static guint8 * +oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr); static void -oneliner_context_randomize(oneliner_context *context) -{ - AES_KEY key; +oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr); - AES_set_encrypt_key((guint8 *) "0123456789012345", 128, &key); +#include "context.c" +#include "string.c" +#include "xor_block.c" +#include "graph_insertion.c" - AES_encrypt((guint8 *) context + 4, - (guint8 *) context + 4, - &key); - * (guint32 *) context = 1; -} - // -// Fill the buffer of context with seed and randomize it. -// -static gint32 -oneliner_context_seed(oneliner_context *context, gint32 seed) -{ - gint32 tmp; - - for (tmp = 1; tmp < 5; tmp++) - ( (gint32 *) context )[tmp] = seed; - - oneliner_context_randomize(context); - - return seed; -} - -// -// Return an int that is the next random in the context -// -static gint32 -oneliner_context_random(oneliner_context *context) -{ - gint32 *int_context = (gint32 *) context; - if (int_context[0] < 5) { - gint32 return_value = int_context[int_context[0]]; - int_context[0]++; - return return_value; - } else { - oneliner_context_randomize(context); - return oneliner_context_random(context); - } -} - -// -// Initialize a context. -// -static oneliner_context * -oneliner_context_new() -{ - return (oneliner_context *) g_new0(guint8, 4 * 5); -} - -// -// Free a context. -// -static void -oneliner_context_free(oneliner_context *context) -{ - g_free(context); -} - -// -// Get a random degree -// -static guint32 -oneliner_context_get_degree(oneliner_context *context) -{ - gdouble f; - guint32 tmp = 0; - - f = RANDFLOAT(context); - while (f > 0) { - tmp++; - f = f - P[tmp]; - } - return tmp; -} - -// -// Make object into object ^ subject -// -static void -oneliner_string_xor(guint8 *object, guint8 *subject, guint32 len) -{ - guint32 tmp; - -#ifdef G_HAVE_GINT64 - for (tmp = 0; tmp < len / 8; tmp++) - ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; - for (tmp = tmp * 2; tmp < len / 4; tmp++) - ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; - for (tmp = tmp * 4; tmp < len; tmp++) - object[tmp] = object[tmp] ^ subject[tmp]; -#else - for (tmp = 0; tmp < len / 4; tmp++) - ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; - for (tmp = tmp * 4; tmp < len; tmp++) - object[tmp] = object[tmp] ^ subject[tmp]; -#endif -} - -static VALUE -rb_oneliner_string_xor(VALUE self, VALUE object) -{ - Check_Type(object, T_STRING); - rb_str_modify(self); - oneliner_string_xor((guint8 *) RSTRING(self)->ptr, (guint8 *) RSTRING(object)->ptr, MIN(RSTRING(self)->len, RSTRING(object)->len)); - return self; -} - -// // Return the block size in bits for a string of the given length. // static guint32 -oneliner_get_block_size(guint32 len) { +oneliner_superstring_get_block_size(guint32 len) { if (len < 1024) { return (guint32) ceil((len / 1024.0) * 8.0); } else { @@ -260,6 +137,9 @@ } } +// +// Fill *block with a block_size (bitwise) piece of *data from pos (bitwise). +// static void oneliner_superstring_get_block_from_data(guint8 *data, guint32 pos, guint32 block_size, guint8 *block) { @@ -286,6 +166,11 @@ } } +// +// Take *data and return a GArray * with all the block_size blocks it contains. +// Needs hints as to how many bytes we need to contain all blocks, how long *data is, +// how many chars each block needs and how many blocks we need in total. +// static GArray * oneliner_superstring_build_blocks_from_data(guint32 n_bytes_for_blocks, guint32 data_len, @@ -326,6 +211,9 @@ data); } +// +// Take the block_size (bitwise) content of *block and insert it in *data at block_nr. +// static void oneliner_superstring_set_data_from_block(guint8 *data, guint32 block_nr, guint32 block_size, guint8 *block) { @@ -382,6 +270,9 @@ return g_realloc(tmp_data, data_len); } +// +// Return the guint8 * that the given *str describes with its blocks. +// static guint8 * oneliner_superstring_build_data(oneliner_superstring *str) { @@ -393,6 +284,9 @@ NULL); } +// +// Create the aux_blocks GArray for *str using its blocks and length. +// static void oneliner_superstring_build_aux_blocks(oneliner_superstring *str) { @@ -403,29 +297,35 @@ str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - for (tmp = 0; tmp < str->blocks->len; tmp++) { - guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); - if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { - ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), - g_array_index(str->blocks, gchar *, tmp), - str->n_chars_in_block); - } else { - oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), - g_array_index(str->blocks, guint8 *, tmp), - str->n_chars_in_block); + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { + guint32 tmp2; + for (tmp2 = 0; tmp2 < Q; tmp2++) { + guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); + if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { + ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, gchar *, tmp), + str->n_chars_in_block); + } else { + oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, guint8 *, tmp), + str->n_chars_in_block); + } } } g_free(context); } +// +// Initialize all the precalculated state of *str using data_len. +// static void oneliner_superstring_initialize(oneliner_superstring *str, guint32 data_len) { // Make sure the length of our data (our String superclass content) is set. str->data_len = (guint32) data_len; // Make sure the block size we deem reasonable for this data length is set. - str->block_size = oneliner_get_block_size(str->data_len); + str->block_size = oneliner_superstring_get_block_size(str->data_len); // Make sure the number of chars needed to contain such a block is set. str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); // Make sure the number of blocks needed to contain this data is set. @@ -441,7 +341,7 @@ } // -// Encode a SuperString +// Initialize a superstring using (possibly) a String to encode. // static VALUE rb_oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) @@ -467,6 +367,9 @@ return self; } +// +// Returns whether *str is done decoding. +// static VALUE oneliner_superstring_decode_done(oneliner_superstring *str) { @@ -475,15 +378,19 @@ return Qtrue; if (str->blocks == NULL) return Qfalse; - if (str->n_known_check_blocks < str->blocks->len) + if (str->n_known_check_blocks < str->n_blocks_needed) return Qfalse; - for (tmp = 0; tmp < str->blocks->len; tmp++) + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) if (g_array_index(str->blocks, guint8 *, tmp) == NULL) return Qfalse; str->decode_done = TRUE; return Qtrue; } +// +// Returns a GArray * containing all the blocks described by *chunk of length chunk_len +// in the context of *str (its block_size, n_chars_in_block etc). +// static GArray * oneliner_superstring_get_blocks_from_chunk(oneliner_superstring *str, guint8 *chunk, guint32 chunk_len) { @@ -495,162 +402,180 @@ chunk); } +// +// Return the guint8 * at either source or aux block with index block_nr in *str. +// static guint8 * oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr) { - if (block_nr < str->blocks->len) + if (block_nr < str->n_blocks_needed) return g_array_index(str->blocks, guint8 *, block_nr); else - return g_array_index(str->aux_blocks, guint8 *, block_nr - str->blocks->len); + return g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed); } +// +// Set either the source of aux block at block_nr of *str to *block. +// static void oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) { - if (block_nr < str->blocks->len) - g_array_index(str->blocks, guint8 *, block_nr) = block; - else - g_array_index(str->aux_blocks, guint8 *, block_nr - str->blocks->len) = block; + if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { + ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); + } else if (g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { + ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed), block, str->n_chars_in_block); + } } -static oneliner_xor_block * -oneliner_xor_block_new(guint8 *data, guint32 len) +static void +oneliner_superstring_analyze_source_block_with_array(oneliner_superstring *str, + GArray *ary, + guint32 found_block_nr) { - oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); - ALLOC_COPY8(rval->sum, data, len); - rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); -} + guint32 source_block_nr; + GList *list_element; + GList *list_head = g_array_index(ary, GList *, found_block_nr); + oneliner_xor_block *xor_block; -static gboolean -oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) -{ - g_free(key); - g_free(data); - return TRUE; -} + // For each xor_block-containing item in the list. + for (list_element = list_head; list_element != NULL; list_element = g_list_next(list_element)) { + // Fetch its xor_block + xor_block = (oneliner_xor_block *) list_element->data; -static void -oneliner_xor_block_free(oneliner_xor_block *xor_block) -{ - g_free(xor_block->sum); - g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); - g_hash_table_destroy(xor_block->source_blocks); - g_free(xor_block); -} + // Apply this new knowledge to it. + oneliner_xor_block_apply(xor_block, + str, + found_block_nr); + + // + // If that meant that it is finished then dance the dance of setting the combined block, + // freeing the check block, removing it from the GList of check blocks for that combined block, + // and analyzing the results. + // + // Otherwise if it is empty, just free it and remove it. + // + if (XOR_BLOCK_FINISHED(xor_block)) { -static void -oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) -{ - guint32 *uses; - guint32 *source; - if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { - (*uses)++; - } else { - uses = g_new(guint32, 1); - source = g_new(guint32, 1); - *uses = 1; - *source = source_block_nr; - g_hash_table_insert(xor_block->source_blocks, source, uses); + // Find the source block that it defines. + source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + + // And set it. + oneliner_superstring_set_combined_block(str, + source_block_nr, + xor_block->sum); + // Then free the check block. + oneliner_xor_block_free(xor_block); + + // Then remove it from our unresolved check blocks so that we can run analyze safely again. + g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); + + // Then remove the list element that contained this check block. + g_list_free_1(list_element); + + // And now analyze what the newly found source block led to. + // (Right, it can be an aux block as well, but my logic is still correct, I believe.) + oneliner_superstring_analyze(str, source_block_nr); + } else if (XOR_BLOCK_EMPTY(xor_block)) { + // Free the check block. + oneliner_xor_block_free(xor_block); + // Remove it from our unresolved list. + g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); + // And remove the list element. + g_list_free_1(list_element); + } } } static void -oneliner_xor_block_last_source_block_iterator(gpointer key, gpointer data, gpointer user_data) +oneliner_superstring_analyze_source_block(oneliner_superstring *str, guint32 found_block_nr) { - * (guint32 *) user_data = * (guint32 *) key; + oneliner_superstring_analyze_source_block_with_array(str, + str->graph, + found_block_nr); + + oneliner_superstring_analyze_source_block_with_array(str, + str->aux_graph_for_source_blocks, + found_block_nr); } -static guint32 -oneliner_xor_block_last_source_block(oneliner_xor_block *xor_block) -{ - guint32 source_block_nr; - g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_source_block_iterator, &source_block_nr); - return source_block_nr; -} - static void -oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) +oneliner_superstring_analyze_aux_block(oneliner_superstring *str, guint32 found_block_nr) { - * (guint32 *) user_data = * (guint32 *) data; -} + oneliner_xor_block *xor_block; -static guint32 -oneliner_xor_block_last_uses(oneliner_xor_block *xor_block) -{ - guint32 uses; - g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_uses_iterator, &uses); - return uses; -} + if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed)) != NULL) { + oneliner_xor_block_set_sum(xor_block, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); + if (XOR_BLOCK_FINISHED(xor_block)) { + guint32 source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); -static gboolean -oneliner_xor_block_finished(oneliner_xor_block *xor_block) -{ - if ((g_hash_table_size(xor_block->source_blocks) == 1) && - ((oneliner_xor_block_last_uses(xor_block) % 2) == 1)) - return TRUE; - else - return FALSE; -} + oneliner_superstring_set_combined_block(str, + source_block_nr, + xor_block->sum); + oneliner_xor_block_free(xor_block); + + g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed) = NULL; -static oneliner_graph_insertion * -oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) -{ - oneliner_graph_insertion *rval = g_new0(oneliner_graph_insertion, 1); - rval->check_block = check_block; - rval->source_block_nr = source_block_nr; - return rval; + oneliner_superstring_analyze(str, source_block_nr); + } else if (XOR_BLOCK_EMPTY(xor_block)) { + oneliner_xor_block_free(xor_block); + g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed) = NULL; + } + } } static void -oneliner_graph_insertion_free_with_cb(gpointer insertion, gpointer user_data) +oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) { - oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); - g_free(insertion); + if (found_block_nr < str->n_blocks_needed) { + oneliner_superstring_analyze_source_block(str, found_block_nr); + } else { + oneliner_superstring_analyze_aux_block(str, found_block_nr); + } } static void -oneliner_insertion_execute(gpointer insertion, gpointer string) -{ - oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; - oneliner_superstring *str = (oneliner_superstring *) string; - guint32 *source_block_nr = g_new(guint32, 1); - GList *check_blocks = g_hash_table_lookup(str->graph, &(ins->source_block_nr)); - - *source_block_nr = ins->source_block_nr; - check_blocks = g_list_append(check_blocks, ins->check_block); - g_hash_table_insert(str->graph, source_block_nr, check_blocks); - - g_free(insertion); -} - -static void oneliner_superstring_add_to_graph(oneliner_superstring *str, guint32 seed, guint8 *chunk, guint32 chunk_len) { oneliner_context *context = oneliner_context_new(); GArray *content_blocks; guint32 tmp; - + guint32 tmp2; + guint32 unknown_source_blocks; + guint32 unknown_source_block_nr; + GList *inserts; + oneliner_xor_block *xor_block; + guint32 degree; + guint32 block_nr; + guint8 *block_content; + oneliner_context_seed(context, (gint32) seed); content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); for (tmp = 0; tmp < content_blocks->len; tmp++) { - guint32 degree = oneliner_context_get_degree(context); + degree = oneliner_context_get_degree(context); if (degree == 1) { - guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); + block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp)); - oneliner_superstring_analyze(block_nr); + oneliner_superstring_analyze(str, block_nr); } else { - GList *inserts = NULL; - guint32 unknown_source_blocks = 0; - guint32 unknown_source_block_nr = 0; - guint32 tmp2; - oneliner_xor_block *xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), - str->n_chars_in_block); - + unknown_source_blocks = 0; + unknown_source_block_nr = 0; + inserts = NULL; + + xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), + str->n_chars_in_block, + TRUE); + for (tmp2 = 0; tmp2 < degree; tmp2++) { - guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); - guint8 *block_content = oneliner_superstring_get_combined_block(str, block_nr); + block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); + block_content = oneliner_superstring_get_combined_block(str, block_nr); if (block_content != NULL) { oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); } else { @@ -661,29 +586,67 @@ } } - if (oneliner_xor_block_finished(xor_block)) { - gboolean free_check_block = TRUE; - + if (XOR_BLOCK_FINISHED(xor_block)) { oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum); - g_list_foreach(inserts, oneliner_graph_insertion_free_with_cb, &free_check_block); + g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); g_list_free(inserts); - oneliner_superstring_analyze(unknown_source_block_nr); + oneliner_superstring_analyze(str, unknown_source_block_nr); } else { g_list_foreach(inserts, oneliner_insertion_execute, str); g_list_free(inserts); } } + (str->n_known_check_blocks)++; } g_array_free(content_blocks, TRUE); g_free(context); } +static void +oneliner_superstring_build_aux_graph(oneliner_superstring *str) +{ + oneliner_context *context = oneliner_context_new(); + guint32 tmp; + guint8 *zeroes = g_new0(guint8, str->n_chars_in_block); + guint32 tmp2; + guint32 aux_block_nr; + oneliner_xor_block *aux_block; + GList *aux_blocks; + + oneliner_context_seed(context, (gint32) str->data_len); + str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); + g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); + str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GList *)); + g_array_set_size(str->aux_graph_for_source_blocks, str->n_blocks_needed); + + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { + aux_blocks = NULL; + + for (tmp2 = 0; tmp2 < Q; tmp2++) { + aux_block_nr = RANDOM(context, str->n_aux_blocks_needed); + + if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { + aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE); + g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr); + } + + oneliner_xor_block_add(aux_block, tmp); + aux_blocks = g_list_append(aux_blocks, aux_block); + } + + g_array_index(str->aux_graph_for_source_blocks, GList *, tmp) = aux_blocks; + } + + g_free(zeroes); + g_free(context); +} + static VALUE -oneliner_superstring_decode(VALUE self, VALUE chunk) +rb_oneliner_superstring_decode(VALUE self, VALUE chunk) { oneliner_superstring *str; guint32 data_len; @@ -712,7 +675,8 @@ g_array_set_size(str->blocks, str->n_blocks_needed); str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - str->graph = g_hash_table_new(g_int_hash, g_int_equal); + str->graph = g_array_new(FALSE, TRUE, sizeof(GList *)); + oneliner_superstring_build_aux_graph(str); } oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); @@ -724,14 +688,14 @@ oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) { guint32 degree = oneliner_context_get_degree(context); - guint32 block_nr = RANDOM(context, str->blocks->len + str->aux_blocks->len); + guint32 block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); guint8 *rval; guint32 tmp; ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); for (tmp = 2; tmp <= degree; tmp++) oneliner_string_xor(rval, - oneliner_superstring_get_combined_block(str, RANDOM(context, str->blocks->len + str->aux_blocks->len)), + oneliner_superstring_get_combined_block(str, RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed)), str->n_chars_in_block); return rval; @@ -775,18 +739,24 @@ } static void -oneliner_superstring_free_and_remove_check_blocks(gpointer data, gpointer user_data) +oneliner_superstring_free_xor_block(gpointer xor_block, gpointer user_data) { - oneliner_xor_block_free((oneliner_xor_block *) data); + oneliner_xor_block_free((oneliner_xor_block *) xor_block); } -static gboolean -oneliner_superstring_free_and_remove(gpointer source_block_nr, gpointer check_blocks, gpointer user_data) +static void +oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, gboolean free_xor_blocks) { - g_free(source_block_nr); - g_list_foreach((GList *) check_blocks, oneliner_superstring_free_and_remove_check_blocks, NULL); - g_list_free((GList *) check_blocks); - return TRUE; + guint32 tmp; + for (tmp = 0; tmp < ary->len; tmp++) { + GList *list; + if ((list = (GList *) g_array_index(ary, GList *, tmp)) != NULL) { + if (free_xor_blocks) + g_list_foreach(list, oneliner_superstring_free_xor_block, NULL); + g_list_free(list); + } + } + g_array_free(ary, FALSE); } static void @@ -797,10 +767,15 @@ g_array_free(str->blocks, TRUE); if (str->aux_blocks != NULL) g_array_free(str->aux_blocks, TRUE); - if (str->graph != NULL) { - g_hash_table_foreach_remove(str->graph, oneliner_superstring_free_and_remove, NULL); - g_hash_table_destroy(str->graph); + if (str->graph != NULL) + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, TRUE); + if (str->aux_graph_for_aux_blocks != NULL) { + for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) + oneliner_xor_block_free((oneliner_xor_block *) g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)); } + if (str->aux_graph_for_source_blocks != NULL) + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, FALSE); + g_free(str); } From nobody at rubyforge.org Mon May 21 14:21:43 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 14:21:43 -0400 (EDT) Subject: [Archipelago-submits] [280] trunk/oneliner/ext: added the forgotten files. Message-ID: <20070521182143.20F325240A4F@rubyforge.org> Revision: 280 Author: zond Date: 2007-05-21 14:21:42 -0400 (Mon, 21 May 2007) Log Message: ----------- added the forgotten files. made a ruby binding for decode. Modified Paths: -------------- trunk/oneliner/ext/oneliner_ext.c Added Paths: ----------- trunk/oneliner/ext/context.c trunk/oneliner/ext/graph_insertion.c trunk/oneliner/ext/string.c trunk/oneliner/ext/xor_block.c Added: trunk/oneliner/ext/context.c =================================================================== --- trunk/oneliner/ext/context.c (rev 0) +++ trunk/oneliner/ext/context.c 2007-05-21 18:21:42 UTC (rev 280) @@ -0,0 +1,81 @@ + +// +// The distribution of degrees. +// +static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; + +// +// Encrypt the context again +// +static void +oneliner_context_randomize(oneliner_context *context) +{ + AES_KEY key; + + AES_set_encrypt_key((guint8 *) "0123456789012345", 128, &key); + + AES_encrypt((guint8 *) context + 4, + (guint8 *) context + 4, + &key); + * (guint32 *) context = 1; +} + +// +// Fill the buffer of context with seed and randomize it. +// +static gint32 +oneliner_context_seed(oneliner_context *context, gint32 seed) +{ + gint32 tmp; + + for (tmp = 1; tmp < 5; tmp++) + ( (gint32 *) context )[tmp] = seed; + + oneliner_context_randomize(context); + + return seed; +} + +// +// Return an int that is the next random in the context +// +static gint32 +oneliner_context_random(oneliner_context *context) +{ + gint32 *int_context = (gint32 *) context; + if (int_context[0] < 5) { + gint32 return_value = int_context[int_context[0]]; + int_context[0]++; + return return_value; + } else { + oneliner_context_randomize(context); + return oneliner_context_random(context); + } +} + +// +// Initialize a context. +// +static oneliner_context * +oneliner_context_new() +{ + return (oneliner_context *) g_new0(guint8, 4 * 5); +} + +// +// Get a random degree +// +static guint32 +oneliner_context_get_degree(oneliner_context *context) +{ + gdouble f; + guint32 tmp = 0; + + f = RANDFLOAT(context); + while (f > 0) { + tmp++; + f = f - P[tmp]; + } + return tmp; +} + Added: trunk/oneliner/ext/graph_insertion.c =================================================================== --- trunk/oneliner/ext/graph_insertion.c (rev 0) +++ trunk/oneliner/ext/graph_insertion.c 2007-05-21 18:21:42 UTC (rev 280) @@ -0,0 +1,41 @@ + +// +// An insertion to do into the graph of a superstring. +// +typedef struct { + guint32 source_block_nr; + oneliner_xor_block *check_block; +} oneliner_graph_insertion; + +static oneliner_graph_insertion * +oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) +{ + oneliner_graph_insertion *rval = g_new0(oneliner_graph_insertion, 1); + rval->check_block = check_block; + rval->source_block_nr = source_block_nr; + return rval; +} + +static void +oneliner_graph_insertion_free_with_check_block(gpointer insertion, gpointer user_data) +{ + oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); + g_free(insertion); +} + +static void +oneliner_insertion_execute(gpointer insertion, gpointer string) +{ + oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; + oneliner_superstring *str = (oneliner_superstring *) string; + + g_array_index(str->graph, + GList *, + ins->source_block_nr) = g_list_append(g_array_index(str->graph, + GList *, + ins->source_block_nr), + ins->check_block); + + g_free(insertion); +} + Modified: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-21 18:19:46 UTC (rev 279) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-21 18:21:42 UTC (rev 280) @@ -900,6 +900,7 @@ rb_define_method(rb_superstring, "encode", rb_oneliner_superstring_encode, 1); rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); rb_define_method(rb_superstring, "chunk_blocks", rb_oneliner_superstring_chunk_blocks, 1); + rb_define_method(rb_superstring, "decode", rb_oneliner_superstring_decode, 1); } #ifdef __cplusplus } Added: trunk/oneliner/ext/string.c =================================================================== --- trunk/oneliner/ext/string.c (rev 0) +++ trunk/oneliner/ext/string.c 2007-05-21 18:21:42 UTC (rev 280) @@ -0,0 +1,32 @@ +// +// Make object into object ^ subject +// +static void +oneliner_string_xor(guint8 *object, guint8 *subject, guint32 len) +{ + guint32 tmp; + +#ifdef G_HAVE_GINT64 + for (tmp = 0; tmp < len / 8; tmp++) + ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; + for (tmp = tmp * 2; tmp < len / 4; tmp++) + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; +#else + for (tmp = 0; tmp < len / 4; tmp++) + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; +#endif +} + +static VALUE +rb_oneliner_string_xor(VALUE self, VALUE object) +{ + Check_Type(object, T_STRING); + rb_str_modify(self); + oneliner_string_xor((guint8 *) RSTRING(self)->ptr, (guint8 *) RSTRING(object)->ptr, MIN(RSTRING(self)->len, RSTRING(object)->len)); + return self; +} + Added: trunk/oneliner/ext/xor_block.c =================================================================== --- trunk/oneliner/ext/xor_block.c (rev 0) +++ trunk/oneliner/ext/xor_block.c 2007-05-21 18:21:42 UTC (rev 280) @@ -0,0 +1,109 @@ +// +// An as yet mysterious block. +// +typedef struct { + gboolean initialized; + guint8 *sum; + GHashTable *source_blocks; +} oneliner_xor_block; + +#define XOR_BLOCK_FINISHED(xor_block) ((xor_block)->initialized && \ + (g_hash_table_size((xor_block)->source_blocks) == 1) && \ + ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) +#define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) + +static oneliner_xor_block * +oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized) +{ + oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); + ALLOC_COPY8(rval->sum, data, len); + rval->initialized = initialized; + rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); +} + +static gboolean +oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) +{ + g_free(key); + g_free(data); + return TRUE; +} + +static void +oneliner_xor_block_free(oneliner_xor_block *xor_block) +{ + g_free(xor_block->sum); + g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); + g_hash_table_destroy(xor_block->source_blocks); + g_free(xor_block); +} + +static void +oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) +{ + guint32 *uses; + guint32 *source; + if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { + (*uses)++; + } else { + uses = g_new(guint32, 1); + source = g_new(guint32, 1); + *uses = 1; + *source = source_block_nr; + g_hash_table_insert(xor_block->source_blocks, source, uses); + } +} + +static void +oneliner_xor_block_set_sum(oneliner_xor_block *xor_block, guint8 *sum, guint32 len) +{ + ALLOC_COPY8(xor_block->sum, sum, len); + xor_block->initialized = TRUE; +} + +static void +oneliner_xor_block_last_source_block_nr_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) key; +} + +static guint32 +oneliner_xor_block_last_source_block_nr(oneliner_xor_block *xor_block) +{ + guint32 source_block_nr; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_source_block_nr_iterator, &source_block_nr); + return source_block_nr; +} + +static void +oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) data; +} + +static guint32 +oneliner_xor_block_last_uses(oneliner_xor_block *xor_block) +{ + guint32 uses; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_uses_iterator, &uses); + return uses; +} + +static void +oneliner_xor_block_apply(oneliner_xor_block *xor_block, oneliner_superstring *str, guint32 found_block_nr) +{ + guint32 tmp; + guint32 *uses; + guint32 *old_key; + + g_hash_table_lookup_extended(xor_block->source_blocks, &found_block_nr, (gpointer) old_key, (gpointer) uses); + + for (tmp = 0; tmp < *uses; tmp++) { + oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); + } + + g_hash_table_remove(xor_block->source_blocks, &found_block_nr); + g_free(old_key); + g_free(uses); +} + From nobody at rubyforge.org Mon May 21 14:28:34 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 14:28:34 -0400 (EDT) Subject: [Archipelago-submits] [281] trunk/oneliner: removed useless stuff Message-ID: <20070521182834.7AF855240A5A@rubyforge.org> Revision: 281 Author: zond Date: 2007-05-21 14:28:34 -0400 (Mon, 21 May 2007) Log Message: ----------- removed useless stuff Modified Paths: -------------- trunk/oneliner/ext/extconf.rb Added Paths: ----------- trunk/oneliner/ext/oneliner.c Removed Paths: ------------- trunk/oneliner/ext/oneliner_ext.c trunk/oneliner/lib/ Modified: trunk/oneliner/ext/extconf.rb =================================================================== --- trunk/oneliner/ext/extconf.rb 2007-05-21 18:21:42 UTC (rev 280) +++ trunk/oneliner/ext/extconf.rb 2007-05-21 18:28:34 UTC (rev 281) @@ -43,4 +43,4 @@ $CFLAGS += " -g -gdwarf-2 -g3 " + `pkg-config --cflags --libs glib-2.0`.strip -create_makefile("oneliner_ext") +create_makefile("oneliner") Copied: trunk/oneliner/ext/oneliner.c (from rev 280, trunk/oneliner/ext/oneliner_ext.c) =================================================================== --- trunk/oneliner/ext/oneliner.c (rev 0) +++ trunk/oneliner/ext/oneliner.c 2007-05-21 18:28:34 UTC (rev 281) @@ -0,0 +1,908 @@ +// Archipelago - a distributed computing toolkit for ruby +// Copyright (C) 2006 Martin Kihlgren +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#include "ruby.h" +#include +#include +#include +#include +#include + +// +// The classes +// +static VALUE rb_superstring; + +// +// Utility macros. +// +#ifdef ONELINER_DEBUG +#define DEBUG(s, ...) { \ + fprintf(stderr, "DEBUG: "); \ + fprintf(stderr, s, ## __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } +#define IFDEBUG(s) s +#define BITSTRING_DEBUG(msg,str,len) { \ + fprintf(stderr, "DEBUG: %s: ", (msg)); \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), \ + rb_intern("print"), \ + 1, \ + rb_funcall(rb_funcall(rb_funcall(rb_str_new((gchar *) (str), (len)), \ + rb_intern("unpack"), \ + 1, \ + rb_str_new2("b*")), \ + rb_intern("first"), \ + 0), \ + rb_intern("gsub"), \ + 2, \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Regexp")), \ + rb_intern("new"), \ + 1, \ + rb_str_new2("(.{4,4})")), \ + rb_str_new2("\\1,"))); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } +#define STRING_DEBUG(msg,str,len) { \ + fprintf(stderr, "DEBUG: %s: ", (msg)); \ + rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); \ + fprintf(stderr, "\n"); \ + fflush(NULL); } +#else +#define DEBUG(s, ...) ; +#define IFDEBUG(s) ; +#define BITSTRING_DEBUG(msg,str,len) ; +#endif + +#define RANDOM(context,max) (oneliner_context_random(context) % (max)) +#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) +#define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) +#define ALLOC_COPY8(dst,src,len) { \ + (dst) = g_new0(guint8, (len) + 1); \ + memcpy((dst), (src), sizeof(guint8) * (len)); } + +#define Q 3 +#define E 0.01 + +// +// The c representation of a superstring. +// +typedef struct { + // The blocks of this superstring. + GArray *blocks; + // The aux blocks of this superstring. + GArray *aux_blocks; + // Our graph of check blocks. + GArray *graph; + // Our graph of aux blocks for the source blocks. + GArray *aux_graph_for_source_blocks; + // Our graph of aux blocks for the aux blocks themselves. + GArray *aux_graph_for_aux_blocks; + // The size of each block in bits. + guint32 block_size; + // The number of guint8's needed to contain those bits. + guint32 n_chars_in_block; + // The length of the original data. + guint32 data_len; + // The number of blocks needed to contain that data. + guint32 n_blocks_needed; + // The number of bytes needed to store those blocks. + guint32 n_bytes_for_blocks; + // The number of aux blocks needed for those blocks. + guint32 n_aux_blocks_needed; + // The number of check blocks we have decoded so far. + guint32 n_known_check_blocks; + // Whether we have decided already that we are done decoding. + gboolean decode_done; +} oneliner_superstring; + +// +// A random context. +// +typedef guint8 oneliner_context; + +static guint8 * +oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr); +static void +oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr); + +#include "context.c" +#include "string.c" +#include "xor_block.c" +#include "graph_insertion.c" + +// +// Return the block size in bits for a string of the given length. +// +static guint32 +oneliner_superstring_get_block_size(guint32 len) { + if (len < 1024) { + return (guint32) ceil((len / 1024.0) * 8.0); + } else { + return ((len / 128) / 8) * 8; + } +} + +// +// Fill *block with a block_size (bitwise) piece of *data from pos (bitwise). +// +static void +oneliner_superstring_get_block_from_data(guint8 *data, guint32 pos, guint32 block_size, guint8 *block) +{ + // + // Block sizes 1-7 are tricky, + // but all other sizes are divisible by 8 and therefore ok to do with a simple memcpy. + // + if (block_size < 8) { + // If the whole block fits within one char then we cant assume that we have permission + // to read the char after it, but if it DOESNT then we MUST assume that we have permission + // to read the char after it. Therefore the below fork where we read a char or a short from the data. + if ((pos + block_size - 1) / 8 == pos / 8) { + *block = data[pos / 8]; + *block = *block << (8 - ((pos + block_size) % 8)) % 8; + *block = *block >> 8 - block_size; + } else { + guint16 short_containing_block = * (guint16 *) (data + (pos / 8)); + short_containing_block = short_containing_block << (8 - ((pos + block_size) % 8)) % 8; + short_containing_block = short_containing_block >> 16 - block_size; + *block = (guint8) short_containing_block; + } + } else { + memcpy(block, data + (pos / 8), sizeof(guint8) * (block_size / 8)); + } +} + +// +// Take *data and return a GArray * with all the block_size blocks it contains. +// Needs hints as to how many bytes we need to contain all blocks, how long *data is, +// how many chars each block needs and how many blocks we need in total. +// +static GArray * +oneliner_superstring_build_blocks_from_data(guint32 n_bytes_for_blocks, + guint32 data_len, + guint32 block_size, + guint32 n_chars_in_block, + guint32 n_blocks_needed, + guint8 *data) +{ + guint32 block_nr; + guint8 *tmp_block; + guint8 tmp_data[n_bytes_for_blocks]; + GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + + g_array_set_size(rval, n_blocks_needed); + memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * data_len); + for (block_nr = 0; block_nr < n_blocks_needed; block_nr++) { + guint32 pos = block_nr * block_size; + tmp_block = g_new0(guint8, n_chars_in_block + 1); + oneliner_superstring_get_block_from_data(tmp_data, pos, block_size, tmp_block); + g_array_index(rval, guint8 *, block_nr) = tmp_block; + } + + return rval; +} + + +// +// Ensure that str->blocks contains a GArray with all the blocks of this data. +// +static void +oneliner_superstring_build_blocks(oneliner_superstring *str, guint8 *data) +{ + str->blocks = oneliner_superstring_build_blocks_from_data(str->n_bytes_for_blocks, + str->data_len, + str->block_size, + str->n_chars_in_block, + str->n_blocks_needed, + data); +} + +// +// Take the block_size (bitwise) content of *block and insert it in *data at block_nr. +// +static void +oneliner_superstring_set_data_from_block(guint8 *data, guint32 block_nr, guint32 block_size, guint8 *block) +{ + // + // If the block size is less than 8 then we have some tricky business, otherwise + // we know that it is a multiple of 8, which makes it into a simple memcpy. + // + if (block_size < 8) { + // If the entire block fits within one byte then we can not assume that we can write + // the byte after, but if it doesnt then we MUST assume that we CAN write the byte + // after, therefore the below fork where we write a char or a long depending. + if ((block_nr * block_size) / 8 == (((block_nr + 1) * block_size) - 1) / 8) { + // Set the byte we want to write to the block content. + guint8 byte_to_write = *block; + // Left shift it enough so that it matches the segment of data we want to write. + byte_to_write = byte_to_write << (block_nr * block_size) % 8; + // Then OR the corresponding byte in the data with the byte to write. Since + // the data is supposed to be initialized with zeroes this ought to do the trick. + data[(block_nr * block_size) / 8] = data[(block_nr * block_size) / 8] | byte_to_write; + } else { + // Set the short we want to write to the block content. + guint16 short_to_write = (guint16) *block; + // Left shift it enough so that it matches the segment of data we want to write. + short_to_write = short_to_write << (block_nr * block_size) % 8; + // Then OR the corresponding short in the data with the short to write. Since + // the data is supposed to be initialized with zeroes this ought to do the trick. + * (guint16 *) (data + (block_nr * block_size) / 8) = * (guint16 *) (data + (block_nr * block_size) / 8) | short_to_write; + } + } else { + memcpy((gchar *) data + (block_nr * (block_size / 8)), (gchar *) block, sizeof(guint8) * (block_size / 8)); + } +} + +// +// Take the given blocks of size block_size needing n_bytes_for_blocks to be stored completely and +// concatenate them into a string, then return the first data_len bytes of the result. +// +// If prepend_size is larger than 0 then the prepend string will be prepended to the result. +// +static guint8 * +oneliner_superstring_build_data_from_blocks(guint32 n_bytes_for_blocks, + guint32 data_len, + guint32 block_size, + GArray *blocks, + guint32 prepend_size, + guint8 *prepend) +{ + guint32 index; + guint8 *tmp_data = g_new0(guint8, n_bytes_for_blocks + prepend_size + 1); + for (index = 0; index < blocks->len; index++) { + oneliner_superstring_set_data_from_block(tmp_data + prepend_size, index, block_size, g_array_index(blocks, guint8 *, index)); + } + memcpy((gchar *) tmp_data, (gchar *) prepend, sizeof(guint8) * prepend_size); + return g_realloc(tmp_data, data_len); +} + +// +// Return the guint8 * that the given *str describes with its blocks. +// +static guint8 * +oneliner_superstring_build_data(oneliner_superstring *str) +{ + return oneliner_superstring_build_data_from_blocks(str->n_bytes_for_blocks, + str->data_len, + str->block_size, + str->blocks, + 0, + NULL); +} + +// +// Create the aux_blocks GArray for *str using its blocks and length. +// +static void +oneliner_superstring_build_aux_blocks(oneliner_superstring *str) +{ + guint32 tmp; + oneliner_context *context = oneliner_context_new(); + + oneliner_context_seed(context, (gint32) str->data_len); + str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); + g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); + + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { + guint32 tmp2; + for (tmp2 = 0; tmp2 < Q; tmp2++) { + guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); + if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { + ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, gchar *, tmp), + str->n_chars_in_block); + } else { + oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), + g_array_index(str->blocks, guint8 *, tmp), + str->n_chars_in_block); + } + } + } + + g_free(context); +} + +// +// Initialize all the precalculated state of *str using data_len. +// +static void +oneliner_superstring_initialize(oneliner_superstring *str, guint32 data_len) +{ + // Make sure the length of our data (our String superclass content) is set. + str->data_len = (guint32) data_len; + // Make sure the block size we deem reasonable for this data length is set. + str->block_size = oneliner_superstring_get_block_size(str->data_len); + // Make sure the number of chars needed to contain such a block is set. + str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); + // Make sure the number of blocks needed to contain this data is set. + str->n_blocks_needed = (guint32) ceil((str->data_len * 8.0) / str->block_size); + // Make sure the number of bytes needed to contain those blocks is set. + str->n_bytes_for_blocks = (guint32) ceil((str->n_blocks_needed * str->block_size) / 8.0); + // Make sure the number of aux blocks needed for those blocks is set. + str->n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->n_blocks_needed); + // Make sure the number of known check blocks so far is set. + str->n_known_check_blocks = 0; + // Make sure we dont think we have decoded already. + str->decode_done = FALSE; +} + +// +// Initialize a superstring using (possibly) a String to encode. +// +static VALUE +rb_oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) +{ + oneliner_superstring *str; + + if (argc > 1) { + rb_raise(rb_eRuntimeError, "Oneliner::SuperString.new(String s = nil) takes at most 1 argument."); + } else if (argc == 1) { + Check_Type(argv[0], T_STRING); + + if (RSTRING(argv[0])->len < 1) + rb_raise(rb_eRuntimeError, "First argument to Oneliner::SuperString.new(String s = nil) must be a String of at least size 1 if given."); + + RB_ONELINER(self, str); + + oneliner_superstring_initialize(str, RSTRING(argv[0])->len); + + // Make sure that we have our blocks calculated properly. + oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); + oneliner_superstring_build_aux_blocks(str); + } + return self; +} + +// +// Returns whether *str is done decoding. +// +static VALUE +oneliner_superstring_decode_done(oneliner_superstring *str) +{ + guint32 tmp; + if (str->decode_done) + return Qtrue; + if (str->blocks == NULL) + return Qfalse; + if (str->n_known_check_blocks < str->n_blocks_needed) + return Qfalse; + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) + if (g_array_index(str->blocks, guint8 *, tmp) == NULL) + return Qfalse; + str->decode_done = TRUE; + return Qtrue; +} + +// +// Returns a GArray * containing all the blocks described by *chunk of length chunk_len +// in the context of *str (its block_size, n_chars_in_block etc). +// +static GArray * +oneliner_superstring_get_blocks_from_chunk(oneliner_superstring *str, guint8 *chunk, guint32 chunk_len) +{ + return oneliner_superstring_build_blocks_from_data(chunk_len, + chunk_len, + str->block_size, + str->n_chars_in_block, + (chunk_len * 8) / str->block_size, + chunk); +} + +// +// Return the guint8 * at either source or aux block with index block_nr in *str. +// +static guint8 * +oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr) +{ + if (block_nr < str->n_blocks_needed) + return g_array_index(str->blocks, guint8 *, block_nr); + else + return g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed); +} + +// +// Set either the source of aux block at block_nr of *str to *block. +// +static void +oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) +{ + if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { + ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); + } else if (g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { + ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed), block, str->n_chars_in_block); + } +} + +static void +oneliner_superstring_analyze_source_block_with_array(oneliner_superstring *str, + GArray *ary, + guint32 found_block_nr) +{ + guint32 source_block_nr; + GList *list_element; + GList *list_head = g_array_index(ary, GList *, found_block_nr); + oneliner_xor_block *xor_block; + + // For each xor_block-containing item in the list. + for (list_element = list_head; list_element != NULL; list_element = g_list_next(list_element)) { + // Fetch its xor_block + xor_block = (oneliner_xor_block *) list_element->data; + + // Apply this new knowledge to it. + oneliner_xor_block_apply(xor_block, + str, + found_block_nr); + + // + // If that meant that it is finished then dance the dance of setting the combined block, + // freeing the check block, removing it from the GList of check blocks for that combined block, + // and analyzing the results. + // + // Otherwise if it is empty, just free it and remove it. + // + if (XOR_BLOCK_FINISHED(xor_block)) { + + // Find the source block that it defines. + source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + + // And set it. + oneliner_superstring_set_combined_block(str, + source_block_nr, + xor_block->sum); + // Then free the check block. + oneliner_xor_block_free(xor_block); + + // Then remove it from our unresolved check blocks so that we can run analyze safely again. + g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); + + // Then remove the list element that contained this check block. + g_list_free_1(list_element); + + // And now analyze what the newly found source block led to. + // (Right, it can be an aux block as well, but my logic is still correct, I believe.) + oneliner_superstring_analyze(str, source_block_nr); + } else if (XOR_BLOCK_EMPTY(xor_block)) { + // Free the check block. + oneliner_xor_block_free(xor_block); + // Remove it from our unresolved list. + g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); + // And remove the list element. + g_list_free_1(list_element); + } + } +} + +static void +oneliner_superstring_analyze_source_block(oneliner_superstring *str, guint32 found_block_nr) +{ + oneliner_superstring_analyze_source_block_with_array(str, + str->graph, + found_block_nr); + + oneliner_superstring_analyze_source_block_with_array(str, + str->aux_graph_for_source_blocks, + found_block_nr); +} + +static void +oneliner_superstring_analyze_aux_block(oneliner_superstring *str, guint32 found_block_nr) +{ + oneliner_xor_block *xor_block; + + if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed)) != NULL) { + oneliner_xor_block_set_sum(xor_block, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); + if (XOR_BLOCK_FINISHED(xor_block)) { + guint32 source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + + oneliner_superstring_set_combined_block(str, + source_block_nr, + xor_block->sum); + oneliner_xor_block_free(xor_block); + + g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed) = NULL; + + oneliner_superstring_analyze(str, source_block_nr); + } else if (XOR_BLOCK_EMPTY(xor_block)) { + oneliner_xor_block_free(xor_block); + g_array_index(str->aux_graph_for_aux_blocks, + oneliner_xor_block *, + found_block_nr - str->n_blocks_needed) = NULL; + } + } +} + +static void +oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) +{ + if (found_block_nr < str->n_blocks_needed) { + oneliner_superstring_analyze_source_block(str, found_block_nr); + } else { + oneliner_superstring_analyze_aux_block(str, found_block_nr); + } +} + +static void +oneliner_superstring_add_to_graph(oneliner_superstring *str, guint32 seed, guint8 *chunk, guint32 chunk_len) +{ + oneliner_context *context = oneliner_context_new(); + GArray *content_blocks; + guint32 tmp; + guint32 tmp2; + guint32 unknown_source_blocks; + guint32 unknown_source_block_nr; + GList *inserts; + oneliner_xor_block *xor_block; + guint32 degree; + guint32 block_nr; + guint8 *block_content; + + oneliner_context_seed(context, (gint32) seed); + + content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); + + for (tmp = 0; tmp < content_blocks->len; tmp++) { + degree = oneliner_context_get_degree(context); + if (degree == 1) { + block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); + oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp)); + oneliner_superstring_analyze(str, block_nr); + } else { + unknown_source_blocks = 0; + unknown_source_block_nr = 0; + inserts = NULL; + + xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), + str->n_chars_in_block, + TRUE); + + for (tmp2 = 0; tmp2 < degree; tmp2++) { + block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); + block_content = oneliner_superstring_get_combined_block(str, block_nr); + if (block_content != NULL) { + oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); + } else { + oneliner_xor_block_add(xor_block, block_nr); + inserts = g_list_append(inserts, oneliner_graph_insertion_new(xor_block, block_nr)); + unknown_source_blocks++; + unknown_source_block_nr = block_nr; + } + } + + if (XOR_BLOCK_FINISHED(xor_block)) { + oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum); + + g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); + g_list_free(inserts); + + oneliner_superstring_analyze(str, unknown_source_block_nr); + } else { + g_list_foreach(inserts, oneliner_insertion_execute, str); + g_list_free(inserts); + } + + } + (str->n_known_check_blocks)++; + } + + g_array_free(content_blocks, TRUE); + g_free(context); +} + +static void +oneliner_superstring_build_aux_graph(oneliner_superstring *str) +{ + oneliner_context *context = oneliner_context_new(); + guint32 tmp; + guint8 *zeroes = g_new0(guint8, str->n_chars_in_block); + guint32 tmp2; + guint32 aux_block_nr; + oneliner_xor_block *aux_block; + GList *aux_blocks; + + oneliner_context_seed(context, (gint32) str->data_len); + str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); + g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); + str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GList *)); + g_array_set_size(str->aux_graph_for_source_blocks, str->n_blocks_needed); + + for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { + aux_blocks = NULL; + + for (tmp2 = 0; tmp2 < Q; tmp2++) { + aux_block_nr = RANDOM(context, str->n_aux_blocks_needed); + + if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { + aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE); + g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr); + } + + oneliner_xor_block_add(aux_block, tmp); + aux_blocks = g_list_append(aux_blocks, aux_block); + } + + g_array_index(str->aux_graph_for_source_blocks, GList *, tmp) = aux_blocks; + } + + g_free(zeroes); + g_free(context); +} + +static VALUE +rb_oneliner_superstring_decode(VALUE self, VALUE chunk) +{ + oneliner_superstring *str; + guint32 data_len; + guint32 seed; + guint32 blocks_needed; + + Check_Type(chunk, T_STRING); + + RB_ONELINER(self, str); + + if (RSTRING(chunk)->len < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString#decode(String chunk) needs an argument that is at least 8 characters long."); + + data_len = ((guint32 *) RSTRING(chunk)->ptr)[0]; + seed = ((guint32 *) RSTRING(chunk)->ptr)[1]; + + if (str->data_len == 0) { + str->data_len = data_len; + } else if (str->data_len != data_len) { + rb_raise(rb_eRuntimeError, "Oneliner::Superstring#decode(String chunk) needs all consecutive calls to be with arguments having the same first four characters. Didn't you use chunks produced using #encode calls from the same instance?"); + } + + if (str->blocks == NULL) { + oneliner_superstring_initialize(str, data_len); + str->blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); + g_array_set_size(str->blocks, str->n_blocks_needed); + str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); + g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); + str->graph = g_array_new(FALSE, TRUE, sizeof(GList *)); + oneliner_superstring_build_aux_graph(str); + } + + oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); + + return oneliner_superstring_decode_done(str); +} + +static guint8 * +oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) +{ + guint32 degree = oneliner_context_get_degree(context); + guint32 block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); + guint8 *rval; + guint32 tmp; + + ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); + for (tmp = 2; tmp <= degree; tmp++) + oneliner_string_xor(rval, + oneliner_superstring_get_combined_block(str, RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed)), + str->n_chars_in_block); + + return rval; +} + +static guint32 +oneliner_superstring_encode(oneliner_superstring *str, guint8 **buffer, guint32 len) +{ + oneliner_context *context = oneliner_context_new(); + GArray *rval_ary = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + guint8 prepend[8]; + gint32 tmp; + + sranddev(); + tmp = (gint32) rand(); + oneliner_context_seed(context, tmp); + + ( (guint32 *) prepend )[0] = str->data_len; + ( (guint32 *) prepend )[1] = (guint32) tmp; + + while ((rval_ary->len * str->block_size) / 8 < len) { + guint8 *check_block = oneliner_superstring_get_check_block(str, context); + g_array_append_val(rval_ary, check_block); + } + + // Here I let tmp describe the number of bytes needed to contain the rval_ary considering the block + // size. And since we cant really truncate it at the end at this stage (like we can in the final build_data_from_blocks) + // the data_len argument is the same as the n_bytes_for_blocks argument. Also, we want to prepend the original data-len + // and seed, so we use the prepend argument. + tmp = (guint32) ceil((rval_ary->len * str->block_size) / 8); + *buffer = oneliner_superstring_build_data_from_blocks(tmp, + tmp, + str->block_size, + rval_ary, + 8, + prepend); + g_free(context); + g_array_free(rval_ary, TRUE); + + return tmp; +} + +static void +oneliner_superstring_free_xor_block(gpointer xor_block, gpointer user_data) +{ + oneliner_xor_block_free((oneliner_xor_block *) xor_block); +} + +static void +oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, gboolean free_xor_blocks) +{ + guint32 tmp; + for (tmp = 0; tmp < ary->len; tmp++) { + GList *list; + if ((list = (GList *) g_array_index(ary, GList *, tmp)) != NULL) { + if (free_xor_blocks) + g_list_foreach(list, oneliner_superstring_free_xor_block, NULL); + g_list_free(list); + } + } + g_array_free(ary, FALSE); +} + +static void +oneliner_superstring_free(oneliner_superstring *str) +{ + guint32 tmp; + if (str->blocks != NULL) + g_array_free(str->blocks, TRUE); + if (str->aux_blocks != NULL) + g_array_free(str->aux_blocks, TRUE); + if (str->graph != NULL) + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, TRUE); + if (str->aux_graph_for_aux_blocks != NULL) { + for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) + oneliner_xor_block_free((oneliner_xor_block *) g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)); + } + if (str->aux_graph_for_source_blocks != NULL) + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, FALSE); + + g_free(str); +} + +static VALUE +rb_oneliner_superstring_alloc(VALUE klass) +{ + oneliner_superstring *str = g_new0(oneliner_superstring, 1); + return Data_Wrap_Struct(klass, NULL, oneliner_superstring_free, str); +} + +static VALUE +oneliner_superstring_get_blocks(GArray *container, guint32 len) +{ + guint32 tmp; + VALUE rval = rb_ary_new(); + for (tmp = 0; tmp < container->len; tmp++) { + guint8 *tmp_block = g_array_index(container, guint8 *, tmp); + rb_ary_push(rval, rb_str_new((gchar *) tmp_block, len)); + } + return rval; +} + +static VALUE +rb_oneliner_superstring_blocks(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return oneliner_superstring_get_blocks(str->blocks, str->n_chars_in_block); +} + +static VALUE +rb_oneliner_superstring_aux_blocks(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return oneliner_superstring_get_blocks(str->aux_blocks, str->n_chars_in_block); +} + +static VALUE +rb_oneliner_superstring_to_s(VALUE self) +{ + oneliner_superstring *str; + VALUE rval; + guint8 *tmp_data; + + RB_ONELINER(self, str); + if (str->blocks == NULL) + return rb_str_new2(""); + tmp_data = oneliner_superstring_build_data(str); + rval = rb_str_new((gchar *) tmp_data, str->data_len); + g_free(tmp_data); + return rval; +} + +static VALUE +rb_oneliner_superstring_block_size(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return INT2NUM(str->block_size); +} + +static VALUE +rb_oneliner_superstring_encode(VALUE self, VALUE size) +{ + guint8 *chunk; + VALUE rval; + oneliner_superstring *str; + guint32 chunk_size; + + Check_Type(size, T_FIXNUM); + if (NUM2INT(size) < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString#encode(Fixnum size) needs a size of at least 8."); + + RB_ONELINER(self, str); + + chunk_size = oneliner_superstring_encode(str, &chunk, NUM2INT(size)); + rval = rb_str_new((gchar *) chunk, chunk_size); + + g_free(chunk); + + return rval; +} + +static VALUE +rb_oneliner_superstring_chunk_blocks(VALUE self, VALUE chunk) +{ + oneliner_superstring *str; + VALUE rval; + GArray *blocks; + + Check_Type(chunk, T_STRING); + + if (RSTRING(chunk)->len < 8) + rb_raise(rb_eRuntimeError, "Oneliner::SuperString.chunk_blocks(String chunk) needs an argument that is at least 8 characters long."); + + RB_ONELINER(self, str); + blocks = oneliner_superstring_get_blocks_from_chunk(str, + (guint8 *) RSTRING(chunk)->ptr + 8, + (guint32) RSTRING(chunk)->len - 8); + rval = oneliner_superstring_get_blocks(blocks, + str->n_chars_in_block); + g_array_free(blocks, TRUE); + return rval; +} + +#ifdef __cplusplus +extern "C" { +#endif + void Init_oneliner_ext() { + VALUE rb_string = rb_define_class("String", rb_cObject); + rb_define_method(rb_string, "xor!", rb_oneliner_string_xor, 1); + + rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), + "SuperString", + rb_cObject); + rb_define_alloc_func(rb_superstring, rb_oneliner_superstring_alloc); + rb_define_method(rb_superstring, "initialize", rb_oneliner_superstring_initialize, -1); + rb_define_method(rb_superstring, "blocks", rb_oneliner_superstring_blocks, 0); + rb_define_method(rb_superstring, "aux_blocks", rb_oneliner_superstring_aux_blocks, 0); + rb_define_method(rb_superstring, "to_s", rb_oneliner_superstring_to_s, 0); + rb_define_method(rb_superstring, "encode", rb_oneliner_superstring_encode, 1); + rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); + rb_define_method(rb_superstring, "chunk_blocks", rb_oneliner_superstring_chunk_blocks, 1); + rb_define_method(rb_superstring, "decode", rb_oneliner_superstring_decode, 1); + } +#ifdef __cplusplus +} +#endif + Deleted: trunk/oneliner/ext/oneliner_ext.c =================================================================== --- trunk/oneliner/ext/oneliner_ext.c 2007-05-21 18:21:42 UTC (rev 280) +++ trunk/oneliner/ext/oneliner_ext.c 2007-05-21 18:28:34 UTC (rev 281) @@ -1,908 +0,0 @@ -// Archipelago - a distributed computing toolkit for ruby -// Copyright (C) 2006 Martin Kihlgren -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -#include "ruby.h" -#include -#include -#include -#include -#include - -// -// The classes -// -static VALUE rb_superstring; - -// -// Utility macros. -// -#ifdef ONELINER_DEBUG -#define DEBUG(s, ...) { \ - fprintf(stderr, "DEBUG: "); \ - fprintf(stderr, s, ## __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - fflush(NULL); } -#define IFDEBUG(s) s -#define BITSTRING_DEBUG(msg,str,len) { \ - fprintf(stderr, "DEBUG: %s: ", (msg)); \ - rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), \ - rb_intern("print"), \ - 1, \ - rb_funcall(rb_funcall(rb_funcall(rb_str_new((gchar *) (str), (len)), \ - rb_intern("unpack"), \ - 1, \ - rb_str_new2("b*")), \ - rb_intern("first"), \ - 0), \ - rb_intern("gsub"), \ - 2, \ - rb_funcall(rb_const_get(rb_cObject, rb_intern("Regexp")), \ - rb_intern("new"), \ - 1, \ - rb_str_new2("(.{4,4})")), \ - rb_str_new2("\\1,"))); \ - fprintf(stderr, "\n"); \ - fflush(NULL); } -#define STRING_DEBUG(msg,str,len) { \ - fprintf(stderr, "DEBUG: %s: ", (msg)); \ - rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); \ - fprintf(stderr, "\n"); \ - fflush(NULL); } -#else -#define DEBUG(s, ...) ; -#define IFDEBUG(s) ; -#define BITSTRING_DEBUG(msg,str,len) ; -#endif - -#define RANDOM(context,max) (oneliner_context_random(context) % (max)) -#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) -#define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) -#define ALLOC_COPY8(dst,src,len) { \ - (dst) = g_new0(guint8, (len) + 1); \ - memcpy((dst), (src), sizeof(guint8) * (len)); } - -#define Q 3 -#define E 0.01 - -// -// The c representation of a superstring. -// -typedef struct { - // The blocks of this superstring. - GArray *blocks; - // The aux blocks of this superstring. - GArray *aux_blocks; - // Our graph of check blocks. - GArray *graph; - // Our graph of aux blocks for the source blocks. - GArray *aux_graph_for_source_blocks; - // Our graph of aux blocks for the aux blocks themselves. - GArray *aux_graph_for_aux_blocks; - // The size of each block in bits. - guint32 block_size; - // The number of guint8's needed to contain those bits. - guint32 n_chars_in_block; - // The length of the original data. - guint32 data_len; - // The number of blocks needed to contain that data. - guint32 n_blocks_needed; - // The number of bytes needed to store those blocks. - guint32 n_bytes_for_blocks; - // The number of aux blocks needed for those blocks. - guint32 n_aux_blocks_needed; - // The number of check blocks we have decoded so far. - guint32 n_known_check_blocks; - // Whether we have decided already that we are done decoding. - gboolean decode_done; -} oneliner_superstring; - -// -// A random context. -// -typedef guint8 oneliner_context; - -static guint8 * -oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr); -static void -oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr); - -#include "context.c" -#include "string.c" -#include "xor_block.c" -#include "graph_insertion.c" - -// -// Return the block size in bits for a string of the given length. -// -static guint32 -oneliner_superstring_get_block_size(guint32 len) { - if (len < 1024) { - return (guint32) ceil((len / 1024.0) * 8.0); - } else { - return ((len / 128) / 8) * 8; - } -} - -// -// Fill *block with a block_size (bitwise) piece of *data from pos (bitwise). -// -static void -oneliner_superstring_get_block_from_data(guint8 *data, guint32 pos, guint32 block_size, guint8 *block) -{ - // - // Block sizes 1-7 are tricky, - // but all other sizes are divisible by 8 and therefore ok to do with a simple memcpy. - // - if (block_size < 8) { - // If the whole block fits within one char then we cant assume that we have permission - // to read the char after it, but if it DOESNT then we MUST assume that we have permission - // to read the char after it. Therefore the below fork where we read a char or a short from the data. - if ((pos + block_size - 1) / 8 == pos / 8) { - *block = data[pos / 8]; - *block = *block << (8 - ((pos + block_size) % 8)) % 8; - *block = *block >> 8 - block_size; - } else { - guint16 short_containing_block = * (guint16 *) (data + (pos / 8)); - short_containing_block = short_containing_block << (8 - ((pos + block_size) % 8)) % 8; - short_containing_block = short_containing_block >> 16 - block_size; - *block = (guint8) short_containing_block; - } - } else { - memcpy(block, data + (pos / 8), sizeof(guint8) * (block_size / 8)); - } -} - -// -// Take *data and return a GArray * with all the block_size blocks it contains. -// Needs hints as to how many bytes we need to contain all blocks, how long *data is, -// how many chars each block needs and how many blocks we need in total. -// -static GArray * -oneliner_superstring_build_blocks_from_data(guint32 n_bytes_for_blocks, - guint32 data_len, - guint32 block_size, - guint32 n_chars_in_block, - guint32 n_blocks_needed, - guint8 *data) -{ - guint32 block_nr; - guint8 *tmp_block; - guint8 tmp_data[n_bytes_for_blocks]; - GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); - - g_array_set_size(rval, n_blocks_needed); - memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * data_len); - for (block_nr = 0; block_nr < n_blocks_needed; block_nr++) { - guint32 pos = block_nr * block_size; - tmp_block = g_new0(guint8, n_chars_in_block + 1); - oneliner_superstring_get_block_from_data(tmp_data, pos, block_size, tmp_block); - g_array_index(rval, guint8 *, block_nr) = tmp_block; - } - - return rval; -} - - -// -// Ensure that str->blocks contains a GArray with all the blocks of this data. -// -static void -oneliner_superstring_build_blocks(oneliner_superstring *str, guint8 *data) -{ - str->blocks = oneliner_superstring_build_blocks_from_data(str->n_bytes_for_blocks, - str->data_len, - str->block_size, - str->n_chars_in_block, - str->n_blocks_needed, - data); -} - -// -// Take the block_size (bitwise) content of *block and insert it in *data at block_nr. -// -static void -oneliner_superstring_set_data_from_block(guint8 *data, guint32 block_nr, guint32 block_size, guint8 *block) -{ - // - // If the block size is less than 8 then we have some tricky business, otherwise - // we know that it is a multiple of 8, which makes it into a simple memcpy. - // - if (block_size < 8) { - // If the entire block fits within one byte then we can not assume that we can write - // the byte after, but if it doesnt then we MUST assume that we CAN write the byte - // after, therefore the below fork where we write a char or a long depending. - if ((block_nr * block_size) / 8 == (((block_nr + 1) * block_size) - 1) / 8) { - // Set the byte we want to write to the block content. - guint8 byte_to_write = *block; - // Left shift it enough so that it matches the segment of data we want to write. - byte_to_write = byte_to_write << (block_nr * block_size) % 8; - // Then OR the corresponding byte in the data with the byte to write. Since - // the data is supposed to be initialized with zeroes this ought to do the trick. - data[(block_nr * block_size) / 8] = data[(block_nr * block_size) / 8] | byte_to_write; - } else { - // Set the short we want to write to the block content. - guint16 short_to_write = (guint16) *block; - // Left shift it enough so that it matches the segment of data we want to write. - short_to_write = short_to_write << (block_nr * block_size) % 8; - // Then OR the corresponding short in the data with the short to write. Since - // the data is supposed to be initialized with zeroes this ought to do the trick. - * (guint16 *) (data + (block_nr * block_size) / 8) = * (guint16 *) (data + (block_nr * block_size) / 8) | short_to_write; - } - } else { - memcpy((gchar *) data + (block_nr * (block_size / 8)), (gchar *) block, sizeof(guint8) * (block_size / 8)); - } -} - -// -// Take the given blocks of size block_size needing n_bytes_for_blocks to be stored completely and -// concatenate them into a string, then return the first data_len bytes of the result. -// -// If prepend_size is larger than 0 then the prepend string will be prepended to the result. -// -static guint8 * -oneliner_superstring_build_data_from_blocks(guint32 n_bytes_for_blocks, - guint32 data_len, - guint32 block_size, - GArray *blocks, - guint32 prepend_size, - guint8 *prepend) -{ - guint32 index; - guint8 *tmp_data = g_new0(guint8, n_bytes_for_blocks + prepend_size + 1); - for (index = 0; index < blocks->len; index++) { - oneliner_superstring_set_data_from_block(tmp_data + prepend_size, index, block_size, g_array_index(blocks, guint8 *, index)); - } - memcpy((gchar *) tmp_data, (gchar *) prepend, sizeof(guint8) * prepend_size); - return g_realloc(tmp_data, data_len); -} - -// -// Return the guint8 * that the given *str describes with its blocks. -// -static guint8 * -oneliner_superstring_build_data(oneliner_superstring *str) -{ - return oneliner_superstring_build_data_from_blocks(str->n_bytes_for_blocks, - str->data_len, - str->block_size, - str->blocks, - 0, - NULL); -} - -// -// Create the aux_blocks GArray for *str using its blocks and length. -// -static void -oneliner_superstring_build_aux_blocks(oneliner_superstring *str) -{ - guint32 tmp; - oneliner_context *context = oneliner_context_new(); - - oneliner_context_seed(context, (gint32) str->data_len); - str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - - for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { - guint32 tmp2; - for (tmp2 = 0; tmp2 < Q; tmp2++) { - guint32 aux_block_nr = (guint32) RANDOM(context, str->n_aux_blocks_needed); - if (g_array_index(str->aux_blocks, guint *, aux_block_nr) == NULL) { - ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), - g_array_index(str->blocks, gchar *, tmp), - str->n_chars_in_block); - } else { - oneliner_string_xor(g_array_index(str->aux_blocks, guint8 *, aux_block_nr), - g_array_index(str->blocks, guint8 *, tmp), - str->n_chars_in_block); - } - } - } - - g_free(context); -} - -// -// Initialize all the precalculated state of *str using data_len. -// -static void -oneliner_superstring_initialize(oneliner_superstring *str, guint32 data_len) -{ - // Make sure the length of our data (our String superclass content) is set. - str->data_len = (guint32) data_len; - // Make sure the block size we deem reasonable for this data length is set. - str->block_size = oneliner_superstring_get_block_size(str->data_len); - // Make sure the number of chars needed to contain such a block is set. - str->n_chars_in_block = (guint32) ceil(str->block_size / 8.0); - // Make sure the number of blocks needed to contain this data is set. - str->n_blocks_needed = (guint32) ceil((str->data_len * 8.0) / str->block_size); - // Make sure the number of bytes needed to contain those blocks is set. - str->n_bytes_for_blocks = (guint32) ceil((str->n_blocks_needed * str->block_size) / 8.0); - // Make sure the number of aux blocks needed for those blocks is set. - str->n_aux_blocks_needed = (guint32) ceil(0.55 * Q * E * str->n_blocks_needed); - // Make sure the number of known check blocks so far is set. - str->n_known_check_blocks = 0; - // Make sure we dont think we have decoded already. - str->decode_done = FALSE; -} - -// -// Initialize a superstring using (possibly) a String to encode. -// -static VALUE -rb_oneliner_superstring_initialize(int argc, VALUE *argv, VALUE self) -{ - oneliner_superstring *str; - - if (argc > 1) { - rb_raise(rb_eRuntimeError, "Oneliner::SuperString.new(String s = nil) takes at most 1 argument."); - } else if (argc == 1) { - Check_Type(argv[0], T_STRING); - - if (RSTRING(argv[0])->len < 1) - rb_raise(rb_eRuntimeError, "First argument to Oneliner::SuperString.new(String s = nil) must be a String of at least size 1 if given."); - - RB_ONELINER(self, str); - - oneliner_superstring_initialize(str, RSTRING(argv[0])->len); - - // Make sure that we have our blocks calculated properly. - oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); - oneliner_superstring_build_aux_blocks(str); - } - return self; -} - -// -// Returns whether *str is done decoding. -// -static VALUE -oneliner_superstring_decode_done(oneliner_superstring *str) -{ - guint32 tmp; - if (str->decode_done) - return Qtrue; - if (str->blocks == NULL) - return Qfalse; - if (str->n_known_check_blocks < str->n_blocks_needed) - return Qfalse; - for (tmp = 0; tmp < str->n_blocks_needed; tmp++) - if (g_array_index(str->blocks, guint8 *, tmp) == NULL) - return Qfalse; - str->decode_done = TRUE; - return Qtrue; -} - -// -// Returns a GArray * containing all the blocks described by *chunk of length chunk_len -// in the context of *str (its block_size, n_chars_in_block etc). -// -static GArray * -oneliner_superstring_get_blocks_from_chunk(oneliner_superstring *str, guint8 *chunk, guint32 chunk_len) -{ - return oneliner_superstring_build_blocks_from_data(chunk_len, - chunk_len, - str->block_size, - str->n_chars_in_block, - (chunk_len * 8) / str->block_size, - chunk); -} - -// -// Return the guint8 * at either source or aux block with index block_nr in *str. -// -static guint8 * -oneliner_superstring_get_combined_block(oneliner_superstring *str, guint32 block_nr) -{ - if (block_nr < str->n_blocks_needed) - return g_array_index(str->blocks, guint8 *, block_nr); - else - return g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed); -} - -// -// Set either the source of aux block at block_nr of *str to *block. -// -static void -oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) -{ - if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { - ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); - } else if (g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { - ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed), block, str->n_chars_in_block); - } -} - -static void -oneliner_superstring_analyze_source_block_with_array(oneliner_superstring *str, - GArray *ary, - guint32 found_block_nr) -{ - guint32 source_block_nr; - GList *list_element; - GList *list_head = g_array_index(ary, GList *, found_block_nr); - oneliner_xor_block *xor_block; - - // For each xor_block-containing item in the list. - for (list_element = list_head; list_element != NULL; list_element = g_list_next(list_element)) { - // Fetch its xor_block - xor_block = (oneliner_xor_block *) list_element->data; - - // Apply this new knowledge to it. - oneliner_xor_block_apply(xor_block, - str, - found_block_nr); - - // - // If that meant that it is finished then dance the dance of setting the combined block, - // freeing the check block, removing it from the GList of check blocks for that combined block, - // and analyzing the results. - // - // Otherwise if it is empty, just free it and remove it. - // - if (XOR_BLOCK_FINISHED(xor_block)) { - - // Find the source block that it defines. - source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); - - // And set it. - oneliner_superstring_set_combined_block(str, - source_block_nr, - xor_block->sum); - // Then free the check block. - oneliner_xor_block_free(xor_block); - - // Then remove it from our unresolved check blocks so that we can run analyze safely again. - g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); - - // Then remove the list element that contained this check block. - g_list_free_1(list_element); - - // And now analyze what the newly found source block led to. - // (Right, it can be an aux block as well, but my logic is still correct, I believe.) - oneliner_superstring_analyze(str, source_block_nr); - } else if (XOR_BLOCK_EMPTY(xor_block)) { - // Free the check block. - oneliner_xor_block_free(xor_block); - // Remove it from our unresolved list. - g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); - // And remove the list element. - g_list_free_1(list_element); - } - } -} - -static void -oneliner_superstring_analyze_source_block(oneliner_superstring *str, guint32 found_block_nr) -{ - oneliner_superstring_analyze_source_block_with_array(str, - str->graph, - found_block_nr); - - oneliner_superstring_analyze_source_block_with_array(str, - str->aux_graph_for_source_blocks, - found_block_nr); -} - -static void -oneliner_superstring_analyze_aux_block(oneliner_superstring *str, guint32 found_block_nr) -{ - oneliner_xor_block *xor_block; - - if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, - oneliner_xor_block *, - found_block_nr - str->n_blocks_needed)) != NULL) { - oneliner_xor_block_set_sum(xor_block, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); - if (XOR_BLOCK_FINISHED(xor_block)) { - guint32 source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); - - oneliner_superstring_set_combined_block(str, - source_block_nr, - xor_block->sum); - oneliner_xor_block_free(xor_block); - - g_array_index(str->aux_graph_for_aux_blocks, - oneliner_xor_block *, - found_block_nr - str->n_blocks_needed) = NULL; - - oneliner_superstring_analyze(str, source_block_nr); - } else if (XOR_BLOCK_EMPTY(xor_block)) { - oneliner_xor_block_free(xor_block); - g_array_index(str->aux_graph_for_aux_blocks, - oneliner_xor_block *, - found_block_nr - str->n_blocks_needed) = NULL; - } - } -} - -static void -oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) -{ - if (found_block_nr < str->n_blocks_needed) { - oneliner_superstring_analyze_source_block(str, found_block_nr); - } else { - oneliner_superstring_analyze_aux_block(str, found_block_nr); - } -} - -static void -oneliner_superstring_add_to_graph(oneliner_superstring *str, guint32 seed, guint8 *chunk, guint32 chunk_len) -{ - oneliner_context *context = oneliner_context_new(); - GArray *content_blocks; - guint32 tmp; - guint32 tmp2; - guint32 unknown_source_blocks; - guint32 unknown_source_block_nr; - GList *inserts; - oneliner_xor_block *xor_block; - guint32 degree; - guint32 block_nr; - guint8 *block_content; - - oneliner_context_seed(context, (gint32) seed); - - content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); - - for (tmp = 0; tmp < content_blocks->len; tmp++) { - degree = oneliner_context_get_degree(context); - if (degree == 1) { - block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp)); - oneliner_superstring_analyze(str, block_nr); - } else { - unknown_source_blocks = 0; - unknown_source_block_nr = 0; - inserts = NULL; - - xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), - str->n_chars_in_block, - TRUE); - - for (tmp2 = 0; tmp2 < degree; tmp2++) { - block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - block_content = oneliner_superstring_get_combined_block(str, block_nr); - if (block_content != NULL) { - oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); - } else { - oneliner_xor_block_add(xor_block, block_nr); - inserts = g_list_append(inserts, oneliner_graph_insertion_new(xor_block, block_nr)); - unknown_source_blocks++; - unknown_source_block_nr = block_nr; - } - } - - if (XOR_BLOCK_FINISHED(xor_block)) { - oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum); - - g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); - g_list_free(inserts); - - oneliner_superstring_analyze(str, unknown_source_block_nr); - } else { - g_list_foreach(inserts, oneliner_insertion_execute, str); - g_list_free(inserts); - } - - } - (str->n_known_check_blocks)++; - } - - g_array_free(content_blocks, TRUE); - g_free(context); -} - -static void -oneliner_superstring_build_aux_graph(oneliner_superstring *str) -{ - oneliner_context *context = oneliner_context_new(); - guint32 tmp; - guint8 *zeroes = g_new0(guint8, str->n_chars_in_block); - guint32 tmp2; - guint32 aux_block_nr; - oneliner_xor_block *aux_block; - GList *aux_blocks; - - oneliner_context_seed(context, (gint32) str->data_len); - str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); - g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); - str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GList *)); - g_array_set_size(str->aux_graph_for_source_blocks, str->n_blocks_needed); - - for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { - aux_blocks = NULL; - - for (tmp2 = 0; tmp2 < Q; tmp2++) { - aux_block_nr = RANDOM(context, str->n_aux_blocks_needed); - - if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { - aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE); - g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr); - } - - oneliner_xor_block_add(aux_block, tmp); - aux_blocks = g_list_append(aux_blocks, aux_block); - } - - g_array_index(str->aux_graph_for_source_blocks, GList *, tmp) = aux_blocks; - } - - g_free(zeroes); - g_free(context); -} - -static VALUE -rb_oneliner_superstring_decode(VALUE self, VALUE chunk) -{ - oneliner_superstring *str; - guint32 data_len; - guint32 seed; - guint32 blocks_needed; - - Check_Type(chunk, T_STRING); - - RB_ONELINER(self, str); - - if (RSTRING(chunk)->len < 8) - rb_raise(rb_eRuntimeError, "Oneliner::SuperString#decode(String chunk) needs an argument that is at least 8 characters long."); - - data_len = ((guint32 *) RSTRING(chunk)->ptr)[0]; - seed = ((guint32 *) RSTRING(chunk)->ptr)[1]; - - if (str->data_len == 0) { - str->data_len = data_len; - } else if (str->data_len != data_len) { - rb_raise(rb_eRuntimeError, "Oneliner::Superstring#decode(String chunk) needs all consecutive calls to be with arguments having the same first four characters. Didn't you use chunks produced using #encode calls from the same instance?"); - } - - if (str->blocks == NULL) { - oneliner_superstring_initialize(str, data_len); - str->blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->blocks, str->n_blocks_needed); - str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - str->graph = g_array_new(FALSE, TRUE, sizeof(GList *)); - oneliner_superstring_build_aux_graph(str); - } - - oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); - - return oneliner_superstring_decode_done(str); -} - -static guint8 * -oneliner_superstring_get_check_block(oneliner_superstring *str, oneliner_context *context) -{ - guint32 degree = oneliner_context_get_degree(context); - guint32 block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - guint8 *rval; - guint32 tmp; - - ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); - for (tmp = 2; tmp <= degree; tmp++) - oneliner_string_xor(rval, - oneliner_superstring_get_combined_block(str, RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed)), - str->n_chars_in_block); - - return rval; -} - -static guint32 -oneliner_superstring_encode(oneliner_superstring *str, guint8 **buffer, guint32 len) -{ - oneliner_context *context = oneliner_context_new(); - GArray *rval_ary = g_array_new(FALSE, FALSE, sizeof(guint8 *)); - guint8 prepend[8]; - gint32 tmp; - - sranddev(); - tmp = (gint32) rand(); - oneliner_context_seed(context, tmp); - - ( (guint32 *) prepend )[0] = str->data_len; - ( (guint32 *) prepend )[1] = (guint32) tmp; - - while ((rval_ary->len * str->block_size) / 8 < len) { - guint8 *check_block = oneliner_superstring_get_check_block(str, context); - g_array_append_val(rval_ary, check_block); - } - - // Here I let tmp describe the number of bytes needed to contain the rval_ary considering the block - // size. And since we cant really truncate it at the end at this stage (like we can in the final build_data_from_blocks) - // the data_len argument is the same as the n_bytes_for_blocks argument. Also, we want to prepend the original data-len - // and seed, so we use the prepend argument. - tmp = (guint32) ceil((rval_ary->len * str->block_size) / 8); - *buffer = oneliner_superstring_build_data_from_blocks(tmp, - tmp, - str->block_size, - rval_ary, - 8, - prepend); - g_free(context); - g_array_free(rval_ary, TRUE); - - return tmp; -} - -static void -oneliner_superstring_free_xor_block(gpointer xor_block, gpointer user_data) -{ - oneliner_xor_block_free((oneliner_xor_block *) xor_block); -} - -static void -oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, gboolean free_xor_blocks) -{ - guint32 tmp; - for (tmp = 0; tmp < ary->len; tmp++) { - GList *list; - if ((list = (GList *) g_array_index(ary, GList *, tmp)) != NULL) { - if (free_xor_blocks) - g_list_foreach(list, oneliner_superstring_free_xor_block, NULL); - g_list_free(list); - } - } - g_array_free(ary, FALSE); -} - -static void -oneliner_superstring_free(oneliner_superstring *str) -{ - guint32 tmp; - if (str->blocks != NULL) - g_array_free(str->blocks, TRUE); - if (str->aux_blocks != NULL) - g_array_free(str->aux_blocks, TRUE); - if (str->graph != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, TRUE); - if (str->aux_graph_for_aux_blocks != NULL) { - for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) - oneliner_xor_block_free((oneliner_xor_block *) g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)); - } - if (str->aux_graph_for_source_blocks != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, FALSE); - - g_free(str); -} - -static VALUE -rb_oneliner_superstring_alloc(VALUE klass) -{ - oneliner_superstring *str = g_new0(oneliner_superstring, 1); - return Data_Wrap_Struct(klass, NULL, oneliner_superstring_free, str); -} - -static VALUE -oneliner_superstring_get_blocks(GArray *container, guint32 len) -{ - guint32 tmp; - VALUE rval = rb_ary_new(); - for (tmp = 0; tmp < container->len; tmp++) { - guint8 *tmp_block = g_array_index(container, guint8 *, tmp); - rb_ary_push(rval, rb_str_new((gchar *) tmp_block, len)); - } - return rval; -} - -static VALUE -rb_oneliner_superstring_blocks(VALUE self) -{ - oneliner_superstring *str; - RB_ONELINER(self, str); - return oneliner_superstring_get_blocks(str->blocks, str->n_chars_in_block); -} - -static VALUE -rb_oneliner_superstring_aux_blocks(VALUE self) -{ - oneliner_superstring *str; - RB_ONELINER(self, str); - return oneliner_superstring_get_blocks(str->aux_blocks, str->n_chars_in_block); -} - -static VALUE -rb_oneliner_superstring_to_s(VALUE self) -{ - oneliner_superstring *str; - VALUE rval; - guint8 *tmp_data; - - RB_ONELINER(self, str); - if (str->blocks == NULL) - return rb_str_new2(""); - tmp_data = oneliner_superstring_build_data(str); - rval = rb_str_new((gchar *) tmp_data, str->data_len); - g_free(tmp_data); - return rval; -} - -static VALUE -rb_oneliner_superstring_block_size(VALUE self) -{ - oneliner_superstring *str; - RB_ONELINER(self, str); - return INT2NUM(str->block_size); -} - -static VALUE -rb_oneliner_superstring_encode(VALUE self, VALUE size) -{ - guint8 *chunk; - VALUE rval; - oneliner_superstring *str; - guint32 chunk_size; - - Check_Type(size, T_FIXNUM); - if (NUM2INT(size) < 8) - rb_raise(rb_eRuntimeError, "Oneliner::SuperString#encode(Fixnum size) needs a size of at least 8."); - - RB_ONELINER(self, str); - - chunk_size = oneliner_superstring_encode(str, &chunk, NUM2INT(size)); - rval = rb_str_new((gchar *) chunk, chunk_size); - - g_free(chunk); - - return rval; -} - -static VALUE -rb_oneliner_superstring_chunk_blocks(VALUE self, VALUE chunk) -{ - oneliner_superstring *str; - VALUE rval; - GArray *blocks; - - Check_Type(chunk, T_STRING); - - if (RSTRING(chunk)->len < 8) - rb_raise(rb_eRuntimeError, "Oneliner::SuperString.chunk_blocks(String chunk) needs an argument that is at least 8 characters long."); - - RB_ONELINER(self, str); - blocks = oneliner_superstring_get_blocks_from_chunk(str, - (guint8 *) RSTRING(chunk)->ptr + 8, - (guint32) RSTRING(chunk)->len - 8); - rval = oneliner_superstring_get_blocks(blocks, - str->n_chars_in_block); - g_array_free(blocks, TRUE); - return rval; -} - -#ifdef __cplusplus -extern "C" { -#endif - void Init_oneliner_ext() { - VALUE rb_string = rb_define_class("String", rb_cObject); - rb_define_method(rb_string, "xor!", rb_oneliner_string_xor, 1); - - rb_superstring = rb_define_class_under(rb_define_module("Oneliner"), - "SuperString", - rb_cObject); - rb_define_alloc_func(rb_superstring, rb_oneliner_superstring_alloc); - rb_define_method(rb_superstring, "initialize", rb_oneliner_superstring_initialize, -1); - rb_define_method(rb_superstring, "blocks", rb_oneliner_superstring_blocks, 0); - rb_define_method(rb_superstring, "aux_blocks", rb_oneliner_superstring_aux_blocks, 0); - rb_define_method(rb_superstring, "to_s", rb_oneliner_superstring_to_s, 0); - rb_define_method(rb_superstring, "encode", rb_oneliner_superstring_encode, 1); - rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); - rb_define_method(rb_superstring, "chunk_blocks", rb_oneliner_superstring_chunk_blocks, 1); - rb_define_method(rb_superstring, "decode", rb_oneliner_superstring_decode, 1); - } -#ifdef __cplusplus -} -#endif - From nobody at rubyforge.org Mon May 21 14:54:32 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 14:54:32 -0400 (EDT) Subject: [Archipelago-submits] [282] trunk/oneliner: ok, went back to one monolithic file. Message-ID: <20070521185432.9BEFE5240A59@rubyforge.org> Revision: 282 Author: zond Date: 2007-05-21 14:54:32 -0400 (Mon, 21 May 2007) Log Message: ----------- ok, went back to one monolithic file. i dont have the balls for a real c project :) Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Added Paths: ----------- trunk/oneliner/ext/oneliner.h Removed Paths: ------------- trunk/oneliner/ext/context.c trunk/oneliner/ext/graph_insertion.c trunk/oneliner/ext/string.c trunk/oneliner/ext/xor_block.c Property Changed: ---------------- trunk/oneliner/ Property changes on: trunk/oneliner ___________________________________________________________________ Name: svn:ignore - pkg Makefile oneliner_ext.bundle mkmf.log .gdb_history tmp.rb + pkg Makefile oneliner.bundle mkmf.log .gdb_history tmp.rb Deleted: trunk/oneliner/ext/context.c =================================================================== --- trunk/oneliner/ext/context.c 2007-05-21 18:28:34 UTC (rev 281) +++ trunk/oneliner/ext/context.c 2007-05-21 18:54:32 UTC (rev 282) @@ -1,81 +0,0 @@ - -// -// The distribution of degrees. -// -static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; - -// -// Encrypt the context again -// -static void -oneliner_context_randomize(oneliner_context *context) -{ - AES_KEY key; - - AES_set_encrypt_key((guint8 *) "0123456789012345", 128, &key); - - AES_encrypt((guint8 *) context + 4, - (guint8 *) context + 4, - &key); - * (guint32 *) context = 1; -} - -// -// Fill the buffer of context with seed and randomize it. -// -static gint32 -oneliner_context_seed(oneliner_context *context, gint32 seed) -{ - gint32 tmp; - - for (tmp = 1; tmp < 5; tmp++) - ( (gint32 *) context )[tmp] = seed; - - oneliner_context_randomize(context); - - return seed; -} - -// -// Return an int that is the next random in the context -// -static gint32 -oneliner_context_random(oneliner_context *context) -{ - gint32 *int_context = (gint32 *) context; - if (int_context[0] < 5) { - gint32 return_value = int_context[int_context[0]]; - int_context[0]++; - return return_value; - } else { - oneliner_context_randomize(context); - return oneliner_context_random(context); - } -} - -// -// Initialize a context. -// -static oneliner_context * -oneliner_context_new() -{ - return (oneliner_context *) g_new0(guint8, 4 * 5); -} - -// -// Get a random degree -// -static guint32 -oneliner_context_get_degree(oneliner_context *context) -{ - gdouble f; - guint32 tmp = 0; - - f = RANDFLOAT(context); - while (f > 0) { - tmp++; - f = f - P[tmp]; - } - return tmp; -} - Deleted: trunk/oneliner/ext/graph_insertion.c =================================================================== --- trunk/oneliner/ext/graph_insertion.c 2007-05-21 18:28:34 UTC (rev 281) +++ trunk/oneliner/ext/graph_insertion.c 2007-05-21 18:54:32 UTC (rev 282) @@ -1,41 +0,0 @@ - -// -// An insertion to do into the graph of a superstring. -// -typedef struct { - guint32 source_block_nr; - oneliner_xor_block *check_block; -} oneliner_graph_insertion; - -static oneliner_graph_insertion * -oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) -{ - oneliner_graph_insertion *rval = g_new0(oneliner_graph_insertion, 1); - rval->check_block = check_block; - rval->source_block_nr = source_block_nr; - return rval; -} - -static void -oneliner_graph_insertion_free_with_check_block(gpointer insertion, gpointer user_data) -{ - oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); - g_free(insertion); -} - -static void -oneliner_insertion_execute(gpointer insertion, gpointer string) -{ - oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; - oneliner_superstring *str = (oneliner_superstring *) string; - - g_array_index(str->graph, - GList *, - ins->source_block_nr) = g_list_append(g_array_index(str->graph, - GList *, - ins->source_block_nr), - ins->check_block); - - g_free(insertion); -} - Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-21 18:28:34 UTC (rev 281) +++ trunk/oneliner/ext/oneliner.c 2007-05-21 18:54:32 UTC (rev 282) @@ -21,6 +21,7 @@ #include #include #include +#include "oneliner.h" // // The classes @@ -120,12 +121,266 @@ static void oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr); -#include "context.c" -#include "string.c" -#include "xor_block.c" -#include "graph_insertion.c" // +// Encrypt the context again +// +static void +oneliner_context_randomize(oneliner_context *context) +{ + AES_KEY key; + + AES_set_encrypt_key((guint8 *) "0123456789012345", 128, &key); + + AES_encrypt((guint8 *) context + 4, + (guint8 *) context + 4, + &key); + * (guint32 *) context = 1; +} + +// +// Fill the buffer of context with seed and randomize it. +// +static gint32 +oneliner_context_seed(oneliner_context *context, gint32 seed) +{ + gint32 tmp; + + for (tmp = 1; tmp < 5; tmp++) + ( (gint32 *) context )[tmp] = seed; + + oneliner_context_randomize(context); + + return seed; +} + +// +// Return an int that is the next random in the context +// +static gint32 +oneliner_context_random(oneliner_context *context) +{ + gint32 *int_context = (gint32 *) context; + if (int_context[0] < 5) { + gint32 return_value = int_context[int_context[0]]; + int_context[0]++; + return return_value; + } else { + oneliner_context_randomize(context); + return oneliner_context_random(context); + } +} + +// +// Initialize a context. +// +static oneliner_context * +oneliner_context_new() +{ + return (oneliner_context *) g_new0(guint8, 4 * 5); +} + +// +// Get a random degree +// +static guint32 +oneliner_context_get_degree(oneliner_context *context) +{ + gdouble f; + guint32 tmp = 0; + + f = RANDFLOAT(context); + while (f > 0) { + tmp++; + f = f - P[tmp]; + } + return tmp; +} + +// +// Make object into object ^ subject +// +static void +oneliner_string_xor(guint8 *object, guint8 *subject, guint32 len) +{ + guint32 tmp; + +#ifdef G_HAVE_GINT64 + for (tmp = 0; tmp < len / 8; tmp++) + ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; + for (tmp = tmp * 2; tmp < len / 4; tmp++) + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; +#else + for (tmp = 0; tmp < len / 4; tmp++) + ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; + for (tmp = tmp * 4; tmp < len; tmp++) + object[tmp] = object[tmp] ^ subject[tmp]; +#endif +} + +static VALUE +rb_oneliner_string_xor(VALUE self, VALUE object) +{ + Check_Type(object, T_STRING); + rb_str_modify(self); + oneliner_string_xor((guint8 *) RSTRING(self)->ptr, (guint8 *) RSTRING(object)->ptr, MIN(RSTRING(self)->len, RSTRING(object)->len)); + return self; +} + +// +// An as yet mysterious block. +// +typedef struct { + gboolean initialized; + guint8 *sum; + GHashTable *source_blocks; +} oneliner_xor_block; + +#define XOR_BLOCK_FINISHED(xor_block) ((xor_block)->initialized && \ + (g_hash_table_size((xor_block)->source_blocks) == 1) && \ + ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) +#define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) + +static oneliner_xor_block * +oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized) +{ + oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); + ALLOC_COPY8(rval->sum, data, len); + rval->initialized = initialized; + rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); +} + +static gboolean +oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) +{ + g_free(key); + g_free(data); + return TRUE; +} + +static void +oneliner_xor_block_free(oneliner_xor_block *xor_block) +{ + g_free(xor_block->sum); + g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); + g_hash_table_destroy(xor_block->source_blocks); + g_free(xor_block); +} + +static void +oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) +{ + guint32 *uses; + guint32 *source; + if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { + (*uses)++; + } else { + uses = g_new(guint32, 1); + source = g_new(guint32, 1); + *uses = 1; + *source = source_block_nr; + g_hash_table_insert(xor_block->source_blocks, source, uses); + } +} + +static void +oneliner_xor_block_set_sum(oneliner_xor_block *xor_block, guint8 *sum, guint32 len) +{ + ALLOC_COPY8(xor_block->sum, sum, len); + xor_block->initialized = TRUE; +} + +static void +oneliner_xor_block_last_source_block_nr_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) key; +} + +static guint32 +oneliner_xor_block_last_source_block_nr(oneliner_xor_block *xor_block) +{ + guint32 source_block_nr; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_source_block_nr_iterator, &source_block_nr); + return source_block_nr; +} + +static void +oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) +{ + * (guint32 *) user_data = * (guint32 *) data; +} + +static guint32 +oneliner_xor_block_last_uses(oneliner_xor_block *xor_block) +{ + guint32 uses; + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_uses_iterator, &uses); + return uses; +} + +static void +oneliner_xor_block_apply(oneliner_xor_block *xor_block, oneliner_superstring *str, guint32 found_block_nr) +{ + guint32 tmp; + guint32 *uses; + guint32 *old_key; + + g_hash_table_lookup_extended(xor_block->source_blocks, &found_block_nr, (gpointer) old_key, (gpointer) uses); + + for (tmp = 0; tmp < *uses; tmp++) { + oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); + } + + g_hash_table_remove(xor_block->source_blocks, &found_block_nr); + g_free(old_key); + g_free(uses); +} + + +// +// An insertion to do into the graph of a superstring. +// +typedef struct { + guint32 source_block_nr; + oneliner_xor_block *check_block; +} oneliner_graph_insertion; + +static oneliner_graph_insertion * +oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) +{ + oneliner_graph_insertion *rval = g_new0(oneliner_graph_insertion, 1); + rval->check_block = check_block; + rval->source_block_nr = source_block_nr; + return rval; +} + +static void +oneliner_graph_insertion_free_with_check_block(gpointer insertion, gpointer user_data) +{ + oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); + g_free(insertion); +} + +static void +oneliner_insertion_execute(gpointer insertion, gpointer string) +{ + oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; + oneliner_superstring *str = (oneliner_superstring *) string; + + g_array_index(str->graph, + GList *, + ins->source_block_nr) = g_list_append(g_array_index(str->graph, + GList *, + ins->source_block_nr), + ins->check_block); + + g_free(insertion); +} + + +// // Return the block size in bits for a string of the given length. // static guint32 Added: trunk/oneliner/ext/oneliner.h =================================================================== --- trunk/oneliner/ext/oneliner.h (rev 0) +++ trunk/oneliner/ext/oneliner.h 2007-05-21 18:54:32 UTC (rev 282) @@ -0,0 +1,4 @@ +// +// The distribution of degrees. +// +static double P[] = {0.0,0.00943264209782069,0.49551807459988,0.165172691533293,0.0825863457666466,0.049551807459988,0.0330345383066586,0.0235960987904705,0.0176970740928528,0.0137643909611078,0.0110115127688862,0.00900941953817963,0.00750784961514969,0.00635279582820358,0.00544525356703164,0.00471921975809409,0.00412931728833233,0.00364351525441088,0.003238680226143,0.00289776651812795,0.00260798986631516,0.00235960987904705,0.00214509989004277,0.00195856946482166,0.00179535534275319,0.00165172691533293,0.00152467099876886,0.00141173240626746,0.00131089437724836,0.00122048786847261,0.00113912201057444,0.00106563026795673,0.000999028376209435,0.000938481201893711,0.000883276425311728,0.000832803486722487,0.000786536626349015,0.000744021133032852,0.000704862126031123,0.000668715350337219,0.000635279582820358,0.000604290334877902,0.000575514604645621,0.000548746483499313,0.000523803461522071,0.000500523307676646,0.000478761424734183,0.00045838859814975,0.000439289073226844,0.000421358906972687,0.000404504550693779,0.00038864162713716,0.00037369387224727,0.000359592216690769,0.000346273986442963,0.000333682205117764,0.000321764983506415,0.000310474984085138,0.000299768950151167,0.000289607290824009,0.000279953714463209,0.00027077490415294,0.000262040229825425,0.00025372149237065,0.000245792695734067,0.000238229843557634,0.000231010757389221,0.000224114913885065,0.000217523298770799,0.000211218275618022,0.000205183467743221,0.000199403651750455,0.000193864661424053,0.000188553300837093,0.000183457265679333,0.000178565071927885,0.000173865991087677,0.000169349991319166,0.000165007683849444,0.000160830274131736,0.000156809517278443,0.000152937677345642,0.000149207490093309,0.000145612128886241,0.000142145173436569,0.000138800581120414,0.000135572660629242,0.000132456047741213,0.000129445683019822,0.000126536791266568,0.000123724862571755,0.000121005634822925,0.000118375077544166,0.000115829376951819,0.000113364922123056,0.000110978292183624,0.000108666244429798,0.000106425703307534,0.000104253750178809,0.00010214761381156,0.000100104661535329,9.81223910098771e-05,9.61984225587031e-05,9.43304920235826e-05,9.25164441000522e-05,9.07542261171941e-05,8.90418822281904e-05,8.73775479809345e-05,8.57594452405468e-05,8.4185877437968e-05,8.2655225120914e-05,8.11659417854021e-05,7.97165499678056e-05,7.83056375789949e-05,7.69318544635739e-05,7.55939091685552e-05,7.42905659070284e-05,7.30206417034895e-05,7.17830037085151e-05,7.05765666713972e-05,6.94002905602072e-05,6.82531783195426e-05,6.71342737569272e-05,6.60426595494975e-05,6.49774553632153e-05,6.39378160774038e-05,6.29229301079212e-05,6.19320178227571e-05,6.09643300442765e-05,6.00191466327373e-05,5.90957751460799e-05,5.81935495713305e-05,5.73118291232801e-05,5.64499971063886e-05,5.5607459836144e-05,5.47836456163493e-05,5.39780037690501e-05,5.31900037140274e-05,5.24191340949836e-05,5.1664901949732e-05,5.09268319218787e-05,5.02044655116393e-05,4.9497360363588e-05,4.88050895892721e-05,4.81272411227544e-05,4.74634171072682e-05,4.68132333112782e-05,4.61763185723492e-05,4.55523142673175e-05,4.49408738073535e-05,4.43416621565888e-05,4.37543553730578e-05,4.31786401707807e-05,4.26142135018816e-05,4.20607821577013e-05,4.15180623879246e-05,4.09857795367973e-05,4.04636676955642e-05,3.99514693703039e-05,3.94489351643882e-05,3.89558234748333e-05,3.8471900201854e-05,3.79969384709669e-05,3.75307183670287e-05,3.70730266796259e-05,3.66236566592668e-05,3.61824077838539e-05,3.57490855349455e-05,3.5323501183339e-05,3.49054715835362e-05,3.4494818976671e-05,3.40913708015053e-05,3.36949595131157e-05,3.33054224089178e-05,3.29226014616889e-05,3.25463431592696e-05,3.21764983506415e-05,3.18129220980919e-05,3.1455473535192e-05,3.11040157303295e-05,3.07584155555481e-05,3.04185435604592e-05,3.00842738510036e-05,2.97554839728505e-05,2.94320547992326e-05,2.91138704230246e-05,2.88008180528846e-05,2.84927879132816e-05,2.81896731482467e-05,2.78913697286885e-05,2.75977763631233e-05,2.7308794411677e-05,2.70243278032221e-05,2.67442829555203e-05,2.64685686982469e-05,2.61970961987777e-05,2.59297788906269e-05,2.56665324044276e-05,2.54072745013526e-05,2.51519250088767e-05,2.49004057587879e-05,2.46526405273572e-05,2.44085549775814e-05,2.4168076603418e-05,2.39311346759335e-05,2.36976601912903e-05,2.3467585820501e-05,2.32408458608827e-05,2.30173761891434e-05,2.27971142160416e-05,2.25799988425555e-05,2.23659704175075e-05,2.21549706965877e-05,2.1946942802723e-05,2.17418311877443e-05,2.15395815953001e-05,2.13401410249733e-05,2.11434576975542e-05,2.09494810214298e-05,2.07581615600469e-05,2.05694510004101e-05,2.03833021225783e-05,2.01996687701227e-05,2.00185058215117e-05,1.98397691623911e-05,1.96634156587254e-05,1.94894031307721e-05,1.93176903278578e-05,1.91482369039292e-05,1.89810033938512e-05,1.88159511904264e-05,1.8653042522111e-05,1.84922404314032e-05,1.83335087538804e-05,1.81768120978643e-05,1.8022115824691e-05,1.78693860295665e-05,1.77185895229879e-05,1.75696938127107e-05,1.74226670862445e-05,1.72774781938591e-05,1.71340966320844e-05,1.6992492527687e-05,1.68526366221093e-05,1.67145002563543e-05,1.65780553563024e-05,1.64432744184463e-05,1.63101304960297e-05,1.61785971855779e-05,1.60486486138062e-05,1.59202594248957e-05,1.57934047681237e-05,1.5668060285837e-05,1.55442021017592e-05,1.54218068096194e-05,1.53008514620929e-05,1.51813135600453e-05,1.50631710420683e-05,1.49464022743003e-05,1.4830986040522e-05,1.4716901532518e-05,1.46041283406979e-05,1.44926464449674e-05,1.43824362058421e-05,1.42734783557979e-05,1.41657539908485e-05,1.40592445623459e-05,1.39539318689949e-05,1.38497980490771e-05,1.37468255728758e-05,1.36449972352989e-05,1.35442961486915e-05,1.34447057358335e-05,1.33462097231168e-05,1.32487921338969e-05,1.31524372820141e-05,1.30571297654777e-05,1.29628544603118e-05,1.28695965145542e-05,1.27773413424068e-05,1.26860746185325e-05,1.25957822724931e-05,1.25064504833265e-05,1.24180656742571e-05,1.23306145075369e-05,1.22440838794139e-05,1.21584609152222e-05,1.20737329645934e-05,1.19898875967838e-05,1.1906912596114e-05,1.18247959575201e-05,1.17435258822107e-05,1.16630907734284e-05,1.15834792323129e-05,1.15046800538618e-05,1.14266822229881e-05,1.13494749106706e-05,1.12730474701947e-05,1.1197389433482e-05,1.11224905075055e-05,1.10483405707888e-05,1.09749296699863e-05,1.09022480165426e-05,1.08302859834301e-05,1.07590341019602e-05,1.06884830586687e-05,1.06186236922721e-05,1.05494469906938e-05,1.04809440881568e-05,1.04131062623435e-05,1.03459249316187e-05,1.02793916523157e-05,1.02134981160829e-05,1.01482361472901e-05,1.0083597700492e-05,1.00195748579492e-05,9.95615982720272e-06,9.89334493870302e-06,9.83112264349106e-06,9.76948551092998e-06,9.70842622648667e-06,9.64793758956152e-06,9.58801251136548e-06,9.5286440128431e-06,9.46982522264036e-06,9.41154937511642e-06,9.35380980839792e-06,9.29659996247499e-06,9.23991337733795e-06,9.18374369115352e-06,9.12808463847987e-06,9.07293004851926e-06,9.0182738434077e-06,8.96411003654039e-06,8.91043273093236e-06,8.85723611761336e-06,8.80451447405614e-06,8.75226216263741e-06,8.70047362913068e-06,8.6491434012302e-06,8.59826608710532e-06,8.54783637398447e-06,8.49784902676818e-06,8.44829888667041e-06,8.39918086988744e-06,8.35048996629389e-06,8.30222123816503e-06,8.25436981892488e-06,8.20693091191957e-06,8.15989978921516e-06,8.11327179041964e-06,8.06704232152836e-06,8.02120685379241e-06,7.97576092260944e-06,7.93070012643651e-06,7.88602012572419e-06,7.84171664187181e-06,7.79778545620306e-06,7.7542224089617e-06,7.71102339832682e-06,7.66818437944722e-06,7.62570136349461e-06,7.58357041673497e-06,7.54178765961797e-06,7.50034926588381e-06,7.45925146168718e-06,7.41849052473807e-06,7.37806278345885e-06,7.33796461615744e-06,7.29819245021621e-06,7.25874276129612e-06,7.21961207255598e-06,7.18079695388632e-06,7.14229402115771e-06,7.10409993548307e-06,7.06621140249383e-06,7.0286251716295e-06,6.99133803544048e-06,6.95434682890376e-06,6.91764842875123e-06,6.88123975281044e-06,6.84511775935736e-06,6.80927944648115e-06,6.77372185146036e-06,6.73844205015067e-06,6.70343715638365e-06,6.66870432137648e-06,6.63424073315232e-06,6.60004361597112e-06,6.56611022977075e-06,6.53243786961808e-06,6.49902386516991e-06,6.46586558014353e-06,6.43296041179674e-06,6.40030579041707e-06,6.36789917882002e-06,6.33573807185628e-06,6.30381999592753e-06,6.27214250851081e-06,6.24070319769121e-06,6.20949968170275e-06,6.1785296084773e-06,6.1477906552013e-06,6.1172805278802e-06,6.08699696091049e-06,6.05693771665908e-06,6.02710058504993e-06,5.99748338315779e-06,5.96808395480898e-06,5.93890017018888e-06,5.90992992545625e-06,5.88117114236401e-06,5.85262176788651e-06,5.82427977385317e-06,5.79614315658817e-06,5.76820993655642e-06,5.74047815801529e-06,5.71294588867229e-06,5.6856112193485e-06,5.65847226364755e-06,5.63152715763018e-06,5.60477405949417e-06,5.5782111492596e-06,5.55183662845932e-06,5.52564871983451e-06,5.49964566703529e-06,5.4738257343262e-06,5.44818720629657e-06,5.42272838757556e-06,5.3974476025519e-06,5.37234319509817e-06,5.34741352829957e-06,5.32265698418707e-06,5.29807196347489e-06,5.2736568853022e-06,5.24941018697897e-06,5.22533032373594e-06,5.20141576847857e-06,5.17766501154488e-06,5.15407656046723e-06,5.13064893973783e-06,5.10738069057802e-06,5.08427037071115e-06,5.06131655413909e-06,5.03851783092225e-06,5.01587280696305e-06,4.99338010379281e-06,4.97103835836197e-06,4.94884622283357e-06,4.92680236437997e-06,4.90490546498272e-06,4.88315422123557e-06,4.86154734415046e-06,4.84008355896657e-06,4.81876160496231e-06,4.79758023527017e-06,4.77653821669442e-06,4.75563432953165e-06,4.73486736739396e-06,4.71423613703494e-06,4.69373945817827e-06,4.67337616334886e-06,4.65314509770666e-06,4.63304511888287e-06,4.61307509681872e-06,4.5932339136066e-06,4.57352046333361e-06,4.55393365192747e-06,4.5344723970047e-06,4.5151356277211e-06,4.49592228462441e-06,4.47683131950923e-06,4.45786169527403e-06,4.43901238578027e-06,4.42028237571368e-06,4.40167066044752e-06,4.38317624590782e-06,4.36479814844071e-06,4.34653539468154e-06,4.32838702142608e-06,4.31035207550348e-06,4.29242961365107e-06,4.27461870239111e-06,4.25691841790916e-06,4.23932784593433e-06,4.22184608162119e-06,4.20447222943345e-06,4.18720540302921e-06,4.17004472514794e-06,4.15298932749907e-06,4.13603835065214e-06,4.11919094392851e-06,4.10244626529465e-06,4.08580348125694e-06,4.06926176675793e-06,4.05282030507406e-06,4.03647828771489e-06,4.02023491432368e-06,4.00408939257941e-06,3.98804093810013e-06,3.97208877434773e-06,3.95623213253397e-06,3.94047025152786e-06,3.92480237776433e-06,3.90922776515415e-06,3.89374567499512e-06,3.87835537588447e-06,3.86305614363246e-06,3.84784726117722e-06,3.83272801850069e-06,3.81769771254578e-06,3.80275564713464e-06,3.78790113288802e-06,3.77313348714577e-06,3.75845203388839e-06,3.7438561036597e-06,3.72934503349048e-06,3.7149181668232e-06,3.70057485343778e-06,3.68631444937829e-06,3.67213631688068e-06,3.65803982430149e-06,3.64402434604746e-06,3.63008926250617e-06,3.61623395997752e-06,3.60245783060618e-06,3.5887602723149e-06,3.57514068873875e-06,3.56159848916019e-06,3.54813308844503e-06,3.5347439069792e-06,3.5214303706064e-06,3.50819191056653e-06,3.49502796343494e-06,3.48193797106253e-06,3.4689213805165e-06,3.45597764402204e-06,3.44310621890464e-06,3.43030656753324e-06,3.4175781572641e-06,3.40492046038535e-06,3.3923329540623e-06,3.37981512028347e-06,3.36736644580729e-06,3.35498642210947e-06,3.34267454533108e-06,3.33043031622731e-06,3.31825324011678e-06,3.30614282683169e-06,3.29409859066837e-06,3.28212005033866e-06,3.27020672892183e-06,3.25835815381704e-06,3.24657385669654e-06,3.23485337345937e-06,3.22319624418564e-06,3.21160201309145e-06,3.2000702284843e-06,3.18860044271912e-06,3.17719221215483e-06,3.16584509711142e-06,3.1545586618276e-06,3.14333247441896e-06,3.13216610683666e-06,3.1210591348266e-06,3.11001113788916e-06,3.09902169923937e-06,3.08809040576763e-06,3.07721684800084e-06,3.06640062006411e-06,3.05564131964283e-06,3.04493854794531e-06,3.03429190966578e-06,3.02370101294792e-06,3.0131654693488e-06,3.00268489380324e-06,2.99225890458865e-06,2.98188712329024e-06,2.97156917476675e-06,2.96130468711643e-06,2.95109329164362e-06,2.94093462282557e-06,2.93082831827977e-06,2.92077401873164e-06,2.91077136798256e-06,2.90082001287835e-06,2.89091960327808e-06,2.8810697920233e-06,2.87127023490758e-06,2.86152059064643e-06,2.85182052084763e-06,2.84216968998182e-06,2.8325677653535e-06,2.82301441707237e-06,2.81350931802499e-06,2.80405214384676e-06,2.79464257289425e-06,2.78528028621789e-06,2.77596496753489e-06,2.76669630320255e-06,2.75747398219187e-06,2.74829769606145e-06,2.73916713893168e-06,2.73008200745927e-06,2.72104200081205e-06,2.71204682064408e-06,2.703096171071e-06,2.69418975864572e-06,2.68532729233439e-06,2.67650848349257e-06,2.66773304584177e-06,2.65900069544622e-06,2.65031115068986e-06,2.64166413225367e-06,2.63305936309324e-06,2.62449656841651e-06,2.61597547566191e-06,2.60749581447662e-06,2.59905731669515e-06,2.5906597163181e-06,2.58230274949127e-06,2.57398615448486e-06,2.56570967167301e-06,2.55747304351354e-06,2.54927601452792e-06,2.54111833128143e-06,2.5329997423636e-06,2.52491999836882e-06,2.5168788518772e-06,2.50887605743562e-06,2.500911371539e-06,2.49298455261178e-06,2.48509536098959e-06,2.47724355890115e-06,2.46942891045036e-06,2.46165118159855e-06,2.45391014014698e-06,2.44620555571952e-06,2.43853719974547e-06,2.43090484544267e-06,2.42330826780066e-06,2.41574724356416e-06,2.4082215512166e-06,2.40073097096399e-06,2.39327528471876e-06,2.38585427608397e-06,2.37846773033758e-06,2.37111543441691e-06,2.36379717690327e-06,2.35651274800681e-06,2.3492619395514e-06,2.34204454495985e-06,2.33486035923911e-06,2.32770917896579e-06,2.32059080227171e-06,2.31350502882965e-06,2.30645165983932e-06,2.29943049801333e-06,2.29244134756344e-06,2.28548401418692e-06,2.27855830505302e-06,2.27166402878962e-06,2.26480099547001e-06,2.25796901659982e-06,2.25116790510403e-06,2.24439747531425e-06,2.23765754295595e-06,2.23094792513599e-06,2.22426844033019e-06,2.21761890837106e-06,2.21099915043562e-06,2.20440898903343e-06,2.19784824799464e-06,2.19131675245825e-06,2.18481432886045e-06,2.17834080492309e-06,2.17189600964225e-06,2.16547977327699e-06,2.15909192733812e-06,2.15273230457718e-06,2.14640073897548e-06,2.14009706573326e-06,2.13382112125897e-06,2.12757274315865e-06,2.12135177022544e-06,2.11515804242916e-06,2.10899140090604e-06,2.10285168794853e-06,2.09673874699519e-06,2.09065242262075e-06,2.0845925605262e-06,2.07855900752902e-06,2.0725516115535e-06,2.06657022162116e-06,2.06061468784128e-06,2.05468486140145e-06,2.04878059455834e-06,2.04290174062847e-06,2.03704815397911e-06,2.03121969001922e-06,2.0254162051906e-06,2.01963755695895e-06,2.01388360380523e-06,2.00815420521688e-06,2.00244922167933e-06,1.99676851466747e-06,1.99111194663725e-06,1.98547938101734e-06,1.97987068220091e-06,1.97428571553744e-06,1.96872434732466e-06,1.96318644480054e-06,1.95767187613537e-06,1.95218051042391e-06,1.94671221767762e-06,1.94126686881699e-06,1.93584433566387e-06,1.93044449093398e-06,1.92506720822943e-06,1.91971236203129e-06,1.91437982769232e-06,1.90906948142965e-06,1.90378120031766e-06,1.89851486228082e-06,1.89327034608667e-06,1.88804753133884e-06,1.88284629847014e-06,1.8776665287357e-06,1.8725081042062e-06,1.86737090776119e-06,1.8622548230824e-06,1.85715973464715e-06,1.85208552772189e-06,1.84703208835566e-06,1.84199930337376e-06,1.83698706037139e-06,1.83199524770733e-06,1.82702375449782e-06,1.82207247061029e-06,1.81714128665735e-06,1.81223009399071e-06,1.80733878469519e-06,1.8024672515828e-06,1.79761538818689e-06,1.79278308875628e-06,1.78797024824955e-06,1.78317676232931e-06,1.77840252735654e-06,1.773647440385e-06,1.76891139915566e-06,1.76419430209125e-06,1.75949604829074e-06,1.75481653752401e-06,1.75015567022647e-06,1.74551334749377e-06,1.74088947107657e-06,1.73628394337531e-06,1.73169666743508e-06,1.72712754694053e-06,1.72257648621078e-06,1.71804339019444e-06,1.71352816446462e-06,1.70903071521406e-06,1.7045509492502e-06,1.70008877399038e-06,1.69564409745707e-06,1.69121682827311e-06,1.68680687565701e-06,1.68241414941832e-06,1.67803855995299e-06,1.67368001823883e-06,1.66933843583095e-06,1.66501372485729e-06,1.6607057980142e-06,1.65641456856196e-06,1.65213995032051e-06,1.64788185766505e-06,1.64364020552176e-06,1.63941490936361e-06,1.63520588520607e-06,1.63101304960297e-06,1.6268363196424e-06,1.62267561294255e-06,1.61853084764768e-06,1.61440194242409e-06,1.61028881645613e-06,1.60619138944224e-06,1.60210958159106e-06,1.59804331361748e-06,1.59399250673885e-06,1.58995708267116e-06,1.58593696362521e-06,1.58193207230293e-06,1.57794233189359e-06,1.57396766607018e-06,1.57000799898572e-06,1.56606325526968e-06,1.56213336002434e-06,1.55821823882127e-06,1.55431781769781e-06,1.55043202315357e-06,1.54656078214694e-06,1.54270402209171e-06,1.53886167085362e-06,1.53503365674702e-06,1.5312199085315e-06,1.5274203554086e-06,1.52363492701849e-06,1.51986355343676e-06,1.51610616517115e-06,1.51236269315839e-06,1.50863306876096e-06,1.50491722376401e-06,1.50121509037221e-06,1.49752660120668e-06,1.49385168930188e-06,1.49019028810261e-06,1.48654233146099e-06,1.48290775363345e-06,1.47928648927782e-06,1.47567847345031e-06,1.47208364160268e-06,1.46850192957932e-06,1.46493327361436e-06,1.46137761032889e-06,1.4578348767281e-06,1.45430501019849e-06,1.45078794850514e-06,1.44728362978895e-06,1.44379199256388e-06,1.44031297571433e-06,1.43684651849239e-06,1.43339256051525e-06,1.42995104176251e-06,1.42652190257363e-06,1.42310508364531e-06,1.41970052602894e-06,1.41630817112803e-06,1.41292796069574e-06,1.40955983683235e-06,1.40620374198274e-06,1.40285961893403e-06,1.39952741081305e-06,1.39620706108396e-06,1.39289851354584e-06,1.38960171233035e-06,1.38631660189931e-06,1.3830431270424e-06,1.37978123287485e-06,1.3765308648351e-06,1.37329196868255e-06,1.37006449049528e-06,1.36684837666782e-06,1.36364357390893e-06,1.36045002923936e-06,1.35726768998967e-06,1.35409650379811e-06,1.35093641860838e-06,1.34778738266757e-06,1.34464934452399e-06,1.3415222530251e-06,1.3384060573154e-06,1.33530070683439e-06,1.33220615131449e-06,1.32912234077904e-06,1.32604922554025e-06,1.3229867561972e-06,1.31993488363388e-06,1.31689355901721e-06,1.31386273379508e-06,1.3108423596944e-06,1.30783238871921e-06,1.30483277314876e-06,1.30184346553559e-06,1.2988644187037e-06,1.29589558574666e-06,1.29293692002578e-06,1.28998837516825e-06,1.28704990506536e-06,1.28412146387067e-06,1.28120300599824e-06,1.27829448612083e-06,1.27539585916818e-06,1.27250708032521e-06,1.26962810503036e-06,1.2667588889738e-06,1.26389938809575e-06,1.26104955858482e-06,1.2582093568763e-06,1.25537873965048e-06,1.25255766383104e-06,1.24974608658339e-06,1.24694396531302e-06,1.24415125766394e-06,1.24136792151704e-06,1.23859391498851e-06,1.23582919642827e-06,1.2330737244184e-06,1.23032745777159e-06,1.2275903555296e-06,1.22486237696176e-06,1.2221434815634e-06,1.21943362905439e-06,1.21673277937763e-06,1.21404089269759e-06,1.21135792939882e-06,1.20868385008447e-06,1.20601861557491e-06,1.20336218690624e-06,1.20071452532889e-06,1.19807559230619e-06,1.19544534951298e-06,1.19282375883423e-06,1.19021078236362e-06,1.18760638240221e-06,1.18501052145707e-06,1.18242316223991e-06,1.17984426766578e-06,1.17727380085169e-06,1.17471172511534e-06,1.17215800397379e-06,1.16961260114214e-06,1.16707548053229e-06,1.16454660625161e-06,1.16202594260172e-06,1.15951345407717e-06,1.15700910536426e-06,1.15451286133974e-06,1.15202468706962e-06,1.14954454780789e-06,1.1470724089954e-06,1.14460823625857e-06,1.14215199540823e-06,1.13970365243844e-06,1.13726317352529e-06,1.13483052502578e-06,1.13240567347657e-06,1.12998858559295e-06,1.1275792282676e-06,1.12517756856947e-06,1.12278357374273e-06,1.12039721120555e-06,1.11801844854906e-06,1.11564725353624e-06,1.11328359410078e-06,1.11092743834607e-06,1.10857875454407e-06,1.10623751113426e-06,1.10390367672258e-06,1.10157722008039e-06,1.09925811014337e-06,1.09694631601058e-06,1.09464180694333e-06,1.09234455236423e-06,1.09005452185613e-06,1.08777168516114e-06,1.08549601217963e-06,1.08322747296922e-06,1.08096603774382e-06,1.07871167687261e-06,1.07646436087913e-06,1.07422406044025e-06,1.07199074638528e-06,1.06976438969497e-06,1.06754496150058e-06,1.06533243308297e-06,1.06312677587161e-06,1.06092796144375e-06,1.05873596152341e-06,1.05655074798054e-06,1.05437229283006e-06,1.05220056823103e-06,1.0500355464857e-06,1.04787720003866e-06,1.04572550147595e-06,1.0435804235242e-06,1.04144193904977e-06,1.03931002105785e-06,1.03718464269168e-06,1.03506577723164e-06,1.03295339809443e-06,1.03084747883226e-06,1.02874799313199e-06,1.02665491481433e-06,1.024568217833e-06,1.02248787627395e-06,1.02041386435453e-06,1.0183461564227e-06,1.01628472695626e-06,1.01422955056201e-06,1.01218060197502e-06,1.01013785605781e-06,1.00810128779963e-06,1.00607087231564e-06,1.0040465848462e-06,1.00202840075605e-06,1.00001629553365e-06,9.98010244790354e-07,9.96010224259712e-07,9.9401620979673e-07,9.92028177377136e-07,9.90046103096662e-07,9.88069963170322e-07,9.86099733931697e-07,9.84135391832232e-07,9.82176913440526e-07,9.80224275441638e-07,9.78277454636391e-07,9.76336427940684e-07,9.74401172384806e-07,9.72471665112757e-07,9.70547883381574e-07,9.68629804560662e-07,9.66717406131125e-07,9.64810665685107e-07,9.62909560925136e-07,9.61014069663472e-07,9.5912416982146e-07,9.57239839428883e-07,9.55361056623331e-07,9.5348779964956e-07,9.51620046858865e-07,9.49757776708456e-07,9.47900967760835e-07,9.46049598683177e-07,9.44203648246722e-07,9.42363095326163e-07,9.40527918899043e-07,9.38698098045154e-07,9.36873611945941e-07,9.35054439883909e-07,9.3324056124204e-07,9.31431955503199e-07,9.29628602249562e-07,9.27830481162039e-07,9.26037572019697e-07,9.24249854699195e-07,9.22467309174221e-07,9.20689915514926e-07,9.18917653887371e-07,9.17150504552972e-07,9.15388447867951e-07,9.13631464282792e-07,9.11879534341694e-07,9.10132638682036e-07,9.0839075803384e-07,9.06653873219244e-07,9.04921965151968e-07,9.03195014836792e-07,9.01473003369039e-07,8.9975591193405e-07,8.98043721806678e-07,8.96336414350771e-07,8.94633971018671e-07,8.92936373350704e-07,8.91243602974684e-07,8.89555641605414e-07,8.87872471044192e-07,8.86194073178324e-07,8.84520429980632e-07,8.8285152350897e-07,8.81187335905748e-07,8.79527849397451e-07,8.77873046294164e-07,8.76222908989099e-07,8.74577419958134e-07,8.72936561759338e-07,8.71300317032517e-07,8.69668668498748e-07,8.68041598959929e-07,8.66419091298322e-07,8.64801128476103e-07,8.63187693534916e-07,8.61578769595428e-07,8.59974339856889e-07,8.58374387596691e-07,8.56778896169931e-07,8.55187849008984e-07,8.53601229623068e-07,8.52019021597816e-07,8.50441208594857e-07,8.48867774351389e-07,8.4729870267976e-07,8.45733977467054e-07,8.4417358267468e-07,8.42617502337952e-07,8.41065720565691e-07,8.39518221539811e-07,8.37974989514922e-07,8.36436008817925e-07,8.34901263847616e-07,8.33370739074294e-07,8.31844419039359e-07,8.30322288354932e-07,8.2880433170346e-07,8.27290533837335e-07,8.25780879578508e-07,8.2427535381811e-07,8.22773941516073e-07,8.21276627700757e-07,8.19783397468574e-07,8.18294235983618e-07,8.16809128477295e-07,8.15328060247962e-07,8.13851016660556e-07,8.12377983146238e-07,8.10908945202032e-07,8.09443888390465e-07,8.07982798339219e-07,8.06525660740771e-07,8.05072461352049e-07,8.0362318599408e-07,8.02177820551645e-07,8.00736350972935e-07,7.99298763269214e-07,7.97865043514471e-07,7.9643517784509e-07,7.95009152459512e-07,7.93586953617903e-07,7.92168567641821e-07,7.90753980913889e-07,7.89343179877468e-07,7.87936151036332e-07,7.86532880954344e-07,7.85133356255137e-07,7.83737563621794e-07,7.82345489796534e-07,7.80957121580391e-07,7.79572445832908e-07,7.78191449471822e-07,7.76814119472757e-07,7.75440442868915e-07,7.74070406750772e-07,7.72703998265775e-07,7.7134120461804e-07,7.69982013068052e-07,7.68626410932369e-07,7.67274385583323e-07,7.6592592444873e-07,7.64581015011595e-07,7.6323964480982e-07,7.6190180143592e-07,7.60567472536733e-07,7.59236645813134e-07,7.57909309019755e-07,7.56585449964698e-07,7.55265056509263e-07,7.5394811656766e-07,7.5263461810674e-07,7.51324549145719e-07,7.500178977559e-07,7.48714652060408e-07,7.47414800233914e-07,7.46118330502372e-07,7.4482523114275e-07,7.43535490482762e-07,7.42249096900612e-07,7.40966038824725e-07,7.39686304733491e-07,7.38409883155003e-07,7.37136762666805e-07,7.3586693189563e-07,7.34600379517153e-07,7.3333709425573e-07,7.32077064884157e-07,7.30820280223411e-07,7.29566729142411e-07,7.28316400557762e-07,7.27069283433519e-07,7.25825366780938e-07,7.24584639658236e-07,7.23347091170348e-07,7.22112710468693e-07,7.20881486750928e-07,7.19653409260722e-07,7.18428467287513e-07,7.17206650166275e-07,7.15987947277293e-07,7.14772348045922e-07,7.13559841942367e-07,7.12350418481447e-07,7.11144067222376e-07,7.09940777768531e-07,7.08740539767232e-07,7.07543342909517e-07,7.06349176929923e-07,7.05158031606264e-07,7.03969896759412e-07,7.02784762253083e-07,7.01602617993616e-07,7.00423453929762e-07,6.99247260052466e-07,6.98074026394659e-07,6.96903743031047e-07,6.95736400077897e-07,6.94571987692829e-07,6.93410496074614e-07,6.9225191546296e-07,6.91096236138314e-07,6.89943448421653e-07,6.88793542674283e-07,6.8764650929764e-07,6.86502338733085e-07,6.85361021461708e-07,6.84222548004131e-07,6.83086908920307e-07,6.81954094809328e-07,6.80824096309229e-07,6.79696904096797e-07,6.78572508887373e-07,6.77450901434666e-07,6.76332072530563e-07,6.75216013004935e-07,6.74102713725454e-07,6.72992165597406e-07,6.71884359563501e-07,6.70779286603692e-07,6.69676937734993e-07,6.6857730401129e-07,6.67480376523166e-07,6.66386146397719e-07,6.65294604798377e-07,6.6420574292473e-07,6.63119552012343e-07,6.62036023332585e-07,6.6095514819245e-07,6.59876917934387e-07,6.58801323936124e-07,6.57728357610495e-07,6.56658010405271e-07,6.55590273802985e-07,6.54525139320771e-07,6.53462598510185e-07,6.52402642957046e-07,6.51345264281265e-07,6.5029045413668e-07,6.49238204210893e-07,6.48188506225103e-07,6.47141351933948e-07,6.46096733125338e-07,6.45054641620297e-07,6.44015069272802e-07,6.42978007969625e-07,6.41943449630173e-07,6.4091138620633e-07,6.39881809682304e-07,6.38854712074468e-07,6.37830085431205e-07,6.36807921832757e-07,6.35788213391071e-07,6.34770952249646e-07,6.33756130583379e-07,6.32743740598422e-07,6.31733774532024e-07,6.30726224652387e-07,6.29721083258519e-07,6.28718342680082e-07,6.27717995277249e-07,6.26720033440561e-07,6.25724449590774e-07,6.24731236178725e-07,6.23740385685183e-07,6.22751890620705e-07,6.21765743525502e-07,6.20781936969291e-07,6.19800463551158e-07,6.18821315899418e-07,6.17844486671479e-07,6.16869968553701e-07,6.1589775426126e-07,6.14927836538014e-07,6.13960208156365e-07,6.12994861917125e-07,6.12031790649384e-07,6.11070987210374e-07,6.10112444485338e-07,6.09156155387399e-07,6.08202112857426e-07,6.07250309863909e-07,6.06300739402824e-07,6.05353394497507e-07,6.04408268198526e-07,6.03465353583552e-07,6.02524643757233e-07,6.01586131851069e-07,6.00649811023285e-07,5.99715674458708e-07,5.9878371536864e-07,5.97853926990738e-07,5.96926302588891e-07,5.96000835453094e-07,5.95077518899332e-07,5.94156346269457e-07,5.93237310931067e-07,5.92320406277387e-07,5.91405625727151e-07,5.90492962724486e-07,5.89582410738789e-07,5.88673963264615e-07,5.8776761382156e-07,5.86863355954142e-07,5.85961183231691e-07,5.85061089248232e-07,5.84163067622372e-07,5.83267111997184e-07,5.823732160401e-07,5.81481373442795e-07,5.80591577921077e-07,5.79703823214776e-07,5.78818103087633e-07,5.77934411327194e-07,5.77052741744696e-07,5.76173088174964e-07,5.75295444476297e-07,5.74419804530366e-07,5.73546162242107e-07,5.72674511539611e-07,5.71804846374023e-07,5.70937160719435e-07,5.70071448572779e-07,5.69207703953729e-07,5.68345920904594e-07,5.67486093490215e-07,5.66628215797864e-07,5.65772281937142e-07,5.64918286039879e-07,5.6406622226003e-07,5.63216084773579e-07,5.62367867778438e-07,5.61521565494347e-07,5.60677172162777e-07,5.5983468204683e-07,5.58994089431144e-07,5.58155388621795e-07,5.573185739462e-07,5.56483639753022e-07,5.55650580412074e-07,5.54819390314225e-07,5.53990063871304e-07,5.53162595516007e-07,5.52336979701804e-07,5.51513210902845e-07,5.5069128361387e-07,5.49871192350111e-07,5.49052931647209e-07,5.48236496061117e-07,5.47421880168009e-07,5.46609078564196e-07,5.4579808586603e-07,5.44988896709816e-07,5.44181505751728e-07,5.43375907667713e-07,5.42572097153412e-07,5.41770068924065e-07,5.40969817714428e-07,5.40171338278687e-07,5.39374625390371e-07,5.38579673842264e-07,5.37786478446325e-07,5.36995034033601e-07,5.3620533545414e-07,5.35417377576911e-07,5.3463115528972e-07,5.33846663499126e-07,5.33063897130359e-07,5.32282851127238e-07,5.31503520452088e-07,5.30725900085662e-07,5.29949985027058e-07,5.29175770293636e-07,5.28403250920945e-07,5.27632421962635e-07,5.26863278490387e-07,5.26095815593824e-07,5.25330028380441e-07,5.24565911975524e-07,5.23803461522071e-07,5.23042672180718e-07,5.22283539129657e-07,5.21526057564567e-07,5.20770222698531e-07,5.20016029761966e-07,5.19263474002542e-07,5.18512550685112e-07,5.17763255091637e-07,5.17015582521107e-07,5.16269528289475e-07,5.15525087729577e-07,5.14782256191062e-07,5.14041029040318e-07,5.13301401660404e-07,5.12563369450972e-07,5.11826927828197e-07,5.11092072224711e-07,5.10358798089525e-07,5.09627100887963e-07,5.0889697610159e-07,5.08168419228145e-07,5.07441425781467e-07,5.06715991291429e-07,5.0599211130387e-07,5.05269781380524e-07,5.04548997098954e-07,5.03829754052483e-07,5.03112047850129e-07,5.02395874116535e-07,5.01681228491903e-07,5.00968106631928e-07,5.00256504207735e-07,4.99546416905808e-07,4.98837840427927e-07,4.98130770491105e-07,4.9742520282752e-07,4.96721133184452e-07,4.9601855732422e-07,4.95317471024115e-07,4.94617870076341e-07,4.93919750287948e-07,4.93223107480772e-07,4.92527937491369e-07,4.91834236170959e-07,4.91141999385356e-07,4.90451223014913e-07,4.89761902954456e-07,4.89074035113228e-07,4.88387615414823e-07,4.87702639797131e-07,4.87019104212271e-07,4.8633700462654e-07,4.85656337020345e-07,4.84977097388148e-07,4.84299281738409e-07,4.83622886093523e-07,4.82947906489764e-07,4.82274338977226e-07,4.81602179619766e-07,4.80931424494948e-07,4.80262069693981e-07,4.79594111321666e-07,4.78927545496341e-07,4.78262368349818e-07,4.77598576027334e-07,4.7693616468749e-07,4.76275130502199e-07,4.75615469656628e-07,4.74957178349145e-07,4.74300252791263e-07,4.73644689207584e-07,4.72990483835751e-07,4.72337632926384e-07,4.71686132743038e-07,4.71035979562137e-07,4.70387169672933e-07,4.69739699377444e-07,4.69093564990405e-07,4.68448762839215e-07,4.67805289263887e-07,4.67163140616991e-07,4.66522313263607e-07,4.65882803581271e-07,4.65244607959927e-07,4.64607722801871e-07,4.63972144521704e-07,4.63337869546282e-07,4.62704894314661e-07,4.62073215278054e-07,4.61442828899776e-07,4.60813731655195e-07,4.60185920031687e-07,4.5955939052858e-07,4.58934139657113e-07,4.5831016394038e-07,4.57687459913287e-07,4.57066024122502e-07,4.56445853126406e-07,4.55826943495048e-07,4.55209291810096e-07,4.54592894664787e-07,4.53977748663888e-07,4.53363850423639e-07,4.52751196571715e-07,4.52139783747176e-07,4.51529608600418e-07,4.50920667793135e-07,4.50312957998266e-07,4.49706475899951e-07,4.49101218193491e-07,4.48497181585296e-07,4.47894362792842e-07,4.47292758544632e-07,4.46692365580142e-07,4.46093180649786e-07,4.45495200514867e-07,4.44898421947533e-07,4.44302841730736e-07,4.43708456658186e-07,4.43115263534312e-07,4.42523259174213e-07,4.41932440403619e-07,4.41342804058852e-07,4.40754346986773e-07,4.40167066044752e-07,4.39580958100618e-07,4.3899602003262e-07,4.38412248729385e-07,4.37829641089877e-07,4.37248194023357e-07,4.36667904449338e-07,4.36088769297548e-07,4.35510785507889e-07,4.34933950030396e-07,4.34358259825193e-07,4.33783711862462e-07,4.33210303122392e-07,4.3263803059515e-07,4.32066891280833e-07,4.31496882189433e-07,4.30928000340799e-07,4.30360242764592e-07,4.29793606500254e-07,4.29228088596964e-07,4.28663686113602e-07,4.28100396118709e-07,4.27538215690451e-07,4.26977141916579e-07,4.26417171894393e-07,4.25858302730705e-07,4.25300531541797e-07,4.24743855453392e-07,4.24188271600608e-07,4.23633777127927e-07,4.23080369189158e-07,4.22528044947397e-07,4.21976801574993e-07,4.21426636253513e-07,4.20877546173704e-07,4.20329528535457e-07,4.19782580547773e-07,4.19236699428725e-07,4.18691882405426e-07,4.1814812671399e-07,4.17605429599501e-07,4.17063788315973e-07,4.16523200126322e-07,4.15983662302324e-07,4.15445172124587e-07,4.14907726882511e-07,4.1437132387426e-07,4.13835960406722e-07,4.1330163379548e-07,4.12768341364776e-07,4.12236080447478e-07,4.11704848385046e-07,4.11174642527499e-07,4.10645460233384e-07,4.10117298869739e-07,4.09590155812066e-07,4.09064028444292e-07,4.08538914158741e-07,4.080148103561e-07,4.07491714445387e-07,4.0696962384392e-07,4.06448535977282e-07,4.05928448279294e-07,4.05409358191981e-07,4.04891263165537e-07,4.04374160658302e-07,4.03858048136721e-07,4.03342923075322e-07,4.02828782956679e-07,4.02315625271384e-07,4.01803447518015e-07,4.01292247203107e-07,4.00782021841119e-07,4.00272768954409e-07,3.99764486073197e-07,3.99257170735541e-07,3.98750820487303e-07,3.98245432882123e-07,3.97741005481385e-07,3.97237535854194e-07,3.96735021577338e-07,3.96233460235268e-07,3.95732849420063e-07,3.95233186731401e-07,3.94734469776535e-07,3.94236696170259e-07,3.93739863534884e-07,3.93243969500205e-07,3.92749011703477e-07,3.92254987789385e-07,3.91761895410014e-07,3.91269732224826e-07,3.90778495900626e-07,3.90288184111542e-07,3.89798794538988e-07,3.89310324871646e-07,3.88822772805432e-07,3.88336136043473e-07,3.87850412296076e-07,3.87365599280706e-07,3.86881694721955e-07,3.86398696351515e-07,3.85916601908157e-07,3.85435409137698e-07,3.84955115792978e-07,3.84475719633834e-07,3.83997218427071e-07,3.8351960994644e-07,3.8304289197261e-07,3.82567062293141e-07,3.82092118702461e-07,3.81618059001837e-07,3.81144880999355e-07,3.80672582509889e-07,3.80201161355078e-07,3.79730615363302e-07,3.79260942369655e-07,3.78792140215922e-07,3.78324206750554e-07,3.7785713982864e-07,3.77390937311886e-07,3.76925597068592e-07,3.76461116973621e-07,3.75997494908383e-07,3.75534728760803e-07,3.75072816425304e-07,3.74611755802777e-07,3.74151544800563e-07,3.73692181332422e-07,3.73233663318517e-07,3.72775988685386e-07,3.72319155365919e-07,3.71863161299334e-07,3.71408004431159e-07,3.709536827132e-07,3.70500194103527e-07,3.70047536566442e-07,3.69595708072466e-07,3.69144706598308e-07,3.68694530126847e-07,3.68245176647107e-07,3.67796644154236e-07,3.67348930649483e-07,3.66902034140177e-07,3.66455952639703e-07,3.66010684167479e-07,3.6556622674894e-07,3.65122578415507e-07,3.64679737204572e-07,3.64237701159476e-07,3.63796468329482e-07,3.63356036769761e-07,3.62916404541365e-07,3.62477569711206e-07,3.62039530352038e-07,3.61602284542434e-07,3.61165830366765e-07,3.60730165915176e-07,3.60295289283573e-07,3.59861198573592e-07,3.59427891892589e-07,3.58995367353608e-07,3.58563623075372e-07,3.58132657182253e-07,3.57702467804256e-07,3.57273053077e-07,3.56844411141695e-07,3.56416540145122e-07,3.55989438239615e-07,3.55563103583041e-07,3.55137534338776e-07,3.54712728675692e-07,3.5428868476813e-07,3.53865400795886e-07,3.53442874944189e-07,3.53021105403683e-07,3.52600090370405e-07,3.52179828045768e-07,3.51760316636541e-07,3.51341554354831e-07,3.50923539418062e-07,3.50506270048956e-07,3.50089744475517e-07,3.49673960931009e-07,3.49258917653939e-07,3.48844612888039e-07,3.48431044882244e-07,3.48018211890678e-07,3.47606112172631e-07,3.47194743992545e-07,3.46784105619993e-07,3.46374195329662e-07,3.45965011401334e-07,3.45556552119868e-07,3.45148815775184e-07,3.44741800662242e-07,3.44335505081025e-07,3.43929927336524e-07,3.43525065738718e-07,3.43120918602555e-07,3.42717484247937e-07,3.42314760999702e-07,3.41912747187606e-07,3.41511441146306e-07,3.41110841215343e-07,3.40710945739123e-07,3.40311753066904e-07,3.39913261552774e-07,3.39515469555638e-07,3.39118375439198e-07,3.3872197757194e-07,3.38326274327113e-07,3.37931264082715e-07,3.37536945221475e-07,3.37143316130838e-07,3.36750375202946e-07,3.36358120834626e-07,3.35966551427368e-07,3.35575665387313e-07,3.35185461125235e-07,3.34795937056524e-07,3.34407091601174e-07,3.34018923183761e-07,3.33631430233432e-07,3.33244611183886e-07,3.3285846447336e-07,3.32472988544613e-07,3.32088181844908e-07,3.31704042826002e-07,3.31320569944122e-07,3.30937761659958e-07,3.30555616438641e-07,3.30174132749734e-07,3.29793309067208e-07,3.29413143869436e-07,3.29033635639172e-07,3.28654782863536e-07,3.28276584034004e-07,3.27899037646386e-07,3.27522142200815e-07,3.27145896201733e-07,3.26770298157874e-07,3.26395346582248e-07,3.26021039992131e-07,3.25647376909045e-07,3.25274355858748e-07,3.24901975371217e-07,3.24530233980632e-07,3.24159130225366e-07,3.23788662647965e-07,3.2341882979514e-07,3.23049630217749e-07,3.2268106247078e-07,3.22313125113345e-07,3.21945816708658e-07,3.21579135824024e-07,3.21213081030826e-07,3.20847650904511e-07,3.20482844024574e-07,3.20118658974546e-07,3.1975509434198e-07,3.19392148718436e-07,3.1902982069947e-07,3.18668108884618e-07,3.18307011877384e-07,3.17946528285224e-07,3.17586656719536e-07,3.17227395795645e-07,3.16868744132789e-07,3.16510700354108e-07,3.16153263086628e-07,3.15796430961248e-07,3.1544020261273e-07,3.15084576679683e-07,3.14729551804551e-07,3.143751266336e-07,3.14021299816904e-07,3.13668070008337e-07,3.1331543586555e-07,3.12963396049971e-07,3.12611949226782e-07,3.12261094064911e-07,3.1191082923702e-07,3.1156115341949e-07,3.11212065292409e-07,3.10863563539562e-07,3.10515646848415e-07,3.10168313910106e-07,3.0982156341943e-07,3.09475394074827e-07,3.09129804578373e-07,3.08784793635763e-07,3.08440359956303e-07,3.08096502252896e-07,3.07753219242029e-07,3.07410509643764e-07,3.07068372181723e-07,3.06726805583078e-07,3.06385808578539e-07,3.06045379902341e-07,3.05705518292232e-07,3.05366222489466e-07,3.05027491238785e-07,3.04689323288409e-07,3.04351717390029e-07,3.04014672298788e-07,3.03678186773278e-07,3.0334225957552e-07,3.03006889470959e-07,3.02672075228449e-07,3.02337815620246e-07,3.02004109421989e-07,3.01670955412699e-07,3.01338352374757e-07,3.01006299093904e-07,3.00674794359219e-07,3.00343836963116e-07,3.00013425701331e-07,2.99683559372907e-07,2.99354236780189e-07,2.99025456728811e-07,2.98697218027681e-07,2.98369519488979e-07,2.98042359928135e-07,2.97715738163831e-07,2.97389653017978e-07,2.97064103315714e-07,2.9673908788539e-07,2.96414605558561e-07,2.96090655169972e-07,2.95767235557553e-07,2.95444345562403e-07,2.95121984028783e-07,2.94800149804106e-07,2.94478841738924e-07,2.94158058686921e-07,2.938377995049e-07,2.93518063052772e-07,2.93198848193552e-07,2.92880153793342e-07,2.92561978721323e-07,2.92244321849747e-07,2.91927182053926e-07,2.91610558212219e-07,2.91294449206026e-07,2.90978853919779e-07,2.90663771240928e-07,2.90349200059931e-07,2.9003513927025e-07,2.89721587768336e-07,2.89408544453622e-07,2.8909600822851e-07,2.88783977998366e-07,2.88472452671506e-07,2.88161431159192e-07,2.87850912375615e-07,2.87540895237893e-07,2.87231378666054e-07,2.86922361583035e-07,2.86613842914667e-07,2.86305821589664e-07,2.85998296539622e-07,2.85691266698999e-07,2.85384731005116e-07,2.8507868839814e-07,2.84773137821079e-07,2.84468078219771e-07,2.84163508542876e-07,2.83859427741867e-07,2.8355583477102e-07,2.83252728587406e-07,2.82950108150881e-07,2.82647972424078e-07,2.82346320372398e-07,2.82045150964001e-07,2.81744463169796e-07,2.81444255963435e-07,2.81144528321302e-07,2.80845279222503e-07,2.80546507648862e-07,2.80248212584908e-07,2.79950393017868e-07,2.79653047937658e-07,2.79356176336875e-07,2.79059777210788e-07,2.7876384955733e-07,2.78468392377089e-07,2.781734046733e-07,2.77878885451835e-07,2.77584833721198e-07,2.77291248492514e-07,2.7699812877952e-07,2.76705473598559e-07,2.76413281968571e-07,2.76121552911084e-07,2.75830285450207e-07,2.75539478612622e-07,2.75249131427571e-07,2.74959242926858e-07,2.74669812144829e-07,2.74380838118375e-07,2.74092319886915e-07,2.73804256492394e-07,2.73516646979272e-07,2.73229490394517e-07,2.72942785787597e-07,2.72656532210473e-07,2.7237072871759e-07,2.72085374365869e-07,2.71800468214701e-07,2.71516009325936e-07,2.71231996763879e-07,2.70948429595282e-07,2.7066530688933e-07,2.70382627717644e-07,2.70100391154265e-07,2.69818596275648e-07,2.69537242160658e-07,2.69256327890558e-07,2.68975852549005e-07,2.68695815222041e-07,2.68416214998085e-07,2.68137050967926e-07,2.67858322224716e-07,2.67580027863963e-07,2.67302166983523e-07,2.67024738683592e-07,2.667477420667e-07,2.66471176237704e-07,2.66195040303779e-07,2.65919333374412e-07,2.65644054561395e-07,2.65369202978817e-07,2.65094777743058e-07,2.64820777972781e-07,2.64547202788925e-07,2.64274051314698e-07,2.6400132267557e-07,2.63729015999267e-07,2.63457130415763e-07,2.63185665057272e-07,2.62914619058243e-07,2.62643991555352e-07,2.62373781687497e-07,2.62103988595787e-07,2.61834611423541e-07,2.61565649316275e-07,2.61297101421699e-07,2.61028966889712e-07,2.60761244872389e-07,2.60493934523981e-07,2.60227035000903e-07,2.59960545461732e-07,2.59694465067196e-07,2.5942879298017e-07,2.59163528365671e-07,2.58898670390847e-07,2.58634218224973e-07,2.58370171039444e-07,2.58106528007771e-07,2.57843288305571e-07,2.5758045111056e-07,2.57318015602551e-07,2.57055980963445e-07,2.56794346377222e-07,2.56533111029941e-07,2.56272274109728e-07,2.56011834806771e-07,2.55751792313316e-07,2.55492145823657e-07,2.55232894534136e-07,2.54974037643127e-07,2.54715574351041e-07,2.54457503860311e-07,2.54199825375389e-07,2.53942538102742e-07,2.53685641250842e-07,2.53429134030164e-07,2.53173015653175e-07,2.52917285334334e-07,2.52661942290079e-07,2.52406985738827e-07,2.52152414900967e-07,2.51898228998849e-07,2.51644427256785e-07,2.51391008901038e-07,2.51137973159819e-07,2.50885319263279e-07,2.50633046443508e-07,2.50381153934519e-07,2.50129640972254e-07,2.49878506794571e-07,2.4962775064124e-07,2.49377371753937e-07,2.49127369376239e-07,2.48877742753617e-07,2.48628491133433e-07,2.48379613764931e-07,2.48131109899234e-07,2.47882978789334e-07,2.47635219690095e-07,2.47387831858237e-07,2.47140814552337e-07,2.46894167032824e-07,2.46647888561968e-07,2.4640197840388e-07,2.46156435824504e-07,2.45911260091611e-07,2.45666450474795e-07,2.45422006245467e-07,2.45177926676849e-07,2.4493421104397e-07,2.44690858623658e-07,2.44447868694538e-07,2.44205240537025e-07,2.43962973433317e-07,2.43721066667394e-07,2.43479519525008e-07,2.43238331293681e-07,2.42997501262697e-07,2.427570287231e-07,2.42516912967687e-07,2.42277153291001e-07,2.4203774898933e-07,2.41798699360699e-07,2.41560003704864e-07,2.4132166132331e-07,2.41083671519243e-07,2.40846033597588e-07,2.4060874686498e-07,2.40371810629761e-07,2.40135224201976e-07,2.39898986893366e-07,2.39663098017364e-07,2.39427556889092e-07,2.3919236282535e-07,2.38957515144618e-07,2.38723013167047e-07,2.38488856214456e-07,2.38255043610324e-07,2.3802157467979e-07,2.37788448749643e-07,2.37555665148322e-07,2.37323223205906e-07,2.37091122254116e-07,2.36859361626301e-07,2.36627940657443e-07,2.36396858684145e-07,2.36166115044629e-07,2.35935709078732e-07,2.35705640127899e-07,2.35475907535182e-07,2.35246510645231e-07,2.35017448804291e-07,2.34788721360199e-07,2.34560327662378e-07,2.34332267061831e-07,2.34104538911139e-07,2.33877142564455e-07,2.33650077377499e-07,2.33423342707555e-07,2.33196937913465e-07,2.32970862355623e-07,2.32745115395976e-07,2.32519696398014e-07,2.32294604726767e-07,2.32069839748802e-07,2.31845400832217e-07,2.31621287346638e-07,2.31397498663211e-07,2.31174034154603e-07,2.30950893194994e-07,2.30728075160074e-07,2.30505579427036e-07,2.30283405374577e-07,2.30061552382886e-07,2.29840019833649e-07,2.29618807110036e-07,2.29397913596703e-07,2.29177338679783e-07,2.28957081746886e-07,2.2873714218709e-07,2.28517519390943e-07,2.28298212750453e-07,2.28079221659086e-07,2.27860545511761e-07,2.2764218370485e-07,2.27424135636167e-07,2.2720640070497e-07,2.26988978311951e-07,2.26771867859237e-07,2.26555068750385e-07,2.26338580390375e-07,2.26122402185609e-07,2.25906533543904e-07,2.25690973874492e-07,2.25475722588012e-07,2.25260779096507e-07,2.25046142813424e-07,2.24831813153601e-07,2.24617789533274e-07,2.24404071370065e-07,2.24190658082979e-07,2.23977549092406e-07,2.23764743820109e-07,2.23552241689226e-07,2.23340042124262e-07,2.2312814455109e-07,2.2291654839694e-07,2.22705253090402e-07,2.2249425806142e-07,2.22283562741286e-07,2.22073166562639e-07,2.21863068959457e-07}; Deleted: trunk/oneliner/ext/string.c =================================================================== --- trunk/oneliner/ext/string.c 2007-05-21 18:28:34 UTC (rev 281) +++ trunk/oneliner/ext/string.c 2007-05-21 18:54:32 UTC (rev 282) @@ -1,32 +0,0 @@ -// -// Make object into object ^ subject -// -static void -oneliner_string_xor(guint8 *object, guint8 *subject, guint32 len) -{ - guint32 tmp; - -#ifdef G_HAVE_GINT64 - for (tmp = 0; tmp < len / 8; tmp++) - ( (guint64 *) object )[tmp] = ( (guint64 *) object )[tmp] ^ ( (guint64 *) subject )[tmp]; - for (tmp = tmp * 2; tmp < len / 4; tmp++) - ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; - for (tmp = tmp * 4; tmp < len; tmp++) - object[tmp] = object[tmp] ^ subject[tmp]; -#else - for (tmp = 0; tmp < len / 4; tmp++) - ( (guint32 *) object )[tmp] = ( (guint32 *) object )[tmp] ^ ( (guint32 *) subject )[tmp]; - for (tmp = tmp * 4; tmp < len; tmp++) - object[tmp] = object[tmp] ^ subject[tmp]; -#endif -} - -static VALUE -rb_oneliner_string_xor(VALUE self, VALUE object) -{ - Check_Type(object, T_STRING); - rb_str_modify(self); - oneliner_string_xor((guint8 *) RSTRING(self)->ptr, (guint8 *) RSTRING(object)->ptr, MIN(RSTRING(self)->len, RSTRING(object)->len)); - return self; -} - Deleted: trunk/oneliner/ext/xor_block.c =================================================================== --- trunk/oneliner/ext/xor_block.c 2007-05-21 18:28:34 UTC (rev 281) +++ trunk/oneliner/ext/xor_block.c 2007-05-21 18:54:32 UTC (rev 282) @@ -1,109 +0,0 @@ -// -// An as yet mysterious block. -// -typedef struct { - gboolean initialized; - guint8 *sum; - GHashTable *source_blocks; -} oneliner_xor_block; - -#define XOR_BLOCK_FINISHED(xor_block) ((xor_block)->initialized && \ - (g_hash_table_size((xor_block)->source_blocks) == 1) && \ - ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) -#define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) - -static oneliner_xor_block * -oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized) -{ - oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); - ALLOC_COPY8(rval->sum, data, len); - rval->initialized = initialized; - rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); -} - -static gboolean -oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) -{ - g_free(key); - g_free(data); - return TRUE; -} - -static void -oneliner_xor_block_free(oneliner_xor_block *xor_block) -{ - g_free(xor_block->sum); - g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); - g_hash_table_destroy(xor_block->source_blocks); - g_free(xor_block); -} - -static void -oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) -{ - guint32 *uses; - guint32 *source; - if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { - (*uses)++; - } else { - uses = g_new(guint32, 1); - source = g_new(guint32, 1); - *uses = 1; - *source = source_block_nr; - g_hash_table_insert(xor_block->source_blocks, source, uses); - } -} - -static void -oneliner_xor_block_set_sum(oneliner_xor_block *xor_block, guint8 *sum, guint32 len) -{ - ALLOC_COPY8(xor_block->sum, sum, len); - xor_block->initialized = TRUE; -} - -static void -oneliner_xor_block_last_source_block_nr_iterator(gpointer key, gpointer data, gpointer user_data) -{ - * (guint32 *) user_data = * (guint32 *) key; -} - -static guint32 -oneliner_xor_block_last_source_block_nr(oneliner_xor_block *xor_block) -{ - guint32 source_block_nr; - g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_source_block_nr_iterator, &source_block_nr); - return source_block_nr; -} - -static void -oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) -{ - * (guint32 *) user_data = * (guint32 *) data; -} - -static guint32 -oneliner_xor_block_last_uses(oneliner_xor_block *xor_block) -{ - guint32 uses; - g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_last_uses_iterator, &uses); - return uses; -} - -static void -oneliner_xor_block_apply(oneliner_xor_block *xor_block, oneliner_superstring *str, guint32 found_block_nr) -{ - guint32 tmp; - guint32 *uses; - guint32 *old_key; - - g_hash_table_lookup_extended(xor_block->source_blocks, &found_block_nr, (gpointer) old_key, (gpointer) uses); - - for (tmp = 0; tmp < *uses; tmp++) { - oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); - } - - g_hash_table_remove(xor_block->source_blocks, &found_block_nr); - g_free(old_key); - g_free(uses); -} - From nobody at rubyforge.org Mon May 21 14:55:14 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 21 May 2007 14:55:14 -0400 (EDT) Subject: [Archipelago-submits] [283] trunk/oneliner/Rakefile: changed rakefile Message-ID: <20070521185514.BA31B5240A5E@rubyforge.org> Revision: 283 Author: zond Date: 2007-05-21 14:55:14 -0400 (Mon, 21 May 2007) Log Message: ----------- changed rakefile Modified Paths: -------------- trunk/oneliner/Rakefile Modified: trunk/oneliner/Rakefile =================================================================== --- trunk/oneliner/Rakefile 2007-05-21 18:54:32 UTC (rev 282) +++ trunk/oneliner/Rakefile 2007-05-21 18:55:14 UTC (rev 283) @@ -13,8 +13,7 @@ s.author = "Martin Kihlgren" s.email = "zond at troja dot ath dot cx" s.summary = "An online code implementation for ruby." - s.files = FileList['lib/**/*.rb', 'tests/*', 'ext/*', 'GPL-2'].to_a - s.require_path = "lib" + s.files = FileList['tests/*', 'ext/*', 'GPL-2'].to_a s.extensions << 'ext/extconf.rb' s.autorequire = "oneliner" s.test_files = Dir.glob('tests/*_test.rb') + Dir.glob('tests/test_helper.rb') From nobody at rubyforge.org Tue May 22 03:57:45 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 03:57:45 -0400 (EDT) Subject: [Archipelago-submits] [284] trunk/oneliner/ext: urgh. Message-ID: <20070522075745.63E645240CB6@rubyforge.org> Revision: 284 Author: zond Date: 2007-05-22 03:57:45 -0400 (Tue, 22 May 2007) Log Message: ----------- urgh. fucking memory management problems Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Property Changed: ---------------- trunk/oneliner/ext/ Property changes on: trunk/oneliner/ext ___________________________________________________________________ Name: svn:ignore + .gdb_history Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-21 18:55:14 UTC (rev 283) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 07:57:45 UTC (rev 284) @@ -112,6 +112,23 @@ } oneliner_superstring; // +// An as yet mysterious block. +// +typedef struct { + gboolean initialized; + guint8 *sum; + GHashTable *source_blocks; +} oneliner_xor_block; + +// +// An insertion to do into the graph of a superstring. +// +typedef struct { + guint32 source_block_nr; + oneliner_xor_block *check_block; +} oneliner_graph_insertion; + +// // A random context. // typedef guint8 oneliner_context; @@ -229,15 +246,6 @@ return self; } -// -// An as yet mysterious block. -// -typedef struct { - gboolean initialized; - guint8 *sum; - GHashTable *source_blocks; -} oneliner_xor_block; - #define XOR_BLOCK_FINISHED(xor_block) ((xor_block)->initialized && \ (g_hash_table_size((xor_block)->source_blocks) == 1) && \ ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) @@ -339,14 +347,6 @@ } -// -// An insertion to do into the graph of a superstring. -// -typedef struct { - guint32 source_block_nr; - oneliner_xor_block *check_block; -} oneliner_graph_insertion; - static oneliner_graph_insertion * oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) { @@ -368,7 +368,7 @@ { oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; oneliner_superstring *str = (oneliner_superstring *) string; - + g_array_index(str->graph, GList *, ins->source_block_nr) = g_list_append(g_array_index(str->graph, @@ -745,10 +745,6 @@ oneliner_superstring_analyze_source_block(oneliner_superstring *str, guint32 found_block_nr) { oneliner_superstring_analyze_source_block_with_array(str, - str->graph, - found_block_nr); - - oneliner_superstring_analyze_source_block_with_array(str, str->aux_graph_for_source_blocks, found_block_nr); } @@ -787,6 +783,10 @@ static void oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) { + oneliner_superstring_analyze_source_block_with_array(str, + str->graph, + found_block_nr); + if (found_block_nr < str->n_blocks_needed) { oneliner_superstring_analyze_source_block(str, found_block_nr); } else { @@ -931,6 +931,7 @@ str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); str->graph = g_array_new(FALSE, TRUE, sizeof(GList *)); + g_array_set_size(str->graph, str->n_blocks_needed + str->n_aux_blocks_needed); oneliner_superstring_build_aux_graph(str); } @@ -1140,7 +1141,7 @@ #ifdef __cplusplus extern "C" { #endif - void Init_oneliner_ext() { + void Init_oneliner() { VALUE rb_string = rb_define_class("String", rb_cObject); rb_define_method(rb_string, "xor!", rb_oneliner_string_xor, 1); From nobody at rubyforge.org Tue May 22 07:30:55 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 07:30:55 -0400 (EDT) Subject: [Archipelago-submits] [285] trunk/oneliner: made it do its stuff without exploding, but still mem problems Message-ID: <20070522113055.1C3275240A43@rubyforge.org> Revision: 285 Author: zond Date: 2007-05-22 07:30:54 -0400 (Tue, 22 May 2007) Log Message: ----------- made it do its stuff without exploding, but still mem problems Modified Paths: -------------- trunk/oneliner/ext/oneliner.c trunk/oneliner/tests/superstring_test.rb Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 07:57:45 UTC (rev 284) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 11:30:54 UTC (rev 285) @@ -32,6 +32,7 @@ // Utility macros. // #ifdef ONELINER_DEBUG +#define NULL_WARN(x) if ((x) == NULL) DEBUG("x is NULL!!!"); #define DEBUG(s, ...) { \ fprintf(stderr, "DEBUG: "); \ fprintf(stderr, s, ## __VA_ARGS__); \ @@ -69,6 +70,7 @@ #define BITSTRING_DEBUG(msg,str,len) ; #endif +#define CHARS_FOR(i) ((guint32) (log10((gdouble) (i))) + 1) #define RANDOM(context,max) (oneliner_context_random(context) % (max)) #define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) @@ -251,28 +253,47 @@ ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) #define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) +static void +oneliner_xor_block_to_s_iterator(gpointer key, gpointer data, gpointer user_data) +{ + guint32 source_block_nr = GPOINTER_TO_UINT(key); + guint32 uses = GPOINTER_TO_UINT(data); + gchar **buffer = (gchar **) user_data; + guint32 extra_size_needed = CHARS_FOR(uses) + CHARS_FOR(source_block_nr) + 5 + 1; + guint32 new_size_needed = strlen(*buffer) + extra_size_needed; + *buffer = g_realloc(*buffer, new_size_needed); + snprintf(*buffer + strlen(*buffer), extra_size_needed, "%i => %i,", source_block_nr, uses); +} + +static gchar * +oneliner_xor_block_to_s(oneliner_xor_block *xor_block, oneliner_superstring *str) +{ + gchar *rval; + gchar *base = ""); + return rval; +} + static oneliner_xor_block * oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized) { oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); ALLOC_COPY8(rval->sum, data, len); rval->initialized = initialized; - rval->source_blocks = g_hash_table_new(g_int_hash, g_int_equal); + rval->source_blocks = g_hash_table_new(NULL, NULL); + return rval; } -static gboolean -oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) -{ - g_free(key); - g_free(data); - return TRUE; -} - static void oneliner_xor_block_free(oneliner_xor_block *xor_block) { g_free(xor_block->sum); - g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); g_hash_table_destroy(xor_block->source_blocks); g_free(xor_block); } @@ -280,17 +301,10 @@ static void oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) { - guint32 *uses; - guint32 *source; - if ((uses = g_hash_table_lookup(xor_block->source_blocks, &source_block_nr)) != NULL) { - (*uses)++; - } else { - uses = g_new(guint32, 1); - source = g_new(guint32, 1); - *uses = 1; - *source = source_block_nr; - g_hash_table_insert(xor_block->source_blocks, source, uses); - } + g_hash_table_insert(xor_block->source_blocks, + GUINT_TO_POINTER(source_block_nr), + GUINT_TO_POINTER(GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, + GUINT_TO_POINTER(source_block_nr))) + 1)); } static void @@ -303,7 +317,7 @@ static void oneliner_xor_block_last_source_block_nr_iterator(gpointer key, gpointer data, gpointer user_data) { - * (guint32 *) user_data = * (guint32 *) key; + * (guint32 *) user_data = GPOINTER_TO_UINT(key); } static guint32 @@ -317,7 +331,7 @@ static void oneliner_xor_block_last_uses_iterator(gpointer key, gpointer data, gpointer user_data) { - * (guint32 *) user_data = * (guint32 *) data; + * (guint32 *) user_data = GPOINTER_TO_UINT(data); } static guint32 @@ -331,22 +345,18 @@ static void oneliner_xor_block_apply(oneliner_xor_block *xor_block, oneliner_superstring *str, guint32 found_block_nr) { + guint32 uses; guint32 tmp; - guint32 *uses; - guint32 *old_key; - g_hash_table_lookup_extended(xor_block->source_blocks, &found_block_nr, (gpointer) old_key, (gpointer) uses); + uses = GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr))); - for (tmp = 0; tmp < *uses; tmp++) { + for (tmp = 0; tmp < uses; tmp++) { oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); } - g_hash_table_remove(xor_block->source_blocks, &found_block_nr); - g_free(old_key); - g_free(uses); + g_hash_table_remove(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr)); } - static oneliner_graph_insertion * oneliner_graph_insertion_new(oneliner_xor_block *check_block, guint32 source_block_nr) { @@ -704,11 +714,15 @@ // // If that meant that it is finished then dance the dance of setting the combined block, - // freeing the check block, removing it from the GList of check blocks for that combined block, + // removing it from the GList of check blocks for that combined block, // and analyzing the results. // // Otherwise if it is empty, just free it and remove it. // + // In fact, right after we have entered this FINISHED block, we will (since we + // call analyze on the resulting block, which leads here) check the same xor_block + // again, reach the EMPTY block, and then free the block. + // if (XOR_BLOCK_FINISHED(xor_block)) { // Find the source block that it defines. @@ -718,9 +732,8 @@ oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum); - // Then free the check block. - oneliner_xor_block_free(xor_block); - + + // Then remove it from our unresolved check blocks so that we can run analyze safely again. g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); @@ -742,14 +755,6 @@ } static void -oneliner_superstring_analyze_source_block(oneliner_superstring *str, guint32 found_block_nr) -{ - oneliner_superstring_analyze_source_block_with_array(str, - str->aux_graph_for_source_blocks, - found_block_nr); -} - -static void oneliner_superstring_analyze_aux_block(oneliner_superstring *str, guint32 found_block_nr) { oneliner_xor_block *xor_block; @@ -764,8 +769,7 @@ oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum); - oneliner_xor_block_free(xor_block); - + g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, found_block_nr - str->n_blocks_needed) = NULL; @@ -783,13 +787,24 @@ static void oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) { + // + // Analyze results for any unresolved check blocks for this found block nr. + // oneliner_superstring_analyze_source_block_with_array(str, str->graph, found_block_nr); if (found_block_nr < str->n_blocks_needed) { - oneliner_superstring_analyze_source_block(str, found_block_nr); + // + // Analyze results for any unresolved aux blocks for this found block nr. + // + oneliner_superstring_analyze_source_block_with_array(str, + str->aux_graph_for_source_blocks, + found_block_nr); } else { + // + // Analyze results for any unresolved SOURCE blocks for this found aux block. + // oneliner_superstring_analyze_aux_block(str, found_block_nr); } } @@ -827,7 +842,7 @@ xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), str->n_chars_in_block, TRUE); - + for (tmp2 = 0; tmp2 < degree; tmp2++) { block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); block_content = oneliner_superstring_get_combined_block(str, block_nr); Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-22 07:57:45 UTC (rev 284) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-22 11:30:54 UTC (rev 285) @@ -27,4 +27,10 @@ end end + def test_encode_decode + s1 = Oneliner::SuperString.new("x" * 191) + s2 = Oneliner::SuperString.new + s2.decode(s1.encode(256)) + end + end From nobody at rubyforge.org Tue May 22 07:37:32 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 07:37:32 -0400 (EDT) Subject: [Archipelago-submits] [286] trunk/oneliner/ext/oneliner.c: emptied the hash before destroying it Message-ID: <20070522113732.B601A5240A20@rubyforge.org> Revision: 286 Author: zond Date: 2007-05-22 07:37:32 -0400 (Tue, 22 May 2007) Log Message: ----------- emptied the hash before destroying it Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 11:30:54 UTC (rev 285) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 11:37:32 UTC (rev 286) @@ -290,10 +290,17 @@ return rval; } +static gboolean +oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) +{ + return TRUE; +} + static void oneliner_xor_block_free(oneliner_xor_block *xor_block) { g_free(xor_block->sum); + g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); g_hash_table_destroy(xor_block->source_blocks); g_free(xor_block); } From nobody at rubyforge.org Tue May 22 07:40:36 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 07:40:36 -0400 (EDT) Subject: [Archipelago-submits] [287] trunk/oneliner/ext/oneliner.c: blar Message-ID: <20070522114036.508715240957@rubyforge.org> Revision: 287 Author: zond Date: 2007-05-22 07:40:35 -0400 (Tue, 22 May 2007) Log Message: ----------- blar Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 11:37:32 UTC (rev 286) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 11:40:35 UTC (rev 287) @@ -300,7 +300,6 @@ oneliner_xor_block_free(oneliner_xor_block *xor_block) { g_free(xor_block->sum); - g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, NULL); g_hash_table_destroy(xor_block->source_blocks); g_free(xor_block); } From nobody at rubyforge.org Tue May 22 09:22:01 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 09:22:01 -0400 (EDT) Subject: [Archipelago-submits] [288] trunk/oneliner: now it runs without any MAJOR memory problems Message-ID: <20070522132201.D303E5240A65@rubyforge.org> Revision: 288 Author: zond Date: 2007-05-22 09:22:01 -0400 (Tue, 22 May 2007) Log Message: ----------- now it runs without any MAJOR memory problems Modified Paths: -------------- trunk/oneliner/ext/oneliner.c trunk/oneliner/tests/superstring_test.rb Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 11:40:35 UTC (rev 287) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 13:22:01 UTC (rev 288) @@ -1,5 +1,5 @@ // Archipelago - a distributed computing toolkit for ruby -// Copyright (C) 2006 Martin Kihlgren +// Copyright (C) 2007 Martin Kihlgren // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -34,9 +34,9 @@ #ifdef ONELINER_DEBUG #define NULL_WARN(x) if ((x) == NULL) DEBUG("x is NULL!!!"); #define DEBUG(s, ...) { \ - fprintf(stderr, "DEBUG: "); \ - fprintf(stderr, s, ## __VA_ARGS__); \ - fprintf(stderr, "\n"); \ + fprintf(stderr, "DEBUG: "); \ + fprintf(stderr, s, ## __VA_ARGS__); \ + fprintf(stderr, "\n"); \ fflush(NULL); } #define IFDEBUG(s) s #define BITSTRING_DEBUG(msg,str,len) { \ @@ -59,10 +59,10 @@ rb_str_new2("\\1,"))); \ fprintf(stderr, "\n"); \ fflush(NULL); } -#define STRING_DEBUG(msg,str,len) { \ - fprintf(stderr, "DEBUG: %s: ", (msg)); \ +#define STRING_DEBUG(msg,str,len) { \ + fprintf(stderr, "DEBUG: %s: ", (msg)); \ rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), rb_intern("print"), 1, rb_funcall(rb_str_new((gchar *) (str), (len)), rb_intern("inspect"), 0)); \ - fprintf(stderr, "\n"); \ + fprintf(stderr, "\n"); \ fflush(NULL); } #else #define DEBUG(s, ...) ; @@ -634,6 +634,7 @@ // Make sure that we have our blocks calculated properly. oneliner_superstring_build_blocks(str, (guint8 *) RSTRING(argv[0])->ptr); oneliner_superstring_build_aux_blocks(str); + str->decode_done = TRUE; } return self; } @@ -781,11 +782,6 @@ found_block_nr - str->n_blocks_needed) = NULL; oneliner_superstring_analyze(str, source_block_nr); - } else if (XOR_BLOCK_EMPTY(xor_block)) { - oneliner_xor_block_free(xor_block); - g_array_index(str->aux_graph_for_aux_blocks, - oneliner_xor_block *, - found_block_nr - str->n_blocks_needed) = NULL; } } } @@ -907,7 +903,7 @@ if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE); - g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr); + g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr) = aux_block; } oneliner_xor_block_add(aux_block, tmp); @@ -986,7 +982,7 @@ guint8 prepend[8]; gint32 tmp; - sranddev(); + srand(time(NULL)); tmp = (gint32) rand(); oneliner_context_seed(context, tmp); @@ -1016,43 +1012,55 @@ } static void -oneliner_superstring_free_xor_block(gpointer xor_block, gpointer user_data) +oneliner_superstring_add_xor_to_hash(gpointer data, gpointer user_data) { - oneliner_xor_block_free((oneliner_xor_block *) xor_block); + g_hash_table_insert((GHashTable *) user_data, data, NULL); } static void -oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, gboolean free_xor_blocks) +oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, GHashTable *xors) { guint32 tmp; for (tmp = 0; tmp < ary->len; tmp++) { GList *list; if ((list = (GList *) g_array_index(ary, GList *, tmp)) != NULL) { - if (free_xor_blocks) - g_list_foreach(list, oneliner_superstring_free_xor_block, NULL); + g_list_foreach(list, oneliner_superstring_add_xor_to_hash, xors); g_list_free(list); } } g_array_free(ary, FALSE); } +static gboolean +oneliner_superstring_free_and_remove_xor(gpointer key, gpointer value, gpointer user_data) +{ + oneliner_xor_block_free((oneliner_xor_block *) key); + return TRUE; +} + static void oneliner_superstring_free(oneliner_superstring *str) { + GHashTable *xors = g_hash_table_new(NULL, NULL); guint32 tmp; if (str->blocks != NULL) g_array_free(str->blocks, TRUE); if (str->aux_blocks != NULL) g_array_free(str->aux_blocks, TRUE); if (str->graph != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, TRUE); + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, xors); if (str->aux_graph_for_aux_blocks != NULL) { - for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) - oneliner_xor_block_free((oneliner_xor_block *) g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)); + for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) { + gpointer xor_block; + if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)) != NULL) + g_hash_table_insert(xors, xor_block, NULL); + } + g_array_free(str->aux_graph_for_aux_blocks, FALSE); } if (str->aux_graph_for_source_blocks != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, FALSE); - + oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, xors); + g_hash_table_foreach_remove(xors, oneliner_superstring_free_and_remove_xor, NULL); + g_hash_table_destroy(xors); g_free(str); } @@ -1099,7 +1107,7 @@ guint8 *tmp_data; RB_ONELINER(self, str); - if (str->blocks == NULL) + if (oneliner_superstring_decode_done(str) == Qfalse) return rb_str_new2(""); tmp_data = oneliner_superstring_build_data(str); rval = rb_str_new((gchar *) tmp_data, str->data_len); @@ -1116,6 +1124,14 @@ } static VALUE +rb_oneliner_superstring_decode_done(VALUE self) +{ + oneliner_superstring *str; + RB_ONELINER(self, str); + return oneliner_superstring_decode_done(str); +} + +static VALUE rb_oneliner_superstring_encode(VALUE self, VALUE size) { guint8 *chunk; @@ -1178,6 +1194,7 @@ rb_define_method(rb_superstring, "block_size", rb_oneliner_superstring_block_size, 0); rb_define_method(rb_superstring, "chunk_blocks", rb_oneliner_superstring_chunk_blocks, 1); rb_define_method(rb_superstring, "decode", rb_oneliner_superstring_decode, 1); + rb_define_method(rb_superstring, "done?", rb_oneliner_superstring_decode_done, 0); } #ifdef __cplusplus } Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-22 11:40:35 UTC (rev 287) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-22 13:22:01 UTC (rev 288) @@ -28,9 +28,13 @@ end def test_encode_decode - s1 = Oneliner::SuperString.new("x" * 191) + s0 = "x" * 191 + s1 = Oneliner::SuperString.new(s0) + assert_equal(s0, s1.to_s) s2 = Oneliner::SuperString.new s2.decode(s1.encode(256)) + assert_equal(s0, s2.to_s); + assert_equal(s1.to_s, s2.to_s); end end From nobody at rubyforge.org Tue May 22 13:59:42 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 13:59:42 -0400 (EDT) Subject: [Archipelago-submits] [289] trunk/oneliner/ext/oneliner.c: almost working, omg Message-ID: <20070522175942.D88765240AFD@rubyforge.org> Revision: 289 Author: zond Date: 2007-05-22 13:59:42 -0400 (Tue, 22 May 2007) Log Message: ----------- almost working, omg Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 13:22:01 UTC (rev 288) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 17:59:42 UTC (rev 289) @@ -32,11 +32,16 @@ // Utility macros. // #ifdef ONELINER_DEBUG +static guint32 indentation = 0; +static guint32 indentation_tmp; +#define INDENT indentation++; +#define UNINDENT indentation--; #define NULL_WARN(x) if ((x) == NULL) DEBUG("x is NULL!!!"); -#define DEBUG(s, ...) { \ - fprintf(stderr, "DEBUG: "); \ - fprintf(stderr, s, ## __VA_ARGS__); \ - fprintf(stderr, "\n"); \ +#define DEBUG(s, ...) { \ + fprintf(stderr, "DEBUG: "); \ + for (indentation_tmp = 0; indentation_tmp < indentation; indentation_tmp++) fprintf(stderr, " "); \ + fprintf(stderr, s, ## __VA_ARGS__); \ + fprintf(stderr, "\n"); \ fflush(NULL); } #define IFDEBUG(s) s #define BITSTRING_DEBUG(msg,str,len) { \ @@ -65,6 +70,8 @@ fprintf(stderr, "\n"); \ fflush(NULL); } #else +#define INDENT ; +#define UNINDENT ; #define DEBUG(s, ...) ; #define IFDEBUG(s) ; #define BITSTRING_DEBUG(msg,str,len) ; @@ -72,7 +79,7 @@ #define CHARS_FOR(i) ((guint32) (log10((gdouble) (i))) + 1) #define RANDOM(context,max) (oneliner_context_random(context) % (max)) -#define RANDFLOAT(context) ( (gdouble) oneliner_context_random(context) ) / ( (gdouble) G_MAXUINT32 ) +#define RANDFLOAT(context) ( (gdouble) ( (guint32) oneliner_context_random(context) ) ) / ( (gdouble) G_MAXUINT32 ) #define RB_ONELINER(rb_obj,pointer) Data_Get_Struct(rb_obj, oneliner_superstring, pointer) #define ALLOC_COPY8(dst,src,len) { \ (dst) = g_new0(guint8, (len) + 1); \ @@ -120,6 +127,8 @@ gboolean initialized; guint8 *sum; GHashTable *source_blocks; + oneliner_superstring *str; + gint32 index; } oneliner_xor_block; // @@ -252,6 +261,7 @@ (g_hash_table_size((xor_block)->source_blocks) == 1) && \ ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) #define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) +#define XOR_BLOCK_USES(xor_block,block_nr) (g_hash_table_lookup_extended((xor_block)->source_blocks, GUINT_TO_POINTER((block_nr)), NULL, NULL)) static void oneliner_xor_block_to_s_iterator(gpointer key, gpointer data, gpointer user_data) @@ -281,27 +291,84 @@ } static oneliner_xor_block * -oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized) +oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized, oneliner_superstring *str, gint32 index) { oneliner_xor_block *rval = g_new0(oneliner_xor_block, 1); ALLOC_COPY8(rval->sum, data, len); rval->initialized = initialized; rval->source_blocks = g_hash_table_new(NULL, NULL); + rval->str = str; + rval->index = index; return rval; } +static void +oneliner_xor_block_print_dep(gpointer key, gpointer data, gpointer user_data) +{ + DEBUG(" %i => %i", GPOINTER_TO_UINT(key), GPOINTER_TO_UINT(data)); +} + +static void +oneliner_xor_block_free_and_remove_from_array(oneliner_xor_block *xor_block, GArray *ary, guint32 source_block_nr) +{ + GHashTable *hash; + + if (ary != NULL) { + DEBUG("we have an array!"); + if ((hash = g_array_index(ary, GHashTable *, source_block_nr)) != NULL) { + DEBUG("the source block has a hash!"); + if (g_hash_table_lookup_extended(hash, xor_block, NULL, NULL)) { + DEBUG("removing it as dependency in the hash"); + g_hash_table_remove(hash, xor_block); + } else { + DEBUG("it doesnt exist as a dependency :/ dependencies are:"); + g_hash_table_foreach(hash, oneliner_xor_block_print_dep, NULL); + } + } else { + DEBUG("no hash for that source block exists :/"); + } + } else { + DEBUG("no array exists :/"); + } +} + static gboolean oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) { + guint32 source_block_nr = GPOINTER_TO_UINT(key); + oneliner_xor_block *xor_block = (oneliner_xor_block *) user_data; + + INDENT; + + DEBUG("trying to remove it as a dependency for %i", source_block_nr); + + if (source_block_nr < xor_block->str->n_blocks_needed) { + DEBUG("looking at graph"); + oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); + } else { + DEBUG("looking at aux_graph_for_source_blocks"); + oneliner_xor_block_free_and_remove_from_array(xor_block, + xor_block->str->aux_graph_for_source_blocks, + source_block_nr - xor_block->str->n_blocks_needed); + } + + UNINDENT; + return TRUE; } static void oneliner_xor_block_free(oneliner_xor_block *xor_block) { + INDENT; + DEBUG("freeing xor_block %i", GPOINTER_TO_UINT(xor_block)); g_free(xor_block->sum); + g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, xor_block); g_hash_table_destroy(xor_block->source_blocks); + if (xor_block->index > -1) + g_array_index(xor_block->str->aux_graph_for_aux_blocks, oneliner_xor_block *, xor_block->index) = NULL; g_free(xor_block); + UNINDENT; } static void @@ -356,9 +423,8 @@ uses = GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr))); - for (tmp = 0; tmp < uses; tmp++) { + if (uses % 2 == 1) oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); - } g_hash_table_remove(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr)); } @@ -384,15 +450,18 @@ { oneliner_graph_insertion *ins = (oneliner_graph_insertion *) insertion; oneliner_superstring *str = (oneliner_superstring *) string; + GHashTable *hash; - g_array_index(str->graph, - GList *, - ins->source_block_nr) = g_list_append(g_array_index(str->graph, - GList *, - ins->source_block_nr), - ins->check_block); + INDENT; + DEBUG("inserting check_block %i as a dependency for block %i", GPOINTER_TO_UINT(ins->check_block), ins->source_block_nr); + if ((hash = g_array_index(str->graph, GHashTable *, ins->source_block_nr)) == NULL) + hash = g_array_index(str->graph, GHashTable *, ins->source_block_nr) = g_hash_table_new(NULL, NULL); + + g_hash_table_insert(hash, ins->check_block, GUINT_TO_POINTER(ins->source_block_nr)); + g_free(insertion); + UNINDENT; } @@ -689,106 +758,163 @@ // // Set either the source of aux block at block_nr of *str to *block. // -static void +static gboolean oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) { if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); + return TRUE; } else if (g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed), block, str->n_chars_in_block); + return TRUE; } + return FALSE; } static void -oneliner_superstring_analyze_source_block_with_array(oneliner_superstring *str, - GArray *ary, - guint32 found_block_nr) +oneliner_superstring_analyze_source_block_with_hash(gpointer key, gpointer data, gpointer user_data) { guint32 source_block_nr; - GList *list_element; - GList *list_head = g_array_index(ary, GList *, found_block_nr); - oneliner_xor_block *xor_block; + guint32 found_block_nr = GPOINTER_TO_UINT(data); + oneliner_xor_block *xor_block = (oneliner_xor_block *) key; + gpointer *args = (gpointer *) user_data; + oneliner_superstring *str = (oneliner_superstring *) args[0]; + GList **to_analyze = (GList **) args[1]; + GList **to_free = (GList **) args[2]; - // For each xor_block-containing item in the list. - for (list_element = list_head; list_element != NULL; list_element = g_list_next(list_element)) { - // Fetch its xor_block - xor_block = (oneliner_xor_block *) list_element->data; + DEBUG("found xor_block %i with size %i", GPOINTER_TO_UINT(xor_block), g_hash_table_size(xor_block->source_blocks)); - // Apply this new knowledge to it. - oneliner_xor_block_apply(xor_block, - str, - found_block_nr); - - // - // If that meant that it is finished then dance the dance of setting the combined block, - // removing it from the GList of check blocks for that combined block, - // and analyzing the results. - // - // Otherwise if it is empty, just free it and remove it. - // - // In fact, right after we have entered this FINISHED block, we will (since we - // call analyze on the resulting block, which leads here) check the same xor_block - // again, reach the EMPTY block, and then free the block. - // - if (XOR_BLOCK_FINISHED(xor_block)) { + // Apply this new knowledge to it. + oneliner_xor_block_apply(xor_block, + str, + found_block_nr); + + DEBUG("after applying it got size %i", g_hash_table_size(xor_block->source_blocks)); - // Find the source block that it defines. - source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + // + // If that meant that it is finished then dance the dance of setting the combined block, + // removing it from the GList of check blocks for that combined block, + // and analyzing the results. + // + // Otherwise if it is empty, just free it and remove it. + // + // In fact, right after we have entered this FINISHED block, we will (since we + // call analyze on the resulting block, which leads here) check the same xor_block + // again, reach the EMPTY block, and then free the block. + // + if (XOR_BLOCK_FINISHED(xor_block)) { - // And set it. - oneliner_superstring_set_combined_block(str, - source_block_nr, - xor_block->sum); + // Find the source block that it defines. + source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + DEBUG("it is finished! setting %i!", source_block_nr); - // Then remove it from our unresolved check blocks so that we can run analyze safely again. - g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); + // And free the xor block. + *to_free = g_list_append(*to_free, xor_block); + + // And set it. + // And now analyze what the newly found source block led to. + // (Right, it can be an aux block as well, but my logic is still correct, I believe.) + if (oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum)) + *to_analyze = g_list_append(*to_analyze, GUINT_TO_POINTER(source_block_nr)); - // Then remove the list element that contained this check block. - g_list_free_1(list_element); + } else if (XOR_BLOCK_EMPTY(xor_block)) { - // And now analyze what the newly found source block led to. - // (Right, it can be an aux block as well, but my logic is still correct, I believe.) - oneliner_superstring_analyze(str, source_block_nr); - } else if (XOR_BLOCK_EMPTY(xor_block)) { - // Free the check block. - oneliner_xor_block_free(xor_block); - // Remove it from our unresolved list. - g_array_index(ary, GList *, found_block_nr) = g_list_remove_link(list_head, list_element); - // And remove the list element. - g_list_free_1(list_element); - } + DEBUG("it is empty!"); + + // Free the check block. + *to_free = g_list_append(*to_free, xor_block); + } } static void -oneliner_superstring_analyze_aux_block(oneliner_superstring *str, guint32 found_block_nr) +oneliner_superstring_to_analyze_iterator(gpointer data, gpointer user_data) { + oneliner_superstring_analyze((oneliner_superstring *) user_data, + GPOINTER_TO_UINT(data)); +} + +static void +oneliner_superstring_to_free_iterator(gpointer data, gpointer user_data) +{ + oneliner_xor_block_free((oneliner_xor_block *) data); +} + +static void +oneliner_superstring_analyze_source_block_with_array(oneliner_superstring *str, + GArray *ary, + guint32 found_block_nr) +{ + GHashTable *hash; + gpointer args[3]; + GList *to_analyze = NULL; + GList *to_free = NULL; + + INDENT; + DEBUG("analyze_source_block_with_array called with %i and %i", found_block_nr, GPOINTER_TO_UINT(ary)); + + args[0] = str; + args[1] = &to_analyze; + args[2] = &to_free; + + if ((hash = g_array_index(ary, GHashTable *, found_block_nr)) != NULL) { + g_hash_table_foreach(hash, oneliner_superstring_analyze_source_block_with_hash, args); + g_list_foreach(to_free, oneliner_superstring_to_free_iterator, NULL); + + g_hash_table_destroy(hash); + g_array_index(ary, GHashTable *, found_block_nr) = NULL; + + g_list_foreach(to_analyze, oneliner_superstring_to_analyze_iterator, str); + } + + UNINDENT; +} + +static void +oneliner_superstring_analyze_aux_block(oneliner_superstring *str, + guint32 found_block_nr) +{ oneliner_xor_block *xor_block; + guint32 source_block_nr; + gboolean found_new_block; + INDENT; + DEBUG("analyze_aux_block called with %i", found_block_nr); + if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, found_block_nr - str->n_blocks_needed)) != NULL) { + + DEBUG("found an unset aux block %i", GPOINTER_TO_UINT(xor_block)); + oneliner_xor_block_set_sum(xor_block, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); if (XOR_BLOCK_FINISHED(xor_block)) { - guint32 source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); + source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); - oneliner_superstring_set_combined_block(str, - source_block_nr, - xor_block->sum); + found_new_block = oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum); g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, found_block_nr - str->n_blocks_needed) = NULL; + oneliner_xor_block_free(xor_block); - oneliner_superstring_analyze(str, source_block_nr); + if (found_new_block) + oneliner_superstring_analyze(str, source_block_nr); + + } else if (XOR_BLOCK_EMPTY(xor_block)) { + oneliner_xor_block_free(xor_block); } } + UNINDENT; } static void oneliner_superstring_analyze(oneliner_superstring *str, guint32 found_block_nr) { + + INDENT; + DEBUG("analyze called with %i", found_block_nr); // // Analyze results for any unresolved check blocks for this found block nr. // @@ -809,6 +935,8 @@ // oneliner_superstring_analyze_aux_block(str, found_block_nr); } + + UNINDENT; } static void @@ -825,7 +953,10 @@ guint32 degree; guint32 block_nr; guint8 *block_content; - + + INDENT; + DEBUG("add_to_graph called"); + oneliner_context_seed(context, (gint32) seed); content_blocks = oneliner_superstring_get_blocks_from_chunk(str, chunk, chunk_len); @@ -834,8 +965,9 @@ degree = oneliner_context_get_degree(context); if (degree == 1) { block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp)); - oneliner_superstring_analyze(str, block_nr); + DEBUG("found block %i in a single block check block", block_nr); + if (oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp))) + oneliner_superstring_analyze(str, block_nr); } else { unknown_source_blocks = 0; unknown_source_block_nr = 0; @@ -843,14 +975,19 @@ xor_block = oneliner_xor_block_new(g_array_index(content_blocks, guint8 *, tmp), str->n_chars_in_block, - TRUE); + TRUE, + str, + -1); + DEBUG("found a multi block check block (sum = %7i) with blocks:", GPOINTER_TO_UINT(xor_block->sum)); for (tmp2 = 0; tmp2 < degree; tmp2++) { block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); block_content = oneliner_superstring_get_combined_block(str, block_nr); if (block_content != NULL) { + DEBUG(" %i IS known!!!!!!!!!", block_nr); oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); } else { + DEBUG(" %i is NOT known :.(", block_nr); oneliner_xor_block_add(xor_block, block_nr); inserts = g_list_append(inserts, oneliner_graph_insertion_new(xor_block, block_nr)); unknown_source_blocks++; @@ -859,13 +996,20 @@ } if (XOR_BLOCK_FINISHED(xor_block)) { - oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum); + DEBUG("found block %i in a multi block check (sum = %i) block with only one missing block", unknown_source_block_nr, GPOINTER_TO_UINT(xor_block->sum)); + + if (oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum)) + oneliner_superstring_analyze(str, unknown_source_block_nr); g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); g_list_free(inserts); - oneliner_superstring_analyze(str, unknown_source_block_nr); + } else if (XOR_BLOCK_EMPTY(xor_block)) { + DEBUG("just deleting it, it is empty..."); + g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); + g_list_free(inserts); } else { + DEBUG("inserting it into the graph"); g_list_foreach(inserts, oneliner_insertion_execute, str); g_list_free(inserts); } @@ -876,6 +1020,7 @@ g_array_free(content_blocks, TRUE); g_free(context); + UNINDENT; } static void @@ -887,30 +1032,31 @@ guint32 tmp2; guint32 aux_block_nr; oneliner_xor_block *aux_block; - GList *aux_blocks; + GHashTable *aux_blocks; oneliner_context_seed(context, (gint32) str->data_len); str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); - str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GList *)); + str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GHashTable *)); g_array_set_size(str->aux_graph_for_source_blocks, str->n_blocks_needed); for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { - aux_blocks = NULL; + aux_blocks = g_hash_table_new(NULL, NULL); for (tmp2 = 0; tmp2 < Q; tmp2++) { aux_block_nr = RANDOM(context, str->n_aux_blocks_needed); if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { - aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE); + aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE, str, aux_block_nr); g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr) = aux_block; } oneliner_xor_block_add(aux_block, tmp); - aux_blocks = g_list_append(aux_blocks, aux_block); + if (!g_hash_table_lookup_extended(aux_blocks, aux_block, NULL, NULL)) + g_hash_table_insert(aux_blocks, aux_block, GUINT_TO_POINTER(tmp)); } - g_array_index(str->aux_graph_for_source_blocks, GList *, tmp) = aux_blocks; + g_array_index(str->aux_graph_for_source_blocks, GHashTable *, tmp) = aux_blocks; } g_free(zeroes); @@ -925,6 +1071,9 @@ guint32 seed; guint32 blocks_needed; + INDENT; + DEBUG("decode called"); + Check_Type(chunk, T_STRING); RB_ONELINER(self, str); @@ -947,13 +1096,13 @@ g_array_set_size(str->blocks, str->n_blocks_needed); str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - str->graph = g_array_new(FALSE, TRUE, sizeof(GList *)); + str->graph = g_array_new(FALSE, TRUE, sizeof(GHashTable *)); g_array_set_size(str->graph, str->n_blocks_needed + str->n_aux_blocks_needed); oneliner_superstring_build_aux_graph(str); } oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); - + UNINDENT; return oneliner_superstring_decode_done(str); } @@ -966,10 +1115,14 @@ guint32 tmp; ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); - for (tmp = 2; tmp <= degree; tmp++) + DEBUG("creating check block with degree %3i and blocks %i", degree, block_nr); + for (tmp = 2; tmp <= degree; tmp++) { + block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); + DEBUG(" %i", block_nr); oneliner_string_xor(rval, - oneliner_superstring_get_combined_block(str, RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed)), + oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); + } return rval; } @@ -989,7 +1142,7 @@ ( (guint32 *) prepend )[0] = str->data_len; ( (guint32 *) prepend )[1] = (guint32) tmp; - while ((rval_ary->len * str->block_size) / 8 < len) { + while ((rval_ary->len * str->block_size) / 8 < (len - 8)) { guint8 *check_block = oneliner_superstring_get_check_block(str, context); g_array_append_val(rval_ary, check_block); } @@ -998,7 +1151,7 @@ // size. And since we cant really truncate it at the end at this stage (like we can in the final build_data_from_blocks) // the data_len argument is the same as the n_bytes_for_blocks argument. Also, we want to prepend the original data-len // and seed, so we use the prepend argument. - tmp = (guint32) ceil((rval_ary->len * str->block_size) / 8); + tmp = (guint32) ceil((rval_ary->len * str->block_size) / 8) + 8; *buffer = oneliner_superstring_build_data_from_blocks(tmp, tmp, str->block_size, @@ -1012,54 +1165,68 @@ } static void -oneliner_superstring_add_xor_to_hash(gpointer data, gpointer user_data) +oneliner_superstring_add_xor_to_hash(gpointer key, gpointer data, gpointer user_data) { - g_hash_table_insert((GHashTable *) user_data, data, NULL); + g_hash_table_insert((GHashTable *) user_data, key, NULL); } static void -oneliner_superstring_free_ary_of_glists_of_xor_blocks(GArray *ary, GHashTable *xors) +oneliner_superstring_free_ary_of_hashes_of_xor_blocks(GArray *ary, GHashTable *xors) { guint32 tmp; for (tmp = 0; tmp < ary->len; tmp++) { - GList *list; - if ((list = (GList *) g_array_index(ary, GList *, tmp)) != NULL) { - g_list_foreach(list, oneliner_superstring_add_xor_to_hash, xors); - g_list_free(list); + GHashTable *hash; + DEBUG("freeing xor blocks belonging to %i", tmp); + if ((hash = (GHashTable *) g_array_index(ary, GHashTable *, tmp)) != NULL) { + g_hash_table_foreach(hash, oneliner_superstring_add_xor_to_hash, xors); + g_hash_table_destroy(hash); } } g_array_free(ary, FALSE); } -static gboolean -oneliner_superstring_free_and_remove_xor(gpointer key, gpointer value, gpointer user_data) +static void +oneliner_superstring_free_xors_killer(gpointer data) { - oneliner_xor_block_free((oneliner_xor_block *) key); - return TRUE; + oneliner_xor_block_free((oneliner_xor_block *) data); } static void oneliner_superstring_free(oneliner_superstring *str) { - GHashTable *xors = g_hash_table_new(NULL, NULL); + GHashTable *xors = g_hash_table_new_full(NULL, NULL, oneliner_superstring_free_xors_killer, NULL); guint32 tmp; + if (str->blocks != NULL) g_array_free(str->blocks, TRUE); if (str->aux_blocks != NULL) g_array_free(str->aux_blocks, TRUE); - if (str->graph != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->graph, xors); + + if (str->graph != NULL) { + INDENT; + DEBUG("freeing graph"); + oneliner_superstring_free_ary_of_hashes_of_xor_blocks(str->graph, xors); + g_array_free(str->graph, FALSE); + str->graph = NULL; + UNINDENT; + } if (str->aux_graph_for_aux_blocks != NULL) { for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) { gpointer xor_block; + DEBUG("freeing aux block at %i", tmp); if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)) != NULL) g_hash_table_insert(xors, xor_block, NULL); } g_array_free(str->aux_graph_for_aux_blocks, FALSE); + str->aux_graph_for_aux_blocks = NULL; } - if (str->aux_graph_for_source_blocks != NULL) - oneliner_superstring_free_ary_of_glists_of_xor_blocks(str->aux_graph_for_source_blocks, xors); - g_hash_table_foreach_remove(xors, oneliner_superstring_free_and_remove_xor, NULL); + if (str->aux_graph_for_source_blocks != NULL) { + INDENT; + DEBUG("freeing aux_graph_for_source_blocks"); + oneliner_superstring_free_ary_of_hashes_of_xor_blocks(str->aux_graph_for_source_blocks, xors); + UNINDENT; + } + g_hash_table_destroy(xors); g_free(str); } From nobody at rubyforge.org Tue May 22 14:20:31 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 14:20:31 -0400 (EDT) Subject: [Archipelago-submits] [290] trunk/oneliner/ext/oneliner.c: working? mostly... Message-ID: <20070522182031.9904B5240AFA@rubyforge.org> Revision: 290 Author: zond Date: 2007-05-22 14:20:31 -0400 (Tue, 22 May 2007) Log Message: ----------- working? mostly... Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 17:59:42 UTC (rev 289) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 18:20:31 UTC (rev 290) @@ -314,15 +314,14 @@ GHashTable *hash; if (ary != NULL) { - DEBUG("we have an array!"); + DEBUG("we have an array, looking for hash at %i!", source_block_nr); if ((hash = g_array_index(ary, GHashTable *, source_block_nr)) != NULL) { - DEBUG("the source block has a hash!"); + DEBUG("the source block has a hash, looking for xor block %i!", GPOINTER_TO_UINT(xor_block)); if (g_hash_table_lookup_extended(hash, xor_block, NULL, NULL)) { DEBUG("removing it as dependency in the hash"); g_hash_table_remove(hash, xor_block); } else { - DEBUG("it doesnt exist as a dependency :/ dependencies are:"); - g_hash_table_foreach(hash, oneliner_xor_block_print_dep, NULL); + rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state... an xor_block that is supposed to be depending on another is not referenced back!"); } } else { DEBUG("no hash for that source block exists :/"); @@ -342,14 +341,12 @@ DEBUG("trying to remove it as a dependency for %i", source_block_nr); - if (source_block_nr < xor_block->str->n_blocks_needed) { - DEBUG("looking at graph"); - oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); - } else { - DEBUG("looking at aux_graph_for_source_blocks"); - oneliner_xor_block_free_and_remove_from_array(xor_block, - xor_block->str->aux_graph_for_source_blocks, - source_block_nr - xor_block->str->n_blocks_needed); + DEBUG("looking at graph (%i)", GPOINTER_TO_UINT(xor_block->str->graph)); + oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); + + if (xor_block->index > -1) { + DEBUG("looking at aux_graph_for_source_blocks (%i)", GPOINTER_TO_UINT(xor_block->str->aux_graph_for_source_blocks)); + oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->aux_graph_for_source_blocks, source_block_nr); } UNINDENT; @@ -860,8 +857,9 @@ if ((hash = g_array_index(ary, GHashTable *, found_block_nr)) != NULL) { g_hash_table_foreach(hash, oneliner_superstring_analyze_source_block_with_hash, args); - g_list_foreach(to_free, oneliner_superstring_to_free_iterator, NULL); + DEBUG("freeing all xor_blocks in ary %i index %i", GPOINTER_TO_UINT(ary), found_block_nr); + g_list_foreach(to_free, oneliner_superstring_to_free_iterator, NULL); g_hash_table_destroy(hash); g_array_index(ary, GHashTable *, found_block_nr) = NULL; From nobody at rubyforge.org Tue May 22 14:35:26 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 14:35:26 -0400 (EDT) Subject: [Archipelago-submits] [291] trunk/oneliner/ext/oneliner.c: ok, it works without crashing and burning, but it doesnt work reliably when it comes to actual decoding... Message-ID: <20070522183526.D8BE45240AFA@rubyforge.org> Revision: 291 Author: zond Date: 2007-05-22 14:35:26 -0400 (Tue, 22 May 2007) Log Message: ----------- ok, it works without crashing and burning, but it doesnt work reliably when it comes to actual decoding... Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 18:20:31 UTC (rev 290) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 18:35:26 UTC (rev 291) @@ -43,7 +43,6 @@ fprintf(stderr, s, ## __VA_ARGS__); \ fprintf(stderr, "\n"); \ fflush(NULL); } -#define IFDEBUG(s) s #define BITSTRING_DEBUG(msg,str,len) { \ fprintf(stderr, "DEBUG: %s: ", (msg)); \ rb_funcall(rb_const_get(rb_cObject, rb_intern("Kernel")), \ @@ -73,7 +72,6 @@ #define INDENT ; #define UNINDENT ; #define DEBUG(s, ...) ; -#define IFDEBUG(s) ; #define BITSTRING_DEBUG(msg,str,len) ; #endif @@ -303,12 +301,6 @@ } static void -oneliner_xor_block_print_dep(gpointer key, gpointer data, gpointer user_data) -{ - DEBUG(" %i => %i", GPOINTER_TO_UINT(key), GPOINTER_TO_UINT(data)); -} - -static void oneliner_xor_block_free_and_remove_from_array(oneliner_xor_block *xor_block, GArray *ary, guint32 source_block_nr) { GHashTable *hash; @@ -321,7 +313,8 @@ DEBUG("removing it as dependency in the hash"); g_hash_table_remove(hash, xor_block); } else { - rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state... an xor_block that is supposed to be depending on another is not referenced back!"); + DEBUG("it doesnt exist as a dependency :/ dependencies are:"); + rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state, an xor_block that depended on a data/aux block wasnt referenced back!"); } } else { DEBUG("no hash for that source block exists :/"); @@ -341,10 +334,10 @@ DEBUG("trying to remove it as a dependency for %i", source_block_nr); - DEBUG("looking at graph (%i)", GPOINTER_TO_UINT(xor_block->str->graph)); - oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); - - if (xor_block->index > -1) { + if (xor_block->index < 0) { + DEBUG("looking at graph (%i)", GPOINTER_TO_UINT(xor_block->str->graph)); + oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); + } else { DEBUG("looking at aux_graph_for_source_blocks (%i)", GPOINTER_TO_UINT(xor_block->str->aux_graph_for_source_blocks)); oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->aux_graph_for_source_blocks, source_block_nr); } From nobody at rubyforge.org Tue May 22 14:43:35 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 22 May 2007 14:43:35 -0400 (EDT) Subject: [Archipelago-submits] [292] trunk/oneliner/ext/oneliner.c: mmok, doesnt really work perfectly even regarding memory management :/ Message-ID: <20070522184336.2D6335240AFA@rubyforge.org> Revision: 292 Author: zond Date: 2007-05-22 14:43:35 -0400 (Tue, 22 May 2007) Log Message: ----------- mmok, doesnt really work perfectly even regarding memory management :/ Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 18:35:26 UTC (rev 291) +++ trunk/oneliner/ext/oneliner.c 2007-05-22 18:43:35 UTC (rev 292) @@ -772,7 +772,8 @@ GList **to_analyze = (GList **) args[1]; GList **to_free = (GList **) args[2]; - DEBUG("found xor_block %i with size %i", GPOINTER_TO_UINT(xor_block), g_hash_table_size(xor_block->source_blocks)); + DEBUG("found xor_block %i", GPOINTER_TO_UINT(xor_block)); + DEBUG("with size %i", g_hash_table_size(xor_block->source_blocks)); // Apply this new knowledge to it. oneliner_xor_block_apply(xor_block, From nobody at rubyforge.org Wed May 23 09:10:23 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:10:23 -0400 (EDT) Subject: [Archipelago-submits] [293] trunk/oneliner: arghghghghgh fucking hash tables Message-ID: <20070523131023.B358B524099C@rubyforge.org> Revision: 293 Author: zond Date: 2007-05-23 09:10:22 -0400 (Wed, 23 May 2007) Log Message: ----------- arghghghghgh fucking hash tables Modified Paths: -------------- trunk/oneliner/ext/extconf.rb trunk/oneliner/ext/oneliner.c trunk/oneliner/tests/superstring_test.rb Modified: trunk/oneliner/ext/extconf.rb =================================================================== --- trunk/oneliner/ext/extconf.rb 2007-05-22 18:43:35 UTC (rev 292) +++ trunk/oneliner/ext/extconf.rb 2007-05-23 13:10:22 UTC (rev 293) @@ -38,9 +38,16 @@ if ARGV.include?("-d") $CFLAGS += " -D ONELINER_DEBUG" +end + +if ARGV.include?("-no_op") $CFLAGS.gsub!(/-O./, "-O0") end -$CFLAGS += " -g -gdwarf-2 -g3 " + `pkg-config --cflags --libs glib-2.0`.strip +if ARGV.include?("-gdb") + $CFLAGS += " -g -gdwarf-2 -g3" +end +$CFLAGS += " " + `pkg-config --cflags --libs glib-2.0`.strip + create_makefile("oneliner") Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-22 18:43:35 UTC (rev 292) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:10:22 UTC (rev 293) @@ -34,6 +34,7 @@ #ifdef ONELINER_DEBUG static guint32 indentation = 0; static guint32 indentation_tmp; +#define IFDEBUG(s) s #define INDENT indentation++; #define UNINDENT indentation--; #define NULL_WARN(x) if ((x) == NULL) DEBUG("x is NULL!!!"); @@ -73,6 +74,7 @@ #define UNINDENT ; #define DEBUG(s, ...) ; #define BITSTRING_DEBUG(msg,str,len) ; +#define IFDEBUG ; #endif #define CHARS_FOR(i) ((guint32) (log10((gdouble) (i))) + 1) @@ -100,6 +102,10 @@ GArray *aux_graph_for_source_blocks; // Our graph of aux blocks for the aux blocks themselves. GArray *aux_graph_for_aux_blocks; + // The list of found blocks to analyze. + GList *to_analyze; + // The list of xor_blocks to free. + GList *to_free; // The size of each block in bits. guint32 block_size; // The number of guint8's needed to contain those bits. @@ -255,39 +261,88 @@ return self; } +static void +oneliner_int_hash_debug_iterator(gpointer key, gpointer value, gpointer user_data) +{ + gchar **buf = (gchar **) user_data; + guint32 key_int = GPOINTER_TO_UINT(key); + guint32 value_int = GPOINTER_TO_UINT(value); + guint32 extra_size_needed = CHARS_FOR(key_int) + CHARS_FOR(value_int) + 6 + 1; + guint32 new_size_needed = strlen(*buf) + extra_size_needed; + *buf = g_realloc(*buf, new_size_needed); + snprintf(*buf + strlen(*buf), extra_size_needed, "%i => %i, ", key_int, value_int); +} + +static gchar * +oneliner_int_hash_to_s(GHashTable *hash) +{ + gchar *buf; + gchar *base = ""); + return buf; +} + +static void +oneliner_int_hash_debug(GHashTable *hash) +{ + gchar *s = oneliner_int_hash_to_s(hash); + DEBUG(s); + g_free(s); +} + +static void +oneliner_debug_block_aux_graph(oneliner_superstring *str, guint32 block_nr) +{ + GHashTable *hash; + guint32 tmp; + if (str->aux_graph_for_source_blocks != NULL && + block_nr < str->aux_graph_for_source_blocks->len && + (hash = g_array_index(str->aux_graph_for_source_blocks, GHashTable *, block_nr)) != NULL) { + fprintf(stderr, "aux_graph_for_source_blocks[_%i_]: ", block_nr); + oneliner_int_hash_debug(hash); + } +} + #define XOR_BLOCK_FINISHED(xor_block) ((xor_block)->initialized && \ (g_hash_table_size((xor_block)->source_blocks) == 1) && \ ((oneliner_xor_block_last_uses((xor_block)) % 2) == 1)) #define XOR_BLOCK_EMPTY(xor_block) (g_hash_table_size((xor_block)->source_blocks) == 0) #define XOR_BLOCK_USES(xor_block,block_nr) (g_hash_table_lookup_extended((xor_block)->source_blocks, GUINT_TO_POINTER((block_nr)), NULL, NULL)) +#define XOR_BLOCK_IS_AUX(xor_block) ((xor_block)->index > -1) +#define XOR_BLOCK_IS_CHECK(xor_block) ((xor_block)->index == -1) +#define XOR_TYPE(xor_block) (XOR_BLOCK_IS_AUX((xor_block)) ? "aux_block" : "check_block") -static void -oneliner_xor_block_to_s_iterator(gpointer key, gpointer data, gpointer user_data) -{ - guint32 source_block_nr = GPOINTER_TO_UINT(key); - guint32 uses = GPOINTER_TO_UINT(data); - gchar **buffer = (gchar **) user_data; - guint32 extra_size_needed = CHARS_FOR(uses) + CHARS_FOR(source_block_nr) + 5 + 1; - guint32 new_size_needed = strlen(*buffer) + extra_size_needed; - *buffer = g_realloc(*buffer, new_size_needed); - snprintf(*buffer + strlen(*buffer), extra_size_needed, "%i => %i,", source_block_nr, uses); -} - static gchar * -oneliner_xor_block_to_s(oneliner_xor_block *xor_block, oneliner_superstring *str) +oneliner_xor_block_to_s(oneliner_xor_block *xor_block) { gchar *rval; - gchar *base = ""); + sprintf(rval + strlen(rval), "%s'>", source_blocks_buf); + g_free(source_blocks_buf); return rval; } +static void +oneliner_xor_block_debug(oneliner_xor_block *xor_block) +{ + gchar *s = oneliner_xor_block_to_s(xor_block); + DEBUG(s); + g_free(s); +} + static oneliner_xor_block * oneliner_xor_block_new(guint8 *data, guint32 len, gboolean initialized, oneliner_superstring *str, gint32 index) { @@ -295,6 +350,7 @@ ALLOC_COPY8(rval->sum, data, len); rval->initialized = initialized; rval->source_blocks = g_hash_table_new(NULL, NULL); + DEBUG("created hash table %i", GPOINTER_TO_UINT(rval->source_blocks)); rval->str = str; rval->index = index; return rval; @@ -306,11 +362,9 @@ GHashTable *hash; if (ary != NULL) { - DEBUG("we have an array, looking for hash at %i!", source_block_nr); if ((hash = g_array_index(ary, GHashTable *, source_block_nr)) != NULL) { - DEBUG("the source block has a hash, looking for xor block %i!", GPOINTER_TO_UINT(xor_block)); if (g_hash_table_lookup_extended(hash, xor_block, NULL, NULL)) { - DEBUG("removing it as dependency in the hash"); + DEBUG("removing from hash table %i", GPOINTER_TO_UINT(hash)); g_hash_table_remove(hash, xor_block); } else { DEBUG("it doesnt exist as a dependency :/ dependencies are:"); @@ -318,13 +372,15 @@ } } else { DEBUG("no hash for that source block exists :/"); + rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state, the source block for an xor_block that we want to remove as a dependency doesnt have a dependency hash!"); } } else { DEBUG("no array exists :/"); + rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state, the oneliner_superstring an xor_block is attached to doesnt have the array we want to remove the dependencies of the xor_block from!"); } } -static gboolean +static void oneliner_xor_block_free_and_remove(gpointer key, gpointer data, gpointer user_data) { guint32 source_block_nr = GPOINTER_TO_UINT(key); @@ -332,30 +388,33 @@ INDENT; - DEBUG("trying to remove it as a dependency for %i", source_block_nr); - - if (xor_block->index < 0) { - DEBUG("looking at graph (%i)", GPOINTER_TO_UINT(xor_block->str->graph)); + if (XOR_BLOCK_IS_CHECK(xor_block)) { + DEBUG("removing _%i_ as a dependency from it in graph", source_block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(xor_block->str, source_block_nr)); oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->graph, source_block_nr); } else { - DEBUG("looking at aux_graph_for_source_blocks (%i)", GPOINTER_TO_UINT(xor_block->str->aux_graph_for_source_blocks)); + DEBUG("removing _%i_ as a dependency from it in aux_graph_for_source_blocks", source_block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(xor_block->str, source_block_nr)); oneliner_xor_block_free_and_remove_from_array(xor_block, xor_block->str->aux_graph_for_source_blocks, source_block_nr); } + IFDEBUG(oneliner_debug_block_aux_graph(xor_block->str, source_block_nr)); + UNINDENT; - - return TRUE; } static void -oneliner_xor_block_free(oneliner_xor_block *xor_block) +oneliner_xor_block_free(oneliner_xor_block *xor_block, gboolean free_dependencies) { INDENT; - DEBUG("freeing xor_block %i", GPOINTER_TO_UINT(xor_block)); + DEBUG("freeing %s %i", XOR_TYPE(xor_block), GPOINTER_TO_UINT(xor_block)); g_free(xor_block->sum); - g_hash_table_foreach_remove(xor_block->source_blocks, oneliner_xor_block_free_and_remove, xor_block); + if (free_dependencies) { + g_hash_table_foreach(xor_block->source_blocks, oneliner_xor_block_free_and_remove, xor_block); + } + DEBUG("destroying hash table %i", GPOINTER_TO_UINT(xor_block->source_blocks)); g_hash_table_destroy(xor_block->source_blocks); - if (xor_block->index > -1) + if (free_dependencies && XOR_BLOCK_IS_AUX(xor_block) && xor_block->str->aux_graph_for_aux_blocks != NULL) g_array_index(xor_block->str->aux_graph_for_aux_blocks, oneliner_xor_block *, xor_block->index) = NULL; g_free(xor_block); UNINDENT; @@ -364,6 +423,11 @@ static void oneliner_xor_block_add(oneliner_xor_block *xor_block, guint32 source_block_nr) { + DEBUG("1 inserting %i => %i into hash table %i", + source_block_nr, + GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, + GUINT_TO_POINTER(source_block_nr))) + 1, + GPOINTER_TO_UINT(xor_block->source_blocks)); g_hash_table_insert(xor_block->source_blocks, GUINT_TO_POINTER(source_block_nr), GUINT_TO_POINTER(GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, @@ -411,12 +475,21 @@ guint32 uses; guint32 tmp; + INDENT; uses = GPOINTER_TO_UINT(g_hash_table_lookup(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr))); + if (uses < 1) { + DEBUG("its not used by this xor_block!!! :O"); + IFDEBUG(oneliner_xor_block_debug(xor_block)); + rb_raise(rb_eRuntimeError, "We have a serious problem with the internal state, the source block being applied to an xor_block doesnt seem to be included in it!"); + } + if (uses % 2 == 1) oneliner_string_xor(xor_block->sum, oneliner_superstring_get_combined_block(str, found_block_nr), str->n_chars_in_block); + DEBUG("removing from hash table %i", GPOINTER_TO_UINT(xor_block->source_blocks)); g_hash_table_remove(xor_block->source_blocks, GUINT_TO_POINTER(found_block_nr)); + UNINDENT; } static oneliner_graph_insertion * @@ -431,7 +504,7 @@ static void oneliner_graph_insertion_free_with_check_block(gpointer insertion, gpointer user_data) { - oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block); + oneliner_xor_block_free(( (oneliner_graph_insertion *) insertion )->check_block, FALSE); g_free(insertion); } @@ -443,11 +516,18 @@ GHashTable *hash; INDENT; - DEBUG("inserting check_block %i as a dependency for block %i", GPOINTER_TO_UINT(ins->check_block), ins->source_block_nr); + DEBUG("inserting check_block %i as a dependency for block _%i_", GPOINTER_TO_UINT(ins->check_block), ins->source_block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(str, ins->source_block_nr)); - if ((hash = g_array_index(str->graph, GHashTable *, ins->source_block_nr)) == NULL) + if ((hash = g_array_index(str->graph, GHashTable *, ins->source_block_nr)) == NULL) { hash = g_array_index(str->graph, GHashTable *, ins->source_block_nr) = g_hash_table_new(NULL, NULL); + DEBUG("created new hash table %i", GPOINTER_TO_UINT(hash)); + } + DEBUG("2 inserting %i => %i into hash table %i", + GPOINTER_TO_UINT(ins->check_block), + ins->source_block_nr, + GPOINTER_TO_UINT(hash)); g_hash_table_insert(hash, ins->check_block, GUINT_TO_POINTER(ins->source_block_nr)); g_free(insertion); @@ -668,6 +748,10 @@ str->n_known_check_blocks = 0; // Make sure we dont think we have decoded already. str->decode_done = FALSE; + // Make sure we have an initialized to_analyze. + str->to_analyze = NULL; + // Make sure we have an initialized to_free. + str->to_free = NULL; } // @@ -767,13 +851,12 @@ guint32 source_block_nr; guint32 found_block_nr = GPOINTER_TO_UINT(data); oneliner_xor_block *xor_block = (oneliner_xor_block *) key; - gpointer *args = (gpointer *) user_data; - oneliner_superstring *str = (oneliner_superstring *) args[0]; - GList **to_analyze = (GList **) args[1]; - GList **to_free = (GList **) args[2]; + oneliner_superstring *str = (oneliner_superstring *) user_data; - DEBUG("found xor_block %i", GPOINTER_TO_UINT(xor_block)); - DEBUG("with size %i", g_hash_table_size(xor_block->source_blocks)); + INDENT; + DEBUG("found %i for _%i_", GPOINTER_TO_UINT(xor_block), found_block_nr); + INDENT; + IFDEBUG(oneliner_xor_block_debug(xor_block)); // Apply this new knowledge to it. oneliner_xor_block_apply(xor_block, @@ -798,38 +881,47 @@ // Find the source block that it defines. source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); - DEBUG("it is finished! setting %i!", source_block_nr); + DEBUG("_%i_ is finished! queueing %s %i to be freed!", source_block_nr, XOR_TYPE(xor_block), GPOINTER_TO_UINT(xor_block)); + IFDEBUG(oneliner_debug_block_aux_graph(str, source_block_nr)); // And free the xor block. - *to_free = g_list_append(*to_free, xor_block); + str->to_free = g_list_append(str->to_free, xor_block); // And set it. // And now analyze what the newly found source block led to. // (Right, it can be an aux block as well, but my logic is still correct, I believe.) - if (oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum)) - *to_analyze = g_list_append(*to_analyze, GUINT_TO_POINTER(source_block_nr)); + if (oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum)) { + DEBUG("_%i_ was unknown, setting and queueing %i to be analyzed! ******************", source_block_nr, source_block_nr); + str->to_analyze = g_list_append(str->to_analyze, GUINT_TO_POINTER(source_block_nr)); + } } else if (XOR_BLOCK_EMPTY(xor_block)) { - DEBUG("it is empty!"); + DEBUG("it is empty, queueing %i to be freed!", GPOINTER_TO_UINT(xor_block)); // Free the check block. - *to_free = g_list_append(*to_free, xor_block); + str->to_free = g_list_append(str->to_free, xor_block); } + UNINDENT; + UNINDENT; } static void -oneliner_superstring_to_analyze_iterator(gpointer data, gpointer user_data) +oneliner_superstring_free_as_necessary(oneliner_superstring *str) { - oneliner_superstring_analyze((oneliner_superstring *) user_data, - GPOINTER_TO_UINT(data)); -} + GList *list_element = str->to_free; -static void -oneliner_superstring_to_free_iterator(gpointer data, gpointer user_data) -{ - oneliner_xor_block_free((oneliner_xor_block *) data); + INDENT; + DEBUG("going through the to_free queue..."); + + while (list_element != NULL) { + oneliner_xor_block_free((oneliner_xor_block *) list_element->data, TRUE); + str->to_free = g_list_remove_link(str->to_free, list_element); + g_list_free_1(list_element); + list_element = str->to_free; + } + UNINDENT; } static void @@ -838,26 +930,21 @@ guint32 found_block_nr) { GHashTable *hash; - gpointer args[3]; - GList *to_analyze = NULL; - GList *to_free = NULL; INDENT; - DEBUG("analyze_source_block_with_array called with %i and %i", found_block_nr, GPOINTER_TO_UINT(ary)); + DEBUG("analyze_source_block_with_array called with _%i_ and %s", found_block_nr, ary == str->graph ? "graph" : "aux_graph_for_source_blocks"); + IFDEBUG(oneliner_debug_block_aux_graph(str, found_block_nr)); - args[0] = str; - args[1] = &to_analyze; - args[2] = &to_free; - if ((hash = g_array_index(ary, GHashTable *, found_block_nr)) != NULL) { - g_hash_table_foreach(hash, oneliner_superstring_analyze_source_block_with_hash, args); + DEBUG("found a hash:"); + IFDEBUG(oneliner_int_hash_debug(hash)); + g_hash_table_foreach(hash, oneliner_superstring_analyze_source_block_with_hash, str); - DEBUG("freeing all xor_blocks in ary %i index %i", GPOINTER_TO_UINT(ary), found_block_nr); - g_list_foreach(to_free, oneliner_superstring_to_free_iterator, NULL); + oneliner_superstring_free_as_necessary(str); + + DEBUG("destroying hash table %i", GPOINTER_TO_UINT(hash)); g_hash_table_destroy(hash); g_array_index(ary, GHashTable *, found_block_nr) = NULL; - - g_list_foreach(to_analyze, oneliner_superstring_to_analyze_iterator, str); } UNINDENT; @@ -872,7 +959,7 @@ gboolean found_new_block; INDENT; - DEBUG("analyze_aux_block called with %i", found_block_nr); + DEBUG("analyze_aux_block called with _%i_", found_block_nr); if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, @@ -884,19 +971,25 @@ if (XOR_BLOCK_FINISHED(xor_block)) { source_block_nr = oneliner_xor_block_last_source_block_nr(xor_block); - found_new_block = oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum); + DEBUG("it is finished, setting the xor block to the new sum, and queueing %i to be freed!", GPOINTER_TO_UINT(xor_block)); g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, found_block_nr - str->n_blocks_needed) = NULL; - oneliner_xor_block_free(xor_block); + str->to_free = g_list_append(str->to_free, xor_block); - if (found_new_block) - oneliner_superstring_analyze(str, source_block_nr); + if (oneliner_superstring_set_combined_block(str, source_block_nr, xor_block->sum)) { + DEBUG("_%i_ was unknown, setting and queueing %i to be analyzed! ******************", source_block_nr, source_block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(str, source_block_nr)); + str->to_analyze = g_list_append(str->to_analyze, GUINT_TO_POINTER(source_block_nr)); + } } else if (XOR_BLOCK_EMPTY(xor_block)) { - oneliner_xor_block_free(xor_block); + DEBUG("it is empty, queueing %i to be freed", GPOINTER_TO_UINT(xor_block)); + str->to_free = g_list_append(str->to_free, xor_block); } + + oneliner_superstring_free_as_necessary(str); } UNINDENT; } @@ -906,7 +999,7 @@ { INDENT; - DEBUG("analyze called with %i", found_block_nr); + DEBUG("analyze called with _%i_", found_block_nr); // // Analyze results for any unresolved check blocks for this found block nr. // @@ -957,9 +1050,11 @@ degree = oneliner_context_get_degree(context); if (degree == 1) { block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - DEBUG("found block %i in a single block check block", block_nr); - if (oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp))) - oneliner_superstring_analyze(str, block_nr); + DEBUG("found block _%i_ in a single block check block", block_nr); + if (oneliner_superstring_set_combined_block(str, block_nr, g_array_index(content_blocks, guint8 *, tmp))) { + DEBUG("_%i_ was unknown, setting it and queueing it for analyze! *********************", block_nr); + str->to_analyze = g_list_append(str->to_analyze, GUINT_TO_POINTER(block_nr)); + } } else { unknown_source_blocks = 0; unknown_source_block_nr = 0; @@ -976,10 +1071,11 @@ block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); block_content = oneliner_superstring_get_combined_block(str, block_nr); if (block_content != NULL) { - DEBUG(" %i IS known!!!!!!!!!", block_nr); + DEBUG(" _%i_ IS known!!!!!!!!!", block_nr); oneliner_string_xor(xor_block->sum, block_content, str->n_chars_in_block); } else { - DEBUG(" %i is NOT known :.(", block_nr); + DEBUG(" _%i_ is NOT known :.(", block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(str, block_nr)); oneliner_xor_block_add(xor_block, block_nr); inserts = g_list_append(inserts, oneliner_graph_insertion_new(xor_block, block_nr)); unknown_source_blocks++; @@ -988,10 +1084,12 @@ } if (XOR_BLOCK_FINISHED(xor_block)) { - DEBUG("found block %i in a multi block check (sum = %i) block with only one missing block", unknown_source_block_nr, GPOINTER_TO_UINT(xor_block->sum)); + DEBUG("found block _%i_ in a multi block check (sum = %i) block with only one missing block", unknown_source_block_nr, GPOINTER_TO_UINT(xor_block->sum)); - if (oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum)) - oneliner_superstring_analyze(str, unknown_source_block_nr); + if (oneliner_superstring_set_combined_block(str, unknown_source_block_nr, xor_block->sum)) { + DEBUG("_%i_ was unknown, setting it and queueing it for analysis *****************", unknown_source_block_nr); + str->to_analyze = g_list_append(str->to_analyze, GUINT_TO_POINTER(unknown_source_block_nr)); + } g_list_foreach(inserts, oneliner_graph_insertion_free_with_check_block, NULL); g_list_free(inserts); @@ -1026,6 +1124,9 @@ oneliner_xor_block *aux_block; GHashTable *aux_blocks; + INDENT; + DEBUG("build_aux_graph called"); + oneliner_context_seed(context, (gint32) str->data_len); str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); @@ -1034,20 +1135,32 @@ for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { aux_blocks = g_hash_table_new(NULL, NULL); + DEBUG("created new hash table %i", GPOINTER_TO_UINT(aux_blocks)); for (tmp2 = 0; tmp2 < Q; tmp2++) { aux_block_nr = RANDOM(context, str->n_aux_blocks_needed); if ((aux_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr)) == NULL) { aux_block = oneliner_xor_block_new(zeroes, str->n_chars_in_block, FALSE, str, aux_block_nr); + DEBUG("creating aux_block nr %i", aux_block_nr, tmp); g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, aux_block_nr) = aux_block; } + DEBUG("adding _%i_ as dependency to aux_block %i", tmp, aux_block_nr); + IFDEBUG(oneliner_debug_block_aux_graph(str, aux_block_nr)); oneliner_xor_block_add(aux_block, tmp); - if (!g_hash_table_lookup_extended(aux_blocks, aux_block, NULL, NULL)) + IFDEBUG(oneliner_xor_block_debug(aux_block)); + + if (!g_hash_table_lookup_extended(aux_blocks, aux_block, NULL, NULL)) { + DEBUG("3 inserting %i => %i into hash table %i", + GPOINTER_TO_UINT(aux_block), + tmp, + GPOINTER_TO_UINT(aux_blocks)); g_hash_table_insert(aux_blocks, aux_block, GUINT_TO_POINTER(tmp)); + } } - + DEBUG("setting aux_graph_for_source_blocks for _%i_", tmp); + IFDEBUG(oneliner_int_hash_debug(aux_blocks)); g_array_index(str->aux_graph_for_source_blocks, GHashTable *, tmp) = aux_blocks; } @@ -1055,6 +1168,24 @@ g_free(context); } +static void +oneliner_superstring_analyze_until_done(oneliner_superstring *str) +{ + GList *list_element = str->to_analyze; + + INDENT; + DEBUG("going through the to_analyze queue..."); + + while (list_element != NULL) { + oneliner_superstring_analyze(str, GPOINTER_TO_UINT(list_element->data)); + str->to_analyze = g_list_remove_link(str->to_analyze, list_element); + g_list_free_1(list_element); + list_element = str->to_analyze; + } + + UNINDENT; +} + static VALUE rb_oneliner_superstring_decode(VALUE self, VALUE chunk) { @@ -1094,6 +1225,8 @@ } oneliner_superstring_add_to_graph(str, seed, (guint8 *) RSTRING(chunk)->ptr + 8, (guint32) RSTRING(chunk)->len - 8); + + oneliner_superstring_analyze_until_done(str); UNINDENT; return oneliner_superstring_decode_done(str); } @@ -1107,10 +1240,10 @@ guint32 tmp; ALLOC_COPY8(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); - DEBUG("creating check block with degree %3i and blocks %i", degree, block_nr); + DEBUG("creating check block with degree %3i and blocks _%i_", degree, block_nr); for (tmp = 2; tmp <= degree; tmp++) { block_nr = RANDOM(context, str->n_blocks_needed + str->n_aux_blocks_needed); - DEBUG(" %i", block_nr); + DEBUG(" _%i_", block_nr); oneliner_string_xor(rval, oneliner_superstring_get_combined_block(str, block_nr), str->n_chars_in_block); @@ -1159,7 +1292,11 @@ static void oneliner_superstring_add_xor_to_hash(gpointer key, gpointer data, gpointer user_data) { - g_hash_table_insert((GHashTable *) user_data, key, NULL); + if (!g_hash_table_lookup_extended((GHashTable *) user_data, key, NULL, NULL)) { + DEBUG("queueing xor_block %i to be freed", GPOINTER_TO_UINT(key)); + DEBUG("4 inserting %i => %i into hash table %i", GPOINTER_TO_UINT(user_data), 0, GPOINTER_TO_UINT(user_data)); + g_hash_table_insert((GHashTable *) user_data, key, NULL); + } } static void @@ -1168,9 +1305,10 @@ guint32 tmp; for (tmp = 0; tmp < ary->len; tmp++) { GHashTable *hash; - DEBUG("freeing xor blocks belonging to %i", tmp); if ((hash = (GHashTable *) g_array_index(ary, GHashTable *, tmp)) != NULL) { + DEBUG("removing xor blocks belonging to _%i_", tmp); g_hash_table_foreach(hash, oneliner_superstring_add_xor_to_hash, xors); + DEBUG("destroying hash table %i", GPOINTER_TO_UINT(hash)); g_hash_table_destroy(hash); } } @@ -1180,7 +1318,7 @@ static void oneliner_superstring_free_xors_killer(gpointer data) { - oneliner_xor_block_free((oneliner_xor_block *) data); + oneliner_xor_block_free((oneliner_xor_block *) data, FALSE); } static void @@ -1189,6 +1327,8 @@ GHashTable *xors = g_hash_table_new_full(NULL, NULL, oneliner_superstring_free_xors_killer, NULL); guint32 tmp; + DEBUG("created new hash table %i", GPOINTER_TO_UINT(xors)); + if (str->blocks != NULL) g_array_free(str->blocks, TRUE); if (str->aux_blocks != NULL) @@ -1203,14 +1343,19 @@ UNINDENT; } if (str->aux_graph_for_aux_blocks != NULL) { + INDENT; + DEBUG("freeing aux_graph_for_aux_blocks"); for (tmp = 0; tmp < str->n_aux_blocks_needed; tmp++) { gpointer xor_block; - DEBUG("freeing aux block at %i", tmp); - if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)) != NULL) + if ((xor_block = g_array_index(str->aux_graph_for_aux_blocks, oneliner_xor_block *, tmp)) != NULL) { + DEBUG("queueing aux block at _%i_ to be freed", tmp); + DEBUG("5 inserting %i => %i into hash table %i", GPOINTER_TO_UINT(xor_block), 0, GPOINTER_TO_UINT(xors)); g_hash_table_insert(xors, xor_block, NULL); + } } g_array_free(str->aux_graph_for_aux_blocks, FALSE); str->aux_graph_for_aux_blocks = NULL; + UNINDENT; } if (str->aux_graph_for_source_blocks != NULL) { INDENT; @@ -1219,6 +1364,8 @@ UNINDENT; } + DEBUG("freeing all xor blocks"); + DEBUG("destroying hash table %i", GPOINTER_TO_UINT(xors)); g_hash_table_destroy(xors); g_free(str); } Modified: trunk/oneliner/tests/superstring_test.rb =================================================================== --- trunk/oneliner/tests/superstring_test.rb 2007-05-22 18:43:35 UTC (rev 292) +++ trunk/oneliner/tests/superstring_test.rb 2007-05-23 13:10:22 UTC (rev 293) @@ -3,6 +3,31 @@ class SuperStringTest < Test::Unit::TestCase + def test_encode_decode + 8.times do |m| + n = 128 * m + 63 + s1 = "x" * n + s2 = Oneliner::SuperString.new(s1) + s3 = Oneliner::SuperString.new + print("(#{s1.size}:#{s2.block_size})") + STDOUT.flush + assert(s3.decode(s2.encode(s1.size * 2))) +# assert_equal(s1, s3.to_s) + end + 2.upto(10) do |m| + n = 1024 * m + 511 + s1 = "x" * n + s2 = Oneliner::SuperString.new(s1) + s3 = Oneliner::SuperString.new + print("(#{s1.size}:#{s2.block_size})") + STDOUT.flush + assert(s3.decode(s2.encode(s1.size * 2))) +# assert_equal(s1, s3.to_s) + end + end + + private + def test_encode_size s = Oneliner::SuperString.new("hehu") 8.upto(20) do |n| @@ -27,14 +52,4 @@ end end - def test_encode_decode - s0 = "x" * 191 - s1 = Oneliner::SuperString.new(s0) - assert_equal(s0, s1.to_s) - s2 = Oneliner::SuperString.new - s2.decode(s1.encode(256)) - assert_equal(s0, s2.to_s); - assert_equal(s1.to_s, s2.to_s); - end - end From nobody at rubyforge.org Wed May 23 09:20:08 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:20:08 -0400 (EDT) Subject: [Archipelago-submits] [294] trunk/oneliner/ext/oneliner.c: more debug Message-ID: <20070523132008.C7DE1524099C@rubyforge.org> Revision: 294 Author: zond Date: 2007-05-23 09:20:08 -0400 (Wed, 23 May 2007) Log Message: ----------- more debug Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:10:22 UTC (rev 293) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:20:08 UTC (rev 294) @@ -835,6 +835,10 @@ static gboolean oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) { + DEBUG("going to try and set combined_array[%i] to %i... at the moment it is set to %i", + block_nr, + GPOINTER_TO_UINT(block), + (block_nr < str->n_blocks_needed) ? GPOINTER_TO_UINT(g_array_index(str->blocks, guint8 *, block_nr)) : GPOINTER_TO_UINT(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed))); if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); return TRUE; From nobody at rubyforge.org Wed May 23 09:31:05 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:31:05 -0400 (EDT) Subject: [Archipelago-submits] [295] trunk/oneliner/ext/oneliner.c: better freeing of arrays Message-ID: <20070523133106.0F802524099C@rubyforge.org> Revision: 295 Author: zond Date: 2007-05-23 09:31:05 -0400 (Wed, 23 May 2007) Log Message: ----------- better freeing of arrays Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:20:08 UTC (rev 294) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:31:05 UTC (rev 295) @@ -77,6 +77,13 @@ #define IFDEBUG ; #endif +#define FREE_ARRAY_WITH_STRINGS(ary,i) { \ + for ((i) = 0; (i) < (ary)->len; (i)++) { \ + if (g_array_index((ary), guint8 *, (i)) != NULL) \ + g_free(g_array_index((ary), guint8 *, (i))); \ + } \ + g_array_free(ary, TRUE); \ + } #define CHARS_FOR(i) ((guint32) (log10((gdouble) (i))) + 1) #define RANDOM(context,max) (oneliner_context_random(context) % (max)) #define RANDFLOAT(context) ( (gdouble) ( (guint32) oneliner_context_random(context) ) ) / ( (gdouble) G_MAXUINT32 ) @@ -1112,7 +1119,7 @@ (str->n_known_check_blocks)++; } - g_array_free(content_blocks, TRUE); + FREE_ARRAY_WITH_STRINGS(content_blocks, tmp); g_free(context); UNINDENT; } @@ -1288,7 +1295,7 @@ 8, prepend); g_free(context); - g_array_free(rval_ary, TRUE); + FREE_ARRAY_WITH_STRINGS(rval_ary, tmp); return tmp; } @@ -1316,7 +1323,7 @@ g_hash_table_destroy(hash); } } - g_array_free(ary, FALSE); + g_array_free(ary, TRUE); } static void @@ -1333,16 +1340,18 @@ DEBUG("created new hash table %i", GPOINTER_TO_UINT(xors)); - if (str->blocks != NULL) - g_array_free(str->blocks, TRUE); - if (str->aux_blocks != NULL) - g_array_free(str->aux_blocks, TRUE); + if (str->blocks != NULL) { + FREE_ARRAY_WITH_STRINGS(str->blocks, tmp); + } + if (str->aux_blocks != NULL) { + FREE_ARRAY_WITH_STRINGS(str->aux_blocks, tmp); + } if (str->graph != NULL) { INDENT; DEBUG("freeing graph"); oneliner_superstring_free_ary_of_hashes_of_xor_blocks(str->graph, xors); - g_array_free(str->graph, FALSE); + g_array_free(str->graph, TRUE); str->graph = NULL; UNINDENT; } @@ -1357,7 +1366,7 @@ g_hash_table_insert(xors, xor_block, NULL); } } - g_array_free(str->aux_graph_for_aux_blocks, FALSE); + g_array_free(str->aux_graph_for_aux_blocks, TRUE); str->aux_graph_for_aux_blocks = NULL; UNINDENT; } From nobody at rubyforge.org Wed May 23 09:34:10 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:34:10 -0400 (EDT) Subject: [Archipelago-submits] [296] trunk/oneliner/ext/oneliner.c: fixed an ugly little bug Message-ID: <20070523133410.89830524099C@rubyforge.org> Revision: 296 Author: zond Date: 2007-05-23 09:34:10 -0400 (Wed, 23 May 2007) Log Message: ----------- fixed an ugly little bug Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:31:05 UTC (rev 295) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:34:10 UTC (rev 296) @@ -842,14 +842,10 @@ static gboolean oneliner_superstring_set_combined_block(oneliner_superstring *str, guint32 block_nr, guint8 *block) { - DEBUG("going to try and set combined_array[%i] to %i... at the moment it is set to %i", - block_nr, - GPOINTER_TO_UINT(block), - (block_nr < str->n_blocks_needed) ? GPOINTER_TO_UINT(g_array_index(str->blocks, guint8 *, block_nr)) : GPOINTER_TO_UINT(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed))); if (block_nr < str->n_blocks_needed && g_array_index(str->blocks, guint8 *, block_nr) == NULL) { ALLOC_COPY8(g_array_index(str->blocks, guint8 *, block_nr), block, str->n_chars_in_block); return TRUE; - } else if (g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { + } else if (block_nr >= str->n_blocks_needed && g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed) == NULL) { ALLOC_COPY8(g_array_index(str->aux_blocks, guint8 *, block_nr - str->n_blocks_needed), block, str->n_chars_in_block); return TRUE; } From nobody at rubyforge.org Wed May 23 09:37:12 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:37:12 -0400 (EDT) Subject: [Archipelago-submits] [297] trunk/oneliner/ext/oneliner.c: fixed some uninitialized pointers Message-ID: <20070523133712.18EB0524099C@rubyforge.org> Revision: 297 Author: zond Date: 2007-05-23 09:37:11 -0400 (Wed, 23 May 2007) Log Message: ----------- fixed some uninitialized pointers Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:34:10 UTC (rev 296) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:37:11 UTC (rev 297) @@ -759,6 +759,10 @@ str->to_analyze = NULL; // Make sure we have an initialized to_free. str->to_free = NULL; + // Make sure our graphs are initialized empty. + str->graph = NULL; + str->aux_graph_for_aux_blocks = NULL; + str->aux_graph_for_source_blocks = NULL; } // From nobody at rubyforge.org Wed May 23 09:47:53 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:47:53 -0400 (EDT) Subject: [Archipelago-submits] [298] trunk/oneliner/ext/oneliner.c: tried to get rid of a memory leak Message-ID: <20070523134753.406CE5240A41@rubyforge.org> Revision: 298 Author: zond Date: 2007-05-23 09:47:53 -0400 (Wed, 23 May 2007) Log Message: ----------- tried to get rid of a memory leak Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:37:11 UTC (rev 297) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:47:53 UTC (rev 298) @@ -1327,7 +1327,7 @@ } static void -oneliner_superstring_free_xors_killer(gpointer data) +oneliner_superstring_free_xors_killer(gpointer data, gpointer tmp1, gpointer tmp2) { oneliner_xor_block_free((oneliner_xor_block *) data, FALSE); } @@ -1335,7 +1335,7 @@ static void oneliner_superstring_free(oneliner_superstring *str) { - GHashTable *xors = g_hash_table_new_full(NULL, NULL, oneliner_superstring_free_xors_killer, NULL); + GHashTable *xors = g_hash_table_new(NULL, NULL); guint32 tmp; DEBUG("created new hash table %i", GPOINTER_TO_UINT(xors)); @@ -1379,6 +1379,7 @@ DEBUG("freeing all xor blocks"); DEBUG("destroying hash table %i", GPOINTER_TO_UINT(xors)); + g_hash_table_foreach(xors, oneliner_superstring_free_xors_killer, NULL); g_hash_table_destroy(xors); g_free(str); } From nobody at rubyforge.org Wed May 23 09:53:23 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:53:23 -0400 (EDT) Subject: [Archipelago-submits] [299] trunk/oneliner/ext/oneliner.c: made some array constructions nicer Message-ID: <20070523135323.4AE295240A83@rubyforge.org> Revision: 299 Author: zond Date: 2007-05-23 09:53:22 -0400 (Wed, 23 May 2007) Log Message: ----------- made some array constructions nicer Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:47:53 UTC (rev 298) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:53:22 UTC (rev 299) @@ -599,9 +599,8 @@ guint32 block_nr; guint8 *tmp_block; guint8 tmp_data[n_bytes_for_blocks]; - GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + GArray *rval = g_array_sized_new(FALSE, FALSE, sizeof(guint8 *), n_blocks_needed); - g_array_set_size(rval, n_blocks_needed); memcpy((gchar *) tmp_data, (gchar *) data, sizeof(guint8) * data_len); for (block_nr = 0; block_nr < n_blocks_needed; block_nr++) { guint32 pos = block_nr * block_size; @@ -711,8 +710,7 @@ oneliner_context *context = oneliner_context_new(); oneliner_context_seed(context, (gint32) str->data_len); - str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); + str->aux_blocks = g_array_sized_new(FALSE, TRUE, sizeof(guint8 *), str->n_aux_blocks_needed); for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { guint32 tmp2; @@ -1139,10 +1137,8 @@ DEBUG("build_aux_graph called"); oneliner_context_seed(context, (gint32) str->data_len); - str->aux_graph_for_aux_blocks = g_array_new(FALSE, TRUE, sizeof(oneliner_xor_block *)); - g_array_set_size(str->aux_graph_for_aux_blocks, str->n_aux_blocks_needed); - str->aux_graph_for_source_blocks = g_array_new(FALSE, TRUE, sizeof(GHashTable *)); - g_array_set_size(str->aux_graph_for_source_blocks, str->n_blocks_needed); + str->aux_graph_for_aux_blocks = g_array_sized_new(FALSE, TRUE, sizeof(oneliner_xor_block *), str->n_aux_blocks_needed); + str->aux_graph_for_source_blocks = g_array_sized_new(FALSE, TRUE, sizeof(GHashTable *), str->n_blocks_needed); for (tmp = 0; tmp < str->n_blocks_needed; tmp++) { aux_blocks = g_hash_table_new(NULL, NULL); @@ -1226,12 +1222,9 @@ if (str->blocks == NULL) { oneliner_superstring_initialize(str, data_len); - str->blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->blocks, str->n_blocks_needed); - str->aux_blocks = g_array_new(FALSE, TRUE, sizeof(guint8 *)); - g_array_set_size(str->aux_blocks, str->n_aux_blocks_needed); - str->graph = g_array_new(FALSE, TRUE, sizeof(GHashTable *)); - g_array_set_size(str->graph, str->n_blocks_needed + str->n_aux_blocks_needed); + str->blocks = g_array_sized_new(FALSE, TRUE, sizeof(guint8 *), str->n_blocks_needed); + str->aux_blocks = g_array_sized_new(FALSE, TRUE, sizeof(guint8 *), str->n_aux_blocks_needed); + str->graph = g_array_sized_new(FALSE, TRUE, sizeof(GHashTable *), str->n_blocks_needed + str->n_aux_blocks_needed); oneliner_superstring_build_aux_graph(str); } From nobody at rubyforge.org Wed May 23 09:56:49 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 May 2007 09:56:49 -0400 (EDT) Subject: [Archipelago-submits] [300] trunk/oneliner/ext/oneliner.c: removed the sized new again, they didnt clear the memory :O Message-ID: <20070523135649.798445240A80@rubyforge.org> Revision: 300 Author: zond Date: 2007-05-23 09:56:49 -0400 (Wed, 23 May 2007) Log Message: ----------- removed the sized new again, they didnt clear the memory :O Modified Paths: -------------- trunk/oneliner/ext/oneliner.c Modified: trunk/oneliner/ext/oneliner.c =================================================================== --- trunk/oneliner/ext/oneliner.c 2007-05-23 13:53:22 UTC (rev 299) +++ trunk/oneliner/ext/oneliner.c 2007-05-23 13:56:49 UTC (rev 300) @@ -599,8 +599,9 @@ guint32 block_nr; guint8 *tmp_block; guint8 tmp_data[n_bytes_for_blocks]; - GArray *rval = g_array_sized_new(FALSE, FALSE, sizeof(guint8 *), n_blocks_needed); + GArray *rval = g_array_new(FALSE, FALSE, sizeof(guint8 *)); + g_array_set_size(rval, n_block