[Pkg] The Trunk: KernelTests-nice.194.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jun 4 19:02:05 UTC 2011
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.194.mcz
==================== Summary ====================
Name: KernelTests-nice.194
Author: nice
Time: 4 June 2011, 9:01:45.693 pm
UUID: c6cd136f-95ab-4d8d-9b73-8cc231b299fb
Ancestors: KernelTests-nice.193
Add a test for Montgomery multiplication (if ever implemented by the VM).
=============== Diff against KernelTests-nice.193 ===============
Item was added:
+ ----- Method: IntegerTest>>testMontgomeryMultiplication (in category 'testing - arithmetic') -----
+ testMontgomeryMultiplication
+ | a m mInv |
+ m := 15485863.
+ mInv := 256 - ((m bitAnd: 255) reciprocalModulo: 256).
+ a := (256 raisedTo: m digitLength) \\ m.
+ #(483933 3871465 8951195) do: [:s |
+ (s montgomeryTimes: a modulo: m mInvModB: mInv) ifNotNil: [:s1 |
+ | s2 sa ssa |
+ self assert: s = s1.
+ sa := s montgomeryTimes: (a * a \\ m) modulo: m mInvModB: mInv.
+ self assert: sa = (s * a \\ m).
+ ssa := sa montgomeryTimes: sa modulo: m mInvModB: mInv.
+ self assert: ssa = (s * s * a \\ m).
+ s2 := ssa montgomeryTimes: 1 modulo: m mInvModB: mInv.
+ self assert: s2 = (s * s \\ m)]].!
More information about the Packages
mailing list