Create a modular multiplication trait, and build a slow implementation using mod.
This commit is contained in:
@@ -13,6 +13,7 @@ testTypes = [("addition", addTest),
|
||||
("subtraction", subTest),
|
||||
("multiplication", mulTest),
|
||||
("expandingmul", expmulTest),
|
||||
("modmul", modmulTest),
|
||||
("squaring", squareTest),
|
||||
("division", divTest)
|
||||
]
|
||||
@@ -96,6 +97,19 @@ expmulTest bitsize gen0 = (res, gen2)
|
||||
("b", showHex b' ""),
|
||||
("c", showHex c "")]
|
||||
|
||||
modmulTest :: Int -> StdGen -> (Map String String, StdGen)
|
||||
modmulTest bitsize gen0 = (res, gen2)
|
||||
where
|
||||
(a, gen1) = random gen0
|
||||
(b, gen2) = random gen1
|
||||
(m, gen3) = random gen2
|
||||
[a',b',m'] = splitMod bitsize [a,b,m]
|
||||
c = (a' * b') `mod` m'
|
||||
res = Map.fromList [("a", showHex a' ""),
|
||||
("b", showHex b' ""),
|
||||
("m", showHex m' ""),
|
||||
("c", showHex c "")]
|
||||
|
||||
squareTest :: Int -> StdGen -> (Map String String, StdGen)
|
||||
squareTest bitsize gen0 = (res, gen1)
|
||||
where
|
||||
|
||||
4000
tests/math/modmulU1024.test
Normal file
4000
tests/math/modmulU1024.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU15360.test
Normal file
4000
tests/math/modmulU15360.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU192.test
Normal file
4000
tests/math/modmulU192.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU2048.test
Normal file
4000
tests/math/modmulU2048.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU256.test
Normal file
4000
tests/math/modmulU256.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU3072.test
Normal file
4000
tests/math/modmulU3072.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU384.test
Normal file
4000
tests/math/modmulU384.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU4096.test
Normal file
4000
tests/math/modmulU4096.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU512.test
Normal file
4000
tests/math/modmulU512.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU576.test
Normal file
4000
tests/math/modmulU576.test
Normal file
File diff suppressed because it is too large
Load Diff
4000
tests/math/modmulU8192.test
Normal file
4000
tests/math/modmulU8192.test
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user