* bignum.c (bigmul0): disable big_mul_toom3_temporalily.

[ruby-core:48552] [Bug #7242]

* test/ruby/test_bignum.rb (test_mul_large_numbers):
  add a test for bigmul1_toom3 suggested in [Bug #7242].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2012-11-08 20:38:53 +00:00
parent 9f9ebe4eba
commit 22767ffd13
3 changed files with 121 additions and 7 deletions

View File

@ -1,3 +1,11 @@
Thu Nov 9 05:33:99 2012 Kenta Murata <mrkn@mrkn.jp>
* bignum.c (bigmul0): disable big_mul_toom3_temporalily.
[ruby-core:48552] [Bug #7242]
* test/ruby/test_bignum.rb (test_mul_large_numbers):
add a test for bigmul1_toom3 suggested in [Bug #7242].
Thu Nov 8 21:57:59 2012 Masaki Matsushita <glass.saga@gmail.com>
* re.c (rb_memsearch): performance improvement by using memchr().

View File

@ -2617,13 +2617,8 @@ bigmul0(VALUE x, VALUE y)
/* balance multiplication by slicing y when x is much smaller than y */
if (2 * xn <= yn) return bigmul1_balance(x, y);
if (xn < TOOM3_MUL_DIGITS) {
/* multiplication by karatsuba method */
return bigmul1_karatsuba(x, y);
}
else if (3*xn <= 2*(yn + 2))
return bigmul1_balance(x, y);
return bigmul1_toom3(x, y);
/* multiplication by karatsuba method */
return bigmul1_karatsuba(x, y);
}
/*

View File

@ -264,6 +264,117 @@ class TestBignum < Test::Unit::TestCase
assert_equal(3**7000, (3**5000) * (3**2000))
end
def test_mul_large_numbers
a = %w[
32580286268570032115047167942578356789222410206194227403993117616454027392
62501901985861926098797067562795526004375784403965882943322008991129440928
33855888840298794008677656280486901895499985197580043127115026675632969396
55040226415022070581995493731570435346323030715226718346725312551631168110
83966158581772380474470605428802018934282425947323171408377505151988776271
85865548747366001752375899635539662017095652855537225416899242508164949615
96848508410008685252121247181772953744297349638273854170932226446528911938
03430429031094465344063914822790537339912760237589085026016396616506014081
53557719631183538265614091691713138728177917059624255801026099255450058876
97412698978242128457751836011774504753020608663272925708049430557191193188
23212591809241860763625985763438355314593186083254640117460724730431447842
15432124830037389073162094304199742919767272162759192882136828372588787906
96027938532441670018954643423581446981760344524184231299785949158765352788
38452309862972527623669323263424418781899966895996672291193305401609553502
63893514163147729201340204483973131948541009975283778189609285614445485714
63843850089417416331356938086609682943037801440660232801570877143192251897
63026816485314923378023904237699794122181407920355722922555234540701118607
37971417665315821995516986204709574657462370947443531049033704997194647442
13711787319587466437795542850136751816475182349380345341647976135081955799
56787050815348701001765730577514591032367920292271016649813170789854524395
72571698998841196411826453893352760318867994518757872432266374568779920489
55597104558927387008506485038236352630863481679853742412042588244086070827
43705456833283086410967648483312972903432798923897357373793064381177468258
69131640408147806442422254638590386673344704147156793990832671592488742473
31524606724894164324227362735271650556732855509929890983919463699819116427
].join.to_i
b = %w[
31519454770031243652776765515030872050264386564379909299874378289835540661
99756262835346828114038365624177182230027040172583473561802565238817167503
85144159132462819032164726177606533272071955542237648482852154879445654746
25061253606344846225905712926863168413666058602449408307586532461776530803
56810626880722653177544008166119272373179841889454920521993413902672848145
77974951972342194855267960390195830413354782136431833731467699250684103370
98571305167189174270854698169136844578685346745340041520068176478277580590
43810457765638903028049263788987034217272442328962400931269515791911786205
15357047519615932249418012945178659435259428163356223753159488306813844040
93609959555018799309373542926110109744437994067754004273450659607204900586
28878103661124568217617766580438460505513654179249613168352070584906185237
34829991855182473813233425492094534396541544295119674419522772382981982574
64708442087451070125274285088681225122475041996116377707892328889948526913
82239084041628877737628853240361038273348062246951097300286513836140601495
63604611754185656404194406869925540477185577643853560887894081047256701731
66884554460428760857958761948461476977864005799494946578017758268987123749
85937011490156431231903167442071541493304390639100774497107347884381581049
85451663323551635322518839895028929788021096587229364219084708576998525298
39594168681411529110089531428721005176467479027585291807482375043729783455
35827667428080449919778142400266842990117940984804919512360370451936835708
76338722049621773169385978521438867493162717866679193103745711403152099047
27294943901673885707639094215339506973982546487889199083181789561917985023
82368442718514694400160954955539704757794969665555505203532944598698824542
00599461848630034847211204029842422678421808487300084850702007663003230882
16645745324467830796203354080471008809087072562876681588151822072260738003
].join.to_i
c = %w[
10269128594368631269792194698469828812223242061960065022209211719149714886
03494742299892841188636314745174778237781513956755034582435818316155459882
71422025990633195596790290038198841087091600598192959108790192789550336119
13849937951116346796903163312950010689963716629093190601532313463306463573
64436438673379454947908896258675634478867189655764364639888427350090856831
84369949421175534994092429682748078316130135651006102162888937624830856951
64818150356583421988135211585954838926347035741143424980258821170351244310
33072045488402539147707418016613224788469923473310249137422855065567940804
75231970365923936034328561426062696074717204901606475826224235014948198414
19979210494282212322919438926816203585575357874850252052656098969732107129
30639419804565653489687198910271702181183420960744232756057631336661646896
48734093497394719644969417287962767186599484579769717220518657324467736902
16947995288312851432262922140679347615046098863974141226499783975470926697
95970415188661518504275964397022973192968233221707696639386238428211541334
69925631385166494600401675904803418143232703594169525858261988389529181035
06048776134746377586210180203524132714354779486439559392942733781343640971
02430607931736785273011780813863748280091795277451796799961887248262211653
38966967509803488282644299584920109534552889962877144862747797551711984992
00726518175235286668236031649728858774545087668286506201943248842967749907
05345423019480534625965140632428736051632750698608916592720742728646191514
86268964807395494825321744802493138032936406889713953832376411900451422777
06372983421062172556566901346288286168790235741528630664513209619789835729
36999522461733403414326366959273556098219489572448083984779946889707480205
42459898495081687425132939473146331452400120169525968892769310016015870148
66821361032541586130017904207971120217385522074967066199941112154460026348
07223950375610474071278649031647998546085807777970592429037128484222394216
33776560239741740193444702279919018283324070210090106960567819910943036248
16660475627526085805165023447934326510232828674828006752369603151390527384
16810180735871644266726954590262010744712519045524839388305761859432443670
05188791334908140831469790180096209292338569623252372975043915954675335333
66614002146554533771788633057869340167604765688639181655208751680821446276
75871494160208888666798836473728725968253820774671626436794492530356258709
62318715778035246655925307167306434486713879511272648637608703497794724929
54912261106702913491290913962825303534484477936036071463820553314826894581
36951927032835690160443252405644718368516656317176848748544135126122940034
68454782581240953957381976073459570718038035358630417744490242611126043987
89191812971310096496208294948623403471433467614886863238916702384858514703
24327715474804343531844042107910755966152655912676456945146277848606406879
49724219295823540160221752189725460676360350860849986313532861445465771187
86822806696323658053947125253562001971534265078959827450518368635828010637
91977444206363529864361796188661941906329947840521598310396004328950804758
79728679236044038853668859284513594307352133390781441610395116807369310560
35193762565748328526426224069629084264376146174383444988110993194030351064
29660536743256949099972314033972121470913480844652490838985461134989129492
75577567064571716731774820127381261057956083604361635892088585967074514802
51958582645785905276289980534832170529946494815794770854644518463332458915
77572397432680871220602513555535017751714443325264019171753694163676670792
04353584782364068773777058727187323211012094819929720407636607815292764459
21851731257845562153822058534043916834839514338448582518847879059020959697
90538105704766415685100946308842788321400392381169436435078204622400475281
].join.to_i
assert_equal(c, a*b)
end
def test_divrem
assert_equal(0, T32 / T64)
end