-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from Bodigrim/gaussian
Speed up factorisation of Gaussian primes
- Loading branch information
Showing
9 changed files
with
244 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
||
module Math.NumberTheory.GaussianIntegersBench | ||
( benchSuite | ||
) where | ||
|
||
import Control.DeepSeq | ||
import Gauge.Main | ||
|
||
import Math.NumberTheory.ArithmeticFunctions (tau) | ||
import Math.NumberTheory.GaussianIntegers | ||
|
||
instance NFData GaussianInteger | ||
|
||
benchFindPrime :: Integer -> Benchmark | ||
benchFindPrime n = bench (show n) $ nf findPrime n | ||
|
||
benchTau :: Integer -> Benchmark | ||
benchTau n = bench (show n) $ nf (\m -> sum [tau (x :+ y) | x <- [1..m], y <- [0..m]] :: Word) n | ||
|
||
benchSuite :: Benchmark | ||
benchSuite = bgroup "Gaussian" | ||
[ bgroup "findPrime" $ map benchFindPrime [1000033, 10000121, 100000037, 1000000009, 10000000033, 100000000057, 1000000000061, 10000000000037] | ||
, bgroup "tau" $ map benchTau [10, 20, 40, 80] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.