packages feed

factory 0.2.0.1 → 0.2.0.2

raw patch · 52 files changed

+247/−212 lines, 52 filesdep ~toolshed

Dependency ranges changed: toolshed

Files

changelog view
@@ -43,3 +43,10 @@ 	* 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.+0.2.0.1+	* 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.
factory.cabal view
@@ -1,6 +1,6 @@ --Package-properties Name:			factory-Version:		0.2.0.1+Version:		0.2.0.2 Cabal-Version:		>= 1.6 Copyright:		(C) 2011 Dr. Alistair Ward License:		GPL@@ -95,7 +95,7 @@         containers,         primes >= 0.1,         random,-        toolshed >= 0.12+        toolshed == 0.13.*      if flag(threaded)         Build-depends:	parallel >= 3.0@@ -103,7 +103,11 @@         Build-depends:	parallel      GHC-options:	-Wall -O2-    GHC-prof-options:	-prof -auto-all -caf-all++    if impl(ghc >= 7.4.1)+        GHC-prof-options:	-prof -fprof-auto -fprof-cafs+    else+        GHC-prof-options:	-prof -auto-all -caf-all      if impl(ghc >= 7.0) && flag(llvm)         GHC-options:	-fllvm
makefile view
@@ -1,18 +1,18 @@ # Copyright (C) 2011 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 # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version.-# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the # GNU General Public License for more details.-# +# # You should have received a copy of the GNU General Public License # along with this program.  If not, see <http://www.gnu.org/licenses/>.- + .PHONY: all build check clean configure copy haddock help hlint install prof sdist  all: install@@ -40,7 +40,7 @@ 	PATH=~/.cabal/bin:$$PATH runhaskell Setup.hs $@ --hyperlink-source	#Amend path to find 'HsColour', as required for 'hyperlink-source'.  hlint:-	@$@ src/+	@$@ -i 'Use &&' -i 'Reduce duplication' -i 'Redundant bracket' src/  sdist: configure 	runhaskell Setup.hs $@
src/Factory/Data/Exponential.hs view
@@ -72,7 +72,7 @@ evaluate :: (Num base, Integral exponent) => Exponential base exponent -> base evaluate	= uncurry (^) --- | 'True' if the /bases/ are equal.+-- | True if the /bases/ are equal. (=~) :: Eq base => Exponential base exponent -> Exponential base exponent -> Bool (l, _) =~ (r, _)	= l == r 
src/Factory/Data/Interval.hs view
@@ -42,10 +42,11 @@ 	Interval, -- * Constants 	closedUnitInterval,+	mkBounded, -- * Functions --	divideAndConquer, 	elem',-	getLength,+--	getLength, 	normalise, 	product', 	shift,@@ -63,7 +64,7 @@ import			Control.Arrow((***), (&&&)) import qualified	Data.Monoid import qualified	Data.Ratio-import qualified	ToolShed.Pair	as Pair+import qualified	ToolShed.Data.Pair  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies@@ -90,26 +91,30 @@ getMaxBound :: Interval endPoint -> endPoint getMaxBound	= snd --- | Construct the interval from a single value.-precisely :: endPoint -> Interval endPoint-precisely	= id &&& id---- | Construct the /closed unit-interval/; <http://en.wikipedia.org/wiki/Unit_interval>.+-- | Construct the /unsigned closed unit-interval/; <http://en.wikipedia.org/wiki/Unit_interval>. closedUnitInterval :: Num n => Interval n closedUnitInterval	= (0, 1) +-- | Construct an /interval/ from a bounded type.+mkBounded :: Bounded endPoint => Interval endPoint+mkBounded	= (minBound, maxBound)++-- | Construct an /interval/ from a single value.+precisely :: endPoint -> Interval endPoint+precisely	= id &&& id+ -- | Shift of both /end-points/ of the /interval/ by the specified amount. shift :: Num endPoint 	=> endPoint		-- ^ The magnitude of the require shift. 	-> Interval endPoint	-- ^ The interval to be shifted. 	-> Interval endPoint-shift i	= Pair.mirror (+ i)+shift i	= ToolShed.Data.Pair.mirror (+ i) --- | 'True' if the specified value is within the inclusive bounds of the /interval/.+-- | True if the specified value is within the inclusive bounds of the /interval/. elem' :: Ord endPoint => endPoint -> Interval endPoint -> Bool-elem' x	= Pair.both . ((<= x) *** (x <=))+elem' x	= uncurry (&&) . ((<= x) *** (x <=)) --- | 'True' if 'getMinBound' exceeds 'getMaxBound' extent.+-- | True if 'getMinBound' exceeds 'getMaxBound' extent. isReversed :: Ord endPoint => Interval endPoint -> Bool isReversed	= uncurry (>) @@ -125,12 +130,23 @@ 	| any ($ i) [(< l), (>= r)]	= error $ "Factory.Data.Interval.splitAt':\tunsuitable index=" ++ show i ++ " for interval=" ++ show interval ++ "." 	| otherwise			= ((l, i), (succ i, r)) --- | The length of 'toList'.+{- |+	* The distance between the endpoints,+	which for 'Integral' quantities is the same as the number of items in closed interval; though the latter concept would return type 'Int'.++	* CAVEAT: the implementation accounts for the potential fence-post error, for closed intervals of integers,+	but this results in the opposite error when used with /Fractional/ quantities.+	So, though most of the module merely requires 'Enum', this function is further restricted to 'Integral'.+-} {-# INLINE getLength #-}-getLength :: (Enum endPoint, Num endPoint) => Interval endPoint -> endPoint+getLength :: Integral endPoint => Interval endPoint -> endPoint getLength (l, r)	= succ r - l --- | Converts 'Interval' to a list by enumerating the values.+{- |+	* Converts 'Interval' to a list by enumerating the values.++	* CAVEAT: produces rather odd results for 'Fractional' types, but no stranger than considering such types 'Enum'erable.+-} {-# INLINE toList #-} toList :: Enum endPoint => Interval endPoint -> [endPoint] toList	= uncurry enumFromTo@@ -168,13 +184,13 @@ 	where 		slave interval@(l, r) 			| getLength interval <= minLength	= Data.Monoid.mconcat . map monoidConstructor $ toList interval	--Fold the monoid's binary operator over the delimited list.-			| otherwise			= uncurry Data.Monoid.mappend .+			| otherwise				= uncurry Data.Monoid.mappend . #if MIN_VERSION_parallel(3,0,0) 			Control.Parallel.Strategies.withStrategy ( 				Control.Parallel.Strategies.parTuple2 Control.Parallel.Strategies.rseq Control.Parallel.Strategies.rseq 			) . #endif-			Pair.mirror slave $ splitAt' (+			ToolShed.Data.Pair.mirror slave $ splitAt' ( 				l + (r - l) * Data.Ratio.numerator ratio `div` Data.Ratio.denominator ratio	--Use the ratio to generate the split-index. 			) interval	--Apply the monoid's binary operator to the two operands resulting from bisection. 
src/Factory/Data/MonicPolynomial.hs view
@@ -39,14 +39,14 @@ import qualified	Factory.Data.QuotientRing	as Data.QuotientRing import			Factory.Data.Ring((=*=), (=+=), (=-=)) import qualified	Factory.Data.Ring		as Data.Ring-import qualified	ToolShed.Pair			as Pair+import qualified	ToolShed.Data.Pair  -- | A type of 'Data.Polynomial.Polynomial', in which the /leading term/ is required to have a /coefficient/ of one. newtype MonicPolynomial c e	= MkMonicPolynomial { 	getPolynomial	:: Data.Polynomial.Polynomial c e } deriving (Eq, Show) --- | Constructs an arbitrary /monic polynomial/.+-- | Smart constructor. Constructs an arbitrary /monic polynomial/. mkMonicPolynomial :: (Num c, Ord e, Show e) => Data.Polynomial.Polynomial c e -> MonicPolynomial c e mkMonicPolynomial polynomial 	| not $ Data.Polynomial.isMonic polynomial	= error $ "Factory.Data.MonicPolynomial.mkMonicPolynomial:\tnot monic; " ++ show polynomial@@ -72,7 +72,7 @@  -- Since the /leading term/ of the /denominator/ is one, the /coefficient/ isn't required to implement 'Fractional'. instance (Num c, Num e, Ord e) => Data.QuotientRing.QuotientRing (MonicPolynomial c e)	where-	MkMonicPolynomial polynomialN `quotRem'` MkMonicPolynomial polynomialD	= Pair.mirror MkMonicPolynomial $ longDivide polynomialN	where+	MkMonicPolynomial polynomialN `quotRem'` MkMonicPolynomial polynomialD	= ToolShed.Data.Pair.mirror MkMonicPolynomial $ longDivide polynomialN	where --		longDivide :: (Num c, Num e, Ord e) => Polynomial c e -> (Polynomial c e, Polynomial c e) 		longDivide numerator 			| Data.Polynomial.isZero numerator || Data.Monomial.getExponent quotient < 0	= (Data.Polynomial.zero, numerator)
src/Factory/Data/Monomial.hs view
@@ -85,7 +85,7 @@ (<=>) :: Ord e => Monomial c e -> Monomial c e -> Ordering (_, l) <=> (_, r)	= l `compare` r --- | 'True' if the /exponents/ are equal.+-- | True if the /exponents/ are equal. (=~) :: Eq e => Monomial c e -> Monomial c e -> Bool (_, l) =~ (_, r)	= l == r 
src/Factory/Data/Polynomial.hs view
@@ -209,7 +209,7 @@ 	-> Polynomial c e mkLinear m c	= pruneCoefficients $ MkPolynomial [(m, 1), (c, 0)] --- | Constructs an arbitrary /polynomial/.+-- | Smart constructor. Constructs an arbitrary /polynomial/. mkPolynomial :: (Num c, Ord e) => MonomialList c e -> Polynomial c e mkPolynomial []	= zero mkPolynomial l	= normalise $ MkPolynomial l@@ -222,25 +222,25 @@ one :: (Num c, Num e) => Polynomial c e one	= mkConstant 1 --- | 'True' if all /exponents/ are in the order defined by the specified comparator.+-- | True if all /exponents/ are in the order defined by the specified comparator. inOrder :: (e -> e -> Bool) -> Polynomial c e -> Bool inOrder comparator p 	| any ($ p) [isZero, isMonomial]	= True 	| otherwise				= and . uncurry (zipWith comparator) . (init &&& tail) . map Data.Monomial.getExponent $ getMonomialList p --- | 'True' if the /exponents/ of successive terms are in /ascending/ order.+-- | True if the /exponents/ of successive terms are in /ascending/ order. inAscendingOrder :: Ord e => Polynomial c e -> Bool inAscendingOrder	= inOrder (<=) --- | 'True' if the /exponents/ of successive terms are in /descending/ order.+-- | True if the /exponents/ of successive terms are in /descending/ order. inDescendingOrder :: Ord e => Polynomial c e -> Bool inDescendingOrder	= inOrder (>=) --- | 'True' if no term has a /coefficient/ of zero.+-- | True if no term has a /coefficient/ of zero. isReduced :: Num c => Polynomial c e -> Bool isReduced	= all ((/= 0) . Data.Monomial.getCoefficient) . getMonomialList --- | 'True' if no term has a /coefficient/ of zero and the /exponents/ of successive terms are in /descending/ order.+-- | True if no term has a /coefficient/ of zero and the /exponents/ of successive terms are in /descending/ order. isNormalised :: (Num c, Ord e) => Polynomial c e -> Bool isNormalised polynomial	= all ($ polynomial) [isReduced, inDescendingOrder] @@ -253,17 +253,17 @@ isMonic (MkPolynomial [])	= False	--All coefficients are zero, and have therefore been removed. isMonic p			= (== 1) . Data.Monomial.getCoefficient $ getLeadingTerm p --- | 'True' if there are zero terms.+-- | True if there are zero terms. isZero :: Polynomial c e -> Bool isZero (MkPolynomial [])	= True isZero _			= False --- | 'True' if there's exactly one term.+-- | True if there's exactly one term. isMonomial :: Polynomial c e -> Bool isMonomial (MkPolynomial [])	= True isMonomial _			= False --- | 'True' if all /exponents/ are /positive/ integers as required.+-- | True if all /exponents/ are /positive/ integers as required. isPolynomial :: Integral e => Polynomial c e -> Bool isPolynomial	= all Data.Monomial.isMonomial . getMonomialList 
src/Factory/Data/PrimeFactors.hs view
@@ -51,7 +51,7 @@ import			Factory.Data.Exponential((<^), (=~))  #if MIN_VERSION_toolshed(11,1,1)-import qualified	ToolShed.ListPlus		as ListPlus+import qualified	ToolShed.Data.List #endif  infixl 7 >/<, >*<	--Same as (/).@@ -106,7 +106,7 @@ (>*<) :: (Ord base, Num exponent, Ord exponent) => Factors base exponent -> Factors base exponent -> Factors base exponent l >*< r	= #if MIN_VERSION_toolshed(11,1,1)-	reduceSorted $ ListPlus.merge l r+	reduceSorted $ ToolShed.Data.List.merge l r #else 	reduce $ l ++ r	--CAVEAT: concatenation disorders the list, necessitating a re-sort. #endif
src/Factory/Data/PrimeWheel.hs view
@@ -67,7 +67,7 @@ -} data PrimeWheel i	= MkPrimeWheel { 	getPrimeComponents	:: [i],	-- ^ Accessor: the ordered sequence of initial primes, from which the /wheel/ was composed.-	getSpokeGaps 		:: [i]	-- ^ Accessor: the sequence of spoke-gaps, the sum of which equals its /circumference/.+	getSpokeGaps		:: [i]	-- ^ Accessor: the sequence of spoke-gaps, the sum of which equals its /circumference/. } deriving Show  -- | The /circumference/ of the specified 'PrimeWheel'.@@ -75,7 +75,7 @@ getCircumference	= product . getPrimeComponents  -- | The number of spokes in the specified 'PrimeWheel'.-getSpokeCount:: Integral i => PrimeWheel i -> i+getSpokeCount :: Integral i => PrimeWheel i -> i getSpokeCount	= foldr ((*) . pred) 1 . getPrimeComponents  -- | An infinite increasing sequence, of the multiples of a specific prime.@@ -136,7 +136,7 @@ 	optimalCircumference	= round (sqrt $ fromIntegral maxPrime :: Double)  {- |-	* Constructs a /wheel/ from the specified number of low primes.+	Smart constructor for a /wheel/ from the specified number of low primes.  	* The optimal number of low primes from which to build the /wheel/, grows with the number of primes required; 	the /circumference/ should be approximately the /square-root/ of the number of integers it will be required to sieve.
src/Factory/Data/QuotientRing.hs view
@@ -24,7 +24,7 @@ 	* This is a /ring/ composed from a residue-class resulting from /modular/ division. -} -module Factory.Data.QuotientRing (+module Factory.Data.QuotientRing( -- * Type-classes 	QuotientRing(..), -- * Functions@@ -70,7 +70,7 @@ 	| l == r	= True	--Only required for efficiency. 	| otherwise	= (l =-= r) `isDivisibleBy` modulus --- | 'True' if the second operand /divides/ the first.+-- | True if the second operand /divides/ the first. isDivisibleBy :: (Eq q, QuotientRing q) 	=> q	-- ^ Numerator. 	-> q	-- ^ Denominator.
src/Factory/Data/Ring.hs view
@@ -80,7 +80,7 @@ 	| otherwise							= slave power 	where 		slave 1	= ring-		slave n	= (if r == 0 {-even-} then id else (=*= ring)) . square $ slave q 	where+		slave n	= (if r == 0 {-even-} then id else (=*= ring)) . square $ slave q	where 			(q, r)	= n `quotRem` 2  -- | Does for 'Ring', what 'Data.Monoid.Product' does for type 'Num', in that it makes it an instance of 'Data.Monoid.Monoid' under multiplication.
src/Factory/Math/Hyperoperation.hs view
@@ -58,7 +58,7 @@ type HyperExponent	= Base  succession, addition, multiplication, exponentiation, tetration, pentation, hexation :: Int	--Arbitrarily.-(succession : addition : multiplication : exponentiation : tetration : pentation : hexation : _) 	= [0 ..]+(succession : addition : multiplication : exponentiation : tetration : pentation : hexation : _)	= [0 ..]  {- | 	* Returns the /power-tower/ of the specified /base/; <http://mathworld.wolfram.com/PowerTower.html>.@@ -104,7 +104,7 @@ ackermannPeter :: Integral rank => rank -> HyperExponent -> Base ackermannPeter rank	= (+ negate 3) . hyperoperation rank 2 {-base-} . (+ 3) --- | 'True' if @hyperoperation base hyperExponent@ has the same value for each specified 'rank'.+-- | True if @hyperoperation base hyperExponent@ has the same value for each specified 'rank'. areCoincidental :: Integral rank => Base -> HyperExponent -> [rank] -> Bool areCoincidental _ _ []				= True areCoincidental _ _ [_]				= True
src/Factory/Math/Implementations/Factorial.hs view
@@ -48,7 +48,7 @@ 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		as Defaultable+import qualified	ToolShed.Defaultable  infixl 7 !/!	--Same as (/). @@ -58,7 +58,7 @@ 	| PrimeFactorisation	-- ^ The /prime factors/ of the /factorial/ are extracted, then raised to the appropriate power, before multiplication. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= Bisection  instance Math.Factorial.Algorithmic Algorithm	where@@ -130,8 +130,8 @@ 	-> i	-- ^ The /denominator/. 	-> f	-- ^ The resulting fraction. numerator !/! denominator-	| numerator <= 1		= recip . fromIntegral $ Math.Factorial.factorial (Defaultable.defaultValue :: Algorithm) denominator-	| denominator <= 1		= fromIntegral $ Math.Factorial.factorial (Defaultable.defaultValue :: Algorithm) numerator+	| numerator <= 1		= recip . fromIntegral $ Math.Factorial.factorial (ToolShed.Defaultable.defaultValue :: Algorithm) denominator+	| denominator <= 1		= fromIntegral $ Math.Factorial.factorial (ToolShed.Defaultable.defaultValue :: Algorithm) numerator 	| numerator == denominator	= 1 	| numerator < denominator	= recip $ denominator !/! numerator	--Recurse. 	| otherwise			= fromIntegral $ Data.Interval.product' (recip 2) 64 (succ denominator, numerator)
src/Factory/Math/Implementations/Pi/AGM/Algorithm.hs view
@@ -29,13 +29,13 @@ 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					as Defaultable+import qualified	ToolShed.Defaultable  -- | Defines the available algorithms. data Algorithm squareRootAlgorithm	= BrentSalamin squareRootAlgorithm	deriving (Eq, Read, Show) -instance Defaultable.Defaultable squareRootAlgorithm => Defaultable.Defaultable (Algorithm squareRootAlgorithm)	where-	defaultValue	= BrentSalamin Defaultable.defaultValue+instance ToolShed.Defaultable.Defaultable squareRootAlgorithm => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm)	where+	defaultValue	= BrentSalamin ToolShed.Defaultable.defaultValue  instance Math.SquareRoot.Algorithmic squareRootAlgorithm => Math.Pi.Algorithmic (Algorithm squareRootAlgorithm)	where 	openR (BrentSalamin squareRootAlgorithm)	= Math.Implementations.Pi.AGM.BrentSalamin.openR squareRootAlgorithm
src/Factory/Math/Implementations/Pi/AGM/BrentSalamin.hs view
@@ -55,7 +55,7 @@ >		=> 4*a[N]^2 / (1 - sum [2^(n-1) * 4 * (a[n-1]^2 - g[n-1]^2)])			where n = [1 .. N] >		=> 4*a[N]^2 / (1 - sum [2^(n+1) * (a[n-1]^2 - g[n-1]^2)]) --}                +-} openR :: Math.SquareRoot.Algorithmic squareRootAlgorithm => squareRootAlgorithm -> Math.Precision.DecimalDigits -> Data.Ratio.Rational openR squareRootAlgorithm decimalDigits	= uncurry (/) . ( 	Math.Power.square . uncurry (+) . last &&& negate . pred . sum . zipWith (*) (iterate (* 2) 1) . map (Math.Power.square . Math.ArithmeticGeometricMean.spread)
src/Factory/Math/Implementations/Pi/BBP/Algorithm.hs view
@@ -30,7 +30,7 @@ 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					as Defaultable+import qualified	ToolShed.Defaultable  -- | Defines those /BBP/-type series which have been implemented. data Algorithm	=@@ -38,7 +38,7 @@ 	| Bellard	-- ^ A /nega-base/ @2^10@ version of the formula. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= Base65536  instance Math.Pi.Algorithmic Algorithm	where
src/Factory/Math/Implementations/Pi/BBP/Implementation.hs view
@@ -37,8 +37,8 @@ import qualified	Factory.Math.Summation				as Math.Summation  -- | Returns /Pi/, accurate to the specified number of decimal digits.-openR ::-	Math.Implementations.Pi.BBP.Series.Series	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use.+openR+	:: Math.Implementations.Pi.BBP.Series.Series	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use. 	-> Math.Precision.DecimalDigits			-- ^ The number of decimal digits required. 	-> Data.Ratio.Rational openR Math.Implementations.Pi.BBP.Series.MkSeries {
src/Factory/Math/Implementations/Pi/Borwein/Algorithm.hs view
@@ -31,7 +31,7 @@ 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					as Defaultable+import qualified	ToolShed.Defaultable  {- | 	* Define those /Borwein/-series which have been implemented.@@ -43,10 +43,10 @@ 	deriving (Eq, Read, Show)  instance (-	Defaultable.Defaultable	squareRootAlgorithm,-	Defaultable.Defaultable	factorialAlgorithm- ) => Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm)	where-	defaultValue	= Borwein1993 Defaultable.defaultValue Defaultable.defaultValue+	ToolShed.Defaultable.Defaultable	squareRootAlgorithm,+	ToolShed.Defaultable.Defaultable	factorialAlgorithm+ ) => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm)	where+	defaultValue	= Borwein1993 ToolShed.Defaultable.defaultValue ToolShed.Defaultable.defaultValue  instance ( 	Math.SquareRoot.Algorithmic	squareRootAlgorithm,
src/Factory/Math/Implementations/Pi/Borwein/Implementation.hs view
@@ -36,8 +36,8 @@ #endif  -- | Returns /Pi/, accurate to the specified number of decimal digits.-openR ::-	Math.Implementations.Pi.Borwein.Series.Series squareRootAlgorithm factorialAlgorithm	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use.+openR+	:: Math.Implementations.Pi.Borwein.Series.Series squareRootAlgorithm factorialAlgorithm	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use. 	-> squareRootAlgorithm									-- ^ The specific /square-root/ algorithm to apply to the above series. 	-> factorialAlgorithm									-- ^ The specific /factorial/-algorithm to apply to the above series. 	-> Math.Precision.DecimalDigits								-- ^ The number of decimal digits required.@@ -53,5 +53,5 @@ 		sum . take ( 			Math.Precision.getTermsRequired convergenceRate decimalDigits 		)-	) $ terms squareRootAlgorithm factorialAlgorithm decimalDigits +	) $ terms squareRootAlgorithm factorialAlgorithm decimalDigits 
src/Factory/Math/Implementations/Pi/Borwein/Series.hs view
@@ -31,14 +31,14 @@  -- | Defines a series corresponding to a specific /Borwein/-formula. data Series squareRootAlgorithm factorialAlgorithm	= MkSeries {-	terms			::-		squareRootAlgorithm+	terms+		:: squareRootAlgorithm 		-> factorialAlgorithm 		-> Math.Precision.DecimalDigits 		-> ( 			Data.Ratio.Rational,	--The factor into which the sum to infinity of the sequence, must be divided to result in /Pi/ 			[Data.Ratio.Rational]	--The sequence of terms, the sum to infinity of which defines the series. 		),-	convergenceRate		:: Math.Precision.ConvergenceRate	-- ^ The expected number of digits of /Pi/, per term in the series.+	convergenceRate :: Math.Precision.ConvergenceRate	-- ^ The expected number of digits of /Pi/, per term in the series. } 
src/Factory/Math/Implementations/Pi/Ramanujan/Algorithm.hs view
@@ -32,7 +32,7 @@ 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						as Defaultable+import qualified	ToolShed.Defaultable  -- | Define those /Ramanujan/-series which have been implemented. data Algorithm squareRootAlgorithm factorialAlgorithm	=@@ -41,10 +41,10 @@ 	deriving (Eq, Read, Show)  instance (-	Defaultable.Defaultable	squareRootAlgorithm,-	Defaultable.Defaultable	factorialAlgorithm- ) => Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm)	where-	defaultValue	= Chudnovsky Defaultable.defaultValue Defaultable.defaultValue+	ToolShed.Defaultable.Defaultable	squareRootAlgorithm,+	ToolShed.Defaultable.Defaultable	factorialAlgorithm+ ) => ToolShed.Defaultable.Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm)	where+	defaultValue	= Chudnovsky ToolShed.Defaultable.defaultValue ToolShed.Defaultable.defaultValue  instance ( 	Math.SquareRoot.Algorithmic	squareRootAlgorithm,
src/Factory/Math/Implementations/Pi/Ramanujan/Implementation.hs view
@@ -36,11 +36,11 @@ #endif  -- | Returns /Pi/, accurate to the specified number of decimal digits.-openR ::-	Math.Implementations.Pi.Ramanujan.Series.Series squareRootAlgorithm factorialAlgorithm	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use.-	-> squareRootAlgorithm									-- ^ The specific /square-root/ algorithm to apply to the above series.-	-> factorialAlgorithm									-- ^ The specific /factorial/-algorithm to apply to the above series.-	-> Math.Precision.DecimalDigits								-- ^ The number of decimal digits required.+openR+	:: Math.Implementations.Pi.Ramanujan.Series.Series squareRootAlgorithm factorialAlgorithm	-- ^ This /Pi/-algorithm is parameterised by the type of other algorithms to use.+	-> squareRootAlgorithm										-- ^ The specific /square-root/ algorithm to apply to the above series.+	-> factorialAlgorithm										-- ^ The specific /factorial/-algorithm to apply to the above series.+	-> Math.Precision.DecimalDigits									-- ^ The number of decimal digits required. 	-> Data.Ratio.Rational openR Math.Implementations.Pi.Ramanujan.Series.MkSeries { 	Math.Implementations.Pi.Ramanujan.Series.terms			= terms,
src/Factory/Math/Implementations/Pi/Spigot/Algorithm.hs view
@@ -31,7 +31,7 @@ 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					as Defaultable+import qualified	ToolShed.Defaultable  -- | Define those /Spigot/-algorithms which have been implemented. data Algorithm	=@@ -39,7 +39,7 @@ 	| RabinowitzWagon	-- ^ A /continued fraction/ discovered by /Rabinowitz/ and /Wagon/. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= Gosper  instance Math.Pi.Algorithmic Algorithm	where
src/Factory/Math/Implementations/Pi/Spigot/Spigot.hs view
@@ -37,12 +37,13 @@ 	decimal, -- * Functions --	carryAndDivide,---	mkRow, --	processColumns, 	openI, -- ** Accessors --	getQuotient,---	getRemainder+--	getRemainder,+-- ** Constructors+--	mkRow ) where  import qualified	Control.Arrow
src/Factory/Math/Implementations/Primality.hs view
@@ -51,7 +51,7 @@ 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			as Defaultable+import qualified	ToolShed.Defaultable  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies@@ -63,7 +63,7 @@ 	| MillerRabin			-- ^ <http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test>. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable (Algorithm factorisationAlgorithm)	where+instance ToolShed.Defaultable.Defaultable (Algorithm factorisationAlgorithm)	where 	defaultValue	= MillerRabin  instance Math.PrimeFactorisation.Algorithmic factorisationAlgorithm => Math.Primality.Algorithmic (Algorithm factorisationAlgorithm)	where
src/Factory/Math/Implementations/PrimeFactorisation.hs view
@@ -50,8 +50,8 @@ import qualified	Factory.Math.PerfectPower	as Math.PerfectPower import qualified	Factory.Math.Power		as Math.Power import qualified	Factory.Math.PrimeFactorisation	as Math.PrimeFactorisation-import qualified	ToolShed.Defaultable		as Defaultable-import qualified	ToolShed.Pair			as Pair+import qualified	ToolShed.Data.Pair+import qualified	ToolShed.Defaultable  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies@@ -64,7 +64,7 @@ 	| TrialDivision	-- ^ <http://en.wikipedia.org/wiki/Trial_division>. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= TrialDivision  instance Math.PrimeFactorisation.Algorithmic Algorithm	where@@ -110,7 +110,7 @@ 		Control.Parallel.Strategies.parTuple2 Control.Parallel.Strategies.rdeepseq Control.Parallel.Strategies.rdeepseq	--CAVEAT: unproductive on the size of integers tested so far. 	) . #endif-	Pair.mirror factoriseByFermatsMethod $ head factors+	ToolShed.Data.Pair.mirror factoriseByFermatsMethod $ head factors 	where --		maybeSquareNumber :: Integral i => Maybe i 		maybeSquareNumber	= Math.PerfectPower.maybeSquareNumber i
src/Factory/Math/Implementations/Primes/Algorithm.hs view
@@ -41,7 +41,7 @@ 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					as Defaultable+import qualified	ToolShed.Defaultable  -- | The implemented methods by which the primes may be generated. data Algorithm@@ -52,7 +52,7 @@ 	| WheelSieve Int					-- ^ 'Data.Numbers.Primes.wheelSieve'. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= SieveOfEratosthenes 7	--Resulting in a wheel of circumference 510510.  instance Math.Primes.Algorithmic Algorithm	where
src/Factory/Math/Implementations/Primes/SieveOfAtkin.hs view
@@ -53,16 +53,14 @@ ) where  import qualified	Control.DeepSeq-import qualified	Data.Array import qualified	Data.Array.IArray import			Data.Array.IArray((!))---import qualified	Data.Array.Unboxed import qualified	Data.IntSet import qualified	Data.List import qualified	Data.Set import qualified	Factory.Data.PrimeWheel	as Data.PrimeWheel import qualified	Factory.Math.Power	as Math.Power-import qualified	ToolShed.ListPlus	as ListPlus+import qualified	ToolShed.Data.List  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies@@ -110,8 +108,7 @@ polynomialTypeLookup :: (Data.Array.IArray.Ix i, Integral i) 	=> Data.PrimeWheel.PrimeWheel i 	-> i	-- ^ The maximum prime required.---	-> Data.Array.Unboxed.Array i PolynomialType	--Changes neither execution-time nor space ?!-	-> Data.Array.Array i PolynomialType+	-> Data.Array.IArray.Array i PolynomialType polynomialTypeLookup primeWheel maxPrime	= Data.Array.IArray.listArray (0, pred (polynomialTypeLookupPeriod primeWheel) `min` maxPrime) $ map select [0 ..]	where --	select :: Integral i => i -> PolynomialType 	select n@@ -169,7 +166,7 @@ 	=> Data.PrimeWheel.PrimeWheel i 	-> i	-- ^ The maximum prime-number required. 	-> [i]-findPolynomialSolutions primeWheel maxPrime	= foldr1 ListPlus.merge --The lists were previously sorted, as a side-effect, by 'filterOddRepetitions'.+findPolynomialSolutions primeWheel maxPrime	= foldr1 ToolShed.Data.List.merge --The lists were previously sorted, as a side-effect, by 'filterOddRepetitions'. #if MIN_VERSION_parallel(3,0,0) 	$ Control.Parallel.Strategies.withStrategy (Control.Parallel.Strategies.parList Control.Parallel.Strategies.rdeepseq) #endif
src/Factory/Math/Implementations/SquareRoot.hs view
@@ -46,7 +46,7 @@ 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			as Defaultable+import qualified	ToolShed.Defaultable  -- | The number of terms in a series. type Terms	= Int@@ -60,12 +60,12 @@ 	| TaylorSeries Terms		-- ^ <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series>. 	deriving (Eq, Read, Show) -instance Defaultable.Defaultable Algorithm	where+instance ToolShed.Defaultable.Defaultable Algorithm	where 	defaultValue	= 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-	= Math.SquareRoot.Estimate +	= Math.SquareRoot.Estimate 	-> Math.Precision.DecimalDigits	-- ^ The required precision. 	-> operand			-- ^ The value for which to find the /square-root/. 	-> Math.SquareRoot.Result
src/Factory/Math/Pi.hs view
@@ -30,7 +30,7 @@  import qualified	Data.Ratio import qualified	Factory.Math.Precision	as Math.Precision-import qualified	ToolShed.Defaultable	as Defaultable+import qualified	ToolShed.Defaultable  {- | 	* Defines the methods expected of a /Pi/-algorithm.@@ -51,7 +51,7 @@  	openS	:: algorithm -> Math.Precision.DecimalDigits -> String			-- ^ Returns the value of /Pi/ as a decimal 'String'. 	openS _ 1	= "3"-	openS algorithm decimalDigits	+	openS algorithm decimalDigits 		| decimalDigits <= 0	= "" 		| decimalDigits <= 16	= take (succ decimalDigits) $ show (pi :: Double) 		| otherwise		= "3." ++ tail (show $ openI algorithm decimalDigits)	--Insert a decimal point.@@ -66,13 +66,13 @@ 	deriving (Eq, Read, Show)  instance (-	Defaultable.Defaultable agm,-	Defaultable.Defaultable bbp,-	Defaultable.Defaultable borwein,-	Defaultable.Defaultable ramanujan,-	Defaultable.Defaultable spigot- )  => Defaultable.Defaultable (Category agm bbp borwein ramanujan spigot)	where-	defaultValue	= BBP Defaultable.defaultValue+	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 ( 	Algorithmic agm,
src/Factory/Math/Precision.hs view
@@ -95,7 +95,7 @@ 	-> i getTermsRequired _ 0		= 0 getTermsRequired convergenceRate requiredDecimalDigits-	| convergenceRate <= 0 || convergenceRate >= 1	= error $ "Factory.Math.Precision.getTermsRequired:\t (0 < convergence-rate < 1); " ++ show convergenceRate+	| convergenceRate <= 0 || convergenceRate >= 1	= error $ "Factory.Math.Precision.getTermsRequired:\t(0 < convergence-rate < 1); " ++ show convergenceRate 	| requiredDecimalDigits < 0			= error $ "Factory.Math.Precision.getTermsRequired:\t'requiredDecimalDigits' must be positive; " ++ show requiredDecimalDigits 	| otherwise					= ceiling $ fromIntegral requiredDecimalDigits / negate (logBase 10 convergenceRate) 
src/Factory/Math/Probability.hs view
@@ -39,9 +39,9 @@ import			Control.Arrow((***), (&&&)) import qualified	Factory.Data.Interval	as Data.Interval import qualified	System.Random-import qualified	ToolShed.ListPlus	as ListPlus-import qualified	ToolShed.Pair		as Pair-import qualified	ToolShed.SelfValidate	as SelfValidate+import qualified	ToolShed.Data.List+import qualified	ToolShed.Data.Pair+import qualified	ToolShed.SelfValidate  -- | Describes a /continuous probability-distribution/; <http://en.wikipedia.org/wiki/List_of_probability_distributions#Continuous_distributions>. data ContinuousDistribution f@@ -49,15 +49,16 @@ 	| NormalDistribution f f				-- ^ Defines a /Normal/-distribution with a particular /mean/ and /variance/; <http://en.wikipedia.org/wiki/Normal_distribution>. 	deriving (Eq, Read, Show) -instance (Num a, Ord a) => SelfValidate.SelfValidator (ContinuousDistribution a)	where-	isValid (UniformDistribution interval)	= not $ Data.Interval.isReversed interval-	isValid (NormalDistribution _ v)	= v >= 0+instance (Num a, Ord a) => ToolShed.SelfValidate.SelfValidator (ContinuousDistribution a)	where+	getErrors distribution	= ToolShed.SelfValidate.extractErrors $ case distribution of+		UniformDistribution interval	-> [(Data.Interval.isReversed interval, "Reversed interval='" ++ show interval ++ "'.")]+		NormalDistribution _ v		-> [(v < 0, "Negative variance=" ++ show v ++ ".")]  -- | Describes a /discrete probability-distribution/; <http://en.wikipedia.org/wiki/List_of_probability_distributions#Discrete_distributions>. data DiscreteDistribution f	= PoissonDistribution f	deriving (Eq, Read, Show) -instance (Num f, Ord f) => SelfValidate.SelfValidator (DiscreteDistribution f)	where-	isValid (PoissonDistribution lambda)	= lambda >= 0+instance (Num f, Ord f) => ToolShed.SelfValidate.SelfValidator (DiscreteDistribution f)	where+	getErrors (PoissonDistribution lambda)	= ToolShed.SelfValidate.extractErrors [(lambda < 0, "Negative lambda=" ++ show lambda ++ ".")]  {- | 	* Converts a pair of independent /uniformly distributed/ random numbers, within the /semi-closed/ /unit interval/ /(0 .. 1]/,@@ -69,11 +70,11 @@ 	=> (f, f)	-- ^ Independent, /uniformly distributed/ random numbers, which must be within the /semi-closed unit interval/, /(0, 1]/. 	-> (f, f)	-- ^ Independent, /normally distributed/ random numbers, with standardized /mean/=0 and /variance/=1. boxMullerTransform cartesian-	| not . Pair.both $ Pair.mirror inSemiClosedUnitInterval cartesian	= error $ "Factory.Math.Probability.boxMullerTransform:\tspecified Cartesian coordinates, must be within semi-closed unit-interval (0, 1]; " ++ show cartesian+	| not . uncurry (&&) $ ToolShed.Data.Pair.mirror inSemiClosedUnitInterval cartesian	= error $ "Factory.Math.Probability.boxMullerTransform:\tspecified Cartesian coordinates, must be within semi-closed unit-interval (0, 1]; " ++ show cartesian 	| otherwise								= polarToCartesianTransform $ (sqrt . negate . (* 2) . log *** (* 2) . (* pi)) cartesian 	where 		inSemiClosedUnitInterval :: (Num n, Ord n) => n -> Bool-		inSemiClosedUnitInterval	= Pair.both . ((> 0) &&& (<= 1))+		inSemiClosedUnitInterval	= uncurry (&&) . ((> 0) &&& (<= 1))  		polarToCartesianTransform :: Floating f => (f, f) -> (f, f) 		polarToCartesianTransform	= uncurry (*) . Control.Arrow.second cos &&& uncurry (*) . Control.Arrow.second sin@@ -92,8 +93,8 @@  	* <http://en.wikipedia.org/wiki/Normal_distribution>, <http://mathworld.wolfram.com/NormalDistribution.html>. -}-generateStandardizedNormalDistribution :: (System.Random.RandomGen g, RealFloat f, System.Random.Random f) => g -> [f]-generateStandardizedNormalDistribution	= ListPlus.linearise . uncurry (zipWith $ curry boxMullerTransform) . Pair.mirror (+generateStandardizedNormalDistribution :: (System.Random.RandomGen randomGen, RealFloat f, System.Random.Random f) => randomGen -> [f]+generateStandardizedNormalDistribution	= ToolShed.Data.List.linearise . uncurry (zipWith $ curry boxMullerTransform) . ToolShed.Data.Pair.mirror ( 	System.Random.randomRs (minPositiveFloat undefined, 1)  ) . System.Random.split @@ -102,21 +103,21 @@ reProfile mean standardDeviation = map ((+ mean) . (* standardDeviation))  {- |-	* Generates a random sample-population, with the specified continuous probability-distribution. +	* Generates a random sample-population, with the specified continuous probability-distribution.  	* When a /Normal distribution/ is requested, 	the generated population will only tend towards the requested /mean/ and /variance/ of, as the sample-size tends towards infinity. 	Whilst one could arrange for these criteria to be precisely met for any sample-size, the sample would lose a degree of randomness as a result. -}-generateContinuousPopulation :: (RealFloat f, System.Random.Random f, System.Random.RandomGen g)+generateContinuousPopulation :: (RealFloat f, System.Random.Random f, System.Random.RandomGen randomGen) 	=> Int	-- ^ number of items. 	-> ContinuousDistribution f-	-> g	-- ^ A generator of /uniformly distributed/ random numbers.+	-> randomGen	-- ^ A generator of /uniformly distributed/ random numbers. 	-> [f] generateContinuousPopulation 0 _ _				= [] generateContinuousPopulation populationSize probabilityDistribution randomGen-	| populationSize < 0					= error $ "Factory.Math.Probability.generateDiscretePopulation:\tinvalid population-size=" ++ show populationSize-	| not $ SelfValidate.isValid probabilityDistribution	= error $ "Factory.Math.Probability.generateContinuousPopulation:\tinvalid; '" ++ show probabilityDistribution ++ "'"+	| populationSize < 0						= error $ "Factory.Math.Probability.generateDiscretePopulation:\tinvalid population-size=" ++ show populationSize+	| not $ ToolShed.SelfValidate.isValid probabilityDistribution	= error $ "Factory.Math.Probability.generateContinuousPopulation:\t" ++ ToolShed.SelfValidate.getFirstError probabilityDistribution 	| otherwise						= take populationSize $ ( 		case probabilityDistribution of 			UniformDistribution interval				-> System.Random.randomRs interval@@ -137,11 +138,11 @@ generatePoissonDistribution :: ( 	RealFloat		lambda, 	System.Random.Random	lambda,-	System.Random.RandomGen	g,+	System.Random.RandomGen	randomGen, 	Integral		events  ) 	=> lambda	-- ^ Defines the required approximate value of both /mean/ and /variance/.-	-> g+	-> randomGen 	-> [events] generatePoissonDistribution lambda 	| lambda < 0	= error $ "Factory.Math.Probability.generatePoissonDistribution:\tinvalid lambda=" ++ show lambda@@ -158,23 +159,23 @@ 			) (negate 1, 1) . System.Random.randomRs (0, 1) *** generator {-recurse-} 		 ) . System.Random.split --- | Generates a random sample-population, with the specified discrete probability-distribution. +-- | Generates a random sample-population, with the specified discrete probability-distribution. generateDiscretePopulation :: ( 	Ord			f, 	RealFloat		f, 	System.Random.Random	f,-	System.Random.RandomGen	g,+	System.Random.RandomGen	randomGen, 	Integral		events  ) 	=> Int	-- ^ number of items. 	-> DiscreteDistribution f-	-> g	-- ^ A generator of /uniformly distributed/ random numbers.+	-> randomGen	-- ^ A generator of /uniformly distributed/ random numbers. 	-> [events] generateDiscretePopulation 0 _ _				= [] generateDiscretePopulation populationSize probabilityDistribution randomGen-	| populationSize < 0					= error $ "Factory.Math.Probability.generateDiscretePopulation:\tinvalid populationSize=" ++ show populationSize-	| not $ SelfValidate.isValid probabilityDistribution	= error $ "Factory.Math.Probability.generateDiscretePopulation:\tinvalid; '" ++ show probabilityDistribution ++ "'"-	| otherwise						= take populationSize $ (+	| populationSize < 0						= error $ "Factory.Math.Probability.generateDiscretePopulation:\tinvalid populationSize=" ++ show populationSize+	| not $ ToolShed.SelfValidate.isValid probabilityDistribution	= error $ "Factory.Math.Probability.generateDiscretePopulation:\t" ++ ToolShed.SelfValidate.getFirstError probabilityDistribution+	| otherwise							= take populationSize $ ( 		case probabilityDistribution of 			PoissonDistribution lambda	-> generatePoissonDistribution lambda 	) randomGen
src/Factory/Math/SquareRoot.hs view
@@ -91,7 +91,7 @@ 		decimalDigits	= 16	-- <http://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.+	* The signed difference between the /square/ of an estimate for the /square-root/ of a value, and that value.  	* Positive when the estimate is too low. @@ -100,7 +100,7 @@ getDiscrepancy :: Real operand => operand -> Result -> Result getDiscrepancy y x	= realToFrac y - Math.Power.square x --- | 'True' if the specified estimate for the /square-root/, is precise.+-- | True if the specified estimate for the /square-root/, is precise. isPrecise :: Real operand => operand -> Result -> Bool isPrecise y x	= getDiscrepancy y x == 0 
src/Factory/Math/Statistics.hs view
@@ -34,6 +34,7 @@  import			Control.Arrow((***)) import			Control.Parallel(par, pseq)+import qualified	Data.Foldable import qualified	Data.List import qualified	Data.Ratio import qualified	Factory.Math.Factorial			as Math.Factorial@@ -41,49 +42,51 @@ import qualified	Factory.Math.Power			as Math.Power  {- |-	* Determines the /mean/ of the specified list of numbers; <http://en.wikipedia.org/wiki/Mean>.+	* Determines the /mean/ of the specified numbers; <http://en.wikipedia.org/wiki/Mean>.  	* Should the caller define the result-type as 'Data.Ratio.Rational', then it will be free from rounding-errors. -}-getMean :: (Real r, Fractional result) => [r] -> result-getMean []	= error "Factory.Math.Statistics.getMean:\tundefined result for null-list."-getMean [x]	= realToFrac x	--Not necessary, but a shortcut for this special case.-getMean l	= uncurry (/) . (realToFrac *** fromIntegral) $ foldr (\s -> (+ s) *** succ) (0, 0 :: Int) l+getMean :: (Data.Foldable.Foldable f, Real r, Fractional result) => f r -> result+getMean x+	| denominator == 0	= error "Factory.Math.Statistics.getMean:\tno data => no result."+	| otherwise		= realToFrac numerator / fromIntegral denominator+	where+		(numerator, denominator)	= Data.Foldable.foldr (\s -> (+ s) *** succ) (0, 0 :: Int) x  {- | 	* Measures the /dispersion/ of a /population/ of results from the /mean/ value; <http://en.wikipedia.org/wiki/Statistical_dispersion>.  	* Should the caller define the result-type as 'Data.Ratio.Rational', then it will be free from rounding-errors. -}-getDispersionFromMean :: (Real r, Fractional result) => (Data.Ratio.Rational -> Data.Ratio.Rational) -> [r] -> result-getDispersionFromMean _ []		= error "Factory.Math.Statistics.getDispersionFromMean:\tundefined result for null-list."-getDispersionFromMean _ [_]		= 0	--Not necessary, but a shortcut for this special case.-getDispersionFromMean weighting l	= getMean $ map (weighting . (+ negate (getMean l :: Data.Ratio.Rational)) . realToFrac) l+getDispersionFromMean :: (Data.Foldable.Foldable f, Functor f, Real r, Fractional result) => (Data.Ratio.Rational -> Data.Ratio.Rational) -> f r -> result+getDispersionFromMean weight x	= getMean $ fmap (weight . (+ negate mean) . realToFrac) x	where+	mean :: Data.Ratio.Rational+	mean	= getMean x  {- |-	* Determines the exact /variance/ of the specified list of numbers; <http://en.wikipedia.org/wiki/Variance>.+	* Determines the exact /variance/ of the specified numbers; <http://en.wikipedia.org/wiki/Variance>.  	* Should the caller define the result-type as 'Data.Ratio.Rational', then it will be free from rounding-errors. -}-getVariance :: (Real r, Fractional result) => [r] -> result+getVariance :: (Data.Foldable.Foldable f, Functor f, Real r, Fractional variance) => f r -> variance getVariance	= getDispersionFromMean Math.Power.square --- | Determines the /standard-deviation/ of the specified list of numbers; <http://en.wikipedia.org/wiki/Standard_deviation>.-getStandardDeviation :: (Real r, Floating result) => [r] -> result+-- | Determines the /standard-deviation/ of the specified numbers; <http://en.wikipedia.org/wiki/Standard_deviation>.+getStandardDeviation :: (Data.Foldable.Foldable f, Functor f, Real r, Floating result) => f r -> result getStandardDeviation	= sqrt . getVariance  {- |-	* Determines the /average absolute deviation/ of the specified list of numbers; <http://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation>.+	* Determines the /average absolute deviation/ of the specified numbers; <http://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation>.  	* Should the caller define the result-type as 'Data.Ratio.Rational', then it will be free from rounding-errors. -}-getAverageAbsoluteDeviation :: (Real r, Fractional result) => [r] -> result-getAverageAbsoluteDeviation 	= getDispersionFromMean abs+getAverageAbsoluteDeviation :: (Data.Foldable.Foldable f, Functor f, Real r, Fractional result) => f r -> result+getAverageAbsoluteDeviation	= getDispersionFromMean abs --- | Determines the /coefficient-of-variance/ of the specified list of numbers; <http://en.wikipedia.org/wiki/Coefficient_of_variation>.-getCoefficientOfVariance :: (Real r, Floating result) => [r] -> result+-- | Determines the /coefficient-of-variance/ of the specified numbers; <http://en.wikipedia.org/wiki/Coefficient_of_variation>.+getCoefficientOfVariance :: (Data.Foldable.Foldable f, Functor f, Real r, Floating result) => f r -> result getCoefficientOfVariance l-	| mean == 0	= error "Factory.Math.Statistics.getCoefficientOfVariance:\tundefined if mean is zero." +	| mean == 0	= error "Factory.Math.Statistics.getCoefficientOfVariance:\tundefined if mean is zero." 	| otherwise	= getStandardDeviation l / abs mean 	where 		mean	= getMean l
src/Factory/Math/Summation.hs view
@@ -35,7 +35,7 @@  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies-import qualified	ToolShed.ListPlus		as ListPlus+import qualified	ToolShed.Data.List #endif  {- |@@ -50,7 +50,7 @@ -} sum' :: (Num n, Control.DeepSeq.NFData n) #if MIN_VERSION_toolshed(11,1,1)-	=> ListPlus.ChunkLength+	=> ToolShed.Data.List.ChunkLength #else 	=> Int	-- ^ The Chunk-length. #endif@@ -64,7 +64,7 @@ 		slave :: (Num n, Control.DeepSeq.NFData n) => [n] -> n 		slave []	= 0 		slave [x]	= x-		slave l		= slave {-recurse-} . Control.Parallel.Strategies.parMap Control.Parallel.Strategies.rdeepseq sum $ ListPlus.chunk chunkLength l+		slave l		= slave {-recurse-} . Control.Parallel.Strategies.parMap Control.Parallel.Strategies.rdeepseq sum $ ToolShed.Data.List.chunk chunkLength l #else sum' _	= sum #endif@@ -91,7 +91,7 @@ {-# INLINE sumR #-}	--This makes a staggering difference to calls from other modules. sumR :: (Integral i, Control.DeepSeq.NFData i) #if MIN_VERSION_toolshed(11,1,1)-	=> ListPlus.ChunkLength+	=> ToolShed.Data.List.ChunkLength #else 	=> Int	-- ^ The Chunk-length. #endif@@ -110,4 +110,4 @@ #else 				map #endif-				sumR' $ ListPlus.chunk chunkLength l+				sumR' $ ToolShed.Data.List.chunk chunkLength l
src/Factory/Test/CommandOptions.hs view
@@ -29,14 +29,14 @@ 	setVerbose ) where -import ToolShed.Defaultable	as Defaultable+import qualified	ToolShed.Defaultable  -- | Declare a record used to contain command-line options. data CommandOptions	= MkCommandOptions { 	verbose	:: Bool	-- ^ Whether additional informative output should be generated, where applicable. } -instance Defaultable CommandOptions	where+instance ToolShed.Defaultable.Defaultable CommandOptions	where 	defaultValue	= MkCommandOptions { verbose = False }  -- | Mutator.
src/Factory/Test/Performance/Factorial.hs view
@@ -31,16 +31,16 @@ import qualified	Control.DeepSeq import qualified	Data.List import qualified	Factory.Math.Factorial	as Math.Factorial-import qualified	ToolShed.TimePure	as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required by 'Math.Factorial.factorial'. factorialPerformance :: (Math.Factorial.Algorithmic algorithm, Control.DeepSeq.NFData i, Integral i) => algorithm -> i -> IO (Double, i)-factorialPerformance algorithm	= TimePure.getCPUSeconds . Math.Factorial.factorial algorithm+factorialPerformance algorithm	= ToolShed.System.TimePure.getCPUSeconds . Math.Factorial.factorial algorithm  -- | Measures the CPU-time required by a naive implementation. factorialPerformanceControl :: (Control.DeepSeq.NFData i, Integral i) => i -> IO (Double, i)---factorialPerformanceControl i	= TimePure.getCPUSeconds $ product [1 .. i]	--CAVEAT: too lazy.-factorialPerformanceControl i	= TimePure.getCPUSeconds $ Data.List.foldl' (*) 1 [2 .. i]+--factorialPerformanceControl i	= ToolShed.System.TimePure.getCPUSeconds $ product [1 .. i]	--CAVEAT: too lazy.+factorialPerformanceControl i	= ToolShed.System.TimePure.getCPUSeconds $ Data.List.foldl' (*) 1 [2 .. i]  {- | 	* Measure the CPU-time required by 'Math.Factorial.factorial', against an exponentially increasing operand.
src/Factory/Test/Performance/Hyperoperation.hs view
@@ -28,19 +28,19 @@ ) where  import qualified	Factory.Math.Hyperoperation	as Math.Hyperoperation-import qualified	ToolShed.TimePure		as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required by 'Math.Hyperoperation.hyperoperation'. hyperoperationPerformance :: Integral rank => rank -> Math.Hyperoperation.Base -> Math.Hyperoperation.HyperExponent -> IO (Double, Integer)-hyperoperationPerformance rank base	= TimePure.getCPUSeconds . Math.Hyperoperation.hyperoperation rank base+hyperoperationPerformance rank base	= ToolShed.System.TimePure.getCPUSeconds . Math.Hyperoperation.hyperoperation rank base  {- | 	* Measure the CPU-time required by 'Math.Hyperoperation.hyperoperation', against a linearly increasing /rank/.  	* CAVEAT: nothing is returned, since the result is printed ... and it never terminates. -}-hyperoperationPerformanceGraphRank ::-	Bool	-- ^ Verbose.+hyperoperationPerformanceGraphRank+	:: Bool	-- ^ Verbose. 	-> Math.Hyperoperation.Base 	-> Math.Hyperoperation.HyperExponent 	-> IO ()
src/Factory/Test/Performance/Pi.hs view
@@ -38,7 +38,7 @@ 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	ToolShed.TimePure					as TimePure+import qualified	ToolShed.System.TimePure  -- | The type of a /Pi/-algorithm, including where required, the algorithm for /square-root/s and /factorial/s. type Category squareRootAlgorithm factorialAlgorithm = Math.Pi.Category (@@ -54,7 +54,7 @@ 	Math.SquareRoot.Algorithmic	squareRootAlgorithm, 	Math.Factorial.Algorithmic	factorialAlgorithm  ) => Category squareRootAlgorithm factorialAlgorithm -> Math.Precision.DecimalDigits -> IO (Double, String)-piPerformance category = TimePure.getCPUSeconds . Math.Pi.openS category+piPerformance category = ToolShed.System.TimePure.getCPUSeconds . Math.Pi.openS category  {- | 	* Measures the CPU-time required to determine /Pi/ to an exponentially increasing precision-requirement.
src/Factory/Test/Performance/Primality.hs view
@@ -30,17 +30,17 @@ import qualified	Control.DeepSeq import qualified	Factory.Math.Fibonacci	as Math.Fibonacci import qualified	Factory.Math.Primality	as Math.Primality-import qualified	ToolShed.TimePure	as TimePure+import qualified	ToolShed.System.TimePure  -- | 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		= error $ "Factory.Test.Performance.Primality.carmichaelNumbersPerformance:\tnegative number; " ++ show i-	| otherwise	= TimePure.getCPUSeconds . take i $ Math.Primality.carmichaelNumbers primalityAlgorithm+	| 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. isPrimePerformance :: (Control.DeepSeq.NFData i, Integral i) => Math.Primality.Algorithmic primalityAlgorithm => primalityAlgorithm -> i -> IO (Double, Bool)-isPrimePerformance primalityAlgorithm	= TimePure.getCPUSeconds . Math.Primality.isPrime primalityAlgorithm+isPrimePerformance primalityAlgorithm	= ToolShed.System.TimePure.getCPUSeconds . Math.Primality.isPrime primalityAlgorithm  {- | 	* Measures the CPU-time required to determine whether /prime-indexed Fibonacci-numbers/ are actually /prime/.
src/Factory/Test/Performance/PrimeFactorisation.hs view
@@ -29,11 +29,11 @@ import qualified	Factory.Data.PrimeFactors	as Data.PrimeFactors import qualified	Factory.Math.Fibonacci		as Math.Fibonacci import qualified	Factory.Math.PrimeFactorisation	as Math.PrimeFactorisation-import qualified	ToolShed.TimePure		as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required to prime-factorise the specified integer, which is returned together with the resulting list of factors. primeFactorsPerformance :: Math.PrimeFactorisation.Algorithmic algorithm => algorithm -> Integer -> IO (Double, Data.PrimeFactors.Factors Integer Int)-primeFactorsPerformance algorithm	= TimePure.getCPUSeconds . Math.PrimeFactorisation.primeFactors algorithm+primeFactorsPerformance algorithm	= ToolShed.System.TimePure.getCPUSeconds . Math.PrimeFactorisation.primeFactors algorithm  {- | 	* Measure the CPU-time required by 'Math.PrimeFactorisation.primeFactors',
src/Factory/Test/Performance/Primes.hs view
@@ -28,8 +28,8 @@ import qualified	Control.DeepSeq import qualified	Data.Array.IArray import qualified	Factory.Math.Primes	as Math.Primes-import qualified	ToolShed.TimePure	as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required by 'Math.Primes.primes', to find the specified prime. primesPerformance :: (Math.Primes.Algorithmic algorithm, Control.DeepSeq.NFData i, Data.Array.IArray.Ix i, Integral i) => algorithm -> Int -> IO (Double, i)-primesPerformance algorithm	= TimePure.getCPUSeconds . (Math.Primes.primes algorithm !!)+primesPerformance algorithm	= ToolShed.System.TimePure.getCPUSeconds . (Math.Primes.primes algorithm !!)
src/Factory/Test/Performance/SquareRoot.hs view
@@ -29,11 +29,11 @@ import qualified	Control.Arrow import qualified	Factory.Math.Precision	as Math.Precision import qualified	Factory.Math.SquareRoot	as Math.SquareRoot-import qualified	ToolShed.TimePure	as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required by 'Math.SquareRoot.squareRootFrom', which is returned together with the approximate rational result. squareRootPerformance :: (Math.SquareRoot.Algorithmic algorithm, Real operand) => algorithm -> operand -> Math.Precision.DecimalDigits -> IO (Double, Math.SquareRoot.Result)-squareRootPerformance algorithm operand requiredDecimalDigits = TimePure.getCPUSeconds $ Math.SquareRoot.squareRoot algorithm requiredDecimalDigits operand+squareRootPerformance algorithm operand requiredDecimalDigits = ToolShed.System.TimePure.getCPUSeconds $ Math.SquareRoot.squareRoot algorithm requiredDecimalDigits operand  {- | 	* Measures the CPU-time required by 'Math.SquareRoot.squareRootFrom', and the resulting accuracy,
src/Factory/Test/Performance/Statistics.hs view
@@ -28,7 +28,7 @@ import qualified	Control.DeepSeq import qualified	Factory.Math.Factorial	as Math.Factorial import qualified	Factory.Math.Statistics	as Math.Statistics-import qualified	ToolShed.TimePure	as TimePure+import qualified	ToolShed.System.TimePure  -- | Measures the CPU-time required by 'Math.Statistics.nCr'. nCrPerformance :: (Math.Factorial.Algorithmic factorialAlgorithm, Control.DeepSeq.NFData i, Integral i)@@ -36,5 +36,5 @@ 	-> i	-- ^ The total number from which to select. 	-> i	-- ^ The number of items in a sample. 	-> IO (Double, i)-nCrPerformance factorialAlgorithm n r	= TimePure.getCPUSeconds $ Math.Statistics.nCr factorialAlgorithm n r+nCrPerformance factorialAlgorithm n r	= ToolShed.System.TimePure.getCPUSeconds $ Math.Statistics.nCr factorialAlgorithm n r 
src/Factory/Test/QuickCheck/MonicPolynomial.hs view
@@ -47,7 +47,7 @@ 	arbitrary	= do 		polynomial	<- Test.QuickCheck.arbitrary -		return . Data.MonicPolynomial.mkMonicPolynomial $ ((1, succ $ Data.Polynomial.getDegree polynomial) :) `Data.Polynomial.lift` polynomial+		return {-to Gen-monad-} . Data.MonicPolynomial.mkMonicPolynomial $ ((1, succ $ Data.Polynomial.getDegree polynomial) :) `Data.Polynomial.lift` polynomial #if !(MIN_VERSION_QuickCheck(2,1,0)) 	coarbitrary	= undefined	--CAVEAT: stops warnings from ghc. #endif
src/Factory/Test/QuickCheck/PerfectPower.hs view
@@ -25,6 +25,7 @@ 	quickChecks ) where +import qualified	Data.Maybe import qualified	Factory.Math.PerfectPower	as Math.PerfectPower import qualified	Factory.Math.Power		as Math.Power import qualified	Test.QuickCheck@@ -40,7 +41,8 @@ 		prop_maybeSquareNumber, prop_notSquare, prop_rewriteRule :: Integer -> Test.QuickCheck.Property 		prop_maybeSquareNumber i	= Test.QuickCheck.label "prop_maybeSquareNumber" $ Math.PerfectPower.maybeSquareNumber (Math.Power.square i) == Just (abs i) -		prop_notSquare i	= abs i > 0	==> Test.QuickCheck.label "prop_notSquare" $ Math.PerfectPower.maybeSquareNumber (succ $ i ^ (10 {-promote rounding-error using big number-} :: Int)) == Nothing+		prop_notSquare i	= abs i > 0	==> Test.QuickCheck.label "prop_notSquare" . Data.Maybe.isNothing $ Math.PerfectPower.maybeSquareNumber (succ $ i ^ (10 {-promote rounding-error using big number-} :: Int))+ 		prop_rewriteRule i	= Test.QuickCheck.label "prop_rewriteRule" $ Math.PerfectPower.isPerfectPower i' == Math.PerfectPower.isPerfectPower (fromIntegral i' :: Int)	where 			i'	= abs i 
src/Factory/Test/QuickCheck/Primes.hs view
@@ -42,7 +42,7 @@ import qualified	Factory.Math.Primes				as Math.Primes import qualified	Test.QuickCheck import			Test.QuickCheck((==>))-import qualified	ToolShed.Defaultable				as Defaultable+import qualified	ToolShed.Defaultable  instance Test.QuickCheck.Arbitrary Math.Implementations.Primes.Algorithm.Algorithm	where 	arbitrary	= Test.QuickCheck.oneof [@@ -57,7 +57,7 @@ isPrime :: (Control.DeepSeq.NFData i, Integral i) => i -> Bool isPrime	= Math.Primality.isPrime primalityAlgorithm	where 	primalityAlgorithm :: Math.Implementations.Primality.Algorithm Math.Implementations.PrimeFactorisation.Algorithm-	primalityAlgorithm	= Defaultable.defaultValue+	primalityAlgorithm	= ToolShed.Defaultable.defaultValue  upperBound :: Math.Implementations.Primes.Algorithm.Algorithm -> Int -> Int upperBound algorithm i	= mod i $ if algorithm == Math.Implementations.Primes.Algorithm.TurnersSieve@@ -65,7 +65,7 @@ 	else 65536  defaultAlgorithm :: Math.Implementations.Primes.Algorithm.Algorithm-defaultAlgorithm	= Defaultable.defaultValue+defaultAlgorithm	= ToolShed.Defaultable.defaultValue  -- | Defines invariant properties. quickChecks :: IO ()
src/Factory/Test/QuickCheck/Probability.hs view
@@ -29,22 +29,19 @@ import qualified	Factory.Math.Probability		as Math.Probability import qualified	Factory.Math.Statistics			as Math.Statistics import			Factory.Test.QuickCheck.Factorial()-import qualified	ToolShed.Pair				as Pair import qualified	System.Random import qualified	Test.QuickCheck import			Test.QuickCheck((==>))+import qualified	ToolShed.Data.Pair  -- | Defines invariant properties. quickChecks :: IO () quickChecks	= do 	randomGen	<- System.Random.getStdGen -	(-		Test.QuickCheck.quickCheck (prop_normalDistribution randomGen)-		>> Test.QuickCheck.quickCheck (prop_poissonDistribution randomGen)-	 ) where-		prop_normalDistribution :: System.Random.RandomGen g => g -> (Double, Double) -> Test.QuickCheck.Property-		prop_normalDistribution randomGen (mean, variance)	= variance' /= 0	==> Test.QuickCheck.label "prop_normalDistribution" . Pair.both . Pair.mirror (+	Test.QuickCheck.quickCheck (prop_normalDistribution randomGen) >> Test.QuickCheck.quickCheck (prop_poissonDistribution randomGen)	where+		prop_normalDistribution :: System.Random.RandomGen randomGen => randomGen -> (Double, Double) -> Test.QuickCheck.Property+		prop_normalDistribution randomGen (mean, variance)	= variance' /= 0	==> Test.QuickCheck.label "prop_normalDistribution" . uncurry (&&) . ToolShed.Data.Pair.mirror ( 			(< (0.1 :: Double)) . abs	--Generous tolerance. 		 ) . ( 			Math.Statistics.getMean &&& pred . Math.Statistics.getStandardDeviation@@ -53,8 +50,8 @@ 		 ) $ Math.Probability.generateContinuousPopulation 1000 (Math.Probability.NormalDistribution mean variance') randomGen	where 			variance'	= abs variance -		prop_poissonDistribution :: System.Random.RandomGen g => g -> Int -> Test.QuickCheck.Property-		prop_poissonDistribution randomGen lambda	= lambda' /= 0	==> Test.QuickCheck.label "prop_poissonDistribution" . Pair.both . Pair.mirror (+		prop_poissonDistribution :: System.Random.RandomGen randomGen => randomGen -> Int -> Test.QuickCheck.Property+		prop_poissonDistribution randomGen lambda	= lambda' /= 0	==> Test.QuickCheck.label "prop_poissonDistribution" . uncurry (&&) . ToolShed.Data.Pair.mirror ( 			(< (0.1 :: Double)) . abs	--Tolerance. 		 ) . ( 			Math.Statistics.getMean &&& pred . Math.Statistics.getStandardDeviation@@ -65,5 +62,4 @@ 		 ) where 			lambda' :: Double 			lambda'	= fromIntegral $ mod lambda 1000- 
src/Factory/Test/QuickCheck/QuickChecks.hs view
@@ -45,7 +45,8 @@  -- | Run the /quickChecks/-functions for modules supporting this feature. run :: IO ()-run	= putStrLn "ArithmeticGeometricMean"	>> Factory.Test.QuickCheck.ArithmeticGeometricMean.quickChecks+run+	= putStrLn "ArithmeticGeometricMean"	>> Factory.Test.QuickCheck.ArithmeticGeometricMean.quickChecks 	>> putStrLn "Factorial"			>> Factory.Test.QuickCheck.Factorial.quickChecks 	>> putStrLn "Hyperoperation"		>> Factory.Test.QuickCheck.Hyperoperation.quickChecks 	>> putStrLn "Interval"			>> Factory.Test.QuickCheck.Interval.quickChecks
src/Factory/Test/QuickCheck/Statistics.hs view
@@ -25,9 +25,12 @@ 	quickChecks ) where +import qualified	Data.Array import qualified	Data.List+import qualified	Data.Map import qualified	Data.Numbers.Primes import qualified	Data.Ratio+import qualified	Data.Set import qualified	Factory.Math.Implementations.Factorial	as Math.Implementations.Factorial import qualified	Factory.Math.Power			as Math.Power import qualified	Factory.Math.Statistics			as Math.Statistics@@ -41,7 +44,7 @@ 	>> Test.QuickCheck.quickCheck `mapM_` [prop_symmetry, prop_prime] 	>> Test.QuickCheck.quickCheck `mapM_` [prop_nP0, prop_nP1] 	>> Test.QuickCheck.quickCheck `mapM_` [prop_zeroVariance, prop_zeroAverageAbsoluteDeviation]-	>> Test.QuickCheck.quickCheck `mapM_` [prop_balance, prop_varianceRelocated, prop_varianceScaled, prop_varianceOrder, prop_equivalence]+	>> Test.QuickCheck.quickCheck `mapM_` [prop_balance, prop_varianceRelocated, prop_varianceScaled, prop_varianceOrder, prop_equivalence, prop_varianceOfArray, prop_varianceOfMap, prop_meanOfSet]  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@@ -70,10 +73,14 @@ 	prop_zeroVariance x			= Test.QuickCheck.label "prop_zeroVariance" $ Math.Statistics.getVariance (replicate 32 x) == (0 :: Data.Ratio.Rational) 	prop_zeroAverageAbsoluteDeviation x	= Test.QuickCheck.label "zeroAverageAbsoluteDeviation" $ Math.Statistics.getAverageAbsoluteDeviation (replicate 32 x) == (0 :: Data.Ratio.Rational) -	prop_balance, prop_varianceRelocated, prop_varianceScaled, prop_varianceOrder, prop_equivalence :: [Integer] -> Test.QuickCheck.Property+	prop_balance, prop_varianceRelocated, prop_varianceScaled, prop_varianceOrder, prop_equivalence, prop_varianceOfMap, prop_meanOfSet, prop_varianceOfArray :: [Integer] -> Test.QuickCheck.Property 	prop_balance l			= not (null l)	==> Test.QuickCheck.label "prop_balance" . (== 0) . abs . sum $ map (\i -> fromIntegral i - (Math.Statistics.getMean l :: Data.Ratio.Rational)) l 	prop_varianceRelocated l	= not (null l)	==> Test.QuickCheck.label "prop_varianceRelocated" $ (Math.Statistics.getVariance l :: Data.Ratio.Rational) == Math.Statistics.getVariance (map succ l) 	prop_varianceScaled l		= not (null l)	==> Test.QuickCheck.label "prop_varianceScaled" $ (4 * Math.Statistics.getVariance l :: Data.Ratio.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) :: Data.Ratio.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 :: Data.Ratio.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 :: Data.Ratio.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 :: Data.Ratio.Rational)+	prop_meanOfSet l		= not (null l')	==> Test.QuickCheck.label "prop_meanOfSet" $ Math.Statistics.getMean (Data.Set.fromList l') == (Math.Statistics.getMean l' :: Data.Ratio.Rational)	where+		l'	= Data.List.nub l 
src/Main.hs view
@@ -55,12 +55,12 @@ import qualified	Factory.Test.Performance.Statistics		as Test.Performance.Statistics import qualified	Factory.Test.QuickCheck.QuickChecks		as Test.QuickCheck.QuickChecks import qualified	Paths_factory					as Paths	--Either local stub, or package-instance autogenerated by 'Setup.hs build'.+import qualified	System.Console.GetOpt				as G import qualified	System.Environment import qualified	System.Exit-import qualified	System.Console.GetOpt				as G import qualified	System.IO import qualified	System.IO.Error-import qualified	ToolShed.Defaultable				as Defaultable+import qualified	ToolShed.Defaultable  -- Local convenience definitions. type PrimalityAlgorithm		= Math.Implementations.Primality.Algorithm Math.Implementations.PrimeFactorisation.Algorithm@@ -83,6 +83,10 @@ 		optDescrList :: [G.OptDescr CommandLineAction] 		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 ""	["version"]				(G.NoArg $ const printVersion)												"Print version-information & then exit.",+			G.Option "q"	["runQuickChecks"]			(G.NoArg $ const runQuickChecks)											"Run Quick-checks using arbitrary data & 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'.", 			G.Option ""	["factorialPerformanceGraph"]		(factorialPerformanceGraph `G.ReqArg` "Math.Implementations.Factorial.Algorithm")					"Test the performance of 'Math.Factorial.factorial', with an exponentially increasing operand.",@@ -99,11 +103,7 @@ 			G.Option ""	["primeFactorsPerformanceGraph"]	(primeFactorsPerformanceGraph `G.ReqArg` "(Math.Implementations.PrimeFactorisation.Algorithm, Int)")			"Test the performance of 'Math.PrimeFactorisation.primeFactors', on the specified number of odd integers from the Fibonacci-sequence.", 			G.Option ""	["primesPerformance"]			(primesPerformance `G.ReqArg` "(Math.Implementations.Primes.Algorithm.Algorithm, Int)")					"Test the performance of 'Math.Primes.primes'.", 			G.Option ""	["squareRootPerformance"]		(squareRootPerformance `G.ReqArg` "(Math.Implementations.SquareRoot.Algorithm, Data.Ratio.Rational, DecimalDigits)")	"Test the performance of 'Math.SquareRoot.squareRoot'.",-			G.Option ""	["squareRootPerformanceGraph"]		(squareRootPerformanceGraph `G.ReqArg` "(Math.Implementations.SquareRoot.Algorithm, Data.Ratio.Rational)")		"Test the performance of 'Math.SquareRoot.squareRoot', with an exponentially increasing precision-requirement.",-			G.Option ""	["verbose"]				(G.NoArg $ return {-to IO-monad-} . Test.CommandOptions.setVerbose)							("Provide additional information where available; default '" ++ show (Test.CommandOptions.verbose Defaultable.defaultValue) ++ "'."),-			G.Option ""	["version"]				(G.NoArg $ const printVersion)												"Print version-information & then exit.",-			G.Option "q"	["runQuickChecks"]			(G.NoArg $ const runQuickChecks)											"Run Quick-checks using arbitrary data & then exit.",-			G.Option "?"	["help"]				(G.NoArg $ const printUsage)												"Display this help-text & then exit."+			G.Option ""	["squareRootPerformanceGraph"]		(squareRootPerformanceGraph `G.ReqArg` "(Math.Implementations.SquareRoot.Algorithm, Data.Ratio.Rational)")		"Test the performance of 'Math.SquareRoot.squareRoot', with an exponentially increasing precision-requirement." 		 ] where 			printVersion, printUsage, runQuickChecks :: IO Test.CommandOptions.CommandOptions 			printVersion	= System.IO.hPutStrLn System.IO.stderr (Distribution.Text.display packageIdentifier ++ "\n\nCopyright (C) 2011 Dr. Alistair Ward.\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by Dr. Alistair Ward.")	>> System.Exit.exitWith System.Exit.ExitSuccess	where@@ -209,6 +209,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-} Defaultable.defaultValue) commandLineActions	>> System.Exit.exitWith System.Exit.ExitSuccess+		(commandLineActions, _, [])	-> Data.List.foldl' (>>=) (return {-to IO-monad-} ToolShed.Defaultable.defaultValue) commandLineActions	>> System.Exit.exitWith System.Exit.ExitSuccess 		(_, _, errors)			-> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usage	--Throw.