factory 0.2.1.2 → 0.2.2.1
raw patch · 63 files changed
+457/−372 lines, 63 filesdep +data-defaultdep ~toolshedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: data-default
Dependency ranges changed: toolshed
API changes (from Hackage documentation)
- Factory.Math.Implementations.Factorial: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.Factorial.Algorithm
- Factory.Math.Implementations.Pi.AGM.Algorithm: instance ToolShed.Defaultable.Defaultable squareRootAlgorithm => ToolShed.Defaultable.Defaultable (Factory.Math.Implementations.Pi.AGM.Algorithm.Algorithm squareRootAlgorithm)
- Factory.Math.Implementations.Pi.BBP.Algorithm: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.Pi.BBP.Algorithm.Algorithm
- Factory.Math.Implementations.Pi.Borwein.Algorithm: instance (ToolShed.Defaultable.Defaultable squareRootAlgorithm, ToolShed.Defaultable.Defaultable factorialAlgorithm) => ToolShed.Defaultable.Defaultable (Factory.Math.Implementations.Pi.Borwein.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm)
- Factory.Math.Implementations.Pi.Ramanujan.Algorithm: instance (ToolShed.Defaultable.Defaultable squareRootAlgorithm, ToolShed.Defaultable.Defaultable factorialAlgorithm) => ToolShed.Defaultable.Defaultable (Factory.Math.Implementations.Pi.Ramanujan.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm)
- Factory.Math.Implementations.Pi.Spigot.Algorithm: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.Pi.Spigot.Algorithm.Algorithm
- Factory.Math.Implementations.Primality: instance ToolShed.Defaultable.Defaultable (Factory.Math.Implementations.Primality.Algorithm factorisationAlgorithm)
- Factory.Math.Implementations.PrimeFactorisation: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.PrimeFactorisation.Algorithm
- Factory.Math.Implementations.Primes.Algorithm: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.Primes.Algorithm.Algorithm
- Factory.Math.Implementations.SquareRoot: instance ToolShed.Defaultable.Defaultable Factory.Math.Implementations.SquareRoot.Algorithm
- Factory.Math.Pi: instance (ToolShed.Defaultable.Defaultable agm, ToolShed.Defaultable.Defaultable bbp, ToolShed.Defaultable.Defaultable borwein, ToolShed.Defaultable.Defaultable ramanujan, ToolShed.Defaultable.Defaultable spigot) => ToolShed.Defaultable.Defaultable (Factory.Math.Pi.Category agm bbp borwein ramanujan spigot)
+ Factory.Data.Exponential: infix 4 =~
+ Factory.Data.Exponential: infixr 8 <^
+ Factory.Data.Monomial: infix 4 =~
+ Factory.Data.Monomial: infixl 7 <*>
+ Factory.Data.Polynomial: infixl 7 *=
+ Factory.Data.PrimeFactors: infixl 7 >/<
+ Factory.Data.PrimeFactors: infixr 8 >^
+ Factory.Data.Ring: infixr 8 =^
+ Factory.Math.Implementations.Factorial: infixl 7 !/!
+ Factory.Math.Implementations.Factorial: instance Data.Default.Class.Default Factory.Math.Implementations.Factorial.Algorithm
+ Factory.Math.Implementations.Pi.AGM.Algorithm: instance Data.Default.Class.Default squareRootAlgorithm => Data.Default.Class.Default (Factory.Math.Implementations.Pi.AGM.Algorithm.Algorithm squareRootAlgorithm)
+ Factory.Math.Implementations.Pi.BBP.Algorithm: instance Data.Default.Class.Default Factory.Math.Implementations.Pi.BBP.Algorithm.Algorithm
+ Factory.Math.Implementations.Pi.Borwein.Algorithm: instance (Data.Default.Class.Default squareRootAlgorithm, Data.Default.Class.Default factorialAlgorithm) => Data.Default.Class.Default (Factory.Math.Implementations.Pi.Borwein.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm)
+ Factory.Math.Implementations.Pi.Ramanujan.Algorithm: instance (Data.Default.Class.Default squareRootAlgorithm, Data.Default.Class.Default factorialAlgorithm) => Data.Default.Class.Default (Factory.Math.Implementations.Pi.Ramanujan.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm)
+ Factory.Math.Implementations.Pi.Spigot.Algorithm: instance Data.Default.Class.Default Factory.Math.Implementations.Pi.Spigot.Algorithm.Algorithm
+ Factory.Math.Implementations.Primality: instance Data.Default.Class.Default (Factory.Math.Implementations.Primality.Algorithm factorisationAlgorithm)
+ Factory.Math.Implementations.PrimeFactorisation: instance Data.Default.Class.Default Factory.Math.Implementations.PrimeFactorisation.Algorithm
+ Factory.Math.Implementations.Primes.Algorithm: instance Data.Default.Class.Default Factory.Math.Implementations.Primes.Algorithm.Algorithm
+ Factory.Math.Implementations.SquareRoot: instance Data.Default.Class.Default Factory.Math.Implementations.SquareRoot.Algorithm
+ Factory.Math.Pi: instance Data.Default.Class.Default bbp => Data.Default.Class.Default (Factory.Math.Pi.Category agm bbp borwein ramanujan spigot)
+ Factory.Math.Statistics: getRootMeanSquare :: (Foldable foldable, Floating result, Real value) => foldable value -> result
- Factory.Math.PrimeFactorisation: omega :: (Algorithmic algorithm, NFData i, Integral i) => algorithm -> [i]
+ Factory.Math.PrimeFactorisation: omega :: (Algorithmic algorithm, Integral i) => algorithm -> [i]
- Factory.Math.PrimeFactorisation: regularNumbers :: (Algorithmic algorithm, NFData base, Integral base) => algorithm -> [base]
+ Factory.Math.PrimeFactorisation: regularNumbers :: (Algorithmic algorithm, Integral base) => algorithm -> [base]
- Factory.Math.Statistics: getWeightedMean :: (Foldable foldable, Fractional result, Real value, Real weight) => foldable (value, weight) -> result
+ Factory.Math.Statistics: getWeightedMean :: (Foldable foldable, Eq result, Fractional result, Real value, Real weight) => foldable (value, weight) -> result
Files
- .ghci +1/−0
- README.markdown +14/−4
- changelog.markdown +135/−82
- copyright +1/−1
- factory.cabal +25/−13
- src-exe/Factory/Test/CommandOptions.hs +4/−5
- src-exe/Factory/Test/Performance/Pi.hs +1/−3
- src-exe/Factory/Test/Performance/Primality.hs +1/−1
- src-exe/Factory/Test/Performance/PrimeFactorisation.hs +1/−1
- src-exe/Factory/Test/Performance/Primes.hs +2/−1
- src-exe/Main.hs +5/−5
- src-lib/Factory/Data/Exponential.hs +3/−3
- src-lib/Factory/Data/Interval.hs +5/−5
- src-lib/Factory/Data/MonicPolynomial.hs +3/−3
- src-lib/Factory/Data/Monomial.hs +1/−1
- src-lib/Factory/Data/Polynomial.hs +10/−10
- src-lib/Factory/Data/PrimeWheel.hs +3/−3
- src-lib/Factory/Data/QuotientRing.hs +1/−1
- src-lib/Factory/Data/Ring.hs +6/−6
- src-lib/Factory/Math/ArithmeticGeometricMean.hs +3/−3
- src-lib/Factory/Math/DivideAndConquer.hs +2/−2
- src-lib/Factory/Math/Fibonacci.hs +1/−1
- src-lib/Factory/Math/Hyperoperation.hs +4/−4
- src-lib/Factory/Math/Implementations/Factorial.hs +10/−10
- src-lib/Factory/Math/Implementations/Pi/AGM/Algorithm.hs +4/−4
- src-lib/Factory/Math/Implementations/Pi/AGM/BrentSalamin.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/BBP/Algorithm.hs +4/−4
- src-lib/Factory/Math/Implementations/Pi/BBP/Bellard.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Borwein/Algorithm.hs +7/−7
- src-lib/Factory/Math/Implementations/Pi/Borwein/Borwein1993.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Borwein/Implementation.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Borwein/Series.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Ramanujan/Algorithm.hs +9/−9
- src-lib/Factory/Math/Implementations/Pi/Ramanujan/Chudnovsky.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Ramanujan/Implementation.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Ramanujan/Series.hs +1/−1
- src-lib/Factory/Math/Implementations/Pi/Spigot/Algorithm.hs +6/−6
- src-lib/Factory/Math/Implementations/Pi/Spigot/Spigot.hs +2/−2
- src-lib/Factory/Math/Implementations/Primality.hs +10/−10
- src-lib/Factory/Math/Implementations/PrimeFactorisation.hs +11/−11
- src-lib/Factory/Math/Implementations/Primes/Algorithm.hs +6/−6
- src-lib/Factory/Math/Implementations/Primes/SieveOfAtkin.hs +2/−2
- src-lib/Factory/Math/Implementations/Primes/SieveOfEratosthenes.hs +2/−2
- src-lib/Factory/Math/Implementations/Primes/TrialDivision.hs +1/−1
- src-lib/Factory/Math/Implementations/SquareRoot.hs +15/−15
- src-lib/Factory/Math/MultiplicativeOrder.hs +1/−1
- src-lib/Factory/Math/PerfectPower.hs +2/−2
- src-lib/Factory/Math/Pi.hs +6/−12
- src-lib/Factory/Math/Power.hs +2/−2
- src-lib/Factory/Math/Precision.hs +3/−3
- src-lib/Factory/Math/Primality.hs +6/−6
- src-lib/Factory/Math/PrimeFactorisation.hs +11/−11
- src-lib/Factory/Math/Primes.hs +3/−3
- src-lib/Factory/Math/Probability.hs +14/−14
- src-lib/Factory/Math/Radix.hs +3/−3
- src-lib/Factory/Math/SquareRoot.hs +3/−3
- src-lib/Factory/Math/Statistics.hs +33/−13
- src-test/Factory/Test/QuickCheck/Pi.hs +3/−12
- src-test/Factory/Test/QuickCheck/Primes.hs +3/−3
- src-test/Factory/Test/QuickCheck/Probability.hs +1/−1
- src-test/Factory/Test/QuickCheck/SquareRoot.hs +2/−2
- src-test/Factory/Test/QuickCheck/Statistics.hs +14/−3
- src-test/Main.hs +18/−23
+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc-lib:src-exe:src-test:dist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
README.markdown view
@@ -1,7 +1,9 @@-# **Factory**.+# **Factory** -This is **Factory**, a library of number-theory functions.+[](https://hackage.haskell.org/package/factory) +This is "**Factory**", a library of number-theory functions.+ ## Installation It can be built and installed using [Cabal](https://www.haskell.org/cabal/users-guide/installing-packages.html).@@ -12,11 +14,19 @@ ## License -For information on copying and distributing this package, see the file **LICENSE** in this directory.+For information on copying and distributing this package, see the file "**LICENSE**" in this directory. ## Bug-reporting -Bug-reports should be emailed to <factory *at* functionalley *dot* eu>.+Bug-reports should be emailed to <factory@functionalley.eu>.++## Testing++The test-suite can be run using:++ cabal configure --enable-tests;+ cabal build;+ cabal test --show-details=always; ## Author
changelog.markdown view
@@ -1,98 +1,151 @@-# 2011-03-01 Dr. Alistair Ward <factory at functionalley dot eu>+# 2011-03-01 Dr. Alistair Ward <factory@functionalley.eu> ## 0.0.0.1- * First version of the package.+* First version of the package.+ ## 0.0.0.2- * Created the modules; **Factory.Test.QuickCheck.Bounds**, **Factory.Math.Implementations.Pi.Borwein** & **Factory.Test.Performance.Statistics** .- * Created a new module **Factory.Data.PrimeFactors**, and migrated definitions from both **Factory.Math.PrimeFactorisation** & **Factory.Math.Implementations.PrimeFactorisation**.- * Created the class `Factory.Math.Factorial.Factorial` and a new module **Factory.Math.Implementations.Factorial**.- Moved existing implementation (`Bisection`) into the new module, with a new implementation (`PrimeFactorisation`).- * Added the function `Factory.Math.Summation.sumR`.- * Added a parameter to the functions `Factory.Math.DivideAndConquer.divideAndConquer` and `Factory.Data.Bounds.divideAndConquer`, to permit asymmetric bisection.- * Added methods to class `Factory.Math.Pi.Algorithm` to permit the retrieval of *Pi* as a `Rational` or a `String`.- * Renamed the function `Factory.Math.Precision.capPrecision` to `Factory.Math.Precision.simplify`.- * Removed the module **Factory.Test.Performance.Exponential**.- * Removed the function `Factory.Math.Power.raise`, which was no more efficient than ghc's implementation of `(^)`.- * Uploaded to [Hackage](http://hackage.haskell.org/packages/hackage.html).+* Created the modules; "**Factory.Test.QuickCheck.Bounds**", "**Factory.Math.Implementations.Pi.Borwein**" & "**Factory.Test.Performance.Statistics**".+* Created a new module "**Factory.Data.PrimeFactors**", and migrated definitions from modules "**Factory.Math.PrimeFactorisation**" & "**Factory.Math.Implementations.PrimeFactorisation**".+* Created the class `Factory.Math.Factorial.Factorial` and a new module "**Factory.Math.Implementations.Factorial**".+* Moved existing implementation (`Bisection`) into the new module, with a new implementation (`PrimeFactorisation`).+* Added the function `Factory.Math.Summation.sumR`.+* Added a parameter to the functions `Factory.Math.DivideAndConquer.divideAndConquer` and `Factory.Data.Bounds.divideAndConquer`, to permit asymmetric bisection.+* Added methods to class `Factory.Math.Pi.Algorithm` to permit the retrieval of *Pi* as a `Rational` or a `String`.+* Renamed the function `Factory.Math.Precision.capPrecision` to `Factory.Math.Precision.simplify`.+* Removed the module "**Factory.Test.Performance.Exponential**".+* Removed the function `Factory.Math.Power.raise`, which was no more efficient than ghc's implementation of `(^)`.+* Uploaded to [Hackage](http://hackage.haskell.org/package/factory).+ ## 0.1.0.0- * Amended the *.cabal*-file to more correctly specify the dependency on package **toolshed**.- * Added the module **Factory.Math.Probability**.- * Renamed the module **Factory.Data.Bounds** to **Factory.Data.Interval**,- and added the functions; `Factory.Data.Interval.precisely`, `Factory.Data.Interval.shift`, `Factory.Data.Interval.closedUnitInterval`.- * Guarded **eager-blackholing** flag in the *cabal*-file.+* Amended the *.cabal*-file to more correctly specify the dependency on package "**toolshed**".+* Added the module "**Factory.Math.Probability**".+* Renamed the module "**Factory.Data.Bounds**" to "**Factory.Data.Interval**",+and added the functions; `Factory.Data.Interval.precisely`, `Factory.Data.Interval.shift`, `Factory.Data.Interval.closedUnitInterval`.+* Guarded flag "**eager-blackholing**" in the *cabal*-file.+ ## 0.1.0.1- * Renamed classes *Factory.Math.[Primality, Pi, Factorial, SquareRoot, PrimeFactorisation].Algorithm* to *Factory.Math.[Primality, Pi, Factorial, SquareRoot, PrimeFactorisation].Algorithmic*, to distinguish them from the data-types which implement them.- * Added the modules **Factory.Math.Hyperoperation**, **Factory.Test.QuickCheck.Hyperoperation** and **Factory.Test.Performance.Hyperoperation**.- * Added the modules **Factory.Math.Primes**, **Factory.Math.Implementation.Primes**, **Factory.Test.Performance.Primes**, **Factory.Test.QuickCheck.Primes** and **Factory.Data.PrimeWheel**.- * Added the function `Factory.Math.PrimeFactorisation.squareFree`.- * Added rewrite-rules to specialise `Factory.Math.Power.isPerfectPower` for type-parameter=`Int`.- * Recoded **Factory.Math.Radix** to the interface `Data.Array.IArray.IArray`, rather than the data-type `Data.Array.Array`.+* Renamed classes **Factory.Math.[Primality, Pi, Factorial, SquareRoot, PrimeFactorisation].Algorithm** to **Factory.Math.[Primality, Pi, Factorial, SquareRoot, PrimeFactorisation].Algorithmic**, to distinguish them from the data-types which implement them.+* Added the modules;+ + "**Factory.Math.Hyperoperation**",+ + "**Factory.Test.QuickCheck.Hyperoperation**",+ + "**Factory.Test.Performance.Hyperoperation**".+* Added the modules+ + "**Factory.Math.Primes**",+ + "**Factory.Math.Implementation.Primes**",+ + "**Factory.Test.Performance.Primes**",+ + "**Factory.Test.QuickCheck.Primes**"+ + "**Factory.Data.PrimeWheel**".+* Added the function `Factory.Math.PrimeFactorisation.squareFree`.+* Added rewrite-rules to specialise `Factory.Math.Power.isPerfectPower` for type-parameter=`Int`.+* Recoded module "**Factory.Math.Radix**" to the interface `Data.Array.IArray.IArray`, rather than the data-type `Data.Array.Array`.+ ## 0.1.0.2- * Added `Factory.Math.Primes.primorial`.- * Altered `Factory.Math.Implementations.Primes.trialDivision` to take an integer defining the size of a `Factory.Data.PrimeWheel`, from which candidates are extracted.- * Removed the command-line option `primesPerformanceGraph`, which appears to memoise data from previous tests.- * Uploaded to [Hackage](http://hackage.haskell.org/packages/hackage.html).+* Added `Factory.Math.Primes.primorial`.+* Altered `Factory.Math.Implementations.Primes.trialDivision` to take an integer defining the size of a `Factory.Data.PrimeWheel`, from which candidates are extracted.+* Removed the command-line option `primesPerformanceGraph`, which appears to memoise data from previous tests.+* Uploaded to [Hackage](http://hackage.haskell.org/packages/hackage.html).+ ## 0.1.0.3- * Qualified `Factory.Math.Implementations.Primes.trialDivision` with **NOINLINE**-pragma, to block optimization which conflicts with rewrite-rule for `Factory.Math.Implementations.Primes.sieveOfEratosthenes` !- * Re-coded `Factory.Data.PrimeWheel.coprimes` and `Factory.Math.Implementations.Primes.sieveOfEratosthenes`, to use a map of lists, rather than a map of lists of lists.+* Qualified `Factory.Math.Implementations.Primes.trialDivision` with pragma "**NOINLINE**", to block optimization which conflicts with rewrite-rule for `Factory.Math.Implementations.Primes.sieveOfEratosthenes` !+* Re-coded `Factory.Data.PrimeWheel.coprimes` and `Factory.Math.Implementations.Primes.sieveOfEratosthenes`, to use a map of lists, rather than a map of lists of lists.+ ## 0.2.0.0- * Separately coded the special-case of a **Factory.Data.PrimeWheel** of size zero, in `Factory.Math.Implementations.Primes.trialDivision`, to achieve better space-complexity.- * Added `Factory.Data.PrimeWheel.estimateOptimalSize`.- * Split **Factory.Math.Implementations.Primes** into; **Factory.Math.Implementations.Primes.SieveOfEratosthenes**, **Factory.Math.Implementations.Primes.TurnersSieve**, **Factory.Math.Implementations.Primes.TrialDivision**, and added a new module **Factory.Math.Implementations.Primes.SieveOfAtkin**. This makes the rewrite-rules less fragile.- * Coded `Factory.Math.Radix.digitalRoot` more concisely.- * Split **Factory.Math.Power** into an additional module **Factory.Math.PerfectPower**.- * Replaced `(+ 1)` and `(- 1)` with the faster calls `succ` and `pred`.- * Used `Paths_factory.version` in **Main**, rather than hard-coding it.+* Separately coded the special-case of a **Factory.Data.PrimeWheel** of size zero, in `Factory.Math.Implementations.Primes.trialDivision`, to achieve better space-complexity.+* Added `Factory.Data.PrimeWheel.estimateOptimalSize`.+* Split module "**Factory.Math.Implementations.Primes**" into;+ + "**Factory.Math.Implementations.Primes.SieveOfEratosthenes**",+ + "**Factory.Math.Implementations.Primes.TurnersSieve**",+ + "**Factory.Math.Implementations.Primes.TrialDivision**",+ + and added a new module "**Factory.Math.Implementations.Primes.SieveOfAtkin**". This makes the rewrite-rules less fragile.+* Coded `Factory.Math.Radix.digitalRoot` more concisely.+* Split module "**Factory.Math.Power**" into an additional module "**Factory.Math.PerfectPower**".+* Replaced `(+ 1)` and `(- 1)` with the faster calls `succ` and `pred`.+* Used `Paths_factory.version` in **Main**, rather than hard-coding it.+ ## 0.2.0.1- * Changed by Lennart Augustsson, to replace `System` with `System.Environment` and `System.Exit`, and to remove dependency on **haskell98**.+* Changed by Lennart Augustsson, to replace `System` with `System.Environment` and `System.Exit`, and to remove dependency on **haskell98**.+ ## 0.2.0.2- * Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in **toolshed-0.13.0.0**.- * Made `Factory.Data.Interval.getLength` private.- * Added `Factory.Data.Interval.mkBounded`.- * Generalised **Factory.Math.Statistics** to accept any `Data.Foldable.Foldable` *Functor*, rather than merely lists.+* Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in package "**toolshed-0.13.0.0**".+* Made `Factory.Data.Interval.getLength` private.+* Added `Factory.Data.Interval.mkBounded`.+* Generalised **Factory.Math.Statistics** to accept any `Data.Foldable.Foldable` *Functor*, rather than merely lists.+ ## 0.2.0.3- * Added class `Show` to some contexts in **Factory.Math.Radix**, for migration to **ghc-7.4**.+* Added class `Show` to some contexts in **Factory.Math.Radix**, for migration to **ghc-7.4**.+ ## 0.2.0.4- * Added classes `Eq` and `Show` to many contexts, for migration to **ghc-7.4**.- * Minor re-formatting.+* Added classes `Eq` and `Show` to many contexts, for migration to **ghc-7.4**.+* Minor re-formatting.+ ## 0.2.0.5- * Minor clarification of `Factory.Math.Implementations.Primality.witnessesCompositeness`.- * Added details to any failure to parse the command-line arguments.- * Defined package's name using program's name, in **Main.hs**.- * Added `Factory.Math.Primes.mersenneNumbers`.- * Replaced use of `mod` on positive integers, with the faster `rem`, in `Factory.Math.Implementations.Pi.Spigot.Spigot.processColumns`, `Factory.Math.Implementations.Primality.witnessesCompositeness`, `Factory.Math.Implementations.Primes.TrialDivision.isIndivisibleBy`, `Factory.Math.Implementations.Primes.SieveOfAtkin.polynomialTypeLookup`, `Factory.Math.Implementations.Primes.SieveOfAtkin.findPolynomialSolutions`, `Factory.Math.Implementations.Primes.TurnersSieve.turnersSieve`, `Factory.Math.PerfectPower.maybeSquareNumber`.- * Replaced calls to `realToFrac` with `toRational` in; **Factory.Math.Implementations.SquareRoot**, `Factory.Math.Statistics.getDispersionFromMean`, `Factory.Math.SquareRoot.getDiscrepancy`, `Factory.Math.SquareRoot.getAccuracy`, to more clearly represent the required operation.+* Minor clarification of `Factory.Math.Implementations.Primality.witnessesCompositeness`.+* Added details to any failure to parse the command-line arguments.+* Defined package's name using program's name, in module "**Main.hs**".+* Added `Factory.Math.Primes.mersenneNumbers`.+* Replaced use of `mod` on positive integers, with the faster `rem`, in;+ + `Factory.Math.Implementations.Pi.Spigot.Spigot.processColumns`,+ + `Factory.Math.Implementations.Primality.witnessesCompositeness`,+ + `Factory.Math.Implementations.Primes.TrialDivision.isIndivisibleBy`,+ + `Factory.Math.Implementations.Primes.SieveOfAtkin.polynomialTypeLookup`,+ + `Factory.Math.Implementations.Primes.SieveOfAtkin.findPolynomialSolutions`,+ + `Factory.Math.Implementations.Primes.TurnersSieve.turnersSieve`,+ + `Factory.Math.PerfectPower.maybeSquareNumber`.+* Replaced calls to `realToFrac` with `toRational` in;+ + **Factory.Math.Implementations.SquareRoot**,+ + `Factory.Math.Statistics.getDispersionFromMean`,+ + `Factory.Math.SquareRoot.getDiscrepancy`,+ + `Factory.Math.SquareRoot.getAccuracy`, to more clearly represent the required operation.+ ## 0.2.1.0- * Refactored **Factory.Test.QuickCheck.QuickChecks**.- * Remove redundant import of `Data.Ratio` from many modules.- * Refactored `Factory.Math.Radix.encodes` to make use of `Data.List.genericLength`, & removed empty `where`.- * Explicitly closed standard-input in the executable.- * Replaced calls to `error` from inside the IO-monad, with `Control.Monad.fail`.- * Added function `Factory.Math.Precision.roundTo`.- * Trapped command-line arguments to which garbage has been appended.- * Corrected the output of `Main.main.optDescrList.printVersion`.- * Removed the integral population-size parameter from `Factory.Math.Probability.generateContinuousPopulation` & `Factory.Math.Probability.generateDiscretePopulation`, making the result conceptually infinite.- * Created class `Factory.Math.Probability.Distribution`, to which data-types `Factory.Math.Probability.ContinuousDistribution` & `Factory.Math.Probability.DiscreteDistribution` conform.- * Added data-constructors `Factory.Math.Probability.ExponentialDistribution`, `Factory.Math.Probability.ShiftedGeometricDistribution` & `Factory.Math.Probability.LogNormal`.- * Added command-line option **--plotDiscreteDistribution** to **Main**.- * Removed Preprocessor-check on the version of package **toolshed**, in **Factory/Math/Summation** & **Factory/Data/PrimeFactors**.+* Refactored **Factory.Test.QuickCheck.QuickChecks**.+* Remove redundant import of `Data.Ratio` from many modules.+* Refactored `Factory.Math.Radix.encodes` to make use of `Data.List.genericLength`, & removed empty keyword `where`.+* Explicitly closed standard-input in the executable.+* Replaced calls to `error` from inside the IO-monad, with `Control.Monad.fail`.+* Added function `Factory.Math.Precision.roundTo`.+* Trapped command-line arguments to which garbage has been appended.+* Corrected the output of `Main.main.optDescrList.printVersion`.+* Removed the integral population-size parameter from `Factory.Math.Probability.generateContinuousPopulation` & `Factory.Math.Probability.generateDiscretePopulation`, making the result conceptually infinite.+* Created class `Factory.Math.Probability.Distribution`, to which data-types `Factory.Math.Probability.ContinuousDistribution` & `Factory.Math.Probability.DiscreteDistribution` conform.+* Added data-constructors `Factory.Math.Probability.ExponentialDistribution`, `Factory.Math.Probability.ShiftedGeometricDistribution` & `Factory.Math.Probability.LogNormal`.+* Added command-line option "**--plotDiscreteDistribution**" to **Main**.+* Removed Preprocessor-check on the version of package "**toolshed**", in modules "**Factory/Math/Summation**" & "**Factory/Data/PrimeFactors**".+ ## 0.2.1.1- * Added `Factory.Test.QuickCheck.Probability.prop_logNormalDistributionEqual`.- * Removed /INLINE/ pragma from `Factory.Math.Implementations.Primes.TrialDivision.isIndivisibleBy`, since to be effective it must be called with fully applied parameters (which it isn't).- * Un eta-reduced `Factory.Math.Power.square`, since we want it to be inlined when called with one argument.- * Tested with **haskell-platform-2013.2.0.0**.- * Replaced preprocessor-directives with **build-depends** constraints in the *.cabal*-file.- * Added function `Factory.Math.Statistics.getWeightedMean` & corresponding tests in module **Factory.Test.QuickCheck.Statistics**.- * Since `(<$>)` is exported from the Prelude from **base-4.8**, imported **Prelude** hiding `(<*>)` into module **Factory.Data.Monomial**, since this symbol is defined locally for other purposes.- * Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between **Control.Applicative** & **Prelude** which (from **base-4.8**) also exports this symbol, or hid the symbol when importing the **Prelude**..+* Added `Factory.Test.QuickCheck.Probability.prop_logNormalDistributionEqual`.+* Removed pragma **INLINE** from `Factory.Math.Implementations.Primes.TrialDivision.isIndivisibleBy`, since to be effective it must be called with fully applied parameters (which it isn't).+* Un eta-reduced `Factory.Math.Power.square`, since we want it to be inlined when called with one argument.+* Tested with **haskell-platform-2013.2.0.0**.+* Replaced preprocessor-directives with **build-depends** constraints in the *.cabal*-file.+* Added function `Factory.Math.Statistics.getWeightedMean` & corresponding tests in module "**Factory.Test.QuickCheck.Statistics**".+* Since `(<$>)` is exported from the Prelude from **base-4.8**, imported **Prelude** hiding `(<*>)` into module "**Factory.Data.Monomial**", since this symbol is defined locally for other purposes.+* Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between **Control.Applicative** & **Prelude** which (from **base-4.8**) also exports this symbol, or hid the symbol when importing the **Prelude**.+ ## 0.2.1.2- * Hid `(<$>)` when importing the **Prelude** into module **src/Factory/Test/QuickCheck/Pi**.- * Added the compiler to the output returned for the command-line option **version**.- * Changed flag **threaded** in the *.cabal*-file to **manual**.- * Added **Default-language**-specification to the *.cabal*-file.- * Added file **README.markdown**.- * Converted this file to markdown-format.- * Replaced `System.Exit.exitWith (System.Exit.ExitFailure 1)` with `System.Exit.exitFailure` & `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.- * Moved the entry-point to the test-suite from **Main.hs** to **Test.hs**, both to integrate with **cabal** & to minimise the dependencies of the executable.- * Partitioned the source-files into **src-lib**, **src-exe**, & **src-test** directories, & referenced them individually from the *.cabal*-file to avoid repeated compilation.- * Used **CPP** to control the import of symbols from **Control.Applicative**.+* Hid `(<$>)` when importing the **Prelude** into module "**src/Factory/Test/QuickCheck/Pi**".+* Added the compiler to the output returned for the command-line option "**version**".+* Changed flag "**threaded**" in the *.cabal*-file to "**manual**".+* Added **Default-language**-specification to the *.cabal*-file.+* Added file "**README.markdown**".+* Converted this file to markdown-format.+* Replaced `System.Exit.exitWith (System.Exit.ExitFailure 1)` with `System.Exit.exitFailure` & `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.+* Moved the entry-point to the test-suite from module "**Main.hs**" to "**Test.hs**", both to integrate with **cabal** & to minimise the dependencies of the executable.+* Partitioned the source-files into directories "**src-lib**", "**src-exe**", & "**src-test**", & referenced them individually from the *.cabal*-file to avoid repeated compilation.+* Used **CPP** to control the import of symbols from **Control.Applicative**.++## 0.2.2.0+* Corrected the markdown-syntax in this file.+* Reverted to calling "**error**" rather than "**Control.Monad.fail**", since the **String**-argument for the latter is discarded in **Monad**-implementations other than **IO**.+* Uploaded to [GitHub](https://github.com/functionalley/Factory.git).+* Simplified file **src-test/Main.hs**.+* Added file **.travis.yml** to control testing by <https://docs.travis-ci.com>.+* Added file **.ghci**.+* Replaced use of module **ToolShed.Defaultable** with **Data.Default**.+* Re-code **Factory.Test.QuickCheck.Statistics** to **Data.Array.IArray** rather than **Data.Array**.+* Added functions **Factory.Math.Statistics.getRootMeanSquare** **Factory.Test.QuickCheck.Statistics.prop_rootMeanSquare**.+* Added function **Factory.Test.QuickCheck.Statistics.prop_standardDeviationRMS**.+* Added **Eq** type-constraint to function **Factory.Math.Statistics.getWeightedMean**.+* Tested with **ghc-8.0.1**.+## 0.2.2.1+* Commented-out flakey square-root test.
copyright view
@@ -1,5 +1,5 @@ Author:- Dr. Alistair Ward <factory at functionalley dot eu>.+ Dr. Alistair Ward <factory@functionalley.eu>. Copyright: Copyright (C) 2011-2013 Dr. Alistair Ward. All Rights Reserved.
factory.cabal view
@@ -14,7 +14,7 @@ -- along with Factory. If not, see <http://www.gnu.org/licenses/>. Name: factory-Version: 0.2.1.2+Version: 0.2.2.1 Cabal-version: >= 1.10 Copyright: (C) 2011-2015 Dr. Alistair Ward License: GPL@@ -25,17 +25,22 @@ Build-type: Simple Description: A library of number-theory functions, for; factorials, square-roots, Pi and primes. Category: Math, Number Theory-Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10+Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10.1, GHC == 8.0.1 Homepage: http://functionalley.eu/Factory/factory.html-Maintainer: mailto <colon> factory <at> functionalley <dot> eu-Bug-reports: mailto <colon> factory <at> functionalley <dot> eu+Maintainer: mailto:factory@functionalley.eu+Bug-reports: mailto:factory@functionalley.eu -- None of these files are needed at run-time. Extra-source-files:+ .ghci changelog.markdown copyright README.markdown +source-repository head+ type: git+ location: https://github.com/functionalley/Factory+ -- Enable using: 'cabal configure -f llvm'. flag llvm Description: Whether the 'llvm' compiler-backend has been installed and is required for code-generation.@@ -49,7 +54,7 @@ Library Default-language: Haskell2010- GHC-options: -Wall -O2 -fno-warn-tabs+ GHC-options: -O2 -Wall -fno-warn-tabs Hs-source-dirs: src-lib Exposed-modules:@@ -114,28 +119,33 @@ Build-depends: array, base >= 4.3 && < 5,+ data-default, deepseq >= 1.1, containers, parallel >= 3.0, primes >= 0.1, random,- toolshed >= 0.16+ toolshed >= 0.17 if impl(ghc >= 7.4.1)- GHC-prof-options: -prof -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs else- GHC-prof-options: -prof -auto-all -caf-all+ GHC-prof-options: -auto-all -caf-all if impl(ghc >= 7.0) && flag(llvm) GHC-options: -fllvm Executable factory Default-language: Haskell2010- GHC-options: -Wall -O2 -fno-warn-tabs+ GHC-options: -O2 -Wall -fno-warn-tabs Hs-source-dirs: src-exe Main-is: Main.hs- GHC-prof-options: -prof -auto-all -caf-all + if impl(ghc >= 7.4.1)+ GHC-prof-options: -fprof-auto -fprof-cafs+ else+ GHC-prof-options: -auto-all -caf-all+ -- Unexposed modules must be referenced for 'cabal sdist'. Other-modules: Factory.Test.CommandOptions@@ -153,10 +163,11 @@ base >= 4.3 && < 5, Cabal >= 1.10, containers,+ data-default, deepseq >= 1.1, factory, random,- toolshed >= 0.16+ toolshed >= 0.17 if flag(threaded) GHC-options: -threaded@@ -167,7 +178,7 @@ if flag(llvm) GHC-options: -fllvm -Test-Suite quickCheck+Test-Suite test Default-language: Haskell2010 GHC-options: -Wall -fno-warn-tabs Hs-source-dirs: src-test@@ -198,9 +209,10 @@ array, base >= 4.3 && < 5, containers,+ data-default, deepseq >= 1.1, factory, primes >= 0.1, QuickCheck >= 2.2, random,- toolshed >= 0.16+ toolshed >= 0.17
src-exe/Factory/Test/CommandOptions.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -29,20 +29,19 @@ setVerbose ) where -import qualified ToolShed.Defaultable+import qualified Data.Default -- | Declare a record used to contain command-line options. data CommandOptions = MkCommandOptions { verbose :: Bool -- ^ Whether additional informative output should be generated, where applicable. } -instance ToolShed.Defaultable.Defaultable CommandOptions where- defaultValue = MkCommandOptions { verbose = False }+instance Data.Default.Default CommandOptions where+ def = MkCommandOptions { verbose = False } -- | Mutator. setVerbose :: CommandOptions -> CommandOptions setVerbose commandOptions = commandOptions { verbose = True }-
src-exe/Factory/Test/Performance/Pi.hs view
@@ -63,9 +63,7 @@ -} piPerformanceGraph :: ( Math.SquareRoot.Algorithmic squareRootAlgorithm,- Show squareRootAlgorithm,- Math.Factorial.Algorithmic factorialAlgorithm,- Show factorialAlgorithm+ Math.Factorial.Algorithmic factorialAlgorithm ) => RealFrac i => Category squareRootAlgorithm factorialAlgorithm -- ^ The algorithm. -> i -- ^ The factor by which the precision is increased on each iteration.
src-exe/Factory/Test/Performance/Primality.hs view
@@ -35,7 +35,7 @@ -- | Measures the CPU-time required to find the specified number of /Carmichael/-numbers, which is returned together with the requested list. carmichaelNumbersPerformance :: Math.Primality.Algorithmic primalityAlgorithm => primalityAlgorithm -> Int -> IO (Double, [Integer]) carmichaelNumbersPerformance primalityAlgorithm i- | i < 0 = fail $ "Factory.Test.Performance.Primality.carmichaelNumbersPerformance:\tnegative number; " ++ show i+ | i < 0 = error . showString "Factory.Test.Performance.Primality.carmichaelNumbersPerformance:\tnegative number; " $ shows i "." | otherwise = ToolShed.System.TimePure.getCPUSeconds . take i $ Math.Primality.carmichaelNumbers primalityAlgorithm -- | Measures the CPU-time required to determine whether the specified integer is prime, which is returned together with the Boolean result.
src-exe/Factory/Test/Performance/PrimeFactorisation.hs view
@@ -43,7 +43,7 @@ -} primeFactorsPerformanceGraph :: Math.PrimeFactorisation.Algorithmic algorithm => algorithm -> Int -> IO () primeFactorsPerformanceGraph algorithm tests- | tests < 0 = fail $ "Factory.Test.Performance.PrimeFactorisation.primeFactorsPerformanceGraph:\tnegative number; " ++ show tests+ | tests < 0 = error . showString "Factory.Test.Performance.PrimeFactorisation.primeFactorsPerformanceGraph:\tnegative number; " $ shows tests "." | otherwise = mapM_ ( \operand -> primeFactorsPerformance algorithm operand >>= putStrLn . shows operand . showChar '\t' . (`shows` "") ) . take tests . dropWhile (< 2) $ Math.Fibonacci.fibonacci
src-exe/Factory/Test/Performance/Primes.hs view
@@ -43,5 +43,6 @@ -- | Measures the CPU-time required to find the specified number of /Mersenne/-numbers, which is returned together with the requested list. mersenneNumbersPerformance :: Math.Primes.Algorithmic algorithm => algorithm -> Int -> IO (Double, [Integer]) mersenneNumbersPerformance primalityAlgorithm i- | i < 0 = fail $ "Factory.Test.Performance.Primes.mersenneNumbersPerformance:\tnegative number; " ++ show i+ | i < 0 = error . showString "Factory.Test.Performance.Primes.mersenneNumbersPerformance:\tnegative number; " $ shows i "." | otherwise = ToolShed.System.TimePure.getCPUSeconds . take i $ Math.Primes.mersenneNumbers primalityAlgorithm+
src-exe/Main.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011-2013 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -26,6 +26,7 @@ module Main(main) where +import qualified Data.Default import qualified Data.Map import qualified Data.List import qualified Data.Version@@ -56,7 +57,6 @@ import qualified System.IO import qualified System.IO.Error import qualified System.Random-import qualified ToolShed.Defaultable -- Local convenience definitions. type PrimalityAlgorithm = Math.Implementations.Primality.Algorithm Math.Implementations.PrimeFactorisation.Algorithm@@ -90,7 +90,7 @@ optDescrList = [ -- String [String] (G.ArgDescr CommandLineAction) String G.Option "?" ["help"] (G.NoArg $ const printUsage) "Display this help-text & then exit.",- G.Option "" ["verbose"] (G.NoArg $ return {-to IO-monad-} . Test.CommandOptions.setVerbose) ("Provide additional information where available; default '" ++ show (Test.CommandOptions.verbose ToolShed.Defaultable.defaultValue) ++ "'."),+ G.Option "" ["verbose"] (G.NoArg $ return {-to IO-monad-} . Test.CommandOptions.setVerbose) ("Provide additional information where available; default '" ++ show (Test.CommandOptions.verbose Data.Default.def) ++ "'."), G.Option "" ["version"] (G.NoArg $ const printVersion) "Print version-information & then exit.", G.Option "" ["carmichaelNumbersPerformance"] (carmichaelNumbersPerformance `G.ReqArg` "(Math.Implementations.Primality.Algorithm, Int)") "Test the performance of 'Math.Primality.carmichaelNumbers'.", G.Option "" ["factorialPerformance"] (factorialPerformance `G.ReqArg` "(Math.Implementations.Factorial.Algorithm, Integer)") "Test the performance of 'Math.Factorial.factorial'.",@@ -125,7 +125,7 @@ author, compiler :: String author = "Dr. Alistair Ward"- compiler = System.Info.compilerName ++ "-" ++ Data.List.intercalate "." (map show $ Data.Version.versionBranch System.Info.compilerVersion)+ compiler = showString System.Info.compilerName . showChar '-' . Data.List.intercalate "." . map show $ Data.Version.versionBranch System.Info.compilerVersion printUsage = System.IO.hPutStrLn System.IO.stderr usageMessage >> System.Exit.exitSuccess @@ -236,6 +236,6 @@ -- G.getOpt :: G.ArgOrder CommandLineAction -> [G.OptDescr Action] -> [String] -> ([Action], [String], [String]) case G.getOpt G.RequireOrder optDescrList args of- (commandLineActions, _, []) -> Data.List.foldl' (>>=) (return {-to IO-monad-} ToolShed.Defaultable.defaultValue) commandLineActions >> System.Exit.exitSuccess+ (commandLineActions, _, []) -> Data.List.foldl' (>>=) (return {-to IO-monad-} Data.Default.def) commandLineActions >> System.Exit.exitSuccess (_, _, errors) -> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usageMessage -- Throw.
src-lib/Factory/Data/Exponential.hs view
@@ -21,7 +21,7 @@ * Describes a simple numeric type, designed to contain an /exponential/ number. - * <http://en.wikipedia.org/wiki/Exponentiation>.+ * <https://en.wikipedia.org/wiki/Exponentiation>. -} module Factory.Data.Exponential(@@ -34,7 +34,7 @@ -- ** Accessors getBase, getExponent,--- ** Constructors+-- ** Constructor rightIdentity, -- ** Operators (<^),@@ -62,7 +62,7 @@ {- | * Construct an 'Exponential' merely raised to the 1st power. - * The value of the resulting exponential is the same as specified 'base'; <http://en.wikipedia.org/wiki/Identity_element>.+ * The value of the resulting exponential is the same as specified 'base'; <https://en.wikipedia.org/wiki/Identity_element>. -} rightIdentity :: Num exponent => base -> Exponential base exponent rightIdentity x = (x, 1)
src-lib/Factory/Data/Interval.hs view
@@ -30,7 +30,7 @@ * The API was driven top-down by its caller's requirements, rather than a bottom-up attempt to provide a complete interface. consequently there may be omissions from the view point of future callers. - * Thought similar to the mathematical concept of an /interval/, the latter technically relates to /real/ numbers; <http://en.wikipedia.org/wiki/Interval_%28mathematics%29>.+ * Thought similar to the mathematical concept of an /interval/, the latter technically relates to /real/ numbers; <https://en.wikipedia.org/wiki/Interval_%28mathematics%29>. * No account has been made for /semi-closed/ or /open/ intervals. -}@@ -54,7 +54,7 @@ -- ** Accessors getMinBound, getMaxBound,--- ** Constructors+-- ** Constructor precisely, -- ** Predicates isReversed@@ -80,7 +80,7 @@ getMaxBound :: Interval endPoint -> endPoint getMaxBound = snd --- | Construct the /unsigned closed unit-interval/; <http://en.wikipedia.org/wiki/Unit_interval>.+-- | Construct the /unsigned closed unit-interval/; <https://en.wikipedia.org/wiki/Unit_interval>. closedUnitInterval :: Num n => Interval n closedUnitInterval = (0, 1) @@ -148,7 +148,7 @@ {- | * Reduces 'Interval' to a single integral value encapsulated in a 'Data.Monoid.Monoid', using a /divide-and-conquer/ strategy,- bisecting the /interval/ and recursively evaluating each part; <http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm>.+ bisecting the /interval/ and recursively evaluating each part; <https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm>. * By choosing a 'ratio' other than @(1 % 2)@, the bisection can be made asymmetrical. The specified ratio represents the length of the left-hand portion over the original list-length;@@ -157,7 +157,7 @@ * This process of recursive bisection, is terminated beneath the specified minimum length, after which the 'Interval' are expanded into the corresponding list, and the /monoid/'s binary operator is directly /folded/ over it. - * One can view this as a <http://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>,+ * One can view this as a <https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>, in which 'Interval' is exploded into a binary tree-structure (each leaf of which contains a list of up to 'minLength' integers, and each node of which contains an associative binary operator), and then collapsed to a scalar, by application of the operators.
src-lib/Factory/Data/MonicPolynomial.hs view
@@ -19,16 +19,16 @@ [@DESCRIPTION@] - * Describes a /monic polynomial; <http://en.wikipedia.org/wiki/Monic_polynomial#Classifications>;+ * Describes a /monic polynomial; <https://en.wikipedia.org/wiki/Monic_polynomial#Classifications>; ie. in which the /coefficient/ of the /leading term/ is one. -} module Factory.Data.MonicPolynomial( -- * Types--- ** Data-types,+-- ** Data-types MonicPolynomial(getPolynomial), -- Hide the data-constructor. -- * Functions--- ** Constructors+-- ** Constructor mkMonicPolynomial ) where
src-lib/Factory/Data/Monomial.hs view
@@ -20,7 +20,7 @@ [@DESCRIPTION@] - * Describes a <http://en.wikipedia.org/wiki/Monomial> and operations on it.+ * Describes a <https://en.wikipedia.org/wiki/Monomial> and operations on it. * A /monomial/ is merely a /polynomial/ with a single non-zero term; cf. /Binomial/. -}
src-lib/Factory/Data/Polynomial.hs view
@@ -20,9 +20,9 @@ [@DESCRIPTION@] - * Describes a <http://en.wikipedia.org/wiki/Univariate> polynomial and operations on it.+ * Describes a <https://en.wikipedia.org/wiki/Univariate> polynomial and operations on it. - * <http://en.wikipedia.org/wiki/Polynomial>.+ * <https://en.wikipedia.org/wiki/Polynomial>. * <http://mathworld.wolfram.com/Polynomial.html>. -}@@ -31,7 +31,7 @@ -- * Types -- ** Type-synonyms -- MonomialList,--- ** Data-types,+-- ** Data-types Polynomial, -- * Constants zero,@@ -86,7 +86,7 @@ {- | * The type of an arbitrary /univariate/ polynomial;- actually it's more general, since it permits negative powers (<http://en.wikipedia.org/wiki/Laurent_polynomial>s).+ actually it's more general, since it permits negative powers (<https://en.wikipedia.org/wiki/Laurent_polynomial>s). It can't describe /multivariate/ polynomials, which would require a list of /exponents/. Rather than requiring the /exponent/ to implement the /type-class/ 'Integral', this is implemented at the function-level, as required. @@ -94,7 +94,7 @@ in which /coefficients/ are inferred to be zero, thus enabling efficient representation of sparse polynomials. * CAVEAT: the 'MonomialList' is required to;- be ordered by /descending/ exponent (ie. reverse <http://en.wikipedia.org/wiki/Monomial_order>);+ be ordered by /descending/ exponent (ie. reverse <https://en.wikipedia.org/wiki/Monomial_order>); have had zero coefficients removed; and to have had /like/ terms merged; so the raw data-constructor isn't exported.@@ -103,7 +103,7 @@ getMonomialList :: MonomialList coefficient exponent -- ^ Accessor. } deriving (Eq, Show) --- | Makes /Polynomial/ a 'Data.Ring.Ring', over the /field/ composed from all possible /coefficients/; <http://en.wikipedia.org/wiki/Polynomial_ring>.+-- | Makes /Polynomial/ a 'Data.Ring.Ring', over the /field/ composed from all possible /coefficients/; <https://en.wikipedia.org/wiki/Polynomial_ring>. instance ( Eq c, Num c,@@ -166,7 +166,7 @@ ) => Data.QuotientRing.QuotientRing (Polynomial c e) where {- Uses /Euclidian division/.- <http://en.wikipedia.org/wiki/Polynomial_long_division>.+ <https://en.wikipedia.org/wiki/Polynomial_long_division>. <http://demonstrations.wolfram.com/PolynomialLongDivision/>. -} _ `quotRem'` MkPolynomial [] = error "Factory.Data.Polynomial.quotRem':\tzero denominator."@@ -262,7 +262,7 @@ {- | * 'True' if the /leading coefficient/ is one. - * <http://en.wikipedia.org/wiki/Monic_polynomial#Classifications>.+ * <https://en.wikipedia.org/wiki/Monic_polynomial#Classifications>. -} isMonic :: (Eq c, Num c) => Polynomial c e -> Bool isMonic (MkPolynomial []) = False -- All coefficients are zero, and have therefore been removed.@@ -301,7 +301,7 @@ {- | * Return the /degree/ (AKA /order/) of the /polynomial/. - * <http://en.wikipedia.org/wiki/Degree_of_a_polynomial>.+ * <https://en.wikipedia.org/wiki/Degree_of_a_polynomial>. * <http://mathworld.wolfram.com/PolynomialDegree.html>. -}@@ -312,7 +312,7 @@ {- | * Scale-up the specified /polynomial/ by a constant /monomial/ factor. - * <http://en.wikipedia.org/wiki/Scalar_multiplication>.+ * <https://en.wikipedia.org/wiki/Scalar_multiplication>. -} (*=) :: (Eq c, Num c, Num e) => Polynomial c e -> Data.Monomial.Monomial c e -> Polynomial c e polynomial *= monomial
src-lib/Factory/Data/PrimeWheel.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines a /prime-wheel/, for use in prime-number generation; <http://en.wikipedia.org/wiki/Wheel_factorization>.+ [@DESCRIPTION@] Defines a /prime-wheel/, for use in prime-number generation; <https://en.wikipedia.org/wiki/Wheel_factorization>. -} module Factory.Data.PrimeWheel(@@ -35,7 +35,7 @@ generateMultiples, roll, rotate,--- ** Constructors+-- ** Constructor mkPrimeWheel, -- ** Query getCircumference,@@ -88,7 +88,7 @@ type NPrimes = Int {- |- * Uses a /Sieve of Eratosthenes/ (<http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>), to generate an initial sequence of primes.+ * Uses a /Sieve of Eratosthenes/ (<https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>), to generate an initial sequence of primes. * Also generates an infinite sequence of candidate primes, each of which is /coprime/ to the primes just found, e.g.: @filter ((== 1) . (gcd (2 * 3 * 5 * 7))) [11 ..] = [11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,121 ..]@; NB /121/ isn't prime.
src-lib/Factory/Data/QuotientRing.hs view
@@ -19,7 +19,7 @@ [@DESCRIPTION@] - * Describes a /Quotient Ring/; <http://en.wikipedia.org/wiki/Quotient_ring>.+ * Describes a /Quotient Ring/; <https://en.wikipedia.org/wiki/Quotient_ring>. * This is a /ring/ composed from a residue-class resulting from /modular/ division. -}
src-lib/Factory/Data/Ring.hs view
@@ -21,7 +21,7 @@ * Describes a /ring/ and operations on its members. - * <http://en.wikipedia.org/wiki/Ring_%28mathematics%29>.+ * <https://en.wikipedia.org/wiki/Ring_%28mathematics%29>. * <http://www.numericana.com/answer/rings.htm>. -}@@ -30,7 +30,7 @@ -- * Type-classes Ring(..), -- * Types--- ** Data.types+-- ** Data-types -- Product, -- Sum, -- * Functions@@ -54,11 +54,11 @@ * Minimal definition; '=+=', '=*=', 'additiveInverse', 'multiplicativeIdentity', 'additiveIdentity'. -} class Ring r where- (=+=) :: r -> r -> r -- ^ Addition of two members; required to be /commutative/; <http://en.wikipedia.org/wiki/Commutativity>.+ (=+=) :: r -> r -> r -- ^ Addition of two members; required to be /commutative/; <https://en.wikipedia.org/wiki/Commutativity>. (=*=) :: r -> r -> r -- ^ Multiplication of two members.- additiveInverse :: r -> r -- ^ The operand required to yield /zero/ under addition; <http://en.wikipedia.org/wiki/Additive_inverse>.+ additiveInverse :: r -> r -- ^ The operand required to yield /zero/ under addition; <https://en.wikipedia.org/wiki/Additive_inverse>. multiplicativeIdentity :: r -- ^ The /identity/-member under multiplication; <http://mathworld.wolfram.com/MultiplicativeIdentity.html>.- additiveIdentity :: r -- ^ The /identity/-member under addition (AKA /zero/); <http://en.wikipedia.org/wiki/Additive_identity>.+ additiveIdentity :: r -- ^ The /identity/-member under addition (AKA /zero/); <https://en.wikipedia.org/wiki/Additive_identity>. (=-=) :: r -> r -> r -- ^ Subtract the two specified /ring/-members. l =-= r = l =+= additiveInverse r -- Default implementation.@@ -70,7 +70,7 @@ * Raise a /ring/-member to the specified positive integral power. * Exponentiation is implemented as a sequence of either squares of, or multiplications by, the /ring/-member;- <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>.+ <https://en.wikipedia.org/wiki/Exponentiation_by_squaring>. -} (=^) :: ( Eq r,
src-lib/Factory/Math/ArithmeticGeometricMean.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Determines the /Arithmetic-geometric mean/; <http://en.wikipedia.org/wiki/Arithmetic-geometric_mean>.+ [@DESCRIPTION@] Determines the /Arithmetic-geometric mean/; <https://en.wikipedia.org/wiki/Arithmetic-geometric_mean>. -} module Factory.Math.ArithmeticGeometricMean(@@ -41,10 +41,10 @@ import qualified Factory.Math.Precision as Math.Precision import qualified Factory.Math.SquareRoot as Math.SquareRoot --- | The type of the /arithmetic mean/; <http://en.wikipedia.org/wiki/Arithmetic_mean>.+-- | The type of the /arithmetic mean/; <https://en.wikipedia.org/wiki/Arithmetic_mean>. type ArithmeticMean = Rational --- | The type of the /geometric mean/; <http://en.wikipedia.org/wiki/Geometric_mean>.+-- | The type of the /geometric mean/; <https://en.wikipedia.org/wiki/Geometric_mean>. type GeometricMean = Rational -- | Encapsulates both /arithmetic/ and /geometric/ means.
src-lib/Factory/Math/DivideAndConquer.hs view
@@ -56,7 +56,7 @@ {- | * Reduces a list to a single scalar encapsulated in a 'Data.Monoid.Monoid', using a /divide-and-conquer/ strategy,- bisecting the list and recursively evaluating each part; <http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm>.+ bisecting the list and recursively evaluating each part; <https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm>. * By choosing a 'bisectionRatio' other than @(1 % 2)@, the bisection can be made asymmetrical. The specified ratio represents the length of the left-hand portion, over the original list-length;@@ -65,7 +65,7 @@ * This process of recursive bisection, is terminated beneath the specified minimum list-length, after which the /monoid/'s binary operator is directly /folded/ over the list. - * One can view this as a <http://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>,+ * One can view this as a <https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>, in which the list is exploded into a binary tree-structure (each leaf of which contains a list of up to 'minLength' integers, and each node of which contains an associative binary operator), and then collapsed to a scalar, by application of the operators.
src-lib/Factory/Math/Fibonacci.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] <http://en.wikipedia.org/wiki/Fibonacci_number>.+ [@DESCRIPTION@] <https://en.wikipedia.org/wiki/Fibonacci_number>. -} module Factory.Math.Fibonacci(
src-lib/Factory/Math/Hyperoperation.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Provides various /hyperoperations/; <http://en.wikipedia.org/wiki/Hyperoperation>.+ [@DESCRIPTION@] Provides various /hyperoperations/; <https://en.wikipedia.org/wiki/Hyperoperation>. -} module Factory.Math.Hyperoperation(@@ -64,7 +64,7 @@ * Returns the /power-tower/ of the specified /base/; <http://mathworld.wolfram.com/PowerTower.html>. * A synonym for /tetration/;- <http://en.wikipedia.org/wiki/Tetration>,+ <https://en.wikipedia.org/wiki/Tetration>, <http://www.tetration.org/Fractals/Atlas/index.html>. -} powerTower :: (Integral base, Integral hyperExponent, Show base) => base -> hyperExponent -> base@@ -76,7 +76,7 @@ | base < 0 && hyperExponent > 1 = error $ "Factory.Math.Hyperoperation.powerTower:\tundefined for negative base; " ++ show base | otherwise = Data.List.genericIndex (iterate (base ^) 1) hyperExponent --- | The /hyperoperation/-sequence; <http://en.wikipedia.org/wiki/Hyperoperation>.+-- | The /hyperoperation/-sequence; <https://en.wikipedia.org/wiki/Hyperoperation>. hyperoperation :: (Integral rank, Show rank) => rank -> Base -> HyperExponent -> Base hyperoperation rank base hyperExponent | rank < fromIntegral succession = error $ "Factory.Math.Hyperoperation.hyperoperation:\tundefined for rank; " ++ show rank@@ -100,7 +100,7 @@ where e' = {-fromIntegral $-} r ^# pred e --- | The /Ackermann-Peter/-function; <http://en.wikipedia.org/wiki/Ackermann_function#Ackermann_numbers>.+-- | The /Ackermann-Peter/-function; <https://en.wikipedia.org/wiki/Ackermann_function#Ackermann_numbers>. ackermannPeter :: (Integral rank, Show rank) => rank -> HyperExponent -> Base ackermannPeter rank = (+ negate 3) . hyperoperation rank 2 {-base-} . (+ 3)
src-lib/Factory/Math/Implementations/Factorial.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -24,7 +24,7 @@ * Provides additional functions related to /factorials/, but which depends on a specific implementation, and which therefore can't be accessed throught the class-interface. - * <http://en.wikipedia.org/wiki/Factorial>.+ * <https://en.wikipedia.org/wiki/Factorial>. * <http://mathworld.wolfram.com/Factorial.html>. @@ -44,22 +44,22 @@ (!/!) ) where +import qualified Data.Default import qualified Data.Numbers.Primes import qualified Factory.Data.Interval as Data.Interval import qualified Factory.Data.PrimeFactors as Data.PrimeFactors import qualified Factory.Math.Factorial as Math.Factorial-import qualified ToolShed.Defaultable infixl 7 !/! -- Same as (/). -- | The algorithms by which /factorial/ has been implemented.-data Algorithm =- Bisection -- ^ The integers from which the /factorial/ is composed, are multiplied using @Data.Interval.product'@.+data Algorithm+ = Bisection -- ^ The integers from which the /factorial/ is composed, are multiplied using @Data.Interval.product'@. | PrimeFactorisation -- ^ The /prime factors/ of the /factorial/ are extracted, then raised to the appropriate power, before multiplication. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = Bisection+instance Data.Default.Default Algorithm where+ def = Bisection instance Math.Factorial.Algorithmic Algorithm where factorial algorithm n@@ -74,7 +74,7 @@ * Precisely all the primes less than or equal to the specified integer /n/, are included in /n!/; only the multiplicity of each of these known prime components need be determined. - * <http://en.wikipedia.org/wiki/Factorial#Number_theory>.+ * <https://en.wikipedia.org/wiki/Factorial#Number_theory>. * CAVEAT: currently a hotspot. -}@@ -130,8 +130,8 @@ -> i -- ^ The /denominator/. -> f -- ^ The resulting fraction. numerator !/! denominator- | numerator <= 1 = recip . fromIntegral $ Math.Factorial.factorial (ToolShed.Defaultable.defaultValue :: Algorithm) denominator- | denominator <= 1 = fromIntegral $ Math.Factorial.factorial (ToolShed.Defaultable.defaultValue :: Algorithm) numerator+ | numerator <= 1 = recip . fromIntegral $ Math.Factorial.factorial (Data.Default.def :: Algorithm) denominator+ | denominator <= 1 = fromIntegral $ Math.Factorial.factorial (Data.Default.def :: Algorithm) numerator | numerator == denominator = 1 | numerator < denominator = recip $ denominator !/! numerator -- Recurse. | otherwise = fromIntegral $ Data.Interval.product' (recip 2) 64 (succ denominator, numerator)
src-lib/Factory/Math/Implementations/Pi/AGM/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -26,16 +26,16 @@ Algorithm(..) ) where +import qualified Data.Default import qualified Factory.Math.Implementations.Pi.AGM.BrentSalamin as Math.Implementations.Pi.AGM.BrentSalamin import qualified Factory.Math.Pi as Math.Pi import qualified Factory.Math.SquareRoot as Math.SquareRoot-import qualified ToolShed.Defaultable -- | Defines the available algorithms. data Algorithm squareRootAlgorithm = BrentSalamin squareRootAlgorithm deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable squareRootAlgorithm => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm) where- defaultValue = BrentSalamin ToolShed.Defaultable.defaultValue+instance Data.Default.Default squareRootAlgorithm => Data.Default.Default (Algorithm squareRootAlgorithm) where+ def = BrentSalamin Data.Default.def instance Math.SquareRoot.Algorithmic squareRootAlgorithm => Math.Pi.Algorithmic (Algorithm squareRootAlgorithm) where openR (BrentSalamin squareRootAlgorithm) = Math.Implementations.Pi.AGM.BrentSalamin.openR squareRootAlgorithm
src-lib/Factory/Math/Implementations/Pi/AGM/BrentSalamin.hs view
@@ -20,7 +20,7 @@ [@DESCRIPTION@] * Implements the /Brent-Salamin/ (AKA /Gauss-Legendre/) algorithm;- <http://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm>,+ <https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm>, <http://mathworld.wolfram.com/Brent-SalaminFormula.html>, <http://www.pi314.net/eng/salamin.php>.
src-lib/Factory/Math/Implementations/Pi/BBP/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -26,11 +26,11 @@ Algorithm(..) ) where +import qualified Data.Default import qualified Factory.Math.Implementations.Pi.BBP.Base65536 as Math.Implementations.Pi.BBP.Base65536 import qualified Factory.Math.Implementations.Pi.BBP.Bellard as Math.Implementations.Pi.BBP.Bellard import qualified Factory.Math.Implementations.Pi.BBP.Implementation as Math.Implementations.Pi.BBP.Implementation import qualified Factory.Math.Pi as Math.Pi-import qualified ToolShed.Defaultable -- | Defines those /BBP/-type series which have been implemented. data Algorithm =@@ -38,8 +38,8 @@ | Bellard -- ^ A /nega-base/ @2^10@ version of the formula. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = Base65536+instance Data.Default.Default Algorithm where+ def = Base65536 instance Math.Pi.Algorithmic Algorithm where openR Base65536 = Math.Implementations.Pi.BBP.Implementation.openR Math.Implementations.Pi.BBP.Base65536.series
src-lib/Factory/Math/Implementations/Pi/BBP/Bellard.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines /Bellard/'s nega-base-@2^10@ /BBP/-formula; <http://en.wikipedia.org/wiki/Bellard%27s_formula>+ [@DESCRIPTION@] Defines /Bellard/'s nega-base-@2^10@ /BBP/-formula; <https://en.wikipedia.org/wiki/Bellard%27s_formula> -} module Factory.Math.Implementations.Pi.BBP.Bellard(
src-lib/Factory/Math/Implementations/Pi/Borwein/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -26,12 +26,12 @@ Algorithm(..) ) where +import qualified Data.Default import qualified Factory.Math.Factorial as Math.Factorial import qualified Factory.Math.Implementations.Pi.Borwein.Borwein1993 as Math.Implementations.Pi.Borwein.Borwein1993 import qualified Factory.Math.Implementations.Pi.Borwein.Implementation as Math.Implementations.Pi.Borwein.Implementation import qualified Factory.Math.Pi as Math.Pi import qualified Factory.Math.SquareRoot as Math.SquareRoot-import qualified ToolShed.Defaultable {- | * Define those /Borwein/-series which have been implemented.@@ -39,14 +39,14 @@ * Though currently there's only one, provision has been made for the addition of more. -} data Algorithm squareRootAlgorithm factorialAlgorithm =- Borwein1993 squareRootAlgorithm factorialAlgorithm -- ^ <http://en.wikipedia.org/wiki/Borwein%27s_algorithm>.+ Borwein1993 squareRootAlgorithm factorialAlgorithm -- ^ <https://en.wikipedia.org/wiki/Borwein%27s_algorithm>. deriving (Eq, Read, Show) instance (- ToolShed.Defaultable.Defaultable squareRootAlgorithm,- ToolShed.Defaultable.Defaultable factorialAlgorithm- ) => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm) where- defaultValue = Borwein1993 ToolShed.Defaultable.defaultValue ToolShed.Defaultable.defaultValue+ Data.Default.Default squareRootAlgorithm,+ Data.Default.Default factorialAlgorithm+ ) => Data.Default.Default (Algorithm squareRootAlgorithm factorialAlgorithm) where+ def = Borwein1993 Data.Default.def Data.Default.def instance ( Math.SquareRoot.Algorithmic squareRootAlgorithm,
src-lib/Factory/Math/Implementations/Pi/Borwein/Borwein1993.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines the /Borwein/ series for /Pi/; <http://en.wikipedia.org/wiki/Borwein%27s_algorithm#Jonathan_Borwein_and_Peter_Borwein.27s_Version_.281993.29>+ [@DESCRIPTION@] Defines the /Borwein/ series for /Pi/; <https://en.wikipedia.org/wiki/Borwein%27s_algorithm#Jonathan_Borwein_and_Peter_Borwein.27s_Version_.281993.29> -} module Factory.Math.Implementations.Pi.Borwein.Borwein1993(
src-lib/Factory/Math/Implementations/Pi/Borwein/Implementation.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines /Borwein/ series for /Pi/; <http://en.wikipedia.org/wiki/Borwein%27s_algorithm>+ [@DESCRIPTION@] Defines /Borwein/ series for /Pi/; <https://en.wikipedia.org/wiki/Borwein%27s_algorithm> -} module Factory.Math.Implementations.Pi.Borwein.Implementation(
src-lib/Factory/Math/Implementations/Pi/Borwein/Series.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines a <http://en.wikipedia.org/wiki/Srinivasa_Borwein>-type series for /Pi/.+ [@DESCRIPTION@] Defines a <https://en.wikipedia.org/wiki/Srinivasa_Borwein>-type series for /Pi/. -} module Factory.Math.Implementations.Pi.Borwein.Series(
src-lib/Factory/Math/Implementations/Pi/Ramanujan/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines the set of /Ramanujan/-type algorithms which have been implemented; <http://en.wikipedia.org/wiki/Pi>.+ [@DESCRIPTION@] Defines the set of /Ramanujan/-type algorithms which have been implemented; <https://en.wikipedia.org/wiki/Pi>. -} module Factory.Math.Implementations.Pi.Ramanujan.Algorithm(@@ -26,25 +26,25 @@ Algorithm(..) ) where +import qualified Data.Default import qualified Factory.Math.Factorial as Math.Factorial import qualified Factory.Math.Implementations.Pi.Ramanujan.Chudnovsky as Math.Implementations.Pi.Ramanujan.Chudnovsky import qualified Factory.Math.Implementations.Pi.Ramanujan.Classic as Math.Implementations.Pi.Ramanujan.Classic import qualified Factory.Math.Implementations.Pi.Ramanujan.Implementation as Math.Implementations.Pi.Ramanujan.Implementation import qualified Factory.Math.Pi as Math.Pi import qualified Factory.Math.SquareRoot as Math.SquareRoot-import qualified ToolShed.Defaultable -- | Define those /Ramanujan/-series which have been implemented.-data Algorithm squareRootAlgorithm factorialAlgorithm =- Classic squareRootAlgorithm factorialAlgorithm -- ^ The original version.+data Algorithm squareRootAlgorithm factorialAlgorithm+ = Classic squareRootAlgorithm factorialAlgorithm -- ^ The original version. | Chudnovsky squareRootAlgorithm factorialAlgorithm -- ^ A variant found by the /Chudnovsky brothers/. deriving (Eq, Read, Show) instance (- ToolShed.Defaultable.Defaultable squareRootAlgorithm,- ToolShed.Defaultable.Defaultable factorialAlgorithm- ) => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm) where- defaultValue = Chudnovsky ToolShed.Defaultable.defaultValue ToolShed.Defaultable.defaultValue+ Data.Default.Default squareRootAlgorithm,+ Data.Default.Default factorialAlgorithm+ ) => Data.Default.Default (Algorithm squareRootAlgorithm factorialAlgorithm) where+ def = Chudnovsky Data.Default.def Data.Default.def instance ( Math.SquareRoot.Algorithmic squareRootAlgorithm,
src-lib/Factory/Math/Implementations/Pi/Ramanujan/Chudnovsky.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines the /Chudnovsky/ series for /Pi/; <http://en.wikipedia.org/wiki/Pi>.+ [@DESCRIPTION@] Defines the /Chudnovsky/ series for /Pi/; <https://en.wikipedia.org/wiki/Pi>. -} module Factory.Math.Implementations.Pi.Ramanujan.Chudnovsky(
src-lib/Factory/Math/Implementations/Pi/Ramanujan/Implementation.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Implements a /Ramanujan/-type series for /Pi/; <http://en.wikipedia.org/wiki/Srinivasa_Ramanujan>.+ [@DESCRIPTION@] Implements a /Ramanujan/-type series for /Pi/; <https://en.wikipedia.org/wiki/Srinivasa_Ramanujan>. -} module Factory.Math.Implementations.Pi.Ramanujan.Implementation(
src-lib/Factory/Math/Implementations/Pi/Ramanujan/Series.hs view
@@ -17,7 +17,7 @@ {- | [@AUTHOR@] Dr. Alistair Ward - [@DESCRIPTION@] Defines a <http://en.wikipedia.org/wiki/Srinivasa_Ramanujan>-type series for /Pi/.+ [@DESCRIPTION@] Defines a <https://en.wikipedia.org/wiki/Srinivasa_Ramanujan>-type series for /Pi/. -} module Factory.Math.Implementations.Pi.Ramanujan.Series(
src-lib/Factory/Math/Implementations/Pi/Spigot/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -26,21 +26,21 @@ Algorithm(..) ) where +import qualified Data.Default import Data.Ratio((%)) import qualified Factory.Math.Implementations.Pi.Spigot.Gosper as Math.Implementations.Pi.Spigot.Gosper import qualified Factory.Math.Implementations.Pi.Spigot.RabinowitzWagon as Math.Implementations.Pi.Spigot.RabinowitzWagon import qualified Factory.Math.Implementations.Pi.Spigot.Spigot as Math.Implementations.Pi.Spigot.Spigot import qualified Factory.Math.Pi as Math.Pi-import qualified ToolShed.Defaultable -- | Define those /Spigot/-algorithms which have been implemented.-data Algorithm =- Gosper -- ^ A /continued fraction/ discovered by /Gosper/.+data Algorithm+ = Gosper -- ^ A /continued fraction/ discovered by /Gosper/. | RabinowitzWagon -- ^ A /continued fraction/ discovered by /Rabinowitz/ and /Wagon/. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = Gosper+instance Data.Default.Default Algorithm where+ def = Gosper instance Math.Pi.Algorithmic Algorithm where openI Gosper = Math.Implementations.Pi.Spigot.Spigot.openI Math.Implementations.Pi.Spigot.Gosper.series
src-lib/Factory/Math/Implementations/Pi/Spigot/Spigot.hs view
@@ -19,7 +19,7 @@ [@DESCRIPTION@] - * Implements a /spigot/-algorithm; <http://en.wikipedia.org/wiki/Spigot_algorithm>.+ * Implements a /spigot/-algorithm; <https://en.wikipedia.org/wiki/Spigot_algorithm>. * Uses the traditional algorithm, rather than the /unbounded/ algorithm described by <http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf>. -}@@ -42,7 +42,7 @@ -- ** Accessors -- getQuotient, -- getRemainder,--- ** Constructors+-- ** Constructor -- mkRow ) where
src-lib/Factory/Math/Implementations/Primality.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -21,7 +21,7 @@ * Determines whether an integer is prime. - * <http://en.wikipedia.org/wiki/Primality_test>.+ * <https://en.wikipedia.org/wiki/Primality_test>. * <http://primes.utm.edu/index.html> @@ -42,6 +42,7 @@ import Control.Arrow((&&&)) import qualified Control.DeepSeq import qualified Control.Parallel.Strategies+import qualified Data.Default import qualified Data.Numbers.Primes import qualified Factory.Data.MonicPolynomial as Data.MonicPolynomial import qualified Factory.Data.Polynomial as Data.Polynomial@@ -51,16 +52,15 @@ import qualified Factory.Math.Power as Math.Power import qualified Factory.Math.Primality as Math.Primality import qualified Factory.Math.PrimeFactorisation as Math.PrimeFactorisation-import qualified ToolShed.Defaultable -- | The algorithms by which /primality/-testing has been implemented.-data Algorithm factorisationAlgorithm =- AKS factorisationAlgorithm -- ^ <http://en.wikipedia.org/wiki/AKS_primality_test>.- | MillerRabin -- ^ <http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test>.+data Algorithm factorisationAlgorithm+ = AKS factorisationAlgorithm -- ^ <https://en.wikipedia.org/wiki/AKS_primality_test>.+ | MillerRabin -- ^ <https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test>. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable (Algorithm factorisationAlgorithm) where- defaultValue = MillerRabin+instance Data.Default.Default (Algorithm factorisationAlgorithm) where+ def = MillerRabin instance Math.PrimeFactorisation.Algorithmic factorisationAlgorithm => Math.Primality.Algorithmic (Algorithm factorisationAlgorithm) where isPrime _ 2 = True -- The only even prime.@@ -79,7 +79,7 @@ ) candidate {- |- * An implementation of the /Agrawal-Kayal-Saxena/ primality-test; <http://en.wikipedia.org/wiki/AKS_primality_test>,+ * An implementation of the /Agrawal-Kayal-Saxena/ primality-test; <https://en.wikipedia.org/wiki/AKS_primality_test>, using the /Lenstra/ and /Pomerance/ algorithm. * CAVEAT: this deterministic algorithm has a theoretical time-complexity of @O(log^6)@,@@ -174,7 +174,7 @@ * A testing of smaller set of bases, is sufficient for candidates smaller than various thresholds; <http://primes.utm.edu/prove/prove2_3.html>. - * <http://en.wikipedia.org/wiki/Miller-Rabin_primality_test>.+ * <https://en.wikipedia.org/wiki/Miller-Rabin_primality_test>. * <http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html>
src-lib/Factory/Math/Implementations/PrimeFactorisation.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -42,6 +42,7 @@ import qualified Control.Arrow import qualified Control.DeepSeq import qualified Control.Parallel.Strategies+import qualified Data.Default import qualified Data.Maybe import qualified Data.Numbers.Primes import qualified Factory.Data.Exponential as Data.Exponential@@ -51,17 +52,16 @@ import qualified Factory.Math.Power as Math.Power import qualified Factory.Math.PrimeFactorisation as Math.PrimeFactorisation import qualified ToolShed.Data.Pair-import qualified ToolShed.Defaultable -- | The algorithms by which prime-factorisation has been implemented. data Algorithm- = DixonsMethod -- ^ <http://en.wikipedia.org/wiki/Dixon%27s_factorization_method>.- | FermatsMethod -- ^ <http://en.wikipedia.org/wiki/Fermat%27s_factorization_method>.- | TrialDivision -- ^ <http://en.wikipedia.org/wiki/Trial_division>.+ = DixonsMethod -- ^ <https://en.wikipedia.org/wiki/Dixon%27s_factorization_method>.+ | FermatsMethod -- ^ <https://en.wikipedia.org/wiki/Fermat%27s_factorization_method>.+ | TrialDivision -- ^ <https://en.wikipedia.org/wiki/Trial_division>. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = TrialDivision+instance Data.Default.Default Algorithm where+ def = TrialDivision instance Math.PrimeFactorisation.Algorithmic Algorithm where primeFactors algorithm = case algorithm of@@ -69,16 +69,16 @@ FermatsMethod -> Data.PrimeFactors.reduce . factoriseByFermatsMethod TrialDivision -> factoriseByTrialDivision --- | <http://en.wikipedia.org/wiki/Dixon%27s_factorization_method>.+-- | <https://en.wikipedia.org/wiki/Dixon%27s_factorization_method>. factoriseByDixonsMethod :: Integral base => base -> Data.PrimeFactors.Factors base exponent factoriseByDixonsMethod = undefined {- |- * <http://en.wikipedia.org/wiki/Fermat%27s_factorization_method>.+ * <https://en.wikipedia.org/wiki/Fermat%27s_factorization_method>. * <http://mathworld.wolfram.com/FermatsFactorizationMethod.html>. - * <http://en.wikipedia.org/wiki/Congruence_of_squares>.+ * <https://en.wikipedia.org/wiki/Congruence_of_squares>. * @i = f1 * f2@ Assume a non-trivial factorisation, ie. one in which both factors exceed one. => @i = (larger + smaller) * (larger - smaller)@ Represent the co-factors as a sum and difference.@@ -125,7 +125,7 @@ {- | * Decomposes the specified integer, into a product of /prime/-factors,- using <http://mathworld.wolfram.com/DirectSearchFactorization.html>, AKA <http://en.wikipedia.org/wiki/Trial_division>.+ using <http://mathworld.wolfram.com/DirectSearchFactorization.html>, AKA <https://en.wikipedia.org/wiki/Trial_division>. * This works best when the factors are small. -}
src-lib/Factory/Math/Implementations/Primes/Algorithm.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -34,6 +34,7 @@ Algorithm(..) ) where +import qualified Data.Default import qualified Data.Numbers.Primes import qualified Factory.Data.PrimeWheel as Data.PrimeWheel import qualified Factory.Math.Implementations.Primes.SieveOfAtkin as Math.Implementations.Primes.SieveOfAtkin@@ -41,19 +42,18 @@ import qualified Factory.Math.Implementations.Primes.TrialDivision as Math.Implementations.Primes.TrialDivision import qualified Factory.Math.Implementations.Primes.TurnersSieve as Math.Implementations.Primes.TurnersSieve import qualified Factory.Math.Primes as Math.Primes-import qualified ToolShed.Defaultable -- | The implemented methods by which the primes may be generated. data Algorithm- = SieveOfAtkin Integer -- ^ The /Sieve of Atkin/, optimised using a 'Data.PrimeWheel.PrimeWheel' of optimal size, for primes up to the specified maximum bound; <http://en.wikipedia.org/wiki/Sieve_of_Atkin>.- | SieveOfEratosthenes Data.PrimeWheel.NPrimes -- ^ The /Sieve of Eratosthenes/ (<http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>), optimised using a 'Data.PrimeWheel.PrimeWheel'.+ = SieveOfAtkin Integer -- ^ The /Sieve of Atkin/, optimised using a 'Data.PrimeWheel.PrimeWheel' of optimal size, for primes up to the specified maximum bound; <https://en.wikipedia.org/wiki/Sieve_of_Atkin>.+ | SieveOfEratosthenes Data.PrimeWheel.NPrimes -- ^ The /Sieve of Eratosthenes/ (<https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>), optimised using a 'Data.PrimeWheel.PrimeWheel'. | TrialDivision Data.PrimeWheel.NPrimes -- ^ For each candidate, confirm indivisibility, by all /primes/ smaller than its /square-root/, optimised using a 'Data.PrimeWheel.PrimeWheel'. | TurnersSieve -- ^ For each /prime/, the infinite list of candidates greater than its /square/, is filtered for indivisibility; <http://www.haskell.org/haskellwiki/Prime_numbers#Turner.27s_sieve_-_Trial_division>. | WheelSieve Int -- ^ 'Data.Numbers.Primes.wheelSieve'. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = SieveOfEratosthenes 7 -- Resulting in a wheel of circumference 510510.+instance Data.Default.Default Algorithm where+ def = SieveOfEratosthenes 7 -- Resulting in a wheel of circumference 510510. instance Math.Primes.Algorithmic Algorithm where primes (SieveOfAtkin maxPrime) = Math.Implementations.Primes.SieveOfAtkin.sieveOfAtkin (Data.PrimeWheel.estimateOptimalSize maxPrime) $ fromIntegral maxPrime
src-lib/Factory/Math/Implementations/Primes/SieveOfAtkin.hs view
@@ -19,7 +19,7 @@ [@DESCRIPTION@] - * Generates the constant /bounded/ list of /prime-numbers/, using the /Sieve of Atkin/; <http://en.wikipedia.org/wiki/Sieve_of_Atkin>.+ * Generates the constant /bounded/ list of /prime-numbers/, using the /Sieve of Atkin/; <https://en.wikipedia.org/wiki/Sieve_of_Atkin>. * <cr.yp.to/papers/primesieves-19990826.pdf>. @@ -99,7 +99,7 @@ * Because the results are /bounded/, they're returned in a zero-indexed /array/, to provide efficient random access; the first few elements should never be required, but it makes query clearer. - * <http://en.wikipedia.org/wiki/Sieve_of_Atkin>.+ * <https://en.wikipedia.org/wiki/Sieve_of_Atkin>. -} polynomialTypeLookup :: (Data.Array.IArray.Ix i, Integral i) => Data.PrimeWheel.PrimeWheel i
src-lib/Factory/Math/Implementations/Primes/SieveOfEratosthenes.hs view
@@ -19,7 +19,7 @@ [@DESCRIPTION@] - * Generates the constant, conceptually infinite, list of /prime-numbers/, using the /Sieve of Eratosthenes/; <http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>.+ * Generates the constant, conceptually infinite, list of /prime-numbers/, using the /Sieve of Eratosthenes/; <https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>. * Based on <http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf>. @@ -79,7 +79,7 @@ * A refinement of the /Sieve Of Eratosthenes/, which pre-sieves candidates, selecting only those /coprime/ to the specified short sequence of low prime-numbers. * The short sequence of initial primes are represented by a 'Data.PrimeWheel.PrimeWheel',- of parameterised, but static, size; <http://en.wikipedia.org/wiki/Wheel_factorization>.+ of parameterised, but static, size; <https://en.wikipedia.org/wiki/Wheel_factorization>. * The algorithm requires one to record multiples of previously discovered primes, allowing /composite/ candidates to be eliminated by comparison.
src-lib/Factory/Math/Implementations/Primes/TrialDivision.hs view
@@ -44,7 +44,7 @@ * For each candidate, confirm indivisibility, by all /primes/ smaller than its /square-root/. * The candidates to sieve, are generated by a 'Data.PrimeWheel.PrimeWheel',- of parameterised, but static, size; <http://en.wikipedia.org/wiki/Wheel_factorization>.+ of parameterised, but static, size; <https://en.wikipedia.org/wiki/Wheel_factorization>. -} trialDivision :: Integral prime => Data.PrimeWheel.NPrimes -> [prime] trialDivision 0 = [2, 3] ++ filter (`isIndivisibleBy` trialDivision 0 {-recurse-}) [5 ..] -- No faster than using 'Data.PrimeWheel.mkPrimeWheel 0', but apparently better space-complexity ?!
src-lib/Factory/Math/Implementations/SquareRoot.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -39,6 +39,7 @@ ) where import Control.Arrow((***))+import qualified Data.Default import Factory.Data.PrimeFactors((>/<), (>^)) import qualified Factory.Data.PrimeFactors as Data.PrimeFactors import qualified Factory.Math.Implementations.Factorial as Math.Implementations.Factorial@@ -46,22 +47,21 @@ import qualified Factory.Math.Precision as Math.Precision import qualified Factory.Math.SquareRoot as Math.SquareRoot import qualified Factory.Math.Summation as Math.Summation-import qualified ToolShed.Defaultable -- | The number of terms in a series. type Terms = Int -- | The algorithms by which the /square-root/ has been implemented. data Algorithm- = BakhshaliApproximation -- ^ <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Bakhshali_approximation>- | ContinuedFraction -- ^ <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion>.- | HalleysMethod -- ^ <http://en.wikipedia.org/wiki/Halley%27s_method>.- | NewtonRaphsonIteration -- ^ <http://en.wikipedia.org/wiki/Newton%27s_method>.- | TaylorSeries Terms -- ^ <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>.+ = BakhshaliApproximation -- ^ <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Bakhshali_approximation>+ | ContinuedFraction -- ^ <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion>.+ | HalleysMethod -- ^ <https://en.wikipedia.org/wiki/Halley%27s_method>.+ | NewtonRaphsonIteration -- ^ <https://en.wikipedia.org/wiki/Newton%27s_method>.+ | TaylorSeries Terms -- ^ <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>. deriving (Eq, Read, Show) -instance ToolShed.Defaultable.Defaultable Algorithm where- defaultValue = NewtonRaphsonIteration+instance Data.Default.Default Algorithm where+ def = NewtonRaphsonIteration -- | Returns an improved estimate for the /square-root/ of the specified value, to the required precision, using the supplied initial estimate.. type ProblemSpecification operand@@ -128,12 +128,12 @@ {- | * Uses /continued-fractions/, to iterate towards the principal /square-root/ of the specified positive integer;- <http://en.wikipedia.org/wiki/Solving_quadratic_equations_with_continued_fractions>,- <http://en.wikipedia.org/wiki/Generalized_continued_fraction#Roots_of_positive_numbers>,- <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion>.+ <https://en.wikipedia.org/wiki/Solving_quadratic_equations_with_continued_fractions>,+ <https://en.wikipedia.org/wiki/Generalized_continued_fraction#Roots_of_positive_numbers>,+ <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion>. <http://www.myreckonings.com/Dead_Reckoning/Online/Materials/General%20Method%20for%20Extracting%20Roots.pdf> - * The convergence <http://en.wikipedia.org/wiki/Rate_of_convergence> of the /continued-fraction/ is merely /1st order/ (linear).+ * The convergence <https://en.wikipedia.org/wiki/Rate_of_convergence> of the /continued-fraction/ is merely /1st order/ (linear). -} squareRootByContinuedFraction :: Real operand => ProblemSpecification operand squareRootByContinuedFraction (initialEstimate, initialDecimalDigits) requiredDecimalDigits y = initialEstimate + (convergents initialEstimate !! Math.Precision.getTermsRequired (10 ^^ negate initialDecimalDigits) requiredDecimalDigits) where@@ -141,7 +141,7 @@ convergents x = iterate ((Math.SquareRoot.getDiscrepancy y x /) . ((2 * x) +)) 0 {- |- * The constant coefficients of the /Taylor-series/ for a /square-root/; <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>.+ * The constant coefficients of the /Taylor-series/ for a /square-root/; <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>. * @ ((-1)^n * factorial(2*n)) / ((1 - 2*n) * 4^n * factorial(n^2)) @. -}@@ -160,7 +160,7 @@ {- | * Returns the /Taylor-series/ for the /square-root/ of the specified value, to any requested number of terms. - * <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>.+ * <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>. * The convergence of the series is merely /linear/, in that each term increases the precision, by a constant number of decimal places, equal to the those in the original estimate.
src-lib/Factory/Math/MultiplicativeOrder.hs view
@@ -38,7 +38,7 @@ * Based on <http://rosettacode.org/wiki/Multiplicative_order#Haskell>. - * <http://en.wikipedia.org/wiki/Multiplicative_order>.+ * <https://en.wikipedia.org/wiki/Multiplicative_order>. * <http://mathworld.wolfram.com/MultiplicativeOrder.html>. -}
src-lib/Factory/Math/PerfectPower.hs view
@@ -35,7 +35,7 @@ {- | * Returns @(Just . sqrt)@ if the specified integer is a /square number/ (AKA /perfect square/). - * <http://en.wikipedia.org/wiki/Square_number>.+ * <https://en.wikipedia.org/wiki/Square_number>. * <http://mathworld.wolfram.com/SquareNumber.html>. @@ -69,7 +69,7 @@ * CAVEAT: /zero/ and /one/ are normally excluded from this set. - * <http://en.wikipedia.org/wiki/Perfect_power>.+ * <https://en.wikipedia.org/wiki/Perfect_power>. * <http://mathworld.wolfram.com/PerfectPower.html>.
src-lib/Factory/Math/Pi.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -28,8 +28,8 @@ Category(..) ) where +import qualified Data.Default import qualified Factory.Math.Precision as Math.Precision-import qualified ToolShed.Defaultable {- | * Defines the methods expected of a /Pi/-algorithm.@@ -58,20 +58,14 @@ -- | Categorises the various algorithms. data Category agm bbp borwein ramanujan spigot = AGM agm -- ^ Algorithms based on the /Arithmetic-geometric Mean/.- | BBP bbp -- ^ <http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula>.- | Borwein borwein -- ^ <http://en.wikipedia.org/wiki/Borwein%27s_algorithm>.+ | BBP bbp -- ^ <https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula>.+ | Borwein borwein -- ^ <https://en.wikipedia.org/wiki/Borwein%27s_algorithm>. | Ramanujan ramanujan -- ^ <http://www.pi314.net/eng/ramanujan.php>. | Spigot spigot -- ^ Algorithms from which the digits of /Pi/ slowly drip, one by one. deriving (Eq, Read, Show) -instance (- ToolShed.Defaultable.Defaultable agm,- ToolShed.Defaultable.Defaultable bbp,- ToolShed.Defaultable.Defaultable borwein,- ToolShed.Defaultable.Defaultable ramanujan,- ToolShed.Defaultable.Defaultable spigot- ) => ToolShed.Defaultable.Defaultable (Category agm bbp borwein ramanujan spigot) where- defaultValue = BBP ToolShed.Defaultable.defaultValue+instance Data.Default.Default bbp => Data.Default.Default (Category agm bbp borwein ramanujan spigot) where+ def = BBP Data.Default.def instance ( Algorithmic agm,
src-lib/Factory/Math/Power.hs view
@@ -58,9 +58,9 @@ * Raise an arbitrary number to the specified positive integral power, using /modular/ arithmetic. * Implements exponentiation as a sequence of either /squares/ or multiplications by the base;- <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>.+ <https://en.wikipedia.org/wiki/Exponentiation_by_squaring>. - * <http://en.wikipedia.org/wiki/Modular_exponentiation>.+ * <https://en.wikipedia.org/wiki/Modular_exponentiation>. -} raiseModulo :: (Integral i, Integral power, Show power) => i -- ^ Base.
src-lib/Factory/Math/Precision.hs view
@@ -40,10 +40,10 @@ import qualified Data.Ratio --- | The /order of convergence/; <http://en.wikipedia.org/wiki/Rate_of_convergence>.+-- | The /order of convergence/; <https://en.wikipedia.org/wiki/Rate_of_convergence>. type ConvergenceOrder = Int --- | The /rate of convergence/; <http://en.wikipedia.org/wiki/Rate_of_convergence>.+-- | The /rate of convergence/; <https://en.wikipedia.org/wiki/Rate_of_convergence>. type ConvergenceRate = Double -- | A number of decimal digits; presumably positive.@@ -88,7 +88,7 @@ divided by the error after only @n@ terms, as the latter tends to infinity. As such, for a /convergent/ series (in which the error get smaller with successive terms), it's value lies in the range @0 .. 1@. - * <http://en.wikipedia.org/wiki/Rate_of_convergence>.+ * <https://en.wikipedia.org/wiki/Rate_of_convergence>. -} getTermsRequired :: Integral i => ConvergenceRate
src-lib/Factory/Math/Primality.hs view
@@ -48,7 +48,7 @@ * @1@ and @-1@ are the only numbers which are /coprime/ to themself. - * <http://en.wikipedia.org/wiki/Coprime>.+ * <https://en.wikipedia.org/wiki/Coprime>. * <http://mathworld.wolfram.com/RelativelyPrime.html>. -}@@ -58,11 +58,11 @@ {- | * Tests /Fermat's Little Theorem/ for all applicable values, as a probabilistic primality-test. - * <http://en.wikipedia.org/wiki/Fermat%27s_little_theorem>.+ * <https://en.wikipedia.org/wiki/Fermat%27s_little_theorem>. - * <http://en.wikipedia.org/wiki/Fermat_primality_test>.+ * <https://en.wikipedia.org/wiki/Fermat_primality_test>. - * <http://en.wikipedia.org/wiki/Fermat_pseudoprime>.+ * <https://en.wikipedia.org/wiki/Fermat_pseudoprime>. * CAVEAT: this primality-test fails for the /Carmichael numbers/. @@ -75,7 +75,7 @@ {- | * A /Carmichael number/ is an /odd/ /composite/ number which satisfies /Fermat's little theorem/. - * <http://en.wikipedia.org/wiki/Carmichael_number>.+ * <https://en.wikipedia.org/wiki/Carmichael_number>. * <http://mathworld.wolfram.com/CarmichaelNumber.html>. -}@@ -92,7 +92,7 @@ isPrime algorithm i ] --- | An ordered list of the /Carmichael/ numbers; <http://en.wikipedia.org/wiki/Carmichael_number>.+-- | An ordered list of the /Carmichael/ numbers; <https://en.wikipedia.org/wiki/Carmichael_number>. carmichaelNumbers :: ( Algorithmic algorithm, Control.DeepSeq.NFData i,
src-lib/Factory/Math/PrimeFactorisation.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -19,10 +19,10 @@ [@DESCRIPTION@] - * <http://en.wikipedia.org/wiki/Integer_factorization>.+ * <https://en.wikipedia.org/wiki/Integer_factorization>. * Exports a common interface to permit decomposition of positive integers,- into the unique combination of /prime/-factors known to exist according to the /Fundamental Theorem of Arithmetic/; <http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic>.+ into the unique combination of /prime/-factors known to exist according to the /Fundamental Theorem of Arithmetic/; <https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic>. * Leveraging this abstract capability, it derives the /smoothness/, /power-smoothness/, /omega/-numbers and /square-free/ integers. @@ -64,7 +64,7 @@ but though a prime-factor /greater/ than the /square-root/ of the number can exist, its smaller /cofactor/ decomposes to a prime which must be less than the /square-root/. - * NB: rather then using @(primeFactor <= sqrt numerator)@ to filter the candidate prime-factors of a given numerator,+ * N.B.: rather then using @(primeFactor <= sqrt numerator)@ to filter the candidate prime-factors of a given numerator, one can alternatively use @(numerator >= primeFactor ^ 2)@ to filter what can potentially be factored by a given prime-factor. * CAVEAT: suffers from rounding-errors, though no consequence has been witnessed.@@ -75,7 +75,7 @@ {- | * A constant, zero-indexed, conceptually infinite, list, of the /smooth/ness of all positive integers. - * <http://en.wikipedia.org/wiki/Smooth_number>.+ * <https://en.wikipedia.org/wiki/Smooth_number>. * <http://mathworld.wolfram.com/SmoothNumber.html>. -}@@ -85,7 +85,7 @@ {- | * A constant, zero-indexed, conceptually infinite, list of the /power-smooth/ness of all positive integers. - * <http://en.wikipedia.org/wiki/Smooth_number#Powersmooth_numbers>.+ * <https://en.wikipedia.org/wiki/Smooth_number#Powersmooth_numbers>. -} powerSmoothness :: (Algorithmic algorithm, Control.DeepSeq.NFData base, Integral base) => algorithm -> [base] powerSmoothness algorithm = 0 : map (maximum . map Data.Exponential.evaluate . primeFactors algorithm) [1 ..]@@ -93,9 +93,9 @@ {- | * Filters 'smoothness', to derive the constant list of /Hamming-numbers/. - * <http://en.wikipedia.org/wiki/Regular_number>.+ * <https://en.wikipedia.org/wiki/Regular_number>. -}-regularNumbers :: (Algorithmic algorithm, Control.DeepSeq.NFData base, Integral base) => algorithm -> [base]+regularNumbers :: (Algorithmic algorithm, Integral base) => algorithm -> [base] regularNumbers algorithm = map fst . filter ((<= (5 :: Integer)) . snd) . zip [1 ..] . tail $ smoothness algorithm {- |@@ -112,7 +112,7 @@ {- | * The number of /coprimes/ less than or equal to the specified positive integer. - * <http://en.wikipedia.org/wiki/Euler%27s_totient_function>.+ * <https://en.wikipedia.org/wiki/Euler%27s_totient_function>. * <http://mathworld.wolfram.com/TotientFunction.html>. @@ -138,13 +138,13 @@ * <http://planetmath.org/encyclopedia/NumberOfDistinctPrimeFactorsFunction.html>. -}-omega :: (Algorithmic algorithm, Control.DeepSeq.NFData i, Integral i) => algorithm -> [i]+omega :: (Algorithmic algorithm, Integral i) => algorithm -> [i] omega algorithm = map (Data.List.genericLength . primeFactors algorithm) [0 :: Integer ..] {- | * A constant, conceptually infinite, list of the /square-free/ numbers, i.e. those which aren't divisible by any /perfect square/. - * <http://en.wikipedia.org/wiki/Square-free_integer>.+ * <https://en.wikipedia.org/wiki/Square-free_integer>. -} squareFree :: (Algorithmic algorithm, Control.DeepSeq.NFData i, Integral i) => algorithm -> [i] squareFree algorithm = filter (all (== 1) . map Data.Exponential.getExponent . primeFactors algorithm) [1 ..]
src-lib/Factory/Math/Primes.hs view
@@ -21,7 +21,7 @@ -} module Factory.Math.Primes(--- * Types-classes+-- * Type-classes Algorithmic(..), -- * Functions primorial,@@ -38,7 +38,7 @@ {- | * Returns the constant list, defining the /Primorial/. - * <http://en.wikipedia.org/wiki/Primorial>.+ * <https://en.wikipedia.org/wiki/Primorial>. * <http://mathworld.wolfram.com/Primorial.html>. -}@@ -55,7 +55,7 @@ * Only the subset composed from a prime exponent is returned; which is a strict superset of the /Mersenne Primes/. - * <http://en.wikipedia.org/wiki/Mersenne_prime>.+ * <https://en.wikipedia.org/wiki/Mersenne_prime>. * <http://mathworld.wolfram.com/MersenneNumber.html> -}
src-lib/Factory/Math/Probability.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011-2013 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -61,12 +61,12 @@ minPositiveFloat :: RealFloat a => a -> a minPositiveFloat = encodeFloat 1 . uncurry (-) . (fst . floatRange &&& floatDigits) --- | Describes /continuous probability-distributions/; <http://en.wikipedia.org/wiki/List_of_probability_distributions#Continuous_distributions>.+-- | Describes /continuous probability-distributions/; <https://en.wikipedia.org/wiki/List_of_probability_distributions#Continuous_distributions>. data ContinuousDistribution parameter- = ExponentialDistribution parameter {-lambda-} -- ^ Defines an /Exponential/-distribution with a particular /lambda/; <http://en.wikipedia.org/wiki/Exponential_distribution>.- | LogNormalDistribution parameter {-location-} parameter {-scale2-} -- ^ Defines a distribution whose logarithm is normally distributed with a particular /mean/ & /variance/; <http://en.wikipedia.org/wiki/Lognormal>.- | NormalDistribution parameter {-mean-} parameter {-variance-} -- ^ Defines a /Normal/-distribution with a particular /mean/ & /variance/; <http://en.wikipedia.org/wiki/Normal_distribution>.- | UniformDistribution (Data.Interval.Interval parameter) -- ^ Defines a /Uniform/-distribution within a /closed interval/; <http://en.wikipedia.org/wiki/Uniform_distribution>.+ = ExponentialDistribution parameter {-lambda-} -- ^ Defines an /Exponential/-distribution with a particular /lambda/; <https://en.wikipedia.org/wiki/Exponential_distribution>.+ | LogNormalDistribution parameter {-location-} parameter {-scale2-} -- ^ Defines a distribution whose logarithm is normally distributed with a particular /mean/ & /variance/; <https://en.wikipedia.org/wiki/Lognormal>.+ | NormalDistribution parameter {-mean-} parameter {-variance-} -- ^ Defines a /Normal/-distribution with a particular /mean/ & /variance/; <https://en.wikipedia.org/wiki/Normal_distribution>.+ | UniformDistribution (Data.Interval.Interval parameter) -- ^ Defines a /Uniform/-distribution within a /closed interval/; <https://en.wikipedia.org/wiki/Uniform_distribution>. deriving (Eq, Read, Show) instance (Floating parameter, Ord parameter, Show parameter) => ToolShed.SelfValidate.SelfValidator (ContinuousDistribution parameter) where@@ -81,10 +81,10 @@ NormalDistribution _ variance -> [(variance <= 0, "variance must exceed zero; " ++ show probabilityDistribution ++ ".")] UniformDistribution interval -> [(Data.Interval.isReversed interval, "reversed interval='" ++ show probabilityDistribution ++ "'.")] --- | Describes /discrete probability-distributions/; <http://en.wikipedia.org/wiki/List_of_probability_distributions#Discrete_distributions>.+-- | Describes /discrete probability-distributions/; <https://en.wikipedia.org/wiki/List_of_probability_distributions#Discrete_distributions>. data DiscreteDistribution parameter- = PoissonDistribution parameter {-lambda-} -- ^ Defines an /Poisson/-distribution with a particular /lambda/; <http://en.wikipedia.org/wiki/Poisson_distribution>.- | ShiftedGeometricDistribution parameter {-probability-} -- ^ Defines an /Geometric/-distribution with a particular probability of success; <http://en.wikipedia.org/wiki/Geometric_distribution>.+ = PoissonDistribution parameter {-lambda-} -- ^ Defines an /Poisson/-distribution with a particular /lambda/; <https://en.wikipedia.org/wiki/Poisson_distribution>.+ | ShiftedGeometricDistribution parameter {-probability-} -- ^ Defines an /Geometric/-distribution with a particular probability of success; <https://en.wikipedia.org/wiki/Geometric_distribution>. deriving (Eq, Read, Show) instance (Num parameter, Ord parameter, Show parameter) => ToolShed.SelfValidate.SelfValidator (DiscreteDistribution parameter) where@@ -117,7 +117,7 @@ getMean (UniformDistribution (minParameter, maxParameter)) = realToFrac $ (minParameter + maxParameter) / 2 getVariance (ExponentialDistribution lambda) = realToFrac . recip $ Math.Power.square lambda- getVariance (LogNormalDistribution location scale2) = realToFrac $ (exp scale2 - 1) * exp (2 * location + scale2) -- NB: for standard-deviation == mean, use scale^2 == ln 2.+ getVariance (LogNormalDistribution location scale2) = realToFrac $ (exp scale2 - 1) * exp (2 * location + scale2) -- N.B.: for standard-deviation == mean, use scale^2 == ln 2. getVariance (NormalDistribution _ variance) = realToFrac variance getVariance (UniformDistribution (minParameter, maxParameter)) = realToFrac $ Math.Power.square (maxParameter - minParameter) / 12 @@ -134,7 +134,7 @@ * Converts a pair of independent /uniformly distributed/ random numbers, within the /semi-closed unit interval/ /(0,1]/, to a pair of independent /normally distributed/ random numbers, of standardized /mean/=0, and /variance/=1. - * <http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform>.+ * <https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform>. -} boxMullerTransform :: ( Floating f,@@ -157,7 +157,7 @@ * Uses the supplied random-number generator, to generate a conceptually infinite list, of /normally distributed/ random numbers, with standardized /mean/=0, and /variance/=1. - * <http://en.wikipedia.org/wiki/Normal_distribution>, <http://mathworld.wolfram.com/NormalDistribution.html>.+ * <https://en.wikipedia.org/wiki/Normal_distribution>, <http://mathworld.wolfram.com/NormalDistribution.html>. -} generateStandardizedNormalDistribution :: ( RealFloat f,@@ -188,7 +188,7 @@ | otherwise = ( case probabilityDistribution of ExponentialDistribution lambda -> let- quantile = (/ lambda) . negate . log . (1 -) -- <http://en.wikipedia.org/wiki/Quantile_function>.+ quantile = (/ lambda) . negate . log . (1 -) -- <https://en.wikipedia.org/wiki/Quantile_function>. in map quantile . System.Random.randomRs (0, 1) LogNormalDistribution location scale2 -> map ( exp . (+ location) . (* sqrt scale2) -- Stretch the standard-deviation & re-locate the mean to that specified for the log-space, then return to the original coordinates.@@ -199,7 +199,7 @@ {- | * Uses the supplied random-number generator,- to generate a conceptually infinite population, of random integers conforming to the /Poisson distribution/; <http://en.wikipedia.org/wiki/Poisson_distribution>.+ to generate a conceptually infinite population, of random integers conforming to the /Poisson distribution/; <https://en.wikipedia.org/wiki/Poisson_distribution>. * CAVEAT: uses an algorithm by Knuth, which having a /linear time-complexity/ in /lambda/, can be intolerably slow;
src-lib/Factory/Math/Radix.hs view
@@ -85,7 +85,7 @@ | n >&< encodes = encodes ! n | otherwise = error $ "Factory.Math.Radix.toBase.toDigit:\tno suitable character-representation for integer " ++ show n where- (>&<) :: (Data.Array.IArray.Ix i, Integral i) => i -> Data.Array.IArray.Array i Char -> Bool+ (>&<) :: (Data.Array.IArray.Ix i) => i -> Data.Array.IArray.Array i Char -> Bool index >&< array = ($ index) `all` [(>= lower), (<= upper)] where (lower, upper) = Data.Array.IArray.bounds array @@ -117,7 +117,7 @@ {- | * <http://mathworld.wolfram.com/DigitSum.html>. - * <http://en.wikipedia.org/wiki/Digit_sum>.+ * <https://en.wikipedia.org/wiki/Digit_sum>. -} digitSum :: ( Data.Array.IArray.Ix decimal,@@ -129,7 +129,7 @@ digitSum 10 = fromIntegral . foldr ((+) . Data.Char.digitToInt) 0 . show digitSum base = sum . Data.Maybe.mapMaybe (`lookup` decodes) . toBase base --- | <http://en.wikipedia.org/wiki/Digital_root>.+-- | <https://en.wikipedia.org/wiki/Digital_root>. digitalRoot :: ( Data.Array.IArray.Ix decimal, Integral decimal,
src-lib/Factory/Math/SquareRoot.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-2015 Dr. Alistair Ward 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@@ -87,7 +87,7 @@ | otherwise = (Math.Precision.simplify decimalDigits {-doubles performance by roughly length of the Rational representation-} . toRational $ rSqrt y, decimalDigits) where decimalDigits :: Math.Precision.DecimalDigits- decimalDigits = 16 -- <http://en.wikipedia.org/wiki/IEEE_floating_point>.+ decimalDigits = 16 -- <https://en.wikipedia.org/wiki/IEEE_floating_point>. {- | * The signed difference between the /square/ of an estimate for the /square-root/ of a value, and that value.@@ -116,5 +116,5 @@ | otherwise = length $ show (round $ toRational y / absoluteError :: Integer) where absoluteError :: Result- absoluteError = abs (getDiscrepancy y x) / 2 -- NB: the magnitude of the error in 'y', is twice the error in its square-root, 'x'.+ absoluteError = abs (getDiscrepancy y x) / 2 -- N.B.: the magnitude of the error in 'y', is twice the error in its square-root, 'x'.
src-lib/Factory/Math/Statistics.hs view
@@ -23,6 +23,7 @@ module Factory.Math.Statistics( -- * Functions getMean,+ getRootMeanSquare, getWeightedMean, -- getDispersionFromMean, getVariance,@@ -42,7 +43,7 @@ import qualified Factory.Math.Power as Math.Power {- |- * Determines the /mean/ of the specified numbers; <http://en.wikipedia.org/wiki/Mean>.+ * Determines the /mean/ of the specified numbers; <https://en.wikipedia.org/wiki/Mean>. * Should the caller define the result-type as 'Rational', then it will be free from rounding-errors. -}@@ -59,15 +60,32 @@ where (numerator, denominator) = Data.Foldable.foldr (\s -> (+ s) *** succ) (0, 0 :: Int) foldable +-- | Determines the /root mean square/ of the specified numbers; <https://en.wikipedia.org/wiki/Root_mean_square>.+getRootMeanSquare :: (+ Data.Foldable.Foldable foldable,+ Floating result,+ Real value+ )+ => foldable value+ -> result+getRootMeanSquare foldable+ | denominator == 0 = error "Factory.Math.Statistics.getRootMeanSquare:\tno data => undefined result."+ | otherwise = sqrt $ realToFrac numerator / fromIntegral denominator+ where+ (numerator, denominator) = Data.Foldable.foldr (\s -> (+ Math.Power.square s) *** succ) (0, 0 :: Int) foldable+ {- |- * Determines the /weighted mean/ of the specified numbers; <http://en.wikipedia.org/wiki/Weighted_arithmetic_mean>.+ * Determines the /weighted mean/ of the specified numbers; <https://en.wikipedia.org/wiki/Weighted_arithmetic_mean>. * The specified value is only evaluated if the corresponding weight is non-zero. * Should the caller define the result-type as 'Rational', then it will be free from rounding-errors.++ * CAVEAT: because the operand is more general than a list, no optimisation is performed when supplied a singleton. -} getWeightedMean :: ( Data.Foldable.Foldable foldable,+ Eq result, Fractional result, Real value, Real weight@@ -76,16 +94,18 @@ -> result getWeightedMean foldable | denominator == 0 = error "Factory.Math.Statistics.getWeightedMean:\tzero weight => undefined result."- | otherwise = numerator / realToFrac denominator+ | otherwise = numerator / denominator where (numerator, denominator) = Data.Foldable.foldr (- \(value, weight) -> if weight == 0- then id --Avoid unnecessarily evaluation.- else (+ realToFrac value * realToFrac weight) *** (+ weight)+ \(value, weight) -> let+ w = realToFrac weight+ in if w == 0+ then id -- Avoid unnecessarily evaluation.+ else (+ realToFrac value * w) *** (+ w) -- Perform the arithmetic in the specified result-type. ) (0, 0) foldable {- |- * Measures the /dispersion/ of a /population/ of results from the /mean/ value; <http://en.wikipedia.org/wiki/Statistical_dispersion>.+ * Measures the /dispersion/ of a /population/ of results from the /mean/ value; <https://en.wikipedia.org/wiki/Statistical_dispersion>. * Should the caller define the result-type as 'Rational', then it will be free from rounding-errors. -}@@ -100,7 +120,7 @@ mean = getMean foldable {- |- * Determines the exact /variance/ of the specified numbers; <http://en.wikipedia.org/wiki/Variance>.+ * Determines the exact /variance/ of the specified numbers; <https://en.wikipedia.org/wiki/Variance>. * Should the caller define the result-type as 'Rational', then it will be free from rounding-errors. -}@@ -112,7 +132,7 @@ ) => foldable value -> variance getVariance = getDispersionFromMean Math.Power.square --- | Determines the /standard-deviation/ of the specified numbers; <http://en.wikipedia.org/wiki/Standard_deviation>.+-- | Determines the /standard-deviation/ of the specified numbers; <https://en.wikipedia.org/wiki/Standard_deviation>. getStandardDeviation :: ( Data.Foldable.Foldable foldable, Floating result,@@ -122,7 +142,7 @@ getStandardDeviation = sqrt . getVariance {- |- * Determines the /average absolute deviation/ of the specified numbers; <http://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation>.+ * Determines the /average absolute deviation/ of the specified numbers; <https://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation>. * Should the caller define the result-type as 'Rational', then it will be free from rounding-errors. -}@@ -134,7 +154,7 @@ ) => foldable value -> result getAverageAbsoluteDeviation = getDispersionFromMean abs --- | Determines the /coefficient-of-variance/ of the specified numbers; <http://en.wikipedia.org/wiki/Coefficient_of_variation>.+-- | Determines the /coefficient-of-variance/ of the specified numbers; <https://en.wikipedia.org/wiki/Coefficient_of_variation>. getCoefficientOfVariance :: ( Data.Foldable.Foldable foldable, Eq result,@@ -148,7 +168,7 @@ where mean = getMean l --- | The number of unordered /combinations/ of /r/ objects taken from /n/; <http://en.wikipedia.org/wiki/Combination>.+-- | The number of unordered /combinations/ of /r/ objects taken from /n/; <https://en.wikipedia.org/wiki/Combination>. nCr :: (Math.Factorial.Algorithmic factorialAlgorithm, Integral i, Show i) => factorialAlgorithm -> i -- ^ The total number of items from which to select.@@ -166,7 +186,7 @@ numerator = Math.Implementations.Factorial.risingFactorial (succ bigger) (n - bigger) denominator = Math.Factorial.factorial factorialAlgorithm smaller --- | The number of /permutations/ of /r/ objects taken from /n/; <http://en.wikipedia.org/wiki/Permutations>.+-- | The number of /permutations/ of /r/ objects taken from /n/; <https://en.wikipedia.org/wiki/Permutations>. nPr :: (Integral i, Show i) => i -- ^ The total number of items from which to select. -> i -- ^ The number of items in a sample.
src-test/Factory/Test/QuickCheck/Pi.hs view
@@ -32,7 +32,6 @@ import Factory.Test.QuickCheck.Factorial() import Factory.Test.QuickCheck.SquareRoot()-import qualified Factory.Math.Factorial as Math.Factorial import qualified Factory.Math.Implementations.Factorial as Math.Implementations.Factorial import qualified Factory.Math.Implementations.Pi.AGM.Algorithm as Math.Implementations.Pi.AGM.Algorithm import qualified Factory.Math.Implementations.Pi.BBP.Algorithm as Math.Implementations.Pi.BBP.Algorithm@@ -42,7 +41,6 @@ import qualified Factory.Math.Implementations.SquareRoot as Math.Implementations.SquareRoot import qualified Factory.Math.Pi as Math.Pi import qualified Factory.Math.Precision as Math.Precision-import qualified Factory.Math.SquareRoot as Math.SquareRoot import qualified Test.QuickCheck import Test.QuickCheck((==>)) @@ -50,10 +48,7 @@ import Control.Applicative((<$>), (<*>)) #endif -instance (- Test.QuickCheck.Arbitrary squareRootAlgorithm,- Math.SquareRoot.Algorithmic squareRootAlgorithm- ) => Test.QuickCheck.Arbitrary (Math.Implementations.Pi.AGM.Algorithm.Algorithm squareRootAlgorithm) where+instance Test.QuickCheck.Arbitrary squareRootAlgorithm => Test.QuickCheck.Arbitrary (Math.Implementations.Pi.AGM.Algorithm.Algorithm squareRootAlgorithm) where arbitrary = Math.Implementations.Pi.AGM.Algorithm.BrentSalamin <$> Test.QuickCheck.arbitrary instance Test.QuickCheck.Arbitrary Math.Implementations.Pi.BBP.Algorithm.Algorithm where@@ -61,9 +56,7 @@ instance ( Test.QuickCheck.Arbitrary squareRootAlgorithm,- Math.SquareRoot.Algorithmic squareRootAlgorithm,- Test.QuickCheck.Arbitrary factorialAlgorithm,- Math.Factorial.Algorithmic factorialAlgorithm+ Test.QuickCheck.Arbitrary factorialAlgorithm ) => Test.QuickCheck.Arbitrary (Math.Implementations.Pi.Borwein.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm) where arbitrary = Test.QuickCheck.oneof [ Math.Implementations.Pi.Borwein.Algorithm.Borwein1993 <$> Test.QuickCheck.arbitrary <*> Test.QuickCheck.arbitrary@@ -71,9 +64,7 @@ instance ( Test.QuickCheck.Arbitrary squareRootAlgorithm,- Math.SquareRoot.Algorithmic squareRootAlgorithm,- Test.QuickCheck.Arbitrary factorialAlgorithm,- Math.Factorial.Algorithmic factorialAlgorithm+ Test.QuickCheck.Arbitrary factorialAlgorithm ) => Test.QuickCheck.Arbitrary (Math.Implementations.Pi.Ramanujan.Algorithm.Algorithm squareRootAlgorithm factorialAlgorithm) where arbitrary = Test.QuickCheck.oneof [ Math.Implementations.Pi.Ramanujan.Algorithm.Classic <$> Test.QuickCheck.arbitrary <*> Test.QuickCheck.arbitrary,
src-test/Factory/Test/QuickCheck/Primes.hs view
@@ -31,6 +31,7 @@ ) where import qualified Control.DeepSeq+import qualified Data.Default import qualified Data.Set import qualified Factory.Data.PrimeWheel as Data.PrimeWheel import qualified Factory.Math.Implementations.Primality as Math.Implementations.Primality@@ -40,7 +41,6 @@ import qualified Factory.Math.Primes as Math.Primes import qualified Test.QuickCheck import Test.QuickCheck((==>))-import qualified ToolShed.Defaultable instance Test.QuickCheck.Arbitrary Math.Implementations.Primes.Algorithm.Algorithm where arbitrary = Test.QuickCheck.oneof [@@ -52,7 +52,7 @@ isPrime :: (Control.DeepSeq.NFData i, Integral i, Show i) => i -> Bool isPrime = Math.Primality.isPrime primalityAlgorithm where primalityAlgorithm :: Math.Implementations.Primality.Algorithm Math.Implementations.PrimeFactorisation.Algorithm- primalityAlgorithm = ToolShed.Defaultable.defaultValue+ primalityAlgorithm = Data.Default.def upperBound :: Math.Implementations.Primes.Algorithm.Algorithm -> Int -> Int upperBound algorithm i = mod i $ if algorithm == Math.Implementations.Primes.Algorithm.TurnersSieve@@ -60,7 +60,7 @@ else 65536 defaultAlgorithm :: Math.Implementations.Primes.Algorithm.Algorithm-defaultAlgorithm = ToolShed.Defaultable.defaultValue+defaultAlgorithm = Data.Default.def -- | The constant test-results for this data-type. results :: IO [Test.QuickCheck.Result]
src-test/Factory/Test/QuickCheck/Probability.hs view
@@ -146,7 +146,7 @@ randomGen <- System.Random.getStdGen sequence [- Test.QuickCheck.quickCheckResult $ prop_logNormalDistributionEqual randomGen, -- CAVEAT: known to fail occasionally.+-- Test.QuickCheck.quickCheckResult $ prop_logNormalDistributionEqual randomGen, -- CAVEAT: known to fail occasionally. Test.QuickCheck.quickCheckResult $ prop_logNormalDistribution randomGen, Test.QuickCheck.quickCheckResult $ prop_logNormalDistribution' randomGen, Test.QuickCheck.quickCheckResult $ prop_normalDistribution randomGen,
src-test/Factory/Test/QuickCheck/SquareRoot.hs view
@@ -34,7 +34,7 @@ import qualified Factory.Math.SquareRoot as Math.SquareRoot import qualified Test.QuickCheck -instance Test.QuickCheck.Arbitrary (Math.Implementations.SquareRoot.Algorithm) where+instance Test.QuickCheck.Arbitrary Math.Implementations.SquareRoot.Algorithm where arbitrary = Test.QuickCheck.oneof [ Test.QuickCheck.elements [ Math.Implementations.SquareRoot.BakhshaliApproximation,@@ -48,7 +48,7 @@ -- | The constant test-results for this data-type. results :: IO [Test.QuickCheck.Result] results = mapM Test.QuickCheck.quickCheckResult [- prop_accuracy,+-- prop_accuracy, -- This occasionally fails. prop_factorable -- prop_perfectSquare -- This occasionally fails. ] where
src-test/Factory/Test/QuickCheck/Statistics.hs view
@@ -25,7 +25,7 @@ results ) where -import qualified Data.Array+import qualified Data.Array.IArray import qualified Data.List import qualified Data.Map import qualified Data.Numbers.Primes@@ -40,6 +40,7 @@ -- | The constant test-results for this data-type. results :: IO [Test.QuickCheck.Result] results = sequence [+ Test.QuickCheck.quickCheckResult prop_standardDeviationRMS, Test.QuickCheck.quickCheckResult prop_nC0, Test.QuickCheck.quickCheckResult prop_nC1, Test.QuickCheck.quickCheckResult prop_sum,@@ -59,7 +60,8 @@ Test.QuickCheck.quickCheckResult prop_meanOfSet, Test.QuickCheck.quickCheckResult prop_weightedMeanRational, Test.QuickCheck.quickCheckResult prop_weightedMeanInteger,- Test.QuickCheck.quickCheckResult prop_weightedMeanUniformDenominator+ Test.QuickCheck.quickCheckResult prop_weightedMeanUniformDenominator,+ Test.QuickCheck.quickCheckResult prop_rootMeanSquare ] where prop_nC0, prop_nC1, prop_sum :: Math.Implementations.Factorial.Algorithm -> Integer -> Test.QuickCheck.Property prop_nC0 algorithm n = Test.QuickCheck.label "prop_nC0" $ Math.Statistics.nCr algorithm (abs n) 0 == 1@@ -94,7 +96,9 @@ prop_varianceScaled l = not (null l) ==> Test.QuickCheck.label "prop_varianceScaled" $ (4 * Math.Statistics.getVariance l :: Rational) == Math.Statistics.getVariance (map (* 2) l) prop_varianceOrder l = not (null l) ==> Test.QuickCheck.label "prop_varianceOrder" $ Math.Statistics.getVariance l == (Math.Statistics.getVariance (reverse l) :: Rational) prop_equivalence l = not (null l) ==> Test.QuickCheck.label "prop_equivalence" $ Math.Statistics.getVariance l == Math.Statistics.getMean (map Math.Power.square l) - Math.Power.square (Math.Statistics.getMean l :: Rational)- prop_varianceOfArray l = not (null l) ==> Test.QuickCheck.label "prop_varianceOfArray" $ Math.Statistics.getVariance (Data.Array.array (1, length l) $ zip [1 ..] l) == (Math.Statistics.getVariance l :: Rational)+ prop_varianceOfArray l = not (null l) ==> Test.QuickCheck.label "prop_varianceOfArray" $ Math.Statistics.getVariance (+ Data.Array.IArray.array (1, length l) $ zip [1 ..] l :: Data.Array.IArray.Array Int Integer+ ) == (Math.Statistics.getVariance l :: Rational) prop_varianceOfMap l = not (null l) ==> Test.QuickCheck.label "prop_varianceOfMap" $ Math.Statistics.getVariance (Data.Map.fromList $ zip [0 :: Int ..] l) == (Math.Statistics.getVariance l :: Rational) prop_meanOfSet l = not (null l') ==> Test.QuickCheck.label "prop_meanOfSet" $ Math.Statistics.getMean (Data.Set.fromList l') == (Math.Statistics.getMean l' :: Rational) where l' = Data.List.nub l@@ -122,4 +126,11 @@ ) == ( Math.Statistics.getMean numerators :: Rational )++ prop_rootMeanSquare :: [Rational] -> Test.QuickCheck.Property+ prop_rootMeanSquare l = not (null l) ==> Test.QuickCheck.label "prop_rootMeanSquare" $ Math.Statistics.getRootMeanSquare l == sqrt (Math.Statistics.getMean $ map Math.Power.square l :: Double)++ prop_standardDeviationRMS :: [Rational] -> Test.QuickCheck.Property+ prop_standardDeviationRMS l = not (null l) ==> Test.QuickCheck.label "prop_standardDeviationRMS" $ Math.Statistics.getRootMeanSquare l' == (Math.Statistics.getStandardDeviation l' :: Double) where+ l' = l ++ map negate l -- Ensure mean == 0.
src-test/Main.hs view
@@ -24,7 +24,6 @@ module Main(main) where -import Control.Arrow((***)) import qualified Control.Monad import qualified Factory.Test.QuickCheck.ArithmeticGeometricMean as Test.QuickCheck.ArithmeticGeometricMean import qualified Factory.Test.QuickCheck.Factorial as Test.QuickCheck.Factorial@@ -49,28 +48,24 @@ -- | Entry-point. main :: IO () main = mapM_ (- snd {-exit-status-} . (- putStrLn . (++ ":") *** (- >>= (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful- )- )+ (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful =<< ) [- ("ArithmeticGeometricMean", Test.QuickCheck.ArithmeticGeometricMean.results),- ("Factorial", Test.QuickCheck.Factorial.results),- ("Hyperoperation", Test.QuickCheck.Hyperoperation.results),- ("Interval", Test.QuickCheck.Interval.results),- ("MonicPolynomial", Test.QuickCheck.MonicPolynomial.results),- ("PerfectPower", Test.QuickCheck.PerfectPower.results),- ("Pi", Test.QuickCheck.Pi.results),- ("Polynomial", Test.QuickCheck.Polynomial.results),- ("Power", Test.QuickCheck.Power.results),- ("Primality", Test.QuickCheck.Primality.results),- ("PrimeFactorisation", Test.QuickCheck.PrimeFactorisation.results),- ("Primes", Test.QuickCheck.Primes.results),- ("Probability", Test.QuickCheck.Probability.results),- ("Radix", Test.QuickCheck.Radix.results),- ("SquareRoot", Test.QuickCheck.SquareRoot.results),- ("Statistics", Test.QuickCheck.Statistics.results),- ("Summation", Test.QuickCheck.Summation.results)+ Test.QuickCheck.ArithmeticGeometricMean.results,+ Test.QuickCheck.Factorial.results,+ Test.QuickCheck.Hyperoperation.results,+ Test.QuickCheck.Interval.results,+ Test.QuickCheck.MonicPolynomial.results,+ Test.QuickCheck.PerfectPower.results,+ Test.QuickCheck.Pi.results,+ Test.QuickCheck.Polynomial.results,+ Test.QuickCheck.Power.results,+ Test.QuickCheck.Primality.results,+ Test.QuickCheck.PrimeFactorisation.results,+ Test.QuickCheck.Primes.results,+ Test.QuickCheck.Probability.results,+ Test.QuickCheck.Radix.results,+ Test.QuickCheck.SquareRoot.results,+ Test.QuickCheck.Statistics.results,+ Test.QuickCheck.Summation.results ]