-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Rational arithmetic in an irrational world. -- -- A library of number-theory functions, for; factorials, square-roots, -- Pi, primality-testing, prime-factorisation ... @package factory @version 0.0.0.2 -- | module Factory.Math.Radix -- | digitSum :: (Integral base, Integral decimal) => base -> decimal -> decimal -- | http://en.wikipedia.org/wiki/Digital_root. digitalRoot :: Integral decimal => decimal -> decimal -- | fromBase :: (Integral base, Integral decimal, Read decimal) => base -> String -> decimal -- | toBase :: (Integral base, Integral decimal) => base -> decimal -> String -- | module Factory.Math.Implementations.Pi.BBP.Series -- | Defines a series corresponding to a specific BBP-formula. data Series MkSeries :: [Integer] -> (Int -> [Integer]) -> Rational -> Integer -> Series -- | The constant numerators from which each term in the series is -- composed. numerators :: Series -> [Integer] -- | Generates the term-dependent denominators from which each term in the -- series is composed. getDenominators :: Series -> Int -> [Integer] -- | The ratio by which the sum to infinity of the series, must be scaled -- to result in Pi. seriesScalingFactor :: Series -> Rational -- | The geometric ratio, by which successive terms are scaled. base :: Series -> Integer -- | module Factory.Math.Implementations.Pi.BBP.Bellard -- | Defines the parameters of this specific series. series :: Series -- | module Factory.Math.Implementations.Pi.BBP.Base65536 -- | Defines the parameters of this specific series. series :: Series -- | module Factory.Math.Summation -- | sum' :: (Num n, NFData n) => Int -> [n] -> n sumR' :: Integral i => [Ratio i] -> Ratio i -- | sumR :: (Integral i, NFData i) => Int -> [Ratio i] -> Ratio i -- | module Factory.Math.Fibonacci -- | A constant ordered list of the Fibonacci-numbers. fibonacci :: Integral i => [i] -- | primeIndexedFibonacci :: Integral i => [i] -- | -- -- module Factory.Math.Factorial -- | Defines the methods expected of a factorial-algorithm. class Algorithm algorithm factorial :: (Algorithm algorithm, Integral i) => algorithm -> i -> i -- | module Factory.Math.Precision -- | The order of convergence; -- http://en.wikipedia.org/wiki/Rate_of_convergence. type ConvergenceOrder = Int -- | The rate of convergence; -- http://en.wikipedia.org/wiki/Rate_of_convergence. type ConvergenceRate = Double -- | A number of decimal digits. type DecimalDigits = Int -- | Linear convergence-rate; which may be qualified by the rate -- of convergence. linearConvergence :: ConvergenceOrder -- | Quadratic convergence-rate. quadraticConvergence :: ConvergenceOrder -- | Cubic convergence-rate. cubicConvergence :: ConvergenceOrder -- | Quartic convergence-rate. quarticConvergence :: ConvergenceOrder -- | The predicted number of iterations, required to achieve a specific -- accuracy, at a given order of convergence. getIterationsRequired :: Integral i => ConvergenceOrder -> DecimalDigits -> DecimalDigits -> i -- | getTermsRequired :: Integral i => ConvergenceRate -> DecimalDigits -> i -- | Promotes the specified number, by a number of DecimalDigits. promote :: Num n => n -> DecimalDigits -> n -- | simplify :: RealFrac operand => DecimalDigits -> operand -> Rational -- | module Factory.Math.Pi -- | class Algorithm algorithm openR :: Algorithm algorithm => algorithm -> DecimalDigits -> Rational openI :: Algorithm algorithm => algorithm -> DecimalDigits -> Integer openS :: Algorithm algorithm => algorithm -> DecimalDigits -> String -- | Categorises the various algorithms. data Category agm bbp borwein ramanujan spigot -- | Algorithms based on the Arithmetic-geometric Mean. AGM :: agm -> Category agm bbp borwein ramanujan spigot -- | -- http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula. BBP :: bbp -> Category agm bbp borwein ramanujan spigot -- | http://en.wikipedia.org/wiki/Borwein%27s_algorithm. Borwein :: borwein -> Category agm bbp borwein ramanujan spigot -- | http://www.pi314.net/eng/ramanujan.php. Ramanujan :: ramanujan -> Category agm bbp borwein ramanujan spigot -- | Algorithms from which the digits of Pi slowly drip, one by one. Spigot :: spigot -> Category agm bbp borwein ramanujan spigot instance (Eq agm, Eq bbp, Eq borwein, Eq ramanujan, Eq spigot) => Eq (Category agm bbp borwein ramanujan spigot) instance (Read agm, Read bbp, Read borwein, Read ramanujan, Read spigot) => Read (Category agm bbp borwein ramanujan spigot) instance (Show agm, Show bbp, Show borwein, Show ramanujan, Show spigot) => Show (Category agm bbp borwein ramanujan spigot) instance (Algorithm agm, Algorithm bbp, Algorithm borwein, Algorithm ramanujan, Algorithm spigot) => Algorithm (Category agm bbp borwein ramanujan spigot) instance (Defaultable agm, Defaultable bbp, Defaultable borwein, Defaultable ramanujan, Defaultable spigot) => Defaultable (Category agm bbp borwein ramanujan spigot) -- | -- -- module Factory.Math.Implementations.Pi.BBP.Implementation -- | Returns Pi, accurate to the specified number of decimal digits. openR :: Series -> DecimalDigits -> Rational -- | module Factory.Math.Implementations.Pi.BBP.Algorithm -- | Defines those BBP-type series which have been implemented. data Algorithm -- | A base-2^16 version of the formula. Base65536 :: Algorithm -- | A nega-base 2^10 version of the formula. Bellard :: Algorithm instance Eq Algorithm instance Read Algorithm instance Show Algorithm instance Algorithm Algorithm instance Defaultable Algorithm -- | module Factory.Math.Implementations.Pi.Borwein.Series -- | Defines a series corresponding to a specific Borwein-formula. data Series squareRootAlgorithm factorialAlgorithm MkSeries :: (squareRootAlgorithm -> factorialAlgorithm -> DecimalDigits -> (Rational, [Rational])) -> ConvergenceRate -> Series squareRootAlgorithm factorialAlgorithm terms :: Series squareRootAlgorithm factorialAlgorithm -> squareRootAlgorithm -> factorialAlgorithm -> DecimalDigits -> (Rational, [Rational]) -- | The expected number of digits of Pi, per term in the series. convergenceRate :: Series squareRootAlgorithm factorialAlgorithm -> ConvergenceRate -- | module Factory.Math.Implementations.Pi.Borwein.Implementation -- | Returns Pi, accurate to the specified number of decimal digits. openR :: Series squareRootAlgorithm factorialAlgorithm -> squareRootAlgorithm -> factorialAlgorithm -> DecimalDigits -> Rational -- | module Factory.Math.Implementations.Pi.Ramanujan.Series -- | Defines a series corresponding to a specific Ramanujan-formula. data Series squareRootAlgorithm factorialAlgorithm MkSeries :: (factorialAlgorithm -> [Rational]) -> (squareRootAlgorithm -> DecimalDigits -> Rational) -> ConvergenceRate -> Series squareRootAlgorithm factorialAlgorithm -- | The sequence of terms, the sum to infinity of which defines the -- series. terms :: Series squareRootAlgorithm factorialAlgorithm -> factorialAlgorithm -> [Rational] -- | The ratio by which the sum to infinity of the sequence, must be scaled -- to result in Pi. getSeriesScalingFactor :: Series squareRootAlgorithm factorialAlgorithm -> squareRootAlgorithm -> DecimalDigits -> Rational -- | The expected number of digits of Pi, per term in the series. convergenceRate :: Series squareRootAlgorithm factorialAlgorithm -> ConvergenceRate -- | module Factory.Math.Implementations.Pi.Ramanujan.Implementation -- | Returns Pi, accurate to the specified number of decimal digits. openR :: Series squareRootAlgorithm factorialAlgorithm -> squareRootAlgorithm -> factorialAlgorithm -> DecimalDigits -> Rational -- | module Factory.Math.Implementations.Pi.Spigot.Series -- | data Series i MkSeries :: [i] -> [i] -> [i] -> (DecimalDigits -> Int) -> Series i coefficients :: Series i -> [i] baseNumerators :: Series i -> [i] baseDenominators :: Series i -> [i] -- | The width of the spigot-table, required to accurately generate the -- requested number of digits. nTerms :: Series i -> DecimalDigits -> Int -- | Combines baseNumerators and baseDenominators, and as a -- side-effect, expresses the ratio in lowest terms. bases :: Integral i => Series i -> [Ratio i] -- | module Factory.Math.Implementations.Pi.Spigot.Gosper -- | Defines a series which converges to Pi. series :: Integral i => Series i -- | module Factory.Math.Implementations.Pi.Spigot.RabinowitzWagon -- | Defines a series which converges to Pi. series :: Integral i => Series i -- | -- -- module Factory.Math.Implementations.Pi.Spigot.Spigot -- | The constant base in which we want the resulting value of Pi to -- be expressed. decimal :: I -- | openI :: Series I -> DecimalDigits -> Integer -- | module Factory.Math.Implementations.Pi.Spigot.Algorithm -- | Define those Spigot-algorithms which have been implemented. data Algorithm -- | A continued fraction discovered by Gosper. Gosper :: Algorithm -- | A continued fraction discovered by Rabinowitz and -- Wagon. RabinowitzWagon :: Algorithm instance Eq Algorithm instance Read Algorithm instance Show Algorithm instance Algorithm Algorithm instance Defaultable Algorithm -- | -- -- module Factory.Math.DivideAndConquer -- | type BisectionRatio = Ratio Int -- | The list-length beneath which to terminate bisection. type MinLength = Int -- | divideAndConquer :: Monoid monoid => BisectionRatio -> MinLength -> [monoid] -> monoid -- | product' :: Num n => BisectionRatio -> MinLength -> [n] -> n -- | sum' :: Num n => BisectionRatio -> MinLength -> [n] -> n -- | module Factory.Math.Power -- | Mainly for convenience. square :: Num n => n -> n -- | squaresFrom :: Num n => n -> [(n, n)] -- | maybeSquareNumber :: Integral i => i -> Maybe i -- | Just for convenience. cube :: Num n => n -> n -- | Just for convenience. cubeRoot :: Double -> Double -- | raiseModulo :: (Integral i, Integral power) => i -> power -> i -> i -- | isPerfectPower :: Integral i => i -> Bool -- | -- -- module Factory.Math.SquareRoot -- | Defines the methods expected of a square-root algorithm. class Algorithm algorithm squareRootFrom :: (Algorithm algorithm, Real operand) => algorithm -> Estimate -> DecimalDigits -> operand -> Result squareRoot :: (Algorithm algorithm, Real operand) => algorithm -> DecimalDigits -> operand -> Result -- | The interface required to iterate, from an estimate of the required -- value, to the next approximation. class Iterator algorithm step :: (Iterator algorithm, Real operand) => algorithm -> operand -> Result -> Result convergenceOrder :: Iterator algorithm => algorithm -> ConvergenceOrder -- | The result-type; actually, only the concrete return-type of -- simplify, stops it being a polymorphic instance of -- Fractional. type Result = Rational -- | Contains an estimate for the square-root of a value, and its -- accuracy. type Estimate = (Result, DecimalDigits) -- | getAccuracy :: Real operand => operand -> Result -> DecimalDigits -- | getDiscrepancy :: Real operand => operand -> Result -> Result -- | Uses Double-precision floating-point arithmetic, to obtain an -- initial estimate for the square-root, and its accuracy. getEstimate :: Real operand => operand -> Estimate -- | True if the specified estimate for the square-root, is -- precise. isPrecise :: Real operand => operand -> Result -> Bool -- | module Factory.Math.ArithmeticGeometricMean -- | The type of the arithmetic mean; -- http://en.wikipedia.org/wiki/Arithmetic_mean. type ArithmeticMean = Rational -- | The type of the geometric mean; -- http://en.wikipedia.org/wiki/Geometric_mean. type GeometricMean = Rational -- | Encapsulates both arithmetic and geometric means. type AGM = (ArithmeticMean, GeometricMean) -- | Returns an infinite list which converges on the -- Arithmetic-geometric mean. convergeToAGM :: Algorithm squareRootAlgorithm => squareRootAlgorithm -> DecimalDigits -> AGM -> [AGM] -- | Returns the bounds within which the AGM has been constrained. spread :: AGM -> Rational -- | Accessor. getArithmeticMean :: AGM -> ArithmeticMean -- | Accessor. getGeometricMean :: AGM -> GeometricMean -- | Checks that both means are positive, as required for the -- geometric mean to be consistently real. isValid :: AGM -> Bool -- | -- -- module Factory.Math.Primality -- | Defines the methods expected of a primality-algorithm. class Algorithm algorithm isPrime :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> i -> Bool -- | An ordered list of the Carmichael numbers; -- http://en.wikipedia.org/wiki/Carmichael_number. carmichaelNumbers :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> [i] -- | True if the two specified integers are relatively prime, -- i.e. if they share no common positive factors except one. -- -- areCoprime :: Integral i => i -> i -> Bool -- | isFermatWitness :: Integral i => i -> Bool -- | isCarmichaelNumber :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> i -> Bool -- | -- -- -- -- module Factory.Math.Implementations.Pi.AGM.BrentSalamin -- | -- --
--   pi = (a[N-1] + g[N-1])^2 / (1 - sum [2^n * (a[n] - g[n])^2])			where n = [0 .. N-1]
--   => 4*a[N]^2 / (1 - sum [2^n * (a[n]^2 - 2*a[n]*g[n] + g[n]^2)])
--   => 4*a[N]^2 / (1 - sum [2^n * (a[n]^2 + 2*a[n]*g[n] + g[n]^2 - 4*a[n]*g[n])])
--   => 4*a[N]^2 / (1 - sum [2^n * ((a[n] + g[n])^2 - 4*a[n]*g[n])])
--   => 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 :: Algorithm squareRootAlgorithm => squareRootAlgorithm -> DecimalDigits -> Rational -- | module Factory.Math.Implementations.Pi.AGM.Algorithm -- | Defines the available algorithms. data Algorithm squareRootAlgorithm BrentSalamin :: squareRootAlgorithm -> Algorithm squareRootAlgorithm instance Eq squareRootAlgorithm => Eq (Algorithm squareRootAlgorithm) instance Read squareRootAlgorithm => Read (Algorithm squareRootAlgorithm) instance Show squareRootAlgorithm => Show (Algorithm squareRootAlgorithm) instance Algorithm squareRootAlgorithm => Algorithm (Algorithm squareRootAlgorithm) instance Defaultable squareRootAlgorithm => Defaultable (Algorithm squareRootAlgorithm) -- | -- -- module Factory.Data.Ring -- | class Ring r (=+=) :: Ring r => r -> r -> r (=*=) :: Ring r => r -> r -> r additiveInverse :: Ring r => r -> r multiplicativeIdentity :: Ring r => r additiveIdentity :: Ring r => r (=-=) :: Ring r => r -> r -> r square :: Ring r => r -> r -- | Returns the product of the list of ring-members. product' :: Ring r => BisectionRatio -> MinLength -> [r] -> r -- | Returns the sum of the list of ring-members. sum' :: Ring r => BisectionRatio -> MinLength -> [r] -> r -- | (=^) :: (Ring r, Eq r, Integral power) => r -> power -> r instance Read p => Read (Product p) instance Show p => Show (Product p) instance Read s => Read (Sum s) instance Show s => Show (Sum s) instance Ring r => Monoid (Sum r) instance Ring r => Monoid (Product r) -- | -- -- module Factory.Data.QuotientRing -- | Defines a sub-class of Ring, in which division is implemented. class Ring q => QuotientRing q quotRem' :: QuotientRing q => q -> q -> (q, q) -- | Returns the quotient, after division of the two specified -- QuotientRings. quot' :: QuotientRing q => q -> q -> q -- | Returns the remainder, after division of the two specified -- QuotientRings. rem' :: QuotientRing q => q -> q -> q -- | areCongruentModulo :: (Eq q, QuotientRing q) => q -> q -> q -> Bool -- | True if the second operand divides the first. isDivisibleBy :: (Eq q, QuotientRing q) => q -> q -> Bool -- | -- -- module Factory.Data.Monomial -- | type Monomial coefficient exponent = (coefficient, exponent) -- | Double the specified Monomial. double :: Num c => Monomial c e -> Monomial c e -- | Reduce the coefficient using modular arithmetic. mod' :: Integral c => Monomial c e -> c -> Monomial c e -- | Negate the coefficient. negateCoefficient :: Num c => Monomial c e -> Monomial c e -- | Convert the type of the coefficient. realCoefficientToFrac :: (Real r, Fractional f) => Monomial r e -> Monomial f e -- | Shift the coefficient, by the specified amount. shiftCoefficient :: Num c => Monomial c e -> c -> Monomial c e -- | Shift the exponent, by the specified amount. shiftExponent :: Num e => Monomial c e -> e -> Monomial c e -- | Square the specified Monomial. square :: (Num c, Num e) => Monomial c e -> Monomial c e -- | Accessor. getExponent :: Monomial c e -> e -- | Accessor. getCoefficient :: Monomial c e -> c -- | Compares the exponents of the specified Monomials. (<=>) :: Ord e => Monomial c e -> Monomial c e -> Ordering -- | Divide the two specified Monomials. () :: (Fractional c, Num e) => Monomial c e -> Monomial c e -> Monomial c e -- | Multiply the two specified Monomials. (<*>) :: (Num c, Num e) => Monomial c e -> Monomial c e -> Monomial c e -- | True if the exponents are equal. (=~) :: Eq e => Monomial c e -> Monomial c e -> Bool -- | isMonomial :: Integral e => Monomial c e -> Bool -- | -- -- module Factory.Data.Polynomial -- | data Polynomial coefficient exponent -- | Constructs a polynomial with zero terms. zero :: Polynomial c e -- | Constructs a constant monomial, independent of the -- indeterminate. one :: (Num c, Num e) => Polynomial c e -- | evaluate :: (Num n, Integral e) => n -> Polynomial n e -> n -- | getDegree :: Num e => Polynomial c e -> e -- | Return the highest-degree monomial. getLeadingTerm :: Polynomial c e -> Monomial c e -- | lift :: (MonomialList c1 e1 -> MonomialList c2 e2) -> Polynomial c1 e1 -> Polynomial c2 e2 -- | Reduces all the coefficients using modular arithmetic. mod' :: Integral c => Polynomial c e -> c -> Polynomial c e -- | Sorts into descending order of exponents, groups like -- exponents, and calls pruneCoefficients. normalise :: (Num c, Ord e) => Polynomial c e -> Polynomial c e -- | raiseModulo :: (Integral c, Integral power, Num e, Ord e) => Polynomial c e -> power -> c -> Polynomial c e -- | Convert the type of the coefficients. realCoefficientsToFrac :: (Real r, Fractional f) => Polynomial r e -> Polynomial f e -- | Returns the number of non-zero terms in the polynomial. terms :: Polynomial c e -> Int -- | Constructs an arbitrary zeroeth-degree polynomial, ie. -- independent of the indeterminate. mkConstant :: (Num c, Num e) => c -> Polynomial c e -- | Constructs an arbitrary first-degree polynomial. mkLinear :: (Num c, Num e) => c -> c -> Polynomial c e -- | Constructs an arbitrary polynomial. mkPolynomial :: (Num c, Ord e) => MonomialList c e -> Polynomial c e -- | (*=) :: (Num c, Num e) => Polynomial c e -> Monomial c e -> Polynomial c e -- | areCongruentModulo :: (Integral c, Num e, Ord e) => Polynomial c e -> Polynomial c e -> c -> Bool -- | True if the exponents of successive terms are in -- ascending order. inAscendingOrder :: Ord e => Polynomial c e -> Bool -- | True if the exponents of successive terms are in -- descending order. inDescendingOrder :: Ord e => Polynomial c e -> Bool -- | isMonic :: Num c => Polynomial c e -> Bool -- | True if there's exactly one term. isMonomial :: Polynomial c e -> Bool -- | 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 -- | True if all exponents are positive integers as -- required. isPolynomial :: Integral e => Polynomial c e -> Bool -- | True if there are zero terms. isZero :: Polynomial c e -> Bool instance (Eq coefficient, Eq exponent) => Eq (Polynomial coefficient exponent) instance (Show coefficient, Show exponent) => Show (Polynomial coefficient exponent) instance (Fractional c, Num e, Ord e) => QuotientRing (Polynomial c e) instance (Num c, Num e, Ord e) => Ring (Polynomial c e) -- | -- -- module Factory.Data.MonicPolynomial -- | A type of Polynomial, in which the leading term is -- required to have a coefficient of one. data MonicPolynomial c e -- | Constructs an arbitrary monic polynomial. mkMonicPolynomial :: (Num c, Ord e, Show e) => Polynomial c e -> MonicPolynomial c e instance (Eq c, Eq e) => Eq (MonicPolynomial c e) instance (Show c, Show e) => Show (MonicPolynomial c e) instance (Num c, Num e, Ord e) => QuotientRing (MonicPolynomial c e) instance (Num c, Num e, Ord e, Show e) => Ring (MonicPolynomial c e) -- | -- -- module Factory.Data.Exponential -- | Describes an exponential, in terms of its base and -- exponent. type Exponential base exponent = (base, exponent) -- | Evaluate the specified Exponential, returning the resulting -- number. evaluate :: (Num base, Integral exponent) => Exponential base exponent -> base -- | Invert the value, by negating the exponent. invert :: Num exponent => Exponential base exponent -> Exponential base exponent -- | Accessor. getBase :: Exponential base exponent -> base -- | Accessor. getExponent :: Exponential base exponent -> exponent -- | rightIdentity :: Num exponent => base -> Exponential base exponent -- | Raise the specified Exponential to a power. (<^) :: Num exponent => Exponential base exponent -> exponent -> Exponential base exponent -- | True if the bases are equal. (=~) :: Eq base => Exponential base exponent -> Exponential base exponent -> Bool -- | -- -- module Factory.Data.PrimeFactors -- | type Factors base exponent = [Exponential base exponent] -- | insert' :: (Ord base, Num exponent) => Exponential base exponent -> Factors base exponent -> Factors base exponent -- | Multiply a list of prime factors. product' :: (Num base, Integral exponent) => BisectionRatio -> MinLength -> Factors base exponent -> base -- | reduce :: (Ord base, Num exponent, Ord exponent) => Factors base exponent -> Factors base exponent -- | (>*<) :: (Ord base, Num exponent, Ord exponent) => Factors base exponent -> Factors base exponent -> Factors base exponent -- | (>/<) :: (Integral base, Integral exponent) => Factors base exponent -> Factors base exponent -> (Factors base exponent, Factors base exponent) -- | (>^) :: Num exponent => Factors base exponent -> exponent -> Factors base exponent -- | -- -- module Factory.Math.PrimeFactorisation -- | Defines the methods expected of a factorisation-algorithm. class Algorithm algorithm primeFactors :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> base -> Factors base Int -- | maxBoundPrimeFactor :: Integral i => i -> i -- | smoothness :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base] -- | powerSmoothness :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base] -- | regularNumbers :: (Algorithm algorithm, NFData base, Integral base) => algorithm -> [base] -- | primePowerTotient :: (Integral base, Integral exponent) => Exponential base exponent -> base -- | eulersTotient :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> i -> i -- | omega :: (Algorithm algorithm, NFData i, Integral i) => algorithm -> [i] -- | module Factory.Math.MultiplicativeOrder -- | multiplicativeOrder :: (Algorithm primeFactorisationAlgorithm, NFData i, Integral i) => primeFactorisationAlgorithm -> i -> i -> i -- | -- -- module Factory.Math.Implementations.Primality -- | The algorithms by which primality-testing has been implemented. data Algorithm factorisationAlgorithm -- | http://en.wikipedia.org/wiki/AKS_primality_test. AKS :: factorisationAlgorithm -> Algorithm factorisationAlgorithm -- | -- http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test. MillerRabin :: Algorithm factorisationAlgorithm instance Eq factorisationAlgorithm => Eq (Algorithm factorisationAlgorithm) instance Read factorisationAlgorithm => Read (Algorithm factorisationAlgorithm) instance Show factorisationAlgorithm => Show (Algorithm factorisationAlgorithm) instance Algorithm factorisationAlgorithm => Algorithm (Algorithm factorisationAlgorithm) instance Defaultable (Algorithm factorisationAlgorithm) -- | -- -- module Factory.Math.Implementations.PrimeFactorisation -- | The algorithms by which prime-factorisation has been implemented. data Algorithm -- | http://en.wikipedia.org/wiki/Fermat%27s_factorization_method. FermatsMethod :: Algorithm -- | http://en.wikipedia.org/wiki/Trial_division. TrialDivision :: Algorithm instance Eq Algorithm instance Read Algorithm instance Show Algorithm instance Algorithm Algorithm instance Defaultable Algorithm -- | -- -- -- -- -- -- module Factory.Data.Bounds -- | Defines a range of consecutive values, bracketed by inclusive -- bounds. type Bounds limit = (limit, limit) -- | True if the specified value is within the inclusive -- Bounds. elem' :: Ord limit => limit -> Bounds limit -> Bool -- | The length of toList. length' :: (Num limit, Ord limit) => Bounds limit -> limit -- | Swap the limits where they were originally reversed, but otherwise do -- nothing. normalise :: Ord limit => Bounds limit -> Bounds limit -- | product' :: Integral i => Ratio i -> i -> Bounds i -> i -- | Bisect the bounds at the specified limit; which should be between the -- two existing limits. splitAt' :: (Num limit, Ord limit) => limit -> Bounds limit -> (Bounds limit, Bounds limit) -- | Converts Bounds to a list by enumerating the values. toList :: Enum limit => Bounds limit -> [limit] -- | Accessor. minBound' :: Bounds a -> a -- | Accessor. maxBound' :: Bounds a -> a -- | -- -- module Factory.Math.Implementations.Factorial -- | The algorithms by which factorial has been implemented. data Algorithm -- | The integers from which the factorial is composed, are -- multiplied using Data.Bounds.product'. Bisection :: Algorithm -- | The prime factors of the factorial are extracted, then -- raised to the appropriate power, before multiplication. PrimeFactorisation :: Algorithm -- | primeFactors :: Integral base => base -> Factors base base -- | Returns the rising factorial; -- http://mathworld.wolfram.com/RisingFactorial.html risingFactorial :: Integral i => i -> i -> i -- | Returns the falling factorial; -- http://mathworld.wolfram.com/FallingFactorial.html fallingFactorial :: Integral i => i -> i -> i -- | (!/!) :: (Integral i, Fractional f) => i -> i -> f instance Eq Algorithm instance Read Algorithm instance Show Algorithm instance Algorithm Algorithm instance Defaultable Algorithm -- | -- -- Caller may benefit from application of simplify before -- operating on the result; which though of the required accuracy, may -- not be the most concise rational number satisfying that criterion. module Factory.Math.Implementations.SquareRoot -- | The number of terms in a series. type Terms = Int -- | The algorithms by which the square-root has been implemented. data Algorithm -- | -- http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Bakhshali_approximation BakhshaliApproximation :: Algorithm -- | -- http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion. ContinuedFraction :: Algorithm -- | http://en.wikipedia.org/wiki/Halley%27s_method. HalleysMethod :: Algorithm -- | http://en.wikipedia.org/wiki/Newton%27s_method. NewtonRaphsonIteration :: Algorithm -- | -- http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series. TaylorSeries :: Terms -> Algorithm instance Eq Algorithm instance Read Algorithm instance Show Algorithm instance Iterator Algorithm instance Algorithm Algorithm instance Defaultable Algorithm -- | module Factory.Math.Implementations.Pi.Borwein.Borwein1993 -- | Defines the parameters of the Borwein series. series :: (Algorithm squareRootAlgorithm, Algorithm factorialAlgorithm) => Series squareRootAlgorithm factorialAlgorithm -- | module Factory.Math.Implementations.Pi.Borwein.Algorithm -- | data Algorithm squareRootAlgorithm factorialAlgorithm -- | http://en.wikipedia.org/wiki/Borwein%27s_algorithm. Borwein1993 :: squareRootAlgorithm -> factorialAlgorithm -> Algorithm squareRootAlgorithm factorialAlgorithm instance (Eq squareRootAlgorithm, Eq factorialAlgorithm) => Eq (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Read squareRootAlgorithm, Read factorialAlgorithm) => Read (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Show squareRootAlgorithm, Show factorialAlgorithm) => Show (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Algorithm squareRootAlgorithm, Algorithm factorialAlgorithm) => Algorithm (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Defaultable squareRootAlgorithm, Defaultable factorialAlgorithm) => Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm) -- | module Factory.Math.Implementations.Pi.Ramanujan.Chudnovsky -- | Defines the parameters of the Chudnovsky series. series :: (Algorithm squareRootAlgorithm, Algorithm factorialAlgorithm) => Series squareRootAlgorithm factorialAlgorithm -- | module Factory.Math.Implementations.Pi.Ramanujan.Classic -- | Defines the parameters of the Ramanujan series. series :: (Algorithm squareRootAlgorithm, Algorithm factorialAlgorithm) => Series squareRootAlgorithm factorialAlgorithm -- | module Factory.Math.Implementations.Pi.Ramanujan.Algorithm -- | Define those Ramanujan-series which have been implemented. data Algorithm squareRootAlgorithm factorialAlgorithm -- | The original version. Classic :: squareRootAlgorithm -> factorialAlgorithm -> Algorithm squareRootAlgorithm factorialAlgorithm -- | A variant found by the Chudnovsky brothers. Chudnovsky :: squareRootAlgorithm -> factorialAlgorithm -> Algorithm squareRootAlgorithm factorialAlgorithm instance (Eq squareRootAlgorithm, Eq factorialAlgorithm) => Eq (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Read squareRootAlgorithm, Read factorialAlgorithm) => Read (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Show squareRootAlgorithm, Show factorialAlgorithm) => Show (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Algorithm squareRootAlgorithm, Algorithm factorialAlgorithm) => Algorithm (Algorithm squareRootAlgorithm factorialAlgorithm) instance (Defaultable squareRootAlgorithm, Defaultable factorialAlgorithm) => Defaultable (Algorithm squareRootAlgorithm factorialAlgorithm) -- | module Factory.Math.Statistics -- | Determines the http://en.wikipedia.org/wiki/Mean of the -- supplied numbers. mean :: (Real r, Fractional f) => [r] -> f -- | The number of unordered combinations of r objects taken from -- n; http://en.wikipedia.org/wiki/Combination. nCr :: (Algorithm factorialAlgorithm, Integral i) => factorialAlgorithm -> i -> i -> i -- | The number of permutations of r objects taken from n; -- http://en.wikipedia.org/wiki/Permutations. nPr :: Integral i => i -> i -> i